You add the flag log_policy=100 (yes, I know it's obvious... the idea is that I'll make various levels of logging detail available, higher numbers mean more logging.) Here's an example:
ns.AzEl << \ Meq.AzEl(radec=ns.RADec, observatory='VLA',log_policy=100)
You can also enable logging globally by setting forest_state.log_policy=100. The log filename is set via forest_state.log_file_name; the default name is "meqlog.mql". The file is in binary format. You can read it with the 'boio' interface provided by the mequtils module. A very simple script that will read the log and print its contents is Timba/PyApps/test/read_meqlog.py:
1 from Timba import dmi
2 from Timba import mequtils
3
4 boio = mequtils.open_boio("meqlog.mql");
5
6 while True:
7 entry = mequtils.read_boio(boio);
8 if entry is None:
9 break;
10 for key,val in entry.iteritems():
11 if isinstance(val,dmi.record):
12 print key,"record";
13 else:
14 print key,val;
You can use this as a starting point for more elaborate log processing. For example, here's a demo script showing how to retrieve and plot some data using the pylab package:
1 from pylab import *
2 from Timba import dmi
3 from Timba import mequtils
4 from Timba.Plugins.VellsData import *
5 from numarray import *
6
7 # open the file containing the stored data
8 boio = mequtils.open_boio("meqlog.mql");
9
10 # create a VellsData object to split up and store the
11 # incoming data record
12 vells_data = VellsData()
13
14 # create lists to store the specific data we want
15 # to plot
16 y_axis = []
17 x_axis = []
18 i = 0
19
20 # NOTE: exactly what an individual user will want
21 # to retrieve and plot will obviously vary. The
22 # VellsData object allows retrieval of the data
23 # by the active plane number. Since we are often
24 # dealing with 2 x 2 Jones matrices, a VellsData
25 # object may often have 4 planes. In our example
26 # here we want to retrieve and combine the data
27 # from XX and YY (planes 0 and 3) visibilities.
28 while True:
29 entry = mequtils.read_boio(boio);
30 if entry is None:
31 break;
32 for key,val in entry.iteritems():
33 if isinstance(val,dmi.record):
34 # if the key is 'result' then we have a record
35 # with data generated by the node
36 if key == 'result':
37 vells_data.StoreVellsData(val,key)
38 vells_data.setActivePlane(0)
39 plane0 =abs(vells_data.getActiveData())
40 vells_data.setActivePlane(3)
41 plane3 = abs(vells_data.getActiveData())
42 vis_ampl = 0.5 * (plane0 + plane3)
43 for j in range(len(vis_ampl)):
44 xval = (-14400 + 15 + i * 30) / 3600.0
45 i = i + 1
46 x_axis.append(xval)
47 y_axis.append(vis_ampl[j])
48 else:
49 print key,val;
50
51 y_array = array(y_axis)
52 mean = y_array.mean()
53 y_array = y_array / mean
54
55 # make a simple plot with pylab / matplotlib
56 plot(x_axis, y_array)
57 xlabel('Hour Angle (hrs)')
58 ylabel('normalized visibility amplitude')
59 title('FPA gain error as a function of Hour Angle')
60 grid(True)
61 savefig('simple_plot')
62 show()
Finally, note the following:
Using log_policy=100 at a node places the results in a log file (meqlog.mql). But, when iteratively executing requests to that node (with e.g. different domains), the log file is overwritten at each iteration. You can get around this problem by setting the global forest_state log_append flag to True with:
Settings.forest_state.log_append=True
But ... watch out for this scenario: If you have created the meqlog.mql file with script A and then run script B with log_append=True then the output of the node in script B will be appended to the already existing meqlog.mql file, even though the node doing the writing in script B may be totally unrelated to the node doing the writing in script A.
