16
16
# You should have received a copy of the GNU General Public License
17
17
# along with this program. If not, see <http://www.gnu.org/licenses/>.
18
18
19
+ from __future__ import division
20
+ from __future__ import print_function
21
+
19
22
from builtins import str
20
23
from builtins import range
21
24
from builtins import object
25
28
import ehtim .observing .obs_simulate as simobs
26
29
import ehtim .io .save
27
30
import ehtim .io .load
31
+ import ehtim .const_def as ehc
28
32
29
- from ehtim .const_def import *
30
- from ehtim .observing .obs_helpers import *
31
-
32
- ###########################################################################################################################################
33
+ ###################################################################################################
33
34
# Array object
34
- ###########################################################################################################################################
35
+ ###################################################################################################
36
+
37
+
35
38
class Array (object ):
39
+
36
40
"""A VLBI array of telescopes with site locations, SEFDs, and other data.
37
41
38
42
Attributes:
39
43
tarr (numpy.recarray): The array of telescope data with datatype DTARR
40
44
tkey (dict): A dictionary of rows in the tarr for each site name
41
- ephem (dict): A dictionary of TLEs for each space antenna, Space antennas have x=y=z=0 in the tarr
45
+ ephem (dict): A dictionary of TLEs for each space antenna,
46
+ Space antennas have x=y=z=0 in the tarr
42
47
"""
43
48
44
49
def __init__ (self , tarr , ephem = {}):
@@ -47,39 +52,40 @@ def __init__(self, tarr, ephem={}):
47
52
48
53
# check to see if ephemeris is correct
49
54
for line in self .tarr :
50
- if np .any (np .isnan ([line ['x' ],line ['y' ],line ['z' ]])):
55
+ if np .any (np .isnan ([line ['x' ], line ['y' ], line ['z' ]])):
51
56
sitename = str (line ['site' ])
52
57
try :
53
58
elen = len (ephem [sitename ])
54
59
except NameError :
55
- raise Exception ('no ephemeris for site %s !' % sitename )
60
+ raise Exception ('no ephemeris for site %s !' % sitename )
56
61
if elen != 3 :
57
62
58
- raise Exception ('wrong ephemeris format for site %s !' % sitename )
63
+ raise Exception ('wrong ephemeris format for site %s !' % sitename )
59
64
60
65
# Dictionary of array indices for site names
61
66
self .tkey = {self .tarr [i ]['site' ]: i for i in range (len (self .tarr ))}
62
67
63
68
def listbls (self ):
64
69
"""List all baselines.
65
-
70
+
66
71
Args:
67
- Returns:
72
+ Returns:
68
73
numpy.array : array of baselines
69
74
"""
70
75
71
76
bls = []
72
77
for i1 in sorted (self .tarr ['site' ]):
73
78
for i2 in sorted (self .tarr ['site' ]):
74
- if not ([i1 ,i2 ] in bls ) and not ([i2 ,i1 ] in bls ) and i1 != i2 :
75
- bls .append ([i1 ,i2 ])
76
-
77
- return np .array (bls )
79
+ if not ([i1 , i2 ] in bls ) and not ([i2 , i1 ] in bls ) and i1 != i2 :
80
+ bls .append ([i1 , i2 ])
81
+ bls = np .array (bls )
78
82
79
- def obsdata (self , ra , dec , rf , bw , tint , tadv , tstart , tstop , mjd = MJD_DEFAULT , timetype = 'UTC' ,
80
- polrep = 'stokes' , elevmin = ELEV_LOW , elevmax = ELEV_HIGH ,
81
- tau = TAUDEF , fix_theta_GMST = False ):
83
+ return bls
82
84
85
+ def obsdata (self , ra , dec , rf , bw , tint , tadv , tstart , tstop ,
86
+ mjd = ehc .MJD_DEFAULT , timetype = 'UTC' , polrep = 'stokes' ,
87
+ elevmin = ehc .ELEV_LOW , elevmax = ehc .ELEV_HIGH ,
88
+ tau = ehc .TAUDEF , fix_theta_GMST = False ):
83
89
"""Generate u,v points and baseline uncertainties.
84
90
85
91
Args:
@@ -102,23 +108,23 @@ def obsdata(self, ra, dec, rf, bw, tint, tadv, tstart, tstop, mjd=MJD_DEFAULT, t
102
108
"""
103
109
104
110
obsarr = simobs .make_uvpoints (self , ra , dec , rf , bw ,
105
- tint , tadv , tstart , tstop ,
106
- mjd = mjd , polrep = polrep , tau = tau ,
107
- elevmin = elevmin , elevmax = elevmax ,
108
- timetype = timetype , fix_theta_GMST = fix_theta_GMST )
111
+ tint , tadv , tstart , tstop ,
112
+ mjd = mjd , polrep = polrep , tau = tau ,
113
+ elevmin = elevmin , elevmax = elevmax ,
114
+ timetype = timetype , fix_theta_GMST = fix_theta_GMST )
109
115
110
116
uniquetimes = np .sort (np .unique (obsarr ['time' ]))
111
- scans = np .array ([[time - 0.5 * tadv , time + 0.5 * tadv ] for time in uniquetimes ])
112
- source = str (ra ) + ":" + str (dec )
113
- obs = ehtim .obsdata .Obsdata (ra , dec , rf , bw , obsarr , self .tarr ,
117
+ scans = np .array ([[time - 0.5 * tadv , time + 0.5 * tadv ] for time in uniquetimes ])
118
+ source = str (ra ) + ":" + str (dec )
119
+ obs = ehtim .obsdata .Obsdata (ra , dec , rf , bw , obsarr , self .tarr ,
114
120
source = source , mjd = mjd , timetype = timetype , polrep = polrep ,
115
- ampcal = True , phasecal = True , opacitycal = True ,
121
+ ampcal = True , phasecal = True , opacitycal = True ,
116
122
dcal = True , frcal = True ,
117
123
scantable = scans )
118
124
return obs
119
125
120
126
def make_subarray (self , sites ):
121
- """Make a subarray from the Array object array that only includes the sites listed in sites .
127
+ """Make a subarray from the Array object array that only includes the sites listed.
122
128
123
129
Args:
124
130
sites (list) : list of sites in the subarray
@@ -127,22 +133,25 @@ def make_subarray(self, sites):
127
133
"""
128
134
all_sites = [t [0 ] for t in self .tarr ]
129
135
mask = np .array ([t in sites for t in all_sites ])
130
- return Array (self .tarr [mask ],ephem = self .ephem )
136
+ subarr = Array (self .tarr [mask ], ephem = self .ephem )
137
+ return subarr
131
138
132
139
def save_txt (self , fname ):
133
140
"""Save the array data in a text file.
134
141
135
142
Args:
136
143
fname (str) : path to output array file
137
144
"""
138
- ehtim .io .save .save_array_txt (self ,fname )
145
+ ehtim .io .save .save_array_txt (self , fname )
139
146
return
140
147
141
- ###########################################################################################################################################
142
- #Array creation functions
143
- ###########################################################################################################################################
148
+ ##########################################################################
149
+ # Array creation functions
150
+ ##########################################################################
151
+
152
+
144
153
def load_txt (fname , ephemdir = 'ephemeris' ):
145
- """Read an array from a text file.
154
+ """Read an array from a text file.
146
155
Sites with x=y=z=0 are spacecraft, TLE ephemerides read from ephemdir.
147
156
148
157
Args:
0 commit comments