英文:
Handling WCS error appeared with different fits file
问题
以下是翻译好的内容:
在处理两个fits文件(以下是头部信息)时,一个是示例案例,可以正常工作,另一个是Orion案例,无法正常工作。
读取和处理fits文件所需的几行代码:
from astropy.io import fits
from astropy.wcs import WCS
hdul = fits.open(cubefits)
hdul.info()
hdul.readall()
hd = hdul[0].header
wcs = WCS(hd)
对于示例案例,当我打印wcs时,我获得正确的输出:
WCS Keywords
Number of WCS axes: 3
CTYPE : 'RA---TAN' 'DEC--TAN' 'FREQ'
CRVAL : 0.70395330810396 0.69721933449752 125.0
CRPIX : 507.90474039695 503.02270076207 1.0
PC1_1 PC1_2 PC1_3 : 1.0 0.0 0.0
PC2_1 PC2_2 PC2_3 : 0.0 1.0 0.0
PC3_1 PC3_2 PC3_3 : 0.0 0.0 1.0
CDELT : 0.0013888888888889 0.0013888888888889 1.0
NAXIS : 1009 1009 181
对于Orion案例,使用相同的代码会导致错误:
In [94]: wcs = WCS(hd)
WARNING: FITSFixedWarning: The WCS transformation has more axes (3) than the image it is associated with (0) [astropy.wcs.wcs]
WARNING: FITSFixedWarning: 'celfix' made the change 'Ill-conditioned coordinate transformation parameter'. [astropy.wcs.wcs]
---------------------------------------------------------------------------
InvalidTransformError Traceback (most recent call last)
Input In [94], in <cell line: 1>()
----> 1 wcs = WCS(hd)
InvalidTransformError: ERROR 7 in wcsset() at line 2660 of file cextern/wcslib/C/wcs.c:
Ill-conditioned coordinate transformation parameter.
ERROR 4 in celset() at line 441 of file cextern/wcslib/C/cel.c:
Ill-conditioned coordinate transformation parameters
No valid solution for latp for these values of phip, phi0, and theta0.
以下是两个fits文件的头部信息。
英文:
I am handling two fits file (the header in the following), EXEMPLE case where it does work and the Orion case where it does not work.
The few lines necessary to read and handle the fits.
from astropy.io import fits
from astropy.wcs import WCS
hdul = fits.open(cubefits)
hdul.info()
hdul.readall()
hd = hdul[0].header
wcs = WCS(hd)
For the EXAMPLE (in the following) I obtain a correct output when I print the wcs:
WCS Keywords
Number of WCS axes: 3
CTYPE : 'RA---TAN' 'DEC--TAN' 'FREQ'
CRVAL : 0.70395330810396 0.69721933449752 125.0
CRPIX : 507.90474039695 503.02270076207 1.0
PC1_1 PC1_2 PC1_3 : 1.0 0.0 0.0
PC2_1 PC2_2 PC2_3 : 0.0 1.0 0.0
PC3_1 PC3_2 PC3_3 : 0.0 0.0 1.0
CDELT : 0.0013888888888889 0.0013888888888889 1.0
NAXIS : 1009 1009 181
For the Orion case I have an error by launching the same code:
In [94]: wcs = WCS(hd)
WARNING: FITSFixedWarning: The WCS transformation has more axes (3) than the image it is associated with (0) [astropy.wcs.wcs]
WARNING: FITSFixedWarning: 'celfix' made the change 'Ill-conditioned coordinate transformation parameter'. [astropy.wcs.wcs]
---------------------------------------------------------------------------
InvalidTransformError Traceback (most recent call last)
Input In [94], in <cell line: 1>()
----> 1 wcs = WCS(hd)
InvalidTransformError: ERROR 7 in wcsset() at line 2660 of file cextern/wcslib/C/wcs.c:
Ill-conditioned coordinate transformation parameter.
ERROR 4 in celset() at line 441 of file cextern/wcslib/C/cel.c:
Ill-conditioned coordinate transformation parameters
No valid solution for latp for these values of phip, phi0, and theta0.
Here the headers of the two fits files:
### EXAMPLE
SIMPLE = T / conforms to FITS standard
BITPIX = -64 / array data type
NAXIS = 3 / number of array dimensions
NAXIS1 = 1009
NAXIS2 = 1009
NAXIS3 = 181
WCSAXES = 3 / Number of coordinate axes
CRPIX1 = 507.90474039695 / Pixel coordinate of reference point
CRPIX2 = 503.02270076207 / Pixel coordinate of reference point
CRPIX3 = 1.0 / Pixel coordinate of reference point
CDELT1 = 0.0013888888888889 / [deg] Coordinate increment at reference point
CDELT2 = 0.0013888888888889 / [deg] Coordinate increment at reference point
CDELT3 = 1.0 / [Hz] Coordinate increment at reference point
CUNIT1 = 'deg' / Units of coordinate increment and value
CUNIT2 = 'deg' / Units of coordinate increment and value
CUNIT3 = 'Hz' / Units of coordinate increment and value
CTYPE1 = 'RA---TAN' / Right ascension, gnomonic projection
CTYPE2 = 'DEC--TAN' / Declination, gnomonic projection
CTYPE3 = 'FREQ' / Frequency (linear)
CRVAL1 = 0.70395330810396 / [deg] Coordinate value at reference point
CRVAL2 = 0.69721933449752 / [deg] Coordinate value at reference point
CRVAL3 = 125.0 / [Hz] Coordinate value at reference point
LONPOLE = 180.0 / [deg] Native longitude of celestial pole
LATPOLE = 0.69721933449752 / [deg] Native latitude of celestial pole
RADESYS = 'ICRS' / Equatorial coordinate system
CUBE =
DATAS =
DATE = '2020-03-30 15:48:36.001328' / date of the creation
### ORION
SIMPLE = T / conforms to FITS standard
BITPIX = 8 / array data type
NAXIS = 0 / number of array dimensions
EXTEND = T /
HIERARCH LASER_SHIFT = '-5.603303303303305' / [sample] Shift between kids and la
CONTINUE '100_S49749_NA_NA'
SCAN = '49749 '
OBJECT = 'OrionSim' /
OBSTYPE = 'OTF ' / Observation Type
OBSDATE = '2022-08-31T00:00:00.000'
SITELAT = '-23.00575' / [deg] Site latitude
SITELONG= '-67.7592222222222'
SITEELEV= '5105.0 ' / [m] Site elevation
PROJID = 'E-0109.A-0442A-2022'
SCANNUM = '49749 '
OBS-ID = '49749 '
DATE = '2023-02-15T11:57:57.513287'
EXPTIME = '395.13672846369445' / 展开收缩 Exposure time
DATE-OBS= '2022-08-31T11:01:12.421'
DATE-END= '2022-08-31T11:07:47.558'
ORIGIN = 'None '
NINT = '736 ' / Total number of blocs
NPTINT = '2048 ' / Number of points per bloc
NSAMPLES= '1507328 '
LABEL = 'None '
INTTIME = '0.000262144' / 展开收缩 Integration Time per sample
WCSAXES = 3 / Number of coordinate axes
CRPIX1 = 381 / Pixel coordinate of reference point
CRPIX2 = 649 / Pixel coordinate of reference point
CRPIX3 = 0.00000000000 / Pixel coordinate of reference point
CDELT1 = 0.0011111111111111 / [deg] Coordinate increment at reference point
CDELT2 = 0.0011111111111111 / [deg] Coordinate increment at reference point
CDELT3 = 600000000.000 / [Hz] Coordinate increment at reference point
CUNIT1 = 'deg' / Units of coordinate increment and value
CUNIT2 = 'deg' / Units of coordinate increment and value
CUNIT3 = 'Hz' / Units of coordinate increment and value
CTYPE1 = 'RA---SFL' / Right ascension, Sanson-Flamsteed projection
CTYPE2 = 'DEC--SFL' / Declination, Sanson-Flamsteed projection
CTYPE3 = 'FREQ' / Coordinate type code
CRVAL1 = 83.8402938843 / [deg] Coordinate value at reference point
CRVAL2 = -5.18931388855 / [deg] Coordinate value at reference point
CRVAL3 = 0.600000000000 / [Hz] Coordinate value at reference point
LONPOLE = 0.0 / [deg] Native longitude of celestial pole
LATPOLE = 69.997710986349 / [deg] Native latitude of celestial pole
MJDREF = 0.0 / [d] MJD of fiducial time
RADESYS = 'ICRS' / Equatorial coordinate system
CRDELT1 = 0 /
CRDELT2 = 0 /
答案1
得分: 1
第一个警告基本解释了发生了什么:
WCS转换具有比其关联的图像更多的轴(3),而图像具有的轴数为(0)[astropy.wcs.wcs]
它指出存在3个参考维度的WCS,但在同一头文件中的图像不包含任何维度(即没有图像)。这在头文件中得到了确认:
SIMPLE = T / 符合FITS标准
BITPIX = 8 / 数组数据类型
NAXIS = 0 / 数组维度的数量
最有可能的情况是,您的文件包含一个只包含信息头的空主HDU,以及不同的数据数组(可能是原始数据和单独的错误校正数组),它们共享相同的WCS。
英文:
The first warning explains essentially what is happening:
The WCS transformation has more axes (3) than the image it is associated with (0) [astropy.wcs.wcs]
It's saying there's a WCS for 3 reference dimensions, but the image in the same header contains 0 dimensions (i.e. there is no image). This is confirmed in the header:
SIMPLE = T / conforms to FITS standard
BITPIX = 8 / array data type
NAXIS = 0 / number of array dimensions
Most likely your file contains an empty primary HDU containing only an informational header, with different data arrays (probably raw data and separate error correction arrays), that share the same WCS.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论