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