-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathprint_w.py
65 lines (49 loc) · 1.91 KB
/
print_w.py
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
import numpy as np
from phasing import compute_uvw, compute_antenna_gainphase
from astropy.coordinates import ITRS, SkyCoord, AltAz, EarthLocation
from astropy.time import Time,TimeDelta
import pandas as pd
import time, os
import argparse
ANTNAMES = ['1A', '1F', '1C', '1K', '1H', '1E', '1G',
'2A', '2B', '2C', '2H', '2E', '2J', '2K', '2L', '2M',
'3C', '3D', '3L',
'4G', '4J',
'5B', '5C']
WD = os.path.realpath(os.path.dirname(__file__))
DEFAULT_ANT_ITRF = os.path.join(WD, "ant_itrf.txt")
DEFAULT_REF_ANT = "1C"
def main():
parser = argparse.ArgumentParser(description='print w coordinate')
parser.add_argument('-source_ra', type=float, required=True,
help = 'Source RA [decimal hours]')
parser.add_argument('-source_dec', type=float, required=True,
help = 'Source Dec [degrees]')
parser.add_argument('-refant', type=str,
default = DEFAULT_REF_ANT,
help = 'Reference antenna')
parser.add_argument('-itrf', type=str,
default = DEFAULT_ANT_ITRF, required = False,
help = 'ITRF file [default: %s]' %DEFAULT_ANT_ITRF)
args = parser.parse_args()
# Get ITRF coordinates of the antennas
itrf = pd.read_csv(args.itrf, names=['x', 'y', 'z'], header=None, skiprows=1)
itrf_sub = itrf.loc[ANTNAMES]
refant = args.refant.upper()
irefant = itrf_sub.index.values.tolist().index(refant)
ra = args.source_ra * 360 / 24.
dec = args.source_dec
source = SkyCoord(ra, dec, unit='deg')
while True:
t = np.floor(time.time())
tts = np.arange(-2, 10) + t
ts = Time(tts, format='unix')
uvw = compute_uvw(ts, source, itrf_sub[['x','y','z']], itrf_sub[['x','y','z']].values[irefant])
w = uvw[...,2]
print("tnow: %.2f" %t)
for i in range(len(ts)):
print(ts[i], w[i])
print("")
time.sleep(5)
if __name__ == "__main__":
main()