Skip to content

Commit

Permalink
Merge pull request #317 from carterbox/log-affine
Browse files Browse the repository at this point in the history
NEW: Add affine transformation to INFO logging output
  • Loading branch information
carterbox authored Jun 10, 2024
2 parents 30e2a80 + 56b0ddd commit 7d3559e
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/tike/ptycho/position.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,8 +180,8 @@ def fromarray(self, T: np.ndarray) -> AffineTransform:
scale1=float(scale1),
shear1=float(shear1),
angle=float(angle),
t0=T[2, 0],
t1=T[2, 1],
t0=T[2, 0] if T.shape[0] > 2 else 0,
t1=T[2, 1] if T.shape[0] > 2 else 0,
)

def asarray(self, xp=np) -> np.ndarray:
Expand Down
26 changes: 26 additions & 0 deletions src/tike/ptycho/ptycho.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,20 @@ def reconstruct(
use_mpi,
) as context:
context.iterate(parameters.algorithm_options.num_iter)

if (
logger.getEffectiveLevel() <= logging.INFO
) and context.parameters.position_options:
mean_scaling = 0.5 * (
context.parameters.position_options.transform.scale0
+ context.parameters.position_options.transform.scale1
)
logger.info(
f"Global scaling of {mean_scaling:.3e} detected from position correction."
" Probably your estimate of photon energy and/or sample to detector "
"distance is off by that amount."
)

return context.parameters


Expand Down Expand Up @@ -921,6 +935,18 @@ def reconstruct_multigrid(
context.iterate(resampled_parameters.algorithm_options.num_iter)

if level == 0:
if (
logger.getEffectiveLevel() <= logging.INFO
) and context.parameters.position_options:
mean_scaling = 0.5 * (
context.parameters.position_options.transform.scale0
+ context.parameters.position_options.transform.scale1
)
logger.info(
f"Global scaling of {mean_scaling:.3e} detected from position correction."
" Probably your estimate of photon energy and/or sample to detector "
"distance is off by that amount."
)
return context.parameters

# Upsample result to next grid
Expand Down

0 comments on commit 7d3559e

Please sign in to comment.