Skip to content

Conversation

@michaelxu01
Copy link
Contributor

@michaelxu01 michaelxu01 commented Jan 15, 2026

  • Added line and affine correction
  • added output plot option for scan_update to compare current iteration to initial scan (need to add .h5 load/save for initial scan positions)
  • refactored scan from array to object
  • updated h5 to include scan positions and any metadata in a dictionary

This has been rebased on latest probe aberration merge. Still need to update and test conventional solvers

Example: affine-only updates after 800 iterations for an experiment:
image

@hexane360
Copy link
Owner

Sorry, I think this needs another rebase. LMK if you need help with it. Also, can you fix the tests? It should be as simple as changing the scan access. We should probably also take a look at the conventional engines before merge, shouldn't be too difficult.

# cast = to_real_dtype(sim.object.data.dtype)
xp = get_array_module(sim.scan.data)
update = xp.zeros_like(sim.scan.data, dtype=sim.scan.data.dtype)
for kind, weight in self.constraints.items():
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this deterministic? It seems like it could apply the updates in arbitrary order, we may want to add sorted() if it matters

Copy link
Contributor Author

@michaelxu01 michaelxu01 Jan 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be deterministic, since the updates are summed and applied after each kind * weight is calculated from the common unconstrained update and previous scan state. Example:
update += scan_affine(sim.scan.data, state.previous) * weight


cost = xp.sum(xp.abs(sim.object.data - 1.0))
cost_scale = xp.array(group.shape[-1] / prod(sim.scan.shape[:-1]), dtype=cost.dtype)
cost_scale = xp.array(group.shape[-1] / prod(sim.scan.data.shape[:-1]), dtype=cost.dtype)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe unnecessary for this PR, but we could probably make n_pos() a method of sim.scan to avoid this repetition


## FIXME: output to Tuple? importance of array number types

@t.overload
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't love this API, not sure what would be better. Maybe output ScanState directly? Or maybe better, keep make_raster_scan clean and include the metadata in the hook only

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm in favor of outputting to ScanState directly.
The grid would need to be re-calculated if not included here, but maybe it would be fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants