-1
私は既存のFITSファイル(xbulge-w1.fits
)を処理し、処理された画像を新しいFITS(w1_resampled.fits
)に保存するプログラムを持っています。ヘッダーを元のものから新しいものにコピーして、同じ座標(つまり銀河系)になるようにしたいと思います。
は、私は次のコードでそれをやろうとしている:1つのFITSファイルから新しく作成された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
を開くと、ヘッダではなくxbulge-w1.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
を含有します。
1つのヘッダーから別のヘッダーにデータをコピーするにはどうすればよいですか?
ルック(http://docs.astropy.org/en/stable/io/fits/api/files.html#astropy.io.fitsを:ここで私が行うために必要なすべてです。 writeto): 'fits.writeto'への第二引数はヘッダーではなく、* data *です。 – Evert
同様に、['fits.getdata'](http://docs.astropy.org/en/stable/io/fits/api/files.html#astropy.io.fits.getdata)は、2組の' (データ、ヘッダ) ';それを 'header'に代入するだけなので、それはタプルなので、dict-formで' header'を使うことができるのには驚いています。おそらくその行に実際のコードに 'fits.getheader'がありますか? – Evert