forked from simoncasassus/PyVtools
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbeam.py
More file actions
executable file
·40 lines (27 loc) · 851 Bytes
/
Copy pathbeam.py
File metadata and controls
executable file
·40 lines (27 loc) · 851 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/usr/bin/env python3
import sys
import os
import os.path
import numpy as np
from astropy.io import fits
from pprint import pprint as pp
filename_source=sys.argv[1]
hdu = fits.open(filename_source)
hdr = hdu[0].header
if 'BMAJ' in hdr.keys():
bmaj=hdr['BMAJ']*3600.
bmin=hdr['BMIN']*3600.
bpa=hdr['BPA']
elif (len(hdu)>1):
print("no beam info, look for extra HDU")
beamhdr=hdu[1].header
#print("beamhdr")
#from pprint import pprint
#pprint(beamhdr)
beamdata=hdu[1].data
#print("beamvector", beamdata)
bmaj=beamdata[0][0]
bmin=beamdata[0][1]
bpa=beamdata[0][2]
print("beam vector %.3f %.3f %.3f ---> %.3f %.3f %.3f " % (beamdata[0][0],beamdata[0][1],beamdata[0][2],beamdata[-1][0],beamdata[-1][1],beamdata[1][2]))
print( "%.3f x %.3f / %.1f " % (bmaj,bmin,bpa))