Draft: Use reproject for image registration

Will Barnes requested to merge wtbarnes/aiapy:reproject-aiaprep into main

Fixes #125

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...
Edited by Will Barnes

Merge request reports