hipspy / hips

Python library to handle HiPS
https://hips.readthedocs.io
13 stars 16 forks source link

Conflict with WCS and Hips Tiles close to RA=180 degrees #157

Open DiegoLeonGaray opened 8 months ago

DiegoLeonGaray commented 8 months ago

Hello all,

I would like to report an error that I have been having while using the WCS library in my hips tiles. With some hips tiles, the relationship between pixel and coordinates cannot be established correctly. Below I will leave an example:

First, we obtain the order 9 hips tile for RA=180.08789062, DEC=32.70846106:

print(hp.ang2pix(512,180.08789062, 32.70846106,nest=True,lonlat=True))

1831167

Now, we get the WCS object from the Norder9/Npix1831167 fits header:

w1=WCS(get_new_header_with_wcs(target_header, 9, 1831167, 512))

What is the pixel that contains the coordinate?:

sky = SkyCoord(180.08789062, 32.70846106, frame='icrs', unit='deg') print(w1.world_to_pixel(sky))

(array(1048575.50000943), array(1048575.50001972))

What is the coordinate for the pixel (250,256) in the hips tile Npix1831167?:

print(w1.pixel_to_world(250,256))

<SkyCoord (ICRS): (ra, dec) in deg (nan, nan)>

I don't understand the above behavior. I will compare it with a case where no such error occurs:

We obtain the order 9 hips tile for RA=180.08789062, DEC=32.60846106:

print(hp.ang2pix(512,180.08789062, 32.60846106,nest=True,lonlat=True))

1831165

We get the WCS object from the Norder9/Npix1831165 fits header:

w2=WCS(get_new_header_with_wcs(target_header, 9, 1831165, 512))

What is the pixel that contains the coordinate?:

sky2 = SkyCoord(180.08789062, 32.60846106, frame='icrs', unit='deg') print(w2.world_to_pixel(sky2))

(array(222.60492137), array(288.39510779))

What is the coordinate for the pixel (250,256) in the hips tile Npix1831165?:

print(w2.pixel_to_world(250,256))

<SkyCoord (ICRS): (ra, dec) in deg (180.08874893, 32.61880395)>

Could someone tell me what is happening here or if I am making a mistake? Thanks in advance :)

I would like to note that I have found several hips tiles where this error occurs, with the particularity that they are all close to RA=180 degrees. Some examples: -Order9/Npix1782015. RA=180.044947, DEC=11.98567 -Order7/Npix111363. RA=180.2305806, DEC=10.5766681 -Order8/Npix445635. RA=180.1556006, DEC=12.4681958