[534] | 1 | \documentclass[11pt]{article} |
---|
| 2 | \usepackage{a4} |
---|
[763] | 3 | \usepackage{calc} |
---|
[534] | 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 | |
---|
[763] | 15 | \title{ATNF Spectral Analysis Package\\User Guide } |
---|
[534] | 16 | \author{Chris Phillips} |
---|
| 17 | |
---|
| 18 | |
---|
| 19 | \newcommand{\cmd}[1]{{\tt #1}} |
---|
| 20 | |
---|
[763] | 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 | |
---|
[534] | 27 | \begin{document} |
---|
| 28 | |
---|
| 29 | \maketitle |
---|
| 30 | |
---|
| 31 | \section{Introduction} |
---|
| 32 | |
---|
[544] | 33 | ASAP is a single dish spectral line processing package currently being |
---|
| 34 | developed by the ATNF. It is intended to process data from all ATNF |
---|
[763] | 35 | antennas, and can probably be used for other antennas if they can |
---|
[544] | 36 | produce ``Single Dish FITS'' format. It is based on the AIPS++ |
---|
| 37 | package. |
---|
| 38 | |
---|
[534] | 39 | %\section{Documentation Standards} |
---|
| 40 | |
---|
[738] | 41 | %In most of the examples in this document, it has been assumed that the |
---|
[534] | 42 | |
---|
[544] | 43 | \section{Installation and Running} |
---|
[534] | 44 | |
---|
[738] | 45 | Currently there are installations running on Linux machines at |
---|
[534] | 46 | |
---|
| 47 | \begin{itemize} |
---|
| 48 | \item Epping - use hosts {\tt draco} or {\tt hydra} |
---|
| 49 | \item Narrabri - use host {\tt kaputar} |
---|
[537] | 50 | \item Parkes - use host {\tt bourbon} |
---|
[534] | 51 | \item Mopra - use host {\tt minos} |
---|
| 52 | \end{itemize} |
---|
| 53 | |
---|
[763] | 54 | To start asap log onto one of these Linux hosts and enter |
---|
[534] | 55 | |
---|
| 56 | \begin{verbatim} |
---|
| 57 | > cd /my/data/directory |
---|
| 58 | > asap |
---|
| 59 | \end{verbatim} |
---|
| 60 | |
---|
[544] | 61 | This starts the ASAP. To quit, you need to type \verb+^+-d |
---|
| 62 | (control-d). |
---|
[534] | 63 | |
---|
| 64 | \section{Interface} |
---|
| 65 | |
---|
| 66 | ASAP is written in C++ and python. The user interface uses the |
---|
| 67 | ``ipython'' interactive shell, which is a simple interactive interface |
---|
| 68 | to python. The user does not need to understand python to use this, |
---|
| 69 | but certain aspects python affect what the user can do. The current |
---|
| 70 | interface is object oriented. In the future, we will build a |
---|
| 71 | functional (non object oriented) shell on top of this to ease |
---|
| 72 | interactive use. |
---|
| 73 | |
---|
| 74 | \subsection {Integer Indices are 0-relative} |
---|
| 75 | |
---|
| 76 | Please note, all integer indices in ASAP and iPython are {\bf 0-relative}. |
---|
| 77 | |
---|
| 78 | \subsection{Objects} |
---|
| 79 | |
---|
| 80 | The ASAP interface is based around a number of ``objects'' which the |
---|
| 81 | user deals with. Objects range from the data which have been read from |
---|
| 82 | disk, to tools used for fitting functions to the data. The following |
---|
| 83 | main objects are used : |
---|
| 84 | |
---|
| 85 | \begin{itemize} |
---|
[544] | 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 |
---|
[534] | 91 | into a scantable object. |
---|
| 92 | \end{itemize} |
---|
| 93 | |
---|
[738] | 94 | There can be many objects of the same type. Each object is referred to |
---|
[534] | 95 | by a variable name made by the user. The name of this variable is not |
---|
[763] | 96 | important and can be set to whatever the user prefers (i.e. ``s'' and |
---|
[534] | 97 | ``ParkesHOH-20052002'' are equivalent). However, having a simple and |
---|
| 98 | consistent naming convention will help you a lot. |
---|
| 99 | |
---|
[544] | 100 | \subsection{Member Functions (functions)} |
---|
[534] | 101 | |
---|
| 102 | Following the object oriented approach, objects have associated |
---|
| 103 | ``member functions'' which can either be used to modify the data in |
---|
| 104 | some way or change global properties of the object. In this document |
---|
| 105 | member functions will be referred to simply as functions. From the |
---|
[538] | 106 | command line, the user can execute these functions using the syntax: |
---|
[534] | 107 | \begin{verbatim} |
---|
| 108 | ASAP> out = object.function(arguments) |
---|
| 109 | \end{verbatim} |
---|
| 110 | |
---|
| 111 | Where \cmd{out} is the name of the returned variable (could be a new |
---|
[544] | 112 | scantable 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} |
---|
| 115 | is a list of arguments to the function. The arguments can be provided |
---|
| 116 | either though position or \cmd{name=}. A mix of the two can be used. |
---|
| 117 | E.g. |
---|
[534] | 118 | |
---|
| 119 | \begin{verbatim} |
---|
| 120 | ASAP> av = scans(msk,weight='tsys') |
---|
| 121 | ASAP> av = scans(mask=msk,weight='tsys') |
---|
[763] | 122 | ASAP> av = scans(msk,tsys) |
---|
[544] | 123 | ASAP> scans.polybaseline(mask=msk, order=0, insitu=True) |
---|
[534] | 124 | ASAP> scans.polybaseline(msk,0,True) |
---|
| 125 | ASAP> scans.polybaseline(mask, insitu=True) |
---|
| 126 | \end{verbatim} |
---|
| 127 | |
---|
| 128 | \subsection{Global Functions} |
---|
| 129 | |
---|
[544] | 130 | It does not make sense to implement some functions as member |
---|
| 131 | functions, typically functions which operate on more than one |
---|
| 132 | scantable (e.g. time averaging of many scans). These functions will |
---|
| 133 | always be referred to as global functions. |
---|
[534] | 134 | |
---|
[538] | 135 | \subsection{Interactive environment} |
---|
[534] | 136 | |
---|
[763] | 137 | ipython has a number of useful interactive features and a few things |
---|
| 138 | to be aware of for the new user. |
---|
[534] | 139 | |
---|
| 140 | \subsubsection{String completion} |
---|
| 141 | |
---|
| 142 | Tab completion is enabled for all function names. If you type the |
---|
[544] | 143 | first few letters of a function name, then type {\tt <TAB>} the |
---|
| 144 | function name will be auto completed if it is un-ambiguous, or a list |
---|
| 145 | of possibilities will be given. Auto-completion works for the user |
---|
| 146 | object names as well as function names. It does not work for |
---|
| 147 | filenames, nor for function arguments. |
---|
[534] | 148 | |
---|
| 149 | Example |
---|
| 150 | \begin{verbatim} |
---|
| 151 | ASAP> scans = scantable('MyData.rpf') |
---|
| 152 | ASAP> scans.se<TAB> |
---|
| 153 | scans.set_cursor scans.set_freqframe scans.set_unit scans.setpol |
---|
[738] | 154 | scans.set_doppler scans.set_instrument scans.setbeam |
---|
| 155 | scans.set_fluxunit scans.set_restfreqs scans.setif |
---|
[534] | 156 | ASAP> scans.set_in<TAB> |
---|
| 157 | ASAP> scans.set_instrument |
---|
| 158 | \end{verbatim} |
---|
| 159 | |
---|
[544] | 160 | \subsubsection{Leading Spaces} |
---|
| 161 | |
---|
| 162 | Python uses leading space to mark blocks of code. This means that it |
---|
| 163 | you start a command line with a space, the command generally will |
---|
| 164 | fail with an syntax error. |
---|
| 165 | |
---|
[763] | 166 | \subsubsection{Variable Names} |
---|
| 167 | |
---|
| 168 | During normal data processing, the user will have to create named |
---|
| 169 | variables to hold spectra etc. These must conform to the normal python |
---|
| 170 | syntax, specifically they cannot contain ``special'' characters such |
---|
| 171 | as \@ \$ etc and cannot start with a number (but can contain numbers). |
---|
| 172 | |
---|
[534] | 173 | \subsubsection{Unix Interaction} |
---|
| 174 | |
---|
[544] | 175 | Basic unix shell commands (\cmd{pwd}, \cmd{ls}, \cmd{cd} etc) can be |
---|
| 176 | issued from within ASAP. This allows the user to do things like look |
---|
| 177 | at files in the current directory. The shell command ``\cmd{cd}'' |
---|
| 178 | works within ASAP, allowing the user to change between data |
---|
| 179 | directories. Unix programs cannot be run this way, but the shell |
---|
| 180 | escape ``$!$'' can be used to run arbitrary programs. E.g. |
---|
[534] | 181 | |
---|
| 182 | \begin{verbatim} |
---|
| 183 | ASAP> pwd |
---|
| 184 | ASAP> ls |
---|
| 185 | ASAP> ! mozilla& |
---|
| 186 | \end{verbatim} |
---|
| 187 | |
---|
| 188 | \subsection{Help} |
---|
| 189 | |
---|
[538] | 190 | ASAP has built in help for all functions. To get a list of functions type: |
---|
[534] | 191 | |
---|
[538] | 192 | \begin{verbatim} |
---|
| 193 | ASAP> commands |
---|
| 194 | \end{verbatim} |
---|
| 195 | |
---|
| 196 | To get help on specific functions, the built in help needs to be given |
---|
| 197 | the 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 |
---|
[544] | 207 | \end{verbatim} |
---|
[538] | 208 | |
---|
[544] | 209 | Global functions just need their name |
---|
[538] | 210 | |
---|
[544] | 211 | \begin{verbatim} |
---|
[738] | 212 | ASAP> help average_time |
---|
[538] | 213 | \end{verbatim} |
---|
| 214 | |
---|
| 215 | Note that if you just type \cmd{help} the internal ipython help is |
---|
| 216 | invoked, which is probably {\em not} what you want. Type \verb+^+-d |
---|
| 217 | (control-d) to escape from this. |
---|
| 218 | |
---|
[738] | 219 | \subsection{Customisation - .asaprc} |
---|
[534] | 220 | |
---|
[544] | 221 | ASAP use an \cmd{.asaprc} file to control the user's preference of |
---|
[538] | 222 | default values for various functions arguments. This includes the |
---|
[544] | 223 | defaults for arguments such as \cmd{insitu}, scantable \cmd{freqframe} |
---|
[538] | 224 | and the plotters \cmd{set\_mode} values. The help on individual |
---|
[544] | 225 | functions says which arguments can be set default values from the |
---|
[538] | 226 | \cmd{.asaprc} file. To get a sample contents for the \cmd{.asaprc} |
---|
| 227 | file use then command \cmd{list\_rcparameters}. |
---|
[534] | 228 | |
---|
[538] | 229 | Common values include: |
---|
| 230 | \begin{verbatim} |
---|
| 231 | # apply operations on the input scantable or return new one |
---|
| 232 | insitu : False |
---|
| 233 | |
---|
[738] | 234 | # default output format when saving scantable |
---|
[538] | 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 | |
---|
[763] | 245 | For a complete list of \cmd{.asaprc} values, see the appendix. |
---|
| 246 | |
---|
[534] | 247 | \section{Scantables} |
---|
| 248 | |
---|
| 249 | \subsection {Description} |
---|
| 250 | |
---|
| 251 | \subsubsection {Basic Structure} |
---|
| 252 | |
---|
| 253 | ASAP data handling works on objects called scantables. A scantable |
---|
| 254 | holds your data, and also provides functions to operate |
---|
| 255 | upon it. |
---|
| 256 | |
---|
| 257 | The building block of a scantable is an integration, which is a single |
---|
| 258 | row of a scantable. Each row contains spectra for each beam, IF and |
---|
| 259 | polarisation. For example Parkes multibeam data would contain many |
---|
| 260 | beams, one IF and 2-4 polarisations, while the new Mopra 8-GHz |
---|
| 261 | filterbank will eventually produce one beam, many IFs, and 2-4 |
---|
| 262 | polarisations. |
---|
| 263 | |
---|
| 264 | A collection of sequential integrations (rows) for one source is termed |
---|
| 265 | a scan (and each scan has a unique numeric identifier, the ScanID). A |
---|
| 266 | scantable is then a collection of one or more scans. If you have |
---|
| 267 | scan-averaged your data in time, then each scan would hold just one |
---|
| 268 | (averaged) integration. |
---|
| 269 | |
---|
| 270 | Many of the functions which work on scantables can either return a |
---|
| 271 | new scantable with modified data or change the scantable insitu. Which |
---|
| 272 | method is used depends on the users preference. The default can be |
---|
| 273 | changed via the {\tt .asaprc} resource file. |
---|
| 274 | |
---|
| 275 | \subsubsection {Contents} |
---|
| 276 | |
---|
[537] | 277 | A scantable has header information and data (a scantable is actually an AIPS++ |
---|
| 278 | Table and it is stored in Memory when you are manipulating it with ASAP. |
---|
[534] | 279 | You can store it to disk and then browse it with the AIPS++ |
---|
[537] | 280 | Table browser if you know how to do that !). |
---|
[534] | 281 | |
---|
| 282 | The data are stored in columns (the length of a column is the number of |
---|
[738] | 283 | rows/integrations of course). |
---|
[534] | 284 | |
---|
| 285 | Two important columns are those that describe the frequency setup. We mention |
---|
[538] | 286 | them explicitly here because you need to be able to understand the presentation |
---|
[534] | 287 | of the frequency information and possibly how to manipulate it. |
---|
| 288 | |
---|
| 289 | These columns are called FreqID and RestFreqID. They contain indices, for |
---|
| 290 | each IF, pointing into tables with all of the frequency information for that |
---|
| 291 | integration. More on these below when we discuss the \cmd{summary} function |
---|
| 292 | in the next subsection. |
---|
| 293 | |
---|
| 294 | There are of course many other columns which contain the actual spectra, |
---|
| 295 | the flags, the Tsys, the source names and so on, but those are a little |
---|
| 296 | more transparently handled. |
---|
| 297 | |
---|
| 298 | \subsection{Management} |
---|
| 299 | |
---|
| 300 | During processing it is possible to create a large number of scan |
---|
| 301 | tables. These all consume memory, so it is best to periodically remove |
---|
| 302 | unneeded scan tables. Use \cmd{list\_scans} to print a list of all |
---|
| 303 | scantables and \cmd{del} to remove unneeded ones. |
---|
| 304 | |
---|
| 305 | Example: |
---|
| 306 | |
---|
| 307 | \begin{verbatim} |
---|
| 308 | ASAP> list_scans |
---|
| 309 | The user created scantables are: |
---|
| 310 | ['s', 'scans', 'av', 's2', 'ss'] |
---|
| 311 | |
---|
[738] | 312 | ASAP> del s2 |
---|
[534] | 313 | ASAP> del ss |
---|
| 314 | \end{verbatim} |
---|
| 315 | |
---|
| 316 | There is also a function \cmd{summary} to list a summary of the scantable. |
---|
| 317 | You will find this very useful. |
---|
| 318 | |
---|
| 319 | Example: |
---|
| 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 |
---|
[544] | 325 | |
---|
| 326 | # Equivalent to brief summary function call |
---|
[738] | 327 | ASAP> print scan |
---|
[534] | 328 | \end{verbatim} |
---|
| 329 | |
---|
| 330 | Most of what the \cmd{summary} function prints out is obvious. However, |
---|
[738] | 331 | it also prints out the FreqIDs and RestFreqIDs to which we alluded above. |
---|
[534] | 332 | These are the last column of the listing. |
---|
| 333 | |
---|
| 334 | The summary function gives you a scan-based summary. So it lists all of |
---|
| 335 | the FreqIDs and RestFreqIDs that it encountered for each scan. If you'd |
---|
| 336 | like to see what each FreqID actually means, then set the verbose |
---|
[738] | 337 | argument to True and the frequency table will be listed at the end. |
---|
[534] | 338 | FreqID of 3 say, refers to the fourth row of the frequency table (ASAP |
---|
| 339 | is 0-relative). The list of rest frequencies, to which the RestFreqIDs |
---|
| 340 | refer, is always listed. |
---|
| 341 | |
---|
[544] | 342 | %You can copy one scantable to another with the \cmd{copy} function. |
---|
[534] | 343 | |
---|
[544] | 344 | %Example: |
---|
[534] | 345 | |
---|
[544] | 346 | %\begin{verbatim} |
---|
| 347 | % ASAP> scans = scantable('MyData.rpf') |
---|
| 348 | % ASAP> scan2 = scans.copy() |
---|
| 349 | %\end{verbatim} |
---|
[534] | 350 | |
---|
| 351 | \subsection{State} |
---|
| 352 | |
---|
| 353 | Each scantable contains "state"; these are properties applying to all |
---|
[738] | 354 | of the data in the scantable. |
---|
[534] | 355 | |
---|
| 356 | Examples are the selection of beam, IF and polarisation, spectral unit |
---|
[544] | 357 | (e.g. km/s) frequency reference frame (e.g. BARY) and velocity Doppler |
---|
[534] | 358 | type (e.g. RADIO). |
---|
| 359 | |
---|
| 360 | \subsubsection{Units, Doppler and Frequency Reference Frame} |
---|
| 361 | |
---|
| 362 | The information describing the frequency setup for each integration |
---|
| 363 | is stored fundamentally in frequency in the reference frame |
---|
[738] | 364 | of observation (E.g. TOPO). |
---|
[534] | 365 | |
---|
[544] | 366 | When 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. |
---|
| 368 | This is important, for example, when you are displaying the data or |
---|
| 369 | fitting to it. |
---|
[534] | 370 | |
---|
| 371 | For units, the user has the choice of frequency, velocity or channel. |
---|
| 372 | The \cmd{set\_unit} function is used to set the current unit for a |
---|
| 373 | scantable. All functions will (where relevant) work with the selected |
---|
| 374 | unit until this changes. This is mainly important for fitting (the fits |
---|
[738] | 375 | can be computed in any of these units), plotting and mask creation. |
---|
[534] | 376 | |
---|
[544] | 377 | The velocity definition can be changed with the \cmd{set\_doppler} |
---|
| 378 | function, and the frequency reference frame can be changed with the |
---|
[534] | 379 | \cmd{set\_freqframe} function. |
---|
| 380 | |
---|
| 381 | Example 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 | |
---|
| 394 | ASAP reads the line rest frequency from the RPFITS file when reading |
---|
| 395 | the data. The values stored in the RPFITS file are not always correct |
---|
| 396 | and so there is a function \cmd{set\_restfreq} to set the rest frequencies. |
---|
| 397 | |
---|
| 398 | For each integration, there is a rest-frequency per IF (the rest |
---|
| 399 | frequencies are just stored as a list with an index into them). |
---|
| 400 | There are a few ways to set the rest frequencies with this function. |
---|
| 401 | |
---|
| 402 | If you specify just one rest frequency, then it is selected for the |
---|
| 403 | specified source and IF and added to the list of rest frequencies. |
---|
| 404 | |
---|
| 405 | \begin{verbatim} |
---|
[538] | 406 | # Select for specified source/IF |
---|
[738] | 407 | ASAP> scans.set_restfreqs(freqs=1.667359e9, source='NGC253', theif=0) |
---|
[538] | 408 | |
---|
| 409 | # Select for all sources and IFs |
---|
[738] | 410 | ASAP> scans.set_restfreqs(freqs=1.667359e9) |
---|
[534] | 411 | \end{verbatim} |
---|
| 412 | |
---|
| 413 | |
---|
| 414 | If you specify a list of frequencies, then it must be of length the |
---|
| 415 | number of IFs. Regardless of the source, the rest frequency will be set |
---|
| 416 | for each IF to the corresponding value in the provided list. The |
---|
| 417 | internally stored list of rest frequencies will be replaced by this |
---|
| 418 | list. |
---|
| 419 | |
---|
| 420 | |
---|
| 421 | \begin{verbatim} |
---|
[763] | 422 | # Set rest frequency for all IFs |
---|
| 423 | ASAP> scans.set_restfreqs(freqs=[1.6654018e9,1.667359e9,]) |
---|
[538] | 424 | |
---|
[534] | 425 | \end{verbatim} |
---|
| 426 | |
---|
| 427 | In both of the above modes, you can also specify the rest frequencies via |
---|
| 428 | names in a known list rather than by their values. |
---|
| 429 | |
---|
| 430 | Examples: |
---|
| 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 | |
---|
| 440 | Data selection is currently fairly limited. This will be improved in |
---|
[738] | 441 | the future. |
---|
[534] | 442 | |
---|
| 443 | |
---|
| 444 | \subsubsection{Cursor} |
---|
| 445 | |
---|
| 446 | Generally the user will want to run functions on all rows in a |
---|
| 447 | scantable. This allows very fast reduction of data. There are situations |
---|
| 448 | when functions should only operate on specific elements of the spectra. This |
---|
| 449 | is handled by the scantable cursor, which allows the user to select a |
---|
| 450 | single beam, IF and polarisation combination. |
---|
| 451 | |
---|
| 452 | Example : |
---|
| 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 | |
---|
| 461 | Most functions work on all rows of a scan table. Exceptions are the |
---|
| 462 | fitter and plotter. If you wish to only operate on a selected set of |
---|
[538] | 463 | scantable rows, use the \cmd{get\_scan} function to copy the rows into |
---|
[534] | 464 | a new scantable. |
---|
| 465 | |
---|
| 466 | \subsubsection{Allaxes} |
---|
| 467 | |
---|
| 468 | Many functions have an \cmd{allaxes} option which controls whether the |
---|
| 469 | function will operate on all elements within a scantable row, or just |
---|
| 470 | those selected with the current cursor. The default is taken from the |
---|
| 471 | users {\tt .asaprc} file. |
---|
| 472 | |
---|
| 473 | \subsubsection{Masks} |
---|
| 474 | |
---|
| 475 | Many tasks (fitting, baseline subtraction, statistics etc) should only |
---|
| 476 | be run on range of channels. Depending on the current ``unit'' setting |
---|
| 477 | this range is set directly as channels, velocity or frequency |
---|
| 478 | ranges. Internally these are converted into a simple boolean mask for |
---|
| 479 | each channel of the abscissa. This means that if the unit setting is |
---|
| 480 | later changed, previously created mask are still valid. (This is not |
---|
| 481 | true for functions which change the shape or shift the frequency axis). |
---|
| 482 | You create masks with the function \cmd{create\_mask} and this specified |
---|
| 483 | the channels to be included in the selection. |
---|
| 484 | |
---|
| 485 | When setting the mask in velocity, the conversion from velocity |
---|
| 486 | to channels is based on the current cursor setting, selected row and |
---|
[544] | 487 | selected frequency reference frame. |
---|
[534] | 488 | |
---|
| 489 | Example : |
---|
| 490 | \begin{verbatim} |
---|
| 491 | |
---|
| 492 | # Select channel range for baselining |
---|
| 493 | ASAP> scans.set_unit('channels') |
---|
[544] | 494 | ASAP> msk = scans.create_mask([100,400],[600,800]) |
---|
[738] | 495 | |
---|
[534] | 496 | # Select velocity range for fitting |
---|
| 497 | ASAP> scans.set_unit('km/s') |
---|
[544] | 498 | ASAP> msk = scans.create_mask([-30,-10]) |
---|
[534] | 499 | \end{verbatim} |
---|
| 500 | |
---|
[544] | 501 | Sometimes it is more convenient to specify the channels to be |
---|
| 502 | excluded, rather included. You can do this with the ``invert'' |
---|
| 503 | argument. |
---|
[534] | 504 | |
---|
| 505 | Example : |
---|
| 506 | \begin{verbatim} |
---|
| 507 | ASAP> scans.set_unit('channels') |
---|
[738] | 508 | ASAP> msk = scans.create_mask([0,100],[900-1023], invert=True) |
---|
[534] | 509 | \end{verbatim} |
---|
| 510 | |
---|
[544] | 511 | By default \cmd{create\_mask} uses the frequency setup of the first row |
---|
| 512 | to convert velocities into a channel mask. If the rows in the data |
---|
| 513 | cover different velocity ranges, the scantable row to use should be |
---|
| 514 | specified: |
---|
| 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 | |
---|
[534] | 521 | Because the mask is stored in a simple python variable, the users is |
---|
| 522 | able to combine masks using simple arithmetic. To create a mask |
---|
| 523 | excluding the edge channels, a strong maser feature and a birdie in |
---|
| 524 | the 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 | |
---|
| 538 | Data can be loaded in one of two ways; using the reader object or via |
---|
| 539 | the scantable constructor. The scantable method is simpler but the |
---|
| 540 | reader allow the user more control on what is read. |
---|
| 541 | |
---|
| 542 | \subsection{Scantable constructor} |
---|
| 543 | |
---|
| 544 | This loads all of the data from filename into the scantable object scans |
---|
| 545 | and averages all the data within a scan (i.e. the resulting scantable |
---|
| 546 | will have one row per scan). The recognised input file formats are |
---|
| 547 | RPFITS, SDFITS (singledish fits), ASAP's scantable format and aips++ |
---|
[738] | 548 | MeasurementSet2 format. |
---|
[534] | 549 | |
---|
| 550 | |
---|
| 551 | Example usage: |
---|
| 552 | |
---|
| 553 | \begin{verbatim} |
---|
| 554 | ASAP> scan = scantable('2004-11-23_1841-P484.rpf') |
---|
[544] | 555 | |
---|
| 556 | # Don't scan average the data |
---|
| 557 | ASAP> scan = scantable('2004-11-23_1841-P484.rpf', average=False) |
---|
[534] | 558 | \end{verbatim} |
---|
| 559 | |
---|
| 560 | |
---|
| 561 | \subsection{Reader object} |
---|
| 562 | |
---|
| 563 | For more control when reading data into ASAP, the reader object should |
---|
| 564 | be used. This has the option of only reading in a range of integrations |
---|
| 565 | and does not perform any scan averaging of the data, allowing analysis |
---|
| 566 | of the individual integrations. Note that due to limitation of the |
---|
| 567 | RPFITS library, only one reader object can be open at one time reading |
---|
| 568 | RPFITS files. To read multiple RPFITS files, the old reader must be |
---|
| 569 | destroyed before the new file is opened. However, multiple readers can |
---|
[738] | 570 | be created and attached to SDFITS files. |
---|
[534] | 571 | |
---|
| 572 | |
---|
| 573 | Example usage: |
---|
| 574 | |
---|
| 575 | \begin{verbatim} |
---|
| 576 | ASAP> r = reader('2003-03-16_082048_t0002.rpf') |
---|
[738] | 577 | ASAP> r.summary |
---|
[534] | 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 | |
---|
| 585 | In the following section, a simple data reduction to form a quotient |
---|
[544] | 586 | spectrum 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} |
---|
| 588 | default value from \cmd{True}. |
---|
[534] | 589 | |
---|
| 590 | %\subsection{Editing} |
---|
| 591 | |
---|
| 592 | %How and when? |
---|
[738] | 593 | \subsection{Auto quotient} |
---|
[763] | 594 | Quotients can be computed ``automatically''. This requires the data to |
---|
| 595 | have matching source/reference pairs or one reference for multiple |
---|
| 596 | sources. |
---|
[534] | 597 | |
---|
[738] | 598 | \begin{verbatim} |
---|
| 599 | ASAP> q = s.auto_quotient() |
---|
| 600 | \end{verbatim} |
---|
| 601 | |
---|
| 602 | If this is not sufficient the following alternative method can be used. |
---|
| 603 | |
---|
[534] | 604 | \subsection{Separate reference and source observations} |
---|
| 605 | |
---|
| 606 | Most data from ATNF observatories distinguishes on and off source data |
---|
| 607 | using the file name. This makes it easy to create two scantables with |
---|
| 608 | the source and reference data. As long as there was exactly one |
---|
| 609 | reference observation for each on source observation for following |
---|
| 610 | method will work. |
---|
| 611 | |
---|
| 612 | For 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 | |
---|
| 618 | For 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 | |
---|
| 626 | Use the quotient function |
---|
| 627 | |
---|
| 628 | \begin{verbatim} |
---|
| 629 | ASAP> q = s.quotient(r) |
---|
| 630 | \end{verbatim} |
---|
| 631 | |
---|
| 632 | This uses the rows in scantable \cmd{r} as reference spectra for the |
---|
| 633 | rows 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 |
---|
| 635 | the same number of rows. By default the quotient spectra is calculated |
---|
[544] | 636 | to preserve continuum emission. If you wish to remove the continuum |
---|
[534] | 637 | contribution, 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 | |
---|
| 645 | If you have observed the source with multiple source/reference cycles you |
---|
| 646 | will want to scan-average the quotient spectra together. |
---|
| 647 | |
---|
| 648 | \begin{verbatim} |
---|
| 649 | ASAP> av = average_time(q) |
---|
| 650 | \end{verbatim} |
---|
| 651 | |
---|
[544] | 652 | If for some you want to average multiple sets of scantables together |
---|
| 653 | you can: |
---|
[534] | 654 | |
---|
| 655 | \begin{verbatim} |
---|
| 656 | ASAP> av = average_time(q1, q2, q3) |
---|
| 657 | \end{verbatim} |
---|
| 658 | |
---|
[544] | 659 | The default is to use integration time weighting. The alternative is |
---|
| 660 | to use none, variance , Tsys weighting or Tsys \& integration time. |
---|
[534] | 661 | |
---|
[544] | 662 | \begin{verbatim} |
---|
| 663 | ASAP> av = average_time(q, weight='tintsys') |
---|
| 664 | \end{verbatim} |
---|
| 665 | |
---|
[534] | 666 | To use variance based weighting, you need to supply a mask saying which |
---|
| 667 | channel range you want it to calculate the variance from. |
---|
| 668 | |
---|
| 669 | \begin{verbatim} |
---|
[544] | 670 | ASAP> msk = scans.create_mask([200,400],[600,800]) |
---|
| 671 | ASAP> av = average_time(scans, mask=msk, weight='var') |
---|
[534] | 672 | \end{verbatim} |
---|
| 673 | |
---|
| 674 | \subsection{Baseline fitting} |
---|
| 675 | |
---|
| 676 | To make a baseline fit, you must first create a mask of channels to |
---|
[738] | 677 | use in the baseline fit. |
---|
[534] | 678 | |
---|
| 679 | \begin{verbatim} |
---|
| 680 | ASAP> msk = scans.create_mask([100,400],[600,900]) |
---|
[738] | 681 | ASAP> scans.poly_baseline(msk, 1) |
---|
[534] | 682 | \end{verbatim} |
---|
| 683 | |
---|
| 684 | This will fit a first order polynomial to the selected channels and subtract |
---|
| 685 | this polynomial from the full spectra. |
---|
| 686 | |
---|
| 687 | \subsubsection{Auto-baselining} |
---|
| 688 | |
---|
| 689 | The function \cmd{auto\_poly\_baseline} can be used to automatically |
---|
| 690 | baseline your data with out having to specify channel ranges for |
---|
| 691 | the line free data. It automatically figures out the line-free |
---|
| 692 | emission and fits a polynomial baseline to that data. The user can use |
---|
| 693 | masks to fix the range of channels or velocity range for the fit as |
---|
[738] | 694 | well as mark the band edge as invalid. |
---|
[534] | 695 | |
---|
| 696 | Simple 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 |
---|
| 703 | the SNR threshold to use to deliminate line emission from |
---|
[548] | 704 | signal. Generally the value of threshold is not too critical, however |
---|
| 705 | making this too large will compromise the fit (as it will include |
---|
| 706 | strong line features) and making it too small will mean it cannot find |
---|
| 707 | enough line free channels. |
---|
[534] | 708 | |
---|
[548] | 709 | |
---|
[534] | 710 | Other 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 | |
---|
| 725 | If you are just interested in the highest SNR for total intensity you |
---|
| 726 | will want to average the parallel polarisations together. |
---|
| 727 | |
---|
| 728 | \begin{verbatim} |
---|
| 729 | ASAP> scans.average_pol() |
---|
| 730 | \end{verbatim} |
---|
| 731 | |
---|
| 732 | \subsection{Calibration} |
---|
| 733 | |
---|
| 734 | For most uses, calibration happens transparently as the input data |
---|
| 735 | contains the Tsys measurements taken during observations. The nominal |
---|
| 736 | ``Tsys'' values may be in Kelvin or Jansky. The user may wish to |
---|
| 737 | supply a Tsys correction or apply gain-elevation and opacity |
---|
| 738 | corrections. |
---|
| 739 | |
---|
| 740 | \subsubsection{Brightness Units} |
---|
| 741 | |
---|
| 742 | RPFITS files to not contain any information as to whether the telescope |
---|
| 743 | calibration was in units of Kelvin or Janskys. On reading the data a |
---|
| 744 | default value is set depending on the telescope and frequency of |
---|
| 745 | observation. If this default is incorrect (you can see it in the |
---|
| 746 | listing from the \cmd{summary} function) the user can either override |
---|
| 747 | this 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 | |
---|
| 758 | Sometime the nominal Tsys measurement at the telescope is wrong due to |
---|
| 759 | an incorrect noise diode calibration. This can easily be corrected for |
---|
| 760 | with the scale function. By default, \cmd{scale} only scans the |
---|
| 761 | spectra and not the corresponding Tsys. |
---|
| 762 | |
---|
| 763 | \begin{verbatim} |
---|
[738] | 764 | ASAP> scans.scale(1.05, tsys=True) |
---|
[534] | 765 | \end{verbatim} |
---|
| 766 | |
---|
| 767 | \subsubsection{Unit Conversion} |
---|
| 768 | |
---|
| 769 | To convert measurements in Kelvin to Jy (and vice versa) the global |
---|
| 770 | function \cmd{convert\_flux} is needed. This converts and scales the data |
---|
| 771 | from K to Jy or vice-versa depending on what the current brightness unit is |
---|
| 772 | set to. The function knows the basic parameters for some frequencies |
---|
| 773 | and telescopes, but the user may need to supply the aperture |
---|
| 774 | efficiency, 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 | |
---|
| 785 | As higher frequencies (particularly $>$20~GHz) it is important to make |
---|
[738] | 786 | corrections for atmospheric opacity and gain-elevation effects. |
---|
[534] | 787 | |
---|
[763] | 788 | {\em Note that currently the elevation is not written correctly into |
---|
| 789 | Tidbinbilla rpfits files. This means that gain-elevation and opacity |
---|
| 790 | corrections will not work until a work around is implemented.} |
---|
| 791 | |
---|
[544] | 792 | Gain-elevation curves for some telescopes and frequencies are known to |
---|
| 793 | ASAP (currently only for Tidbinbilla at 20~GHz). In these cases making |
---|
[534] | 794 | gain-corrections is simple. If the gain curve for your data is not |
---|
[544] | 795 | known, the user can supply either a gain polynomial or text file |
---|
[534] | 796 | tabulating gain factors at a range of elevations (see \cmd{help |
---|
[544] | 797 | scantable.gain\_el}). |
---|
[534] | 798 | |
---|
| 799 | Examples: |
---|
| 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 | |
---|
| 806 | Opacity corrections can be made with the global function |
---|
| 807 | \cmd{opacity}. This should work on all telescopes as long as a |
---|
[544] | 808 | measurement of the opacity factor was made during the observation. |
---|
[534] | 809 | |
---|
| 810 | \begin{verbatim} |
---|
| 811 | ASAP> scans.opacity(0.083) |
---|
| 812 | \end{verbatim} |
---|
| 813 | |
---|
| 814 | Note that at 3~mm Mopra uses a paddle wheel for Tsys calibration, |
---|
| 815 | which takes opacity effects into account (to first order). ASAP |
---|
[544] | 816 | opacity corrections should not be used for Mopra 3-mm data. |
---|
[534] | 817 | |
---|
| 818 | \subsection{Frequency Frame Alignment} |
---|
| 819 | |
---|
[544] | 820 | When time averaging a series of scans together, it is possible that |
---|
| 821 | the velocity scales are not exactly aligned. This may be for many |
---|
| 822 | reasons such as not Doppler tracking the observations, errors in the |
---|
| 823 | Doppler tracking etc. This mostly affects very long integrations or |
---|
| 824 | integrations averaged together from different days. Before averaging |
---|
| 825 | such data together, they should be frequency aligned using |
---|
| 826 | \cmd{freq\_align}. |
---|
[534] | 827 | |
---|
| 828 | E.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 |
---|
| 837 | separately. This is needed for scan tables containing multiple |
---|
[763] | 838 | sources. However if scan-based Doppler tracking has been made at the |
---|
| 839 | observatory, each row will have a different freqid. In these cases run |
---|
| 840 | with \cmd{perif=True} and all rows of a source will be aligned to the |
---|
| 841 | same frame. In general \cmd{perif=True} will be needed for most |
---|
[534] | 842 | observations as Doppler tracking of some form is made at Parkes, Tid |
---|
| 843 | and Mopra. |
---|
| 844 | |
---|
| 845 | \begin{verbatim} |
---|
| 846 | ASAP> scans.freq_align(perif=True) |
---|
| 847 | \end{verbatim} |
---|
| 848 | |
---|
| 849 | To average together data taken on different days, which are in |
---|
| 850 | different scantables, each scantable must aligned to a common |
---|
| 851 | reference time then the scantables averaged. The simplest way of |
---|
| 852 | doing this is to allow ASAP to choose the reference time for the first |
---|
[738] | 853 | scantable then using this time for the subsequent scantables. |
---|
[534] | 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 | |
---|
| 864 | While it is very useful to have many independent sources within one |
---|
| 865 | scantable, it is often inconvenient for data processing. The |
---|
| 866 | \cmd{get\_scan} function can be used to create a new scantable with a |
---|
| 867 | selection of scans from a scantable. The selection can either be on |
---|
| 868 | the source name, with simple wildcard matching or set of scan ids. |
---|
| 869 | |
---|
| 870 | For 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 |
---|
[538] | 875 | ASAP> ss = scans.get_scan(range(10,20)) # Get the next 10 scans |
---|
[534] | 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 | |
---|
| 888 | To copy a scantable the following does not work: |
---|
| 889 | |
---|
| 890 | \begin{verbatim} |
---|
| 891 | ASAP> ss = scans |
---|
| 892 | \end{verbatim} |
---|
| 893 | |
---|
[544] | 894 | as this just creates a reference to the original scantable. Any |
---|
| 895 | changes made to \cmd{ss} are also seen in \cmd{scans}. To duplicate a |
---|
[534] | 896 | scantable, use the copy function. |
---|
| 897 | |
---|
| 898 | \begin{verbatim} |
---|
| 899 | ASAP> ss = scans.copy |
---|
| 900 | \end{verbatim} |
---|
| 901 | |
---|
| 902 | \section{Data Output} |
---|
| 903 | |
---|
| 904 | ASAP can save scantables in a variety of formats, suitable for reading |
---|
| 905 | into other packages. The formats are: |
---|
| 906 | |
---|
| 907 | \begin{itemize} |
---|
| 908 | \item[ASAP] This is the internal format used for ASAP. It is the only |
---|
[544] | 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. |
---|
[534] | 914 | |
---|
[544] | 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. |
---|
[534] | 918 | |
---|
| 919 | \item[FITS] This uses simple ``image'' fits to save the data, each row |
---|
[544] | 920 | being written to a separate fits file. This format is suitable for |
---|
| 921 | importing the data into CLASS. |
---|
[534] | 922 | |
---|
| 923 | \item[ASCII] A simple text based format suitable for the user to |
---|
| 924 | processing using Perl or, Python, gnuplot etc. |
---|
| 925 | |
---|
| 926 | \item[MS2] Saves the data in an aips++ MeasurementSet V2 format. |
---|
| 927 | You can also access this with the Table browser and other AIPS++ |
---|
| 928 | tools. |
---|
| 929 | |
---|
| 930 | \end{itemize} |
---|
| 931 | |
---|
[738] | 932 | The default output format can be set in the users {\tt .asaprc} file. |
---|
[534] | 933 | Typical 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 | |
---|
[763] | 946 | Scantable spectra can be plotted at any time. An asapplotter object is |
---|
[534] | 947 | used for plotting, meaning multiple plot windows can be active at the |
---|
| 948 | same time. On start up a default asapplotter object is created called |
---|
| 949 | ``plotter''. This would normally be used for standard plotting. |
---|
| 950 | |
---|
[538] | 951 | The plotter, optionally, will run in a multipanel mode and contain |
---|
[534] | 952 | multiple plots per panel. The user must tell the plotter how they want |
---|
| 953 | the data distributed. This is done using the set\_mode function. The |
---|
| 954 | default can be set in the users {\tt .asaprc} file. The units (and frame |
---|
[538] | 955 | etc) of the abscissa will be whatever has previously been set by |
---|
| 956 | \cmd{set\_unit}, \cmd{set\_freqframe} etc. |
---|
[534] | 957 | |
---|
| 958 | Typical 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 | |
---|
| 966 | This will plot multiple polarisation within each plot panel and each |
---|
[544] | 967 | scan row in a separate panel. |
---|
[534] | 968 | |
---|
[538] | 969 | Other possibilities include: |
---|
[534] | 970 | |
---|
| 971 | \begin{verbatim} |
---|
| 972 | # Plot multiple IFs per panel |
---|
| 973 | ASAP> plotter.set_mode(stacking='i',panelling='t') |
---|
[538] | 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 | |
---|
[534] | 984 | \end{verbatim} |
---|
| 985 | |
---|
[538] | 986 | \subsection{Plot Selection} |
---|
| 987 | \label{sec:plotter_cursor} |
---|
| 988 | |
---|
| 989 | The plotter can plot up to 25 panels and stacked spectra per |
---|
| 990 | panel. If you have data larger than this (or for your own sanity) you |
---|
| 991 | need to select a subset of this data. This is particularly true for |
---|
| 992 | multibeam or multi IF data. The plotter \cmd{set\_cursor} function is |
---|
| 993 | used to select a subset of the data. The arguments \cmd{row}, |
---|
[544] | 994 | \cmd{beam} and \cmd{IF} all accept a vector of indices corresponding |
---|
| 995 | to row, beam or IF selection. Only the selected data will be plotted. |
---|
| 996 | To select on polarisation, see section~\ref{sec:polplot}. |
---|
[538] | 997 | |
---|
| 998 | Examples: |
---|
| 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 | |
---|
[544] | 1014 | Note that the plotter cursor selection is independent of the scantable |
---|
| 1015 | cursor. |
---|
[534] | 1016 | |
---|
[544] | 1017 | \subsection{Plot Control} |
---|
| 1018 | |
---|
[534] | 1019 | The plotter window has a row of buttons on the lower left. These can |
---|
| 1020 | be used to control the plotter (mostly for zooming the individual |
---|
| 1021 | plots). 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 |
---|
| 1028 | history of zoom settings. The left arrow sets the plot zoom to the |
---|
| 1029 | previous value. The right arrow returns back again. This allows you, |
---|
| 1030 | for example, to zoom in on one feature then return the plot to how it |
---|
| 1031 | was 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 |
---|
[738] | 1039 | region. Use the plot history to unzoom again. |
---|
[534] | 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 | |
---|
| 1047 | The plotter has a number of functions to describe the layout of the |
---|
| 1048 | plot. These include \cmd{set\_legend}, \cmd{set\_layout} and \cmd{set\_title}. |
---|
| 1049 | |
---|
| 1050 | To 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) |
---|
[544] | 1058 | ASAP> plotter.set_range() # To reset |
---|
[534] | 1059 | \end{verbatim} |
---|
| 1060 | |
---|
[544] | 1061 | Both 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 | |
---|
[738] | 1067 | To save a hardcopy of the current plot, use the save function, e.g. |
---|
[534] | 1068 | |
---|
| 1069 | \begin{verbatim} |
---|
| 1070 | ASAP> plotter.save('myplot.ps') |
---|
| 1071 | \end{verbatim} |
---|
| 1072 | |
---|
| 1073 | \section{Fitting} |
---|
| 1074 | |
---|
| 1075 | Currently multicomponent Gaussian function is available. This is done |
---|
| 1076 | by creating a fitting object, setting up the fit and actually fitting |
---|
| 1077 | the data. Fitting can either be done on a single scantable row/cursor |
---|
| 1078 | selection 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 | |
---|
| 1091 | This auto-guesses the initial values of the fit and works well for data |
---|
| 1092 | without extra confusing features. Note that the fit is performed in |
---|
| 1093 | whatever unit the abscissa is set to. |
---|
| 1094 | |
---|
| 1095 | If you want to confine the fitting to a smaller range (e.g. to avoid |
---|
| 1096 | band 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 | |
---|
[544] | 1110 | If you wish, the initial parameter guesses can be specified and |
---|
| 1111 | specific parameters can be fixed: |
---|
[534] | 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 |
---|
[738] | 1118 | # Set Peak, centre and fwhm for the second gaussian. |
---|
[534] | 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 | |
---|
| 1124 | The fitter \cmd{plot} function has a number of options to either view |
---|
| 1125 | the fit residuals or the individual components (by default it plots |
---|
| 1126 | the sum of the model components). |
---|
| 1127 | |
---|
| 1128 | Examples: |
---|
| 1129 | |
---|
| 1130 | \begin{verbatim} |
---|
| 1131 | # Plot the residual |
---|
[738] | 1132 | ASAP> f.plot(residual=True) |
---|
[534] | 1133 | |
---|
| 1134 | # Plot the first 2 componentsa |
---|
[738] | 1135 | ASAP> f.plot(components=[0,1]) |
---|
[534] | 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 | |
---|
[544] | 1141 | \subsection{Fit saving} |
---|
| 1142 | |
---|
| 1143 | One you are happy with your fit, it is possible to store it as part of |
---|
| 1144 | the scantable. |
---|
| 1145 | |
---|
| 1146 | \begin{verbatim} |
---|
| 1147 | ASAP> f.storefit() |
---|
| 1148 | \end{verbatim} |
---|
| 1149 | |
---|
| 1150 | This will be saved to disk with the data, if the ``ASAP'' file format |
---|
| 1151 | is selected. Multiple fits to the same data can be stored in the |
---|
[738] | 1152 | scantable. |
---|
[544] | 1153 | |
---|
| 1154 | The scantable function \cmd{get\_fit} can be used to retrieve the |
---|
| 1155 | stored fits. Currently the fit parameters are just printed to the |
---|
| 1156 | screen. |
---|
| 1157 | |
---|
| 1158 | \begin{verbatim} |
---|
| 1159 | ASAP> scans.get_fit(4) # Print fits for row 4 |
---|
| 1160 | \end{verbatim} |
---|
| 1161 | |
---|
[534] | 1162 | \section{Polarisation} |
---|
| 1163 | |
---|
| 1164 | Currently ASAP only supports polarmetric analysis on linearly |
---|
| 1165 | polarised feeds and the cross polarisation products measured. Other |
---|
| 1166 | cases will be added on an as needed basic. |
---|
| 1167 | |
---|
[538] | 1168 | Conversions of linears to Stokes or Circular polarisations are done |
---|
[544] | 1169 | ``on-the-fly''. Leakage cannot be corrected for nor are these routines |
---|
[738] | 1170 | able to calibrate position angle offsets. |
---|
[534] | 1171 | |
---|
[538] | 1172 | \subsection{Simple Calibration} |
---|
| 1173 | |
---|
[763] | 1174 | {\em Currently the receiver position angle is not read from the RPFITS |
---|
| 1175 | file and a position angle of zero is assumed. This severely hampers |
---|
| 1176 | correct handling of polarimetry. In the future we aim to define a |
---|
| 1177 | general framework and populate the RPFITS files with the data required |
---|
| 1178 | for transparent polarimetric calibration.} |
---|
[538] | 1179 | |
---|
| 1180 | It is possible that there is a phase offset between polarisation which |
---|
[546] | 1181 | will effect the phase of the cross polarisation correlation, and so give |
---|
| 1182 | rise to spurious polarisation. \cmd{rotate\_xyphase} can be used to |
---|
| 1183 | correct for this error. At this point, the user must know how to |
---|
| 1184 | determine the size of the phase offset themselves. |
---|
[538] | 1185 | |
---|
| 1186 | \begin{verbatim} |
---|
[546] | 1187 | ASAP> scans.rotate_xyphase(10.5) # Degrees |
---|
[538] | 1188 | \end{verbatim} |
---|
| 1189 | |
---|
| 1190 | Note that if this function is run twice, the sum of the two values is |
---|
[546] | 1191 | applied because it is done in-situ. |
---|
[538] | 1192 | |
---|
[546] | 1193 | A correction for the receiver parallactic angle may need to be made, |
---|
| 1194 | either because of how it is mounted or if parallactifiying had to track |
---|
[538] | 1195 | at 90 degrees rather than 0. Use \cmd{rotate\_linpolphase} to correct |
---|
| 1196 | the position angle. Running this function twice results in the sum of |
---|
[546] | 1197 | the corrections being applied because it is applied in-situ. |
---|
[538] | 1198 | |
---|
| 1199 | \begin{verbatim} |
---|
[546] | 1200 | ASAP> scans.rotate_linpolphase(-20) # Degrees; correct for receiver mounting |
---|
[538] | 1201 | |
---|
| 1202 | # Receiver was tracking 90 degrees rather than 0 |
---|
[738] | 1203 | ASAP> scans.rotate_linpolphase(90) |
---|
[538] | 1204 | \end{verbatim} |
---|
| 1205 | |
---|
| 1206 | \subsection{Plotting} |
---|
| 1207 | \label{sec:polplot} |
---|
| 1208 | |
---|
[546] | 1209 | To plot Stokes values, the plotter \cmd{set\_cursor} function should |
---|
[538] | 1210 | be called first using the \cmd{pol} argument. The values which can be |
---|
[548] | 1211 | plotted 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 |
---|
| 1213 | the percentage and position angle of linear polarisation). Conversion |
---|
| 1214 | to circular polarisations are currently not available. |
---|
[538] | 1215 | |
---|
| 1216 | Example: |
---|
| 1217 | |
---|
| 1218 | \begin{verbatim} |
---|
[763] | 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'') |
---|
[538] | 1223 | \end{verbatim} |
---|
| 1224 | |
---|
| 1225 | Row, beam and IF selection are also available in \cmd{set\_cursor} as |
---|
| 1226 | describe in section~\ref{sec:plotter_cursor}. |
---|
| 1227 | |
---|
| 1228 | \subsection{Saving} |
---|
| 1229 | |
---|
| 1230 | When saving data using the \cmd{save} function, the \cmd{stokes} |
---|
| 1231 | argument can be used to save the data as Stoke values when saving in |
---|
| 1232 | FITS format. |
---|
| 1233 | |
---|
| 1234 | Example: |
---|
| 1235 | |
---|
| 1236 | \begin{verbatim} |
---|
| 1237 | ASAP> scans.save('myscan.sdfits', 'SDFITS', stokes=True) |
---|
| 1238 | \end{verbatim} |
---|
| 1239 | |
---|
[534] | 1240 | |
---|
[763] | 1241 | \section{Scantable Mathematics} |
---|
| 1242 | |
---|
| 1243 | It is possible to to simple mathematics directly on scantables from |
---|
| 1244 | the command line using the \cmd{+, -, *, /} operators as well as their |
---|
| 1245 | cousins \cmd{+=, -= *=, /=}. This works between two scantables or a |
---|
| 1246 | scantable and a float. (Note that it does not work for integers). |
---|
| 1247 | |
---|
[534] | 1248 | \begin{verbatim} |
---|
[763] | 1249 | ASAP> sum = scan1+scan2 |
---|
| 1250 | ASAP> scan2 = scan1+2.0 |
---|
| 1251 | ASAP> scan *= 1.05 |
---|
| 1252 | \end{verbatim} |
---|
| 1253 | |
---|
| 1254 | \section{Scripting} |
---|
| 1255 | |
---|
| 1256 | Because asap is based on python, it easy for the user write their own |
---|
| 1257 | scripts and functions to process data. This is highly recommended as |
---|
| 1258 | most processing of user data could then be done in a couple of steps |
---|
| 1259 | using a few simple user defined functions. A Python primer is beyond |
---|
| 1260 | the scope of this userguide. See the asap home pages for a scripting |
---|
| 1261 | tutorial 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 | |
---|
| 1268 | The asap global function \cmd{execfile} reads the named text file and |
---|
| 1269 | executes the contained python code. This file can either contain |
---|
| 1270 | function definitions which will be used in subsequent processing or |
---|
| 1271 | just a set of commands to process a specific dataset. |
---|
| 1272 | |
---|
| 1273 | \subsection{asapuserfuncs.py} |
---|
| 1274 | |
---|
| 1275 | The file $\sim$/.asap/asapuserfuncs.py is automatically read in when |
---|
| 1276 | asap is started. The user can use this to define a set of user |
---|
| 1277 | functions which are automatically available each time asap is |
---|
| 1278 | used. The \cmd{execfile} function can be called from within this file. |
---|
| 1279 | |
---|
| 1280 | \section{Worked examples} |
---|
| 1281 | |
---|
| 1282 | In the following section a few examples of end-to-end processing of |
---|
| 1283 | some data in asap are given. |
---|
| 1284 | |
---|
| 1285 | \subsection{Mopra} |
---|
| 1286 | |
---|
| 1287 | \subsection{Parkes Polarimetry} |
---|
| 1288 | |
---|
| 1289 | The following example is processing of some Parkes polarmetric |
---|
| 1290 | observations of OH masers at 1.6~GHz. Because digital filters where |
---|
| 1291 | used in the backend, the baselines are stable enough not to require a |
---|
| 1292 | quotient spectra. The 4~MHz bandwidth is wide enough to observe both |
---|
| 1293 | the 1665 and 1667~MHz OH maser transitions. Each source was observed |
---|
| 1294 | once for about 10 minutes. Tsys information was not written to the |
---|
| 1295 | rpfits file (a nominal 25K values was used), so the amplitudes need |
---|
| 1296 | to be adjusted based on a separate log file. A simple user function is |
---|
| 1297 | used to simplify this, contained in a file called mypol.py: |
---|
| 1298 | |
---|
| 1299 | \begin{verbatim} |
---|
| 1300 | def 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 | |
---|
| 1315 | The typical asap session would be |
---|
| 1316 | |
---|
| 1317 | \begin{verbatim} |
---|
| 1318 | |
---|
| 1319 | # Remind ourself the name of the rpfits files |
---|
| 1320 | ls |
---|
| 1321 | |
---|
| 1322 | # Load data from an rpfits file |
---|
| 1323 | d1665 = scantable('2005-10-27_0154-P484.rpf') |
---|
| 1324 | |
---|
| 1325 | # Check what we have just loaded |
---|
| 1326 | d1665.summary |
---|
| 1327 | |
---|
| 1328 | # View the data in velocity |
---|
| 1329 | d1665.set_unit('km/s') |
---|
| 1330 | d1665.set_freqframe('LSRK') |
---|
| 1331 | |
---|
| 1332 | # Correct for the known phase offset in the crosspol data |
---|
| 1333 | d1665.rotate_xyphase(-4) |
---|
| 1334 | |
---|
| 1335 | # Create a copy of the data and set the rest frequency to the 1667 MHz |
---|
| 1336 | # transition |
---|
| 1337 | d1667 = d1665.copy() |
---|
| 1338 | d1667.set_restfreqs(lines=['OH1667']) |
---|
| 1339 | d1667.summary |
---|
| 1340 | |
---|
| 1341 | # Copy out the scan we wish to process |
---|
| 1342 | g351_5 = d1665.get_scan('351p160') |
---|
| 1343 | g351_7 = d1667.get_scan('351p160') |
---|
| 1344 | |
---|
| 1345 | # Plot the data |
---|
| 1346 | plotter.plot(g351_5,g351_7) # Only shows one panel |
---|
| 1347 | |
---|
| 1348 | # Tell the plotter to stack polarisation and panel scans |
---|
| 1349 | plotter.set_mode('p','s') |
---|
| 1350 | |
---|
| 1351 | # Correct for the Tsys using our predefined function |
---|
| 1352 | execfile('mypol.py') # Read in the function |
---|
| 1353 | xyscale(g351_5,23.2,22.7) # Execute it on the data |
---|
| 1354 | xyscale(g351_7,23.2,22.7) |
---|
| 1355 | |
---|
| 1356 | # Only plot the velocity range of interest |
---|
| 1357 | plotter.set_range(-30,10) |
---|
| 1358 | |
---|
| 1359 | # Baseline the data |
---|
| 1360 | msk = g351_5.create_mask([-20,-15],[0,5]) |
---|
| 1361 | g351_5.poly_baseline(msk,1) |
---|
| 1362 | msk = g351_7.create_mask([-20,-15],[0,5]) |
---|
| 1363 | g351_7.poly_baseline(msk,1) |
---|
| 1364 | |
---|
| 1365 | # Update the plot with the baselined data |
---|
| 1366 | plotter.plot() |
---|
| 1367 | |
---|
| 1368 | # Look at the various polarisation products |
---|
| 1369 | plotter.set_cursor(pol='RR LL') |
---|
| 1370 | plotter.set_cursor(pol='I Plinear') |
---|
| 1371 | plotter.set_cursor(pol='I Q U V') |
---|
| 1372 | |
---|
| 1373 | # Save the plot as postscript |
---|
| 1374 | plotter.save('g361_stokes.ps') |
---|
| 1375 | |
---|
| 1376 | # Save the process spectra |
---|
| 1377 | g351_5.save('junk5.asap') |
---|
| 1378 | g351_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} |
---|
[738] | 1391 | [The scan container] |
---|
[534] | 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 |
---|
[544] | 1428 | get_fit - get a fit which has been stored witnh the data |
---|
[738] | 1429 | average_time - return the (weighted) time average of a scan |
---|
[534] | 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. |
---|
[738] | 1435 | auto_quotient - return the on/off quotient with |
---|
| 1436 | automatic detection of the on/off scans |
---|
[534] | 1437 | quotient - return the on/off quotient |
---|
| 1438 | scale - return a scan scaled by a given factor |
---|
[738] | 1439 | add - return a scan with given value added |
---|
[534] | 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 |
---|
[738] | 1444 | auto_poly_baseline - automatically fit a polynomial baseline |
---|
[534] | 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 | |
---|
[738] | 1455 | average_time - return the (weighted) time average |
---|
[534] | 1456 | of a list of scans |
---|
| 1457 | quotient - return the on/off quotient |
---|
[544] | 1458 | simple_math - simple mathematical operations on two scantables, |
---|
| 1459 | 'add', 'sub', 'mul', 'div' |
---|
[534] | 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 |
---|
[544] | 1467 | store_fit - store the fit paramaters in the data (scantable) |
---|
[534] | 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 |
---|
[544] | 1473 | set_gauss_parameters - same as above but specialised for individual |
---|
| 1474 | gaussian components |
---|
[534] | 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' |
---|
[544] | 1486 | set_cursor - only plot a selected part of the data |
---|
| 1487 | set_range - set a 'zoom' window |
---|
[534] | 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) |
---|
[738] | 1493 | |
---|
[534] | 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 |
---|
[538] | 1507 | execfile - execute an asap script, e.g. execfile('myscript') |
---|
[544] | 1508 | list_rcparameters - print out a list of possible values to be |
---|
[763] | 1509 | put into \$HOME/.asaprc |
---|
[534] | 1510 | mask_and,mask_or, |
---|
| 1511 | mask_not - boolean operations on masks created with |
---|
| 1512 | scantable.create_mask |
---|
[738] | 1513 | |
---|
[534] | 1514 | Note: |
---|
| 1515 | How to use this with help: |
---|
| 1516 | # function 'summary' |
---|
| 1517 | [xxx] is just a category |
---|
[544] | 1518 | Every 'sub-level' in this list should be replaces by a '.' Period when |
---|
[738] | 1519 | using help |
---|
[534] | 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 |
---|
[544] | 1524 | |
---|
[534] | 1525 | \end{verbatim} |
---|
| 1526 | |
---|
| 1527 | \subsection{Installation} |
---|
| 1528 | |
---|
| 1529 | ASAP depends on a number of third-party libraries which you must |
---|
| 1530 | have installed before attempting to build ASAP. These are: |
---|
| 1531 | |
---|
| 1532 | \begin{itemize} |
---|
| 1533 | \item AIPS++ |
---|
| 1534 | \item Boost |
---|
| 1535 | \item Matplotlib |
---|
[738] | 1536 | \item python/ipython |
---|
[534] | 1537 | \end{itemize} |
---|
| 1538 | |
---|
| 1539 | Debian Linux is currently supported and we intend also |
---|
| 1540 | to support other popular Linux flavours, Solaris and Mac. |
---|
| 1541 | |
---|
| 1542 | Of the dependencies, AIPS++ is the most complex to install. |
---|
| 1543 | |
---|
| 1544 | \subsection{ASCII output format} |
---|
| 1545 | |
---|
| 1546 | \subsection{.asaprc settings} |
---|
| 1547 | |
---|
[763] | 1548 | \asaprc{verbose}{{\bf True}/False}{Print verbose output} |
---|
| 1549 | |
---|
| 1550 | \asaprc{insitu}{{\bf True}/False}{Apply operations on the input |
---|
| 1551 | scantable 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 |
---|
| 1558 | file} |
---|
| 1559 | |
---|
| 1560 | \asaprc{plotter.stacking}{{\bf Pol} Beam IF Scan Time}{Default mode for |
---|
| 1561 | colour stacking} |
---|
| 1562 | |
---|
| 1563 | \asaprc{plotter.panelling}{Pol Beam IF {\bf Scan} Time}{Default mode |
---|
| 1564 | for panelling} |
---|
| 1565 | |
---|
| 1566 | \asaprc{plotter.ganged}{{\bf True}/False}{Push panels together, to |
---|
| 1567 | share axislabels} |
---|
| 1568 | |
---|
| 1569 | \asaprc{plotter.decimate}{True/{\bf False}}{Decimate the number of |
---|
| 1570 | points 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 |
---|
| 1578 | format when saving} |
---|
| 1579 | |
---|
| 1580 | \asaprc{scantable.autoaverage}{{\bf True}/False}{Auto averaging on |
---|
| 1581 | read} |
---|
| 1582 | |
---|
| 1583 | \asaprc{scantable.freqframe}{{\bf LSRK} TOPO BARY etc}{default |
---|
| 1584 | frequency frame to set when function scantable.set\_freqframe is |
---|
| 1585 | called} |
---|
| 1586 | |
---|
| 1587 | \asaprc{scantable.allaxes}{{\bf True}/False}{Apply action to all axes |
---|
| 1588 | not 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 |
---|
| 1593 | of information printed by summary} |
---|
| 1594 | |
---|
[534] | 1595 | \end{document} |
---|