将星座中的标头从一个FITS文件复制到新创建的FITS文件

时间:2017-09-04 00:06:49

标签: python astropy fits

我有一个处理现有FITS文件(xbulge-w1.fits)的程序,并将处理后的图像保存到新的FITS(w1_resampled.fits)。我想将标题从原始标题复制到新标题,以便它们处于相同的坐标(即银河系)中。
我尝试使用以下代码执行此操作:

#   Open the FITS files as input image and mask
#   Process the images
#   Rescale image to galactic coordinates and display
#   Plot and save median filtered images as png, rescaled to galactic coordinates
#   Save as FITS files and close
#   Edit FITS headers to recenter images at galactic center
header = fits.getdata('xbulge-w1.fits', header=True)

header['COMMENT'] = 'Resampled with median filtered pixels'
header['IMAGEW'] = 877
header['IMAGEH'] = 901
header['WCSAXES'] = (2, 'Number of coordinate axes')
header['CRPIX1'] = 438.5
header['CRPIX2'] = 450.5                                                  
header['PC1_1'] = (-0.0333333333333, 'Coordinate transformation matrix element')
header['PC2_2'] = (0.0333333333333, 'Coordinate transformation matrix element')
header['CDELT1'] = (1., '[deg] Coordinate increment at reference point')
header['CDELT2'] = (1., '[deg] Coordinate increment at reference point')
header['CUNIT1'] = ('deg     ', 'Units of coordinate increment and value')
header['CUNIT2'] = ('deg     ', 'Units of coordinate increment and value')
header['CTYPE1'] = 'GLON-AIT'                
header['CTYPE2'] = 'GLAT-AIT'                                                            
header['CRVAL1'] = (0., '[deg] Coordinate value at reference point')
header['CRVAL2'] = (0., '[deg] Coordinate value at reference point')
header['LONPOLE'] = (0., '[deg] Native longitude of celestial pole')
header['LATPOLE'] = (90., '[deg] Native latitude of celestial pole')
header['RADESYS'] = ('ICRS    ', 'Equatorial coordinate system')

fits.writeto('w1_resampled.fits', header, overwrite=True)
fits.writeto('w2_resampled.fits', header, overwrite=True)

hdulist.close()
hdulist2.close()
hdulist3.close()

前5个评论列出了程序中的工作功能,它只是我遇到困难的标题。当我在DS9中打开w1_resampled.fits时,标题包含

SIMPLE  =                    T / conforms to FITS standard                      
BITPIX  =                  -32 / array data type                                
NAXIS   =                    2 / number of array dimensions                     
NAXIS1  =                  877                                                  
NAXIS2  =                  901                                                  
EXTEND  =                    T                                                  
END  

而不是从xbulge-w1.fits标题中复制的数据 如何将数据从一个标题复制到另一个标题?

1 个答案:

答案 0 :(得分:-1)

哦,我明白了。我太复杂了。这就是我需要做的所有事情:

providers:
    in_memory:
        memory: ~
    fos_userbundle:
      id: fos_user.user_provider.username