Skip to content

Commit

Permalink
Merge pull request #81 from AdvancedPhotonSource/coordinate-transform
Browse files Browse the repository at this point in the history
BUG: Correct coordinate transform between tike and ptychodus
  • Loading branch information
carterbox authored May 7, 2024
2 parents 1a8beb1 + 42e927e commit 9242fe7
Showing 1 changed file with 11 additions and 12 deletions.
23 changes: 11 additions & 12 deletions ptychodus/model/tike/reconstructor.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,10 @@ def __call__(self, parameters: ReconstructInput,
scanInputCoords.append(objectPoint.y + uy)
scanInputCoords.append(objectPoint.x + ux)

scanInputArray = numpy.array(scanInputCoords,
dtype=numpy.float32).reshape(len(scanInput), 2)
scanInputArray = numpy.array(
scanInputCoords,
dtype=numpy.float32,
).reshape(len(scanInput), 2)
scanMin = scanInputArray.min(axis=0)
scanMax = scanInputArray.max(axis=0)
logger.debug(f'Scan range [px]: {scanMin} -> {scanMax}')
Expand Down Expand Up @@ -184,18 +186,15 @@ def __call__(self, parameters: ReconstructInput,

logger.debug(f'Result: {pprint.pformat(result)}')

if self._positionCorrectionSettings.usePositionCorrection.value:
scanOutputPoints: list[ScanPoint] = list()
scanOutputPoints: list[ScanPoint] = list()

for uncorrectedPoint, xy in zip(scanInput, result.scan):
objectPoint = Point2D(x=xy[1], y=xy[0])
point = objectGeometry.mapObjectPointToScanPoint(objectPoint)
scanPoint = ScanPoint(uncorrectedPoint.index, point.x, point.y)
scanOutputPoints.append(scanPoint)
for uncorrectedPoint, xy in zip(scanInput, result.scan):
objectPoint = Point2D(x=xy[1] - ux, y=xy[0] - uy)
point = objectGeometry.mapObjectPointToScanPoint(objectPoint)
scanPoint = ScanPoint(uncorrectedPoint.index, point.x, point.y)
scanOutputPoints.append(scanPoint)

scanOutput = Scan(scanOutputPoints)
else:
scanOutput = scanInput.copy()
scanOutput = Scan(scanOutputPoints)

if self._probeCorrectionSettings.useProbeCorrection.value:
probeOutput = Probe(
Expand Down

0 comments on commit 9242fe7

Please sign in to comment.