Introduction

This tutorial is aimed at observers who want to "batch reduce" their data, i.e. process multiple files the same way.

Part I - Need to knows

As ASAP is python based, we need to know a few commands and expression. Python has "lists", which are basically vectors. We will use these extensively.
x = range(5) # creates a vector of length 5, x = [0,1,2,3,4]
len(x)       # gives the length of the vector
x[0]         # gets the first element of the vector
x[-1]        # gets the last element of the vector
"for" loops are very useful. The code which should be run in the loop has to be indented. The end of the loop is indicated by the fact that the next command is aligned with the for.
The following code prints out the numbers [0..4]
for i in range(5):
   print i
Vectors can also be filled:
x = [] # empty
for i in range(5):
   x.append(i*5)
The output is x = [0,5,10,15,20]
Now we can access those elements like we did above (by index), or directly:
for i in x:
   print i
That's all we need to know!

Part II - the code

This shows example code to process multiple files.

Let's say we have three files (a.rpf, b.rpf, c.rpf) which contain on/off pairs and we want to get the quotients

fnames = ["a.rpf","b.rpf","c.rpf"] # First we set up a vector of filenames
vec = []                           # a vector to hold the scantables
for f in fnames:
   vec.append(scantable(f))        # fill the vector with scantables
Then we can loop over all scantables:
quotients = []                        # to hold the quotient scantables
for scan in vec:                      # loop over input scantables
   quotients.append(scan.auto_quotient()) # add this quotient to the vector
Let's have a look at the vector, and subtract a baseline
for q in quotients:
   print q
   q.auto_poly_baseline(order=1,insitu=True)
Now we average the lot together:
av = average_time(quotients)

Appendix

More info can be found on the ASAP homepage http://www.atnf.csiro.au/computing/software/asap