1 # A Python TDL script to test the AzEl node
   2 
   3 # standard preamble
   4 from Timba.TDL import *
   5 from Timba.Meq import meq
   6 from Timba.Meq import meqds
   7 from numarray import *
   8 
   9 # Timba.TDL.Settings.forest_state is a standard TDL name.
  10 # This is a record passed to Set.Forest.State.
  11 Settings.forest_state.cache_policy = 100;
  12 
  13 def _define_forest (ns):
  14   """define_forest() is a standard TDL name. When a forest script is
  15   loaded by, e.g., the browser, this method is automatically called to
  16   define the forest. The 'ns' argument is a NodeScope object in which
  17   the forest is to be defined, usually this is simply the global scope.
  18   """;
  19 # set up a sequence of nodes for testing of the AzEl node
  20 
  21 # first define an RA and DEC (in radians)
  22   ra = 0.0
  23   dec = 0.57595865
  24   ns.ra0 << Meq.Parm(ra,node_groups='Parm')
  25   ns.dec0 << Meq.Parm(dec,node_groups='Parm')
  26 
  27 # then create a MeqComposer containing ra dec children
  28   ns.RADec <<Meq.Composer(ns.ra0, ns.dec0)
  29 
  30 # station positions for one of the VLA telescopes - gets converted
  31 # into an aips++ MVDirection object in the AzEl node;
  32 # (units are metres)
  33   X_pos = -1597262.96
  34   Y_pos = -5043205.54
  35   Z_pos = 3554901.34
  36   ns.x_pos << Meq.Parm(X_pos,node_groups='Parm')
  37   ns.y_pos << Meq.Parm(Y_pos,node_groups='Parm')
  38   ns.z_pos << Meq.Parm(Z_pos,node_groups='Parm')
  39 
  40 # create a  MeqComposer containing X_pos, Y_pos, Z_pos children
  41   ns.XYZ <<Meq.Composer(ns.x_pos, ns.y_pos, ns.z_pos)
  42 
  43 # we should now be able to create an AzEl node with X,Y,Z station positions
  44   ns.AzEl << Meq.AzEl(radec=ns.RADec, xyz=ns.XYZ)
  45 
  46 # we should also be able to specify the VLA position directly
  47   ns.AzEl1 << Meq.AzEl(radec=ns.RADec, observatory='VLA')
  48 
  49 # create a ReqSeq node to call the two AzEl nodes
  50   ns.reqseq <<Meq.ReqSeq(ns.AzEl,ns.AzEl1)
  51 
  52 def _test_forest (mqs,parent):
  53   """test_forest() is a standard TDL name. When a forest script is
  54   loaded by, e.g., the browser, and the "test" option is set to true,
  55   this method is automatically called after define_forest() to run a
  56   test on the forest. The 'mqs' argument is a meqserver proxy object.
  57   """;
  58 
  59 ####
  60 # time and frequency domain
  61 # time - cover one day
  62   t0 = 0.01;
  63   t1 = 86400.01;
  64 
  65 # any old frequency####
  66   f1 =  299792458.0;
  67   f0 = 0.9*f1;
  68 
  69 # Make cells array - we will compute Azimuth and Elevation over a period
  70 # of one day divided into 120 segments
  71 
  72   cells = meq.cells(meq.domain(f0,f1,t0,t1),num_freq=1,num_time=120);
  73 
  74 # define request
  75   request = meq.request(cells,rqtype='e1')
  76 
  77 # execute request
  78   a = mqs.meq('Node.Execute',record(name='reqseq',request=request),wait=True);
  79 
  80 # The following is the testing branch, executed when the script is run directly
  81 # via 'python script.py'
  82 if __name__ == '__main__':
  83   Timba.TDL._dbg.set_verbose(5);
  84   ns = NodeScope();
  85   _define_forest(ns);
  86   # resolves nodes
  87   ns.Resolve();

MeqAzEl.py (last edited 2007-03-19 20:59:20 by TonyWillis)