1 # Tests the Meqtree LMRaDec and LMN nodes
2
3 # Copyright: The MeqTree Foundation
4
5 # standard preamble
6 from Timba.TDL import *
7 from Timba.Meq import meq
8 from Timba.Meq import meqds
9
10 # Timba.TDL.Settings.forest_state is a standard TDL name.
11 # This is a record passed to Set.Forest.State.
12 Settings.forest_state.cache_policy = 100;
13
14 def _define_forest (ns):
15 """define_forest() is a standard TDL name. """;
16 # set up a sequence of nodes for testing of the LMRaDec node
17
18 # first define a field centre RA and DEC (in radians)
19 ra = 1.0
20 dec = 1.0
21 ns.ra0 << Meq.Parm(ra,node_groups='Parm')
22 ns.dec0 << Meq.Parm(dec,node_groups='Parm')
23
24 # then create a MeqComposer containing the field centre
25 # RA and DEC as children
26 ns.RADec0 <<Meq.Composer(ns.ra0, ns.dec0)
27
28 # then define an L,M location (in radians) with respect to
29 # the field centre
30 L_pos = -0.1 # radians
31 M_pos = 0.5 # radians
32 ns.l_pos << Meq.Parm(L_pos,node_groups='Parm')
33 ns.m_pos << Meq.Parm(M_pos,node_groups='Parm')
34
35 # create a MeqComposer containing L_pos and M_pos as children
36 ns.LM <<Meq.Composer(ns.l_pos, ns.m_pos)
37
38 # we should now be able to create an LMRaDec node with the
39 # field centre RA and DEC and the L and M offsets as
40 # children. This node gives as output the RA and DEC
41 # corresponding to the specified L,M offset.
42 ns.LMRaDec << Meq.LMRaDec(radec_0=ns.RADec0, lm=ns.LM)
43
44 # Finally, as a check: convert the resulting RA and DEC back
45 # to L,M with respect to the field centre. This is done by
46 # creating an LMN node which has the field centre
47 # RA and DEC and the offset RA and DEC as children.
48 ns.LMN << Meq.LMN(ns.RADec0, ns.LMRaDec)
49
50 def _test_forest (mqs,parent):
51 """test_forest() is a standard TDL name.""";
52
53 ####
54 # any old time and frequency domain will do
55 # time - cover one day
56 t0 = 0.01;
57 t1 = 86400.01;
58
59 # any old frequency
60 f1 = 299792458.0;
61 f0 = 0.9*f1;
62
63 ####
64 # Make cells array - a period of one day divided into 120 segments
65
66 cells = meq.cells(meq.domain(f0,f1,t0,t1),num_freq=1,num_time=120);
67
68 # define request
69 request = meq.request(cells,rqtype='e1')
70
71 # execute request
72 a = mqs.meq('Node.Execute',record(name='LMN',request=request),
73 wait=True);
74
75 # The following is the testing branch, executed when the script is run directly
76 # via 'python script.py'
77 if __name__ == '__main__':
78 Timba.TDL._dbg.set_verbose(5);
79 ns = NodeScope();
80 _define_forest(ns);
81 # resolves nodes
82 ns.Resolve();
