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