I am looking for a way to check if there is valid WCS data in the FITS file header or not.
When creating a WCS from FITS file with no WCS inside (ds9 does not see any WCS for example) I surprisingly had no warnings or errors.
from astropy import wcs, fits
hdu = fits.open(path_to_fit_file)
header = hdu[0].header
w = wcs.WCS(header)
print(w)
This code gave
WCS Keywords
Number of WCS axes: 2
CTYPE : '' ''
CRVAL : 0.0 0.0
CRPIX : 0.0 0.0
PC1_1 PC1_2 : 1.0 0.0
PC2_1 PC2_2 : 0.0 1.0
CDELT : 1.0 1.0
NAXIS : 1920 1200
wcs.validate
also does not return a clear answer, only some warnings.
Here is a full header:
SIMPLE = T / C# FITS: 07/16/2023 02:02:13
BITPIX = 16
NAXIS = 2 / Dimensionality
NAXIS1 = 1920
NAXIS2 = 1200
BLKLEVEL= 0 /
CAMID = '926f8841ad8ccd139' /
OBJCTALT= 34.4417644433851 /
GPS_EU = 3868.9 / EndShutterMicroSeconds
OBJECT = 'Sa11 ' /
EQUINOX = 2023.53719335833 /
OBJCTAZ = 215.096223700444 /
EXTEND = T / Extensions are permitted
BZERO = 32768 /
BSCALE = 1 /
ROWORDER= 'TOP-DOWN' /
EXPTIME = 3 / seconds
XPIXSZ = 5.86 / microns, includes binning if any
YPIXSZ = 5.86 / microns, includes binning if any
XBINNING= 1 /
YBINNING= 1 /
CCD-TEMP= -15.1 / C
FRAMETYP= 'Light ' /
SWCREATE= 'SharpCap v4.0.9268.0, 64 bit' /
DATE-OBS= '2023-07-15T23:02:10.0038605' / GPS:Start Exposure
DATE-END= '2023-07-15T23:02:13.1115415' / System Clock:Frame Received
DATE-OB2= '2023-07-15T23:02:13.0038689' / GPS:End Exposure
DATE-AVG= '2023-07-15T23:02:11.5038647' / GPS:Mid Exposure
FOCALLEN= 300 /
RA = 281.387381627622 / Epoch : JNOW
DEC = 0.507833420011808 / Epoch : JNOW
OBJCTRA = '18 45 32.000' / Epoch : JNOW
OBJCTDEC= '+00 30 28.000' / Epoch : JNOW
END