问题描述
我正在尝试使用FITS文件.我有以下代码:
I am trying to use a FITS file. I have the following code:
from astropy.io import fits
from astropy.wcs import WCS
hdul = fits.open(fitsfilename)[0]
wcs = WCS(hdul.header)
它给了我这些警告:
已固定"A_2_0"卡符合FITS标准是什么意思?卡A_2_0指向的数据发生了什么?我对警告:VerifyWarning:注意:astropy.io.fits使用基于零的索引的含义也很感兴趣.
What does it mean that Fixed 'A_2_0' card to meet the FITS standard? What happened with the data to which the card A_2_0 is referring to? I am also interested in the meaning of WARNING: VerifyWarning: Note: astropy.io.fits uses zero-based indexing.
推荐答案
如注释中所述,io.fits
具有用于验证标头的有效性,甚至可以修复较小的格式错误(它会尽力只写最好是完全有效的FITS文件).
As already noted in the comments, io.fits
has functionality for verifying the validity of headers, and will even fix minor trivial formatting errors (it tries its best to only write perfectly valid FITS files as best possible).
尽管有一些选项可用于在写文件时执行验证,但在某些情况下,它也可以在读取时执行自动验证,尤其是在解析标头时.这是一个长期存在的问题(这只是一个相关示例;有几个示例)当前没有什么好方法可以控制读取时间验证/修正.有一种更简单的方法可以将此静音或完全禁用它可能会很好.我认为这不会太难解决,我猜只是没有人有足够的动力.尽管目前,如果您希望使警告静音,则可以使用标准的 Python警告来取消警告系统.
Although there are options for how to perform verification at the time of writing out a file, there are also some cases where it performs automatic verification at read time too, particularly while parsing the headers. It's a long standing open issue (this is just one related example; there are several) that there's no great way currently to control for read-time verification / fixups. It might be nice to have an easier way to silence this, or disable it altogether. I think this would not be too hard to fix, just no one has ever been sufficiently motivated I guess. Although currently, if you wish to silence the warnings, you can do so with the standard Python warnings system.
关于警告本身的含义,我认为这可能是科学表示法中使用e
而不是E
的原因(FITS标准可以追溯到FORTRAN的时代,后者我认为更常见).如果消息能更好地准确解释其修复内容,那就太好了.
With that out of the way, as to the meanings of the warnings themselves, I think it's probably the use of e
instead of E
in scientific notation (the FITS standard goes back to days of FORTRAN where the latter was more common I think). It would be nice if the message explained better exactly what it was fixing.
注释注意:astropy.io.fits使用基于零的索引."从技术上讲,它只是第一条警告消息的一部分,并且主要出于历史原因而存在.将其添加到此消息中的事实甚至是一个小错误,因为该消息甚至还提到了任何索引(在过去,它可能说过一些有关卡[N]中的错误"的内容,其中N
将是卡的索引).出现此消息的原因只是提醒那些更习惯使用基于1的索引的FORTRAN和/或IRAF的用户,而PyFITS/astropy.io.fits使用基于0的索引来提供HDU编号和标头卡号由C和Python使用.在这一点上,它可能会被删除,或者至少固定为仅附加到与之实际相关的警告消息中.
The note "Note: astropy.io.fits uses zero-based indexing." is technically just part of the first warning message, and is there mostly for historical reasons. The fact that it was added to this message is a bit of a bug even, since the message does even mention any indices (in the past it might have said something about "Error in card [N]", where N
would be an index of the card). The reason for this message was just as a reminder to users who were more accustomed to FORTRAN and/or IRAF, which uses 1-based indexing, whereas PyFITS/astropy.io.fits gives HDU numbers and header card numbers using 0-based indexing as used by C and Python. At this point it could probably be removed, or at least fixed to only be appended to warning messages to which it's actually relevant.
这篇关于固定符合FITS标准的卡意味着什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!