spacetelescope / drizzlepac

AstroDrizzle for HST images.
https://drizzlepac.readthedocs.io
BSD 3-Clause "New" or "Revised" License
50 stars 39 forks source link

MVM: Bad RA coordinates for skycells in the "North Pole" projection cell #1384

Closed stscijgbot-hstdp closed 11 months ago

stscijgbot-hstdp commented 2 years ago

Issue HLA-783 was created on JIRA by Michele De La Pena:

A problem was found by Rick and documented on 31 May in the team-burgundy Slack channel. Please see the team-burgundy Slack channel discussion and images for the full details. In essence, the coordinates in the projection cell at the north pole (2643) are wrong (by a lot). There are weird things that happen in that polar cell because it is centered at RA=0, Dec=90. Fortunately, Rick believes this issue only affects this single projection cell.

stscijgbot-hstdp commented 1 year ago

Comment by Steve Goldman on JIRA:

Projection Cell: 2643 Skycell: hst_skycell-p2643x06y10

stscijgbot-hstdp commented 1 year ago

Comment by Steve Goldman on JIRA:

The problem seems resolved. The file that was mentioned to be faulty seems to have the correct coordinates now (see top right attached). 

!Screenshot 2023-05-01 at 9.44.07 PM.png!

stscijgbot-hstdp commented 1 year ago

Comment by Steve Goldman on JIRA:

I've also created the MVM file from the FLCs manually and found a similar result. 

stscijgbot-hstdp commented 1 year ago

Comment by Rick White on JIRA:

Is the MVM image you are using the one that is currently in the HST public cache?  I downloaded these files:

hst_15652_15_wfc3_ir_f160w_idxo15_drz.fits
hst_skycell-p2643x06y10_wfc3_ir_f160w_coarse-all_drz.fits

I loaded the files into ds9 and find that the RA coordinates are off by 12 hours in the MVM image.

As an independent test (not relying on ds9), I can generate cutouts at the position of a compact bright galaxy using fitscut (which is a C program using cfitsio). Here is a JPEG cutout link for the SVM image: https://hla.stsci.edu/cgi-bin/fitscut.cgi?format=jpg&size=64&output_size=512&ra=260.325471&dec=88.704372&red=hst_15652_15_wfc3_ir_f160w_idxo15 Here is a cutout for the MVM image, which fails because it is off the edge of the image (due to the WCS issue): https://hla.stsci.edu/cgi-bin/fitscut.cgi?format=jpg&size=64&output_size=512&ra=260.325471&dec=88.704372&red=hst_skycell-p2643x06y10_wfc3_ir_f160w_coarse-all And here is a cutout for the MVM image where the RA has been shifted by 180 degrees (from 260.325471 to 80.325471): https://hla.stsci.edu/cgi-bin/fitscut.cgi?format=jpg&size=64&output_size=512&ra=80.325471&dec=88.704372&red=hst_skycell-p2643x06y10_wfc3_ir_f160w_coarse-all The shifted version works.

So it looks to me like the RA coordinates in the MVM image are still off by 180 degrees.

Possibly I am using an older version of ds9? But it seems a little unlikely that both ds9 and the WCS library I'm using with cfitsio is incorrect. I'm currently using ds9 version 7.6.

stscijgbot-hstdp commented 1 year ago

Comment by Steve Goldman on JIRA:

Hey Rick, thanks for looking into this. The images look fine when I use my version of DS9 (8.5b1), however, when I plot the data with python/matplotlib it give me something that looks like your results. I will consider the problem unresolved and continue looking for the issue. Thanks!

stscijgbot-hstdp commented 1 year ago

Comment by Rick White on JIRA:

I just updated to the latest version of ds9 (8.4.1) and see that the coordinates match, as you do. I will dig a little deeper into the changes to see if I can understand why the current version is different. I'm guess there is something about the WCS keywords that can lead to misinterpretation using some versions of WCS software.

stscijgbot-hstdp commented 1 year ago

Comment by Rick White on JIRA:

I'm comparing the WCS in the images to what Pan-STARRS images use for projection cell 2643. (PS1 defined the projection cell grid we are using for the MVM products.) For PS1 images, the CRVAL position is shifted slightly off the pole:

CRVAL1  =                   0.
CRVAL2  =      89.999999999997

For the HAP MVM images, the CRVAL position is exactly on the pole:

CRVAL2  =                 90.0
CRVAL1  =                  0.0

That's what makes the orientation of the axes ambiguous. I'm fiddling a little with the headers to see if there is a version that works with all the FITS readers I'm looking at. I suspect that if we could define projection cell 2643 as being centered at (0.0, 89.999999999997), the ambiguity would go away.

stscijgbot-hstdp commented 1 year ago

Comment by Rick White on JIRA:

I found that if I change CRVAL2 in the header to 90.000000000003 (which seems a little crazy since declinations > 90 are not possible) then the file worked correctly with both versions of ds9. But the cutouts using fitscut were still not correct.

I'm betting that if we change the center of projection cell 2643 to have dec = 89.999999999997 and redrizzle the images, everything will just work and the problem will go away. It looks like the projection cell centers come from the file allsky_cells.fits in {}drizzlepac/pars/{}. I would change the DEC value for the first row of the table (for {}PROJCELL=0{}) to -89.999999999997 and the DEC value for the last row ({}PROJCELL=2643{}) to 89.999999999997. I'm pretty sure that will fix the issue.

nden commented 11 months ago

JIRA ticket resolved