def compute_piercings(ns, source_list, stations=None): """Creates nodes to compute the "piercing points" of each source in source_list, for each antenna in array.""" stations = stations or Context.array.stations() xyz = Context.array.xyz() radec0 = Context.observation.phase_centre.radec() # project our stations into an ionospheric coordinate system xyz1 # for now, we just project everything to z=0, and take station 1 as origin for p in stations: # xyz_proj gives positions projected to equatorial plane (z=0) xyzp = ns.xyz_proj(p) << Meq.Paster(xyz(p), 0, index=2) # xyz1 gives positions relative to station1 xyz1 = ns.xyz1(p) << xyzp - ns.xyz_proj(stations[0]) # and extract the xy1 component ns.xy1(p) << Meq.Selector(xyz1, index=[0, 1], multi=True) # if ionosphere is "stuck" to the sky, we need to rotate the antenna # coordinates as we go along. Otherwise we need to rotate the piercing # coordinates. The angle of rotation is given by the P.A. _at the # projected antenna positions_. if iono_rotate: ns.pa0 << -Meq.ParAngle(xyz=ns.xyz_proj(stations[0]), radec=radec0) ns.P0 << Jones.define_rotation_matrix(ns.pa0) for p in stations: # if ionosphere is stuck to the sky, rotate antenna coordinates by P0 if iono_rotate: ns.xy_r(p) << Meq.MatrixMultiply(ns.P0, ns.xy1(p)) else: # else create P (p/a rotation matrix) ns.pa(p) << -Meq.ParAngle(xyz=ns.xyz_proj(p), radec=radec0) ns.P(p) << Jones.define_rotation_matrix(ns.pa(p)) for src in source_list: lm = src.direction.lm() lm_sq = ns.lm_sq(src.name) << Meq.Sqr(lm) # dxy is the relative X,Y coordinate of the piercing point for this source, # relative to centre. In each direction it's to H*tg(alpha), where # alpha is the direction of the source w.r.t. center (i.e., arccos l). ns.dxy(src.name) << H * lm / Meq.Sqrt(1 - lm_sq) # now compute absolute piercings per source, per antenna for p in Context.array.stations(): if iono_rotate: ns.pxy(src.name, p) << ns.xy_r(p) + ns.dxy(src.name) else: ns.pxy(src.name, p) << ns.xy1(p) + Meq.MatrixMultiply( ns.P(p), ns.dxy(src.name)) return ns.pxy
def compute_piercings (ns,source_list,stations=None): """Creates nodes to compute the "piercing points" of each source in source_list, for each antenna in array."""; stations = stations or Context.array.stations(); xyz = Context.array.xyz(); radec0 = Context.observation.phase_centre.radec(); # project our stations into an ionospheric coordinate system xyz1 # for now, we just project everything to z=0, and take station 1 as origin for p in stations: # xyz_proj gives positions projected to equatorial plane (z=0) xyzp = ns.xyz_proj(p) << Meq.Paster(xyz(p),0,index=2); # xyz1 gives positions relative to station1 xyz1 = ns.xyz1(p) << xyzp - ns.xyz_proj(stations[0]); # and extract the xy1 component ns.xy1(p) << Meq.Selector(xyz1,index=[0,1],multi=True); # if ionosphere is "stuck" to the sky, we need to rotate the antenna # coordinates as we go along. Otherwise we need to rotate the piercing # coordinates. The angle of rotation is given by the P.A. _at the # projected antenna positions_. if iono_rotate: ns.pa0 << - Meq.ParAngle(xyz=ns.xyz_proj(stations[0]),radec=radec0); ns.P0 << Jones.define_rotation_matrix(ns.pa0); for p in stations: # if ionosphere is stuck to the sky, rotate antenna coordinates by P0 if iono_rotate: ns.xy_r(p) << Meq.MatrixMultiply(ns.P0,ns.xy1(p)); else: # else create P (p/a rotation matrix) ns.pa(p) << - Meq.ParAngle(xyz=ns.xyz_proj(p),radec=radec0); ns.P(p) << Jones.define_rotation_matrix(ns.pa(p)); for src in source_list: lm = src.direction.lm(); lm_sq = ns.lm_sq(src.name) << Meq.Sqr(lm); # dxy is the relative X,Y coordinate of the piercing point for this source, # relative to centre. In each direction it's to H*tg(alpha), where # alpha is the direction of the source w.r.t. center (i.e., arccos l). ns.dxy(src.name) << H*lm/Meq.Sqrt(1-lm_sq); # now compute absolute piercings per source, per antenna for p in Context.array.stations(): if iono_rotate: ns.pxy(src.name,p) << ns.xy_r(p) + ns.dxy(src.name); else: ns.pxy(src.name,p) << ns.xy1(p) + Meq.MatrixMultiply(ns.P(p),ns.dxy(src.name)); return ns.pxy;
def compute_jones(self, nodes, stations=None, tags=None, label='', **kw): stations = stations or Context.array.stations() g_ampl_def = Meow.Parm(1) g_phase_def = Meow.Parm(0) nodes = Jones.gain_ap_matrix(nodes, g_ampl_def, g_phase_def, tags=tags, series=stations) # make parmgroups for phases and gains self.pg_phase = ParmGroup.ParmGroup( label + "_phase", nodes.search(tags="solvable phase"), table_name="%s_phase.fmep" % label, bookmark=4) self.pg_ampl = ParmGroup.ParmGroup(label + "_ampl", nodes.search(tags="solvable ampl"), table_name="%s_ampl.fmep" % label, bookmark=4) # make solvejobs ParmGroup.SolveJob("cal_" + label + "_phase", "Calibrate %s phases" % label, self.pg_phase) ParmGroup.SolveJob("cal_" + label + "_ampl", "Calibrate %s amplitudes" % label, self.pg_ampl) return nodes
def compute_jones (self,nodes,stations=None,tags=None,label='',inspectors=[],**kw): stations = stations or Context.array.stations(); rot_def = Meow.Parm(0); nr = Jones.rotation_matrix(nodes("R"),rot_def,tags=tags,series=stations); ne = Jones.ellipticity_matrix(nodes("E"),rot_def,tags=tags,series=stations); for p in stations: nodes(p) << Meq.MatrixMultiply(nr(p),ne(p)); # make parmgroups for phases and gains self.pg_rot = ParmGroup.ParmGroup(label+"_leakage", nodes.search(tags="solvable"), table_name="%s_leakage.mep"%label,bookmark=True); # make solvejobs ParmGroup.SolveJob("cal_"+label+"_leakage","Calibrate %s (leakage)"%label,self.pg_rot); # make inspector for parameters StdTrees.inspector(nodes('inspector'),self.pg_rot.nodes,bookmark=False); inspectors.append(nodes('inspector')); return nodes;
def compute_jones(self, nodes, stations=None, tags=None, label='', inspectors=[], **kw): stations = stations or Context.array.stations() rot_def = Meow.Parm(0) nr = Jones.rotation_matrix(nodes("R"), rot_def, tags=tags, series=stations) ne = Jones.ellipticity_matrix(nodes("E"), rot_def, tags=tags, series=stations) for p in stations: nodes(p) << Meq.MatrixMultiply(nr(p), ne(p)) # make parmgroups for phases and gains self.pg_rot = ParmGroup.ParmGroup(label + "_leakage", nodes.search(tags="solvable"), table_name="%s_leakage.mep" % label, bookmark=True) # make solvejobs ParmGroup.SolveJob("cal_" + label + "_leakage", "Calibrate %s (leakage)" % label, self.pg_rot) # make inspector for parameters StdTrees.inspector(nodes('inspector'), self.pg_rot.nodes, bookmark=False) inspectors.append(nodes('inspector')) return nodes
def compute_jones (self,nodes,stations=None,tags=None,label='',**kw): stations = stations or Context.array.stations(); g_ampl_def = Meow.Parm(1); g_phase_def = Meow.Parm(0); nodes = Jones.gain_ap_matrix(nodes,g_ampl_def,g_phase_def,tags=tags,series=stations); # make parmgroups for phases and gains self.pg_phase = ParmGroup.ParmGroup(label+"_phase", nodes.search(tags="solvable phase"), table_name="%s_phase.fmep"%label,bookmark=4); self.pg_ampl = ParmGroup.ParmGroup(label+"_ampl", nodes.search(tags="solvable ampl"), table_name="%s_ampl.fmep"%label,bookmark=4); # make solvejobs ParmGroup.SolveJob("cal_"+label+"_phase","Calibrate %s phases"%label,self.pg_phase); ParmGroup.SolveJob("cal_"+label+"_ampl","Calibrate %s amplitudes"%label,self.pg_ampl); return nodes;