Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use reproject for image registration #317

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

wtbarnes
Copy link
Contributor

@wtbarnes wtbarnes commented Nov 1, 2023

Fixes #112

This is a first pass at using the reproject package to perform image registration by constructing a WCS for the aligned, translated, and scaled image and reprojecting the input map into that new WCS. This also now works for submaps. Note that this does not add a dependency as reproject is an optional dependency of sunpy that we already pick up by requiring sunpy[map].

I've marked this as a draft because it still needs quite a bit of cleaning up and I'd like several pairs of eyes on it before we even think about merging (if we do at all).

There is also the issue of performance. This is markedly slower for full-disk images by an OOM.

In [22]: %%timeit
    ...: m_l15_cutout = aiapy.calibrate.prep.register_reproject(m_l1_cutout)
1.6 s ± 15.2 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)

In [23]: %%timeit
    ...: m_l15 = aiapy.calibrate.prep.register_reproject(m_l1)
33.5 s ± 749 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)

In [24]: %%timeit
    ...: m_l15 = aiapy.calibrate.prep.register(m_l1)
WARNING: SunpyUserWarning: Integer input data has been cast to float64. [sunpy.image.transform]
3.34 s ± 10.5 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)

However, this version does have the advantage that prep on submaps is possible. Additionally, reproject offers several different algorithms for performing the actual reprojection and there are proposed performance improvements.. There is also progress being made on parallelizing the map_coordinates function with Dask which is the underlying scipy function called by reproject_interp. There's also a cupy version of map_coordinates.

All my comments above are assuming that the performance bottleneck is the map_coordinates function, i.e. the actual interpolation of the array onto the new coordinates. While this is almost certainly true, it should be confirmed with some profiling.

Some TODOs:

  • Fix up docstring
  • Fix tests--need a submap test and to remove/modify some of our existing tests.
  • Changelog
  • Quantitative comparisons with our current version of register
  • Comparisons to aiaprep in SSW?
  • Performance...

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.

Refactor calibrate.register to use reproject
1 participant