[英]How do I overlay two .fits images each with different WCS / resolutions?
[英]How do I reproject fits files using ccdproc's wcs_project?
我正在嘗試堆疊一系列適合文件。 我正在學習這個過程,我知道因為它們有不同的 wcs,所以我必須先調整它們的方向,甚至在我開始堆疊之前。 我發現 ccdproc 的wcs_project
是一種合理解決這個問題的方法。 我試圖遵循此頁面上的最后一個示例。 話雖如此,當我嘗試運行wcs_project
,我不斷收到 wcs 錯誤。
我的代碼如下:
target_image = fits.open(list_of_fits_files[1])
target_wcs = WCS(target_image[0]).celestial
reprojected = []
for fits_file in list_of_fits_files:
img = fits.open(fits_file)
new_image = wcs_project(img, target_wcs)
reprojected.append(new_image)
我的錯誤信息如下:
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-189-2f3f9f278991> in <module>
9 for fits_file in list_of_fits_files:
10 img = fits.open(fits_file)
---> 11 new_image = wcs_project(img, target_wcs)
12 reprojected.append(new_image)
/anaconda3/lib/python3.6/site-packages/ccdproc/log_meta.py in wrapper(*args, **kwd)
90 # Grab the logging keyword, if it is present.
91 log_result = kwd.pop(_LOG_ARGUMENT, True)
---> 92 result = func(*args, **kwd)
93
94 if not log_result:
/anaconda3/lib/python3.6/site-packages/ccdproc/core.py in wcs_project(ccd, target_wcs, target_shape, order)
922 from reproject import reproject_interp
923
--> 924 if not (ccd.wcs.is_celestial and target_wcs.is_celestial):
925 raise ValueError('one or both WCS is not celestial.')
926
AttributeError: 'HDUList' object has no attribute 'wcs'
我搞砸了什么? 我一直在嘗試閱讀 ccdproc,但沒有太多例子。 或者如果有人建議更好的堆疊方法,請告訴我。
在你寫的代碼中:
for fits_file in list_of_fits_files:
img = fits.open(fits_file)
new_image = wcs_project(img, target_wcs)
但是fits.open
返回的對象是HDUList
對象(因此出現錯誤AttributeError: 'HDUList' object has no attribute 'wcs'
),它是存儲在單個 FITS 文件中的一個或多個 HDU 的列表。 但是, wcs_project
需要一個CCDData
對象,其中包含實際的圖像數據(可能來自任何來源,在您的情況下恰好是 FITS 文件)。
您可以使用CCDData.read('/path/to/image.fits')
直接從 FITS 文件中讀取CCDData
,因此您可能想要編寫如下內容:
img = CCDData.read(fits_file)
new_image = wcs_project(img, target_wcs)
如果您的 FITS 文件包含一張圖像, CCDData.read()
應該能夠猜測您要加載哪個圖像。 如果它包含多個圖像,您可能需要指定要讀取的擴展名; 從 FITS 文件讀取時CCDData.read
使用與低級函數fits_ccddata_reader
相同的所有參數,例如用於指定要讀取的擴展 HDU。 在大多數情況下,您不需要這樣做,具體取決於數據是什么。
您可以嘗試使用 astromatic 軟件 swarp ( https://www.astromatic.net/software/swarp ) 先對齊圖像,然后堆疊它們。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.