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. Making this too small or too large will result in a poor fit,
|
---|
684 | but generally the value is not critical.
|
---|
685 |
|
---|
686 | Other examples:
|
---|
687 |
|
---|
688 | \begin{verbatim}
|
---|
689 | # Don't try and fit the edge of the bandpass which is noisier
|
---|
690 | ASAP> scans.auto_poly_baseline(edge=(500,450),order=3,threshold=3)
|
---|
691 |
|
---|
692 | # Only fit a given region around the line
|
---|
693 | ASAP> scans.set_unit('km/s')
|
---|
694 | ASAP> msk = scans.create_mask((-60,-20))
|
---|
695 | ASAP> scans.auto_poly_baseline(mask=msk,order=3,threshold=3)
|
---|
696 |
|
---|
697 | \end{verbatim}
|
---|
698 |
|
---|
699 | \subsection{Average the polarisations}
|
---|
700 |
|
---|
701 | If you are just interested in the highest SNR for total intensity you
|
---|
702 | will want to average the parallel polarisations together.
|
---|
703 |
|
---|
704 | \begin{verbatim}
|
---|
705 | ASAP> scans.average_pol()
|
---|
706 | \end{verbatim}
|
---|
707 |
|
---|
708 | \subsection{Calibration}
|
---|
709 |
|
---|
710 | For most uses, calibration happens transparently as the input data
|
---|
711 | contains the Tsys measurements taken during observations. The nominal
|
---|
712 | ``Tsys'' values may be in Kelvin or Jansky. The user may wish to
|
---|
713 | supply a Tsys correction or apply gain-elevation and opacity
|
---|
714 | corrections.
|
---|
715 |
|
---|
716 | \subsubsection{Brightness Units}
|
---|
717 |
|
---|
718 | RPFITS files to not contain any information as to whether the telescope
|
---|
719 | calibration was in units of Kelvin or Janskys. On reading the data a
|
---|
720 | default value is set depending on the telescope and frequency of
|
---|
721 | observation. If this default is incorrect (you can see it in the
|
---|
722 | listing from the \cmd{summary} function) the user can either override
|
---|
723 | this value on reading the data or later. E.g:
|
---|
724 |
|
---|
725 | \begin{verbatim}
|
---|
726 | ASAP> scans = scantable(('2004-11-23_1841-P484.rpf', unit='Jy')
|
---|
727 | # Or in two steps
|
---|
728 | ASAP> scans = scantable(('2004-11-23_1841-P484.rpf')
|
---|
729 | ASAP> scans.set_fluxunit('Jy)
|
---|
730 | \end{verbatim}
|
---|
731 |
|
---|
732 | \subsubsection{Tsys scaling}
|
---|
733 |
|
---|
734 | Sometime the nominal Tsys measurement at the telescope is wrong due to
|
---|
735 | an incorrect noise diode calibration. This can easily be corrected for
|
---|
736 | with the scale function. By default, \cmd{scale} only scans the
|
---|
737 | spectra and not the corresponding Tsys.
|
---|
738 |
|
---|
739 | \begin{verbatim}
|
---|
740 | ASAP> scans.scale(1.05, tsys=True)
|
---|
741 | \end{verbatim}
|
---|
742 |
|
---|
743 | \subsubsection{Unit Conversion}
|
---|
744 |
|
---|
745 | To convert measurements in Kelvin to Jy (and vice versa) the global
|
---|
746 | function \cmd{convert\_flux} is needed. This converts and scales the data
|
---|
747 | from K to Jy or vice-versa depending on what the current brightness unit is
|
---|
748 | set to. The function knows the basic parameters for some frequencies
|
---|
749 | and telescopes, but the user may need to supply the aperture
|
---|
750 | efficiency, telescope diameter or the Jy/K factor.
|
---|
751 |
|
---|
752 | \begin{verbatim}
|
---|
753 | ASAP> scans.convert_flux # If efficency known
|
---|
754 | ASAP> scans.convert_flux(eta=0.48) # If telescope diameter known
|
---|
755 | ASAP> scans.convert_flux(eta=0.48,d=35) # Unknown telescope
|
---|
756 | ASAP> scans.convert_flux(jypk=15) # Alternative
|
---|
757 | \end{verbatim}
|
---|
758 |
|
---|
759 | \subsubsection{Gain-Elevation and Opacity Corrections}
|
---|
760 |
|
---|
761 | As higher frequencies (particularly $>$20~GHz) it is important to make
|
---|
762 | corrections for atmospheric opacity and gain-elevation effects.
|
---|
763 |
|
---|
764 | Gain-elevation curves for some telescopes and frequencies are known to
|
---|
765 | ASAP (currently only for Tidbinbilla at 20~GHz). In these cases making
|
---|
766 | gain-corrections is simple. If the gain curve for your data is not
|
---|
767 | known, the user can supply either a gain polynomial or text file
|
---|
768 | tabulating gain factors at a range of elevations (see \cmd{help
|
---|
769 | scantable.gain\_el}).
|
---|
770 |
|
---|
771 | Examples:
|
---|
772 |
|
---|
773 | \begin{verbatim}
|
---|
774 | ASAP> scans.gain_el() # If gain table known
|
---|
775 | ASAP> scans.gain_el(poly=[3.58788e-1,2.87243e-2,-3.219093e-4])
|
---|
776 | \end{verbatim}
|
---|
777 |
|
---|
778 | Opacity corrections can be made with the global function
|
---|
779 | \cmd{opacity}. This should work on all telescopes as long as a
|
---|
780 | measurement of the opacity factor was made during the observation.
|
---|
781 |
|
---|
782 | \begin{verbatim}
|
---|
783 | ASAP> scans.opacity(0.083)
|
---|
784 | \end{verbatim}
|
---|
785 |
|
---|
786 | Note that at 3~mm Mopra uses a paddle wheel for Tsys calibration,
|
---|
787 | which takes opacity effects into account (to first order). ASAP
|
---|
788 | opacity corrections should not be used for Mopra 3-mm data.
|
---|
789 |
|
---|
790 | \subsection{Frequency Frame Alignment}
|
---|
791 |
|
---|
792 | When time averaging a series of scans together, it is possible that
|
---|
793 | the velocity scales are not exactly aligned. This may be for many
|
---|
794 | reasons such as not Doppler tracking the observations, errors in the
|
---|
795 | Doppler tracking etc. This mostly affects very long integrations or
|
---|
796 | integrations averaged together from different days. Before averaging
|
---|
797 | such data together, they should be frequency aligned using
|
---|
798 | \cmd{freq\_align}.
|
---|
799 |
|
---|
800 | E.g.:
|
---|
801 |
|
---|
802 | \begin{verbatim}
|
---|
803 | ASAP> scans.freq_align()
|
---|
804 | ASAP> av = average_time(scans)
|
---|
805 | \end{verbatim}
|
---|
806 |
|
---|
807 | \cmd{freq\_align} has two modes of operations controlled by the
|
---|
808 | \cmd{perif} argument. By default it will align each source and freqid
|
---|
809 | separately. This is needed for scan tables containing multiple
|
---|
810 | sources. However if scan-based Doppler tracking has been made at the observatory,
|
---|
811 | each row will have a different freqid. In these cases run with
|
---|
812 | \cmd{perif=True} and all rows of a source will be aligned to the same
|
---|
813 | frame. In general \cmd{perif=True} will be needed for most
|
---|
814 | observations as Doppler tracking of some form is made at Parkes, Tid
|
---|
815 | and Mopra.
|
---|
816 |
|
---|
817 | \begin{verbatim}
|
---|
818 | ASAP> scans.freq_align(perif=True)
|
---|
819 | \end{verbatim}
|
---|
820 |
|
---|
821 | To average together data taken on different days, which are in
|
---|
822 | different scantables, each scantable must aligned to a common
|
---|
823 | reference time then the scantables averaged. The simplest way of
|
---|
824 | doing this is to allow ASAP to choose the reference time for the first
|
---|
825 | scantable then using this time for the subsequent scantables.
|
---|
826 |
|
---|
827 | \begin{verbatim}
|
---|
828 | ASAP> scans1.freq_align() # Copy the refeference Epoch from the output
|
---|
829 | ASAP> scans2.freq_align(reftime='2004/11/23/18:43:35')
|
---|
830 | ASAP> scans3.freq_align(reftime='2004/11/23/18:43:35')
|
---|
831 | ASAP> av = average_time(scans1, scans2, scans3)
|
---|
832 | \end{verbatim}
|
---|
833 |
|
---|
834 | \section{Scantable manipulation}
|
---|
835 |
|
---|
836 | While it is very useful to have many independent sources within one
|
---|
837 | scantable, it is often inconvenient for data processing. The
|
---|
838 | \cmd{get\_scan} function can be used to create a new scantable with a
|
---|
839 | selection of scans from a scantable. The selection can either be on
|
---|
840 | the source name, with simple wildcard matching or set of scan ids.
|
---|
841 |
|
---|
842 | For example:
|
---|
843 |
|
---|
844 | \begin{verbatim}
|
---|
845 | ASAP> ss = scans.get_scan(10) # Get the 11th scan (zero based)
|
---|
846 | ASAP> ss = scans.get_scan(range(10)) # Get the first 10 scans
|
---|
847 | ASAP> ss = scans.get_scan(range(10,20)) # Get the next 10 scans
|
---|
848 | ASAP> ss = scans.get_scan([2,4,6,8,10]) # Get a selection of scans
|
---|
849 |
|
---|
850 | ASAP> ss = scans.get_scan('345p407') # Get a specific source
|
---|
851 | ASAP> ss = scans.get_scan('345*') # Get a few sources
|
---|
852 |
|
---|
853 | ASAP> r = scans.get_scan('*_R') # Get all reference sources (Parkes/Mopra)
|
---|
854 | ASAP> s = scans.get_scan('*_S') # Get all program sources (Parkes/Mopra)
|
---|
855 | ASAP> r = scans.get_scan('*_[ew]') # Get all reference sources (Tid)
|
---|
856 | ASAP> s = scans.get_scan('*_[^ew]') # Get all program sources (Tid)
|
---|
857 |
|
---|
858 | \end{verbatim}
|
---|
859 |
|
---|
860 | To copy a scantable the following does not work:
|
---|
861 |
|
---|
862 | \begin{verbatim}
|
---|
863 | ASAP> ss = scans
|
---|
864 | \end{verbatim}
|
---|
865 |
|
---|
866 | as this just creates a reference to the original scantable. Any
|
---|
867 | changes made to \cmd{ss} are also seen in \cmd{scans}. To duplicate a
|
---|
868 | scantable, use the copy function.
|
---|
869 |
|
---|
870 | \begin{verbatim}
|
---|
871 | ASAP> ss = scans.copy
|
---|
872 | \end{verbatim}
|
---|
873 |
|
---|
874 | \section{Data Output}
|
---|
875 |
|
---|
876 | ASAP can save scantables in a variety of formats, suitable for reading
|
---|
877 | into other packages. The formats are:
|
---|
878 |
|
---|
879 | \begin{itemize}
|
---|
880 | \item[ASAP] This is the internal format used for ASAP. It is the only
|
---|
881 | format that allows the user to restore the data, fits etc. without
|
---|
882 | loosing any information. As mentioned before, the ASAP scantable is
|
---|
883 | an AIPS++ Table (a memory-based table). This function just converts
|
---|
884 | it to a disk-based Table. You can the access that Table with the
|
---|
885 | AIPS++ Table browser or any other AIPS++ tool.
|
---|
886 |
|
---|
887 | \item[SDFITS] The Single Dish FITS format. This format was designed to
|
---|
888 | for interchange between packages, but few packages actually can read
|
---|
889 | it.
|
---|
890 |
|
---|
891 | \item[FITS] This uses simple ``image'' fits to save the data, each row
|
---|
892 | being written to a separate fits file. This format is suitable for
|
---|
893 | importing the data into CLASS.
|
---|
894 |
|
---|
895 | \item[ASCII] A simple text based format suitable for the user to
|
---|
896 | processing using Perl or, Python, gnuplot etc.
|
---|
897 |
|
---|
898 | \item[MS2] Saves the data in an aips++ MeasurementSet V2 format.
|
---|
899 | You can also access this with the Table browser and other AIPS++
|
---|
900 | tools.
|
---|
901 |
|
---|
902 | \end{itemize}
|
---|
903 |
|
---|
904 | The default output format can be set in the users {\tt .asaprc} file.
|
---|
905 | Typical usages are:
|
---|
906 |
|
---|
907 | \begin{verbatim}
|
---|
908 | ASAP> scans.save('myscans') # Save in default format
|
---|
909 | ASAP> scans.save('myscans', 'FITS') # Save as FITS for exporting into CLASS
|
---|
910 |
|
---|
911 | ASAP> scans.save('myscans', stokes=True) # Convert raw polarisations into Stokes
|
---|
912 | ASAP> scans.save('myscans', overwrite=True) # Overwrite an existing file
|
---|
913 | \end{verbatim}
|
---|
914 |
|
---|
915 |
|
---|
916 | \section{Plotter}
|
---|
917 |
|
---|
918 | Scantable spectra can be plotter at any time. An asapplotter object is
|
---|
919 | used for plotting, meaning multiple plot windows can be active at the
|
---|
920 | same time. On start up a default asapplotter object is created called
|
---|
921 | ``plotter''. This would normally be used for standard plotting.
|
---|
922 |
|
---|
923 | The plotter, optionally, will run in a multipanel mode and contain
|
---|
924 | multiple plots per panel. The user must tell the plotter how they want
|
---|
925 | the data distributed. This is done using the set\_mode function. The
|
---|
926 | default can be set in the users {\tt .asaprc} file. The units (and frame
|
---|
927 | etc) of the abscissa will be whatever has previously been set by
|
---|
928 | \cmd{set\_unit}, \cmd{set\_freqframe} etc.
|
---|
929 |
|
---|
930 | Typical plotter usage would be:
|
---|
931 |
|
---|
932 | \begin{verbatim}
|
---|
933 | ASAP> scans.set_unit('km/s')
|
---|
934 | ASAP> plotter.set_mode(stacking='p',panelling='t')
|
---|
935 | ASAP> plotter.plot(scans)
|
---|
936 | \end{verbatim}
|
---|
937 |
|
---|
938 | This will plot multiple polarisation within each plot panel and each
|
---|
939 | scan row in a separate panel.
|
---|
940 |
|
---|
941 | Other possibilities include:
|
---|
942 |
|
---|
943 | \begin{verbatim}
|
---|
944 | # Plot multiple IFs per panel
|
---|
945 | ASAP> plotter.set_mode(stacking='i',panelling='t')
|
---|
946 |
|
---|
947 | # Plot multiple beams per panel
|
---|
948 | ASAP> plotter.set_mode(stacking='b',panelling='t')
|
---|
949 |
|
---|
950 | # Plot one IF per panel, time stacked
|
---|
951 | ASAP> plotter.set_mode('t', 'i')
|
---|
952 |
|
---|
953 | # Plot each scan in a seperate panel
|
---|
954 | ASAP> plotter.set_mode('t', 's')
|
---|
955 |
|
---|
956 | \end{verbatim}
|
---|
957 |
|
---|
958 | \subsection{Plot Selection}
|
---|
959 | \label{sec:plotter_cursor}
|
---|
960 |
|
---|
961 | The plotter can plot up to 25 panels and stacked spectra per
|
---|
962 | panel. If you have data larger than this (or for your own sanity) you
|
---|
963 | need to select a subset of this data. This is particularly true for
|
---|
964 | multibeam or multi IF data. The plotter \cmd{set\_cursor} function is
|
---|
965 | used to select a subset of the data. The arguments \cmd{row},
|
---|
966 | \cmd{beam} and \cmd{IF} all accept a vector of indices corresponding
|
---|
967 | to row, beam or IF selection. Only the selected data will be plotted.
|
---|
968 | To select on polarisation, see section~\ref{sec:polplot}.
|
---|
969 |
|
---|
970 | Examples:
|
---|
971 |
|
---|
972 | \begin{verbatim}
|
---|
973 | # Select second IF
|
---|
974 | ASAP> plotter.set_cursor(IF=[1])
|
---|
975 |
|
---|
976 | # Select first 4 beams
|
---|
977 | ASAP> plotter.set_cursor(beam=[0,1,2,3])
|
---|
978 |
|
---|
979 | # Select a few rows
|
---|
980 | ASAP> plotter.set_cursor(row=[2,4,6,10])
|
---|
981 |
|
---|
982 | # Multiple selection
|
---|
983 | ASAP> plotter.set_cursor(IF=[1], beam=[0,2], row=range(10))
|
---|
984 | \end{verbatim}
|
---|
985 |
|
---|
986 | Note that the plotter cursor selection is independent of the scantable
|
---|
987 | cursor.
|
---|
988 |
|
---|
989 | \subsection{Plot Control}
|
---|
990 |
|
---|
991 | The plotter window has a row of buttons on the lower left. These can
|
---|
992 | be used to control the plotter (mostly for zooming the individual
|
---|
993 | plots). From left to right:
|
---|
994 |
|
---|
995 | \begin{itemize}
|
---|
996 |
|
---|
997 | \item[Home] This will unzoom the plots to the original zoom factor
|
---|
998 |
|
---|
999 | \item[Plot history] (left and right arrow). The plotter keeps a
|
---|
1000 | history of zoom settings. The left arrow sets the plot zoom to the
|
---|
1001 | previous value. The right arrow returns back again. This allows you,
|
---|
1002 | for example, to zoom in on one feature then return the plot to how it
|
---|
1003 | was previously.
|
---|
1004 |
|
---|
1005 | \item[Pan] (The Cross) This sets the cursor to pan, or scroll mode
|
---|
1006 | allowing you to shift the plot within the window. Useful when
|
---|
1007 | zoomed in on a feature.
|
---|
1008 |
|
---|
1009 | \item[Zoom] (the letter with the magnifying glass) lets you draw a
|
---|
1010 | rectangle around a region of interest then zooms in on that
|
---|
1011 | region. Use the plot history to unzoom again.
|
---|
1012 |
|
---|
1013 | \item[Save] (floppy disk). Save the plot as a postscript or .png file
|
---|
1014 |
|
---|
1015 | \end{itemize}
|
---|
1016 |
|
---|
1017 | \subsection{Other control}
|
---|
1018 |
|
---|
1019 | The plotter has a number of functions to describe the layout of the
|
---|
1020 | plot. These include \cmd{set\_legend}, \cmd{set\_layout} and \cmd{set\_title}.
|
---|
1021 |
|
---|
1022 | To set the exact velocity or channel range to be plotted use the
|
---|
1023 | \cmd{set\_range} function. To reset to the default value, call
|
---|
1024 | \cmd{set\_range} with no arguments. E.g.
|
---|
1025 |
|
---|
1026 | \begin{verbatim}
|
---|
1027 | ASAP> scans.set_unit('km/s')
|
---|
1028 | ASAP> plotter.plot(scans)
|
---|
1029 | ASAP> plotter.set_range(-150,-50)
|
---|
1030 | ASAP> plotter.set_range() # To reset
|
---|
1031 | \end{verbatim}
|
---|
1032 |
|
---|
1033 | Both the range of the ``x'' and ``y'' axis can be set at once, if desired:
|
---|
1034 |
|
---|
1035 | \begin{verbatim}
|
---|
1036 | ASAP> plotter.set_range(-10,30,-1,6.6)
|
---|
1037 | \end{verbatim}
|
---|
1038 |
|
---|
1039 | To save a hardcopy of the current plot, use the save function, e.g.
|
---|
1040 |
|
---|
1041 | \begin{verbatim}
|
---|
1042 | ASAP> plotter.save('myplot.ps')
|
---|
1043 | \end{verbatim}
|
---|
1044 |
|
---|
1045 | \section{Fitting}
|
---|
1046 |
|
---|
1047 | Currently multicomponent Gaussian function is available. This is done
|
---|
1048 | by creating a fitting object, setting up the fit and actually fitting
|
---|
1049 | the data. Fitting can either be done on a single scantable row/cursor
|
---|
1050 | selection or on an entire scantable using the \cmd{auto\_fit} function.
|
---|
1051 |
|
---|
1052 | \begin{verbatim}
|
---|
1053 | ASAP> f = fitter()
|
---|
1054 | ASAP> f.set_function(gauss=2) # Fit two Gaussians
|
---|
1055 | ASAP> f.set_scan(scans)
|
---|
1056 | ASAP> scans.set_cursor(0,0,1) # Fit the second polarisation
|
---|
1057 | ASAP> scans.set_unit('km/s') # Make fit in velocity units
|
---|
1058 | ASAP> f.fit(1) # Run the fit on the second row in the table
|
---|
1059 | ASAP> f.plot() # Show fit in a plot window
|
---|
1060 | ASAP> f.get_parameters() # Return the fit paramaters
|
---|
1061 | \end{verbatim}
|
---|
1062 |
|
---|
1063 | This auto-guesses the initial values of the fit and works well for data
|
---|
1064 | without extra confusing features. Note that the fit is performed in
|
---|
1065 | whatever unit the abscissa is set to.
|
---|
1066 |
|
---|
1067 | If you want to confine the fitting to a smaller range (e.g. to avoid
|
---|
1068 | band edge effects or RFI you must set a mask.
|
---|
1069 |
|
---|
1070 | \begin{verbatim}
|
---|
1071 | ASAP> f = fitter()
|
---|
1072 | ASAP> f.set_function(gauss=2)
|
---|
1073 | ASAP> scans.set_unit('km/s') # Set the mask in channel units
|
---|
1074 | ASAP> msk = s.create_mask([1800,2200])
|
---|
1075 | ASAP> scans.set_unit('km/s') # Make fit in velocity units
|
---|
1076 | ASAP> f.set_scan(s,msk)
|
---|
1077 | ASAP> f.fit()
|
---|
1078 | ASAP> f.plot()
|
---|
1079 | ASAP> f.get_parameters()
|
---|
1080 | \end{verbatim}
|
---|
1081 |
|
---|
1082 | If you wish, the initial parameter guesses can be specified and
|
---|
1083 | specific parameters can be fixed:
|
---|
1084 |
|
---|
1085 | \begin{verbatim}
|
---|
1086 | ASAP> f = fitter()
|
---|
1087 | ASAP> f.set_function(gauss=2)
|
---|
1088 | ASAP> f.set_scan(s,msk)
|
---|
1089 | ASAP> f.fit() # Fit using auto-estimates
|
---|
1090 | # Set Peak, centre and fwhm for the second gaussian.
|
---|
1091 | # Force the centre to be fixed
|
---|
1092 | ASAP> f.set_gauss_parameters(0.4,450,150,0,1,0,component=1)
|
---|
1093 | ASAP> f.fit() # Re-run the fit
|
---|
1094 | \end{verbatim}
|
---|
1095 |
|
---|
1096 | The fitter \cmd{plot} function has a number of options to either view
|
---|
1097 | the fit residuals or the individual components (by default it plots
|
---|
1098 | the sum of the model components).
|
---|
1099 |
|
---|
1100 | Examples:
|
---|
1101 |
|
---|
1102 | \begin{verbatim}
|
---|
1103 | # Plot the residual
|
---|
1104 | ASAP> f.plot(residual=True)
|
---|
1105 |
|
---|
1106 | # Plot the first 2 componentsa
|
---|
1107 | ASAP> f.plot(components=[0,1])
|
---|
1108 |
|
---|
1109 | # Plot the first and third component plus the model sum
|
---|
1110 | ASAP> f.plot(components=[-1,0,2]) # -1 means the compoment sum
|
---|
1111 | \end{verbatim}
|
---|
1112 |
|
---|
1113 | \subsection{Fit saving}
|
---|
1114 |
|
---|
1115 | One you are happy with your fit, it is possible to store it as part of
|
---|
1116 | the scantable.
|
---|
1117 |
|
---|
1118 | \begin{verbatim}
|
---|
1119 | ASAP> f.storefit()
|
---|
1120 | \end{verbatim}
|
---|
1121 |
|
---|
1122 | This will be saved to disk with the data, if the ``ASAP'' file format
|
---|
1123 | is selected. Multiple fits to the same data can be stored in the
|
---|
1124 | scantable.
|
---|
1125 |
|
---|
1126 | The scantable function \cmd{get\_fit} can be used to retrieve the
|
---|
1127 | stored fits. Currently the fit parameters are just printed to the
|
---|
1128 | screen.
|
---|
1129 |
|
---|
1130 | \begin{verbatim}
|
---|
1131 | ASAP> scans.get_fit(4) # Print fits for row 4
|
---|
1132 | \end{verbatim}
|
---|
1133 |
|
---|
1134 | \section{Polarisation}
|
---|
1135 |
|
---|
1136 | Currently ASAP only supports polarmetric analysis on linearly
|
---|
1137 | polarised feeds and the cross polarisation products measured. Other
|
---|
1138 | cases will be added on an as needed basic.
|
---|
1139 |
|
---|
1140 | Conversions of linears to Stokes or Circular polarisations are done
|
---|
1141 | ``on-the-fly''. Leakage cannot be corrected for nor are these routines
|
---|
1142 | able to calibrate position angle offsets.
|
---|
1143 |
|
---|
1144 | \subsection{Simple Calibration}
|
---|
1145 |
|
---|
1146 | {\em Currently the receiver position angle is not stored in the RPFITS
|
---|
1147 | file. This severely hampers correct handling of polarimetry. In the future
|
---|
1148 | we aim to define a general framework and populate the RPFITS files
|
---|
1149 | with the data required for transparent polarimetric calibration.}
|
---|
1150 |
|
---|
1151 | It is possible that there is a phase offset between polarisation which
|
---|
1152 | will effect the phase of the cross polarisation correlation, and so give
|
---|
1153 | rise to spurious polarisation. \cmd{rotate\_xyphase} can be used to
|
---|
1154 | correct for this error. At this point, the user must know how to
|
---|
1155 | determine the size of the phase offset themselves.
|
---|
1156 |
|
---|
1157 | \begin{verbatim}
|
---|
1158 | ASAP> scans.rotate_xyphase(10.5) # Degrees
|
---|
1159 | \end{verbatim}
|
---|
1160 |
|
---|
1161 | Note that if this function is run twice, the sum of the two values is
|
---|
1162 | applied because it is done in-situ.
|
---|
1163 |
|
---|
1164 | A correction for the receiver parallactic angle may need to be made,
|
---|
1165 | either because of how it is mounted or if parallactifiying had to track
|
---|
1166 | at 90 degrees rather than 0. Use \cmd{rotate\_linpolphase} to correct
|
---|
1167 | the position angle. Running this function twice results in the sum of
|
---|
1168 | the corrections being applied because it is applied in-situ.
|
---|
1169 |
|
---|
1170 | \begin{verbatim}
|
---|
1171 | ASAP> scans.rotate_linpolphase(-20) # Degrees; correct for receiver mounting
|
---|
1172 |
|
---|
1173 | # Receiver was tracking 90 degrees rather than 0
|
---|
1174 | ASAP> scans.rotate_linpolphase(90)
|
---|
1175 | \end{verbatim}
|
---|
1176 |
|
---|
1177 | \subsection{Plotting}
|
---|
1178 | \label{sec:polplot}
|
---|
1179 |
|
---|
1180 | To plot Stokes values, the plotter \cmd{set\_cursor} function should
|
---|
1181 | be called first using the \cmd{pol} argument. The values which can be
|
---|
1182 | plotted include a selection of [I,Q,U,V], [I, Plinear, Pangle, V], or
|
---|
1183 | [XX, YY, Real(XY), Imaginary(XY)]. (Plinear and Pangle are the
|
---|
1184 | percentage and position angle of linear polarisation). Conversion to
|
---|
1185 | circular polarisations are currently not available.
|
---|
1186 |
|
---|
1187 | Example:
|
---|
1188 |
|
---|
1189 | \begin{verbatim}
|
---|
1190 | ASAP> plotter.set_cursor(pol=[``I'',''Q'']
|
---|
1191 | ASAP> plotter.set_cursor(pol=[``XX'',''YY'']
|
---|
1192 | ASAP> plotter.set_cursor(pol=[``I'',''Plinear'']
|
---|
1193 | \end{verbatim}
|
---|
1194 |
|
---|
1195 | Row, beam and IF selection are also available in \cmd{set\_cursor} as
|
---|
1196 | describe in section~\ref{sec:plotter_cursor}.
|
---|
1197 |
|
---|
1198 | \subsection{Saving}
|
---|
1199 |
|
---|
1200 | When saving data using the \cmd{save} function, the \cmd{stokes}
|
---|
1201 | argument can be used to save the data as Stoke values when saving in
|
---|
1202 | FITS format.
|
---|
1203 |
|
---|
1204 | Example:
|
---|
1205 |
|
---|
1206 | \begin{verbatim}
|
---|
1207 | ASAP> scans.save('myscan.sdfits', 'SDFITS', stokes=True)
|
---|
1208 | \end{verbatim}
|
---|
1209 |
|
---|
1210 | \section{Function Summary}
|
---|
1211 |
|
---|
1212 | \begin{verbatim}
|
---|
1213 | scantable - a container for integrations/scans
|
---|
1214 | (can open asap/rpfits/sdfits and ms files)
|
---|
1215 | copy - returns a copy of a scan
|
---|
1216 | get_scan - gets a specific scan out of a scantable
|
---|
1217 | summary - print info about the scantable contents
|
---|
1218 | set_cursor - set a specific Beam/IF/Pol 'cursor' for
|
---|
1219 | further use
|
---|
1220 | get_cursor - print out the current cursor position
|
---|
1221 | stats - get specified statistic of the spectra in
|
---|
1222 | the scantable
|
---|
1223 | stddev - get the standard deviation of the spectra
|
---|
1224 | in the scantable
|
---|
1225 | get_tsys - get the TSys
|
---|
1226 | get_time - get the timestamps of the integrations
|
---|
1227 | get_unit - get the currnt unit
|
---|
1228 | set_unit - set the abcissa unit to be used from this
|
---|
1229 | point on
|
---|
1230 | get_abcissa - get the abcissa values and name for a given
|
---|
1231 | row (time)
|
---|
1232 | set_freqframe - set the frame info for the Spectral Axis
|
---|
1233 | (e.g. 'LSRK')
|
---|
1234 | set_doppler - set the doppler to be used from this point on
|
---|
1235 | set_instrument - set the instrument name
|
---|
1236 | get_fluxunit - get the brightness flux unit
|
---|
1237 | set_fluxunit - set the brightness flux unit
|
---|
1238 | create_mask - return an mask in the current unit
|
---|
1239 | for the given region. The specified regions
|
---|
1240 | are NOT masked
|
---|
1241 | get_restfreqs - get the current list of rest frequencies
|
---|
1242 | set_restfreqs - set a list of rest frequencies
|
---|
1243 | lines - print list of known spectral lines
|
---|
1244 | flag_spectrum - flag a whole Beam/IF/Pol
|
---|
1245 | save - save the scantable to disk as either 'ASAP'
|
---|
1246 | or 'SDFITS'
|
---|
1247 | nbeam,nif,nchan,npol - the number of beams/IFs/Pols/Chans
|
---|
1248 | history - print the history of the scantable
|
---|
1249 | get_fit - get a fit which has been stored witnh the data
|
---|
1250 | average_time - return the (weighted) time average of a scan
|
---|
1251 | or a list of scans
|
---|
1252 | average_pol - average the polarisations together.
|
---|
1253 | The dimension won't be reduced and
|
---|
1254 | all polarisations will contain the
|
---|
1255 | averaged spectrum.
|
---|
1256 | quotient - return the on/off quotient
|
---|
1257 | scale - return a scan scaled by a given factor
|
---|
1258 | add - return a scan with given value added
|
---|
1259 | bin - return a scan with binned channels
|
---|
1260 | resample - return a scan with resampled channels
|
---|
1261 | smooth - return the spectrally smoothed scan
|
---|
1262 | poly_baseline - fit a polynomial baseline to all Beams/IFs/Pols
|
---|
1263 | gain_el - apply gain-elevation correction
|
---|
1264 | opacity - apply opacity correction
|
---|
1265 | convert_flux - convert to and from Jy and Kelvin brightness
|
---|
1266 | units
|
---|
1267 | freq_align - align spectra in frequency frame
|
---|
1268 | rotate_xyphase - rotate XY phase of cross correlation
|
---|
1269 | rotate_linpolphase - rotate the phase of the complex
|
---|
1270 | polarization O=Q+iU correlation
|
---|
1271 | [Math] Mainly functions which operate on more than one scantable
|
---|
1272 |
|
---|
1273 | average_time - return the (weighted) time average
|
---|
1274 | of a list of scans
|
---|
1275 | quotient - return the on/off quotient
|
---|
1276 | simple_math - simple mathematical operations on two scantables,
|
---|
1277 | 'add', 'sub', 'mul', 'div'
|
---|
1278 | [Fitting]
|
---|
1279 | fitter
|
---|
1280 | auto_fit - return a scan where the function is
|
---|
1281 | applied to all Beams/IFs/Pols.
|
---|
1282 | commit - return a new scan where the fits have been
|
---|
1283 | commited.
|
---|
1284 | fit - execute the actual fitting process
|
---|
1285 | store_fit - store the fit paramaters in the data (scantable)
|
---|
1286 | get_chi2 - get the Chi^2
|
---|
1287 | set_scan - set the scantable to be fit
|
---|
1288 | set_function - set the fitting function
|
---|
1289 | set_parameters - set the parameters for the function(s), and
|
---|
1290 | set if they should be held fixed during fitting
|
---|
1291 | set_gauss_parameters - same as above but specialised for individual
|
---|
1292 | gaussian components
|
---|
1293 | get_parameters - get the fitted parameters
|
---|
1294 | plot - plot the resulting fit and/or components and
|
---|
1295 | residual
|
---|
1296 | [Plotter]
|
---|
1297 | asapplotter - a plotter for asap, default plotter is
|
---|
1298 | called 'plotter'
|
---|
1299 | plot - plot a (list of) scantable
|
---|
1300 | save - save the plot to a file ('png' ,'ps' or 'eps')
|
---|
1301 | set_mode - set the state of the plotter, i.e.
|
---|
1302 | what is to be plotted 'colour stacked'
|
---|
1303 | and what 'panelled'
|
---|
1304 | set_cursor - only plot a selected part of the data
|
---|
1305 | set_range - set a 'zoom' window
|
---|
1306 | set_legend - specify user labels for the legend indeces
|
---|
1307 | set_title - specify user labels for the panel indeces
|
---|
1308 | set_ordinate - specify a user label for the ordinate
|
---|
1309 | set_abcissa - specify a user label for the abcissa
|
---|
1310 | set_layout - specify the multi-panel layout (rows,cols)
|
---|
1311 |
|
---|
1312 | [Reading files]
|
---|
1313 | reader - access rpfits/sdfits files
|
---|
1314 | read - read in integrations
|
---|
1315 | summary - list info about all integrations
|
---|
1316 |
|
---|
1317 | [General]
|
---|
1318 | commands - this command
|
---|
1319 | print - print details about a variable
|
---|
1320 | list_scans - list all scantables created bt the user
|
---|
1321 | del - delete the given variable from memory
|
---|
1322 | range - create a list of values, e.g.
|
---|
1323 | range(3) = [0,1,2], range(2,5) = [2,3,4]
|
---|
1324 | help - print help for one of the listed functions
|
---|
1325 | execfile - execute an asap script, e.g. execfile('myscript')
|
---|
1326 | list_rcparameters - print out a list of possible values to be
|
---|
1327 | put into .asaprc file
|
---|
1328 | mask_and,mask_or,
|
---|
1329 | mask_not - boolean operations on masks created with
|
---|
1330 | scantable.create_mask
|
---|
1331 |
|
---|
1332 | Note:
|
---|
1333 | How to use this with help:
|
---|
1334 | # function 'summary'
|
---|
1335 | [xxx] is just a category
|
---|
1336 | Every 'sub-level' in this list should be replaces by a '.' Period when
|
---|
1337 | using help
|
---|
1338 | Example:
|
---|
1339 | ASAP> help scantable # to get info on ths scantable
|
---|
1340 | ASAP> help scantable.summary # to get help on the scantable's
|
---|
1341 | ASAP> help average_time
|
---|
1342 |
|
---|
1343 | \end{verbatim}
|
---|
1344 |
|
---|
1345 | \section{Scantable Mathematics}
|
---|
1346 |
|
---|
1347 | It is possible to to simple mathematics directly on scantables from
|
---|
1348 | the command line using the \cmd{+, -, *, /} operators as well as their
|
---|
1349 | cousins \cmd{+=, -= *=, /=}. This works between two scantables or a
|
---|
1350 | scantable and a float. (Note that it does not work for integers).
|
---|
1351 |
|
---|
1352 | \begin{verbatim}
|
---|
1353 | ASAP> sum = scan1+scan2
|
---|
1354 | ASAP> scan2 = scan1+2.0
|
---|
1355 | ASAP> scan *= 1.05
|
---|
1356 | \end{verbatim}
|
---|
1357 |
|
---|
1358 | %\section{Scripting}
|
---|
1359 |
|
---|
1360 | %Malte to add something
|
---|
1361 |
|
---|
1362 | \section{Appendix}
|
---|
1363 |
|
---|
1364 | \subsection{Installation}
|
---|
1365 |
|
---|
1366 | ASAP depends on a number of third-party libraries which you must
|
---|
1367 | have installed before attempting to build ASAP. These are:
|
---|
1368 |
|
---|
1369 | \begin{itemize}
|
---|
1370 | \item AIPS++
|
---|
1371 | \item Boost
|
---|
1372 | \item Matplotlib
|
---|
1373 | \item ipython/python
|
---|
1374 | \end{itemize}
|
---|
1375 |
|
---|
1376 | Debian Linux is currently supported and we intend also
|
---|
1377 | to support other popular Linux flavours, Solaris and Mac.
|
---|
1378 |
|
---|
1379 | Of the dependencies, AIPS++ is the most complex to install.
|
---|
1380 |
|
---|
1381 | \subsection{ASCII output format}
|
---|
1382 |
|
---|
1383 | \subsection{.asaprc settings}
|
---|
1384 |
|
---|
1385 | \end{document}
|
---|
1386 |
|
---|
1387 |
|
---|