source: branches/Release2.1/doc/userguide.tex @ 1265

Last change on this file since 1265 was 1265, checked in by phi196, 18 years ago

Release 2.1 updates

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 79.2 KB
Line 
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 v2.1\\DRAFT }
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\newcommand{\commanddef}[3]{
27  \begin{minipage}[t]{27mm}\tt #1\end{minipage}\hspace{3mm}
28  \begin{minipage}[t]{\textwidth-30mm}#2 \\ \tt #3\end{minipage}
29}
30
31\newcommand{\bigcommanddef}[3]{
32  \begin{minipage}[t]{45mm}\tt #1\end{minipage}\hspace{3mm}
33  \begin{minipage}[t]{\textwidth-47mm}#2 \\ \tt #3\end{minipage}
34}
35
36\makeindex
37
38\begin{document}
39
40\maketitle
41
42\section{Introduction}
43
44ASAP is a single dish spectral line processing package currently being
45developed by the ATNF. It is intended to process data from all ATNF
46antennas, and can probably be used for other antennas if they can
47produce ``Single Dish FITS'' format. It is based on the AIPS++
48package.
49
50This userguide is being updated for the ASAP 2.1. Please report any
51mistakes you find.
52
53\section{Installation and Running}
54
55Currently there are installations running on Linux machines at
56
57\begin{itemize}
58\item Epping - use hosts {\tt draco} or {\tt hydra}
59\item Narrabri - use host {\tt kaputar}
60\item Parkes - use host {\tt bourbon}
61\item Mopra - use host {\tt minos}
62\end{itemize}
63
64Or use your own Linux desktop.
65
66{\em Note. ASAP2.1 only runs on ATNF Linux machines which have been
67updated to Debian Sarge and are using the ``DEBIANsarge''
68/usr/local. If your favourite machine has not been upgraded, send a
69request your your friendly IT support. At the time of writing asap 2.1
70does not run on hydra, bourbon or kaputar.}
71
72\index{Running}To start asap log onto one of these Linux hosts and enter
73
74\begin{verbatim}
75  > cd /my/data/directory
76  > asap
77\end{verbatim}
78
79This starts the ASAP. To quit, you need to type \verb+^+-d
80(control-d) or type \cmd{\%Exit}.
81
82\section{Interface}
83
84\index{Interface}ASAP is written in C++ and python. The user interface
85uses the ``ipython'' interactive shell, which is a simple interactive
86interface to python. The user does not need to understand python to
87use this, but certain aspects python affect what the user can do.  The
88current interface is object oriented.
89
90\subsection {Integer Indices are 0-relative}
91
92Please note, all integer indices in ASAP and iPython are {\bf 0-relative}.
93
94\subsection{Objects}
95\index{objects}
96The ASAP interface is based around a number of ``objects'' which the
97user deals with. Objects range from the data which have been read from
98disk, to tools used for fitting functions to the data. The following
99main objects are used :
100
101\begin{itemize}
102  \item[\cmd{scantable}] The data container (actual spectra and header
103    information)
104  \item[\cmd{selector}] Allows the user to select a subsection of the
105    data, such as a specified or range of beam numbers, IFs, etc.
106  \item[\cmd{plotter}] A tool used to plot the spectral line data
107  \item[\cmd{fitter}] A tool used to fit functions to the spectral data
108  \item[\cmd{reader}] A tool which can be used to read data from disks
109    into a scantable object (advanced use).
110\end{itemize}
111
112There can be many objects of the same type. Each object is referred to
113by a variable name made by the user. The name of this variable is not
114important and can be set to whatever the user prefers (i.e. ``s'' and
115``ParkesHOH-20052002'' are equivalent).  However, having a simple and
116consistent naming convention will help you a lot.
117
118\subsection{Member Functions (functions)}
119
120\index{Functions!member}Following the object oriented approach,
121objects have associated ``member functions'' which can either be used
122to modify the data in some way or change global properties of the
123object. In this document member functions will be referred to simply
124as functions. From the command line, the user can execute these
125functions using the syntax:
126\begin{verbatim}
127  ASAP>out = object.function(arguments)
128\end{verbatim}
129
130Where \cmd{out} is the name of the returned variable (could be a new
131scantable object, or a vector of data, or a status return),
132\cmd{object} is the object variable name (set by the user),
133\cmd{function} is the name of the member function and \cmd{arguments}
134is a list of arguments to the function. The arguments can be provided
135either though position or \cmd{name=}.  A mix of the two can be used.
136E.g.
137
138\begin{verbatim}
139  ASAP>av = scans.average_time(msk,weight='tsys')
140  ASAP>av = scans.average_time(mask=msk,weight='tsys')
141  ASAP>av = scans.average_time(msk,tsys)
142  ASAP>scans.poly_baseline(mask=msk, order=0, insitu=True)
143  ASAP>scans.poly_baseline(msk,0,True)
144  ASAP>scans.poly_baseline(mask, insitu=True)
145\end{verbatim}
146
147\subsection{Global Functions}
148
149\index{Functions!global}It does not make sense to implement some functions as member
150functions, typically functions which operate on more than one
151scantable (e.g. time averaging of many scans). These functions will
152always be referred to as global functions.
153
154\subsection{Interactive environment}
155
156\index{ipython!environment}ipython has a number of useful interactive
157features and a few things to be aware of for the new user.
158
159\subsubsection{String completion}
160
161\index{ipython!string completion}Tab completion is enabled for all
162function names. If you type the first few letters of a function name,
163then type {\tt <TAB>} the function name will be auto completed if it
164is un-ambiguous, or a list of possibilities will be
165given. Auto-completion works for the user object names as well as
166function names. It does not work for filenames, nor for function
167arguments.
168
169Example
170\begin{verbatim}
171  ASAP>scans = scantable('MyData.rpf')
172  ASAP>scans.se<TAB>
173  ASAP>scans.set_in<TAB>
174scans.set_cursor      scans.set_freqframe   scans.set_selection
175scans.set_doppler     scans.set_instrument  scans.set_unit
176scans.set_fluxunit    scans.set_restfreqs
177
178  ASAP>scans.set_instrument()
179\end{verbatim}
180
181\subsubsection{Leading Spaces}
182
183\index{ipython!leading space}Python uses leading space to mark blocks
184of code. This means that it you start a command line with a space, the
185command generally will fail with an syntax error.
186
187\subsubsection{Variable Names}
188
189\index{ipython!variable names}During normal data processing, the user
190will have to create named variables to hold spectra etc. These must
191conform to the normal python syntax, specifically they cannot contain
192``special'' characters such as \@ \$ etc and cannot start with a
193number (but can contain numbers).  Variable (and function) names are
194case sensitive.
195
196\subsubsection{Unix Interaction}
197
198\index{ipython!unix interaction}Basic unix shell commands (\cmd{pwd},
199\cmd{ls}, \cmd{cd} etc) can be issued from within ASAP. This allows
200the user to do things like look at files in the current directory. The
201shell command ``\cmd{cd}'' works within ASAP, allowing the user to
202change between data directories. Unix programs cannot be run this way,
203but the shell escape ``$!$'' can be used to run arbitrary
204programs. E.g.
205
206\begin{verbatim}
207  ASAP>pwd
208  ASAP>ls
209  ASAP>cd /my/data/directory
210  ASAP>! mozilla&
211\end{verbatim}
212
213\subsection{Help}
214
215\index{Help}ASAP has built in help for all functions. To get a list of
216functions type:
217
218\begin{verbatim}
219  ASAP>commands()
220\end{verbatim}
221
222To get help on specific functions, the built in help needs to be given
223the object and function name. E.g.
224
225\begin{verbatim}
226  ASAP>help scantable.get_scan # or help(scantable.get_scan)
227  ASAP>help scantable.stats
228  ASAP>help plotter.plot
229  ASAP>help fitter.plot
230
231  ASAP>scans = scantable('mydata.asap')
232  ASAP>help scans.get_scan # Same as above
233\end{verbatim}
234
235Global functions just need their name
236
237\begin{verbatim}
238  ASAP>help average_time
239\end{verbatim}
240
241Note that if you just type \cmd{help} the internal ipython help is
242invoked, which is probably {\em not} what you want. Type \verb+^+-d
243(control-d) to escape from this.
244
245\subsection{Customisation - .asaprc}
246
247\index{.asaprc}ASAP use an \cmd{.asaprc} file to control the user's
248preference of default values for various functions arguments. This
249includes the defaults for arguments such as \cmd{insitu}, scantable
250\cmd{freqframe} and the plotters \cmd{set\_mode} values. The help on
251individual functions says which arguments can be set default values
252from the \cmd{.asaprc} file. To get a sample contents for the
253\cmd{.asaprc} file use the command \cmd{list\_rcparameters}.
254
255Common values include:
256\begin{verbatim}
257  # apply operations on the input scantable or return new one
258  insitu                     : False
259
260  # default output format when saving scantable
261  scantable.save             : ASAP
262
263  # default frequency frame to set when function
264  # scantable.set_freqframe is called
265  scantable.freqframe        : LSRK
266
267  # auto averaging on read
268  scantable.autoaverage      : True
269\end{verbatim}
270
271For a complete list of \cmd{.asaprc} values, see the Appendix.
272
273\section{Scantables}
274\index{Scantables}
275\subsection {Description}
276
277\subsubsection {Basic Structure}
278
279\index{Scantable!structure}ASAP data handling works on objects called
280scantables.  A scantable holds your data, and also provides functions
281to operate upon it.
282
283The building block of a scantable is an integration, which is a single
284row of a scantable. Each row contains just one spectrum for each beam,
285IF and polarisation. For example Parkes OH-multibeam data would
286normally contain 13 beams, 1 IF and 2 polarisations, Parkes
287methanol-multibeam data would contain 7 beams, 2 IFs and 2
288polarisations while the Mopra 8-GHz MOPS filterbank will produce one
289beam, many IFs, and 2-4 polarisations.
290
291All of the combinations of Beams/IFs an Polarisations are
292contained in separate rows. These rows are grouped in cycles (same time stamp).
293
294A collection of cycles for one source is termed a scan (and each scan
295has a unique numeric identifier, the SCANNO). A scantable is then a
296collection of one or more scans. If you have scan-averaged your data
297in time, i.e. you have averaged all cycles within a scan, then each
298scan would hold just one (averaged) integration.
299
300Many of the functions which work on scantables can either return a new
301scantable with modified data or change the scantable insitu. Which
302method is used depends on the users preference. The default can be
303changed via the {\tt .asaprc} resource file.
304
305For example a Mopra scan with a  4s integration time, two IFs and
306dual polarisations has two (2s) cycles.
307\begin{verbatim}
308    SCANNO  CYCLENO BEAMNO IFNO POLNO
309    0       0       0      0    0
310    0       0       0      0    1
311    0       0       0      1    0
312    0       0       0      1    1
313    0       1       0      0    0
314    0       1       0      0    1
315    0       1       0      1    0
316    0       1       0      1    1
317\end{verbatim}
318
319
320\subsubsection {Contents}
321
322\index{Scantable!contents}A scantable has header information and data
323(a scantable is actually an AIPS++ Table and it is generally stored in
324memory when you are manipulating it with ASAP.  You can save it to
325disk and then browse it with the AIPS++ Table browser if you know how
326to do that !).
327
328The data are stored in columns (the length of a column is the number of
329rows/spectra of course).
330
331Two important columns are those that describe the frequency setup.  We mention
332them explicitly here because you need to be able to understand the presentation
333of the frequency information and possibly how to manipulate it.
334
335These columns are called FREQ\_ID and MOLECULE\_ID.  They contain indices, for
336each IF, pointing into tables with all of the frequency and rest-frequency
337information for that integration.
338
339There are of course many other columns which contain the actual spectra,
340the flags, the Tsys, the source names and so on.
341
342There is also a function \cmd{summary} to list a summary of the scantable.
343You will find this very useful.
344
345Example:
346
347\begin{verbatim}
348  ASAP>scans = scantable('MyData.rpf')
349  ASAP>scans.summary()                # Brief listing
350
351  # Equivalent to brief summary function call
352  ASAP>print scan
353\end{verbatim}
354
355The summary function gives you a scan-based summary, presenting the
356scantable as a cascading view of Beams and IFs. Note that the output
357of summary is redirected into your current pager specified by the
358\$PAGER environment variable. If you find the screen is reset to the
359original state when summary is finished (i.e. the output from summary
360disappears), you may need to set the \$LESS environment variable to
361include the \cmd{-X} option.
362
363\subsection{Data Selection}
364\label{sec:selection}
365
366ASAP contains flexible data selection. Data can be selected based on
367IF, beam, polarisation, scan number as well as values such as
368Tsys. Advanced users can also make use of the AIPS++ TAQL language to
369create selections based on almost any of the values recorded.
370
371Selection is based on a \cmd{selector} object. This object is created
372and various selection functions applied to it (\cmd{set\_ifs},
373\cmd{set\_beams} etc). The selection object then must be applied to a
374scantable using the \cmd{set\_selection} function. A single selection
375object can be created and setup then applied to multiple scantables.
376
377Once a selection has been applied, all following functions will only
378``see'' the selected spectra (including functions such as
379\cmd{summary}). The selection can then be reset and all spectra are
380visible. Note that if functions such as \cmd{copy} are run on a
381scantable with active selection, only the selected spectra are copied.
382
383The common selection functions are:
384
385\begin{itemize}
386
387\item[\cmd{set\_beams}] Select beams by index number
388\item[\cmd{set\_ifs}] Select ifs by index number
389\item[\cmd{set\_name}] Select by source name. Can contain ``*'' as a
390wildcard, e.g. ``Orion*\_R''.
391\item[\cmd{set\_ifs}] Select IFs by index number
392\item[\cmd{set\_polarisation}] Select by polarisation index or
393name. If polarisation names are given, the data will be on-the-fly
394converted (for example from linears to Stokes).
395\item[\cmd{set\_query}] Set query directly. For power users only!
396\item[\cmd{set\_tsys}] Select data based on Tsys. Also example of user
397definable query.
398\item[\cmd{reset}] Reset the selection to include all spectra.
399
400
401Note that all indices are zero based.
402
403Examples:
404
405\begin{verbatim}
406  ASAP>selection = selector()         # Create selection object
407  ASAP>selection.set_ifs(0)           # Just select the first IF
408  ASAP>scans.set_selection(selection) # Apply the selection
409  ASAP>print scans                    # Will just show the first IF
410
411  ASAP>selection.set_ifs([0,1])       # Select the first two IFs
412  ASAP>selection.set_beams([1,3,5])   # Also select three of the beams
413  ASAP>scans.set_selection(selection) # Apply the selection
414
415  ASAP>selection.set_name('G308*')     # Select by source name
416
417  ASAP>selection.reset()              # Turn off selection
418  ASAP>scans.set_selection(selection) # Apply the reset selection
419
420\end{verbatim}
421
422\end{itemize}
423
424\subsection{State}
425
426\index{Scantable!state}Each scantable contains "state"; these are
427properties applying to all of the data in the scantable.
428
429Examples are the selection of beam, IF and polarisation,  spectral unit
430(e.g. km/s), frequency reference frame (e.g. BARY) and velocity Doppler
431type (e.g. RADIO).
432
433\subsubsection{Units, Doppler and Frequency Reference Frame}
434
435The information describing the frequency setup for each integration
436is stored fundamentally in frequency in the reference frame
437of observation (E.g. TOPO).
438
439When required, this is converted to the desired reference frame
440(e.g. LSRK), Doppler (e.g. OPTICAL) and unit (e.g. km/s) on-the-fly.
441This is important, for example, when you are displaying the data or
442fitting to it. The reference frame is set on file read to the value
443set in the user \cmd{.asaprc} file.
444
445For units, the user has the choice of frequency, velocity or channel.
446The \cmd{set\_unit} function is used to set the current unit for a
447scantable. All functions will (where relevant) work with the selected
448unit until this changes. This is mainly important for fitting (the fits
449can be computed in any of these units), plotting and mask creation.
450
451The velocity definition can be changed with the \cmd{set\_doppler}
452function, and the frequency reference frame can be changed with the
453\cmd{set\_freqframe} function.
454
455Example usage:
456
457\begin{verbatim}
458  ASAP>scans = scantable('2004-11-23_1841-P484.rpf') # Read in the data
459  ASAP>scans.set_freqframe('LSRK')  # Use the LSR velocity frame
460  ASAP>scans.set_unit('km/s')        # Use velocity for plots etc from now on
461  ASAP>scans.set_doppler('OPTICAL')  # Use the optical velocity convention
462  ASAP>scans.set_unit('MHz')         # Use frequency in MHz from now on
463\end{verbatim}
464
465
466\subsubsection{Rest Frequency}
467
468\index{Scantable!rest frequency}ASAP reads the line rest frequency
469from the RPFITS file when reading the data. The values stored in the
470RPFITS file are not always correct and so there is a function
471\cmd{set\_restfreq} to set the rest frequencies for the currently
472selected data.
473
474For each integration, there is a rest-frequency per IF (the rest
475frequencies are just stored as a list with an index into them).
476There are a few ways to set the rest frequencies with this function.
477
478If you specify just one rest frequency, then it is set for all IF.
479
480\begin{verbatim}
481  # Set all IFs
482  ASAP>scans.set_restfreqs(freqs=1.667359e9)
483\end{verbatim}
484
485If set a rest frequency for each IF, specify a list of frequencies (of
486length the number of IFs).  Regardless of the source, the rest
487frequency will be set for each IF to the corresponding value in the
488provided list.
489
490\begin{verbatim}
491  # Set rest frequency for all IFs
492  ASAP>scans.set_restfreqs(freqs=[1.6654018e9,1.667359e9,])
493
494\end{verbatim}
495
496{\em Currently the following is not implemented
497
498In both of the above modes, you can also specify the rest frequencies via
499names in a known list rather than by their values.
500
501Examples:
502
503\begin{verbatim}
504  ASAP>scans.set_restfreqs(freqs=['OH1665','OH1667'])
505\end{verbatim}
506}
507
508\subsubsection{Masks}
509
510\index{Masks}\index{Scantable!masks}
511
512Many tasks (fitting, baseline subtraction, statistics etc) should only
513be run on range of channels. Depending on the current ``unit'' setting
514this range is set directly as channels, velocity or frequency
515ranges. Internally these are converted into a simple boolean mask for
516each channel of the abscissa. This means that if the unit setting is
517later changed, previously created mask are still valid. (This is not
518true for functions which change the shape or shift the frequency
519axis).  You create masks with the function \cmd{create\_mask} and this
520specified the channels to be included in the selection. When setting
521the mask in velocity, the conversion from velocity to channels is
522based on the current selection, specified row and selected frequency
523reference frame.
524
525
526Note that for multi IF data with different number of channels per IF a
527single mask cannot be applied to different IFs. To use a mask on such
528data the selector should be applied to select all IFs with the same
529number of channels.
530
531Example :
532\begin{verbatim}
533
534  # Select channel range for baselining
535  ASAP>scans.set_unit('channels')
536  ASAP>msk = scans.create_mask([100,400],[600,800])
537
538  # Select velocity range for fitting
539  ASAP>scans.set_unit('km/s')
540  ASAP>msk = scans.create_mask([-30,-10])
541\end{verbatim}
542
543Sometimes it is more convenient to specify the channels to be
544excluded, rather included.  You can do this with the ``invert''
545argument.
546
547Example :
548\begin{verbatim}
549  ASAP>scans.set_unit('channels')
550  ASAP>msk = scans.create_mask([0,100],[900-1023], invert=True)
551\end{verbatim}
552
553By default \cmd{create\_mask} uses the frequency setup of the first row
554to convert velocities into a channel mask. If the rows in the data
555cover different velocity ranges, the scantable row to use should be
556specified:
557
558\begin{verbatim}
559  ASAP>scans.set_unit('km/s')
560  ASAP>msk = q.create_mask([-30,-10], row=5)
561\end{verbatim}
562
563Because the mask is stored in a simple python variable, the users is
564able to combine masks using simple arithmetic. To create a mask
565excluding the edge channels, a strong maser feature and a birdie in
566the middle of the band:
567
568\begin{verbatim}
569  ASAP>scans.set_unit('channels')
570  ASAP>msk1 = q.create_mask([0,100],[511,511],[900,1023],invert=True)
571  ASAP>scans.set_unit('km/s')
572  ASAP>msk2 = q.create_mask([-20,-10],invert=True)
573
574  ASAP>mask = msk1 and msk2
575\end{verbatim}
576
577
578\subsection{Management}
579
580\index{Scantable!management}During processing it is possible to create
581a large number of scan tables. These all consume memory, so it is best
582to periodically remove unneeded scan tables. Use \cmd{list\_scans} to
583print a list of all scantables and \cmd{del} to remove unneeded ones.
584
585Example:
586
587\begin{verbatim}
588  ASAP>list_scans()
589  The user created scantables are:
590  ['s', 'scans', 'av', 's2', 'ss']
591
592  ASAP>del s2
593  ASAP>del ss
594\end{verbatim}
595
596\section{Data Input}
597
598\index{Reading data}Data can be loaded in one of two ways; using the
599reader object or via the scantable constructor. The scantable method
600is simpler but the reader allows the user more control on what is read.
601
602\subsection{Scantable constructor}
603
604\index{Scantable constructor}\index{Scantable!constructor}This loads
605all of the data from filename into the scantable object scans and
606averages all the data within a scan (i.e.  the resulting scantable
607will have one row per scan).  The recognised input file formats are
608RPFITS, SDFITS (singledish fits), ASAP's scantable format and aips++
609MeasurementSet2 format.
610
611Example usage:
612
613\begin{verbatim}
614  ASAP>scan = scantable('2004-11-23_1841-P484.rpf')
615
616  # Don't scan average the data
617  ASAP>scan = scantable('2004-11-23_1841-P484.rpf', average=False)
618\end{verbatim}
619
620
621\subsection{Reader object}
622
623\index{Reader object}\index{Scantable!reader object}For more control
624when reading data into ASAP, the reader object should be used.  This
625has the option of only reading in a range of integrations, only a
626specified beam or IF and does not perform any scan averaging of the
627data, allowing analysis of the individual integrations.  Note that due
628to limitation of the RPFITS library, only one reader object can be
629open at one time reading RPFITS files.  To read multiple RPFITS files,
630the old reader must be destroyed before the new file is opened.
631However, multiple readers can be created and attached to SDFITS files.
632
633
634Example usage:
635
636\begin{verbatim}
637  ASAP>r = reader('2003-03-16_082048_t0002.rpf')
638  ASAP>r.summary()
639  ASAP>scan = r.read()
640  ASAP>del r
641\end{verbatim}
642
643\section{Basic Processing}
644
645In the following section, a simple data reduction to form a quotient
646spectrum of a single source is followed.  It has been assume that the
647\cmd{.asaprc} file has {\em not} been used to change the \cmd{insitu}
648default value from \cmd{True}.
649
650\subsection{Auto quotient}
651\index{Auto quotient}Quotients can be computed ``automatically''. This
652requires the data to have matching source/reference pairs or one
653reference for multiple sources. Auto quotient assumes reference scans
654have a trailing ``\_R'' in the source name for data from Parkes and
655Mopra, and a trailing ``e'' or ``w'' for data fro, Tidbinbilla.
656
657\begin{verbatim}
658  ASAP>q = s.auto_quotient()
659\end{verbatim}
660
661By default the quotient spectra is calculated
662to preserve continuum emission. If you wish to remove the continuum
663contribution, use the \cmd{preserve} argument:
664
665\begin{verbatim}
666 ASAP>q = s.auto_quotient(preserve=True)
667\end{verbatim}
668
669If this is not sufficient the following alternative method can be used.
670
671\subsection{Separate reference and source observations}
672
673\index{Quotient spectra}Most data from ATNF observatories
674distinguishes on and off source data using the file name. This makes
675it easy to create two scantables with the source and reference
676data. As long as there was exactly one reference observation for each
677on source observation for following method will work.
678
679For Mopra and Parkes data:
680\begin{verbatim}
681  ASAP>r = scans.get_scan('*_R')
682  ASAP>s = scans.get_scan('*_S')
683\end{verbatim}
684
685For Tidbinbilla data
686\begin{verbatim}
687  ASAP>r = scans.get_scan('*_[ew]')
688  ASAP>s = scans.get_scan('*_[^ew]')
689\end{verbatim}
690
691\subsection{Make the quotient spectra}
692
693Use the quotient function
694
695\begin{verbatim}
696  ASAP>q = s.quotient(r)
697\end{verbatim}
698
699This uses the rows in scantable \cmd{r} as reference spectra for the
700rows in scantable \cmd{s}. Scantable \cmd{r} must have either 1 row
701(which is applied to all rows in \cmd{s}) or both scantables must have
702the same number of rows.
703
704\subsection{Time average separate scans}
705
706\index{Time average}If you have observed the source with multiple
707source/reference cycles you will want to scan-average the quotient
708spectra together.
709
710\begin{verbatim}
711 ASAP>av = q.average_time()
712\end{verbatim}
713
714If for some you want to average multiple sets of scantables together
715you can:
716
717\begin{verbatim}
718 ASAP>av = average_time(q1, q2, q3)
719\end{verbatim}
720
721The default is to use integration time weighting. The alternative is
722to use none, variance, Tsys weighting, Tsys \& integration time or
723median averaging.
724
725\begin{verbatim}
726 ASAP>av = average_time(q, weight='tintsys')
727\end{verbatim}
728
729To use variance based weighting, you need to supply a mask saying which
730channel range you want it to calculate the variance from.
731
732\begin{verbatim}
733 ASAP>msk = scans.create_mask([200,400],[600,800])
734 ASAP>av = average_time(scans, mask=msk, weight='var')
735\end{verbatim}
736
737If you have not observed your data with Doppler tracking (or run
738\cmd{freq\_align} explicitly) you should align the data in frequency
739before averaging.
740
741\begin{verbatim}
742 ASAP>av = scans.average_time(align=True)
743\end{verbatim}
744
745Note that, if needed, you should run \cmd{gain\_el} and \cmd{opacity}
746before you average the data in time (\S \ref{sec:gainel} \&
747\ref{sec:freqalign}).
748
749\subsection{Baseline fitting}
750
751\index{Baseline fitting}To make a baseline fit, you must first create
752a mask of channels to use in the baseline fit.
753
754\begin{verbatim}
755 ASAP>msk = scans.create_mask([100,400],[600,900])
756 ASAP>scans.poly_baseline(msk, order=1)
757\end{verbatim}
758
759This will fit a first order polynomial to the selected channels and subtract
760this polynomial from the full spectra.
761
762\subsubsection{Auto-baselining}
763
764\index{Auto-baseline}The function \cmd{auto\_poly\_baseline} can be used to automatically
765baseline your data without having to specify channel ranges for the
766line free data. It automatically figures out the line-free emission
767and fits a polynomial baseline to that data. The user can use masks to
768fix the range of channels or velocity range for the fit as well as
769mark the band edge as invalid.
770
771Simple example
772
773\begin{verbatim}
774  ASAP>scans.auto_poly_baseline(order=2,threshold=5)
775\end{verbatim}
776
777\cmd{order} is the polynomial order for the fit. \cmd{threshold} is
778the SNR threshold to use to deliminate line emission from
779signal. Generally the value of threshold is not too critical, however
780making this too large will compromise the fit (as it will include
781strong line features) and making it too small will mean it cannot find
782enough line free channels.
783
784
785Other examples:
786
787\begin{verbatim}
788  # Don't try and fit the edge of the bandpass which is noisier
789  ASAP>scans.auto_poly_baseline(edge=(500,450),order=3,threshold=3)
790
791  # Only fit a given region around the line
792  ASAP>scans.set_unit('km/s')
793  ASAP>msk = scans.create_mask([-60,-20])
794  ASAP>scans.auto_poly_baseline(mask=msk,order=3,threshold=3)
795
796\end{verbatim}
797
798\subsection{Average the polarisations}
799
800\index{average\_pol}If you are just interested in the highest SNR for total intensity you
801will want to average the parallel polarisations together.
802
803\begin{verbatim}
804 ASAP>scans.average_pol()
805\end{verbatim}
806
807\subsection{Calibration}
808
809\index{Calibration}For most uses, calibration happens transparently as the input data
810contains the Tsys measurements taken during observations. The nominal
811``Tsys'' values may be in Kelvin or Jansky. The user may wish to
812supply a Tsys correction or apply gain-elevation and opacity
813corrections.
814
815\subsubsection{Brightness Units}
816
817\index{Brightness Units}RPFITS files do not contain any information as
818to whether the telescope calibration was in units of Kelvin or
819Janskys.  On reading the data a default value is set depending on the
820telescope and frequency of observation.  If this default is incorrect
821(you can see it in the listing from the \cmd{summary} function) the
822user can either override this value on reading the data or later.
823E.g:
824
825\begin{verbatim}
826  ASAP>scans = scantable('2004-11-23_1841-P484.rpf', unit='Jy')
827  # Or in two steps
828  ASAP>scans = scantable('2004-11-23_1841-P484.rpf')
829  ASAP>scans.set_fluxunit('Jy')
830\end{verbatim}
831
832\subsubsection{Feed Polarisation}
833
834\index{Brightness Units}The RPFITS files also do not contain any
835information as to the feed polarisation. ASAP will set a default based
836on the antenna, but this will often be wrong the data has been read,
837the default can be changed using the \cmd{set\_feedtype} function with
838an argument of \cmd{'linear'} or \cmd{'circular'}.
839
840E.g:
841
842\begin{verbatim}
843  ASAP>scans = scantable('2004-11-23_1841-P484.rpf')
844  ASAP>scans.set_feedtype('circular')
845\end{verbatim}
846
847\subsubsection{Tsys scaling}
848
849\index{Tsys scaling}Sometime the nominal Tsys measurement at the
850telescope is wrong due to an incorrect noise diode calibration. This
851can easily be corrected for with the scale function. By default,
852\cmd{scale} only scans the spectra and not the corresponding Tsys.
853
854\begin{verbatim}
855  ASAP>scans.scale(1.05, tsys=True)
856\end{verbatim}
857
858\subsubsection{Unit Conversion}
859
860\index{Unit conversion}To convert measurements in Kelvin to Jy (and
861vice versa) the global function \cmd{convert\_flux} is needed. This
862converts and scales the data from K to Jy or vice-versa depending on
863what the current brightness unit is set to. The function knows the
864basic parameters for some frequencies and telescopes, but the user may
865need to supply the aperture efficiency, telescope diameter or the Jy/K
866factor.
867
868\begin{verbatim}
869  ASAP>scans.convert_flux()               # If efficency known
870  ASAP>scans.convert_flux(eta=0.48)       # If telescope diameter known
871  ASAP>scans.convert_flux(eta=0.48,d=35)  # Unknown telescope
872  ASAP>scans.convert_flux(jypk=15)        # Alternative
873\end{verbatim}
874
875\subsubsection{Gain-Elevation and Opacity Corrections}
876\label{sec:gainel}
877
878\index{Gain-elevation}As higher frequencies (particularly $>$20~GHz)
879it is important to make corrections for atmospheric opacity and
880gain-elevation effects.
881
882Note that currently the elevation is not written correctly into
883Tidbinbilla rpfits files. This means that gain-elevation and opacity
884corrections will not work unless these get recalculated.
885
886\begin{verbatim}
887  ASAP>scans.recalc_azel()                # recalculate az/el based on pointing
888\end{verbatim}
889
890Gain-elevation curves for some telescopes and frequencies are known to
891ASAP (currently only for Tidbinbilla at 20~GHz).  In these cases
892making gain-corrections is simple.  If the gain curve for your data is
893not known, the user can supply either a gain polynomial or text file
894tabulating gain factors at a range of elevations (see \cmd{help
895scantable.gain\_el}).
896
897Examples:
898
899\begin{verbatim}
900  ASAP>scans.gain_el()   # If gain table known
901  ASAP>scans.gain_el(poly=[3.58788e-1,2.87243e-2,-3.219093e-4])
902\end{verbatim}
903
904\index{Opacity}Opacity corrections can be made with the global
905function \cmd{opacity}. This should work on all telescopes as long as
906a measurement of the opacity factor was made during the observation.
907
908\begin{verbatim}
909  ASAP>scans.opacity(0.083)
910\end{verbatim}
911
912Note that at 3~mm Mopra uses a paddle wheel for Tsys calibration,
913which takes opacity effects into account (to first order). ASAP
914opacity corrections should not be used for Mopra 3-mm data.
915
916\subsection{Frequency Frame Alignment}
917\label{sec:freqalign}
918
919\index{Frequency alignment}\index{Velocity alignment}When time
920averaging a series of scans together, it is possible that the velocity
921scales are not exactly aligned.  This may be for many reasons such as
922not Doppler tracking the observations, errors in the Doppler tracking
923etc.  This mostly affects very long integrations or integrations
924averaged together from different days.  Before averaging such data
925together, they should be frequency aligned using \cmd{freq\_align}.
926
927E.g.:
928
929\begin{verbatim}
930  ASAP>scans.freq_align()
931  ASAP>av = average_time(scans)
932\end{verbatim}
933
934{\em A Global freq\_align command will be made eventually}
935
936To average together data taken on different days, which are in
937different scantables, each scantable must aligned to a common
938reference time then the scantables averaged. The simplest way of
939doing this is to allow ASAP to choose the reference time for the first
940scantable then using this time for the subsequent scantables.
941
942\begin{verbatim}
943  ASAP>scans1.freq_align() # Copy the refeference Epoch from the output
944  ASAP>scans2.freq_align(reftime='2004/11/23/18:43:35')
945  ASAP>scans3.freq_align(reftime='2004/11/23/18:43:35')
946  ASAP>av = average_time(scans1, scans2, scans3)
947\end{verbatim}
948
949\section{Scantable manipulation}
950
951\index{Scantable!manipulation}While it is very useful to have many
952independent sources within one scantable, it is often inconvenient for
953data processing. The \cmd{get\_scan} function can be used to create a
954new scantable with a selection of scans from a scantable. The
955selection can either be on the source name, with simple wildcard
956matching or set of scan ids. Internally this uses the selector object,
957so for more complicated selection the selector should be used directly
958instead.
959
960For example:
961
962\begin{verbatim}
963  ASAP>ss = scans.get_scan(10) # Get the 11th scan (zero based)
964  ASAP>ss = scans.get_scan(range(10)) # Get the first 10 scans
965  ASAP>ss = scans.get_scan(range(10,20)) # Get the next 10 scans
966  ASAP>ss = scans.get_scan([2,4,6,8,10]) # Get a selection of scans
967
968  ASAP>ss = scans.get_scan('345p407') # Get a specific source
969  ASAP>ss = scans.get_scan('345*')    # Get a few sources
970
971  ASAP>r = scans.get_scan('*_R') # Get all reference sources (Parkes/Mopra)
972  ASAP>s = scans.get_scan('*_S') # Get all program sources (Parkes/Mopra)
973  ASAP>r = scans.get_scan('*[ew]')  # Get all reference sources (Tid)
974  ASAP>s = scans.get_scan('*[^ew]') # Get all program sources (Tid)
975
976\end{verbatim}
977
978To copy a scantable the following does not work:
979
980\begin{verbatim}
981  ASAP>ss = scans
982\end{verbatim}
983
984as this just creates a reference to the original scantable. Any
985changes made to \cmd{ss} are also seen in \cmd{scans}. To duplicate a
986scantable, use the copy function.
987
988\begin{verbatim}
989  ASAP>ss = scans.copy()
990\end{verbatim}
991
992\section{Data Output}
993
994\index{Scantable!save}\index{Saving data}ASAP can save scantables in a
995variety of formats, suitable for reading into other packages. The
996formats are:
997
998\begin{itemize}
999\item[ASAP] This is the internal format used for ASAP. It is the only
1000  format that allows the user to restore the data, fits etc. without
1001  loosing any information.  As mentioned before, the ASAP scantable is
1002  an AIPS++ Table (a memory-based table).  This function just converts
1003  it to a disk-based Table.  You can the access that Table with the
1004  AIPS++ Table browser or any other AIPS++ tool.
1005
1006\item[SDFITS] The Single Dish FITS format. This format was designed to
1007  for interchange between packages, but few packages actually can read
1008  it.
1009
1010%\item[FITS] This uses simple ``image'' fits to save the data, each row
1011%  being written to a separate fits file. This format is suitable for
1012%  importing the data into CLASS.
1013
1014\item[ASCII] A simple text based format suitable for the user to
1015processing using Perl or, Python, gnuplot etc.
1016
1017\item[MS2] Saves the data in an aips++ MeasurementSet V2 format.
1018You can also access this with the Table browser and other AIPS++
1019tools.
1020
1021\end{itemize}
1022
1023The default output format can be set in the users {\tt .asaprc} file.
1024Typical usages are:
1025
1026\begin{verbatim}
1027  ASAP>scans.save('myscans') # Save in default format
1028  ASAP>scans.save('myscans', 'FITS') # Save as FITS for exporting into CLASS
1029  ASAP>scans.save('myscans', overwrite=True) # Overwrite an existing file
1030\end{verbatim}
1031
1032\section{Plotter}
1033
1034\index{Plotter}Scantable spectra can be plotted at any time. An
1035asapplotter object is used for plotting, meaning multiple plot windows
1036can be active at the same time. On start up a default asapplotter
1037object is created called ``plotter''. This would normally be used for
1038standard plotting.
1039
1040The plotter, optionally, will run in a multi-panel mode and contain
1041multiple plots per panel. The user must tell the plotter how they want
1042the data distributed. This is done using the set\_mode function. The
1043default can be set in the users {\tt .asaprc} file. The units (and frame
1044etc) of the abscissa will be whatever has previously been set by
1045\cmd{set\_unit}, \cmd{set\_freqframe} etc.
1046
1047Typical plotter usage would be:
1048
1049\begin{verbatim}
1050  ASAP>scans.set_unit('km/s')
1051  ASAP>plotter.set_mode(stacking='p',panelling='t')
1052  ASAP>plotter.plot(scans)
1053\end{verbatim}
1054
1055This will plot multiple polarisation within each plot panel and each
1056scan row in a separate panel.
1057
1058Other possibilities include:
1059
1060\begin{verbatim}
1061  # Plot multiple IFs per panel
1062  ASAP>plotter.set_mode(stacking='i',panelling='t')
1063
1064  # Plot multiple beams per panel
1065  ASAP>plotter.set_mode(stacking='b',panelling='t')
1066
1067  # Plot one IF per panel, time stacked
1068  ASAP>plotter.set_mode('t', 'i')
1069
1070  # Plot each scan in a seperate panel
1071  ASAP>plotter.set_mode('t', 's')
1072
1073\end{verbatim}
1074
1075\subsection{Plot Selection}
1076\label{sec:plotter_cursor}
1077
1078\index{Plotter!selection}The plotter can plot up to 25 panels and
1079stacked spectra per panel. If you have data larger than this (or for
1080your own sanity) you need to select a subset of this data. This is
1081particularly true for multibeam or multi IF data. The selector object
1082should be used for this purpose. Selection can either be applied to
1083the scantable or directly to the plotter, the end result is the same.
1084You don't have to reset the scantable selection though, if you set
1085the selection on the plotter.
1086
1087Examples:
1088
1089\begin{verbatim}
1090  ASAP>selection = selector()
1091  # Select second IF
1092  ASAP>selection.set_ifs(1)
1093  ASAP>plotter.set_selection(selection)
1094
1095  # Select first 4 beams
1096  ASAP>selection.set_beams([0,1,2,3])
1097  ASAP>plotter.set_selection(selection)
1098
1099  # Select a few scans
1100  ASAP>selection.set_scans([2,4,6,10])
1101  ASAP>plotter.set_selection(selection)
1102
1103  # Multiple selection
1104  ASAP>selection.set_ifs(1)
1105  ASAP>selection.set_scans([2,4,6,10])
1106  ASAP>plotter.set_selection(selection)
1107
1108\end{verbatim}
1109
1110\subsection{Plot Control}
1111
1112\index{Plotter!control}The plotter window has a row of buttons on the
1113lower left. These can be used to control the plotter (mostly for
1114zooming the individual plots). From left to right:
1115
1116\begin{itemize}
1117
1118\item[Home] This will unzoom the plots to the original zoom factor
1119
1120\item[Plot history] (left and right arrow). The plotter keeps a
1121history of zoom settings. The left arrow sets the plot zoom to the
1122previous value. The right arrow returns back again. This allows you,
1123for example, to zoom in on one feature then return the plot to how it
1124was previously.
1125
1126\item[Pan] (The Cross) This sets the cursor to pan, or scroll mode
1127  allowing you to shift the plot within the window. Useful when
1128  zoomed in on a feature.
1129
1130\item[Zoom] (the letter with the magnifying glass) lets you draw a
1131  rectangle around a region of interest then zooms in on that
1132  region. Use the plot history to unzoom again.
1133
1134\item[Adjust] (rectangle with 4 arrows) adjust subplot parameters
1135  (space at edge of plots)
1136
1137\item[Save] (floppy disk). Save the plot as a postscript or .png file
1138
1139You can also type ``g'' in the plot window to toggle on and off grid
1140lines. Typing 'l' turns on and off logarithmic Y-axis.
1141
1142\end{itemize}
1143
1144\subsection{Other control}
1145
1146The plotter has a number of functions to describe the layout of the
1147plot. These include \cmd{set\_legend}, \cmd{set\_layout} and \cmd{set\_title}.
1148
1149To set the exact velocity or channel range to be plotted use the
1150\cmd{set\_range} function. To reset to the default value, call
1151\cmd{set\_range} with no arguments. E.g.
1152
1153\begin{verbatim}
1154  ASAP>scans.set_unit('km/s')
1155  ASAP>plotter.plot(scans)
1156  ASAP>plotter.set_range(-150,-50)
1157  ASAP>plotter.set_range() # To reset
1158\end{verbatim}
1159
1160Both the range of the ``x'' and ``y'' axis can be set at once, if desired:
1161
1162\begin{verbatim}
1163  ASAP>plotter.set_range(-10,30,-1,6.6)
1164\end{verbatim}
1165
1166To save a hardcopy of the current plot, use the save function, e.g.
1167
1168\begin{verbatim}
1169  ASAP>plotter.save('myplot.ps')
1170  ASAP>plotter.save('myplot.png', dpi=80)
1171\end{verbatim}
1172
1173\subsection{Plotter Customisation}
1174
1175The plotter allows the user to change most properties such as text
1176size and colour. The \cmd{commands} function and {\cmd help\
1177asapplotter} list all the possible commands that can be used with the
1178plotter.
1179
1180\commanddef{set\_colors}{Change the default colours used for line
1181plotting. Colours can be given either by name, using the html standard
1182(e.g. red, blue or hotpink), or hexadecimal code (e.g. for black
1183\#000000). If less colours are specified than lines plotted , the
1184plotter cycles through the colours. Example:} {ASAP>
1185plotter.set\_colors('red blue green')\\ ASAP>
1186plotter.set\_colors(`\#0000 blue \#FF00FF')\\ }
1187
1188\commanddef{set\_linestyles}{Change the line styles used for
1189plots. Allowable values are 'line', 'dashed', 'dotted', 'dashdot',
1190'dashdotdot' and 'dashdashdot. Example: }{
1191  ASAP>plotter.set\_linestyles('line dash cotted datshot.)\\
1192  ASAP>plotter.set\_font(size=10)\\
1193}
1194
1195\commanddef{set\_font}{Change the font style and size. Example}{
1196  ASAP>plotter.set\_font(weight='bold')\\
1197  ASAP>plotter.set\_font(size=10)\\
1198  ASAP>plotter.set\_font(style='italic')\\
1199}
1200
1201\commanddef{set\_layout}{Change the multi-panel layout, i.e. now many
1202  rows and columns}{
1203  ASAP>plotter.set\_layout(3,2)
1204}
1205
1206\commanddef{set\_legend}{Set the position, size and optional value of the legend}{
1207  ASAP>plotter.set\_legend(fontsize=16)\\
1208  ASAP>plotter.set\_legend(mode=0)  \# ASAP chooses where to put the legend\\
1209  ASAP>plotter.set\_legend(mode=4)  \# Put legend on lower right\\
1210  ASAP>plotter.set\_legend(mode=-1) \# No legend\\
1211  ASAP>plotter.set\_legend(mp=['RR','LL']) \# Specify legend labels\\
1212  ASAP>plotter.set\_legend(mp=[r'\$\^\{12\}CO\$',r'\$\^\{13\}CO\$']) \# Latex labels
1213}
1214
1215\commanddef{set\_title}{Set the plot title. If multiple panels are
1216  plotted, multiple titles have to be specified}{
1217  ASAP>plotter.set\_title(`G323.12$-$1.79`)\\
1218  ASAP>plotter.set\_title([`SiO`, 'Methanol'], fontsize=18)\\
1219}
1220
1221\subsection{Plotter Annotations}
1222
1223The plotter allows various annotations (lines, arrows, text and
1224``spans'') to be added to the plot. These annotations are
1225``temporary'', when the plotter is next refreshed
1226(e.g. \cmd{plotter.plot} or \cmd{plotter.set\_range}) the annotations
1227will be removed.
1228
1229\bigcommanddef{arrow(x,y,x+dx,y+dy)}{Draw an arrow from a specified
1230\cmd{(x,y)} position to \cmd{(x+dx, y+dy)}. The values are in world
1231coordinates. \em {HOW TO SET ARROW HEAD??}}{
1232  ASAP>plotter.arrow(-40,7,35,0)
1233}
1234
1235\bigcommanddef{axhline(y, xmin, xmax)}{Draw a horizontal line at the
1236specified \cmd{y} position (in world coordinates) between xmin and xmax
1237(in relative coordinates, i.e. 0.0 is the left hand edge of the plot
1238while 1.0 is the right side of the plot.}{
1239 ASAP>plotter.axhline(6.0,0.2,0.8)
1240}
1241
1242\bigcommanddef{avhline(x, ymin, ymax)}{Draw a vertical line at the
1243specified \cmd{x} position (in world coordinates) between \cmd{ymin}
1244and \cmd{ymax} (in relative coordinates, i.e. 0.0 is the left hand edge
1245of the plot while 1.0 is the right side of the plot).}{
1246 ASAP>plotter.axvline(-50.0,0.1,1.0)
1247}
1248
1249\bigcommanddef{axhspan(ymin, ymax, \\ \hspace*{20mm}xmin,
1250 xmax)}{Overlay a transparent colour rectangle. \cmd{ymin} and
1251 \cmd{ymax} are given in world coordinates while \cmd{xmin} and
1252 \cmd{xmax} are given in relative coordinates}{
1253ASAP>plotter.axhspan(2,4,0.25,0.75)
1254}
1255
1256\bigcommanddef{axvspan(xmin, xmax, \\ \hspace*{20mm} ymin,
1257 ymax)}{Overlay a transparent colour rectangle. \cmd{ymin} and
1258 \cmd{ymax} are given in relative coordinates while \cmd{xmin} and
1259 \cmd{xmax} are given in world coordinates}{
1260ASAP>plotter.axvspan(-50,60,0.2,0.5)
1261}
1262
1263\bigcommanddef{text(x, y, str)}{Place the string \cmd{str} at the
1264 given \cmd{(x,y)} position in world coordinates.}{
1265ASAP>plotter.text(-10,7,"CO")
1266}
1267
1268These functions all take a set of \cmd{kwargs} commands. These can be
1269used to set colour, linewidth fontsize etc. These are standard
1270matplotlib settings. Common ones include:
1271
1272\begin{tabular}{ll}
1273 \tt color  \\
1274 \tt linewidth \\
1275 \tt fontsize \\
1276 \tt fontname & Sans, Helvetica, Courier, Times etc\\
1277 \tt rotation & Text rotation (horizontal, vertical) \\
1278 \tt alpha & The alpha transparency on 0-1 scale\\
1279\end{tabular}
1280
1281Examples:
1282\begin{verbatim}
1283  ASAP>plotter.axhline(6.0,0.2,0.8, color='red', linewidth=3)
1284  ASAP>plotter.text(-10,7,"CO", fontsize=20)
1285\end{verbatim}
1286
1287\section{Line Catalog}
1288
1289\index{Linecatalog}ASAP can load and manipulate line catlogs to
1290retrieve rest frequencies for \cmd{set\_restfreqs} and for line
1291identification in the plotter. All line catalogs are loaded into a ``linecatalog'' object.
1292
1293No line catalogs are built into ASAP, the user must load a ASCII based
1294table (which can optionally be saved in an internal format) either of
1295the users own creation or a standard line catalog such as the JPL line
1296catalog or Lovas. The ATNF asap ftp area as copies of the JPL and
1297Lovas catalog in the appropriate format
1298(\cmd{ftp://ftp.atnf.csiro.au/pub/software/asap/data})
1299
1300\subsection{Loading a Line Catalog}
1301
1302\index{Linecatalog!loading}The ASCII text line catalog must have at
1303least 4 columns. The first four columns must contain (in order):
1304Molecule name, frequency in MHz, frequency error and ``intensity''
1305(any units). If the molecule name contains any spaces, they must be
1306wrapped in quotes \verb+""+.
1307
1308A sample from the JPL line catalog:
1309
1310\begin{verbatim}
1311     H2D+    3955.2551 228.8818  -7.1941 
1312     H2D+   12104.7712 177.1558  -6.0769 
1313     H2D+   45809.2731 118.3223  -3.9494 
1314     CH       701.6811    .0441  -7.1641 
1315     CH       724.7709    .0456  -7.3912 
1316     CH      3263.7940    .1000  -6.3501 
1317     CH      3335.4810    .1000  -6.0304 
1318\end{verbatim}
1319
1320To load a line catalog then save it in the internal format:
1321
1322\begin{verbatim}
1323  ASAP>jpl = linecatalog('jpl_pruned.txt')
1324  ASAP>jpl.save('jpl.tbl')
1325\end{verbatim}
1326
1327Later the saved line catalog can reloaded:
1328
1329\begin{verbatim}
1330  ASAP>jpl = linecatalog('jpl.tbl')
1331\end{verbatim}
1332
1333{\em NOTE:} Due to a bug in ipython, if you do not \cmd{del} the
1334linecatalog table before quiting asap, you will be left with temporary
1335files. It is safe to delete these once asap has finished.
1336
1337\subsection{Line selection}
1338
1339\index{Linecatalog!line selection}The linecatalog has a number of
1340selection functions to select a range of lines from a larger catalog
1341(the JPL catalog has $>$180000 lines for
1342example). \cmd{set\_frequency\_limits} selects on frequency range,
1343\cmd{set\_strength\_limits} selects on intensity while \cmd{set\_name}
1344selects on molecule name (wild cards allowed).
1345
1346\begin{verbatim}
1347  ASAP>jpl = linecatalog('jpl.tbl')
1348  ASAP>jpl.set_frequency_limits(80,115,'GHz') # Lines for 3mm receiver
1349  ASAP>jpl.set_name('*OH')                    # Select all alcohols
1350  ASAP>jpl.set_name('OH')                     # Select only OH molecules
1351  ASAP>jpl.summary()
1352
1353  ASAP>jpl.reset()                            # Selections are accumulative
1354  ASAP>jpl.set_frequency_limits(80,115,'GHz')
1355  ASAP>jpl.set_strength_limits(-2,10)         # Select brightest lines
1356  ASAP>jpl.summary()
1357\end{verbatim}
1358
1359\subsection{Using Linecatalog}
1360
1361The line catalogs can be used for line overlays on the plotter or with
1362\cmd{set\_restfreq}.
1363
1364\subsubsection{Plotting linecatalog}
1365
1366\index{Linecatalog!plotting}
1367
1368The plotter \cmd{plot\_lines} function takes a line catalog as an
1369argument and overlays the lines on the spectrum. {\em Currently this
1370only works when plotting in units of frequency (Hz, GHz etc).} If a
1371large line catalog has been loaded (e.g. JPL) it is highly recommended
1372that you use the selection functions to narrow down the number of
1373lines.  By default the line catalog overlay is plotted assuming a line
1374velocity of 0.0. This can be set using the \cmd{doppler} argument (in
1375km/s). Each time \cmd{plot\_lines} is called the new lines are added
1376to any existing line catalog annotations. These are all removed after
1377the next call to \cmd{plotter.plot()}.
1378
1379\begin{verbatim}
1380  ASAP>jpl = linecatalog('jpl.tbl')
1381  ASAP>jpl.set_frequency_limits(23,24,'GHz')
1382  ASAP>data.set_unit('GHz')            # Only works with freq axis currently
1383  ASAP>plotter.plot(data)
1384  ASAP>plotter.plot_lines(jpl)
1385
1386  ASAP>plotter.plot()                  # Reset plotter
1387  ASAP>plotter.plot_lines(jpl,doppler=-10,location='Top') # On top with -10 km/s velocity
1388\end{verbatim}
1389
1390\subsubsection{Setting Rest Frequencies}
1391
1392\index{Linecatalog!set\_restfreq}A linecatalog can be used as an
1393argument for \cmd{set\_restfreqs}. If a personal line catalog has been
1394used (which has the same size as the number of number of IFs) or
1395linecatalog selection has been used to reduce the number of entries,
1396the line catalog can be used directly as an argument to
1397\cmd{set\_restfreqs}, e.g.:
1398\begin{verbatim}
1399  ASAP>jpl = linecatalog('jpl.tbl')
1400  ASAP>jpl.set_frequency_limits(23.66,23.75,'GHz')
1401  ASAP>data = scantable('data.rpf')
1402  ASAP>data.set_restfreqs(jpl)
1403\end{verbatim}
1404
1405If a larger linecatalog is used, individual elements can be used. Use
1406the \cmd{summary} to get the index number of the rest frequency you
1407wish to use. E.g.:
1408
1409\begin{verbatim}
1410  ASAP>jpl.summary()
1411  ASAP>data.set_restfreqs([jpl[11],[jpl[21]])
1412\end{verbatim}
1413
1414
1415
1416
1417\section{Fitting}
1418
1419\index{Fitting}Currently multicomponent Gaussian function is
1420available. This is done by creating a fitting object, setting up the
1421fit and actually fitting the data. Fitting can either be done on a
1422single scantable selection or on an entire scantable using the
1423\cmd{auto\_fit} function. If single value fitting is used, and the
1424current selection includes multiple spectra (beams, IFs, scans etc)
1425then the first spectrum in the scantable will be used for fitting.
1426
1427\begin{verbatim}
1428 ASAP>f = fitter()
1429 ASAP>f.set_function(gauss=2) # Fit two Gaussians
1430 ASAP>f.set_scan(scans)
1431 ASAP>selection = selector()
1432 ASAP>selection.set_polarisations(1) # Fit the second polarisation
1433 ASAP>scans.set_selection(selection)
1434 ASAP>scans.set_unit('km/s')  # Make fit in velocity units
1435 ASAP>f.fit(1)                # Run the fit on the second row in the table
1436 ASAP>f.plot()                # Show fit in a plot window
1437 ASAP>f.get_parameters()      # Return the fit paramaters
1438\end{verbatim}
1439
1440This auto-guesses the initial values of the fit and works well for data
1441without extra confusing features. Note that the fit is performed in
1442whatever unit the abscissa is set to.
1443
1444If you want to confine the fitting to a smaller range (e.g. to avoid
1445band edge effects or RFI you must set a mask.
1446
1447\begin{verbatim}
1448  ASAP>f = fitter()
1449  ASAP>f.set_function(gauss=2)
1450  ASAP>scans.set_unit('km/s')  # Set the mask in channel units
1451  ASAP>msk = s.create_mask([1800,2200])
1452  ASAP>scans.set_unit('km/s')  # Make fit in velocity units
1453  ASAP>f.set_scan(s,msk)
1454  ASAP>f.fit()
1455  ASAP>f.plot()
1456  ASAP>f.get_parameters()
1457\end{verbatim}
1458
1459If you wish, the initial parameter guesses can be specified and
1460specific parameters can be fixed:
1461
1462\begin{verbatim}
1463  ASAP>f = fitter()
1464  ASAP>f.set_function(gauss=2)
1465  ASAP>f.set_scan(s,msk)
1466  ASAP>f.fit() # Fit using auto-estimates
1467  # Set Peak, centre and fwhm for the second gaussian.
1468  # Force the centre to be fixed
1469  ASAP>f.set_gauss_parameters(0.4,450,150,0,1,0,component=1)
1470  ASAP>f.fit() # Re-run the fit
1471\end{verbatim}
1472
1473The fitter \cmd{plot} function has a number of options to either view
1474the fit residuals or the individual components (by default it plots
1475the sum of the model components).
1476
1477Examples:
1478
1479\begin{verbatim}
1480  # Plot the residual
1481  ASAP>f.plot(residual=True)
1482
1483  # Plot the first 2 componentsa
1484  ASAP>f.plot(components=[0,1])
1485
1486  # Plot the first and third component plus the model sum
1487  ASAP>f.plot(components=[-1,0,2])  # -1 means the compoment sum
1488\end{verbatim}
1489
1490\subsection{Fit saving}
1491
1492\index{Fitter!Fit saving}One you are happy with your fit, it is
1493possible to store it as part of the scantable.
1494
1495\begin{verbatim}
1496  ASAP>f.store_fit()
1497\end{verbatim}
1498
1499This will be saved to disk with the data, if the ``ASAP'' file format
1500is selected. Multiple fits to the same data can be stored in the
1501scantable.
1502
1503The scantable function \cmd{get\_fit} can be used to retrieve the
1504stored fits. Currently the fit parameters are just printed to the
1505screen.
1506
1507\begin{verbatim}
1508  ASAP>scans.get_fit(4) # Print fits for row 4
1509\end{verbatim}
1510
1511A fit can also be exported to an ASCII file using the \cmd{store\_fit}
1512function. Simply give the name of the output file requires as an
1513argument.
1514
1515\begin{verbatim}
1516  ASAP>f.store_fit('myfit.txt')
1517\end{verbatim}
1518
1519\section{Polarisation}
1520
1521\index{Polarisation}Currently ASAP only supports polarmetric analysis
1522on linearly polarised feeds and the cross polarisation products
1523measured. Other cases will be added on an as needed basis.
1524
1525Conversions of linears to Stokes or Circular polarisations are done
1526``on-the-fly''. Leakage cannot be corrected for nor are there routines
1527to calibrate position angle offsets.
1528
1529\subsection{Simple Calibration}
1530
1531\index{Polarisation!calibration}It is possible that there is a phase
1532offset between polarisation which will effect the phase of the cross
1533polarisation correlation, and so give rise to spurious
1534polarisation. \cmd{rotate\_xyphase} can be used to correct for this
1535error. At this point, the user must know how to determine the size of
1536the phase offset themselves.
1537
1538\begin{verbatim}
1539  ASAP>scans.rotate_xyphase(10.5)            # Degrees
1540\end{verbatim}
1541
1542Note that if this function is run twice, the sum of the two values is
1543applied because it is done in-situ.
1544
1545A correction for the receiver parallactic angle may need to be made,
1546generally because of how it is mounted. Use \cmd{rotate\_linpolphase}
1547to correct the position angle. Running this function twice results in
1548the sum of the corrections being applied because it is applied
1549in-situ.
1550
1551\begin{verbatim}
1552  ASAP>scans.rotate_linpolphase(-45) # Degrees; correct for receiver mounting
1553\end{verbatim}
1554
1555If the sign of the complex correlation is wrong (this can happen
1556depending on the correlator configuration), use \cmd{invert\_phase} to
1557change take the complex conjugate of the complex correlation
1558term. This is always performed in-situ.
1559
1560\begin{verbatim}
1561  ASAP>scans.invert_phase()
1562\end{verbatim}
1563
1564Depending on how the correlator is configured, ``BA'' may be
1565correlated instead of ``AB''. Use \cmd{swap\_linears} to correct for
1566this problem:
1567
1568\begin{verbatim}
1569  ASAP>scans.swap_linears()
1570\end{verbatim}
1571
1572\subsection{Conversion}
1573\label{sec:polconv}
1574
1575Data can be permanently converted between linear and circular
1576polarisations and stokes.
1577
1578\begin{verbatim}
1579  ASAP>stokescans = linearscans.convert_pol("stokes")
1580\end{verbatim}
1581
1582
1583\subsection{Plotting}
1584\label{sec:polplot}
1585
1586\index{Polarisation!plotting}To plot Stokes values, a selector object
1587must be created and the set\_polarisation function used to select the
1588desired polarisation products.
1589
1590The values which can be plotted include a selection of [I,Q,U,V], [I,
1591Plinear, Pangle, V], [RR, LL] or [XX, YY, Real(XY),
1592Imaginary(XY)]. (Plinear and Pangle are the percentage and position
1593angle of linear polarisation).
1594
1595Example:
1596
1597\begin{verbatim}
1598  ASAP>selection = selector()
1599
1600  ASAP>selection.set_polarisations(``I Q U V'')
1601  ASAP  plotter.set_selection(selection);              # Select I, Q, U \& V
1602
1603  ASAP>selection.set_polarisations(``I Q'')
1604  ASAP  plotter.set_selection(selection);              # Select just I \& Q
1605
1606  ASAP>selection.set_polarisations(``RR LL'')
1607  ASAP  plotter.set_selection(selection);              # Select just RR \& LL
1608
1609  ASAP>selection.set_polarisations(``XX YY'')
1610  ASAP  plotter.set_selection(selection);              # Select linears
1611
1612  ASAP>selection.set_polarisations(``I Plinear'')
1613  ASAP  plotter.set_selection(selection);              # Fractional linear
1614
1615  ASAP>selection.set_polarisations(``Pangle'')
1616  ASAP  plotter.set_selection(selection);              # Position angle
1617
1618\end{verbatim}
1619
1620Scan, beam and IF selection are also available in the selector object as
1621describe in section~\ref{sec:selection}.
1622
1623\subsection{Saving}
1624
1625\index{Polarisation!saving}When saving data using the \cmd{save}
1626function, the \cmd{stokes} argument can be used to save the data as
1627Stoke values when saving in FITS format.
1628
1629Example:
1630
1631\begin{verbatim}
1632  ASAP>scans.save('myscan.sdfits', 'SDFITS', stokes=True)
1633\end{verbatim}
1634
1635\section{Specialised Processing}
1636
1637\subsection{Multibeam MX mode}
1638
1639MX mode is a specific observing approach with a multibeam where a
1640single source is observed cycling through each beam. The scans when
1641the beam is off source is used as a reference for the on-source
1642scan. The function \cmd{mx\_quotient} is used to make a quotient
1643spectrum from an MX cycle. This works averaging the ``off-source''
1644scans for each beam (either a median average or mean) and using this
1645as a reference scan in a normal quotient (for each beam). The final
1646spectrum for each beam is returned on a new scantable containing
1647single scan (it the scan numbers are re-labelled to be the same). Note
1648that the current version of \cmd{mx\_quotient} only handles a single
1649MX cycle, i.e. if each beam has observed the source multiple times you
1650will need to use the selector object multiple times to select a single
1651MX cycle, run \cmd{mx\_quotient} for each cycle then merge the
1652resulting scan tables back together.
1653
1654Example:
1655
1656\begin{verbatim}
1657  ASAP>scans = scantable('mydata.rpf')
1658  ASAP>q = scans.mx_quotient()
1659  ASAP>plotter.plot(q)
1660\end{verbatim}
1661
1662The function \cmd{average\_beam} averages multiple beam data
1663together. This is need if MX mode has been used to make a long
1664integration on a single source. E.g.
1665
1666\begin{verbatim}
1667  ASAP>av = q.average_beam()
1668\end{verbatim}
1669
1670\subsection{Frequency Switching}
1671
1672{\em FILL ME IN}
1673
1674\subsection{Disk Based Processing}
1675\index{Scantable!disk based}
1676
1677Normally scantables exist entirely in memory during an ASAP
1678session. This has the advantage of speed, but causes limits on the
1679size of the dataset which can be loaded. ASAP can use ``disk based''
1680scan tables which cache the bulk of the scantable on disk and require
1681significantly less memory usage.
1682
1683To use disk based tables you either need to change the default in your
1684\cmd{.asapr} file, e.g.
1685\begin{verbatim}
1686   scantable.storage          : disk
1687\end{verbatim}
1688
1689or use set the ``\cmd{rc}'' value while running asap to change this
1690on-the-fly. E.g.
1691\begin{verbatim}
1692  ASAP>rc('scantable',storage='disk')
1693  ASAP>data = scantable('data.rpf')     # Loaded using disk based table
1694  ASAP>rc('scantable',storage='memory') # Memory tables will be used now
1695\end{verbatim}
1696
1697Changing the ``\cmd{rc}'' value affects the next time the
1698\cmd{scantable} constructor is called.
1699
1700{\bf NOTE: } Currently a bug in ipython means temporary files are not
1701cleaned up properly when you exit ASAP. If you use disk based scan
1702tables your directory will be left with 'tabXXXXX\_X' directories. These can
1703be safely removed if ASAP is not running.
1704
1705\section{Scantable Mathematics}
1706
1707\index{Scantable!maths}It is possible to to simple mathematics
1708directly on scantables from the command line using the \cmd{+, -, *,
1709/} operators as well as their cousins \cmd{+=, -= *=, /=}. This works
1710between a scantable and a float. (Note that it does
1711not work for integers).
1712
1713{\em Currently mathematics between two scantables is not available }
1714
1715%  ASAP>sum = scan1+scan2
1716\begin{verbatim}
1717  ASAP>scan2 = scan1+2.0
1718  ASAP>scan *= 1.05
1719\end{verbatim}
1720
1721\section{Scripting}
1722
1723\index{Scripting}Because ASAP is based on python, it easy for the user
1724write their own scripts and functions to process data. This is highly
1725recommended as most processing of user data could then be done in a
1726couple of steps using a few simple user defined functions. A Python
1727primer is beyond the scope of this userguide. See the ASAP home pages
1728for a scripting tutorial or the main python website for comprehensive
1729documentation.
1730
1731\hspace{1cm} http://www.atnf.csiro.au/computing/software/asap/tutorials
1732
1733\hspace{1cm} http://www.python.org/doc/Introduction.html
1734
1735\subsection{Running scripts}
1736
1737The ASAP global function \cmd{execfile} reads the named text file and
1738executes the contained python code. This file can either contain
1739function definitions which will be used in subsequent processing or
1740just a set of commands to process a specific dataset.
1741
1742\subsection{asapuserfuncs.py}
1743
1744The file $\sim$/.asap/asapuserfuncs.py is automatically read in when
1745ASAP is started. The user can use this to define a set of user
1746functions which are automatically available each time ASAP is
1747used. The \cmd{execfile} function can be called from within this file.
1748
1749\section{Worked examples}
1750
1751In the following section a few examples of end-to-end processing of
1752some data in ASAP are given.
1753
1754\subsection{Mopra}
1755\index{Mopra}
1756
1757The following example is of some dual polarisation, position switched
1758data from Mopra. The source has been observed multiple times split
1759into a number of separate RPFITS files. To make the processing easier,
1760the first step is to \cmd{cat} the separate RPFITS files together and
1761load as a whole (future versions of ASAP will make this unnecessary).
1762
1763
1764\begin{verbatim}
1765# get a list of the individual rpfits files in the current directory
1766myfiles = list_files()
1767
1768# Load the data into a scantable
1769data = scantable(myfiles)
1770print data
1771
1772# Form the quotient spectra
1773q = data.auto_quotient()
1774print q
1775
1776# Look at the spectra
1777plotter.plot(q)
1778
1779# Set unit and reference frame
1780q.set_unit('km/s')
1781q.set_freqframe('LSRK')
1782
1783# Average all scans in time, aligning in velocity
1784av = q.average_time(align=True)
1785plotter.plot(av)
1786
1787# Remove the baseline
1788msk = av.create_mask([100,130],[160,200])
1789av.poly_baseline(msk,2)
1790
1791# Average the two polarisations together
1792iav = av.average_pol()
1793print iav
1794plotter.plot(iav)
1795
1796# Set a sensible velocity range on the plot
1797plotter.set_range(85,200)
1798
1799# Smooth the data a little
1800av.smooth('gauss',4)
1801plotter.plot()
1802
1803# Fit a guassian to the emission
1804f = fitter()
1805f.set_function(gauss=1)
1806f.set_scan(av)
1807f.fit()
1808
1809# View the fit
1810f.plot()
1811
1812# Get the fit parameters
1813f.get_parameters()
1814
1815\end{verbatim}
1816
1817
1818\subsection{Parkes Polarimetry}
1819
1820\index{Parkes}\index{Polarisation}The following example is processing
1821of some Parkes polarimetric observations of OH masers at
18221.6~GHz. Because digital filters where used in the backend, the
1823baselines are stable enough not to require a quotient spectra. The
18244~MHz bandwidth is wide enough to observe both the 1665 and 1667~MHz
1825OH maser transitions. Each source was observed once for about 10
1826minutes. Tsys information was not written to the RPFITS file (a
1827nominal 25K values was used), so the amplitudes need to be adjusted
1828based on a separate log file. A simple user function is used to
1829simplify this, contained in a file called mypol.py:
1830
1831\begin{verbatim}
1832def xyscale(data,xtsys=1.0,ytsys=1.0,nomtsys=25.0) :
1833
1834 selection = selector()
1835 selection.set_polarisations(0)
1836 data.set_selection(selection)
1837 data.scale(xtsys/nomtsys)
1838
1839 selection.set_polarisations(1)
1840 data.set_selection(selection)
1841 data.scale(ytsys/nomtsys)
1842
1843 selection.set_polarisations(0)
1844 data.set_selection(selection)
1845 data.scale((xtsys+ytsys)/(2*nomtsys))
1846
1847 selection.set_polarisations(0)
1848 data.set_selection(selection)
1849 data.scale((xtsys+ytsys)/(2*nomtsys))
1850\end{verbatim}
1851
1852The typical ASAP session would be
1853
1854\begin{verbatim}
1855
1856# Remind ourself the name of the rpfits files
1857ls
1858
1859# Load data from an rpfits file
1860d1665 = scantable('2005-10-27_0154-P484.rpf')
1861
1862# Check what we have just loaded
1863d1665.summary()
1864
1865# View the data in velocity
1866d1665.set_unit('km/s')
1867d1665.set_freqframe('LSRK')
1868
1869# Correct for the known phase offset in the crosspol data
1870d1665.rotate_xyphase(-4)
1871
1872# Create a copy of the data and set the rest frequency to the 1667 MHz
1873# transition
1874d1667 = d1665.copy()
1875d1667.set_restfreqs([1667.3590], 'MHz')
1876d1667.summary()
1877
1878# Copy out the scan we wish to process
1879g351_5 = d1665.get_scan('351p160')
1880g351_7 = d1667.get_scan('351p160')
1881
1882# Baseline both
1883msk = g351_5.create_mask([-30,-25],[-5,0])
1884g351_5.poly_baseline(msk,order=1)
1885msk = g351_7.create_mask([-30,-25],[-5,0])
1886g351_7.poly_baseline(msk,order=1)
1887
1888
1889# Plot the data. The plotter can only plot a single scantable
1890# So we must merge the two tables first
1891
1892plotscans = merge(g351_5, g351_7)
1893
1894plotter.plot(plotscans) # Only shows one panel
1895
1896# Tell the plotter to stack polarisation and panel scans
1897plotter.set_mode('p','s')
1898
1899# Correct for the Tsys using our predefined function
1900execfile('mypol.py') # Read in the function xyscale
1901xyscale(g351_5,23.2,22.7) # Execute it on the data
1902xyscale(g351_7,23.2,22.7)
1903
1904# Only plot the velocity range of interest
1905plotter.set_range(-30,10)
1906
1907# Update the plot with the baselined data
1908plotter.plot()
1909
1910# Look at the various polarisation products
1911selection = selector()
1912selection.set_polarisations(``RR LL'')
1913plotter.set_selection(selection)
1914selection.set_polarisations(``I Plinear'')
1915plotter.set_selection(selection)
1916selection.set_polarisations(``I Q U V'')
1917plotter.set_selection(selection)
1918
1919# Save the plot as postscript
1920plotter.save('g351_stokes.ps')
1921
1922# Save the process spectra
1923plotscans.save('g351.asap')
1924
1925\end{verbatim}
1926
1927\subsection{Tidbinbilla}
1928
1929\index{Tidbinbilla}The following example is processing of some
1930Tidbinbilla observations of NH$_3$ at 12~mm. Tidbinbilla has (at the
1931time of observations) a single polarisation, but can process two IFs
1932simultaneously. In the example, the first half of the observation was
1933observing the (1,1) and (2,2) transitions simultaneously). The second
1934half observed only the (4,4) transition due to bandwidth
1935limitations. The data is position switched, observing first an
1936reference to the west, then the source twice and finally reference to
1937the east.
1938
1939\begin{verbatim}
1940
1941# Load the rpfits file and inspect
1942d = scantable('2003-03-16_082048_t0002.rpf')
1943print d
1944
1945# Make the quotient spectra
1946q = d.auto_quotient()
1947print q
1948
1949del d
1950
1951# Plot/select in velocity
1952q.set_freqframe('LSRK')
1953q.set_unit('km/s')
1954
1955# Correct for gain/el effects
1956
1957q.recalc_azel()  # Tid does not write the elevation
1958q.gain_el()
1959q.opacity(0.05)
1960
1961# Seperate data from the (1,1)&(2,2) and (4,4) transitions
1962g1 = q.get_scan(range(6))     # scans 0..5
1963g2 = q.get_scan(range(6,12))  # scans 6..11
1964
1965# Align data in velocity
1966g1.freq_align()
1967g2.freq_align()
1968
1969# Average individual scans
1970a1 = g1.average_time()
1971a2 = g2.average_time()
1972
1973# Rpfits file only contains a single rest frequency. Set both
1974a1.set_restfreqs([23694.4700e6,23722.6336e6])
1975
1976plotter.plot(a1)
1977plotter.set_mode('i','t')
1978
1979a1.auto_poly_baseline()
1980
1981plotter.plot()
1982
1983a1.smooth('gauss',5)
1984plotter.plot()
1985
1986
1987\end{verbatim}
1988
1989\newpage
1990
1991\section{Appendix}
1992
1993\subsection{Function Summary}
1994
1995\index{Functions!summary}%
1996\begin{verbatim}
1997   [The scan container]
1998        scantable           - a container for integrations/scans
1999                              (can open asap/rpfits/sdfits and ms files)
2000            copy            - returns a copy of a scan
2001            get_scan        - gets a specific scan out of a scantable
2002                              (by name or number)
2003            drop_scan       - drops a specific scan out of a scantable
2004                              (by number)
2005            set_selection   - set a new subselection of the data
2006            get_selection   - get the current selection object
2007            summary         - print info about the scantable contents
2008            stats           - get specified statistic of the spectra in
2009                              the scantable
2010            stddev          - get the standard deviation of the spectra
2011                              in the scantable
2012            get_tsys        - get the TSys
2013            get_time        - get the timestamps of the integrations
2014            get_sourcename  - get the source names of the scans
2015            get_azimuth     - get the azimuth of the scans
2016            get_elevation   - get the elevation of the scans
2017            get_parangle    - get the parallactic angle of the scans
2018            get_unit        - get the current unit
2019            set_unit        - set the abcissa unit to be used from this
2020                              point on
2021            get_abcissa     - get the abcissa values and name for a given
2022                              row (time)
2023            get_column_names - get the names of the columns in the scantable
2024                               for use with selector.set_query
2025            set_freqframe   - set the frame info for the Spectral Axis
2026                              (e.g. 'LSRK')
2027            set_doppler     - set the doppler to be used from this point on
2028            set_dirframe    - set the frame for the direction on the sky
2029            set_instrument  - set the instrument name
2030            set_feedtype    - set the feed type
2031            get_fluxunit    - get the brightness flux unit
2032            set_fluxunit    - set the brightness flux unit
2033            create_mask     - return an mask in the current unit
2034                              for the given region. The specified regions
2035                              are NOT masked
2036            get_restfreqs   - get the current list of rest frequencies
2037            set_restfreqs   - set a list of rest frequencies
2038            flag            - flag selected channels in the data
2039            save            - save the scantable to disk as either 'ASAP',
2040                              'SDFITS' or 'ASCII'
2041            nbeam,nif,nchan,npol - the number of beams/IFs/Pols/Chans
2042            nscan           - the number of scans in the scantable
2043            nrow            - te number of spectra in the scantable
2044            history         - print the history of the scantable
2045            get_fit         - get a fit which has been stored witnh the data
2046            average_time    - return the (weighted) time average of a scan
2047                              or a list of scans
2048            average_pol     - average the polarisations together.
2049            average_beam    - average the beams together.
2050            convert_pol     - convert to a different polarisation type
2051            auto_quotient   - return the on/off quotient with
2052                              automatic detection of the on/off scans (closest
2053                              in time off is selected)
2054            mx_quotient     - Form a quotient using MX data (off beams)
2055            scale, *, /     - return a scan scaled by a given factor
2056            add, +, -       - return a scan with given value added
2057            bin             - return a scan with binned channels
2058            resample        - return a scan with resampled channels
2059            smooth          - return the spectrally smoothed scan
2060            poly_baseline   - fit a polynomial baseline to all Beams/IFs/Pols
2061            auto_poly_baseline - automatically fit a polynomial baseline
2062            recalc_azel     - recalculate azimuth and elevation based on
2063                              the pointing
2064            gain_el         - apply gain-elevation correction
2065            opacity         - apply opacity correction
2066            convert_flux    - convert to and from Jy and Kelvin brightness
2067                              units
2068            freq_align      - align spectra in frequency frame
2069            invert_phase    - Invert the phase of the cross-correlation
2070            swap_linears    - Swap XX and YY
2071            rotate_xyphase  - rotate XY phase of cross correlation
2072            rotate_linpolphase - rotate the phase of the complex
2073                                 polarization O=Q+iU correlation
2074            freq_switch     - perform frequency switching on the data
2075            stats           - Determine the specified statistic, e.g. 'min'
2076                              'max', 'rms' etc.
2077            stddev          - Determine the standard deviation of the current
2078                              beam/if/pol
2079     [Selection]
2080         selector              - a selection object to set a subset of a scantable
2081           set_cycles         - set (a list of) cycles by index
2082            set_beams          - set (a list of) beamss by index
2083            set_ifs            - set (a list of) ifs by index
2084            set_polarisations  - set (a list of) polarisations by name
2085                                 or by index
2086            set_names          - set a selection by name (wildcards allowed)
2087            set_tsys           - set a selection by tsys thresholds
2088            set_query          - set a selection by SQL-like query, e.g. BEAMNO==1
2089            reset              - unset all selections
2090            +                  - merge to selections
2091
2092     [Math] Mainly functions which operate on more than one scantable
2093
2094            average_time    - return the (weighted) time average
2095                              of a list of scans
2096            quotient        - return the on/off quotient
2097            simple_math     - simple mathematical operations on two scantables,
2098                              'add', 'sub', 'mul', 'div'
2099            quotient        - build quotient of the given on and off scans
2100                              (matched pairs and 1 off/n on are valid)
2101            merge           - merge a list of scantables
2102
2103     [Line Catalog]
2104        linecatalog              - a linecatalog wrapper, taking an ASCII or
2105                                   internal format table
2106            summary              - print a summary of the current selection
2107            set_name             - select a subset by name pattern, e.g. '*OH*'
2108            set_strength_limits  - select a subset by line strength limits
2109            set_frequency_limits - select a subset by frequency limits
2110            reset                - unset all selections
2111            save                 - save the current subset to a table (internal
2112                                   format)
2113            get_row              - get the name and frequency from a specific
2114                                   row in the table
2115     [Fitting]
2116        fitter
2117            auto_fit        - return a scan where the function is
2118                              applied to all Beams/IFs/Pols.
2119            commit          - return a new scan where the fits have been
2120                              commited.
2121            fit             - execute the actual fitting process
2122            store_fit       - store the fit parameters in the data (scantable)
2123            get_chi2        - get the Chi^2
2124            set_scan        - set the scantable to be fit
2125            set_function    - set the fitting function
2126            set_parameters  - set the parameters for the function(s), and
2127                              set if they should be held fixed during fitting
2128            set_gauss_parameters - same as above but specialised for individual
2129                                   gaussian components
2130            get_parameters  - get the fitted parameters
2131            plot            - plot the resulting fit and/or components and
2132                              residual
2133    [Plotter]
2134        asapplotter         - a plotter for asap, default plotter is
2135                              called 'plotter'
2136            plot            - plot a scantable
2137            plot_lines      - plot a linecatalog overlay
2138            save            - save the plot to a file ('png' ,'ps' or 'eps')
2139            set_mode        - set the state of the plotter, i.e.
2140                              what is to be plotted 'colour stacked'
2141                              and what 'panelled'
2142            set_selection   - only plot a selected part of the data
2143            set_range       - set a 'zoom' window [xmin,xmax,ymin,ymax]
2144            set_legend      - specify user labels for the legend indeces
2145            set_title       - specify user labels for the panel indeces
2146            set_abcissa     - specify a user label for the abcissa
2147            set_ordinate    - specify a user label for the ordinate
2148            set_layout      - specify the multi-panel layout (rows,cols)
2149            set_colors      - specify a set of colours to use
2150            set_linestyles  - specify a set of linestyles to use if only
2151                              using one color
2152            set_font        - set general font properties, e.g. 'family'
2153            set_histogram   - plot in historam style
2154            set_mask        - set a plotting mask for a specific polarization
2155            text            - draw text annotations either in data or relative
2156                              coordinates
2157            arrow           - draw arrow annotations either in data or relative
2158                              coordinates
2159            axhline,axvline - draw horizontal/vertical lines
2160            axhspan,axvspan - draw horizontal/vertical regions
2161
2162        xyplotter           - matplotlib/pylab plotting functions
2163
2164    [Reading files]
2165        reader              - access rpfits/sdfits files
2166            arrow           - draw arrow annotations either in data or relative
2167                              coordinates
2168            axhline,axvline - draw horizontal/vertical lines
2169            axhspan,axvspan - draw horizontal/vertical regions
2170
2171        xyplotter           - matplotlib/pylab plotting functions
2172
2173    [Reading files]
2174        reader              - access rpfits/sdfits files
2175            open            - attach reader to a file
2176            close           - detach reader from file
2177            read            - read in integrations
2178            summary         - list info about all integrations
2179
2180    [General]
2181        commands            - this command
2182        print               - print details about a variable
2183        list_scans          - list all scantables created bt the user
2184        list_files          - list all files readable by asap (default rpf)
2185        del                 - delete the given variable from memory
2186        range               - create a list of values, e.g.
2187                              range(3) = [0,1,2], range(2,5) = [2,3,4]
2188        help                - print help for one of the listed functions
2189        execfile            - execute an asap script, e.g. execfile('myscript')
2190        list_rcparameters   - print out a list of possible values to be
2191                              put into .asaprc
2192        rc                  - set rc parameters from within asap
2193        mask_and,mask_or,
2194        mask_not            - boolean operations on masks created with
2195                              scantable.create_mask
2196\end{verbatim}
2197
2198\subsection{ASCII output format}
2199
2200\subsection{.asaprc settings}
2201\index{.asaprc}
2202\asaprc{verbose}{{\bf True}/False}{Print verbose output, good to disable in scripts}
2203
2204\asaprc{insitu}{{\bf True}/False}{Apply operations on the input
2205scantable or return new one}
2206
2207\asaprc{useplotter}{{\bf True}/False}{Preload a default plotter}
2208
2209\asaprc{plotter.gui}{{\bf True}/False}{Do we want a GUI or plot to a
2210file}
2211
2212\asaprc{plotter.stacking}{{\bf Pol} Beam IF Scan Time}{Default mode for
2213colour stacking}
2214
2215\asaprc{plotter.panelling}{Pol Beam IF {\bf Scan} Time}{Default mode
2216for panelling}
2217
2218\asaprc{plotter.ganged}{{\bf True}/False}{Push panels together, to
2219share axislabels}
2220
2221\asaprc{plotter.decimate}{True/{\bf False}}{Decimate the number of
2222points plotted by a factor of nchan/1024}
2223
2224\asaprc{plotter.histogram}{True/{\bf False}}{Plot spectrum using
2225histogram rather than lines.}
2226
2227\asaprc{plotter.colours}{}{Set default colours for plotting}
2228
2229\asaprc{plotter.colours}{}{Set default line styles}
2230
2231\asaprc{plotter.papersze}{{\bf A4}}{}
2232
2233% scantable
2234\asaprc{scantable.save}{{\bf ASAP} SDFITS FITS ASCII MS2}{Default output
2235format when saving}
2236
2237\asaprc{scantable.autoaverage}{{\bf True}/False}{Auto averaging on
2238read}
2239
2240\asaprc{scantable.freqframe}{{\bf LSRK} TOPO BARY etc}{default
2241frequency frame to set when function scantable.set\_freqframe is
2242called or the data is imported}
2243
2244\asaprc{scantable.verbosesummary}{True/{\bf False}}{Control the level
2245of information printed by summary}
2246
2247\asaprc{scantable.storage}{{\bf memory}/disk}{Storage of scantables in
2248memory of via based disk tables}
2249
2250\subsection{Installation}
2251
2252\index{Installation}ASAP depends on a number of third-party libraries which you must
2253have installed before attempting to build ASAP. These are:
2254
2255\begin{itemize}
2256\item AIPS++
2257\item Boost
2258\item Matplotlib
2259\item python/ipython
2260\end{itemize}
2261
2262Debian Linux is currently supported and we intend also
2263to support other popular Linux flavours, Solaris and Mac.
2264
2265Of the dependencies, AIPS++ is the most complex to install.
2266
2267\printindex
2268
2269\end{document}
2270
Note: See TracBrowser for help on using the repository browser.