source: trunk/tutorials/tutorial_5.rst@ 2241

Last change on this file since 2241 was 1636, checked in by Malte Marquarding, 15 years ago

Added sphinx project for ASAP tutorials

File size: 3.1 KB
RevLine 
[1636]1===========================
2Tutorial #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
8without using mx quotient
9
10Files
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
22Instructions
23------------
24
251. Load the data from RPFITS file
26
272. Play with various methods to get access to the data
28
293. Run the reduction script using the built-in quotient
30
314. Copy the template script doing the quotient
32
335. 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
41Copy *systemquotient.py* to a new name, change the import statement at the
42top of *tutorial.py* to load your file instead of the *systemquotient.py*.
43
44.. code-block:: python
45
46 from myquotient import *
47
48Now your version of `makeQuotient` will be called from *tutorial.py*.
49Use 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
55Inspect the content.
56
57.. code-block:: python
58
59 sc.summary()
60
61The file contains 7 scans. Each scan corresponds to observations of a source
62with a different beam of a 7-beam receiver. We want to use the median
63spectrum from all other scans as a reference when constructing the quotient
64using the formula
65
66.. code-block:: none
67
68 Result = Toff * (On/Off - 1),
69
70where Toff is the system temperature measured during the reference scan, On
71is the signal spectrum, Off is the reference spectrum. We want to construct
72Result for each individual beam (out of 7 beams available) and average all
73these spectra together.
74
75To 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
87To 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
94To merge the scans together (i.e. individual quotients for each beam) build
95a 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
104Note that merge will fail if the list has only 1 element. An if-statement may
105be necessary
106To scale the scantable with the constant factor use::
107
108 scan.scale(factor,tsys=False, insitu=True)
109
110To add a constant use::
111
112 scan.add(constant_to_add, insitu=True)
113
114To get the tsys use::
115
116 scan.get_tsys()
117
118Note that some selection of data is usually necessary. Otherwise `get_tsys()`
119returns too many numbers.
120To divide two spectra simply divide one scan table to another::
121
122 quotient = signal / ref
Note: See TracBrowser for help on using the repository browser.