1 | =========================== |
---|
2 | Tutorial #5 - ASAP advanced |
---|
3 | =========================== |
---|
4 | |
---|
5 | .. sectionauthor:: Maxim Voronkov |
---|
6 | |
---|
7 | **Main goal:** To understand how to handle the data manually by building a quotient |
---|
8 | without using mx quotient |
---|
9 | |
---|
10 | Files |
---|
11 | ----- |
---|
12 | |
---|
13 | * 2009-04-02 2240 MMB-MX-11.9-0.13333.rpf data file |
---|
14 | |
---|
15 | * Script 1: tutorial.py general reduction script |
---|
16 | |
---|
17 | * Script 2: systemquotient.py script doing built-in quotient (to be copied and modified) |
---|
18 | |
---|
19 | * Script 3: userquotient.py the result (youâre not supposed to look into itunless desperate) |
---|
20 | |
---|
21 | |
---|
22 | Instructions |
---|
23 | ------------ |
---|
24 | |
---|
25 | 1. Load the data from RPFITS file |
---|
26 | |
---|
27 | 2. Play with various methods to get access to the data |
---|
28 | |
---|
29 | 3. Run the reduction script using the built-in quotient |
---|
30 | |
---|
31 | 4. Copy the template script doing the quotient |
---|
32 | |
---|
33 | 5. Modify makeQuotient method to replicate the functionality of the built-in mx quotient |
---|
34 | |
---|
35 | **Help:** Use help method in asap to get information about parameters, etc |
---|
36 | |
---|
37 | .. code-block:: python |
---|
38 | |
---|
39 | %run tutorial.py |
---|
40 | |
---|
41 | Copy *systemquotient.py* to a new name, change the import statement at the |
---|
42 | top of *tutorial.py* to load your file instead of the *systemquotient.py*. |
---|
43 | |
---|
44 | .. code-block:: python |
---|
45 | |
---|
46 | from myquotient import * |
---|
47 | |
---|
48 | Now your version of `makeQuotient` will be called from *tutorial.py*. |
---|
49 | Use the following to load the data into a scan table called sc |
---|
50 | |
---|
51 | .. code-block:: python |
---|
52 | |
---|
53 | sc=scantable("2009-04-02_2240_MMB-MX-11.9-0.13333.rpf") |
---|
54 | |
---|
55 | Inspect the content. |
---|
56 | |
---|
57 | .. code-block:: python |
---|
58 | |
---|
59 | sc.summary() |
---|
60 | |
---|
61 | The file contains 7 scans. Each scan corresponds to observations of a source |
---|
62 | with a different beam of a 7-beam receiver. We want to use the median |
---|
63 | spectrum from all other scans as a reference when constructing the quotient |
---|
64 | using the formula |
---|
65 | |
---|
66 | .. code-block:: none |
---|
67 | |
---|
68 | Result = Toff * (On/Off - 1), |
---|
69 | |
---|
70 | where Toff is the system temperature measured during the reference scan, On |
---|
71 | is the signal spectrum, Off is the reference spectrum. We want to construct |
---|
72 | Result for each individual beam (out of 7 beams available) and average all |
---|
73 | these spectra together. |
---|
74 | |
---|
75 | To do the selection |
---|
76 | |
---|
77 | .. code-block:: python |
---|
78 | |
---|
79 | sel=sc.get_selection() |
---|
80 | sel.set_beams(0) |
---|
81 | sel.set_scans(0) |
---|
82 | sel.set_polarisations(0) |
---|
83 | sc.set_selection(sel) |
---|
84 | selected_sc = sc.copy() |
---|
85 | selected_sc.summary() |
---|
86 | |
---|
87 | To average or compute the median use one of |
---|
88 | |
---|
89 | .. code-block:: python |
---|
90 | |
---|
91 | ref.average_time(weight="median") |
---|
92 | scans.average_time() |
---|
93 | |
---|
94 | To merge the scans together (i.e. individual quotients for each beam) build |
---|
95 | a python list first and then use merge and average time |
---|
96 | |
---|
97 | .. code-block:: python |
---|
98 | |
---|
99 | res=[] |
---|
100 | for b in range(7): |
---|
101 | res.append(myFunctionReturningAScanTable(beam)) |
---|
102 | averaged_scantable = average_time(merge(res)) |
---|
103 | |
---|
104 | Note that merge will fail if the list has only 1 element. An if-statement may |
---|
105 | be necessary |
---|
106 | To scale the scantable with the constant factor use:: |
---|
107 | |
---|
108 | scan.scale(factor,tsys=False, insitu=True) |
---|
109 | |
---|
110 | To add a constant use:: |
---|
111 | |
---|
112 | scan.add(constant_to_add, insitu=True) |
---|
113 | |
---|
114 | To get the tsys use:: |
---|
115 | |
---|
116 | scan.get_tsys() |
---|
117 | |
---|
118 | Note that some selection of data is usually necessary. Otherwise `get_tsys()` |
---|
119 | returns too many numbers. |
---|
120 | To divide two spectra simply divide one scan table to another:: |
---|
121 | |
---|
122 | quotient = signal / ref |
---|