source: branches/Release12/web/tutorials/tutorial2.html@ 2417

Last change on this file since 2417 was 680, checked in by mar637, 19 years ago

merge from Release-2-fixes

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 3.1 KB
Line 
1<html>
2<head>
3<title>Batch processing tutorial</title>
4<style type="text/css" media="all">
5div.shell {
6background-color: #dbfff9;
7padding: 0.1em;
8}
9div.code {
10background-color: #c9ffbf;
11padding: 0.1em;
12}
13div.main {
14margin: 0.2em 0.2em 0.2em 0.2em;
15text-align: left;
16font-family: sans-serif;
17width: auto;
18}
19h1.custom {
20background-color: #aaaaaa;
21color: #000000;
22padding: 0.5em;
23font-family: sans-serif;
24font-size: x-large;
25}
26</style>
27</head>
28<body>
29<div>
30<h1 class=custom>
31Introduction
32</h1>
33<div class=main align=center>
34This tutorial is aimed at observers who want to "batch reduce" their
35data, i.e. process multiple files the same way.
36</div>
37<h1 class=custom>
38Part I - Need to knows
39</h1>
40<div class=main align=center>
41As ASAP is python based, we need to know a few commands and expression.
42Python has "lists", which are basically vectors. We will use
43these extensively.<br>
44<div class=code><pre>
45x = range(5) # creates a vector of length 5, x = [0,1,2,3,4]
46len(x) # gives the length of the vector
47x[0] # gets the first element of the vector
48x[-1] # gets the last element of the vector
49</pre></div>
50"for" loops are very useful. The code which should be run in the loop
51has to be indented. The end of the loop is indicated by the fact that
52the next command is aligned with the for.<br>
53The following code prints out the numbers [0..4]
54<div class=code><pre>
55for i in range(5):
56 print i
57</pre></div>
58Vectors can also be filled:
59<div class=code><pre>
60x = [] # empty
61for i in range(5):
62 x.append(i*5)
63</pre></div>
64The output is x = [0,5,10,15,20]<br>
65Now we can access those elements like we did above (by index), or directly:
66<div class=code><pre>
67for i in x:
68 print i
69</pre></div>
70That's all we need to know!
71
72</div>
73<h1 class=custom>
74Part II - the code
75</h1>
76<div class=main align=center>
77This shows example code to process multiple files.<p>
78Let's say we have three files (a.rpf, b.rpf, c.rpf) which contain
79on/off pairs and we want to get the quotients<br>
80<div class=code><pre>
81fnames = ["a.rpf","b.rpf","c.rpf"] # First we set up a vector of filenames
82vec = [] # a vector to hold the scantables
83for f in fnames:
84 vec.append(scantable(f)) # fill the vector with scantables
85</pre></div>
86Then we can loop over all scantables:
87<div class=code><pre>
88quotients = [] # to hold the quotient scantables
89for scan in vec: # loop over input scantables
90 on = scan.get_source("*_S")
91 off = scan.get_source("*_R")
92 quotients.append(quotient(on,off)) # add this quotient to the vector
93</pre></div>
94Let's have a look at the vector, and subtract a baseline
95<div class=code><pre>
96for q in quotients:
97 print q
98 q.auto_poly_baseline(order=1,insitu=True)
99</pre></div>
100Now we average the lot together:
101<div class=code><pre>
102av = average_time(quotients)
103</pre></div>
104
105</div>
106<h1 class=custom>
107Appendix
108</h1>
109<div class=main align=center>
110More info can be found on the ASAP homepage
111<a href="http://www.atnf.csiro.au/computing/software/asap">
112http://www.atnf.csiro.au/computing/software/asap</a>
113</div>
114</body>
115</html>
Note: See TracBrowser for help on using the repository browser.