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