Skip to content

Commit fb7a782

Browse files
committedApr 22, 2024
code to change fits headers
1 parent 1b17cf9 commit fb7a782

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed
 

‎scripts/updsateFitsHeader.py

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import sys
2+
3+
from astropy.io import fits
4+
5+
fname = sys.argv[1]
6+
print("Looking at header for file ", fname)
7+
8+
hdul = fits.open(fname)
9+
10+
hdr = hdul[0].header
11+
12+
expTime = hdr['EXPTIME']
13+
14+
hdr['XBINNING'] = 2
15+
hdr['YBINNING'] = 2
16+
hdr.set('XBINNING', 2)
17+
hdr.set('YBINNING', 2)
18+
19+
#print("Telescope: ", hdr['TELESCOP'])
20+
print("Exposure time: ", expTime)
21+
#print("Object: ", hdr['OBJECT'])
22+
print("Gain: ", hdr['GAIN'])
23+
#print("Offset:", hdr['OFFSET'])
24+
print("Binning: ", hdr['XBINNING'], "x", hdr['YBINNING'])
25+
print("Bits per pixel:", hdr['BITPIX'])
26+
print("Width: ", hdr['NAXIS1'], " x Height: ", hdr['NAXIS2'])
27+
28+
hdul.writeto('updated.fits')
29+
30+
hdul.close()
31+

0 commit comments

Comments
 (0)
Please sign in to comment.