source: branches/Release12/doc/cookbook.tex@ 763

Last change on this file since 763 was 763, checked in by phi196, 19 years ago

Updates for 1.2 release

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