Open DanRyanIrish opened 10 months ago
ping @jmason86 @Cadair
I think these 3 functions would solve your problem @jmason86 and should not be an unreasonable amount of work. Your SunCET pipeline could then use NDCube
natively and be significantly simplified. And you could write the end product our to FITS in only a couple of lines of code.
While I think writing the convert-back-to-fits functionality is good and should be done, I think there's a better way of doing this holistically.
Ideally, when constructing a low level wrapper, the wrapper class should see if it can modify the input WCS rather than return an instance of itself. Ideally (I think), this would be dispatched out to the input WCS (i.e WCS._resample_wcs
) which could return NotImplemented
if the operation can not be done on that particular WCS.
I think this would be a good addition to the APE 14 API to extend it into analysis operations.
Describe the feature
ndcube
only requires that its WCS is APE-14 compliant and is agnostic to the underlying WCS implementation. However, many users want to write theirNDCube
out to FITS. However, even if anNDCube
starts with a FITS-WCS, certain operations will cause the WCS to be wrapped in an APE-14-compliant wrapper that cannot itself be read back to FITS. However, for many of these wrappers, it should be possible to reconstruct a FITS-WCS by combining the wrapper information with the original underlying FITS-WCS. This will enable users to write their modifiedNDCube
out to FITS.Currently, there are only two
NDCube
operations that will produce a WCS wrapper:SlicedLowLevelWCS
)ResampledWCS
)Aside
NDCube.reproject_to
will also replace the WCS. However, the WCS is provided by the user and so the user can ensure that the new WCS is FITS-WCS.Proposed solution
This issue proposes a set of functions to live in a new module in the
ndcube.wcs
sunpackage. These can be applied to theNDCube.wcs
by the user to produce a new FITS-WCS. The user can then use this new FITS WCS to write theirNDCube
out to a FITS file.The functions should be:
unravel_wcs_wrappers_to_fitswcs
TypeError
NDCube
.TypeError
is an unsupported wrapper type if found.slice_fitswcs
tuple
of slice items/int
in pixel order and a FITS-WCS and alters theCRPIX
values of the FITS-WCS.int
is given, then that axis is dropped, and so all FITS-keywords for that axis (e.g.CRPIX1
,CRVAL1
, etc.) must be deleted, and the names of keywords for following axes have their numbers decremented.CDELT
andCRPIX
keywords as necessary.unravel_wcs_wrappers_to_fitswcs