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

Representing a HEALPix map with data #57

Open
astrofrog opened this issue Oct 2, 2017 · 6 comments
Open

Representing a HEALPix map with data #57

astrofrog opened this issue Oct 2, 2017 · 6 comments

Comments

@astrofrog
Copy link
Member

astrofrog commented Oct 2, 2017

At the moment, the HEALPix class doesn't include data internally, and instead data should be passed when interpolating. However, it would be nice to be able to represent a HEALPix map including potentially multiple fields, so that we can easily read/write from/to e.g. HEALPix FITS files.

Here is an idea of how to do this (but looking for feedback): we change __init__ on HEALPix so as to optionally also accept a data argument. This can be either a single data array or a dict-like object of arrays (which can include Table). Then when interpolating, if there is a single array, then that array gets interpolated, otherwise a dictionary of interpolated values will be returned (and there could be an option to specify the field to interpolate to save computing time).

We can then use the Astropy I/O registry to register FITS readers/writers (which could also take HDU objects).

@woodmd @cdeil - any thoughts on this?

@woodmd
Copy link

woodmd commented Oct 2, 2017

Sounds reasonable to me although I would go for a tuple rather than a dict argument.

With respect to FITS I/O it would be nice if this would support the HEALPix format conventions that we created for gamma-ray analysis:
http://gamma-astro-data-formats.readthedocs.io/en/latest/skymaps/healpix/index.html

Here we also have the concept of a partial-sky HEALPix map where we define the geometry of the map with a HPX_REG string that we write to the FITS header. Right now we've only defined disk and single pixel geometries but one could also define more complicated geometries (square or arbitrary list of healpix pixels). Do you think it would be feasible to add support for partial-sky maps in this package?

@astrofrog
Copy link
Member Author

Sounds reasonable to me although I would go for a tuple rather than a dict argument.

Do you mean a named tuple or really just a tuple? (the issue with tuple would be that we'd lose the field names from the FITS table).

Regarding partial maps, I think it would be fine to include here (depending on the amount of code overhead)

@woodmd
Copy link

woodmd commented Oct 4, 2017

Ah I see you intended that each element would map to a column. I would still prefer something that allows tuple-like access (i.e. by index) so I guess named tuple might be a good compromise.

For the partial maps the overhead should be fairly small. What we should try to decide now is what convention to use for specifying the geometry of a partial-sky map. In the gamma-astro-data-formats spec we use a string so one option would be to add an optional string argument to all methods that can accept a partial sky map.

@astrofrog
Copy link
Member Author

Thinking about this more, a named tuple won't work because some column names aren't necessarily valid Python names.

Could you provide an example file that you'd like to use and show how you would expect the index access to behave? Just to clarify, in some cases HEALPIX maps have a single column, e.g. TEMPERATURE, which is the a vector column - I'm suggesting this would be one field in a dictionary and that you would then indeed use item access to access rows/columns of that field. In my mind it doesn't make sense to access e.g. TEMPERATURE using an index since it would be far more reliable to simply use TEMPERATURE in case the number/order of columns changes in future.

Just to clarify, if I have a file with one column which is then a vector column,

@cdeil cdeil modified the milestones: 0.2, 0.3 Oct 17, 2017
@woodmd
Copy link

woodmd commented Oct 23, 2017

In gamma-ray applications we often have columns which correspond to image planes of a higher dimensional data structure -- for instance a cube where the third axis is energy. In that case we usually name the columns according to the image plane number (e.g. CHANNEL1, CHANNEL2, etc.). In this scenario being able to access the columns by index rather than name would be convenient although not absolutely critical. Here and here are files that illustrate what this looks like in the case of all- and partial-sky maps.

@astrofrog
Copy link
Member Author

Ah that makes sense - I think we could easily have some kind of object that can be accessed by name or by index.

@cdeil cdeil modified the milestones: 0.3, 0.4 Oct 24, 2018
@cdeil cdeil modified the milestones: 0.4, 0.5 Jun 5, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants