1 | \documentclass[11pt]{article}
|
---|
2 | \usepackage{a4}
|
---|
3 | \usepackage{calc}
|
---|
4 | \usepackage[dvips]{graphicx}
|
---|
5 | \usepackage{makeidx}
|
---|
6 |
|
---|
7 | % Adjust the page size
|
---|
8 | \addtolength{\oddsidemargin}{-0.4in}
|
---|
9 | \addtolength{\evensidemargin}{+0.4in}
|
---|
10 | \addtolength{\textwidth}{+0.8in}
|
---|
11 |
|
---|
12 | \setlength{\parindent}{0mm}
|
---|
13 | \setlength{\parskip}{1ex}
|
---|
14 |
|
---|
15 | \title{ATNF Spectral Analysis Package\\User Guide }
|
---|
16 | \author{Chris Phillips}
|
---|
17 |
|
---|
18 | \newcommand{\cmd}[1]{{\tt #1}}
|
---|
19 |
|
---|
20 | \newcommand{\asaprc}[3]{
|
---|
21 | \begin{minipage}[t]{45mm}#1\end{minipage}
|
---|
22 | \begin{minipage}[t]{30mm}\raggedright #2\end{minipage}\hspace{3mm}
|
---|
23 | \begin{minipage}[t]{\textwidth-75mm}#3\end{minipage}
|
---|
24 | }
|
---|
25 |
|
---|
26 | \makeindex
|
---|
27 |
|
---|
28 |
|
---|
29 | \begin{document}
|
---|
30 |
|
---|
31 | \maketitle
|
---|
32 |
|
---|
33 | \section{Introduction}
|
---|
34 |
|
---|
35 | ASAP is a single dish spectral line processing package currently being
|
---|
36 | developed by the ATNF. It is intended to process data from all ATNF
|
---|
37 | antennas, and can probably be used for other antennas if they can
|
---|
38 | produce ``Single Dish FITS'' format. It is based on the AIPS++
|
---|
39 | package.
|
---|
40 |
|
---|
41 | This useeguide is currently being updated for the ASAP 2.0 release
|
---|
42 | which has a number of significant changes which affect the user
|
---|
43 | interface. Please report any mistakes you find in this userguide.
|
---|
44 |
|
---|
45 | \section{Installation and Running}
|
---|
46 |
|
---|
47 | Currently there are installations running on Linux machines at
|
---|
48 |
|
---|
49 | \begin{itemize}
|
---|
50 | \item Epping - use hosts {\tt draco} or {\tt hydra}
|
---|
51 | \item Narrabri - use host {\tt kaputar}
|
---|
52 | \item Parkes - use host {\tt bourbon}
|
---|
53 | \item Mopra - use host {\tt minos}
|
---|
54 | \end{itemize}
|
---|
55 |
|
---|
56 | \index{Running}To start asap log onto one of these Linux hosts and enter
|
---|
57 |
|
---|
58 | \begin{verbatim}
|
---|
59 | > cd /my/data/directory
|
---|
60 | > asap
|
---|
61 | \end{verbatim}
|
---|
62 |
|
---|
63 | This starts the ASAP. To quit, you need to type \verb+^+-d
|
---|
64 | (control-d).
|
---|
65 |
|
---|
66 | \section{Interface}
|
---|
67 |
|
---|
68 | \index{Interface}ASAP is written in C++ and python. The user interface uses the
|
---|
69 | ``ipython'' interactive shell, which is a simple interactive interface
|
---|
70 | to python. The user does not need to understand python to use this,
|
---|
71 | but certain aspects python affect what the user can do. The current
|
---|
72 | interface is object oriented. In the future, we will build a
|
---|
73 | functional (non object oriented) shell on top of this to ease
|
---|
74 | interactive use.
|
---|
75 |
|
---|
76 | \subsection {Integer Indices are 0-relative}
|
---|
77 |
|
---|
78 | Please note, all integer indices in ASAP and iPython are {\bf 0-relative}.
|
---|
79 |
|
---|
80 | \subsection{Objects}
|
---|
81 | \index{objects}
|
---|
82 | The ASAP interface is based around a number of ``objects'' which the
|
---|
83 | user deals with. Objects range from the data which have been read from
|
---|
84 | disk, to tools used for fitting functions to the data. The following
|
---|
85 | main objects are used :
|
---|
86 |
|
---|
87 | \begin{itemize}
|
---|
88 | \item[\cmd{scantable}] The data container (actual spectra and header
|
---|
89 | information)
|
---|
90 | \item[\cmd{selector}] Allows the user to select a subsection of the
|
---|
91 | data, such as a specified or ramge of beam numbers, IFs, etc.
|
---|
92 | \item[\cmd{plotter}] A tool used to plot the spectral line data
|
---|
93 | \item[\cmd{fitter}] A tool used to fit functions to the spectral data
|
---|
94 | \item[\cmd{reader}] A tool which can be used to read data from disks
|
---|
95 | into a scantable object.
|
---|
96 | \end{itemize}
|
---|
97 |
|
---|
98 | There can be many objects of the same type. Each object is referred to
|
---|
99 | by a variable name made by the user. The name of this variable is not
|
---|
100 | important and can be set to whatever the user prefers (i.e. ``s'' and
|
---|
101 | ``ParkesHOH-20052002'' are equivalent). However, having a simple and
|
---|
102 | consistent naming convention will help you a lot.
|
---|
103 |
|
---|
104 | \subsection{Member Functions (functions)}
|
---|
105 |
|
---|
106 | \index{Functions!member}Following the object oriented approach,
|
---|
107 | objects have associated ``member functions'' which can either be used
|
---|
108 | to modify the data in some way or change global properties of the
|
---|
109 | object. In this document member functions will be referred to simply
|
---|
110 | as functions. From the command line, the user can execute these
|
---|
111 | functions using the syntax:
|
---|
112 | \begin{verbatim}
|
---|
113 | ASAP> out = object.function(arguments)
|
---|
114 | \end{verbatim}
|
---|
115 |
|
---|
116 | Where \cmd{out} is the name of the returned variable (could be a new
|
---|
117 | scantable object, or a vector of data, or a status return),
|
---|
118 | \cmd{object} is the object variable name (set by the user),
|
---|
119 | \cmd{function} is the name of the member function and \cmd{arguments}
|
---|
120 | is a list of arguments to the function. The arguments can be provided
|
---|
121 | either though position or \cmd{name=}. A mix of the two can be used.
|
---|
122 | E.g.
|
---|
123 |
|
---|
124 | \begin{verbatim}
|
---|
125 | ASAP> av = scans.average_time(msk,weight='tsys')
|
---|
126 | ASAP> av = scans.average_time(mask=msk,weight='tsys')
|
---|
127 | ASAP> av = scans.average_time(msk,tsys)
|
---|
128 | ASAP> scans.polybaseline(mask=msk, order=0, insitu=True)
|
---|
129 | ASAP> scans.polybaseline(msk,0,True)
|
---|
130 | ASAP> scans.polybaseline(mask, insitu=True)
|
---|
131 | \end{verbatim}
|
---|
132 |
|
---|
133 | \subsection{Global Functions}
|
---|
134 |
|
---|
135 | \index{Functions!global}It does not make sense to implement some functions as member
|
---|
136 | functions, typically functions which operate on more than one
|
---|
137 | scantable (e.g. time averaging of many scans). These functions will
|
---|
138 | always be referred to as global functions.
|
---|
139 |
|
---|
140 | \subsection{Interactive environment}
|
---|
141 |
|
---|
142 | \index{ipython!environment}ipython has a number of useful interactive
|
---|
143 | features and a few things to be aware of for the new user.
|
---|
144 |
|
---|
145 | \subsubsection{String completion}
|
---|
146 |
|
---|
147 | \index{ipython!string completion}Tab completion is enabled for all
|
---|
148 | function names. If you type the first few letters of a function name,
|
---|
149 | then type {\tt <TAB>} the function name will be auto completed if it
|
---|
150 | is un-ambiguous, or a list of possibilities will be
|
---|
151 | given. Auto-completion works for the user object names as well as
|
---|
152 | function names. It does not work for filenames, nor for function
|
---|
153 | arguments.
|
---|
154 |
|
---|
155 | Example
|
---|
156 | \begin{verbatim}
|
---|
157 | ASAP> scans = scantable('MyData.rpf')
|
---|
158 | ASAP> scans.se<TAB>
|
---|
159 | scans.set_cursor scans.set_freqframe scans.set_unit scans.setpol
|
---|
160 | scans.set_doppler scans.set_instrument scans.setbeam
|
---|
161 | scans.set_fluxunit scans.set_restfreqs scans.setif
|
---|
162 | ASAP> scans.set_in<TAB>
|
---|
163 | ASAP> scans.set_instrument()
|
---|
164 | \end{verbatim}
|
---|
165 |
|
---|
166 | \subsubsection{Leading Spaces}
|
---|
167 |
|
---|
168 | \index{ipython!leading space}Python uses leading space to mark blocks
|
---|
169 | of code. This means that it you start a command line with a space, the
|
---|
170 | command generally will fail with an syntax error.
|
---|
171 |
|
---|
172 | \subsubsection{Variable Names}
|
---|
173 |
|
---|
174 | \index{ipython!variable names}During normal data processing, the user
|
---|
175 | will have to create named variables to hold spectra etc. These must
|
---|
176 | conform to the normal python syntax, specifically they cannot contain
|
---|
177 | ``special'' characters such as \@ \$ etc and cannot start with a
|
---|
178 | number (but can contain numbers). Variable (and function) names are
|
---|
179 | case sensitive.
|
---|
180 |
|
---|
181 | \subsubsection{Unix Interaction}
|
---|
182 |
|
---|
183 | \index{ipython!unix interaction}Basic unix shell commands (\cmd{pwd},
|
---|
184 | \cmd{ls}, \cmd{cd} etc) can be issued from within ASAP. This allows
|
---|
185 | the user to do things like look at files in the current directory. The
|
---|
186 | shell command ``\cmd{cd}'' works within ASAP, allowing the user to
|
---|
187 | change between data directories. Unix programs cannot be run this way,
|
---|
188 | but the shell escape ``$!$'' can be used to run arbitrary
|
---|
189 | programs. E.g.
|
---|
190 |
|
---|
191 | \begin{verbatim}
|
---|
192 | ASAP> pwd
|
---|
193 | ASAP> ls
|
---|
194 | ASAP> cd /my/data/directory
|
---|
195 | ASAP> ! mozilla&
|
---|
196 | \end{verbatim}
|
---|
197 |
|
---|
198 | \subsection{Help}
|
---|
199 |
|
---|
200 | \index{Help}ASAP has built in help for all functions. To get a list of
|
---|
201 | functions type:
|
---|
202 |
|
---|
203 | \begin{verbatim}
|
---|
204 | ASAP> commands()
|
---|
205 | \end{verbatim}
|
---|
206 |
|
---|
207 | To get help on specific functions, the built in help needs to be given
|
---|
208 | the object and function name. E.g.
|
---|
209 |
|
---|
210 | \begin{verbatim}
|
---|
211 | ASAP> help scantable.get_scan
|
---|
212 | ASAP> help scantable.stats
|
---|
213 | ASAP> help plotter.plot
|
---|
214 | ASAP> help fitter.plot
|
---|
215 |
|
---|
216 | ASAP> scans = scantable('mydata.asap')
|
---|
217 | ASAP> help scans.get_scan # Same as above
|
---|
218 | \end{verbatim}
|
---|
219 |
|
---|
220 | Global functions just need their name
|
---|
221 |
|
---|
222 | \begin{verbatim}
|
---|
223 | ASAP> help average_time
|
---|
224 | \end{verbatim}
|
---|
225 |
|
---|
226 | Note that if you just type \cmd{help} the internal ipython help is
|
---|
227 | invoked, which is probably {\em not} what you want. Type \verb+^+-d
|
---|
228 | (control-d) to escape from this.
|
---|
229 |
|
---|
230 | \subsection{Customisation - .asaprc}
|
---|
231 |
|
---|
232 | \index{.asaprc}ASAP use an \cmd{.asaprc} file to control the user's
|
---|
233 | preference of default values for various functions arguments. This
|
---|
234 | includes the defaults for arguments such as \cmd{insitu}, scantable
|
---|
235 | \cmd{freqframe} and the plotters \cmd{set\_mode} values. The help on
|
---|
236 | individual functions says which arguments can be set default values
|
---|
237 | from the \cmd{.asaprc} file. To get a sample contents for the
|
---|
238 | \cmd{.asaprc} file use then command \cmd{list\_rcparameters}.
|
---|
239 |
|
---|
240 | Common values include:
|
---|
241 | \begin{verbatim}
|
---|
242 | # apply operations on the input scantable or return new one
|
---|
243 | insitu : False
|
---|
244 |
|
---|
245 | # default output format when saving scantable
|
---|
246 | scantable.save : ASAP
|
---|
247 |
|
---|
248 | # default frequency frame to set when function
|
---|
249 | # scantable.set_freqframe is called
|
---|
250 | scantable.freqframe : LSRK
|
---|
251 |
|
---|
252 | # auto averaging on read
|
---|
253 | scantable.autoaverage : True
|
---|
254 | \end{verbatim}
|
---|
255 |
|
---|
256 | For a complete list of \cmd{.asaprc} values, see the Appendix.
|
---|
257 |
|
---|
258 | \section{Scantables}
|
---|
259 | \index{Scantables}
|
---|
260 | \subsection {Description}
|
---|
261 |
|
---|
262 | \subsubsection {Basic Structure}
|
---|
263 |
|
---|
264 | \index{Scantable!structure}ASAP data handling works on objects called
|
---|
265 | scantables. A scantable holds your data, and also provides functions
|
---|
266 | to operate upon it.
|
---|
267 |
|
---|
268 | {\bf [MALTE: Could you please reword this??]}
|
---|
269 |
|
---|
270 | The building block of a scantable is an integration, which is a single
|
---|
271 | row of a scantable. Each row contains spectra for each beam, IF and
|
---|
272 | polarisation. For example Parkes multibeam data would contain many
|
---|
273 | beams, one IF and 2-4 polarisations, while the new Mopra 8-GHz
|
---|
274 | filterbank will eventually produce one beam, many IFs, and 2-4
|
---|
275 | polarisations.
|
---|
276 |
|
---|
277 | A collection of sequential integrations (rows) for one source is termed
|
---|
278 | a scan (and each scan has a unique numeric identifier, the ScanID). A
|
---|
279 | scantable is then a collection of one or more scans. If you have
|
---|
280 | scan-averaged your data in time, then each scan would hold just one
|
---|
281 | (averaged) integration.
|
---|
282 |
|
---|
283 | Many of the functions which work on scantables can either return a
|
---|
284 | new scantable with modified data or change the scantable insitu. Which
|
---|
285 | method is used depends on the users preference. The default can be
|
---|
286 | changed via the {\tt .asaprc} resource file.
|
---|
287 |
|
---|
288 | \subsubsection {Contents}
|
---|
289 |
|
---|
290 | \index{Scantable!contents}A scantable has header information and data
|
---|
291 | (a scantable is actually an AIPS++ Table and it is generally stored in
|
---|
292 | memory when you are manipulating it with ASAP. You can save it to
|
---|
293 | disk and then browse it with the AIPS++ Table browser if you know how
|
---|
294 | to do that !).
|
---|
295 |
|
---|
296 | The data are stored in columns (the length of a column is the number of
|
---|
297 | rows/integrations of course).
|
---|
298 |
|
---|
299 | {\bf [MALTE: Is this outdated??]}
|
---|
300 |
|
---|
301 | Two important columns are those that describe the frequency setup. We mention
|
---|
302 | them explicitly here because you need to be able to understand the presentation
|
---|
303 | of the frequency information and possibly how to manipulate it.
|
---|
304 |
|
---|
305 | These columns are called FreqID and RestFreqID. They contain indices, for
|
---|
306 | each IF, pointing into tables with all of the frequency information for that
|
---|
307 | integration. More on these below when we discuss the \cmd{summary} function
|
---|
308 | in the next subsection.
|
---|
309 |
|
---|
310 | There are of course many other columns which contain the actual spectra,
|
---|
311 | the flags, the Tsys, the source names and so on, but those are a little
|
---|
312 | more transparently handled.
|
---|
313 |
|
---|
314 | There is also a function \cmd{summary} to list a summary of the scantable.
|
---|
315 | You will find this very useful.
|
---|
316 |
|
---|
317 | Example:
|
---|
318 |
|
---|
319 | \begin{verbatim}
|
---|
320 | ASAP> scans = scantable('MyData.rpf')
|
---|
321 | ASAP> scans.summary() # Brief listing
|
---|
322 | ASAP> scans.summary(verbose=True) # Include frequency information
|
---|
323 |
|
---|
324 | # Equivalent to brief summary function call
|
---|
325 | ASAP> print scan
|
---|
326 | \end{verbatim}
|
---|
327 |
|
---|
328 | Most of what the \cmd{summary} function prints out is obvious. However,
|
---|
329 | it also prints out the FreqIDs and RestFreqIDs to which we alluded above.
|
---|
330 | These are the last column of the listing.
|
---|
331 |
|
---|
332 | The summary function gives you a scan-based summary. So it lists all of
|
---|
333 | the FreqIDs and RestFreqIDs that it encountered for each scan. If you'd
|
---|
334 | like to see what each FreqID actually means, then set the verbose
|
---|
335 | argument to True and the frequency table will be listed at the end.
|
---|
336 | FreqID of 3 say, refers to the fourth row of the frequency table (ASAP
|
---|
337 | is 0-relative). The list of rest frequencies, to which the RestFreqIDs
|
---|
338 | refer, is always listed.
|
---|
339 |
|
---|
340 | \subsection{Data Selection}
|
---|
341 | \label{sec:selection}
|
---|
342 |
|
---|
343 | ASAP contains flexible data selection. Data can be selected based on
|
---|
344 | IF, beam, polarisation, scan number as well as values such as
|
---|
345 | Tsys. Advanced users can also make use of the AIPS++ TAQL language to
|
---|
346 | create selections based on almost any of the standard header values.
|
---|
347 |
|
---|
348 | Selection is based on a \cmd{selector} object. This object is created
|
---|
349 | and various selection functions applied to it (\cmd{set\_ifs},
|
---|
350 | \cmd{set\_beams} etc). The selection object then must be applied to a
|
---|
351 | scantable using the \cmd{set\_selection} function. A single selection
|
---|
352 | object can be created and setup then applied to multiple scantables.
|
---|
353 |
|
---|
354 | Once a selection has been applied, all following functions will only
|
---|
355 | ``see'' the selected spectra (including functions such as
|
---|
356 | \cmd{summary}). The selection can then be reset and all spectra are
|
---|
357 | visible. Note that if functions such as \cmd{copy} are run on a
|
---|
358 | scantable with active selection, only the selected spectra are copied.
|
---|
359 |
|
---|
360 | The common selection functions are:
|
---|
361 |
|
---|
362 | \begin{itemize}
|
---|
363 |
|
---|
364 | \item[\cmd{set\_beams}] Select beams by index number
|
---|
365 | \item[\cmd{set\_ifs}] Select ifs by index number
|
---|
366 | \item[\cmd{set\_name}] Select by source name. Can contain ``*'' as a
|
---|
367 | wildcard, e.g. ``Orion*\_R''.
|
---|
368 | \item[\cmd{set\_ifs}] Select ifs by index number
|
---|
369 | \item[\cmd{set\_polarisation}] Select but polarisation index or
|
---|
370 | name. If polarisation names are given, the data will be on-the-fly
|
---|
371 | converted (for example from linears to Stokes). Not all conversions
|
---|
372 | are currently supported.
|
---|
373 | \item[\cmd{set\_query}] Set query directly. For power users only!
|
---|
374 | \item[\cmd{set\_tsys}] Select data based on Tsys. Also example of user
|
---|
375 | definable query.
|
---|
376 | \item[\cmd{reset}] Reset the selection to include all spectra.
|
---|
377 |
|
---|
378 |
|
---|
379 | Note that all indices are zero based.
|
---|
380 |
|
---|
381 | Examples:
|
---|
382 |
|
---|
383 | \begin{verbatim}
|
---|
384 | ASAP> selection = selector() # Create selection object
|
---|
385 | ASAP> selection.set_ifs(0) # Just select the first IF
|
---|
386 | ASAP> scans.set_selection(selection) # Apply the selection
|
---|
387 | ASAP> print scans # Will just show the first IF
|
---|
388 |
|
---|
389 | ASAP> selection.set_ifs([0,1]) # Select the first two IFs
|
---|
390 | ASAP> selection.set_beams([1,3,5]) # Also select three of the beams
|
---|
391 | ASAP> scans.set_selection(selection) # Apply the selection
|
---|
392 |
|
---|
393 | ASAP> selection.set_name('G308*') # Select by source name
|
---|
394 |
|
---|
395 | ASAP> selection.reset() # Turn off selection
|
---|
396 | ASAP> scans.set_selection(selection) # Apply the reset selection
|
---|
397 |
|
---|
398 | \end{verbatim}
|
---|
399 |
|
---|
400 | \end{itemize}
|
---|
401 |
|
---|
402 | \subsection{State}
|
---|
403 |
|
---|
404 | \index{Scantable!state}Each scantable contains "state"; these are
|
---|
405 | properties applying to all of the data in the scantable.
|
---|
406 |
|
---|
407 | Examples are the selection of beam, IF and polarisation, spectral unit
|
---|
408 | (e.g. km/s), frequency reference frame (e.g. BARY) and velocity Doppler
|
---|
409 | type (e.g. RADIO).
|
---|
410 |
|
---|
411 | \subsubsection{Units, Doppler and Frequency Reference Frame}
|
---|
412 |
|
---|
413 | The information describing the frequency setup for each integration
|
---|
414 | is stored fundamentally in frequency in the reference frame
|
---|
415 | of observation (E.g. TOPO).
|
---|
416 |
|
---|
417 | When required, this is converted to the desired reference frame
|
---|
418 | (e.g. LSRK), Doppler (e.g. OPTICAL) and unit (e.g. km/s) on-the-fly.
|
---|
419 | This is important, for example, when you are displaying the data or
|
---|
420 | fitting to it.
|
---|
421 |
|
---|
422 | For units, the user has the choice of frequency, velocity or channel.
|
---|
423 | The \cmd{set\_unit} function is used to set the current unit for a
|
---|
424 | scantable. All functions will (where relevant) work with the selected
|
---|
425 | unit until this changes. This is mainly important for fitting (the fits
|
---|
426 | can be computed in any of these units), plotting and mask creation.
|
---|
427 |
|
---|
428 | The velocity definition can be changed with the \cmd{set\_doppler}
|
---|
429 | function, and the frequency reference frame can be changed with the
|
---|
430 | \cmd{set\_freqframe} function.
|
---|
431 |
|
---|
432 | Example usage:
|
---|
433 |
|
---|
434 | \begin{verbatim}
|
---|
435 | ASAP> scans = scantable('2004-11-23_1841-P484.rpf') # Read in the data
|
---|
436 | ASAP> scans.set_freqframe('LSRK') # Use the LSR velocity frame
|
---|
437 | ASAP> scans.set_unit('km/s') # Use velocity for plots etc from now on
|
---|
438 | ASAP> scans.set_doppler('OPTICAL') # Use the optical velocity convention
|
---|
439 | ASAP> scans.set_unit('MHz') # Use frequency in MHz from now on
|
---|
440 | \end{verbatim}
|
---|
441 |
|
---|
442 |
|
---|
443 | \subsubsection{Rest Frequency}
|
---|
444 |
|
---|
445 | \index{Scantable!rest frequency}ASAP reads the line rest frequency
|
---|
446 | from the RPFITS file when reading the data. The values stored in the
|
---|
447 | RPFITS file are not always correct and so there is a function
|
---|
448 | \cmd{set\_restfreq} to set the rest frequencies for the currently
|
---|
449 | selected data.
|
---|
450 |
|
---|
451 | For each integration, there is a rest-frequency per IF (the rest
|
---|
452 | frequencies are just stored as a list with an index into them).
|
---|
453 | There are a few ways to set the rest frequencies with this function.
|
---|
454 |
|
---|
455 | If you specify just one rest frequency, then it is set for all IF.
|
---|
456 |
|
---|
457 | \begin{verbatim}
|
---|
458 | # Set all IFs
|
---|
459 | ASAP> scans.set_restfreqs(freqs=1.667359e9)
|
---|
460 | \end{verbatim}
|
---|
461 |
|
---|
462 | If set a rest frequency for each IF, specify a list of frequencies (of
|
---|
463 | length the number of IFs). Regardless of the source, the rest
|
---|
464 | frequency will be set for each IF to the corresponding value in the
|
---|
465 | provided list.
|
---|
466 |
|
---|
467 | \begin{verbatim}
|
---|
468 | # Set rest frequency for all IFs
|
---|
469 | ASAP> scans.set_restfreqs(freqs=[1.6654018e9,1.667359e9,])
|
---|
470 |
|
---|
471 | \end{verbatim}
|
---|
472 |
|
---|
473 | {\em Currently this is not implemented}
|
---|
474 |
|
---|
475 | In both of the above modes, you can also specify the rest frequencies via
|
---|
476 | names in a known list rather than by their values.
|
---|
477 |
|
---|
478 | Examples:
|
---|
479 |
|
---|
480 | \begin{verbatim}
|
---|
481 | ASAP> scans.set_restfreqs(freqs=['OH1665','OH1667'])
|
---|
482 | \end{verbatim}
|
---|
483 |
|
---|
484 |
|
---|
485 | \subsubsection{Masks}
|
---|
486 |
|
---|
487 | \index{Masks}\index{Scantable!masks}
|
---|
488 |
|
---|
489 | Many tasks (fitting, baseline subtraction, statistics etc) should only
|
---|
490 | be run on range of channels. Depending on the current ``unit'' setting
|
---|
491 | this range is set directly as channels, velocity or frequency
|
---|
492 | ranges. Internally these are converted into a simple boolean mask for
|
---|
493 | each channel of the abscissa. This means that if the unit setting is
|
---|
494 | later changed, previously created mask are still valid. (This is not
|
---|
495 | true for functions which change the shape or shift the frequency
|
---|
496 | axis). You create masks with the function \cmd{create\_mask} and this
|
---|
497 | specified the channels to be included in the selection. When setting
|
---|
498 | the mask in velocity, the conversion from velocity to channels is
|
---|
499 | based on the current cursor setting, selected row and selected
|
---|
500 | frequency reference frame.
|
---|
501 |
|
---|
502 |
|
---|
503 | Note that for multi IF data with different number of channels per IF a
|
---|
504 | single mask cannot be applied to different IFs. To use a mask on such
|
---|
505 | data the selector should be applied to select all IFs with the same
|
---|
506 | number of channels.
|
---|
507 |
|
---|
508 | Example :
|
---|
509 | \begin{verbatim}
|
---|
510 |
|
---|
511 | # Select channel range for baselining
|
---|
512 | ASAP> scans.set_unit('channels')
|
---|
513 | ASAP> msk = scans.create_mask([100,400],[600,800])
|
---|
514 |
|
---|
515 | # Select velocity range for fitting
|
---|
516 | ASAP> scans.set_unit('km/s')
|
---|
517 | ASAP> msk = scans.create_mask([-30,-10])
|
---|
518 | \end{verbatim}
|
---|
519 |
|
---|
520 | Sometimes it is more convenient to specify the channels to be
|
---|
521 | excluded, rather included. You can do this with the ``invert''
|
---|
522 | argument.
|
---|
523 |
|
---|
524 | Example :
|
---|
525 | \begin{verbatim}
|
---|
526 | ASAP> scans.set_unit('channels')
|
---|
527 | ASAP> msk = scans.create_mask([0,100],[900-1023], invert=True)
|
---|
528 | \end{verbatim}
|
---|
529 |
|
---|
530 | By default \cmd{create\_mask} uses the frequency setup of the first row
|
---|
531 | to convert velocities into a channel mask. If the rows in the data
|
---|
532 | cover different velocity ranges, the scantable row to use should be
|
---|
533 | specified:
|
---|
534 |
|
---|
535 | \begin{verbatim}
|
---|
536 | ASAP> scans.set_unit('km/s')
|
---|
537 | ASAP> msk = q.create_mask([-30,-10], row=5)
|
---|
538 | \end{verbatim}
|
---|
539 |
|
---|
540 | Because the mask is stored in a simple python variable, the users is
|
---|
541 | able to combine masks using simple arithmetic. To create a mask
|
---|
542 | excluding the edge channels, a strong maser feature and a birdie in
|
---|
543 | the middle of the band:
|
---|
544 |
|
---|
545 | \begin{verbatim}
|
---|
546 | ASAP> scans.set_unit('channels')
|
---|
547 | ASAP> msk1 = q.create_mask([0,100],[511,511],[900,1023],invert=True)
|
---|
548 | ASAP> scans.set_unit('km/s')
|
---|
549 | ASAP> msk2 = q.create_mask([-20,-10],invert=True)
|
---|
550 |
|
---|
551 | ASAP> mask = msk1 and msk2
|
---|
552 | \end{verbatim}
|
---|
553 |
|
---|
554 |
|
---|
555 | \subsection{Management}
|
---|
556 |
|
---|
557 | \index{Scantable!management}During processing it is possible to create
|
---|
558 | a large number of scan tables. These all consume memory, so it is best
|
---|
559 | to periodically remove unneeded scan tables. Use \cmd{list\_scans} to
|
---|
560 | print a list of all scantables and \cmd{del} to remove unneeded ones.
|
---|
561 |
|
---|
562 | Example:
|
---|
563 |
|
---|
564 | \begin{verbatim}
|
---|
565 | ASAP> list_scans()
|
---|
566 | The user created scantables are:
|
---|
567 | ['s', 'scans', 'av', 's2', 'ss']
|
---|
568 |
|
---|
569 | ASAP> del s2
|
---|
570 | ASAP> del ss
|
---|
571 | \end{verbatim}
|
---|
572 |
|
---|
573 | \section{Data Input}
|
---|
574 |
|
---|
575 | \index{Reading data}Data can be loaded in one of two ways; using the reader object or via
|
---|
576 | the scantable constructor. The scantable method is simpler but the
|
---|
577 | reader allow the user more control on what is read.
|
---|
578 |
|
---|
579 | \subsection{Scantable constructor}
|
---|
580 |
|
---|
581 | \index{Scantable constructor}\index{Scantable!constructor}This loads
|
---|
582 | all of the data from filename into the scantable object scans and
|
---|
583 | averages all the data within a scan (i.e. the resulting scantable
|
---|
584 | will have one row per scan). The recognised input file formats are
|
---|
585 | RPFITS, SDFITS (singledish fits), ASAP's scantable format and aips++
|
---|
586 | MeasurementSet2 format.
|
---|
587 |
|
---|
588 | Example usage:
|
---|
589 |
|
---|
590 | \begin{verbatim}
|
---|
591 | ASAP> scan = scantable('2004-11-23_1841-P484.rpf')
|
---|
592 |
|
---|
593 | # Don't scan average the data
|
---|
594 | ASAP> scan = scantable('2004-11-23_1841-P484.rpf', average=False)
|
---|
595 | \end{verbatim}
|
---|
596 |
|
---|
597 |
|
---|
598 | \subsection{Reader object}
|
---|
599 |
|
---|
600 | \index{Reader object}\index{Scantable!reader object}For more control
|
---|
601 | when reading data into ASAP, the reader object should be used. This
|
---|
602 | has the option of only reading in a range of integrations, only a
|
---|
603 | specified beam or IF and does not perform any scan averaging of the
|
---|
604 | data, allowing analysis of the individual integrations. Note that due
|
---|
605 | to limitation of the RPFITS library, only one reader object can be
|
---|
606 | open at one time reading RPFITS files. To read multiple RPFITS files,
|
---|
607 | the old reader must be destroyed before the new file is opened.
|
---|
608 | However, multiple readers can be created and attached to SDFITS files.
|
---|
609 |
|
---|
610 |
|
---|
611 | Example usage:
|
---|
612 |
|
---|
613 | \begin{verbatim}
|
---|
614 | ASAP> r = reader('2003-03-16_082048_t0002.rpf')
|
---|
615 | ASAP> r.summary()
|
---|
616 | ASAP> scan = r.read()
|
---|
617 | ASAP> s = r.read(range(100)) # To read in the first 100 integrations
|
---|
618 | ASAP> del r
|
---|
619 | \end{verbatim}
|
---|
620 |
|
---|
621 | \section{Basic Processing}
|
---|
622 |
|
---|
623 | In the following section, a simple data reduction to form a quotient
|
---|
624 | spectrum of a single source is followed. It has been assume that the
|
---|
625 | \cmd{.asaprc} file has {\em not} been used to change the \cmd{insitu}
|
---|
626 | default value from \cmd{True}.
|
---|
627 |
|
---|
628 | \subsection{Auto quotient}
|
---|
629 | \index{Auto quotient}Quotients can be computed ``automatically''. This
|
---|
630 | requires the data to have matching source/reference pairs or one
|
---|
631 | reference for multiple sources. Auto quotient assumes reference scans
|
---|
632 | have a trailing ``\_R'' in the source name for data from Parkes and
|
---|
633 | Mopra, and a trailing ``e'' or ``w'' for data fro, Tidbinbilla.
|
---|
634 |
|
---|
635 | \begin{verbatim}
|
---|
636 | ASAP> q = s.auto_quotient()
|
---|
637 | \end{verbatim}
|
---|
638 |
|
---|
639 | %If this is not sufficient the following alternative method can be used.
|
---|
640 | %
|
---|
641 | %\subsection{Separate reference and source observations}
|
---|
642 | %
|
---|
643 | %\index{Quotient spectra}Most data from ATNF observatories
|
---|
644 | %distinguishes on and off source data using the file name. This makes
|
---|
645 | %it easy to create two scantables with the source and reference
|
---|
646 | %data. As long as there was exactly one reference observation for each
|
---|
647 | %on source observation for following method will work.
|
---|
648 | %
|
---|
649 | %For Mopra and Parkes data:
|
---|
650 | %\begin{verbatim}
|
---|
651 | % ASAP> r = scans.get_scan('*_R')
|
---|
652 | % ASAP> s = scans.get_scan('*_S')
|
---|
653 | %\end{verbatim}
|
---|
654 | %
|
---|
655 | %For Tidbinbilla data
|
---|
656 | %\begin{verbatim}
|
---|
657 | % ASAP> r = scans.get_scan('*_[ew]')
|
---|
658 | % ASAP> s = scans.get_scan('*_[^ew]')
|
---|
659 | %\end{verbatim}
|
---|
660 | %
|
---|
661 | %\subsection{Make the quotient spectra}
|
---|
662 | %
|
---|
663 | %Use the quotient function
|
---|
664 | %
|
---|
665 | %\begin{verbatim}
|
---|
666 | % ASAP> q = s.quotient(r)
|
---|
667 | %\end{verbatim}
|
---|
668 | %
|
---|
669 | %This uses the rows in scantable \cmd{r} as reference spectra for the
|
---|
670 | %rows in scantable \cmd{s}. Scantable \cmd{r} must have either 1 row
|
---|
671 | %(which is applied to all rows in \cmd{s}) or both scantables must have
|
---|
672 | %the same number of rows. By default the quotient spectra is calculated
|
---|
673 | %to preserve continuum emission. If you wish to remove the continuum
|
---|
674 | %contribution, use the \cmd{preserve} argument:
|
---|
675 | %
|
---|
676 | %\begin{verbatim}
|
---|
677 | % ASAP> q = s.quotient(r, preserve=True)
|
---|
678 | %\end{verbatim}
|
---|
679 |
|
---|
680 | \subsection{Time average separate scans}
|
---|
681 |
|
---|
682 | \index{Time average}If you have observed the source with multiple
|
---|
683 | source/reference cycles you will want to scan-average the quotient
|
---|
684 | spectra together.
|
---|
685 |
|
---|
686 | \begin{verbatim}
|
---|
687 | ASAP> av = q.average_time()
|
---|
688 | \end{verbatim}
|
---|
689 |
|
---|
690 | If for some you want to average multiple sets of scantables together
|
---|
691 | you can:
|
---|
692 |
|
---|
693 | \begin{verbatim}
|
---|
694 | ASAP> av = average_time(q1, q2, q3)
|
---|
695 | \end{verbatim}
|
---|
696 |
|
---|
697 | The default is to use integration time weighting. The alternative is
|
---|
698 | to use none, variance, Tsys weighting or Tsys \& integration time.
|
---|
699 |
|
---|
700 | \begin{verbatim}
|
---|
701 | ASAP> av = average_time(q, weight='tintsys')
|
---|
702 | \end{verbatim}
|
---|
703 |
|
---|
704 | To use variance based weighting, you need to supply a mask saying which
|
---|
705 | channel range you want it to calculate the variance from.
|
---|
706 |
|
---|
707 | \begin{verbatim}
|
---|
708 | ASAP> msk = scans.create_mask([200,400],[600,800])
|
---|
709 | ASAP> av = average_time(scans, mask=msk, weight='var')
|
---|
710 | \end{verbatim}
|
---|
711 |
|
---|
712 | If you have not observed your data with Doppler tracking (or run
|
---|
713 | \cmd{freq\_align} explicitally) you should align the data in frequency
|
---|
714 | before averaging.
|
---|
715 |
|
---|
716 | \begin{verbatim}
|
---|
717 | ASAP> av = scans.average_time(align=True)
|
---|
718 | \end{verbatim}
|
---|
719 |
|
---|
720 | Note that, if needed, you should run \cmd{gain\_el} and \cmd{opacity}
|
---|
721 | before you average the data in time (\S \ref{sec:gainel} \&
|
---|
722 | \ref{sec:freqalign}).
|
---|
723 |
|
---|
724 | \subsection{Baseline fitting}
|
---|
725 |
|
---|
726 | \index{Baseline fitting}To make a baseline fit, you must first create
|
---|
727 | a mask of channels to use in the baseline fit.
|
---|
728 |
|
---|
729 | \begin{verbatim}
|
---|
730 | ASAP> msk = scans.create_mask([100,400],[600,900])
|
---|
731 | ASAP> scans.poly_baseline(msk, 1)
|
---|
732 | \end{verbatim}
|
---|
733 |
|
---|
734 | This will fit a first order polynomial to the selected channels and subtract
|
---|
735 | this polynomial from the full spectra.
|
---|
736 |
|
---|
737 | \subsubsection{Auto-baselining}
|
---|
738 |
|
---|
739 | \index{Auto-baseline}The function \cmd{auto\_poly\_baseline} can be used to automatically
|
---|
740 | baseline your data without having to specify channel ranges for the
|
---|
741 | line free data. It automatically figures out the line-free emission
|
---|
742 | and fits a polynomial baseline to that data. The user can use masks to
|
---|
743 | fix the range of channels or velocity range for the fit as well as
|
---|
744 | mark the band edge as invalid.
|
---|
745 |
|
---|
746 | Simple example
|
---|
747 |
|
---|
748 | \begin{verbatim}
|
---|
749 | ASAP> scans.auto_poly_baseline(order=2,threshold=5)
|
---|
750 | \end{verbatim}
|
---|
751 |
|
---|
752 | \cmd{order} is the polynomial order for the fit. \cmd{threshold} is
|
---|
753 | the SNR threshold to use to deliminate line emission from
|
---|
754 | signal. Generally the value of threshold is not too critical, however
|
---|
755 | making this too large will compromise the fit (as it will include
|
---|
756 | strong line features) and making it too small will mean it cannot find
|
---|
757 | enough line free channels.
|
---|
758 |
|
---|
759 |
|
---|
760 | Other examples:
|
---|
761 |
|
---|
762 | \begin{verbatim}
|
---|
763 | # Don't try and fit the edge of the bandpass which is noisier
|
---|
764 | ASAP> scans.auto_poly_baseline(edge=(500,450),order=3,threshold=3)
|
---|
765 |
|
---|
766 | # Only fit a given region around the line
|
---|
767 | ASAP> scans.set_unit('km/s')
|
---|
768 | ASAP> msk = scans.create_mask((-60,-20))
|
---|
769 | ASAP> scans.auto_poly_baseline(mask=msk,order=3,threshold=3)
|
---|
770 |
|
---|
771 | \end{verbatim}
|
---|
772 |
|
---|
773 | \subsection{Average the polarisations}
|
---|
774 |
|
---|
775 | \index{average\_pol}If you are just interested in the highest SNR for total intensity you
|
---|
776 | will want to average the parallel polarisations together.
|
---|
777 |
|
---|
778 | \begin{verbatim}
|
---|
779 | ASAP> scans.average_pol()
|
---|
780 | \end{verbatim}
|
---|
781 |
|
---|
782 | \subsection{Calibration}
|
---|
783 |
|
---|
784 | \index{Calibration}For most uses, calibration happens transparently as the input data
|
---|
785 | contains the Tsys measurements taken during observations. The nominal
|
---|
786 | ``Tsys'' values may be in Kelvin or Jansky. The user may wish to
|
---|
787 | supply a Tsys correction or apply gain-elevation and opacity
|
---|
788 | corrections.
|
---|
789 |
|
---|
790 | \subsubsection{Brightness Units}
|
---|
791 |
|
---|
792 | \index{Brightness Units}RPFITS files do not contain any information as
|
---|
793 | to whether the telescope calibration was in units of Kelvin or
|
---|
794 | Janskys. On reading the data a default value is set depending on the
|
---|
795 | telescope and frequency of observation. If this default is incorrect
|
---|
796 | (you can see it in the listing from the \cmd{summary} function) the
|
---|
797 | user can either override this value on reading the data or later.
|
---|
798 | E.g:
|
---|
799 |
|
---|
800 | \begin{verbatim}
|
---|
801 | ASAP> scans = scantable(('2004-11-23_1841-P484.rpf', unit='Jy')
|
---|
802 | # Or in two steps
|
---|
803 | ASAP> scans = scantable(('2004-11-23_1841-P484.rpf')
|
---|
804 | ASAP> scans.set_fluxunit('Jy)
|
---|
805 | \end{verbatim}
|
---|
806 |
|
---|
807 | \subsubsection{Tsys scaling}
|
---|
808 |
|
---|
809 | \index{Tsys scaling}Sometime the nominal Tsys measurement at the
|
---|
810 | telescope is wrong due to an incorrect noise diode calibration. This
|
---|
811 | can easily be corrected for with the scale function. By default,
|
---|
812 | \cmd{scale} only scans the spectra and not the corresponding Tsys.
|
---|
813 |
|
---|
814 | \begin{verbatim}
|
---|
815 | ASAP> scans.scale(1.05, tsys=True)
|
---|
816 | \end{verbatim}
|
---|
817 |
|
---|
818 | \subsubsection{Unit Conversion}
|
---|
819 |
|
---|
820 | \index{Unit conversion}To convert measurements in Kelvin to Jy (and
|
---|
821 | vice versa) the global function \cmd{convert\_flux} is needed. This
|
---|
822 | converts and scales the data from K to Jy or vice-versa depending on
|
---|
823 | what the current brightness unit is set to. The function knows the
|
---|
824 | basic parameters for some frequencies and telescopes, but the user may
|
---|
825 | need to supply the aperture efficiency, telescope diameter or the Jy/K
|
---|
826 | factor.
|
---|
827 |
|
---|
828 | \begin{verbatim}
|
---|
829 | ASAP> scans.convert_flux() # If efficency known
|
---|
830 | ASAP> scans.convert_flux(eta=0.48) # If telescope diameter known
|
---|
831 | ASAP> scans.convert_flux(eta=0.48,d=35) # Unknown telescope
|
---|
832 | ASAP> scans.convert_flux(jypk=15) # Alternative
|
---|
833 | \end{verbatim}
|
---|
834 |
|
---|
835 | \subsubsection{Gain-Elevation and Opacity Corrections}
|
---|
836 | \label{sec:gainel}
|
---|
837 |
|
---|
838 | \index{Gain-elevation}As higher frequencies (particularly $>$20~GHz)
|
---|
839 | it is important to make corrections for atmospheric opacity and
|
---|
840 | gain-elevation effects.
|
---|
841 |
|
---|
842 | Note that currently the elevation is not written correctly into
|
---|
843 | Tidbinbilla rpfits files. This means that gain-elevation and opacity
|
---|
844 | corrections will not work unless these get recalculated.
|
---|
845 |
|
---|
846 | \begin{verbatim}
|
---|
847 | ASAP> scans.recalc_azel() # recalculate az/el based on pointing
|
---|
848 | \end{verbatim}
|
---|
849 |
|
---|
850 | Gain-elevation curves for some telescopes and frequencies are known to
|
---|
851 | ASAP (currently only for Tidbinbilla at 20~GHz). In these cases
|
---|
852 | making gain-corrections is simple. If the gain curve for your data is
|
---|
853 | not known, the user can supply either a gain polynomial or text file
|
---|
854 | tabulating gain factors at a range of elevations (see \cmd{help
|
---|
855 | scantable.gain\_el}).
|
---|
856 |
|
---|
857 | Examples:
|
---|
858 |
|
---|
859 | \begin{verbatim}
|
---|
860 | ASAP> scans.gain_el() # If gain table known
|
---|
861 | ASAP> scans.gain_el(poly=[3.58788e-1,2.87243e-2,-3.219093e-4])
|
---|
862 | \end{verbatim}
|
---|
863 |
|
---|
864 | \index{Opacity}Opacity corrections can be made with the global
|
---|
865 | function \cmd{opacity}. This should work on all telescopes as long as
|
---|
866 | a measurement of the opacity factor was made during the observation.
|
---|
867 |
|
---|
868 | \begin{verbatim}
|
---|
869 | ASAP> scans.opacity(0.083)
|
---|
870 | \end{verbatim}
|
---|
871 |
|
---|
872 | Note that at 3~mm Mopra uses a paddle wheel for Tsys calibration,
|
---|
873 | which takes opacity effects into account (to first order). ASAP
|
---|
874 | opacity corrections should not be used for Mopra 3-mm data.
|
---|
875 |
|
---|
876 | \subsection{Frequency Frame Alignment}
|
---|
877 | \label{sec:freqalign}
|
---|
878 |
|
---|
879 | \index{Frequency alignment}\index{Velicity alignment}When time
|
---|
880 | averaging a series of scans together, it is possible that the velocity
|
---|
881 | scales are not exactly aligned. This may be for many reasons such as
|
---|
882 | not Doppler tracking the observations, errors in the Doppler tracking
|
---|
883 | etc. This mostly affects very long integrations or integrations
|
---|
884 | averaged together from different days. Before averaging such data
|
---|
885 | together, they should be frequency aligned using \cmd{freq\_align}.
|
---|
886 |
|
---|
887 | E.g.:
|
---|
888 |
|
---|
889 | \begin{verbatim}
|
---|
890 | ASAP> scans.freq_align()
|
---|
891 | ASAP> av = average_time(scans)
|
---|
892 | \end{verbatim}
|
---|
893 |
|
---|
894 | {\em A Global freq\_align command will be made eventually}
|
---|
895 |
|
---|
896 | To average together data taken on different days, which are in
|
---|
897 | different scantables, each scantable must aligned to a common
|
---|
898 | reference time then the scantables averaged. The simplest way of
|
---|
899 | doing this is to allow ASAP to choose the reference time for the first
|
---|
900 | scantable then using this time for the subsequent scantables.
|
---|
901 |
|
---|
902 | \begin{verbatim}
|
---|
903 | ASAP> scans1.freq_align() # Copy the refeference Epoch from the output
|
---|
904 | ASAP> scans2.freq_align(reftime='2004/11/23/18:43:35')
|
---|
905 | ASAP> scans3.freq_align(reftime='2004/11/23/18:43:35')
|
---|
906 | ASAP> av = average_time(scans1, scans2, scans3)
|
---|
907 | \end{verbatim}
|
---|
908 |
|
---|
909 | \section{Scantable manipulation}
|
---|
910 |
|
---|
911 | \index{Scantable!manipulation}While it is very useful to have many
|
---|
912 | independent sources within one scantable, it is often inconvenient for
|
---|
913 | data processing. The \cmd{get\_scan} function can be used to create a
|
---|
914 | new scantable with a selection of scans from a scantable. The
|
---|
915 | selection can either be on the source name, with simple wildcard
|
---|
916 | matching or set of scan ids. Internally this uses the selector object,
|
---|
917 | so for more complicated selection the selector should be used directly
|
---|
918 | instead.
|
---|
919 |
|
---|
920 | For example:
|
---|
921 |
|
---|
922 | \begin{verbatim}
|
---|
923 | ASAP> ss = scans.get_scan(10) # Get the 11th scan (zero based)
|
---|
924 | ASAP> ss = scans.get_scan(range(10)) # Get the first 10 scans
|
---|
925 | ASAP> ss = scans.get_scan(range(10,20)) # Get the next 10 scans
|
---|
926 | ASAP> ss = scans.get_scan([2,4,6,8,10]) # Get a selection of scans
|
---|
927 |
|
---|
928 | ASAP> ss = scans.get_scan('345p407') # Get a specific source
|
---|
929 | ASAP> ss = scans.get_scan('345*') # Get a few sources
|
---|
930 |
|
---|
931 | ASAP> r = scans.get_scan('*_R') # Get all reference sources (Parkes/Mopra)
|
---|
932 | ASAP> s = scans.get_scan('*_S') # Get all program sources (Parkes/Mopra)
|
---|
933 | ASAP> r = scans.get_scan('*[ew]') # Get all reference sources (Tid)
|
---|
934 | ASAP> s = scans.get_scan('*[^ew]') # Get all program sources (Tid)
|
---|
935 |
|
---|
936 | \end{verbatim}
|
---|
937 |
|
---|
938 | To copy a scantable the following does not work:
|
---|
939 |
|
---|
940 | \begin{verbatim}
|
---|
941 | ASAP> ss = scans
|
---|
942 | \end{verbatim}
|
---|
943 |
|
---|
944 | as this just creates a reference to the original scantable. Any
|
---|
945 | changes made to \cmd{ss} are also seen in \cmd{scans}. To duplicate a
|
---|
946 | scantable, use the copy function.
|
---|
947 |
|
---|
948 | \begin{verbatim}
|
---|
949 | ASAP> ss = scans.copy()
|
---|
950 | \end{verbatim}
|
---|
951 |
|
---|
952 | \section{Data Output}
|
---|
953 |
|
---|
954 | \index{Scantable!save}\index{Saving data}ASAP can save scantables in a
|
---|
955 | variety of formats, suitable for reading into other packages. The
|
---|
956 | formats are:
|
---|
957 |
|
---|
958 | {\em Currently only raw ASAP output is available. Other formats will be added soon}
|
---|
959 |
|
---|
960 | \begin{itemize}
|
---|
961 | \item[ASAP] This is the internal format used for ASAP. It is the only
|
---|
962 | format that allows the user to restore the data, fits etc. without
|
---|
963 | loosing any information. As mentioned before, the ASAP scantable is
|
---|
964 | an AIPS++ Table (a memory-based table). This function just converts
|
---|
965 | it to a disk-based Table. You can the access that Table with the
|
---|
966 | AIPS++ Table browser or any other AIPS++ tool.
|
---|
967 |
|
---|
968 | \item[SDFITS] The Single Dish FITS format. This format was designed to
|
---|
969 | for interchange between packages, but few packages actually can read
|
---|
970 | it.
|
---|
971 |
|
---|
972 | \item[FITS] This uses simple ``image'' fits to save the data, each row
|
---|
973 | being written to a separate fits file. This format is suitable for
|
---|
974 | importing the data into CLASS.
|
---|
975 |
|
---|
976 | \item[ASCII] A simple text based format suitable for the user to
|
---|
977 | processing using Perl or, Python, gnuplot etc.
|
---|
978 |
|
---|
979 | \item[MS2] Saves the data in an aips++ MeasurementSet V2 format.
|
---|
980 | You can also access this with the Table browser and other AIPS++
|
---|
981 | tools.
|
---|
982 |
|
---|
983 | \end{itemize}
|
---|
984 |
|
---|
985 | The default output format can be set in the users {\tt .asaprc} file.
|
---|
986 | Typical usages are:
|
---|
987 |
|
---|
988 | \begin{verbatim}
|
---|
989 | ASAP> scans.save('myscans') # Save in default format
|
---|
990 | ASAP> scans.save('myscans', 'FITS') # Save as FITS for exporting into CLASS
|
---|
991 |
|
---|
992 | ASAP> scans.save('myscans', stokes=True) # Convert raw polarisations into Stokes
|
---|
993 | ASAP> scans.save('myscans', overwrite=True) # Overwrite an existing file
|
---|
994 | \end{verbatim}
|
---|
995 |
|
---|
996 |
|
---|
997 | \section{Plotter}
|
---|
998 |
|
---|
999 | \index{Plotter}Scantable spectra can be plotted at any time. An asapplotter object is
|
---|
1000 | used for plotting, meaning multiple plot windows can be active at the
|
---|
1001 | same time. On start up a default asapplotter object is created called
|
---|
1002 | ``plotter''. This would normally be used for standard plotting.
|
---|
1003 |
|
---|
1004 | The plotter, optionally, will run in a multipanel mode and contain
|
---|
1005 | multiple plots per panel. The user must tell the plotter how they want
|
---|
1006 | the data distributed. This is done using the set\_mode function. The
|
---|
1007 | default can be set in the users {\tt .asaprc} file. The units (and frame
|
---|
1008 | etc) of the abscissa will be whatever has previously been set by
|
---|
1009 | \cmd{set\_unit}, \cmd{set\_freqframe} etc.
|
---|
1010 |
|
---|
1011 | Typical plotter usage would be:
|
---|
1012 |
|
---|
1013 | \begin{verbatim}
|
---|
1014 | ASAP> scans.set_unit('km/s')
|
---|
1015 | ASAP> plotter.set_mode(stacking='p',panelling='t')
|
---|
1016 | ASAP> plotter.plot(scans)
|
---|
1017 | \end{verbatim}
|
---|
1018 |
|
---|
1019 | This will plot multiple polarisation within each plot panel and each
|
---|
1020 | scan row in a separate panel.
|
---|
1021 |
|
---|
1022 | Other possibilities include:
|
---|
1023 |
|
---|
1024 | \begin{verbatim}
|
---|
1025 | # Plot multiple IFs per panel
|
---|
1026 | ASAP> plotter.set_mode(stacking='i',panelling='t')
|
---|
1027 |
|
---|
1028 | # Plot multiple beams per panel
|
---|
1029 | ASAP> plotter.set_mode(stacking='b',panelling='t')
|
---|
1030 |
|
---|
1031 | # Plot one IF per panel, time stacked
|
---|
1032 | ASAP> plotter.set_mode('t', 'i')
|
---|
1033 |
|
---|
1034 | # Plot each scan in a seperate panel
|
---|
1035 | ASAP> plotter.set_mode('t', 's')
|
---|
1036 |
|
---|
1037 | \end{verbatim}
|
---|
1038 |
|
---|
1039 | \subsection{Plot Selection}
|
---|
1040 | \label{sec:plotter_cursor}
|
---|
1041 |
|
---|
1042 | \index{Plotter!selection}The plotter can plot up to 25 panels and
|
---|
1043 | stacked spectra per panel. If you have data larger than this (or for
|
---|
1044 | your own sanity) you need to select a subset of this data. This is
|
---|
1045 | particularly true for multibeam or multi IF data. The selector object
|
---|
1046 | should be used for this purpose. Selection can either be applide to
|
---|
1047 | the scantable or directly to the plotter, the end result is the same.
|
---|
1048 |
|
---|
1049 | Examples:
|
---|
1050 |
|
---|
1051 | \begin{verbatim}
|
---|
1052 | ASAP> selection = selector()
|
---|
1053 | # Select second IF
|
---|
1054 | ASAP> selection.set_ifs(1)
|
---|
1055 | ASAP> plotter.set_selection(selection)
|
---|
1056 |
|
---|
1057 | # Select first 4 beams
|
---|
1058 | ASAP> selection.set_beams([0,1,2,3])
|
---|
1059 | ASAP> plotter.set_selection(selection)
|
---|
1060 |
|
---|
1061 | # Select a few scans
|
---|
1062 | ASAP> selection.set_scans([2,4,6,10])
|
---|
1063 | ASAP> plotter.set_selection(selection)
|
---|
1064 |
|
---|
1065 | # Multiple selection
|
---|
1066 | ASAP> selection.set_ifs(1)
|
---|
1067 | ASAP> selection.set_scans([2,4,6,10])
|
---|
1068 | ASAP> plotter.set_selection(selection)
|
---|
1069 |
|
---|
1070 | \end{verbatim}
|
---|
1071 |
|
---|
1072 | \subsection{Plot Control}
|
---|
1073 |
|
---|
1074 | \index{Plotter!control}The plotter window has a row of buttons on the
|
---|
1075 | lower left. These can be used to control the plotter (mostly for
|
---|
1076 | zooming the individual plots). From left to right:
|
---|
1077 |
|
---|
1078 | \begin{itemize}
|
---|
1079 |
|
---|
1080 | \item[Home] This will unzoom the plots to the original zoom factor
|
---|
1081 |
|
---|
1082 | \item[Plot history] (left and right arrow). The plotter keeps a
|
---|
1083 | history of zoom settings. The left arrow sets the plot zoom to the
|
---|
1084 | previous value. The right arrow returns back again. This allows you,
|
---|
1085 | for example, to zoom in on one feature then return the plot to how it
|
---|
1086 | was previously.
|
---|
1087 |
|
---|
1088 | \item[Pan] (The Cross) This sets the cursor to pan, or scroll mode
|
---|
1089 | allowing you to shift the plot within the window. Useful when
|
---|
1090 | zoomed in on a feature.
|
---|
1091 |
|
---|
1092 | \item[Zoom] (the letter with the magnifying glass) lets you draw a
|
---|
1093 | rectangle around a region of interest then zooms in on that
|
---|
1094 | region. Use the plot history to unzoom again.
|
---|
1095 |
|
---|
1096 | \item[Adjust] (rectangle with 4 arrows) adjust subplot paramaters
|
---|
1097 | (space at edge of plots)
|
---|
1098 |
|
---|
1099 | \item[Save] (floppy disk). Save the plot as a postscript or .png file
|
---|
1100 |
|
---|
1101 | You can also type ``g'' in the plot window to toggle on and off grid
|
---|
1102 | lines. Typing 'l' turns on and off logarithmic Y-axis.
|
---|
1103 |
|
---|
1104 | \end{itemize}
|
---|
1105 |
|
---|
1106 | \subsection{Other control}
|
---|
1107 |
|
---|
1108 | The plotter has a number of functions to describe the layout of the
|
---|
1109 | plot. These include \cmd{set\_legend}, \cmd{set\_layout} and \cmd{set\_title}.
|
---|
1110 |
|
---|
1111 | To set the exact velocity or channel range to be plotted use the
|
---|
1112 | \cmd{set\_range} function. To reset to the default value, call
|
---|
1113 | \cmd{set\_range} with no arguments. E.g.
|
---|
1114 |
|
---|
1115 | \begin{verbatim}
|
---|
1116 | ASAP> scans.set_unit('km/s')
|
---|
1117 | ASAP> plotter.plot(scans)
|
---|
1118 | ASAP> plotter.set_range(-150,-50)
|
---|
1119 | ASAP> plotter.set_range() # To reset
|
---|
1120 | \end{verbatim}
|
---|
1121 |
|
---|
1122 | Both the range of the ``x'' and ``y'' axis can be set at once, if desired:
|
---|
1123 |
|
---|
1124 | \begin{verbatim}
|
---|
1125 | ASAP> plotter.set_range(-10,30,-1,6.6)
|
---|
1126 | \end{verbatim}
|
---|
1127 |
|
---|
1128 | To save a hardcopy of the current plot, use the save function, e.g.
|
---|
1129 |
|
---|
1130 | \begin{verbatim}
|
---|
1131 | ASAP> plotter.save('myplot.ps')
|
---|
1132 | \end{verbatim}
|
---|
1133 |
|
---|
1134 | \section{Fitting}
|
---|
1135 |
|
---|
1136 | \index{Fitting}Currently multicomponent Gaussian function is
|
---|
1137 | available. This is done by creating a fitting object, setting up the
|
---|
1138 | fit and actually fitting the data. Fitting can either be done on a
|
---|
1139 | single scantable selection or on an entire scantable using the
|
---|
1140 | \cmd{auto\_fit} function. If single value fitting is used, and the
|
---|
1141 | current selection includes multiple spectra (beams, IFs, scans etc)
|
---|
1142 | then the first spectra in the scantable will be used for fitting.
|
---|
1143 |
|
---|
1144 | \begin{verbatim}
|
---|
1145 | ASAP> f = fitter()
|
---|
1146 | ASAP> f.set_function(gauss=2) # Fit two Gaussians
|
---|
1147 | ASAP> f.set_scan(scans)
|
---|
1148 | ASAP> selection = selector()
|
---|
1149 | ASAP> selection.set_polarisation(1) # Fit the second polarisation
|
---|
1150 | ASAP> scans.set_selection(selection)
|
---|
1151 | ASAP> scans.set_unit('km/s') # Make fit in velocity units
|
---|
1152 | ASAP> f.fit(1) # Run the fit on the second row in the table
|
---|
1153 | ASAP> f.plot() # Show fit in a plot window
|
---|
1154 | ASAP> f.get_parameters() # Return the fit paramaters
|
---|
1155 | \end{verbatim}
|
---|
1156 |
|
---|
1157 | This auto-guesses the initial values of the fit and works well for data
|
---|
1158 | without extra confusing features. Note that the fit is performed in
|
---|
1159 | whatever unit the abscissa is set to.
|
---|
1160 |
|
---|
1161 | If you want to confine the fitting to a smaller range (e.g. to avoid
|
---|
1162 | band edge effects or RFI you must set a mask.
|
---|
1163 |
|
---|
1164 | \begin{verbatim}
|
---|
1165 | ASAP> f = fitter()
|
---|
1166 | ASAP> f.set_function(gauss=2)
|
---|
1167 | ASAP> scans.set_unit('km/s') # Set the mask in channel units
|
---|
1168 | ASAP> msk = s.create_mask([1800,2200])
|
---|
1169 | ASAP> scans.set_unit('km/s') # Make fit in velocity units
|
---|
1170 | ASAP> f.set_scan(s,msk)
|
---|
1171 | ASAP> f.fit()
|
---|
1172 | ASAP> f.plot()
|
---|
1173 | ASAP> f.get_parameters()
|
---|
1174 | \end{verbatim}
|
---|
1175 |
|
---|
1176 | If you wish, the initial parameter guesses can be specified and
|
---|
1177 | specific parameters can be fixed:
|
---|
1178 |
|
---|
1179 | \begin{verbatim}
|
---|
1180 | ASAP> f = fitter()
|
---|
1181 | ASAP> f.set_function(gauss=2)
|
---|
1182 | ASAP> f.set_scan(s,msk)
|
---|
1183 | ASAP> f.fit() # Fit using auto-estimates
|
---|
1184 | # Set Peak, centre and fwhm for the second gaussian.
|
---|
1185 | # Force the centre to be fixed
|
---|
1186 | ASAP> f.set_gauss_parameters(0.4,450,150,0,1,0,component=1)
|
---|
1187 | ASAP> f.fit() # Re-run the fit
|
---|
1188 | \end{verbatim}
|
---|
1189 |
|
---|
1190 | The fitter \cmd{plot} function has a number of options to either view
|
---|
1191 | the fit residuals or the individual components (by default it plots
|
---|
1192 | the sum of the model components).
|
---|
1193 |
|
---|
1194 | Examples:
|
---|
1195 |
|
---|
1196 | \begin{verbatim}
|
---|
1197 | # Plot the residual
|
---|
1198 | ASAP> f.plot(residual=True)
|
---|
1199 |
|
---|
1200 | # Plot the first 2 componentsa
|
---|
1201 | ASAP> f.plot(components=[0,1])
|
---|
1202 |
|
---|
1203 | # Plot the first and third component plus the model sum
|
---|
1204 | ASAP> f.plot(components=[-1,0,2]) # -1 means the compoment sum
|
---|
1205 | \end{verbatim}
|
---|
1206 |
|
---|
1207 | \subsection{Fit saving}
|
---|
1208 |
|
---|
1209 | \index{Fitter!Fit saving}One you are happy with your fit, it is
|
---|
1210 | possible to store it as part of the scantable.
|
---|
1211 |
|
---|
1212 | \begin{verbatim}
|
---|
1213 | ASAP> f.storefit()
|
---|
1214 | \end{verbatim}
|
---|
1215 |
|
---|
1216 | This will be saved to disk with the data, if the ``ASAP'' file format
|
---|
1217 | is selected. Multiple fits to the same data can be stored in the
|
---|
1218 | scantable.
|
---|
1219 |
|
---|
1220 | The scantable function \cmd{get\_fit} can be used to retrieve the
|
---|
1221 | stored fits. Currently the fit parameters are just printed to the
|
---|
1222 | screen.
|
---|
1223 |
|
---|
1224 | \begin{verbatim}
|
---|
1225 | ASAP> scans.get_fit(4) # Print fits for row 4
|
---|
1226 | \end{verbatim}
|
---|
1227 |
|
---|
1228 | \section{Polarisation}
|
---|
1229 |
|
---|
1230 | \index{Polarisation}Currently ASAP only supports polarmetric analysis
|
---|
1231 | on linearly polarised feeds and the cross polarisation products
|
---|
1232 | measured. Other cases will be added on an as needed basic.
|
---|
1233 |
|
---|
1234 | Conversions of linears to Stokes or Circular polarisations are done
|
---|
1235 | ``on-the-fly''. Leakage cannot be corrected for nor are there routines
|
---|
1236 | to calibrate position angle offsets.
|
---|
1237 |
|
---|
1238 | \subsection{Simple Calibration}
|
---|
1239 |
|
---|
1240 | \index{Polarisation!calibration}It is possible that there is a phase
|
---|
1241 | offset between polarisation which will effect the phase of the cross
|
---|
1242 | polarisation correlation, and so give rise to spurious
|
---|
1243 | polarisation. \cmd{rotate\_xyphase} can be used to correct for this
|
---|
1244 | error. At this point, the user must know how to determine the size of
|
---|
1245 | the phase offset themselves.
|
---|
1246 |
|
---|
1247 | \begin{verbatim}
|
---|
1248 | ASAP> scans.rotate_xyphase(10.5) # Degrees
|
---|
1249 | \end{verbatim}
|
---|
1250 |
|
---|
1251 | Note that if this function is run twice, the sum of the two values is
|
---|
1252 | applied because it is done in-situ.
|
---|
1253 |
|
---|
1254 | A correction for the receiver parallactic angle may need to be made,
|
---|
1255 | generally because of how it is mounted. Use \cmd{rotate\_linpolphase}
|
---|
1256 | to correct the position angle. Running this function twice results in
|
---|
1257 | the sum of the corrections being applied because it is applied
|
---|
1258 | in-situ.
|
---|
1259 |
|
---|
1260 | \begin{verbatim}
|
---|
1261 | ASAP> scans.rotate_linpolphase(-45) # Degrees; correct for receiver mounting
|
---|
1262 | \end{verbatim}
|
---|
1263 |
|
---|
1264 | If the sign of the complex correlation is wrong (this can happen
|
---|
1265 | depending on the correlator configuration), use \cmd{invert\_phase} to
|
---|
1266 | change take the complex conjugate of the complex correlation
|
---|
1267 | term. This is always performed in-situ.
|
---|
1268 |
|
---|
1269 | \begin{verbatim}
|
---|
1270 | ASAP> scans.invert_phase()
|
---|
1271 | \end{verbatim}
|
---|
1272 |
|
---|
1273 | Depending on how the correlator is configured, ``BA'' may be
|
---|
1274 | correlated insead of ``AB''. Use \cmd{swap\_linears} to correct for
|
---|
1275 | this problem:
|
---|
1276 |
|
---|
1277 | \begin{verbatim}
|
---|
1278 | ASAP> scans.swap_linears()
|
---|
1279 | \end{verbatim}
|
---|
1280 |
|
---|
1281 | \subsection{Plotting}
|
---|
1282 | \label{sec:polplot}
|
---|
1283 |
|
---|
1284 | \index{Polarisation!plotting}To plot Stokes values, a selector object
|
---|
1285 | must be created and the set\_polarisation function used to select the
|
---|
1286 | desired polarisation products.
|
---|
1287 |
|
---|
1288 | The values which can be plotted include a selection of [I,Q,U,V], [I,
|
---|
1289 | Plinear, Pangle, V], [RR, LL] or [XX, YY, Real(XY),
|
---|
1290 | Imaginary(XY)]. (Plinear and Pangle are the percentage and position
|
---|
1291 | angle of linear polarisation). Conversion to circular polarisations
|
---|
1292 | are currently not available.
|
---|
1293 |
|
---|
1294 | Example:
|
---|
1295 |
|
---|
1296 | \begin{verbatim}
|
---|
1297 | ASAP> selection = selector()
|
---|
1298 |
|
---|
1299 | ASAP> selection.set_polarisations([``I Q U V''])
|
---|
1300 | ASAP plotter.set_selection(selection); # Select I, Q, U \& V
|
---|
1301 |
|
---|
1302 | ASAP> selection.set_polarisations([``I Q'')
|
---|
1303 | ASAP plotter.set_selection(selection); # Select just I \& Q
|
---|
1304 |
|
---|
1305 | ASAP> selection.set_polarisations([``RR LL'')
|
---|
1306 | ASAP plotter.set_selection(selection); # Select just RR \& LL
|
---|
1307 |
|
---|
1308 | ASAP> selection.set_polarisations([``XX YY'')
|
---|
1309 | ASAP plotter.set_selection(selection); # Select linears
|
---|
1310 |
|
---|
1311 | ASAP> selection.set_polarisations([``I Plinear'')
|
---|
1312 | ASAP plotter.set_selection(selection); # Fractional linear
|
---|
1313 |
|
---|
1314 | [[MALTE: This does not work]]
|
---|
1315 |
|
---|
1316 | ASAP> selection.set_polarisations([``Pangle'')
|
---|
1317 | ASAP plotter.set_selection(selection); # Position angle
|
---|
1318 |
|
---|
1319 | \end{verbatim}
|
---|
1320 |
|
---|
1321 | Scan, beam and IF selection are also available in the selector object as
|
---|
1322 | describe in section~\ref{sec:selection}.
|
---|
1323 |
|
---|
1324 | \subsection{Saving}
|
---|
1325 |
|
---|
1326 | \index{Polarisation!saving}When saving data using the \cmd{save}
|
---|
1327 | function, the \cmd{stokes} argument can be used to save the data as
|
---|
1328 | Stoke values when saving in FITS format.
|
---|
1329 |
|
---|
1330 | Example:
|
---|
1331 |
|
---|
1332 | \begin{verbatim}
|
---|
1333 | ASAP> scans.save('myscan.sdfits', 'SDFITS', stokes=True)
|
---|
1334 | \end{verbatim}
|
---|
1335 |
|
---|
1336 | \section{Scantable Mathematics}
|
---|
1337 |
|
---|
1338 | \index{Scantable!maths}It is possible to to simple mathematics
|
---|
1339 | directly on scantables from the command line using the \cmd{+, -, *,
|
---|
1340 | /} operators as well as their cousins \cmd{+=, -= *=, /=}. This works
|
---|
1341 | between two scantables or a scantable and a float. (Note that it does
|
---|
1342 | not work for integers).
|
---|
1343 |
|
---|
1344 | {\em Currently mathematics between two scan tables is not available }
|
---|
1345 |
|
---|
1346 | \begin{verbatim}
|
---|
1347 | % ASAP> sum = scan1+scan2
|
---|
1348 | ASAP> scan2 = scan1+2.0
|
---|
1349 | ASAP> scan *= 1.05
|
---|
1350 | \end{verbatim}
|
---|
1351 |
|
---|
1352 | \section{Scripting}
|
---|
1353 |
|
---|
1354 | \index{Scripting}Because asap is based on python, it easy for the user
|
---|
1355 | write their own scripts and functions to process data. This is highly
|
---|
1356 | recommended as most processing of user data could then be done in a
|
---|
1357 | couple of steps using a few simple user defined functions. A Python
|
---|
1358 | primer is beyond the scope of this userguide. See the asap home pages
|
---|
1359 | for a scripting tutorial or the main python website for comprehensive
|
---|
1360 | documentation.
|
---|
1361 |
|
---|
1362 | \hspace{1cm} http://www.atnf.csiro.au/computing/software/asap/tutorials
|
---|
1363 |
|
---|
1364 | \hspace{1cm} http://www.python.org/doc/Introduction.html
|
---|
1365 |
|
---|
1366 | \subsection{Running scripts}
|
---|
1367 |
|
---|
1368 | The asap global function \cmd{execfile} reads the named text file and
|
---|
1369 | executes the contained python code. This file can either contain
|
---|
1370 | function definitions which will be used in subsequent processing or
|
---|
1371 | just a set of commands to process a specific dataset.
|
---|
1372 |
|
---|
1373 | \subsection{asapuserfuncs.py}
|
---|
1374 |
|
---|
1375 | The file $\sim$/.asap/asapuserfuncs.py is automatically read in when
|
---|
1376 | asap is started. The user can use this to define a set of user
|
---|
1377 | functions which are automatically available each time asap is
|
---|
1378 | used. The \cmd{execfile} function can be called from within this file.
|
---|
1379 |
|
---|
1380 | \section{Worked examples}
|
---|
1381 |
|
---|
1382 | In the following section a few examples of end-to-end processing of
|
---|
1383 | some data in asap are given.
|
---|
1384 |
|
---|
1385 | \subsection{Mopra}
|
---|
1386 | \index{Mopra}
|
---|
1387 |
|
---|
1388 | The following example is of some dual polarisation, position switched
|
---|
1389 | data from Mopra. The source has been observed mulitple times split
|
---|
1390 | into a number of seperate rpfits files. To make the processing easier,
|
---|
1391 | the first step is to \cmd{cat} the seeprate rpfits files together and
|
---|
1392 | load as a whole (future versions of asap will make this unnecessary).
|
---|
1393 |
|
---|
1394 |
|
---|
1395 | \begin{verbatim}
|
---|
1396 | # Concatenate the individual rpfits files together before loading
|
---|
1397 | !cat 2005-06*.rpf > data.rpf
|
---|
1398 |
|
---|
1399 | # Load the data into a scantable
|
---|
1400 | data = scantable('data.rpf')
|
---|
1401 | print data
|
---|
1402 |
|
---|
1403 | # Form the quotient spectra
|
---|
1404 | q = data.auto_quotient()
|
---|
1405 | print q
|
---|
1406 |
|
---|
1407 | # Look at the spectra
|
---|
1408 | plotter.plot(q)
|
---|
1409 |
|
---|
1410 | # Set reference frame
|
---|
1411 | q.set_unit('km/s')
|
---|
1412 | q.set_freqframe('LSRK')
|
---|
1413 |
|
---|
1414 | # Average all scans in time, aligning in velocity
|
---|
1415 | av = q.average_time(align=True)
|
---|
1416 | plotter.plot(av)
|
---|
1417 |
|
---|
1418 | # Remove the baseline
|
---|
1419 | msk = av.create_mask([100,130],[160,200])
|
---|
1420 | av.poly_baseline(msk,2)
|
---|
1421 |
|
---|
1422 | # Average the two polarisations together
|
---|
1423 | iav = av.average_pol()
|
---|
1424 | print iav
|
---|
1425 | plotter.plot(iav)
|
---|
1426 |
|
---|
1427 | # Set a sensible velocity range on the plot
|
---|
1428 | plotter.set_range(85,200)
|
---|
1429 |
|
---|
1430 | # Smooth the data a little
|
---|
1431 | av.smooth('gauss',4)
|
---|
1432 | plotter.plot()
|
---|
1433 |
|
---|
1434 | # Fit a guassian to the emission
|
---|
1435 | f = fitter()
|
---|
1436 | f.set_function(gauss=1)
|
---|
1437 | f.set_scan(av)
|
---|
1438 | f.fit()
|
---|
1439 |
|
---|
1440 | # View the fit
|
---|
1441 | f.plot()
|
---|
1442 |
|
---|
1443 | # Get the fit parameters
|
---|
1444 | f.get_parameters()
|
---|
1445 |
|
---|
1446 | \end{verbatim}
|
---|
1447 |
|
---|
1448 |
|
---|
1449 | \subsection{Parkes Polarimetry}
|
---|
1450 |
|
---|
1451 | \index{Parkes}\index{Polarisation}The following example is processing
|
---|
1452 | of some Parkes polarmetric observations of OH masers at
|
---|
1453 | 1.6~GHz. Because digital filters where used in the backend, the
|
---|
1454 | baselines are stable enough not to require a quotient spectra. The
|
---|
1455 | 4~MHz bandwidth is wide enough to observe both the 1665 and 1667~MHz
|
---|
1456 | OH maser transitions. Each source was observed once for about 10
|
---|
1457 | minutes. Tsys information was not written to the rpfits file (a
|
---|
1458 | nominal 25K values was used), so the amplitudes need to be adjusted
|
---|
1459 | based on a separate log file. A simple user function is used to
|
---|
1460 | simplify this, contained in a file called mypol.py:
|
---|
1461 |
|
---|
1462 | \begin{verbatim}
|
---|
1463 | def xyscale(data,xtsys=1.0,ytsys=1.0,nomtsys=25.0) :
|
---|
1464 |
|
---|
1465 | selection = selector()
|
---|
1466 | selection.set_polarisation(0)
|
---|
1467 | data.set_selection(selection)
|
---|
1468 | data.scale(xtsys/nomtsys)
|
---|
1469 |
|
---|
1470 | selection.set_polarisation(1)
|
---|
1471 | data.set_selection(selection)
|
---|
1472 | data.scale(ytsys/nomtsys)
|
---|
1473 |
|
---|
1474 | selection.set_polarisation(0)
|
---|
1475 | data.set_selection(selection)
|
---|
1476 | data.scale((xtsys+ytsys)/(2*nomtsys))
|
---|
1477 |
|
---|
1478 | selection.set_polarisation(0)
|
---|
1479 | data.set_selection(selection)
|
---|
1480 | data.scale((xtsys+ytsys)/(2*nomtsys))
|
---|
1481 | \end{verbatim}
|
---|
1482 |
|
---|
1483 | The typical asap session would be
|
---|
1484 |
|
---|
1485 | \begin{verbatim}
|
---|
1486 |
|
---|
1487 | # Remind ourself the name of the rpfits files
|
---|
1488 | ls
|
---|
1489 |
|
---|
1490 | # Load data from an rpfits file
|
---|
1491 | d1665 = scantable('2005-10-27_0154-P484.rpf')
|
---|
1492 |
|
---|
1493 | # Check what we have just loaded
|
---|
1494 | d1665.summary
|
---|
1495 |
|
---|
1496 | # View the data in velocity
|
---|
1497 | d1665.set_unit('km/s')
|
---|
1498 | d1665.set_freqframe('LSRK')
|
---|
1499 |
|
---|
1500 | # Correct for the known phase offset in the crosspol data
|
---|
1501 | d1665.rotate_xyphase(-4)
|
---|
1502 |
|
---|
1503 | # Create a copy of the data and set the rest frequency to the 1667 MHz
|
---|
1504 | # transition
|
---|
1505 | d1667 = d1665.copy()
|
---|
1506 | d1667.set_restfreqs([1667.3590], 'MHz')
|
---|
1507 | d1667.summary()
|
---|
1508 |
|
---|
1509 | # Copy out the scan we wish to process
|
---|
1510 | g351_5 = d1665.get_scan('351p160')
|
---|
1511 | g351_7 = d1667.get_scan('351p160')
|
---|
1512 |
|
---|
1513 | # Baseline both
|
---|
1514 | msk = g351_5.create_mask([-30,-25],[-5,0])
|
---|
1515 | g351_5.poly_baseline(msk,order=1)
|
---|
1516 | msk = g351_7.create_mask([-30,-25],[-5,0])
|
---|
1517 | g351_7.poly_baseline(msk,order=1)
|
---|
1518 |
|
---|
1519 |
|
---|
1520 | # Plot the data. The plotter can only plot a single scantable
|
---|
1521 | # So we must merge the two tables first
|
---|
1522 |
|
---|
1523 | plotscans = merge(g351_5, g351_7)
|
---|
1524 |
|
---|
1525 | plotter.plot(plotscans) # Only shows one panel
|
---|
1526 |
|
---|
1527 | # Tell the plotter to stack polarisation and panel scans
|
---|
1528 | plotter.set_mode('p','s')
|
---|
1529 |
|
---|
1530 | # Correct for the Tsys using our predefined function
|
---|
1531 | execfile('mypol.py') # Read in the function
|
---|
1532 | xyscale(g351_5,23.2,22.7) # Execute it on the data
|
---|
1533 | xyscale(g351_7,23.2,22.7)
|
---|
1534 |
|
---|
1535 | # Only plot the velocity range of interest
|
---|
1536 | plotter.set_range(-30,10)
|
---|
1537 |
|
---|
1538 | # Update the plot with the baselined data
|
---|
1539 | plotter.plot()
|
---|
1540 |
|
---|
1541 | # Look at the various polarisation products
|
---|
1542 | selection = selector()
|
---|
1543 | selection.set_polarisations(``RR LL'')
|
---|
1544 | plotter.set_selection(selection)
|
---|
1545 | selection.set_polarisations(``I Plinear'')
|
---|
1546 | plotter.set_selection(selection)
|
---|
1547 | selection.set_polarisations(``I Q U V'')
|
---|
1548 | plotter.set_selection(selection)
|
---|
1549 |
|
---|
1550 | # Save the plot as postscript
|
---|
1551 | plotter.save('g351_stokes.ps')
|
---|
1552 |
|
---|
1553 | # Save the process spectra
|
---|
1554 | plotscans.save('g351.asap')
|
---|
1555 |
|
---|
1556 | \end{verbatim}
|
---|
1557 |
|
---|
1558 | \subsection{Tidbinbilla}
|
---|
1559 |
|
---|
1560 | \index{Tidbinbilla}The following example is processing of some
|
---|
1561 | Tidbinbilla observations of NH$_3$ at 12~mm. Tidbinbilla has (at the
|
---|
1562 | time of observations) a single polarisation, but can process two IFs
|
---|
1563 | simultaneously. In the example, the first half of the observation was
|
---|
1564 | observing the (1,1) and (2,2) transitions simultaneously). The second
|
---|
1565 | half observed only the (4,4) transition due to bandwidth
|
---|
1566 | limitations. The data is position switched, observing first an
|
---|
1567 | reference to the west, then the source twice and finally reference to
|
---|
1568 | the east.
|
---|
1569 |
|
---|
1570 | \begin{verbatim}
|
---|
1571 |
|
---|
1572 | # Load the rpfits file and inspect
|
---|
1573 | d = scantable('2003-03-16_082048_t0002.rpf')
|
---|
1574 | print d
|
---|
1575 |
|
---|
1576 | # Make the quotient spectra
|
---|
1577 | q = d.auto_quotient()
|
---|
1578 | print q
|
---|
1579 |
|
---|
1580 | del d
|
---|
1581 |
|
---|
1582 | # Plot/select in velocity
|
---|
1583 | q.set_freqframe('LSRK')
|
---|
1584 | q.set_unit('km/s')
|
---|
1585 |
|
---|
1586 | # Correct for gain/el effects
|
---|
1587 |
|
---|
1588 | q.recalc_azel() # Tid does not write the elevation
|
---|
1589 | q.gain_el()
|
---|
1590 | q.opacity(0.05)
|
---|
1591 |
|
---|
1592 | # Seperate data from the (1,1)&(2,2) and (4,4) transitions
|
---|
1593 | g1 = q.get_scan(range(6)) # Rows 0..5
|
---|
1594 | g2 = q.get_scan(range(6,12)) # Rows 6..11
|
---|
1595 |
|
---|
1596 | # Align data in velocity
|
---|
1597 | g1.freq_align()
|
---|
1598 | g2.freq_align()
|
---|
1599 |
|
---|
1600 | # Average individual scans
|
---|
1601 | a1 = g1.average_time()
|
---|
1602 | a2 = g2.average_time()
|
---|
1603 |
|
---|
1604 | # Rpfits file only contrains a single rest frequency. Set both
|
---|
1605 | a1.set_restfreqs([23694.4700e6,23722.6336e6])
|
---|
1606 |
|
---|
1607 | plotter.plot(a1)
|
---|
1608 | plotter.set_mode('i','s')
|
---|
1609 |
|
---|
1610 | a1.auto_poly_baseline()
|
---|
1611 |
|
---|
1612 | plotter.plot()
|
---|
1613 |
|
---|
1614 | a1.smooth('gauss',5)
|
---|
1615 | plotter.plot()
|
---|
1616 |
|
---|
1617 |
|
---|
1618 | \end{verbatim}
|
---|
1619 |
|
---|
1620 | \newpage
|
---|
1621 |
|
---|
1622 | \section{Appendix}
|
---|
1623 |
|
---|
1624 | \subsection{Function Summary}
|
---|
1625 |
|
---|
1626 | \index{Functions!summary}%
|
---|
1627 | \begin{verbatim}
|
---|
1628 | [The scan container]
|
---|
1629 | scantable - a container for integrations/scans
|
---|
1630 | (can open asap/rpfits/sdfits and ms files)
|
---|
1631 | copy - returns a copy of a scan
|
---|
1632 | get_scan - gets a specific scan out of a scantable
|
---|
1633 | summary - print info about the scantable contents
|
---|
1634 | set_cursor - set a specific Beam/IF/Pol 'cursor' for
|
---|
1635 | further use
|
---|
1636 | get_cursor - print out the current cursor position
|
---|
1637 | stats - get specified statistic of the spectra in
|
---|
1638 | the scantable
|
---|
1639 | stddev - get the standard deviation of the spectra
|
---|
1640 | in the scantable
|
---|
1641 | get_tsys - get the TSys
|
---|
1642 | get_time - get the timestamps of the integrations
|
---|
1643 | get_azimuth - get the azimuth of the scans
|
---|
1644 | get_elevation - get the elevation of the scans
|
---|
1645 | get_parangle - get the parallactic angle of the scans
|
---|
1646 | get_unit - get the currnt unit
|
---|
1647 | set_unit - set the abcissa unit to be used from this
|
---|
1648 | point on
|
---|
1649 | get_abcissa - get the abcissa values and name for a given
|
---|
1650 | row (time)
|
---|
1651 | set_freqframe - set the frame info for the Spectral Axis
|
---|
1652 | (e.g. 'LSRK')
|
---|
1653 | set_doppler - set the doppler to be used from this point on
|
---|
1654 | set_instrument - set the instrument name
|
---|
1655 | get_fluxunit - get the brightness flux unit
|
---|
1656 | set_fluxunit - set the brightness flux unit
|
---|
1657 | create_mask - return an mask in the current unit
|
---|
1658 | for the given region. The specified regions
|
---|
1659 | are NOT masked
|
---|
1660 | get_restfreqs - get the current list of rest frequencies
|
---|
1661 | set_restfreqs - set a list of rest frequencies
|
---|
1662 | lines - print list of known spectral lines
|
---|
1663 | flag_spectrum - flag a whole Beam/IF/Pol
|
---|
1664 | save - save the scantable to disk as either 'ASAP'
|
---|
1665 | or 'SDFITS'
|
---|
1666 | nbeam,nif,nchan,npol - the number of beams/IFs/Pols/Chans
|
---|
1667 | history - print the history of the scantable
|
---|
1668 | get_fit - get a fit which has been stored witnh the data
|
---|
1669 | average_time - return the (weighted) time average of a scan
|
---|
1670 | or a list of scans
|
---|
1671 | average_pol - average the polarisations together.
|
---|
1672 | The dimension won't be reduced and
|
---|
1673 | all polarisations will contain the
|
---|
1674 | averaged spectrum.
|
---|
1675 | auto_quotient - return the on/off quotient with
|
---|
1676 | automatic detection of the on/off scans
|
---|
1677 | quotient - return the on/off quotient
|
---|
1678 | scale - return a scan scaled by a given factor
|
---|
1679 | add - return a scan with given value added
|
---|
1680 | bin - return a scan with binned channels
|
---|
1681 | resample - return a scan with resampled channels
|
---|
1682 | smooth - return the spectrally smoothed scan
|
---|
1683 | poly_baseline - fit a polynomial baseline to all Beams/IFs/Pols
|
---|
1684 | auto_poly_baseline - automatically fit a polynomial baseline
|
---|
1685 | recalc_azel - recalculate azimuth and elevation based on
|
---|
1686 | the pointing
|
---|
1687 | gain_el - apply gain-elevation correction
|
---|
1688 | opacity - apply opacity correction
|
---|
1689 | convert_flux - convert to and from Jy and Kelvin brightness
|
---|
1690 | units
|
---|
1691 | freq_align - align spectra in frequency frame
|
---|
1692 | rotate_xyphase - rotate XY phase of cross correlation
|
---|
1693 | rotate_linpolphase - rotate the phase of the complex
|
---|
1694 | polarization O=Q+iU correlation
|
---|
1695 | [Math] Mainly functions which operate on more than one scantable
|
---|
1696 |
|
---|
1697 | average_time - return the (weighted) time average
|
---|
1698 | of a list of scans
|
---|
1699 | quotient - return the on/off quotient
|
---|
1700 | simple_math - simple mathematical operations on two scantables,
|
---|
1701 | 'add', 'sub', 'mul', 'div'
|
---|
1702 | [Fitting]
|
---|
1703 | fitter
|
---|
1704 | auto_fit - return a scan where the function is
|
---|
1705 | applied to all Beams/IFs/Pols.
|
---|
1706 | commit - return a new scan where the fits have been
|
---|
1707 | commited.
|
---|
1708 | fit - execute the actual fitting process
|
---|
1709 | store_fit - store the fit paramaters in the data (scantable)
|
---|
1710 | get_chi2 - get the Chi^2
|
---|
1711 | set_scan - set the scantable to be fit
|
---|
1712 | set_function - set the fitting function
|
---|
1713 | set_parameters - set the parameters for the function(s), and
|
---|
1714 | set if they should be held fixed during fitting
|
---|
1715 | set_gauss_parameters - same as above but specialised for individual
|
---|
1716 | gaussian components
|
---|
1717 | get_parameters - get the fitted parameters
|
---|
1718 | plot - plot the resulting fit and/or components and
|
---|
1719 | residual
|
---|
1720 | [Plotter]
|
---|
1721 | asapplotter - a plotter for asap, default plotter is
|
---|
1722 | called 'plotter'
|
---|
1723 | plot - plot a (list of) scantable
|
---|
1724 | save - save the plot to a file ('png' ,'ps' or 'eps')
|
---|
1725 | set_mode - set the state of the plotter, i.e.
|
---|
1726 | what is to be plotted 'colour stacked'
|
---|
1727 | and what 'panelled'
|
---|
1728 | set_cursor - only plot a selected part of the data
|
---|
1729 | set_range - set a 'zoom' window
|
---|
1730 | set_legend - specify user labels for the legend indeces
|
---|
1731 | set_title - specify user labels for the panel indeces
|
---|
1732 | set_ordinate - specify a user label for the ordinate
|
---|
1733 | set_abcissa - specify a user label for the abcissa
|
---|
1734 | set_layout - specify the multi-panel layout (rows,cols)
|
---|
1735 |
|
---|
1736 | [Reading files]
|
---|
1737 | reader - access rpfits/sdfits files
|
---|
1738 | read - read in integrations
|
---|
1739 | summary - list info about all integrations
|
---|
1740 |
|
---|
1741 | [General]
|
---|
1742 | commands - this command
|
---|
1743 | print - print details about a variable
|
---|
1744 | list_scans - list all scantables created bt the user
|
---|
1745 | del - delete the given variable from memory
|
---|
1746 | range - create a list of values, e.g.
|
---|
1747 | range(3) = [0,1,2], range(2,5) = [2,3,4]
|
---|
1748 | help - print help for one of the listed functions
|
---|
1749 | execfile - execute an asap script, e.g. execfile('myscript')
|
---|
1750 | list_rcparameters - print out a list of possible values to be
|
---|
1751 | put into \$HOME/.asaprc
|
---|
1752 | mask_and,mask_or,
|
---|
1753 | mask_not - boolean operations on masks created with
|
---|
1754 | scantable.create_mask
|
---|
1755 |
|
---|
1756 | Note:
|
---|
1757 | How to use this with help:
|
---|
1758 | # function 'summary'
|
---|
1759 | [xxx] is just a category
|
---|
1760 | Every 'sub-level' in this list should be replaces by a '.' Period when
|
---|
1761 | using help
|
---|
1762 | Example:
|
---|
1763 | ASAP> help scantable # to get info on ths scantable
|
---|
1764 | ASAP> help scantable.summary # to get help on the scantable's
|
---|
1765 | ASAP> help average_time
|
---|
1766 |
|
---|
1767 | \end{verbatim}
|
---|
1768 |
|
---|
1769 | \subsection{ASCII output format}
|
---|
1770 |
|
---|
1771 | \subsection{.asaprc settings}
|
---|
1772 | \index{.asaprc}
|
---|
1773 | \asaprc{verbose}{{\bf True}/False}{Print verbose output}
|
---|
1774 |
|
---|
1775 | \asaprc{insitu}{{\bf True}/False}{Apply operations on the input
|
---|
1776 | scantable or return new one}
|
---|
1777 |
|
---|
1778 | % plotting
|
---|
1779 |
|
---|
1780 | \asaprc{useplotter}{{\bf True}/False}{Preload a default plotter}
|
---|
1781 |
|
---|
1782 | \asaprc{plotter.gui}{{\bf True}/False}{Do we want a GUI or plot to a
|
---|
1783 | file}
|
---|
1784 |
|
---|
1785 | \asaprc{plotter.stacking}{{\bf Pol} Beam IF Scan Time}{Default mode for
|
---|
1786 | colour stacking}
|
---|
1787 |
|
---|
1788 | \asaprc{plotter.panelling}{Pol Beam IF {\bf Scan} Time}{Default mode
|
---|
1789 | for panelling}
|
---|
1790 |
|
---|
1791 | \asaprc{plotter.ganged}{{\bf True}/False}{Push panels together, to
|
---|
1792 | share axislabels}
|
---|
1793 |
|
---|
1794 | \asaprc{plotter.decimate}{True/{\bf False}}{Decimate the number of
|
---|
1795 | points plotted by a factor of nchan/1024}
|
---|
1796 |
|
---|
1797 | % default colours/linestyles
|
---|
1798 | %\asaprc{plotter.colours}{.}{.}
|
---|
1799 | %\asaprc{plotter.linestyles{.}{.}
|
---|
1800 |
|
---|
1801 | % scantable
|
---|
1802 | \asaprc{scantable.save}{{\bf ASAP} SDFITS FITS ASCII MS2}{Default output
|
---|
1803 | format when saving}
|
---|
1804 |
|
---|
1805 | \asaprc{scantable.autoaverage}{{\bf True}/False}{Auto averaging on
|
---|
1806 | read}
|
---|
1807 |
|
---|
1808 | \asaprc{scantable.freqframe}{{\bf LSRK} TOPO BARY etc}{default
|
---|
1809 | frequency frame to set when function scantable.set\_freqframe is
|
---|
1810 | called}
|
---|
1811 |
|
---|
1812 | \asaprc{scantable.plotter}{{\bf True}/False}{Use internal plotter}
|
---|
1813 |
|
---|
1814 | \asaprc{scantable.verbosesummary}{True/{\bf False}}{Control the level
|
---|
1815 | of information printed by summary}
|
---|
1816 |
|
---|
1817 | \subsection{Installation}
|
---|
1818 |
|
---|
1819 | \index{Installation}ASAP depends on a number of third-party libraries which you must
|
---|
1820 | have installed before attempting to build ASAP. These are:
|
---|
1821 |
|
---|
1822 | \begin{itemize}
|
---|
1823 | \item AIPS++
|
---|
1824 | \item Boost
|
---|
1825 | \item Matplotlib
|
---|
1826 | \item python/ipython
|
---|
1827 | \end{itemize}
|
---|
1828 |
|
---|
1829 | Debian Linux is currently supported and we intend also
|
---|
1830 | to support other popular Linux flavours, Solaris and Mac.
|
---|
1831 |
|
---|
1832 | Of the dependencies, AIPS++ is the most complex to install.
|
---|
1833 |
|
---|
1834 | \printindex
|
---|
1835 |
|
---|
1836 | \end{document}
|
---|
1837 |
|
---|