source: branches/Release2.1/web/tutorials/tutorial2.html@ 1721

Last change on this file since 1721 was 1040, checked in by mar637, 19 years ago

Web doc update for usage of ASAP v2

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 3.0 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 quotients.append(scan.auto_quotient()) # add this quotient to the vector
91</pre></div>
92Let's have a look at the vector, and subtract a baseline
93<div class=code><pre>
94for q in quotients:
95 print q
96 q.auto_poly_baseline(order=1,insitu=True)
97</pre></div>
98Now we average the lot together:
99<div class=code><pre>
100av = average_time(quotients)
101</pre></div>
102
103</div>
104<h1 class=custom>
105Appendix
106</h1>
107<div class=main align=center>
108More info can be found on the ASAP homepage
109<a href="http://www.atnf.csiro.au/computing/software/asap">
110http://www.atnf.csiro.au/computing/software/asap</a>
111</div>
112</body>
113</html>
Note: See TracBrowser for help on using the repository browser.