astropy / astropy-healpix

BSD-licensed HEALPix for Astropy - maintained by @astrofrog and @lpsinger
https://astropy-healpix.readthedocs.io
BSD 3-Clause "New" or "Revised" License
50 stars 22 forks source link

Support strings for frame in HEALPix class #56

Open astrofrog opened 6 years ago

astrofrog commented 6 years ago

We should try and re-use the frame-parsing machinery from Astropy to make it so we can use:

hp = HEALPix(nside=4, order='ring', frame='galactic')

(like in SkyCoord)

cdeil commented 6 years ago

👍

This is one thing I'm missing in https://github.com/hipspy/hips/pull/109 , trying to use astropy-healpix for hips. I'll implement some utility function there now, but having direct support for frame={‘icrs’, ‘galactic’, ‘ecliptic’}would be great (I haven't encountered ecliptic so far, but the other two are common).

cdeil commented 6 years ago

This is the make_frame helper function I'm using in hips for now: https://github.com/hipspy/hips/pull/109/files#diff-82f8d9d870d0601c2c9452cdd650e703R207

astrofrog commented 6 years ago

This should be easy to do with:

In [1]: from astropy.coordinates import frame_transform_graph

In [3]: frame_transform_graph.lookup_name('galactic')
Out[3]: astropy.coordinates.builtin_frames.galactic.Galactic
astrofrog commented 6 years ago

(This could replace make_frame)

cdeil commented 6 years ago

I don't know ... this silently fails (returns None):

frame_transform_graph.lookup_name('spam')

For now I'll stick with my helper function.

astrofrog commented 6 years ago

We could easily check for None output though and raise an exception in that case? (for here, not hips). I'll open an issue to Astropy to add an option to raise an exception if the frame is not known.

cdeil commented 6 years ago

Yes, maybe that would be the way to go here.

I think the hard part will be to have a sane way to handle frame for FITS I/O for HEALPix maps. There only a small subset of frames will be supported, so at that point something custom like the helper function I have now in hipspy or what you have in reproject is needed.

I guess a good strategy is to allow HEALPix objects with any frame for in-memory computations, and only to apply the checks on valid subset on FITS I/O?

astrofrog commented 6 years ago

I guess a good strategy is to allow HEALPix objects with any frame for in-memory computations, and only to apply the checks on valid subset on FITS I/O?

I agree with this! The HEALPix class itself should not have restrictions, whereas once we write the FITS readers/writers, those should have validation of COORDSYS.