I remember that when first encountering HEALPix I was very confused, because it's a pixelisation and a WCS projection, and I couldn't find docs how to work with the HEALPix projection in Astropy.
Specifically, this doesn't apply the projection, and doesn't give an error, it just passes the values through without change:
>>> from astropy.coordinates import Angle
>>> from astropy.modeling.models import Sky2Pix_HEALPix, Pix2Sky_HEALPix
>>> x, y = Sky2Pix_HEALPix()(-148, 65)
>>> print(x, y)
-141.89216598555333 66.14250235769997
>>> print(Angle(x, 'deg').rad, Angle(y, 'deg').rad)
-2.4764854792342104 1.1544044416499766
>>> lon, lat = Pix2Sky_HEALPix()(x, y)
>>> print(lon, lat)
-147.99999999999997 65.0
This is the example from here and the results are identical.
I have two questions:
How can I use astropy.wcs.WCS to achieve the HEALPix projection?
Why does the HEALPix projection yield values in the range X = {0, 360} and Y={-90, 90}, i.e. values in the same range as LON = {0, 360} and LAT={-90, 90}, making it easy to think (X, Y) would be angles again (which they aren't)?
For the second question, I think it's a bit of a convention to have X=LON, another scale factor, e.g. X=LON/360 could have been chosen? And for Y, is there a fundamental reason why it has the same range as LAT, or is is a bit by chance that it comes out to Y={-90, 90}?
Once these two points are clarified, I'd like to make a small docs addition in astropy-healpix to clarify this, and give an example how one can do the HEALPix projection with Astropy (since it's not exposed in the astropy-healpix API).
I remember that when first encountering HEALPix I was very confused, because it's a pixelisation and a WCS projection, and I couldn't find docs how to work with the HEALPix projection in Astropy.
Specifically, this doesn't apply the projection, and doesn't give an error, it just passes the values through without change:
I did manage to access the projection via the astropy.modeling.projections.Sky2Pix_HEALPix wrapper for that WCS transform:
This is the example from here and the results are identical.
I have two questions:
astropy.wcs.WCS
to achieve the HEALPix projection?X = {0, 360}
andY={-90, 90}
, i.e. values in the same range asLON = {0, 360}
andLAT={-90, 90}
, making it easy to think(X, Y)
would be angles again (which they aren't)?For the second question, I think it's a bit of a convention to have
X=LON
, another scale factor, e.g.X=LON/360
could have been chosen? And forY
, is there a fundamental reason why it has the same range asLAT
, or is is a bit by chance that it comes out toY={-90, 90}
?Once these two points are clarified, I'd like to make a small docs addition in
astropy-healpix
to clarify this, and give an example how one can do the HEALPix projection with Astropy (since it's not exposed in the astropy-healpix API).