处理不同拟合文件出现的WCS错误

huangapple go评论58阅读模式
英文:

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 : &#39;RA---TAN&#39;  &#39;DEC--TAN&#39;  &#39;FREQ&#39;  
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: &#39;celfix&#39; made the change &#39;Ill-conditioned coordinate transformation parameter&#39;. [astropy.wcs.wcs]
---------------------------------------------------------------------------
InvalidTransformError                     Traceback (most recent call last)
Input In [94], in &lt;cell line: 1&gt;()
----&gt; 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  = &#39;deg&#39;                / Units of coordinate increment and value                                 
CUNIT2  = &#39;deg&#39;                / Units of coordinate increment and value                                 
CUNIT3  = &#39;Hz&#39;                 / Units of coordinate increment and value                                 
CTYPE1  = &#39;RA---TAN&#39;           / Right ascension, gnomonic projection                                    
CTYPE2  = &#39;DEC--TAN&#39;           / Declination, gnomonic projection                                        
CTYPE3  = &#39;FREQ&#39;               / 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 = &#39;ICRS&#39;               / Equatorial coordinate system                                            
CUBE    =                                                                                                
DATAS   =                                                                                                
DATE    = &#39;2020-03-30 15:48:36.001328&#39; / 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 = &#39;-5.603303303303305&#39; / [sample] Shift between kids and la                         
CONTINUE  &#39;100_S49749_NA_NA&#39;                                                                             
SCAN    = &#39;49749   &#39;                                                                                     
OBJECT  = &#39;OrionSim&#39;           /                                                                         
OBSTYPE = &#39;OTF     &#39;           / Observation Type                                                        
OBSDATE = &#39;2022-08-31T00:00:00.000&#39;                                                                      
SITELAT = &#39;-23.00575&#39;          / [deg] Site latitude
SITELONG= &#39;-67.7592222222222&#39;
SITEELEV= &#39;5105.0  &#39;           / [m] Site elevation
PROJID  = &#39;E-0109.A-0442A-2022&#39;
SCANNUM = &#39;49749   &#39;
OBS-ID  = &#39;49749   &#39;
DATE    = &#39;2023-02-15T11:57:57.513287&#39;
EXPTIME = &#39;395.13672846369445&#39; / 
展开收缩
Exposure time DATE-OBS= &#39;2022-08-31T11:01:12.421&#39; DATE-END= &#39;2022-08-31T11:07:47.558&#39; ORIGIN = &#39;None &#39; NINT = &#39;736 &#39; / Total number of blocs NPTINT = &#39;2048 &#39; / Number of points per bloc NSAMPLES= &#39;1507328 &#39; LABEL = &#39;None &#39; INTTIME = &#39;0.000262144&#39; /
展开收缩
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 = &#39;deg&#39; / Units of coordinate increment and value CUNIT2 = &#39;deg&#39; / Units of coordinate increment and value CUNIT3 = &#39;Hz&#39; / Units of coordinate increment and value CTYPE1 = &#39;RA---SFL&#39; / Right ascension, Sanson-Flamsteed projection CTYPE2 = &#39;DEC--SFL&#39; / Declination, Sanson-Flamsteed projection CTYPE3 = &#39;FREQ&#39; / 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 = &#39;ICRS&#39; / 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.

huangapple
  • 本文由 发表于 2023年5月10日 21:10:04
  • 转载请务必保留本文链接:https://go.coder-hub.com/76218839.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定