Open keflavich opened 8 years ago
Thanks, I was vaguely aware of radio_beam and at some point it would probably be useful to see whether it does everything I need (I have an extensive collection of test cases contributed by radioflux users) and if so adopt it (and if not, try to push the changes I need into it).
I was not aware of the spectral-cube package till it was mentioned over in the pyregion issue. That almost certainly offers a more maintainable way of dealing with cube headers than my current one (which does however seem to work for all common radio formats).
First thing to do is to see if using pyregion with the celestial WCS works, because if so my problem with dealing with cubes becomes 'find a frequency axis if there is one and do something sensible with it' rather than 'find a frequency axis while trying to flatten to a set of 2D images'.
I just wanted to bring your attention to the spectral-cube and radio-beam packages, which seem to have significant overlap with what you're doing here.
In particular,
radio_beam
contains a lot of the header-parsing machinery (and translation to astropy units) used in yourradiomap
class.For header flattening, you might make use of https://github.com/keflavich/FITS_tools/blob/master/FITS_tools/strip_headers.py#L3. I feel that both our approaches are 'hacks' to some degree, though. The appropriate approach is often to use
mywcs.sub([wcs.WCSSUB_CELESTIAL])
ormywcs.celestial
to access the celestial WCS and not worry about the header, though this isn't always adequate.