CARTAvis / carta

To CARTA users, this repo holds the CARTA release packages. Please use this repo to log bugs and feature requests. These will be triaged by the development team and prioritised as necessary in the development cycles.
19 stars 0 forks source link

Some WCSes that don't work but should #212

Open keflavich opened 2 months ago

keflavich commented 2 months ago

Describe the bug These two FITS headers refuse to align with others. What is wrong with them?

Could not enable spatial matching of Bania2_downsampled_kms_try2.fits to reference image G002.5+0.0IFx_Mosaic_Mom0.fits. No valid transform was found.
Could not enable spatial matching of H2_mosaic_avg.fits to reference image G002.5+0.0IFx_Mosaic_Mom0.fits. No valid transform was found.

To Reproduce H2 header:

$ imhead H2_mosaic_avg.fits
SIMPLE  =                    T / Fits standard
BITPIX  =                  -32 / Bits per pixel
NAXIS   =                    2 / Number of axes
NAXIS1  =                 1969 / Axis length
NAXIS2  =                 1461 / Axis length
EXTEND  =                    T / File may contain extensions
ORIGIN  = 'NOAO-IRAF FITS Image Kernel July 2003' / FITS file originator
DATE    = '2024-09-08T22:04:24' / Date FITS file was generated
IRAF-TLM= '2024-09-08T22:04:24' / Time of last modification
SEQNAME = 'CDS     '
DATE-OBS= '2024-05-31T07:39:22.784000' / TAI time at start of exposure
MJD-OBS =    2460461.818634259 / Mean Julian Date of exposure
STARTCLR= '2024-05-31T07:38:50.784000' / UTC time at start of exposure
ENDRD   = '2024-05-31T07:41:57.472000' / UTC time at end of reading final frame
TIME2CLR=              0.65625 / Estimated time (sec) to clear the chip
TIME2RD =              0.67625 / Estimated time (sec) to read the chip
EXPTIME =                180.0 / Actual exposure time of CDS
IMAGETYP= 'OBJECT  '           / Type of image taken
CNPIX1  =                    1 / Lower Left X pixel pos of window (start at 1)
CNPIX2  =                    1 / Lower Left Y pixel pos of window (start at 1)
NFS     =                    8 / Number of Fowler Samples
FILTER  = 'H2-2.12 '           / The name of the current filter
FILTER1M=                    7 / The physical position of filter wheel 1
FILTER2M=                    1 / The physical position of filter wheel 2
FILTER3M=                    7 / The physical position of filter wheel 3
FPINBEAM= 'Unknown '           / Position of etalon
PRESSURE= 9.687999999999999E-007 / Instrument pressure in Torr
TEMP1VAL=               78.426 / Temperature from LN2_Container in K
TEMP2VAL=    85.10299999999999 / Temperature from Bench-FPA in K
TEMP3VAL=               100.45 / Temperature from Bench-Front in K
TEMP4VAL=    90.95399999999999 / Temperature from Bench-FP in K
OBSERVAT= 'APO'                / Per the IRAF observatory list.
TELESCOP= '3.5m'
INSTRUME= 'nicfps'             / Instrument name
LATITUDE= +3.2780361000000E+01 / Latitude of telescope base
LONGITUD= -1.0582041700000E+02 / Longitude of telescope base
TIMESYS = 'TAI'                / Time system for DATE-OBS
UTC-TAI = -37.0                / UTC = TAI + UTC_TAI(seconds)
UT1-TAI = -37.02               / UT1 = TAI + UT1_TAI(seconds)
LST     = '17:12:40.451'       / Local Apparent Sidereal time
OBJNAME = 'Bania_Clump2_e'     / Object name, per TCC ObjName
RADECSYS= 'ICRS    '           / Coordinate system, per TCC ObjSys
EQUINOX = +2.0000000000000E+03 / Equinox, per TCC ObjSys
OBJANGLE= +3.2296940000000E-02 / Angle from inst x,y to sky
RA      = '17:51:35.52'        / RA hours, extrapolated from TCC ObjNetPos
DEC     = '-25:50:52.93'       / Dec degrees, extrapolated from TCC ObjNetPos
ARCOFFX = -6.6666700000000E-02 / TCC arc offset X
ARCOFFY = +0.0000000000000E+00 / TCC arc offset Y
CALOFFX = +0.0000000000000E+00 / TCC calibration offset X
CALOFFY = +0.0000000000000E+00 / TCC calibration offset Y
BOREOFFX= +0.0000000000000E+00 / TCC boresight offset X
BOREOFFY= +0.0000000000000E+00 / TCC boresight offset Y
AIRPRESS= +7.2888000000000E+04 / Air pressure, Pascals
HUMIDITY= +1.3000000000000E-01 / Humidity, fraction
TELAZ   = +1.0668439000000E+01 / TCC AxePos azimuth
TELALT  = +3.0615123000000E+01 / TCC AxePos altitude
TELROT  = +4.0366414000000E+01 / TCC AxePos rotator
TELFOCUS= +2.7100000000000E+02 / TCC SecFocus
ZD      = +5.9384877000000E+01 / Zenith distance
AIRMASS = +1.9636003956248E+00 / 1/cos(ZD)
CTYPE1  = 'RA---TAN'           / WCS projection
CTYPE2  = 'DEC--TAN'           / WCS projection
CRPIX1  =            506.03615 / WCS reference pixel
CRPIX2  =            565.75294 / WCS reference pixel
CRVAL1  =           267.894173 / WCS reference sky pos.
CRVAL2  =           -25.848215 / WCS reference sky pos.
CD1_1   = +7.5550943338896E-05 / WCS (1/InstScaleX)*cos(InstAng)
CD1_2   = +4.2637734975314E-08 / WCS (1/InstScaleY)*sin(InstAng)
CD2_1   = -4.2587160226021E-08 / WCS (-1/(InstScaleX)*sin(InstAng)
CD2_2   = +7.5640664513022E-05 / WCS (1/InstScaleY)*cos(InstAng)
WCSDIM  =                    2
LTM1_1  =                   1.
LTM2_2  =                   1.
WAT0_001= 'system=image'
WAT1_001= 'wtype=tan axtype=ra'
WAT2_001= 'wtype=tan axtype=dec'
NCOMBINE=                   20
IMCMB001= 'BC2_e_H2_diff.fits'
IMCMB002= '1.fits  '
COMMENT   28 blank lines
END

Bania2 header:

$ imhead CHIMPS/Bania2_downsampled_kms.fits
SIMPLE  =                    T / conforms to FITS standard
BITPIX  =                  -64 / array data type
NAXIS   =                    3 / number of array dimensions
NAXIS1  =                  550
NAXIS2  =                  590
NAXIS3  =                  131
BUNIT   = 'K       '           / Units of the primary array
DATE    = '2019-07-06T13:38:58' / file creation date (YYYY-MM-DDThh:mm:ss UT)
ORIGIN  = 'East Asian Observatory' / Origin of file
BMAJ    =      0.0041666666666
BMIN    =     0.00416666666666
BPA     =                  0.0
WCSAXES =                    3 / Number of coordinate axes
CRPIX1  =              426.798 / Pixel coordinate of reference point
CRPIX2  =              265.753 / Pixel coordinate of reference point
CRPIX3  =                65.75 / Pixel coordinate of reference point
CDELT1  =  -0.0016666666666732 / [deg] Coordinate increment at reference point
CDELT2  =   0.0016666666666677 / [deg] Coordinate increment at reference point
CDELT3  =                 -6.0 / [m/s] Coordinate increment at reference point
CUNIT1  = 'deg'                / Units of coordinate increment and value
CUNIT2  = 'deg'                / Units of coordinate increment and value
CUNIT3  = 'km s-1  '           / Units of coordinate increment and value
CTYPE1  = 'GLON-TAN'           / Galactic longitude, gnomonic projection
CTYPE2  = 'GLAT-TAN'           / Galactic latitude, gnomonic projection
CTYPE3  = 'VRAD'               / Radio velocity (linear)
CRVAL1  =                  3.0 / [deg] Coordinate value at reference point
CRVAL2  =             0.000000 / [deg] Coordinate value at reference point
CRVAL3  =     -14.900250073081 / [m/s] Coordinate value at reference point
RESTFRQ =       345795989900.0 / [Hz] Line rest frequency
MJDREF  =                  0.0 / [d] MJD of fiducial time
DATE-OBS= '2018-08-13T07:11:50.088' / ISO-8601 time of observation
MJD-OBS =       58343.29988528 / [d] MJD of observation
DATE-END= '2018-09-15T06:19:59' / ISO-8601 time at end of observation
MJD-END =      58376.263877315 / [d] MJD at end of observation
OBSGEO-X=        -5464586.7038 / [m] observatory X-coordinate
OBSGEO-Y=     -2492996.9384415 / [m] observatory Y-coordinate
OBSGEO-Z=      2150653.6634182 / [m] observatory Z-coordinate
SPECSYS = 'LSRK'               / Reference frame of spectral coordinates
SSYSOBS = 'TOPOCENT'           / Reference frame of spectral observation
VELOSYS =      12233.982413461 / [m/s] Velocity towards source
ZSOURCE =                  0.0 / Redshift of the source
SSYSSRC = 'LSRK'               / Reference frame of source redshift
COMMENT Original Unit=m / s
COMMENT Original Type=VRAD
HISTORY Written by spectral_cube v0.6.6.dev71+g89db2de on 2024/09/08-21:23:26
END

Expected behavior AFAICT, these are perfectly reasonable FITS headers with valid WCSes. Astropy's WCS recognizes them.

Platform info (please complete the following information):

Additional context The Inspector console gives these messages:

Cannot perform spatial transform between images with non-square pixels
main.8fd3acb4.js:8 Error creating spatial transform between files 6 and 0
main.8fd3acb4.js:8 Error creating spatial transform between files 7 and 0

Looking at those last messages.... is the issue just the incredibly tiny non-squareness? I'll try without that, but that is still a bug.

keflavich commented 2 months ago

OK, as often happens, the act of writing up the issue led to the "solution" (though I think it's just a workaround): the WCSes both have CD/CDELTs that differ a tiny amount. In the second case, it's only in the 14th decimal place.

I'd recommend having the 'are CDs equal?' check be a little softer - allow variation at the level of 1 part in 10^9, maybe?