- Timestamp:
- 03/08/05 15:48:43 (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/doc/cookbook.tex
r538 r544 1 %% TODO2 %% Intro3 %% Fit saving4 5 1 \documentclass[11pt]{article} 6 2 \usepackage{a4} … … 28 24 \section{Introduction} 29 25 26 ASAP is a single dish spectral line processing package currently being 27 developed by the ATNF. It is intended to process data from all ATNF 28 antennas, and can probably be used for other antnnas if they can 29 produce ``Single Dish FITS'' format. It is based on the AIPS++ 30 package. 31 30 32 %\section{Documentation Standards} 31 33 32 34 %In most of the examples in this document, it has been assumed that the 33 35 34 \section{Installation and running}36 \section{Installation and Running} 35 37 36 38 Currently there are installations running on Linux machines at … … 47 49 \begin{verbatim} 48 50 > cd /my/data/directory 49 > source /nfs/aips++/daily/aipsinit.csh # Temporary measure50 51 > asap 51 52 \end{verbatim} 52 53 53 This starts the asap. To quit, you need to type \verb+^+-d (control-d). 54 This starts the ASAP. To quit, you need to type \verb+^+-d 55 (control-d). 54 56 55 57 \section{Interface} … … 75 77 76 78 \begin{itemize} 77 \item[scantable] The data container (actual spectra and header information) 78 \item[fitter] A tool used to fit functions to the spectral data 79 \item[plotter] A tool used to plot the spectral line data 80 \item[reader] A tool which can be used to read data from disks 79 \item[\cmd{scantable}] The data container (actual spectra and header 80 information) 81 \item[\cmd{fitter}] A tool used to fit functions to the spectral data 82 \item[\cmd{plotter}] A tool used to plot the spectral line data 83 \item[\cmd{reader}] A tool which can be used to read data from disks 81 84 into a scantable object. 82 85 \end{itemize} 83 84 These are all described below.85 86 86 87 There can be many objects of the same type. Each object is referred to … … 90 91 consistent naming convention will help you a lot. 91 92 92 \subsection{Member functions(functions)}93 \subsection{Member Functions (functions)} 93 94 94 95 Following the object oriented approach, objects have associated … … 102 103 103 104 Where \cmd{out} is the name of the returned variable (could be a new 104 scantable object, or a vector of data, or a status return), \cmd{object} is the 105 object variable name (set by the user), \cmd{function} is the name of 106 the member function and \cmd{arguments} is a list of arguments to the 107 function. The arguments can be provided either though position or names. 108 A mix of the two can be used. E.g. 105 scantable object, or a vector of data, or a status return), 106 \cmd{object} is the object variable name (set by the user), 107 \cmd{function} is the name of the member function and \cmd{arguments} 108 is a list of arguments to the function. The arguments can be provided 109 either though position or \cmd{name=}. A mix of the two can be used. 110 E.g. 109 111 110 112 \begin{verbatim} … … 112 114 ASAP> av = scans(mask=msk,weight='tsys') 113 115 ASAP> av = scans(msk,True) 114 ASAP> scans.polybaseline(mask=msk, order=0, insitu e=True)116 ASAP> scans.polybaseline(mask=msk, order=0, insitu=True) 115 117 ASAP> scans.polybaseline(msk,0,True) 116 118 ASAP> scans.polybaseline(mask, insitu=True) … … 119 121 \subsection{Global Functions} 120 122 121 Some functions do not make sense to be implementedas member122 functions, typically functions which operate on more than one scantable123 (e.g. time averaging of many scans). These functions will always be 124 referred to as global functions.123 It does not make sense to implement some functions as member 124 functions, typically functions which operate on more than one 125 scantable (e.g. time averaging of many scans). These functions will 126 always be referred to as global functions. 125 127 126 128 \subsection{Interactive environment} … … 132 134 133 135 Tab completion is enabled for all function names. If you type the 134 first few letters of a function name, then type <TAB> the function135 name will be auto completed if it is un-ambiguous, or a list of 136 possibilities will be given. Auto-completion works for the user137 object names as well as function names. It does not work for filenames,138 nor for function arguments.136 first few letters of a function name, then type {\tt <TAB>} the 137 function name will be auto completed if it is un-ambiguous, or a list 138 of possibilities will be given. Auto-completion works for the user 139 object names as well as function names. It does not work for 140 filenames, nor for function arguments. 139 141 140 142 Example … … 149 151 \end{verbatim} 150 152 153 \subsubsection{Leading Spaces} 154 155 Python uses leading space to mark blocks of code. This means that it 156 you start a command line with a space, the command generally will 157 fail with an syntax error. 158 151 159 \subsubsection{Unix Interaction} 152 160 153 Basic unix shell commands ( pwd, ls, cd etc) can be issued from within154 ASAP. This allows the user to do things list look at files in the 155 current directory. The shell command ``cd'' does work within ASAP 156 allowing the user to change between data directories. Unix programs 157 cannot be run this way, but the shell escape ``$!$'' can be used to run 158 arbitrary programs. E.g.161 Basic unix shell commands (\cmd{pwd}, \cmd{ls}, \cmd{cd} etc) can be 162 issued from within ASAP. This allows the user to do things like look 163 at files in the current directory. The shell command ``\cmd{cd}'' 164 works within ASAP, allowing the user to change between data 165 directories. Unix programs cannot be run this way, but the shell 166 escape ``$!$'' can be used to run arbitrary programs. E.g. 159 167 160 168 \begin{verbatim} … … 183 191 ASAP> scans = scantable('mydata.asap') 184 192 ASAP> help scans.get_scan # Same as above 185 186 ASAP> help average_time # Global functions just need their name 187 193 \end{verbatim} 194 195 Global functions just need their name 196 197 \begin{verbatim} 198 ASAP> help average_time 188 199 \end{verbatim} 189 200 … … 194 205 \subsection{.asaprc} 195 206 196 ASAP use a \cmd{.asaprc} file to control the users preferencesof207 ASAP use an \cmd{.asaprc} file to control the user's preference of 197 208 default values for various functions arguments. This includes the 198 defaults for a guments such as \cmd{insitu}, scantable \cmd{freqframe}209 defaults for arguments such as \cmd{insitu}, scantable \cmd{freqframe} 199 210 and the plotters \cmd{set\_mode} values. The help on individual 200 funct ons says which agruments can be set default values from the211 functions says which arguments can be set default values from the 201 212 \cmd{.asaprc} file. To get a sample contents for the \cmd{.asaprc} 202 213 file use then command \cmd{list\_rcparameters}. … … 297 308 ASAP> scans.summary() # Brief listing 298 309 ASAP> scans.summary(verbose=True) # Include frequency information 299 ASAP> print scan # Equivalent to brief summary function call 310 311 # Equivalent to brief summary function call 312 ASAP> print scan 300 313 \end{verbatim} 301 314 … … 312 325 refer, is always listed. 313 326 314 You can copy one scantable to another with the \cmd{copy} function.315 316 Example:317 318 \begin{verbatim}319 ASAP> scans = scantable('MyData.rpf')320 ASAP> scan2 = scans.copy()321 \end{verbatim}327 %You can copy one scantable to another with the \cmd{copy} function. 328 329 %Example: 330 331 %\begin{verbatim} 332 % ASAP> scans = scantable('MyData.rpf') 333 % ASAP> scan2 = scans.copy() 334 %\end{verbatim} 322 335 323 336 \subsection{State} … … 327 340 328 341 Examples are the selection of beam, IF and polarisation, spectral unit 329 (e.g. $km/s$) frequency reference frame (e.g. BARY) and velocity Doppler342 (e.g. km/s) frequency reference frame (e.g. BARY) and velocity Doppler 330 343 type (e.g. RADIO). 331 344 … … 336 349 of observation (E.g. TOPO). 337 350 338 When required, this is converted to the desired reference frame (e.g. LSRK), 339 Doppler (e.g. OPTICAL) and unit (e.g. $km/s$) on-the-fly. For example, 340 this is important when you are displaying the data or fitting to it. 351 When required, this is converted to the desired reference frame 352 (e.g. LSRK), Doppler (e.g. OPTICAL) and unit (e.g. km/s) on-the-fly. 353 This is important, for example, when you are displaying the data or 354 fitting to it. 341 355 342 356 For units, the user has the choice of frequency, velocity or channel. … … 346 360 can be computed in any of these units), plotting and mask creation. 347 361 348 The velocity Dopplercan be changed with the \cmd{set\_doppler}349 function, and the frequency reference frame can be changed with the 362 The velocity definition can be changed with the \cmd{set\_doppler} 363 function, and the frequency reference frame can be changed with the 350 364 \cmd{set\_freqframe} function. 351 365 … … 460 474 When setting the mask in velocity, the conversion from velocity 461 475 to channels is based on the current cursor setting, selected row and 462 selected frequency reference frame (**Currently first row only**) 463 476 selected frequency reference frame. 464 477 465 478 Example : … … 468 481 # Select channel range for baselining 469 482 ASAP> scans.set_unit('channels') 470 ASAP> msk = q.create_mask([100,400],[600,800])483 ASAP> msk = scans.create_mask([100,400],[600,800]) 471 484 472 485 # Select velocity range for fitting 473 486 ASAP> scans.set_unit('km/s') 474 ASAP> msk = q.create_mask([-30,-10])475 \end{verbatim} 476 477 478 Sometimes it is more convenient to specify the channels to be 479 excluded, rather included. You can do this with the ``invert''argument.487 ASAP> msk = scans.create_mask([-30,-10]) 488 \end{verbatim} 489 490 Sometimes it is more convenient to specify the channels to be 491 excluded, rather included. You can do this with the ``invert'' 492 argument. 480 493 481 494 Example : 482 495 \begin{verbatim} 483 496 ASAP> scans.set_unit('channels') 484 ASAP> msk = q.create_mask([0,100],[900-1023], invert=True) # Excludes specified channels 497 ASAP> msk = scans.create_mask([0,100],[900-1023], invert=True) 498 \end{verbatim} 499 500 By default \cmd{create\_mask} uses the frequency setup of the first row 501 to convert velocities into a channel mask. If the rows in the data 502 cover different velocity ranges, the scantable row to use should be 503 specified: 504 505 \begin{verbatim} 506 ASAP> scans.set_unit('km/s') 507 ASAP> msk = q.create_mask([-30,-10], row=5) 485 508 \end{verbatim} 486 509 … … 519 542 \begin{verbatim} 520 543 ASAP> scan = scantable('2004-11-23_1841-P484.rpf') 544 545 # Don't scan average the data 546 ASAP> scan = scantable('2004-11-23_1841-P484.rpf', average=False) 521 547 \end{verbatim} 522 548 … … 547 573 548 574 In the following section, a simple data reduction to form a quotient 549 spectrum of a single source is followed. In the following it has been550 assume that the \cmd{.asaprc} file has been used to set\cmd{insitu}551 to a default value or\cmd{True}.575 spectrum of a single source is followed. It has been assume that the 576 \cmd{.asaprc} file has {\em not} been used to change the \cmd{insitu} 577 default value from \cmd{True}. 552 578 553 579 %\subsection{Editing} … … 587 613 (which is applied to all rows in \cmd{s}) or both scantables must have 588 614 the same number of rows. By default the quotient spectra is calculated 589 to preserve continuum emission. If you wish to remove continuum615 to preserve continuum emission. If you wish to remove the continuum 590 616 contribution, use the \cmd{preserve} argument: 591 617 … … 603 629 \end{verbatim} 604 630 605 If for some you want to average multiple sets of scan tables together you can: 631 If for some you want to average multiple sets of scantables together 632 you can: 606 633 607 634 \begin{verbatim} … … 609 636 \end{verbatim} 610 637 611 The default is not to use any weighting, which probably is not what 612 you want. The alternative is to use variance or Tsys weighting. 638 The default is to use integration time weighting. The alternative is 639 to use none, variance , Tsys weighting or Tsys \& integration time. 640 641 \begin{verbatim} 642 ASAP> av = average_time(q, weight='tintsys') 643 \end{verbatim} 613 644 614 645 To use variance based weighting, you need to supply a mask saying which … … 616 647 617 648 \begin{verbatim} 618 ASAP> av = average_time(q, weight='tsys') 619 620 ASAP> msk = q.create_mask([200,400],[600,800]) 621 ASAP> av = average_time(q, mask=msk, weight='var') 649 ASAP> msk = scans.create_mask([200,400],[600,800]) 650 ASAP> av = average_time(scans, mask=msk, weight='var') 622 651 \end{verbatim} 623 652 … … 733 762 corrections for atmospheric opacity and gain-elevation effects. 734 763 735 Gain-elevation curves for some telescopes and frequencies a ndknown to736 ASAP (currently only for Tid at 20~GHz). In these cases making764 Gain-elevation curves for some telescopes and frequencies are known to 765 ASAP (currently only for Tidbinbilla at 20~GHz). In these cases making 737 766 gain-corrections is simple. If the gain curve for your data is not 738 known the user can supply either a gain polynomial or text file767 known, the user can supply either a gain polynomial or text file 739 768 tabulating gain factors at a range of elevations (see \cmd{help 740 gain\_el}). 769 scantable.gain\_el}). 741 770 742 771 Examples: … … 749 778 Opacity corrections can be made with the global function 750 779 \cmd{opacity}. This should work on all telescopes as long as a 751 measurement of the opacity factor, was made during the 752 observation. 780 measurement of the opacity factor was made during the observation. 753 781 754 782 \begin{verbatim} … … 758 786 Note that at 3~mm Mopra uses a paddle wheel for Tsys calibration, 759 787 which takes opacity effects into account (to first order). ASAP 760 opacity corrections should not thenbe used for Mopra 3-mm data.788 opacity corrections should not be used for Mopra 3-mm data. 761 789 762 790 \subsection{Frequency Frame Alignment} 763 791 764 When time averaging a series of scans together, it is possible that the765 velocity scales are not exactly aligned. This may be for many reasons 766 such as not Doppler tracking the observations, errors in the Doppler 767 tracking etc. This mostly affects very long integrations or768 integrations averaged together from different days data. Before769 averagingsuch data together, they should be frequency aligned using770 \cmd{freq\_align}. 792 When time averaging a series of scans together, it is possible that 793 the velocity scales are not exactly aligned. This may be for many 794 reasons such as not Doppler tracking the observations, errors in the 795 Doppler tracking etc. This mostly affects very long integrations or 796 integrations averaged together from different days. Before averaging 797 such data together, they should be frequency aligned using 798 \cmd{freq\_align}. 771 799 772 800 E.g.: … … 836 864 \end{verbatim} 837 865 838 as this just creates a reference to the original scantable. Any changes839 made to \cmd{ss} andalso seen in \cmd{scans}. To duplicate a866 as this just creates a reference to the original scantable. Any 867 changes made to \cmd{ss} are also seen in \cmd{scans}. To duplicate a 840 868 scantable, use the copy function. 841 869 … … 851 879 \begin{itemize} 852 880 \item[ASAP] This is the internal format used for ASAP. It is the only 853 format that allows the user to restore the data, fits etc. without 854 loosing any information. As mentioned before, the ASAP scantable 855 is just an AIPS++ Table (a memory-based table). 856 This function just converts it to a disk-based 857 Table. You can the access that Table with the AIPS++ Table browser 858 or any other AIPS++ tool. 859 860 \item[SDFITS] The Single Dish FITS format. This format was 861 designed to for interchange between packages, but few packages 862 actually can read it. 881 format that allows the user to restore the data, fits etc. without 882 loosing any information. As mentioned before, the ASAP scantable is 883 an AIPS++ Table (a memory-based table). This function just converts 884 it to a disk-based Table. You can the access that Table with the 885 AIPS++ Table browser or any other AIPS++ tool. 886 887 \item[SDFITS] The Single Dish FITS format. This format was designed to 888 for interchange between packages, but few packages actually can read 889 it. 863 890 864 891 \item[FITS] This uses simple ``image'' fits to save the data, each row 865 being written to a separate fits file. This format is suitable for866 importing the data into CLASS.892 being written to a separate fits file. This format is suitable for 893 importing the data into CLASS. 867 894 868 895 \item[ASCII] A simple text based format suitable for the user to … … 910 937 911 938 This will plot multiple polarisation within each plot panel and each 912 scan row in a separate panel.939 scan row in a separate panel. 913 940 914 941 Other possibilities include: … … 937 964 multibeam or multi IF data. The plotter \cmd{set\_cursor} function is 938 965 used to select a subset of the data. The arguments \cmd{row}, 939 \cmd{beam} and \cmd{IF} all accept a vector if indices corresponding940 to tow, beam or IF selection. Only the selected data will be plotted.941 So select on polarisation, see section~\ref{sec:polplot}.966 \cmd{beam} and \cmd{IF} all accept a vector of indices corresponding 967 to row, beam or IF selection. Only the selected data will be plotted. 968 To select on polarisation, see section~\ref{sec:polplot}. 942 969 943 970 Examples: … … 957 984 \end{verbatim} 958 985 959 \subsection{Plot control} 986 Note that the plotter cursor selection is independent of the scantable 987 cursor. 988 989 \subsection{Plot Control} 960 990 961 991 The plotter window has a row of buttons on the lower left. These can … … 985 1015 \end{itemize} 986 1016 987 \subsection{Plot selection}988 989 1017 \subsection{Other control} 990 1018 … … 1000 1028 ASAP> plotter.plot(scans) 1001 1029 ASAP> plotter.set_range(-150,-50) 1002 ASAP> plotter.set_range() 1030 ASAP> plotter.set_range() # To reset 1031 \end{verbatim} 1032 1033 Both the range of the ``x'' and ``y'' axis can be set at once, if desired: 1034 1035 \begin{verbatim} 1036 ASAP> plotter.set_range(-10,30,-1,6.6) 1003 1037 \end{verbatim} 1004 1038 … … 1046 1080 \end{verbatim} 1047 1081 1048 If you wish, the initial parameter guesses can be specified specific1049 parameters can be fixed:1082 If you wish, the initial parameter guesses can be specified and 1083 specific parameters can be fixed: 1050 1084 1051 1085 \begin{verbatim} … … 1077 1111 \end{verbatim} 1078 1112 1113 \subsection{Fit saving} 1114 1115 One you are happy with your fit, it is possible to store it as part of 1116 the scantable. 1117 1118 \begin{verbatim} 1119 ASAP> f.storefit() 1120 \end{verbatim} 1121 1122 This will be saved to disk with the data, if the ``ASAP'' file format 1123 is selected. Multiple fits to the same data can be stored in the 1124 scantable. 1125 1126 The scantable function \cmd{get\_fit} can be used to retrieve the 1127 stored fits. Currently the fit parameters are just printed to the 1128 screen. 1129 1130 \begin{verbatim} 1131 ASAP> scans.get_fit(4) # Print fits for row 4 1132 \end{verbatim} 1133 1079 1134 \section{Polarisation} 1080 1135 … … 1084 1139 1085 1140 Conversions of linears to Stokes or Circular polarisations are done 1086 ``on-the-fly''. Leakage cannot be corrected for nor are the re routines1141 ``on-the-fly''. Leakage cannot be corrected for nor are these routines 1087 1142 able to calibrate position angle offsets. 1088 1143 … … 1093 1148 1094 1149 It is possible that there is a phase offset between polarisation which 1095 will effect the phase of the cross polarisation 1096 correlation. \cmd{rotate\_xyphase} can be used to correct for this 1097 error. The user must know how to determine the size of the phase1098 offset.1150 will effect the phase of the cross polarisation correlation, and so 1151 give rise to spurious polarisation. \cmd{rotate\_xyphase} can be used 1152 to correct for this error. The user must know how to determine the 1153 size of the phase offset themselves. 1099 1154 1100 1155 \begin{verbatim} … … 1154 1209 1155 1210 \begin{verbatim} 1156 1157 [The scan container]1158 1211 scantable - a container for integrations/scans 1159 1212 (can open asap/rpfits/sdfits and ms files) … … 1192 1245 nbeam,nif,nchan,npol - the number of beams/IFs/Pols/Chans 1193 1246 history - print the history of the scantable 1194 1195 average_time - return the (weighted) time average of a scan 1247 get_fit - get a fit which has been stored witnh the data 1248 average_time - return the (weighted) time average of a scan 1196 1249 or a list of scans 1197 1250 average_pol - average the polarisations together. … … 1201 1254 quotient - return the on/off quotient 1202 1255 scale - return a scan scaled by a given factor 1203 add - return a scan with given value added 1256 add - return a scan with given value added 1204 1257 bin - return a scan with binned channels 1205 1258 resample - return a scan with resampled channels … … 1216 1269 [Math] Mainly functions which operate on more than one scantable 1217 1270 1218 average_time - return the (weighted) time average 1271 average_time - return the (weighted) time average 1219 1272 of a list of scans 1220 1273 quotient - return the on/off quotient 1221 simple_math - simple mathematical operations on two scantables, 'add', 'sub', 'mul', 'div' 1274 simple_math - simple mathematical operations on two scantables, 1275 'add', 'sub', 'mul', 'div' 1222 1276 [Fitting] 1223 1277 fitter … … 1227 1281 commited. 1228 1282 fit - execute the actual fitting process 1283 store_fit - store the fit paramaters in the data (scantable) 1229 1284 get_chi2 - get the Chi^2 1230 1285 set_scan - set the scantable to be fit … … 1232 1287 set_parameters - set the parameters for the function(s), and 1233 1288 set if they should be held fixed during fitting 1234 set_gauss_parameters - same as above but specialised for individual gaussian components 1289 set_gauss_parameters - same as above but specialised for individual 1290 gaussian components 1235 1291 get_parameters - get the fitted parameters 1236 1292 plot - plot the resulting fit and/or components and … … 1244 1300 what is to be plotted 'colour stacked' 1245 1301 and what 'panelled' 1246 set_range - set the abcissa 'zoom' range 1302 set_cursor - only plot a selected part of the data 1303 set_range - set a 'zoom' window 1247 1304 set_legend - specify user labels for the legend indeces 1248 1305 set_title - specify user labels for the panel indeces … … 1250 1307 set_abcissa - specify a user label for the abcissa 1251 1308 set_layout - specify the multi-panel layout (rows,cols) 1252 1309 1253 1310 [Reading files] 1254 1311 reader - access rpfits/sdfits files … … 1265 1322 help - print help for one of the listed functions 1266 1323 execfile - execute an asap script, e.g. execfile('myscript') 1267 1268 put into \$HOME/.asaprc1324 list_rcparameters - print out a list of possible values to be 1325 put into .asaprc file 1269 1326 mask_and,mask_or, 1270 1327 mask_not - boolean operations on masks created with 1271 1328 scantable.create_mask 1272 1329 1273 1330 Note: 1274 1331 How to use this with help: 1275 1332 # function 'summary' 1276 1333 [xxx] is just a category 1277 Every 'sub-level' in this list should be replaces by a '.' Period when using help 1334 Every 'sub-level' in this list should be replaces by a '.' Period when 1335 using help 1278 1336 Example: 1279 1337 ASAP> help scantable # to get info on ths scantable 1280 1338 ASAP> help scantable.summary # to get help on the scantable's 1281 1339 ASAP> help average_time 1340 1341 \end{verbatim} 1342 1343 \section{Scantable Mathematics} 1344 1345 It is possible to to simple mathematics directly on scantables from 1346 the command line using the \cmd{+, -, *, /} operators as well as their 1347 cousins \cmd{+=, -= *=, /=}. This works between two scantables or a 1348 scantable and a float. (Note that it does not work for integers). 1349 1350 \begin{verbatim} 1351 ASAP> sum = scan1+scan2 1352 ASAP> scan2 = scan1+2.0 1353 ASAP> scan *= 1.05 1282 1354 \end{verbatim} 1283 1355
Note:
See TracChangeset
for help on using the changeset viewer.