1 | \documentclass[11pt]{article} |
---|
2 | \usepackage{a4} |
---|
3 | \usepackage[dvips]{graphicx} |
---|
4 | |
---|
5 | % Adjust the page size |
---|
6 | \addtolength{\oddsidemargin}{-0.4in} |
---|
7 | \addtolength{\evensidemargin}{+0.4in} |
---|
8 | \addtolength{\textwidth}{+0.8in} |
---|
9 | |
---|
10 | \setlength{\parindent}{0mm} |
---|
11 | \setlength{\parskip}{1ex} |
---|
12 | |
---|
13 | |
---|
14 | \title{ATNF Spectral Analysis Package\\Cookbook } |
---|
15 | \author{Chris Phillips} |
---|
16 | |
---|
17 | |
---|
18 | \newcommand{\cmd}[1]{{\tt #1}} |
---|
19 | |
---|
20 | \begin{document} |
---|
21 | |
---|
22 | \maketitle |
---|
23 | |
---|
24 | \section{Introduction} |
---|
25 | |
---|
26 | ASAP is a single dish spectral line processing package currently being |
---|
27 | developed by the ATNF. It is intended to process data from all ATNF |
---|
28 | antennas, and can probably be used for other antnnas if they can |
---|
29 | produce ``Single Dish FITS'' format. It is based on the AIPS++ |
---|
30 | package. |
---|
31 | |
---|
32 | %\section{Documentation Standards} |
---|
33 | |
---|
34 | %In most of the examples in this document, it has been assumed that the |
---|
35 | |
---|
36 | \section{Installation and Running} |
---|
37 | |
---|
38 | Currently there are installations running on Linux machines at |
---|
39 | |
---|
40 | \begin{itemize} |
---|
41 | \item Epping - use hosts {\tt draco} or {\tt hydra} |
---|
42 | \item Narrabri - use host {\tt kaputar} |
---|
43 | \item Parkes - use host {\tt bourbon} |
---|
44 | \item Mopra - use host {\tt minos} |
---|
45 | \end{itemize} |
---|
46 | |
---|
47 | To start asap log onto one of these Linux hosts and enter |
---|
48 | |
---|
49 | \begin{verbatim} |
---|
50 | > cd /my/data/directory |
---|
51 | > asap |
---|
52 | \end{verbatim} |
---|
53 | |
---|
54 | This starts the ASAP. To quit, you need to type \verb+^+-d |
---|
55 | (control-d). |
---|
56 | |
---|
57 | \section{Interface} |
---|
58 | |
---|
59 | ASAP is written in C++ and python. The user interface uses the |
---|
60 | ``ipython'' interactive shell, which is a simple interactive interface |
---|
61 | to python. The user does not need to understand python to use this, |
---|
62 | but certain aspects python affect what the user can do. The current |
---|
63 | interface is object oriented. In the future, we will build a |
---|
64 | functional (non object oriented) shell on top of this to ease |
---|
65 | interactive use. |
---|
66 | |
---|
67 | \subsection {Integer Indices are 0-relative} |
---|
68 | |
---|
69 | Please note, all integer indices in ASAP and iPython are {\bf 0-relative}. |
---|
70 | |
---|
71 | \subsection{Objects} |
---|
72 | |
---|
73 | The ASAP interface is based around a number of ``objects'' which the |
---|
74 | user deals with. Objects range from the data which have been read from |
---|
75 | disk, to tools used for fitting functions to the data. The following |
---|
76 | main objects are used : |
---|
77 | |
---|
78 | \begin{itemize} |
---|
79 | \item[\cmd{scantable}] The data container (actual spectra and header |
---|
80 | information) |
---|
81 | \item[\cmd{fitter}] A tool used to fit functions to the spectral data |
---|
82 | \item[\cmd{plotter}] A tool used to plot the spectral line data |
---|
83 | \item[\cmd{reader}] A tool which can be used to read data from disks |
---|
84 | into a scantable object. |
---|
85 | \end{itemize} |
---|
86 | |
---|
87 | There can be many objects of the same type. Each object is referred to |
---|
88 | by a variable name made by the user. The name of this variable is not |
---|
89 | important and can be set to whatever the user prefers (ie ``s'' and |
---|
90 | ``ParkesHOH-20052002'' are equivalent). However, having a simple and |
---|
91 | consistent naming convention will help you a lot. |
---|
92 | |
---|
93 | \subsection{Member Functions (functions)} |
---|
94 | |
---|
95 | Following the object oriented approach, objects have associated |
---|
96 | ``member functions'' which can either be used to modify the data in |
---|
97 | some way or change global properties of the object. In this document |
---|
98 | member functions will be referred to simply as functions. From the |
---|
99 | command line, the user can execute these functions using the syntax: |
---|
100 | \begin{verbatim} |
---|
101 | ASAP> out = object.function(arguments) |
---|
102 | \end{verbatim} |
---|
103 | |
---|
104 | Where \cmd{out} is the name of the returned variable (could be a new |
---|
105 | scantable object, or a vector of data, or a status return), |
---|
106 | \cmd{object} is the object variable name (set by the user), |
---|
107 | \cmd{function} is the name of the member function and \cmd{arguments} |
---|
108 | is a list of arguments to the function. The arguments can be provided |
---|
109 | either though position or \cmd{name=}. A mix of the two can be used. |
---|
110 | E.g. |
---|
111 | |
---|
112 | \begin{verbatim} |
---|
113 | ASAP> av = scans(msk,weight='tsys') |
---|
114 | ASAP> av = scans(mask=msk,weight='tsys') |
---|
115 | ASAP> av = scans(msk,True) |
---|
116 | ASAP> scans.polybaseline(mask=msk, order=0, insitu=True) |
---|
117 | ASAP> scans.polybaseline(msk,0,True) |
---|
118 | ASAP> scans.polybaseline(mask, insitu=True) |
---|
119 | \end{verbatim} |
---|
120 | |
---|
121 | \subsection{Global Functions} |
---|
122 | |
---|
123 | It does not make sense to implement some functions as member |
---|
124 | functions, typically functions which operate on more than one |
---|
125 | scantable (e.g. time averaging of many scans). These functions will |
---|
126 | always be referred to as global functions. |
---|
127 | |
---|
128 | \subsection{Interactive environment} |
---|
129 | |
---|
130 | ipython has a number of useful interactive features and a few things to be aware |
---|
131 | of for the new user. |
---|
132 | |
---|
133 | \subsubsection{String completion} |
---|
134 | |
---|
135 | Tab completion is enabled for all function names. If you type the |
---|
136 | first few letters of a function name, then type {\tt <TAB>} the |
---|
137 | function name will be auto completed if it is un-ambiguous, or a list |
---|
138 | of possibilities will be given. Auto-completion works for the user |
---|
139 | object names as well as function names. It does not work for |
---|
140 | filenames, nor for function arguments. |
---|
141 | |
---|
142 | Example |
---|
143 | \begin{verbatim} |
---|
144 | ASAP> scans = scantable('MyData.rpf') |
---|
145 | ASAP> scans.se<TAB> |
---|
146 | scans.set_cursor scans.set_freqframe scans.set_unit scans.setpol |
---|
147 | scans.set_doppler scans.set_instrument scans.setbeam |
---|
148 | scans.set_fluxunit scans.set_restfreqs scans.setif |
---|
149 | ASAP> scans.set_in<TAB> |
---|
150 | ASAP> scans.set_instrument |
---|
151 | \end{verbatim} |
---|
152 | |
---|
153 | \subsubsection{Leading Spaces} |
---|
154 | |
---|
155 | Python uses leading space to mark blocks of code. This means that it |
---|
156 | you start a command line with a space, the command generally will |
---|
157 | fail with an syntax error. |
---|
158 | |
---|
159 | \subsubsection{Unix Interaction} |
---|
160 | |
---|
161 | Basic unix shell commands (\cmd{pwd}, \cmd{ls}, \cmd{cd} etc) can be |
---|
162 | issued from within ASAP. This allows the user to do things like look |
---|
163 | at files in the current directory. The shell command ``\cmd{cd}'' |
---|
164 | works within ASAP, allowing the user to change between data |
---|
165 | directories. Unix programs cannot be run this way, but the shell |
---|
166 | escape ``$!$'' can be used to run arbitrary programs. E.g. |
---|
167 | |
---|
168 | \begin{verbatim} |
---|
169 | ASAP> pwd |
---|
170 | ASAP> ls |
---|
171 | ASAP> ! mozilla& |
---|
172 | \end{verbatim} |
---|
173 | |
---|
174 | \subsection{Help} |
---|
175 | |
---|
176 | ASAP has built in help for all functions. To get a list of functions type: |
---|
177 | |
---|
178 | \begin{verbatim} |
---|
179 | ASAP> commands |
---|
180 | \end{verbatim} |
---|
181 | |
---|
182 | To get help on specific functions, the built in help needs to be given |
---|
183 | the object and function name. E.g. |
---|
184 | |
---|
185 | \begin{verbatim} |
---|
186 | ASAP> help scantable.get_scan |
---|
187 | ASAP> help scantable.stats |
---|
188 | ASAP> help plotter.plot |
---|
189 | ASAP> help fitter.plot |
---|
190 | |
---|
191 | ASAP> scans = scantable('mydata.asap') |
---|
192 | ASAP> help scans.get_scan # Same as above |
---|
193 | \end{verbatim} |
---|
194 | |
---|
195 | Global functions just need their name |
---|
196 | |
---|
197 | \begin{verbatim} |
---|
198 | ASAP> help average_time |
---|
199 | \end{verbatim} |
---|
200 | |
---|
201 | Note that if you just type \cmd{help} the internal ipython help is |
---|
202 | invoked, which is probably {\em not} what you want. Type \verb+^+-d |
---|
203 | (control-d) to escape from this. |
---|
204 | |
---|
205 | \subsection{.asaprc} |
---|
206 | |
---|
207 | ASAP use an \cmd{.asaprc} file to control the user's preference of |
---|
208 | default values for various functions arguments. This includes the |
---|
209 | defaults for arguments such as \cmd{insitu}, scantable \cmd{freqframe} |
---|
210 | and the plotters \cmd{set\_mode} values. The help on individual |
---|
211 | functions says which arguments can be set default values from the |
---|
212 | \cmd{.asaprc} file. To get a sample contents for the \cmd{.asaprc} |
---|
213 | file use then command \cmd{list\_rcparameters}. |
---|
214 | |
---|
215 | Common values include: |
---|
216 | \begin{verbatim} |
---|
217 | # apply operations on the input scantable or return new one |
---|
218 | insitu : False |
---|
219 | |
---|
220 | # default ouput format when saving scantable |
---|
221 | scantable.save : 'ASAP' |
---|
222 | |
---|
223 | |
---|
224 | # default frequency frame to set when function |
---|
225 | # scantable.set_freqframe is called |
---|
226 | scantable.freqframe : 'LSRK' |
---|
227 | |
---|
228 | # auto averaging on read |
---|
229 | scantable.autoaverage : True |
---|
230 | \end{verbatim} |
---|
231 | |
---|
232 | \section{Scantables} |
---|
233 | |
---|
234 | \subsection {Description} |
---|
235 | |
---|
236 | \subsubsection {Basic Structure} |
---|
237 | |
---|
238 | ASAP data handling works on objects called scantables. A scantable |
---|
239 | holds your data, and also provides functions to operate |
---|
240 | upon it. |
---|
241 | |
---|
242 | The building block of a scantable is an integration, which is a single |
---|
243 | row of a scantable. Each row contains spectra for each beam, IF and |
---|
244 | polarisation. For example Parkes multibeam data would contain many |
---|
245 | beams, one IF and 2-4 polarisations, while the new Mopra 8-GHz |
---|
246 | filterbank will eventually produce one beam, many IFs, and 2-4 |
---|
247 | polarisations. |
---|
248 | |
---|
249 | A collection of sequential integrations (rows) for one source is termed |
---|
250 | a scan (and each scan has a unique numeric identifier, the ScanID). A |
---|
251 | scantable is then a collection of one or more scans. If you have |
---|
252 | scan-averaged your data in time, then each scan would hold just one |
---|
253 | (averaged) integration. |
---|
254 | |
---|
255 | Many of the functions which work on scantables can either return a |
---|
256 | new scantable with modified data or change the scantable insitu. Which |
---|
257 | method is used depends on the users preference. The default can be |
---|
258 | changed via the {\tt .asaprc} resource file. |
---|
259 | |
---|
260 | \subsubsection {Contents} |
---|
261 | |
---|
262 | A scantable has header information and data (a scantable is actually an AIPS++ |
---|
263 | Table and it is stored in Memory when you are manipulating it with ASAP. |
---|
264 | You can store it to disk and then browse it with the AIPS++ |
---|
265 | Table browser if you know how to do that !). |
---|
266 | |
---|
267 | The data are stored in columns (the length of a column is the number of |
---|
268 | rows/integrations of course). |
---|
269 | |
---|
270 | Two important columns are those that describe the frequency setup. We mention |
---|
271 | them explicitly here because you need to be able to understand the presentation |
---|
272 | of the frequency information and possibly how to manipulate it. |
---|
273 | |
---|
274 | These columns are called FreqID and RestFreqID. They contain indices, for |
---|
275 | each IF, pointing into tables with all of the frequency information for that |
---|
276 | integration. More on these below when we discuss the \cmd{summary} function |
---|
277 | in the next subsection. |
---|
278 | |
---|
279 | There are of course many other columns which contain the actual spectra, |
---|
280 | the flags, the Tsys, the source names and so on, but those are a little |
---|
281 | more transparently handled. |
---|
282 | |
---|
283 | \subsection{Management} |
---|
284 | |
---|
285 | During processing it is possible to create a large number of scan |
---|
286 | tables. These all consume memory, so it is best to periodically remove |
---|
287 | unneeded scan tables. Use \cmd{list\_scans} to print a list of all |
---|
288 | scantables and \cmd{del} to remove unneeded ones. |
---|
289 | |
---|
290 | Example: |
---|
291 | |
---|
292 | \begin{verbatim} |
---|
293 | ASAP> list_scans |
---|
294 | The user created scantables are: |
---|
295 | ['s', 'scans', 'av', 's2', 'ss'] |
---|
296 | |
---|
297 | ASAP> del s2 |
---|
298 | ASAP> del ss |
---|
299 | \end{verbatim} |
---|
300 | |
---|
301 | There is also a function \cmd{summary} to list a summary of the scantable. |
---|
302 | You will find this very useful. |
---|
303 | |
---|
304 | Example: |
---|
305 | |
---|
306 | \begin{verbatim} |
---|
307 | ASAP> scans = scantable('MyData.rpf') |
---|
308 | ASAP> scans.summary() # Brief listing |
---|
309 | ASAP> scans.summary(verbose=True) # Include frequency information |
---|
310 | |
---|
311 | # Equivalent to brief summary function call |
---|
312 | ASAP> print scan |
---|
313 | \end{verbatim} |
---|
314 | |
---|
315 | Most of what the \cmd{summary} function prints out is obvious. However, |
---|
316 | it also prints out the FreqIDs and RestFreqIDs to which we alluded above. |
---|
317 | These are the last column of the listing. |
---|
318 | |
---|
319 | The summary function gives you a scan-based summary. So it lists all of |
---|
320 | the FreqIDs and RestFreqIDs that it encountered for each scan. If you'd |
---|
321 | like to see what each FreqID actually means, then set the verbose |
---|
322 | argument to True and the frequency table will be listed at the end. |
---|
323 | FreqID of 3 say, refers to the fourth row of the frequency table (ASAP |
---|
324 | is 0-relative). The list of rest frequencies, to which the RestFreqIDs |
---|
325 | refer, is always listed. |
---|
326 | |
---|
327 | %You can copy one scantable to another with the \cmd{copy} function. |
---|
328 | |
---|
329 | %Example: |
---|
330 | |
---|
331 | %\begin{verbatim} |
---|
332 | % ASAP> scans = scantable('MyData.rpf') |
---|
333 | % ASAP> scan2 = scans.copy() |
---|
334 | %\end{verbatim} |
---|
335 | |
---|
336 | \subsection{State} |
---|
337 | |
---|
338 | Each scantable contains "state"; these are properties applying to all |
---|
339 | of the data in the scantable. |
---|
340 | |
---|
341 | Examples are the selection of beam, IF and polarisation, spectral unit |
---|
342 | (e.g. km/s) frequency reference frame (e.g. BARY) and velocity Doppler |
---|
343 | type (e.g. RADIO). |
---|
344 | |
---|
345 | \subsubsection{Units, Doppler and Frequency Reference Frame} |
---|
346 | |
---|
347 | The information describing the frequency setup for each integration |
---|
348 | is stored fundamentally in frequency in the reference frame |
---|
349 | of observation (E.g. TOPO). |
---|
350 | |
---|
351 | When required, this is converted to the desired reference frame |
---|
352 | (e.g. LSRK), Doppler (e.g. OPTICAL) and unit (e.g. km/s) on-the-fly. |
---|
353 | This is important, for example, when you are displaying the data or |
---|
354 | fitting to it. |
---|
355 | |
---|
356 | For units, the user has the choice of frequency, velocity or channel. |
---|
357 | The \cmd{set\_unit} function is used to set the current unit for a |
---|
358 | scantable. All functions will (where relevant) work with the selected |
---|
359 | unit until this changes. This is mainly important for fitting (the fits |
---|
360 | can be computed in any of these units), plotting and mask creation. |
---|
361 | |
---|
362 | The velocity definition can be changed with the \cmd{set\_doppler} |
---|
363 | function, and the frequency reference frame can be changed with the |
---|
364 | \cmd{set\_freqframe} function. |
---|
365 | |
---|
366 | Example usage: |
---|
367 | |
---|
368 | \begin{verbatim} |
---|
369 | ASAP> scans = scantable('2004-11-23_1841-P484.rpf') # Read in the data |
---|
370 | ASAP> scans.set_freqframe('LSRK') # Use the LSR velocity frame |
---|
371 | ASAP> scans.set_unit('km/s') # Use velocity for plots etc from now on |
---|
372 | ASAP> scans.set_doppler('OPTICAL') # Use the optical velocity convention |
---|
373 | ASAP> scans.set_unit('MHz') # Use frequency in MHz from now on |
---|
374 | \end{verbatim} |
---|
375 | |
---|
376 | |
---|
377 | \subsubsection{Rest Frequency} |
---|
378 | |
---|
379 | ASAP reads the line rest frequency from the RPFITS file when reading |
---|
380 | the data. The values stored in the RPFITS file are not always correct |
---|
381 | and so there is a function \cmd{set\_restfreq} to set the rest frequencies. |
---|
382 | |
---|
383 | For each integration, there is a rest-frequency per IF (the rest |
---|
384 | frequencies are just stored as a list with an index into them). |
---|
385 | There are a few ways to set the rest frequencies with this function. |
---|
386 | |
---|
387 | If you specify just one rest frequency, then it is selected for the |
---|
388 | specified source and IF and added to the list of rest frequencies. |
---|
389 | |
---|
390 | \begin{verbatim} |
---|
391 | # Select for specified source/IF |
---|
392 | ASAP> scans.set_restfreqs(freqs=1.667359e9, source='NGC253', theif=0) |
---|
393 | |
---|
394 | # Select for all sources and IFs |
---|
395 | ASAP> scans.set_restfreqs(freqs=1.667359e9) |
---|
396 | \end{verbatim} |
---|
397 | |
---|
398 | |
---|
399 | If you specify a list of frequencies, then it must be of length the |
---|
400 | number of IFs. Regardless of the source, the rest frequency will be set |
---|
401 | for each IF to the corresponding value in the provided list. The |
---|
402 | internally stored list of rest frequencies will be replaced by this |
---|
403 | list. |
---|
404 | |
---|
405 | |
---|
406 | \begin{verbatim} |
---|
407 | # Select for specified source/IF |
---|
408 | ASAP> scans.set_restfreqs(freqs=1.667359e9, source='NGC253', theif=0) |
---|
409 | |
---|
410 | # Select for all sources and IFs |
---|
411 | ASAP> scans.set_restfreqs(freqs=1.667359e9) |
---|
412 | \end{verbatim} |
---|
413 | |
---|
414 | |
---|
415 | In both of the above modes, you can also specify the rest frequencies via |
---|
416 | names in a known list rather than by their values. |
---|
417 | |
---|
418 | Examples: |
---|
419 | |
---|
420 | \begin{verbatim} |
---|
421 | ASAP> scans.lines() # Print list of known lines |
---|
422 | ASAP> scans.set_restfreqs(lines=['OH1665','OH1667']) |
---|
423 | \end{verbatim} |
---|
424 | |
---|
425 | |
---|
426 | |
---|
427 | \subsection{Data Selection} |
---|
428 | |
---|
429 | Data selection is currently fairly limited. This will be improved in |
---|
430 | the future. |
---|
431 | |
---|
432 | |
---|
433 | \subsubsection{Cursor} |
---|
434 | |
---|
435 | Generally the user will want to run functions on all rows in a |
---|
436 | scantable. This allows very fast reduction of data. There are situations |
---|
437 | when functions should only operate on specific elements of the spectra. This |
---|
438 | is handled by the scantable cursor, which allows the user to select a |
---|
439 | single beam, IF and polarisation combination. |
---|
440 | |
---|
441 | Example : |
---|
442 | |
---|
443 | \begin{verbatim} |
---|
444 | ASAP> scans.set_cursor(0,2,1) # beam, IF, pol |
---|
445 | ASAP> scans.smooth(allaxes=F) # in situ by default or .aipsrc |
---|
446 | \end{verbatim} |
---|
447 | |
---|
448 | \subsubsection{Row number} |
---|
449 | |
---|
450 | Most functions work on all rows of a scan table. Exceptions are the |
---|
451 | fitter and plotter. If you wish to only operate on a selected set of |
---|
452 | scantable rows, use the \cmd{get\_scan} function to copy the rows into |
---|
453 | a new scantable. |
---|
454 | |
---|
455 | \subsubsection{Allaxes} |
---|
456 | |
---|
457 | Many functions have an \cmd{allaxes} option which controls whether the |
---|
458 | function will operate on all elements within a scantable row, or just |
---|
459 | those selected with the current cursor. The default is taken from the |
---|
460 | users {\tt .asaprc} file. |
---|
461 | |
---|
462 | \subsubsection{Masks} |
---|
463 | |
---|
464 | Many tasks (fitting, baseline subtraction, statistics etc) should only |
---|
465 | be run on range of channels. Depending on the current ``unit'' setting |
---|
466 | this range is set directly as channels, velocity or frequency |
---|
467 | ranges. Internally these are converted into a simple boolean mask for |
---|
468 | each channel of the abscissa. This means that if the unit setting is |
---|
469 | later changed, previously created mask are still valid. (This is not |
---|
470 | true for functions which change the shape or shift the frequency axis). |
---|
471 | You create masks with the function \cmd{create\_mask} and this specified |
---|
472 | the channels to be included in the selection. |
---|
473 | |
---|
474 | When setting the mask in velocity, the conversion from velocity |
---|
475 | to channels is based on the current cursor setting, selected row and |
---|
476 | selected frequency reference frame. |
---|
477 | |
---|
478 | Example : |
---|
479 | \begin{verbatim} |
---|
480 | |
---|
481 | # Select channel range for baselining |
---|
482 | ASAP> scans.set_unit('channels') |
---|
483 | ASAP> msk = scans.create_mask([100,400],[600,800]) |
---|
484 | |
---|
485 | # Select velocity range for fitting |
---|
486 | ASAP> scans.set_unit('km/s') |
---|
487 | ASAP> msk = scans.create_mask([-30,-10]) |
---|
488 | \end{verbatim} |
---|
489 | |
---|
490 | Sometimes it is more convenient to specify the channels to be |
---|
491 | excluded, rather included. You can do this with the ``invert'' |
---|
492 | argument. |
---|
493 | |
---|
494 | Example : |
---|
495 | \begin{verbatim} |
---|
496 | ASAP> scans.set_unit('channels') |
---|
497 | ASAP> msk = scans.create_mask([0,100],[900-1023], invert=True) |
---|
498 | \end{verbatim} |
---|
499 | |
---|
500 | By default \cmd{create\_mask} uses the frequency setup of the first row |
---|
501 | to convert velocities into a channel mask. If the rows in the data |
---|
502 | cover different velocity ranges, the scantable row to use should be |
---|
503 | specified: |
---|
504 | |
---|
505 | \begin{verbatim} |
---|
506 | ASAP> scans.set_unit('km/s') |
---|
507 | ASAP> msk = q.create_mask([-30,-10], row=5) |
---|
508 | \end{verbatim} |
---|
509 | |
---|
510 | Because the mask is stored in a simple python variable, the users is |
---|
511 | able to combine masks using simple arithmetic. To create a mask |
---|
512 | excluding the edge channels, a strong maser feature and a birdie in |
---|
513 | the middle of the band: |
---|
514 | |
---|
515 | \begin{verbatim} |
---|
516 | ASAP> scans.set_unit('channels') |
---|
517 | ASAP> msk1 = q.create_mask([0,100],[511,511],[900,1023],invert=True) |
---|
518 | ASAP> scans.set_unit('km/s') |
---|
519 | ASAP> msk2 = q.create_mask([-20,-10],invert=True) |
---|
520 | |
---|
521 | ASAP> mask = msk1 and msk2 |
---|
522 | \end{verbatim} |
---|
523 | |
---|
524 | |
---|
525 | \section{Data Input} |
---|
526 | |
---|
527 | Data can be loaded in one of two ways; using the reader object or via |
---|
528 | the scantable constructor. The scantable method is simpler but the |
---|
529 | reader allow the user more control on what is read. |
---|
530 | |
---|
531 | \subsection{Scantable constructor} |
---|
532 | |
---|
533 | This loads all of the data from filename into the scantable object scans |
---|
534 | and averages all the data within a scan (i.e. the resulting scantable |
---|
535 | will have one row per scan). The recognised input file formats are |
---|
536 | RPFITS, SDFITS (singledish fits), ASAP's scantable format and aips++ |
---|
537 | MeasurementSet2 format. |
---|
538 | |
---|
539 | |
---|
540 | Example usage: |
---|
541 | |
---|
542 | \begin{verbatim} |
---|
543 | ASAP> scan = scantable('2004-11-23_1841-P484.rpf') |
---|
544 | |
---|
545 | # Don't scan average the data |
---|
546 | ASAP> scan = scantable('2004-11-23_1841-P484.rpf', average=False) |
---|
547 | \end{verbatim} |
---|
548 | |
---|
549 | |
---|
550 | \subsection{Reader object} |
---|
551 | |
---|
552 | For more control when reading data into ASAP, the reader object should |
---|
553 | be used. This has the option of only reading in a range of integrations |
---|
554 | and does not perform any scan averaging of the data, allowing analysis |
---|
555 | of the individual integrations. Note that due to limitation of the |
---|
556 | RPFITS library, only one reader object can be open at one time reading |
---|
557 | RPFITS files. To read multiple RPFITS files, the old reader must be |
---|
558 | destroyed before the new file is opened. However, multiple readers can |
---|
559 | be created and attached to SDFITS files. |
---|
560 | |
---|
561 | |
---|
562 | Example usage: |
---|
563 | |
---|
564 | \begin{verbatim} |
---|
565 | ASAP> r = reader('2003-03-16_082048_t0002.rpf') |
---|
566 | ASAP> r.summary |
---|
567 | ASAP> scan = r.read() |
---|
568 | ASAP> s = r.read(range(100)) # To read in the first 100 integrations |
---|
569 | ASAP> del r |
---|
570 | \end{verbatim} |
---|
571 | |
---|
572 | \section{Basic Processing} |
---|
573 | |
---|
574 | In the following section, a simple data reduction to form a quotient |
---|
575 | spectrum of a single source is followed. It has been assume that the |
---|
576 | \cmd{.asaprc} file has {\em not} been used to change the \cmd{insitu} |
---|
577 | default value from \cmd{True}. |
---|
578 | |
---|
579 | %\subsection{Editing} |
---|
580 | |
---|
581 | %How and when? |
---|
582 | |
---|
583 | \subsection{Separate reference and source observations} |
---|
584 | |
---|
585 | Most data from ATNF observatories distinguishes on and off source data |
---|
586 | using the file name. This makes it easy to create two scantables with |
---|
587 | the source and reference data. As long as there was exactly one |
---|
588 | reference observation for each on source observation for following |
---|
589 | method will work. |
---|
590 | |
---|
591 | For Mopra and Parkes data: |
---|
592 | \begin{verbatim} |
---|
593 | ASAP> r = scans.get_scan('*_R') |
---|
594 | ASAP> s = scans.get_scan('*_S') |
---|
595 | \end{verbatim} |
---|
596 | |
---|
597 | For Tidbinbilla data |
---|
598 | \begin{verbatim} |
---|
599 | ASAP> r = scans.get_scan('*_[ew]') |
---|
600 | ASAP> s = scans.get_scan('*_[^ew]') |
---|
601 | \end{verbatim} |
---|
602 | |
---|
603 | \subsection{Make the quotient spectra} |
---|
604 | |
---|
605 | Use the quotient function |
---|
606 | |
---|
607 | \begin{verbatim} |
---|
608 | ASAP> q = s.quotient(r) |
---|
609 | \end{verbatim} |
---|
610 | |
---|
611 | This uses the rows in scantable \cmd{r} as reference spectra for the |
---|
612 | rows in scantable \cmd{s}. Scantable \cmd{r} must have either 1 row |
---|
613 | (which is applied to all rows in \cmd{s}) or both scantables must have |
---|
614 | the same number of rows. By default the quotient spectra is calculated |
---|
615 | to preserve continuum emission. If you wish to remove the continuum |
---|
616 | contribution, use the \cmd{preserve} argument: |
---|
617 | |
---|
618 | \begin{verbatim} |
---|
619 | ASAP> q = s.quotient(r, preserve=True) |
---|
620 | \end{verbatim} |
---|
621 | |
---|
622 | \subsection{Time average separate scans} |
---|
623 | |
---|
624 | If you have observed the source with multiple source/reference cycles you |
---|
625 | will want to scan-average the quotient spectra together. |
---|
626 | |
---|
627 | \begin{verbatim} |
---|
628 | ASAP> av = average_time(q) |
---|
629 | \end{verbatim} |
---|
630 | |
---|
631 | If for some you want to average multiple sets of scantables together |
---|
632 | you can: |
---|
633 | |
---|
634 | \begin{verbatim} |
---|
635 | ASAP> av = average_time(q1, q2, q3) |
---|
636 | \end{verbatim} |
---|
637 | |
---|
638 | The default is to use integration time weighting. The alternative is |
---|
639 | to use none, variance , Tsys weighting or Tsys \& integration time. |
---|
640 | |
---|
641 | \begin{verbatim} |
---|
642 | ASAP> av = average_time(q, weight='tintsys') |
---|
643 | \end{verbatim} |
---|
644 | |
---|
645 | To use variance based weighting, you need to supply a mask saying which |
---|
646 | channel range you want it to calculate the variance from. |
---|
647 | |
---|
648 | \begin{verbatim} |
---|
649 | ASAP> msk = scans.create_mask([200,400],[600,800]) |
---|
650 | ASAP> av = average_time(scans, mask=msk, weight='var') |
---|
651 | \end{verbatim} |
---|
652 | |
---|
653 | \subsection{Baseline fitting} |
---|
654 | |
---|
655 | To make a baseline fit, you must first create a mask of channels to |
---|
656 | use in the baseline fit. |
---|
657 | |
---|
658 | \begin{verbatim} |
---|
659 | ASAP> msk = scans.create_mask([100,400],[600,900]) |
---|
660 | ASAP> scans.poly_baseline(msk, 1) |
---|
661 | \end{verbatim} |
---|
662 | |
---|
663 | This will fit a first order polynomial to the selected channels and subtract |
---|
664 | this polynomial from the full spectra. |
---|
665 | |
---|
666 | \subsubsection{Auto-baselining} |
---|
667 | |
---|
668 | The function \cmd{auto\_poly\_baseline} can be used to automatically |
---|
669 | baseline your data with out having to specify channel ranges for |
---|
670 | the line free data. It automatically figures out the line-free |
---|
671 | emission and fits a polynomial baseline to that data. The user can use |
---|
672 | masks to fix the range of channels or velocity range for the fit as |
---|
673 | well as mark the band edge as invalid. |
---|
674 | |
---|
675 | Simple example |
---|
676 | |
---|
677 | \begin{verbatim} |
---|
678 | ASAP> scans.auto_poly_baseline(order=2,threshold=5) |
---|
679 | \end{verbatim} |
---|
680 | |
---|
681 | \cmd{order} is the polynomial order for the fit. \cmd{threshold} is |
---|
682 | the SNR threshold to use to deliminate line emission from |
---|
683 | signal. Generally the value of threshold is not too critical, however |
---|
684 | making this too large will compromise the fit (as it will include |
---|
685 | strong line features) and making it too small will mean it cannot find |
---|
686 | enough line free channels. |
---|
687 | |
---|
688 | |
---|
689 | Other examples: |
---|
690 | |
---|
691 | \begin{verbatim} |
---|
692 | # Don't try and fit the edge of the bandpass which is noisier |
---|
693 | ASAP> scans.auto_poly_baseline(edge=(500,450),order=3,threshold=3) |
---|
694 | |
---|
695 | # Only fit a given region around the line |
---|
696 | ASAP> scans.set_unit('km/s') |
---|
697 | ASAP> msk = scans.create_mask((-60,-20)) |
---|
698 | ASAP> scans.auto_poly_baseline(mask=msk,order=3,threshold=3) |
---|
699 | |
---|
700 | \end{verbatim} |
---|
701 | |
---|
702 | \subsection{Average the polarisations} |
---|
703 | |
---|
704 | If you are just interested in the highest SNR for total intensity you |
---|
705 | will want to average the parallel polarisations together. |
---|
706 | |
---|
707 | \begin{verbatim} |
---|
708 | ASAP> scans.average_pol() |
---|
709 | \end{verbatim} |
---|
710 | |
---|
711 | \subsection{Calibration} |
---|
712 | |
---|
713 | For most uses, calibration happens transparently as the input data |
---|
714 | contains the Tsys measurements taken during observations. The nominal |
---|
715 | ``Tsys'' values may be in Kelvin or Jansky. The user may wish to |
---|
716 | supply a Tsys correction or apply gain-elevation and opacity |
---|
717 | corrections. |
---|
718 | |
---|
719 | \subsubsection{Brightness Units} |
---|
720 | |
---|
721 | RPFITS files to not contain any information as to whether the telescope |
---|
722 | calibration was in units of Kelvin or Janskys. On reading the data a |
---|
723 | default value is set depending on the telescope and frequency of |
---|
724 | observation. If this default is incorrect (you can see it in the |
---|
725 | listing from the \cmd{summary} function) the user can either override |
---|
726 | this value on reading the data or later. E.g: |
---|
727 | |
---|
728 | \begin{verbatim} |
---|
729 | ASAP> scans = scantable(('2004-11-23_1841-P484.rpf', unit='Jy') |
---|
730 | # Or in two steps |
---|
731 | ASAP> scans = scantable(('2004-11-23_1841-P484.rpf') |
---|
732 | ASAP> scans.set_fluxunit('Jy) |
---|
733 | \end{verbatim} |
---|
734 | |
---|
735 | \subsubsection{Tsys scaling} |
---|
736 | |
---|
737 | Sometime the nominal Tsys measurement at the telescope is wrong due to |
---|
738 | an incorrect noise diode calibration. This can easily be corrected for |
---|
739 | with the scale function. By default, \cmd{scale} only scans the |
---|
740 | spectra and not the corresponding Tsys. |
---|
741 | |
---|
742 | \begin{verbatim} |
---|
743 | ASAP> scans.scale(1.05, tsys=True) |
---|
744 | \end{verbatim} |
---|
745 | |
---|
746 | \subsubsection{Unit Conversion} |
---|
747 | |
---|
748 | To convert measurements in Kelvin to Jy (and vice versa) the global |
---|
749 | function \cmd{convert\_flux} is needed. This converts and scales the data |
---|
750 | from K to Jy or vice-versa depending on what the current brightness unit is |
---|
751 | set to. The function knows the basic parameters for some frequencies |
---|
752 | and telescopes, but the user may need to supply the aperture |
---|
753 | efficiency, telescope diameter or the Jy/K factor. |
---|
754 | |
---|
755 | \begin{verbatim} |
---|
756 | ASAP> scans.convert_flux # If efficency known |
---|
757 | ASAP> scans.convert_flux(eta=0.48) # If telescope diameter known |
---|
758 | ASAP> scans.convert_flux(eta=0.48,d=35) # Unknown telescope |
---|
759 | ASAP> scans.convert_flux(jypk=15) # Alternative |
---|
760 | \end{verbatim} |
---|
761 | |
---|
762 | \subsubsection{Gain-Elevation and Opacity Corrections} |
---|
763 | |
---|
764 | As higher frequencies (particularly $>$20~GHz) it is important to make |
---|
765 | corrections for atmospheric opacity and gain-elevation effects. |
---|
766 | |
---|
767 | Gain-elevation curves for some telescopes and frequencies are known to |
---|
768 | ASAP (currently only for Tidbinbilla at 20~GHz). In these cases making |
---|
769 | gain-corrections is simple. If the gain curve for your data is not |
---|
770 | known, the user can supply either a gain polynomial or text file |
---|
771 | tabulating gain factors at a range of elevations (see \cmd{help |
---|
772 | scantable.gain\_el}). |
---|
773 | |
---|
774 | Examples: |
---|
775 | |
---|
776 | \begin{verbatim} |
---|
777 | ASAP> scans.gain_el() # If gain table known |
---|
778 | ASAP> scans.gain_el(poly=[3.58788e-1,2.87243e-2,-3.219093e-4]) |
---|
779 | \end{verbatim} |
---|
780 | |
---|
781 | Opacity corrections can be made with the global function |
---|
782 | \cmd{opacity}. This should work on all telescopes as long as a |
---|
783 | measurement of the opacity factor was made during the observation. |
---|
784 | |
---|
785 | \begin{verbatim} |
---|
786 | ASAP> scans.opacity(0.083) |
---|
787 | \end{verbatim} |
---|
788 | |
---|
789 | Note that at 3~mm Mopra uses a paddle wheel for Tsys calibration, |
---|
790 | which takes opacity effects into account (to first order). ASAP |
---|
791 | opacity corrections should not be used for Mopra 3-mm data. |
---|
792 | |
---|
793 | \subsection{Frequency Frame Alignment} |
---|
794 | |
---|
795 | When time averaging a series of scans together, it is possible that |
---|
796 | the velocity scales are not exactly aligned. This may be for many |
---|
797 | reasons such as not Doppler tracking the observations, errors in the |
---|
798 | Doppler tracking etc. This mostly affects very long integrations or |
---|
799 | integrations averaged together from different days. Before averaging |
---|
800 | such data together, they should be frequency aligned using |
---|
801 | \cmd{freq\_align}. |
---|
802 | |
---|
803 | E.g.: |
---|
804 | |
---|
805 | \begin{verbatim} |
---|
806 | ASAP> scans.freq_align() |
---|
807 | ASAP> av = average_time(scans) |
---|
808 | \end{verbatim} |
---|
809 | |
---|
810 | \cmd{freq\_align} has two modes of operations controlled by the |
---|
811 | \cmd{perif} argument. By default it will align each source and freqid |
---|
812 | separately. This is needed for scan tables containing multiple |
---|
813 | sources. However if scan-based Doppler tracking has been made at the observatory, |
---|
814 | each row will have a different freqid. In these cases run with |
---|
815 | \cmd{perif=True} and all rows of a source will be aligned to the same |
---|
816 | frame. In general \cmd{perif=True} will be needed for most |
---|
817 | observations as Doppler tracking of some form is made at Parkes, Tid |
---|
818 | and Mopra. |
---|
819 | |
---|
820 | \begin{verbatim} |
---|
821 | ASAP> scans.freq_align(perif=True) |
---|
822 | \end{verbatim} |
---|
823 | |
---|
824 | To average together data taken on different days, which are in |
---|
825 | different scantables, each scantable must aligned to a common |
---|
826 | reference time then the scantables averaged. The simplest way of |
---|
827 | doing this is to allow ASAP to choose the reference time for the first |
---|
828 | scantable then using this time for the subsequent scantables. |
---|
829 | |
---|
830 | \begin{verbatim} |
---|
831 | ASAP> scans1.freq_align() # Copy the refeference Epoch from the output |
---|
832 | ASAP> scans2.freq_align(reftime='2004/11/23/18:43:35') |
---|
833 | ASAP> scans3.freq_align(reftime='2004/11/23/18:43:35') |
---|
834 | ASAP> av = average_time(scans1, scans2, scans3) |
---|
835 | \end{verbatim} |
---|
836 | |
---|
837 | \section{Scantable manipulation} |
---|
838 | |
---|
839 | While it is very useful to have many independent sources within one |
---|
840 | scantable, it is often inconvenient for data processing. The |
---|
841 | \cmd{get\_scan} function can be used to create a new scantable with a |
---|
842 | selection of scans from a scantable. The selection can either be on |
---|
843 | the source name, with simple wildcard matching or set of scan ids. |
---|
844 | |
---|
845 | For example: |
---|
846 | |
---|
847 | \begin{verbatim} |
---|
848 | ASAP> ss = scans.get_scan(10) # Get the 11th scan (zero based) |
---|
849 | ASAP> ss = scans.get_scan(range(10)) # Get the first 10 scans |
---|
850 | ASAP> ss = scans.get_scan(range(10,20)) # Get the next 10 scans |
---|
851 | ASAP> ss = scans.get_scan([2,4,6,8,10]) # Get a selection of scans |
---|
852 | |
---|
853 | ASAP> ss = scans.get_scan('345p407') # Get a specific source |
---|
854 | ASAP> ss = scans.get_scan('345*') # Get a few sources |
---|
855 | |
---|
856 | ASAP> r = scans.get_scan('*_R') # Get all reference sources (Parkes/Mopra) |
---|
857 | ASAP> s = scans.get_scan('*_S') # Get all program sources (Parkes/Mopra) |
---|
858 | ASAP> r = scans.get_scan('*_[ew]') # Get all reference sources (Tid) |
---|
859 | ASAP> s = scans.get_scan('*_[^ew]') # Get all program sources (Tid) |
---|
860 | |
---|
861 | \end{verbatim} |
---|
862 | |
---|
863 | To copy a scantable the following does not work: |
---|
864 | |
---|
865 | \begin{verbatim} |
---|
866 | ASAP> ss = scans |
---|
867 | \end{verbatim} |
---|
868 | |
---|
869 | as this just creates a reference to the original scantable. Any |
---|
870 | changes made to \cmd{ss} are also seen in \cmd{scans}. To duplicate a |
---|
871 | scantable, use the copy function. |
---|
872 | |
---|
873 | \begin{verbatim} |
---|
874 | ASAP> ss = scans.copy |
---|
875 | \end{verbatim} |
---|
876 | |
---|
877 | \section{Data Output} |
---|
878 | |
---|
879 | ASAP can save scantables in a variety of formats, suitable for reading |
---|
880 | into other packages. The formats are: |
---|
881 | |
---|
882 | \begin{itemize} |
---|
883 | \item[ASAP] This is the internal format used for ASAP. It is the only |
---|
884 | format that allows the user to restore the data, fits etc. without |
---|
885 | loosing any information. As mentioned before, the ASAP scantable is |
---|
886 | an AIPS++ Table (a memory-based table). This function just converts |
---|
887 | it to a disk-based Table. You can the access that Table with the |
---|
888 | AIPS++ Table browser or any other AIPS++ tool. |
---|
889 | |
---|
890 | \item[SDFITS] The Single Dish FITS format. This format was designed to |
---|
891 | for interchange between packages, but few packages actually can read |
---|
892 | it. |
---|
893 | |
---|
894 | \item[FITS] This uses simple ``image'' fits to save the data, each row |
---|
895 | being written to a separate fits file. This format is suitable for |
---|
896 | importing the data into CLASS. |
---|
897 | |
---|
898 | \item[ASCII] A simple text based format suitable for the user to |
---|
899 | processing using Perl or, Python, gnuplot etc. |
---|
900 | |
---|
901 | \item[MS2] Saves the data in an aips++ MeasurementSet V2 format. |
---|
902 | You can also access this with the Table browser and other AIPS++ |
---|
903 | tools. |
---|
904 | |
---|
905 | \end{itemize} |
---|
906 | |
---|
907 | The default output format can be set in the users {\tt .asaprc} file. |
---|
908 | Typical usages are: |
---|
909 | |
---|
910 | \begin{verbatim} |
---|
911 | ASAP> scans.save('myscans') # Save in default format |
---|
912 | ASAP> scans.save('myscans', 'FITS') # Save as FITS for exporting into CLASS |
---|
913 | |
---|
914 | ASAP> scans.save('myscans', stokes=True) # Convert raw polarisations into Stokes |
---|
915 | ASAP> scans.save('myscans', overwrite=True) # Overwrite an existing file |
---|
916 | \end{verbatim} |
---|
917 | |
---|
918 | |
---|
919 | \section{Plotter} |
---|
920 | |
---|
921 | Scantable spectra can be plotter at any time. An asapplotter object is |
---|
922 | used for plotting, meaning multiple plot windows can be active at the |
---|
923 | same time. On start up a default asapplotter object is created called |
---|
924 | ``plotter''. This would normally be used for standard plotting. |
---|
925 | |
---|
926 | The plotter, optionally, will run in a multipanel mode and contain |
---|
927 | multiple plots per panel. The user must tell the plotter how they want |
---|
928 | the data distributed. This is done using the set\_mode function. The |
---|
929 | default can be set in the users {\tt .asaprc} file. The units (and frame |
---|
930 | etc) of the abscissa will be whatever has previously been set by |
---|
931 | \cmd{set\_unit}, \cmd{set\_freqframe} etc. |
---|
932 | |
---|
933 | Typical plotter usage would be: |
---|
934 | |
---|
935 | \begin{verbatim} |
---|
936 | ASAP> scans.set_unit('km/s') |
---|
937 | ASAP> plotter.set_mode(stacking='p',panelling='t') |
---|
938 | ASAP> plotter.plot(scans) |
---|
939 | \end{verbatim} |
---|
940 | |
---|
941 | This will plot multiple polarisation within each plot panel and each |
---|
942 | scan row in a separate panel. |
---|
943 | |
---|
944 | Other possibilities include: |
---|
945 | |
---|
946 | \begin{verbatim} |
---|
947 | # Plot multiple IFs per panel |
---|
948 | ASAP> plotter.set_mode(stacking='i',panelling='t') |
---|
949 | |
---|
950 | # Plot multiple beams per panel |
---|
951 | ASAP> plotter.set_mode(stacking='b',panelling='t') |
---|
952 | |
---|
953 | # Plot one IF per panel, time stacked |
---|
954 | ASAP> plotter.set_mode('t', 'i') |
---|
955 | |
---|
956 | # Plot each scan in a seperate panel |
---|
957 | ASAP> plotter.set_mode('t', 's') |
---|
958 | |
---|
959 | \end{verbatim} |
---|
960 | |
---|
961 | \subsection{Plot Selection} |
---|
962 | \label{sec:plotter_cursor} |
---|
963 | |
---|
964 | The plotter can plot up to 25 panels and stacked spectra per |
---|
965 | panel. If you have data larger than this (or for your own sanity) you |
---|
966 | need to select a subset of this data. This is particularly true for |
---|
967 | multibeam or multi IF data. The plotter \cmd{set\_cursor} function is |
---|
968 | used to select a subset of the data. The arguments \cmd{row}, |
---|
969 | \cmd{beam} and \cmd{IF} all accept a vector of indices corresponding |
---|
970 | to row, beam or IF selection. Only the selected data will be plotted. |
---|
971 | To select on polarisation, see section~\ref{sec:polplot}. |
---|
972 | |
---|
973 | Examples: |
---|
974 | |
---|
975 | \begin{verbatim} |
---|
976 | # Select second IF |
---|
977 | ASAP> plotter.set_cursor(IF=[1]) |
---|
978 | |
---|
979 | # Select first 4 beams |
---|
980 | ASAP> plotter.set_cursor(beam=[0,1,2,3]) |
---|
981 | |
---|
982 | # Select a few rows |
---|
983 | ASAP> plotter.set_cursor(row=[2,4,6,10]) |
---|
984 | |
---|
985 | # Multiple selection |
---|
986 | ASAP> plotter.set_cursor(IF=[1], beam=[0,2], row=range(10)) |
---|
987 | \end{verbatim} |
---|
988 | |
---|
989 | Note that the plotter cursor selection is independent of the scantable |
---|
990 | cursor. |
---|
991 | |
---|
992 | \subsection{Plot Control} |
---|
993 | |
---|
994 | The plotter window has a row of buttons on the lower left. These can |
---|
995 | be used to control the plotter (mostly for zooming the individual |
---|
996 | plots). From left to right: |
---|
997 | |
---|
998 | \begin{itemize} |
---|
999 | |
---|
1000 | \item[Home] This will unzoom the plots to the original zoom factor |
---|
1001 | |
---|
1002 | \item[Plot history] (left and right arrow). The plotter keeps a |
---|
1003 | history of zoom settings. The left arrow sets the plot zoom to the |
---|
1004 | previous value. The right arrow returns back again. This allows you, |
---|
1005 | for example, to zoom in on one feature then return the plot to how it |
---|
1006 | was previously. |
---|
1007 | |
---|
1008 | \item[Pan] (The Cross) This sets the cursor to pan, or scroll mode |
---|
1009 | allowing you to shift the plot within the window. Useful when |
---|
1010 | zoomed in on a feature. |
---|
1011 | |
---|
1012 | \item[Zoom] (the letter with the magnifying glass) lets you draw a |
---|
1013 | rectangle around a region of interest then zooms in on that |
---|
1014 | region. Use the plot history to unzoom again. |
---|
1015 | |
---|
1016 | \item[Save] (floppy disk). Save the plot as a postscript or .png file |
---|
1017 | |
---|
1018 | \end{itemize} |
---|
1019 | |
---|
1020 | \subsection{Other control} |
---|
1021 | |
---|
1022 | The plotter has a number of functions to describe the layout of the |
---|
1023 | plot. These include \cmd{set\_legend}, \cmd{set\_layout} and \cmd{set\_title}. |
---|
1024 | |
---|
1025 | To set the exact velocity or channel range to be plotted use the |
---|
1026 | \cmd{set\_range} function. To reset to the default value, call |
---|
1027 | \cmd{set\_range} with no arguments. E.g. |
---|
1028 | |
---|
1029 | \begin{verbatim} |
---|
1030 | ASAP> scans.set_unit('km/s') |
---|
1031 | ASAP> plotter.plot(scans) |
---|
1032 | ASAP> plotter.set_range(-150,-50) |
---|
1033 | ASAP> plotter.set_range() # To reset |
---|
1034 | \end{verbatim} |
---|
1035 | |
---|
1036 | Both the range of the ``x'' and ``y'' axis can be set at once, if desired: |
---|
1037 | |
---|
1038 | \begin{verbatim} |
---|
1039 | ASAP> plotter.set_range(-10,30,-1,6.6) |
---|
1040 | \end{verbatim} |
---|
1041 | |
---|
1042 | To save a hardcopy of the current plot, use the save function, e.g. |
---|
1043 | |
---|
1044 | \begin{verbatim} |
---|
1045 | ASAP> plotter.save('myplot.ps') |
---|
1046 | \end{verbatim} |
---|
1047 | |
---|
1048 | \section{Fitting} |
---|
1049 | |
---|
1050 | Currently multicomponent Gaussian function is available. This is done |
---|
1051 | by creating a fitting object, setting up the fit and actually fitting |
---|
1052 | the data. Fitting can either be done on a single scantable row/cursor |
---|
1053 | selection or on an entire scantable using the \cmd{auto\_fit} function. |
---|
1054 | |
---|
1055 | \begin{verbatim} |
---|
1056 | ASAP> f = fitter() |
---|
1057 | ASAP> f.set_function(gauss=2) # Fit two Gaussians |
---|
1058 | ASAP> f.set_scan(scans) |
---|
1059 | ASAP> scans.set_cursor(0,0,1) # Fit the second polarisation |
---|
1060 | ASAP> scans.set_unit('km/s') # Make fit in velocity units |
---|
1061 | ASAP> f.fit(1) # Run the fit on the second row in the table |
---|
1062 | ASAP> f.plot() # Show fit in a plot window |
---|
1063 | ASAP> f.get_parameters() # Return the fit paramaters |
---|
1064 | \end{verbatim} |
---|
1065 | |
---|
1066 | This auto-guesses the initial values of the fit and works well for data |
---|
1067 | without extra confusing features. Note that the fit is performed in |
---|
1068 | whatever unit the abscissa is set to. |
---|
1069 | |
---|
1070 | If you want to confine the fitting to a smaller range (e.g. to avoid |
---|
1071 | band edge effects or RFI you must set a mask. |
---|
1072 | |
---|
1073 | \begin{verbatim} |
---|
1074 | ASAP> f = fitter() |
---|
1075 | ASAP> f.set_function(gauss=2) |
---|
1076 | ASAP> scans.set_unit('km/s') # Set the mask in channel units |
---|
1077 | ASAP> msk = s.create_mask([1800,2200]) |
---|
1078 | ASAP> scans.set_unit('km/s') # Make fit in velocity units |
---|
1079 | ASAP> f.set_scan(s,msk) |
---|
1080 | ASAP> f.fit() |
---|
1081 | ASAP> f.plot() |
---|
1082 | ASAP> f.get_parameters() |
---|
1083 | \end{verbatim} |
---|
1084 | |
---|
1085 | If you wish, the initial parameter guesses can be specified and |
---|
1086 | specific parameters can be fixed: |
---|
1087 | |
---|
1088 | \begin{verbatim} |
---|
1089 | ASAP> f = fitter() |
---|
1090 | ASAP> f.set_function(gauss=2) |
---|
1091 | ASAP> f.set_scan(s,msk) |
---|
1092 | ASAP> f.fit() # Fit using auto-estimates |
---|
1093 | # Set Peak, centre and fwhm for the second gaussian. |
---|
1094 | # Force the centre to be fixed |
---|
1095 | ASAP> f.set_gauss_parameters(0.4,450,150,0,1,0,component=1) |
---|
1096 | ASAP> f.fit() # Re-run the fit |
---|
1097 | \end{verbatim} |
---|
1098 | |
---|
1099 | The fitter \cmd{plot} function has a number of options to either view |
---|
1100 | the fit residuals or the individual components (by default it plots |
---|
1101 | the sum of the model components). |
---|
1102 | |
---|
1103 | Examples: |
---|
1104 | |
---|
1105 | \begin{verbatim} |
---|
1106 | # Plot the residual |
---|
1107 | ASAP> f.plot(residual=True) |
---|
1108 | |
---|
1109 | # Plot the first 2 componentsa |
---|
1110 | ASAP> f.plot(components=[0,1]) |
---|
1111 | |
---|
1112 | # Plot the first and third component plus the model sum |
---|
1113 | ASAP> f.plot(components=[-1,0,2]) # -1 means the compoment sum |
---|
1114 | \end{verbatim} |
---|
1115 | |
---|
1116 | \subsection{Fit saving} |
---|
1117 | |
---|
1118 | One you are happy with your fit, it is possible to store it as part of |
---|
1119 | the scantable. |
---|
1120 | |
---|
1121 | \begin{verbatim} |
---|
1122 | ASAP> f.storefit() |
---|
1123 | \end{verbatim} |
---|
1124 | |
---|
1125 | This will be saved to disk with the data, if the ``ASAP'' file format |
---|
1126 | is selected. Multiple fits to the same data can be stored in the |
---|
1127 | scantable. |
---|
1128 | |
---|
1129 | The scantable function \cmd{get\_fit} can be used to retrieve the |
---|
1130 | stored fits. Currently the fit parameters are just printed to the |
---|
1131 | screen. |
---|
1132 | |
---|
1133 | \begin{verbatim} |
---|
1134 | ASAP> scans.get_fit(4) # Print fits for row 4 |
---|
1135 | \end{verbatim} |
---|
1136 | |
---|
1137 | \section{Polarisation} |
---|
1138 | |
---|
1139 | Currently ASAP only supports polarmetric analysis on linearly |
---|
1140 | polarised feeds and the cross polarisation products measured. Other |
---|
1141 | cases will be added on an as needed basic. |
---|
1142 | |
---|
1143 | Conversions of linears to Stokes or Circular polarisations are done |
---|
1144 | ``on-the-fly''. Leakage cannot be corrected for nor are these routines |
---|
1145 | able to calibrate position angle offsets. |
---|
1146 | |
---|
1147 | \subsection{Simple Calibration} |
---|
1148 | |
---|
1149 | {\em Currently the receiver position angle is not stored in the RPFITS |
---|
1150 | file. This severely hampers correct handling of polarimetry. In the future |
---|
1151 | we aim to define a general framework and populate the RPFITS files |
---|
1152 | with the data required for transparent polarimetric calibration.} |
---|
1153 | |
---|
1154 | It is possible that there is a phase offset between polarisation which |
---|
1155 | will effect the phase of the cross polarisation correlation, and so give |
---|
1156 | rise to spurious polarisation. \cmd{rotate\_xyphase} can be used to |
---|
1157 | correct for this error. At this point, the user must know how to |
---|
1158 | determine the size of the phase offset themselves. |
---|
1159 | |
---|
1160 | \begin{verbatim} |
---|
1161 | ASAP> scans.rotate_xyphase(10.5) # Degrees |
---|
1162 | \end{verbatim} |
---|
1163 | |
---|
1164 | Note that if this function is run twice, the sum of the two values is |
---|
1165 | applied because it is done in-situ. |
---|
1166 | |
---|
1167 | A correction for the receiver parallactic angle may need to be made, |
---|
1168 | either because of how it is mounted or if parallactifiying had to track |
---|
1169 | at 90 degrees rather than 0. Use \cmd{rotate\_linpolphase} to correct |
---|
1170 | the position angle. Running this function twice results in the sum of |
---|
1171 | the corrections being applied because it is applied in-situ. |
---|
1172 | |
---|
1173 | \begin{verbatim} |
---|
1174 | ASAP> scans.rotate_linpolphase(-20) # Degrees; correct for receiver mounting |
---|
1175 | |
---|
1176 | # Receiver was tracking 90 degrees rather than 0 |
---|
1177 | ASAP> scans.rotate_linpolphase(90) |
---|
1178 | \end{verbatim} |
---|
1179 | |
---|
1180 | \subsection{Plotting} |
---|
1181 | \label{sec:polplot} |
---|
1182 | |
---|
1183 | To plot Stokes values, the plotter \cmd{set\_cursor} function should |
---|
1184 | be called first using the \cmd{pol} argument. The values which can be |
---|
1185 | plotted include a selection of [I,Q,U,V], [I, Plinear, Pangle, V], |
---|
1186 | [RR, LL] or [XX, YY, Real(XY), Imaginary(XY)]. (Plinear and Pangle are |
---|
1187 | the percentage and position angle of linear polarisation). Conversion |
---|
1188 | to circular polarisations are currently not available. |
---|
1189 | |
---|
1190 | Example: |
---|
1191 | |
---|
1192 | \begin{verbatim} |
---|
1193 | ASAP> plotter.set_cursor(pol=[``I'',''Q''] |
---|
1194 | ASAP> plotter.set_cursor(pol=[``RR'',''LL''] |
---|
1195 | ASAP> plotter.set_cursor(pol=[``XX'',''YY''] |
---|
1196 | ASAP> plotter.set_cursor(pol=[``I'',''Plinear''] |
---|
1197 | \end{verbatim} |
---|
1198 | |
---|
1199 | Row, beam and IF selection are also available in \cmd{set\_cursor} as |
---|
1200 | describe in section~\ref{sec:plotter_cursor}. |
---|
1201 | |
---|
1202 | \subsection{Saving} |
---|
1203 | |
---|
1204 | When saving data using the \cmd{save} function, the \cmd{stokes} |
---|
1205 | argument can be used to save the data as Stoke values when saving in |
---|
1206 | FITS format. |
---|
1207 | |
---|
1208 | Example: |
---|
1209 | |
---|
1210 | \begin{verbatim} |
---|
1211 | ASAP> scans.save('myscan.sdfits', 'SDFITS', stokes=True) |
---|
1212 | \end{verbatim} |
---|
1213 | |
---|
1214 | \section{Function Summary} |
---|
1215 | |
---|
1216 | \begin{verbatim} |
---|
1217 | scantable - a container for integrations/scans |
---|
1218 | (can open asap/rpfits/sdfits and ms files) |
---|
1219 | copy - returns a copy of a scan |
---|
1220 | get_scan - gets a specific scan out of a scantable |
---|
1221 | summary - print info about the scantable contents |
---|
1222 | set_cursor - set a specific Beam/IF/Pol 'cursor' for |
---|
1223 | further use |
---|
1224 | get_cursor - print out the current cursor position |
---|
1225 | stats - get specified statistic of the spectra in |
---|
1226 | the scantable |
---|
1227 | stddev - get the standard deviation of the spectra |
---|
1228 | in the scantable |
---|
1229 | get_tsys - get the TSys |
---|
1230 | get_time - get the timestamps of the integrations |
---|
1231 | get_unit - get the currnt unit |
---|
1232 | set_unit - set the abcissa unit to be used from this |
---|
1233 | point on |
---|
1234 | get_abcissa - get the abcissa values and name for a given |
---|
1235 | row (time) |
---|
1236 | set_freqframe - set the frame info for the Spectral Axis |
---|
1237 | (e.g. 'LSRK') |
---|
1238 | set_doppler - set the doppler to be used from this point on |
---|
1239 | set_instrument - set the instrument name |
---|
1240 | get_fluxunit - get the brightness flux unit |
---|
1241 | set_fluxunit - set the brightness flux unit |
---|
1242 | create_mask - return an mask in the current unit |
---|
1243 | for the given region. The specified regions |
---|
1244 | are NOT masked |
---|
1245 | get_restfreqs - get the current list of rest frequencies |
---|
1246 | set_restfreqs - set a list of rest frequencies |
---|
1247 | lines - print list of known spectral lines |
---|
1248 | flag_spectrum - flag a whole Beam/IF/Pol |
---|
1249 | save - save the scantable to disk as either 'ASAP' |
---|
1250 | or 'SDFITS' |
---|
1251 | nbeam,nif,nchan,npol - the number of beams/IFs/Pols/Chans |
---|
1252 | history - print the history of the scantable |
---|
1253 | get_fit - get a fit which has been stored witnh the data |
---|
1254 | average_time - return the (weighted) time average of a scan |
---|
1255 | or a list of scans |
---|
1256 | average_pol - average the polarisations together. |
---|
1257 | The dimension won't be reduced and |
---|
1258 | all polarisations will contain the |
---|
1259 | averaged spectrum. |
---|
1260 | quotient - return the on/off quotient |
---|
1261 | scale - return a scan scaled by a given factor |
---|
1262 | add - return a scan with given value added |
---|
1263 | bin - return a scan with binned channels |
---|
1264 | resample - return a scan with resampled channels |
---|
1265 | smooth - return the spectrally smoothed scan |
---|
1266 | poly_baseline - fit a polynomial baseline to all Beams/IFs/Pols |
---|
1267 | auto_poly_baseline - automatically fit a polynomial baseline |
---|
1268 | gain_el - apply gain-elevation correction |
---|
1269 | opacity - apply opacity correction |
---|
1270 | convert_flux - convert to and from Jy and Kelvin brightness |
---|
1271 | units |
---|
1272 | freq_align - align spectra in frequency frame |
---|
1273 | rotate_xyphase - rotate XY phase of cross correlation |
---|
1274 | rotate_linpolphase - rotate the phase of the complex |
---|
1275 | polarization O=Q+iU correlation |
---|
1276 | [Math] Mainly functions which operate on more than one scantable |
---|
1277 | |
---|
1278 | average_time - return the (weighted) time average |
---|
1279 | of a list of scans |
---|
1280 | quotient - return the on/off quotient |
---|
1281 | simple_math - simple mathematical operations on two scantables, |
---|
1282 | 'add', 'sub', 'mul', 'div' |
---|
1283 | [Fitting] |
---|
1284 | fitter |
---|
1285 | auto_fit - return a scan where the function is |
---|
1286 | applied to all Beams/IFs/Pols. |
---|
1287 | commit - return a new scan where the fits have been |
---|
1288 | commited. |
---|
1289 | fit - execute the actual fitting process |
---|
1290 | store_fit - store the fit paramaters in the data (scantable) |
---|
1291 | get_chi2 - get the Chi^2 |
---|
1292 | set_scan - set the scantable to be fit |
---|
1293 | set_function - set the fitting function |
---|
1294 | set_parameters - set the parameters for the function(s), and |
---|
1295 | set if they should be held fixed during fitting |
---|
1296 | set_gauss_parameters - same as above but specialised for individual |
---|
1297 | gaussian components |
---|
1298 | get_parameters - get the fitted parameters |
---|
1299 | plot - plot the resulting fit and/or components and |
---|
1300 | residual |
---|
1301 | [Plotter] |
---|
1302 | asapplotter - a plotter for asap, default plotter is |
---|
1303 | called 'plotter' |
---|
1304 | plot - plot a (list of) scantable |
---|
1305 | save - save the plot to a file ('png' ,'ps' or 'eps') |
---|
1306 | set_mode - set the state of the plotter, i.e. |
---|
1307 | what is to be plotted 'colour stacked' |
---|
1308 | and what 'panelled' |
---|
1309 | set_cursor - only plot a selected part of the data |
---|
1310 | set_range - set a 'zoom' window |
---|
1311 | set_legend - specify user labels for the legend indeces |
---|
1312 | set_title - specify user labels for the panel indeces |
---|
1313 | set_ordinate - specify a user label for the ordinate |
---|
1314 | set_abcissa - specify a user label for the abcissa |
---|
1315 | set_layout - specify the multi-panel layout (rows,cols) |
---|
1316 | |
---|
1317 | [Reading files] |
---|
1318 | reader - access rpfits/sdfits files |
---|
1319 | read - read in integrations |
---|
1320 | summary - list info about all integrations |
---|
1321 | |
---|
1322 | [General] |
---|
1323 | commands - this command |
---|
1324 | print - print details about a variable |
---|
1325 | list_scans - list all scantables created bt the user |
---|
1326 | del - delete the given variable from memory |
---|
1327 | range - create a list of values, e.g. |
---|
1328 | range(3) = [0,1,2], range(2,5) = [2,3,4] |
---|
1329 | help - print help for one of the listed functions |
---|
1330 | execfile - execute an asap script, e.g. execfile('myscript') |
---|
1331 | list_rcparameters - print out a list of possible values to be |
---|
1332 | put into .asaprc file |
---|
1333 | mask_and,mask_or, |
---|
1334 | mask_not - boolean operations on masks created with |
---|
1335 | scantable.create_mask |
---|
1336 | |
---|
1337 | Note: |
---|
1338 | How to use this with help: |
---|
1339 | # function 'summary' |
---|
1340 | [xxx] is just a category |
---|
1341 | Every 'sub-level' in this list should be replaces by a '.' Period when |
---|
1342 | using help |
---|
1343 | Example: |
---|
1344 | ASAP> help scantable # to get info on ths scantable |
---|
1345 | ASAP> help scantable.summary # to get help on the scantable's |
---|
1346 | ASAP> help average_time |
---|
1347 | |
---|
1348 | \end{verbatim} |
---|
1349 | |
---|
1350 | \section{Scantable Mathematics} |
---|
1351 | |
---|
1352 | It is possible to to simple mathematics directly on scantables from |
---|
1353 | the command line using the \cmd{+, -, *, /} operators as well as their |
---|
1354 | cousins \cmd{+=, -= *=, /=}. This works between two scantables or a |
---|
1355 | scantable and a float. (Note that it does not work for integers). |
---|
1356 | |
---|
1357 | \begin{verbatim} |
---|
1358 | ASAP> sum = scan1+scan2 |
---|
1359 | ASAP> scan2 = scan1+2.0 |
---|
1360 | ASAP> scan *= 1.05 |
---|
1361 | \end{verbatim} |
---|
1362 | |
---|
1363 | %\section{Scripting} |
---|
1364 | |
---|
1365 | %Malte to add something |
---|
1366 | |
---|
1367 | \section{Appendix} |
---|
1368 | |
---|
1369 | \subsection{Installation} |
---|
1370 | |
---|
1371 | ASAP depends on a number of third-party libraries which you must |
---|
1372 | have installed before attempting to build ASAP. These are: |
---|
1373 | |
---|
1374 | \begin{itemize} |
---|
1375 | \item AIPS++ |
---|
1376 | \item Boost |
---|
1377 | \item Matplotlib |
---|
1378 | \item ipython/python |
---|
1379 | \end{itemize} |
---|
1380 | |
---|
1381 | Debian Linux is currently supported and we intend also |
---|
1382 | to support other popular Linux flavours, Solaris and Mac. |
---|
1383 | |
---|
1384 | Of the dependencies, AIPS++ is the most complex to install. |
---|
1385 | |
---|
1386 | \subsection{ASCII output format} |
---|
1387 | |
---|
1388 | \subsection{.asaprc settings} |
---|
1389 | |
---|
1390 | \end{document} |
---|
1391 | |
---|
1392 | |
---|