casa
$Rev:20696$
|
00001 # 00002 # This file was generated using xslt from its XML file 00003 # 00004 # Copyright 2008, Associated Universities Inc., Washington DC 00005 # 00006 import sys 00007 import os 00008 #from casac import * 00009 import casac 00010 import string 00011 import time 00012 import inspect 00013 import gc 00014 import numpy 00015 from odict import odict 00016 from taskmanager import tm 00017 from task_flagdata import flagdata 00018 class flagdata_cli_: 00019 __name__ = "flagdata" 00020 __async__ = {} 00021 rkey = None 00022 i_am_a_casapy_task = None 00023 # The existence of the i_am_a_casapy_task attribute allows help() 00024 # (and other) to treat casapy tasks as a special case. 00025 00026 def __init__(self) : 00027 self.__bases__ = (flagdata_cli_,) 00028 self.__doc__ = self.__call__.__doc__ 00029 00030 self.parameters={'vis':None, 'mode':None, 'autocorr':None, 'inpfile':None, 'reason':None, 'spw':None, 'field':None, 'antenna':None, 'uvrange':None, 'timerange':None, 'correlation':None, 'scan':None, 'intent':None, 'array':None, 'observation':None, 'feed':None, 'clipminmax':None, 'datacolumn':None, 'clipoutside':None, 'channelavg':None, 'clipzeros':None, 'quackinterval':None, 'quackmode':None, 'quackincrement':None, 'tolerance':None, 'addantenna':None, 'lowerlimit':None, 'upperlimit':None, 'ntime':None, 'combinescans':None, 'timecutoff':None, 'freqcutoff':None, 'timefit':None, 'freqfit':None, 'maxnpieces':None, 'flagdimension':None, 'usewindowstats':None, 'halfwin':None, 'winsize':None, 'timedev':None, 'freqdev':None, 'timedevscale':None, 'freqdevscale':None, 'spectralmax':None, 'spectralmin':None, 'extendpols':None, 'growtime':None, 'growfreq':None, 'growaround':None, 'flagneartime':None, 'flagnearfreq':None, 'minrel':None, 'maxrel':None, 'minabs':None, 'maxabs':None, 'spwchan':None, 'spwcorr':None, 'basecnt':None, 'action':None, 'display':None, 'flagbackup':None, 'savepars':None, 'cmdreason':None, 'outfile':None, 'async':None} 00031 00032 00033 def result(self, key=None): 00034 #### here we will scan the task-ids in __async__ 00035 #### and add any that have completed... 00036 if key is not None and self.__async__.has_key(key) and self.__async__[key] is not None: 00037 ret = tm.retrieve(self.__async__[key]) 00038 if ret['state'] == "done" : 00039 self.__async__[key] = None 00040 elif ret['state'] == 'crashed' : 00041 self.__async__[key] = None 00042 return ret 00043 return None 00044 00045 00046 def __call__(self, vis=None, mode=None, autocorr=None, inpfile=None, reason=None, spw=None, field=None, antenna=None, uvrange=None, timerange=None, correlation=None, scan=None, intent=None, array=None, observation=None, feed=None, clipminmax=None, datacolumn=None, clipoutside=None, channelavg=None, clipzeros=None, quackinterval=None, quackmode=None, quackincrement=None, tolerance=None, addantenna=None, lowerlimit=None, upperlimit=None, ntime=None, combinescans=None, timecutoff=None, freqcutoff=None, timefit=None, freqfit=None, maxnpieces=None, flagdimension=None, usewindowstats=None, halfwin=None, winsize=None, timedev=None, freqdev=None, timedevscale=None, freqdevscale=None, spectralmax=None, spectralmin=None, extendpols=None, growtime=None, growfreq=None, growaround=None, flagneartime=None, flagnearfreq=None, minrel=None, maxrel=None, minabs=None, maxabs=None, spwchan=None, spwcorr=None, basecnt=None, action=None, display=None, flagbackup=None, savepars=None, cmdreason=None, outfile=None, async=None): 00047 00048 """All-purpose flagging task based on data-selections and flagging modes/algorithms. 00049 00050 This task can flag a Measurement Set or a calibration table. It has 00051 two main types of operation. One type will read the parameters from 00052 the interface and flag using any of the various available modes. The 00053 other type will read the commands from a text file or a Python list of 00054 strings, containing a list of flag commands (each line containing data 00055 selection parameters and any parameter specific for the mode being 00056 requested). Please see examples at the end of this help. 00057 00058 It is also possible to only save the parameters set in the interface 00059 without flagging. The parameters can be saved in the FLAG_CMD sub-table 00060 or in a text file. Note that when saving to an external file, the parameters 00061 will be appended to the given file. 00062 00063 The available flagging modes are: manual, clip, shadow, quack, elevation, 00064 tfcrop, rflag, extend, unflag and summary. 00065 00066 The current flags can be automatically backed up before applying new 00067 flags if the parameter flagbackup is set. Previous flag versions can be 00068 recovered using the flagmanager task. 00069 00070 NOTE on flagging calibration tables. 00071 ----------------------------------- 00072 00073 When the input is a calibration table, the modes 'elevation' and 'shadow' 00074 will be disabled. Data selection for calibration tables is limited to field, 00075 antenna and spw at the moment. It is only possible to save the parameters 00076 to an external file. 00077 00078 The task will flag a subset of data based on the following modes of operation: 00079 00080 list = list of flagging commands to apply to MS/cal table 00081 manual = flagging based on specific selection parameters 00082 clip = clip data according to values 00083 quack = remove/keep specific time range at scan beginning/end 00084 shadow = remove antenna-shadowed data 00085 elevation = remove data below/above given elevations 00086 tfcrop = automatic identification of outliers on the time-freq plane 00087 rflag = automatic detection of outliers based on sliding-window RMS filters 00088 extend = extend and/or grow flags beyond what the basic algorithms detect 00089 summary = report the amount of flagged data 00090 unflag = unflag the specified data 00091 00092 Keyword arguments: 00093 vis -- Name of input visibility file or calibration table. 00094 default: '' (none) 00095 example1: vis='uid___A002_X2a5c2f_X54.ms' or 00096 example2: vis='cal-X54.B1' 00097 00098 Any flagging will only be applied to the specified selection. 00099 00100 antenna -- Select data based on baseline 00101 default: '' (all); example: antenna='DV04&DV06' baseline DV04-DV06 00102 antenna='DV04&DV06;DV07&DV10' #baselines DV04-DV06 and DV07-DV10 00103 antenna='DV06' # all cross-correlation baselines between antenna DV06 and 00104 all other available antennas 00105 antenna='DV04,DV06' # all baselines with antennas DV04 and DV06 00106 antenna='DV06&&DV06' # only the auto-correlation baselines for antenna DV06 00107 antenna='DV04&&*' # cross and auto-correlation baselines between antenna DV04 00108 and all other available antennas 00109 antenna='0~2&&&' # only the auto-correlation baselines for antennas 00110 in range 0~2 00111 00112 spw -- Select data based on spectral window and channels 00113 default: '' (all); example: spw='1' 00114 spw='<2' #spectral windows less than 2 00115 spw='>1' #spectral windows greater than 1 00116 spw='1:0~10' # first 10 channels from spw 1 00117 spw='1:0~5;120~128' # multiple separated channel chunks. 00118 00119 Note : For modes clip, tfcrop and rflag, channel-ranges can be excluded 00120 from flagging by selecting ranges such as spw='0:0~5;10~63'. This is a way to 00121 protect known spectral-lines from being flagged by the autoflag algorithms. 00122 00123 correlation -- Correlation types or expression. 00124 default: '' (all correlations) 00125 For modes clip, tfcrop or rflag, the default means ABS_ALL. If 00126 the input is cal table that does not contain a complex data column, 00127 the default will fall back to REAL_ALL. 00128 example: correlation='XX,YY' or 00129 options: Any of 'ABS', 'ARG', 'REAL', 'IMAG', 'NORM' followed by 00130 any of 'ALL', 'I', 'XX', 'YY', 'RR', 'LL', 'Sol1', 'Sol2', 'WVR' 00131 'WVR' refers to the water vapour radiometer of ALMA data. 00132 example: correlation='REAL_XX,XY' 00133 -->correlation selection is not supported for modes other than clip, tfcrop or 00134 rflag in cal tables. 00135 00136 Note that the operators ABS,ARG,REAL, etc. are written only once as the first value. 00137 if more than one correlation is given, the operator will be applied to all of them. 00138 00139 The expression is used only in modes clip, tfcrop and rflag. 00140 00141 field -- Select data based on field id(s) or name(s) 00142 default: '' (all); example: field='1' 00143 field='0~2' # field ids inclusive from 0 to 2 00144 field='3C*' # all field names starting with 3C 00145 00146 uvrange -- Select data within uvrange (default units meters) 00147 default: '' (all); example: 00148 uvrange='0~1000klambda'; uvrange from 0-1000 kilo-lambda 00149 uvrange='>4klamda';uvranges greater than 4 kilo-lambda 00150 uvrange='0~1000km'; uvrange in kilometers 00151 -->uvrange selection is not supported for cal tables. 00152 00153 timerange -- Select data based on time range: 00154 default = '' (all); example, 00155 timerange = 'YYYY/MM/DD/hh:mm:ss~YYYY/MM/DD/hh:mm:ss' 00156 Note: YYYY/MM/DD can be dropped as needed: 00157 timerange='09:14:0~09:54:0' # this time range 00158 timerange='09:44:00' # data within one integration of time 00159 timerange='>10:24:00' # data after this time 00160 timerange='09:44:00+00:13:00' #data 13 minutes after time 00161 -->timerange selection is not supported for cal tables. 00162 00163 scan -- Select data based on scan number 00164 default: '' (all); example: scan='>3' 00165 -->scan selection is not supported for cal tables. 00166 00167 intent -- Select data based on observation intent 00168 default: '' (all); example: intent='*CAL*,*BAND*' 00169 -->intent selection is not supported for cal tables. 00170 00171 array -- Selection based on the antenna array 00172 default: '' (all); 00173 -->array selection is not supported for cal tables. 00174 00175 observation -- Selection based on the observation ID 00176 default: '' (all); example: observation='1' or observation=1 00177 -->observation selection is not supported for cal tables. 00178 00179 feed -- Selection based on the feed - NOT IMPLEMENTED YET 00180 00181 00182 mode -- Mode of operation. 00183 options: 'list', 'manual','clip','quack','shadow','elevation', 'tfcrop', 'extend', 00184 'unflag', 'summary' 00185 default: 'manual' 00186 00187 list -- Flag according to the data selection and flag commands specified in the input list. 00188 The input list may come from a text file or from a Python list of strings. 00189 Each input line may contain data selection parameters and any parameter 00190 specific to the mode given in the line. Default values will be used for 00191 the parameters that are not present in the line. Each line will be taken 00192 as a command to the task. If data is pre-selected using any of the selection 00193 parameters, then flagging will apply only to that subset of the MS. 00194 00195 The summary mode is not allowed in the input list. 00196 00197 For optimization, the task will create a union of the data selection parameters 00198 present in the list and select only that portion of the MS. 00199 00200 NOTE: the flag commands will be applied only when action='apply'. If 00201 action='calculate' the flags will be calculated, but not applied. 00202 This is useful if display is set to something other than 'none'. If 00203 action='' or 'none', the flag commands will not be applied either. 00204 An empty action is useful only to save the parameters of the list 00205 to a file or to the FLAG_CMD sub-table. 00206 00207 inpfile -- Input ASCII file or a Python list of command strings. 00208 default: '' 00209 options: [] or '' with filename. 00210 Example1: the following commands can be saved into a file and given 00211 to the task (e.g. save it to flags.txt). 00212 00213 scan='1~3' mode='manual' 00214 mode='clip' clipminmax=[0,2] correlation='ABS_XX' clipoutside=False 00215 spw='9' mode='tfcrop' correlation='ABS_YY' ntime=51.0 00216 mode='extend' extendpols=True 00217 00218 flagdata(vis,mode='list',inpfile='flags.txt') 00219 00220 Example2: the same commands can be given in a Python list on the command line 00221 to the task. 00222 cmd=["scan='1~3' mode='manual'", 00223 "mode='clip' clipminmax=[0,2] correlation='ABS_XX' clipoutside=False", 00224 "spw='9' mode='tfcrop' correlation='ABS_YY' ntime=51.0", 00225 "mode='extend' extendpols=True"] 00226 00227 flagdata(vis,mode='list',inpfile=cmd) 00228 00229 reason -- select flag commands based on REASON(s) 00230 default: 'any' (all flags regardless of reason) 00231 can be a string, or list of strings 00232 example: reason='FOCUS_ERROR' 00233 reason=['FOCUS_ERROR','SUBREFLECTOR_ERROR'] 00234 00235 NOTE: what is within the string is literally 00236 matched, e.g. reason='' matches only blank reasons, 00237 and reason = 'FOCUS_ERROR,SUBREFLECTOR_ERROR' 00238 matches this compound reason string only 00239 00240 See the syntax for writing flag commands at the end of this help. 00241 00242 00243 manual -- Flag according to the data selection specified. 00244 This is the default mode (used when the mode is not specified). 00245 00246 autocorr -- Flag only the auto-correlations. Note that this parameter is only 00247 active when set to True. If set to False it does NOT mean "do not 00248 flag auto-correlations". 00249 default: False 00250 options: True,False 00251 00252 clip -- Clip data according to values of the following subparameters. The polarization 00253 expression is given by the correlation parameter. 00254 00255 channelavg -- Average data over (selected) channels? Channel 00256 selections are taken into account. Flagged channels 00257 are excluded from the average. The average is done 00258 after applying the specified clipexpr, i.e. scalar 00259 averaging. 00260 default: False 00261 options: True,False 00262 00263 clipminmax -- Range of data (Jy) that will NOT be flagged 00264 default: []; it will flag only NaN and Infs. 00265 example: [0.0,1.5] 00266 It will always flag the NaN/Inf data, even when a range is specified. 00267 00268 datacolumn -- Column to use for clipping. 00269 default: 'DATA' 00270 options: 'DATA', 'CORRECTED','MODEL', 'RESIDUAL, 'RESIDUAL_DATA', 00271 'FPARAM', 'CPARAM', 'SNR'. 00272 00273 NOTE: by default for calibration tables, the framework will try to use FPARAM; 00274 if that does not exist, it will try to use CPARAM. If none of them exist, it 00275 will give an error and exit. 00276 00277 clipoutside -- Clip OUTSIDE the range? 00278 default: True 00279 example: False; flag data WITHIN the range. 00280 00281 clipzeros -- Clip zero-value data. 00282 default: False 00283 00284 quack -- Option to remove specified part of scan beginning/end 00285 00286 quackinterval -- Time in seconds from scan beginning/end to flag. Make time slightly 00287 smaller than the desired time. 00288 default: 0.0 00289 quackmode -- Quack mode 00290 default: 'beg' 00291 options: 'beg' ==> beginning of scan 00292 'endb' ==> end of scan. 00293 'tail' ==> all but beginning of scan 00294 'end' ==> all but end of scan. 00295 quackincrement -- Quack incrementally in time? 00296 default: False 00297 False ==> the quack interval is counted from the 00298 beginning of the scan 00299 True ==> the quack interval is counted from the 00300 first unflagged data in the scan 00301 00302 shadow -- Option to flag data of shadowed antennas. This mode is not available 00303 for cal tables. 00304 00305 All antennas in the antenna-subtable of the MS (and the corresponding 00306 diameters) will be considered for shadow-flag calculations. 00307 For a given timestep, an antenna is flagged if any of its baselines 00308 (projected onto the uv-plane) is shorter than radius_1 + radius_2 - tolerance. 00309 The value of 'w' is used to determine which antenna is behind the other. 00310 The phase-reference center is used for antenna-pointing direction. 00311 00312 tolerance -- Amount of shadowing allowed (or tolerated), in meters. 00313 A positive number allows antennas to overlap in projection 00314 A negative number forces antennas apart in projection 00315 Zero implies a distance of radius_1+radius_2 between antenna centers. 00316 default: 0.0 00317 00318 addantenna -- It can be either a file name with additional antenna names, positions 00319 and diameters, or a Python dictionary with the same information. 00320 You can use the flaghelper functions to create the dictionary from a file. 00321 default: '' 00322 00323 To create a dictionary inside casapy. 00324 > import flaghelper as fh 00325 > antdic = fh.readAntennaList(antfile) 00326 00327 Where antfile is a text file in disk that contains information such as: 00328 name=VLA01 00329 diameter=25.0 00330 position=[-1601144.96146691, -5041998.01971858, 3554864.76811967] 00331 name=VLA02 00332 diameter=25.0 00333 position=[-1601105.7664601889, -5042022.3917835914, 3554847.245159178] 00334 00335 00336 elevation -- Option to flag based on antenna elevation. This mode is not available 00337 for cal tables. 00338 00339 lowerlimit -- Lower limiting elevation in degrees. Data coming from a baseline 00340 where one or both antennas were pointing at a strictly lower elevation 00341 (as function of time), will be flagged. 00342 default: 0.0 00343 00344 upperlimit -- Upper limiting elevation in degrees. Data coming from a baseline 00345 where one or both antennas were pointing at a strictly higher elevation 00346 (as function of time), will be flagged. 00347 default: 90.0 00348 00349 tfcrop -- Flag using the TFCrop autoflag algorithm. The polarization 00350 expression is given by the correlation parameter. 00351 00352 For each field, spw, timerange (specified by ntime), and baseline, 00353 (1) Average visibility amplitudes along time dimension to 00354 form an average spectrum 00355 (2) Calculate a robust piece-wise polynomial fit for the band-shape 00356 at the base of RFI spikes. Calculate 'stddev' of (data - fit). 00357 (3) Flag points deviating from the fit by more than N-stddev 00358 (4) Repeat (1-3) along the other dimension. 00359 00360 This algorithm is designed to operate on un-calibrated data (step (2)), 00361 as well as calibrated data. It is usually helpful to extend the flags along 00362 time, frequency, and correlation in a second step (via mode='extend) 00363 00364 ntime -- Timerange (in seconds or minutes) over which to buffer data before 00365 running the algorithm. 00366 options: 'scan' or any other float value or string containing the units. 00367 default: 'scan' 00368 example: '1.5min' 00369 : 1.2 (taken in seconds) 00370 The dataset will be iterated through in time-chunks defined here. 00371 00372 combinescans -- accumulate data across scans. 00373 default: False 00374 This parameter is relevant only ntime is specified as a time-interval (not 'scan') 00375 00376 datacolumn -- Column to use for flagging. 00377 default: 'DATA' 00378 options: 'DATA', 'CORRECTED','MODEL', 'RESIDUAL, 'RESIDUAL_DATA', 00379 'FPARAM', 'CPARAM', 'SNR'. 00380 00381 NOTE: by default for calibration tables, the framework will try to use FPARAM; 00382 if that does not exist, it will try to use CPARAM. If none of them exist, it 00383 will give an error and exit. 00384 00385 00386 timecutoff -- Flag threshold in time. Flag all data-points further than N-stddev 00387 from the fit. This threshold catches time-varying RFI spikes ( 00388 narrow and broad-band), but will not catch RFI that is persistent in time. 00389 default: 4.0 00390 Flagging is done in upto 5 iterations. The stddev calculation is adaptive and 00391 converges to a value that reflects only the data and no RFI. At each iteration, 00392 the same relative threshold is applied to detect flags. (Step (3) of the algorithm). 00393 00394 freqcutoff -- Flag threshold in frequency. Flag all data-points further than N-stddev 00395 from the fit. 00396 default: 3.0 00397 Same as timecutoff, but along the frequency-dimension. This threshold catches 00398 narrow-band RFI that may or may not be persistent in time. 00399 00400 timefit -- Fitting function for the time direction 00401 default: 'line' 00402 options: 'line', 'poly' 00403 A 'line' fit is a robust straight-line fit across the entire timerange (defined 00404 by 'ntime'). 00405 A 'poly' fit is a robust piece-wise polynomial fit across the timerange. 00406 Note: A robust fit is computed in upto 5 iterations. At each iteration, the stddev 00407 between the data and the fit is computed, values beyond N-stddev are flagged, 00408 and the fit and stddev are re-calculated with the remaining points. 00409 This stddev calculation is adaptive, and converges to a value that reflects 00410 only the data and no RFI. It also provides a varying set of flagging thresholds, 00411 that allows deep flagging only when the fit best represents the true data. 00412 Choose 'poly' only if the visibilities are expected to vary significantly over the 00413 timerange selected by 'ntime', or if there is a lot of strong but intermittent RFI. 00414 00415 freqfit -- Fitting function for the frequency direction 00416 default: 'poly' 00417 options: 'line','poly' 00418 Same as for the 'timefit' parameter. 00419 Choose 'line' only if you are operating on bandpass-corrected data, or residuals, 00420 and expect that the bandshape is linear. The 'poly' option works better on 00421 uncalibrated bandpasses with narrow-band RFI spikes. 00422 00423 maxnpieces -- Maxinum number of pieces to allow in the piecewise-polynomial fits 00424 default: 7 00425 options: 1 - 9 00426 This parameter is used only if 'timefit' or 'freqfit' are chosen as 'poly'. 00427 If there is significant broad-band RFI, reduce this number. Using too many 00428 pieces could result in the RFI being fitted in the 'clean' bandpass. 00429 In later stages of the fit, a third-order polynomial is fit per piece, so 00430 for best results, please ensure that nchan/maxnpieces is at-least 10. 00431 00432 flagdimension -- Choose the directions along which to perform flagging 00433 default: 'freqtime'; first flag along frequency, and then along time 00434 options: 'time', 'freq', 'timefreq', 'freqtime' 00435 For most cases, 'freqtime' or 'timefreq' are appropriate, and differences 00436 between these choices are apparant only if RFI in one dimension is 00437 significantly stronger than the other. The goal is to flag the dominant RFI first. 00438 If there are very few (less than 5) channels of data, then choose 'time'. 00439 Similarly for 'freq'. 00440 00441 usewindowstats -- Use sliding-window statistics to find additional flags. 00442 default: 'none' 00443 options: 'none', 'sum', 'std', 'both' 00444 Note: This is experimental ! 00445 The 'sum' option chooses to flag a point, if the mean-value in a 00446 window centered on that point deviates from the fit by more than 00447 N-stddev/2.0. 00448 Note: stddev is calculated between the data and fit as explained in Step (2). 00449 This option is an attempt to catch broad-band or 00450 time-persistent RFI that the above polynomial fits will mistakenly fit 00451 as the clean band. It is an approximation to the sumThreshold 00452 method found to be effective by Offringa et.al (2010) for LOFAR data. 00453 The 'std' option chooses to flag a point, if the 'local' stddev calculated 00454 in a window centered on that point is larger than N-stddev/2.0. 00455 This option is an attempt to catch noisy RFI that is not excluded in the 00456 polynomial fits, and which increases the global stddev, and results in 00457 fewer flags (based on the N-stddev threshold). 00458 00459 halfwin -- Half width of sliding window to use with 'usewindowstats' 00460 default: 1 (a 3-point window size) 00461 options: 1,2,3 00462 Note: This is experimental ! 00463 00464 rflag -- Detect outliers based on the RFLAG algorithm (ref. E.Greisen, AIPS, 2011). 00465 The polarization expression is given by the correlation parameter. 00466 00467 Iterate through the data in chunks of time. For each chunk, calculate local 00468 statistics, and apply flags based on user supplied (or auto-calculated) thresholds. 00469 00470 Step 1 : Time analysis (for each channel) 00471 -- calculate local rms of real and imag visibilities, within a sliding time window 00472 -- calculate the median rms across time windows, deviations of local rms from 00473 this median, and the median deviation 00474 -- flag if local rms is larger than timedevscale x (medianRMS + medianDev) 00475 00476 Step 2 : Spectral analysis (for each time) 00477 -- calculate avg of real and imag visibilities and their rms across channels 00478 -- calculate the deviation of each channel from this avg, and the median-deviation 00479 -- flag if deviation is larger than freqdevscale x medianDev 00480 00481 Example usage : 00482 00483 (1) Calculate thresholds automatically per scan, and use them to find flags. 00484 Specify scale-factor for time-analysis thresholds, use default for frequency. 00485 00486 flagdata('my.ms', mode='rflag',spw='9',timedevscale=4.0) 00487 00488 (2) Supply noise-estimates to be used with default scale-factors. 00489 00490 flagdata(vis='my.ms', mode='rflag', spw='9', timedev=0.1, freqdev=0.5, action='calculate) 00491 00492 (3) Two-passes. This replicates the usage pattern in AIPS. 00493 00494 -- The first pass saves commands in an output text files, with auto-calculated 00495 thresholds. Thresholds are returned from rflag only when action='calculate'. 00496 The user can edit this file before doing the second pass, 00497 but the python-dictionary structure must be preserved. 00498 00499 -- The second pass applies these commands (action='apply'). 00500 00501 flagdata(vis='my.ms', mode='rflag', spw='9,10', timedev='tdevfile.txt', 00502 freqdev='fdevfile.txt', action='calculate') 00503 flagdata(vis='my.ms', mode='rflag', spw='9,10', timedev='tdevfile.txt', 00504 freqdev='fdevfile.txt', action='apply') 00505 00506 With action='calculate', display='report' will produce diagnostic plots 00507 showing data-statistics and thresholds (the same thresholds as those 00508 written out to 'tdevfile.txt' and 'fdevfile.txt'). 00509 00510 Note : The rflag algorithm was originally developed by Eric Greisen in 00511 AIPS (31DEC11). 00512 AIPS documentation : Section E.5 of the AIPS cookbook 00513 (Appendix E : Special Considerations for EVLA data calibration and imaging in AIPS, 00514 http://www.aips.nrao.edu/cook.html#CEE ) 00515 00516 Note : Since this algorithm operates with two passes through each 00517 chunk of data (time and freq axes), some data points get flagged 00518 twice. This can affect the flag-percentage estimate printed in the 00519 logger at runtime. An accurate estimate can be obtained via the 00520 summary mode. 00521 00522 ntime -- Timerange (in seconds or minutes) over which to buffer data before running the algorithm. 00523 options: 'scan' or any other float value or string containing the units. 00524 default: 'scan' 00525 example: '1.5min' 00526 : 1.2 (taken in seconds) 00527 The dataset will be iterated through in time-chunks defined here. 00528 00529 combinescans -- accumulate data across scans. 00530 default: False 00531 It only makes sense when ntime not equal 'scan'. 00532 00533 datacolumn -- Column to use for flagging. 00534 default: 'DATA' 00535 options: 'DATA', 'CORRECTED','MODEL', 'RESIDUAL, 'RESIDUAL_DATA', 00536 'FPARAM', 'CPARAM', 'SNR'. 00537 00538 NOTE: by default for calibration tables, the framework will try to use FPARAM; 00539 if that does not exist, it will try to use CPARAM. If none of them exist, it 00540 will give an error and exit. 00541 00542 00543 winsize -- number of timesteps in the sliding time window ( fparm(1) in AIPS ). 00544 default: 3 00545 00546 timedev -- time-series noise estimate ( noise in AIPS ). 00547 default: [] 00548 Examples : 00549 timedev = 0.5 : Use this noise-estimate to calculate flags. Do not recalculate. 00550 timedev = [ [1,9,0.2], [1,10,0.5] ] : Use noise-estimate of 0.2 for field 1, 00551 spw 9, and noise-estimate of 0.5 for field 1, spw 10. 00552 timedev = [] : Auto-calculate noise estimates. 00553 00554 00555 freqdev -- spectral noise estimate ( scutoff in AIPS ). 00556 This step depends on having a relatively-flat bandshape. 00557 Same parameter-options as 'timedev'. 00558 default: [] 00559 00560 00561 timedevscale -- For Step 1 (time analysis), flag a point if local rms around it 00562 is larger than 'timedevscale' x 'timedev' ( fparm(0) in AIPS ) 00563 default: 5.0 00564 00565 freqdevscale -- For Step 2 (spectral analysis), flag a point if local rms around it 00566 is larger than 'freqdevscale' x 'freqdev' ( fparm(10) in AIPS ) 00567 default: 5.0 00568 00569 spectralmax -- Flag whole spectrum if 'freqdev' is greater than spectralmax ( fparm(6) in AIPS ) 00570 default: 1E6 00571 00572 spectralmin -- Flag whole spectrum if 'freqdev' is less than spectralmin ( fparm(5) in AIPS ) 00573 default: 0.0 00574 00575 00576 00577 extend -- Extend and/or grow flags beyond what the basic algorithms detect. 00578 This mode will extend the accumulated flags available in the MS, 00579 regardless of which algorithm created them. 00580 00581 Extensions will apply only within the selected data, according to the settings 00582 of extendpols,growtime,growfreq,growaround, flagneartime,flagnearfreq. 00583 00584 Note : Runtime summary counts in the logger can sometimes report larger 00585 flag percentages than what is actually flagged. This is because 00586 extensions onto already-flagged data-points are counted as new flags. 00587 An accurate flag count can be obtained via the summary mode. 00588 00589 ntime -- Timerange (in seconds or minutes) over which to buffer data before running 00590 the algorithm. 00591 options: 'scan' or any other float value or string containing the units. 00592 default: 'scan' 00593 example: '1.5min' 00594 : 1.2 (taken in seconds) 00595 The dataset will be iterated through in time-chunks defined here. 00596 00597 combinescans -- accumulate data across scans. 00598 default: False 00599 It only makes sense when ntime not equal 'scan'. 00600 00601 extendpols -- Extend flags to all selected correlations 00602 default: True 00603 options: True/False 00604 For example, to extend flags from RR to only RL and LR, a data-selection 00605 of correlation='RR,LR,RL' is required along with extendpols=True. 00606 00607 growtime -- For any channel, flag the entire timerange in the current 2D chunk ( 00608 set by 'ntime') if more than X% of the timerange is already flagged. 00609 default: 50.0 00610 options: 0.0 - 100.0 00611 This option catches the low-intensity parts of time-persistent RFI. 00612 00613 growfreq -- For any timestep, flag all channels in the current 2D chunk (set by 00614 data-selection) if more than X% of the channels are already flagged. 00615 default: 50.0 00616 options: 0.0 - 100.0 00617 This option catches broad-band RFI that is partially identified by earlier steps. 00618 00619 growaround -- Flag a point based on the number of flagged points around it. 00620 default: False 00621 options: True/False 00622 For every un-flagged point on the 2D time/freq plane, if more than four 00623 surrounding points are already flagged, flag that point. 00624 This option catches some wings of strong RFI spikes. 00625 00626 flagneartime -- Flag points before and after every flagged one, in the time-direction. 00627 default: False 00628 options: True/False 00629 Note: This can result in excessive flagging. 00630 00631 flagnearfreq -- Flag points before and after every flagged one, in the frequency-direction 00632 default: False 00633 options: True/False 00634 This option allows flagging of wings in the spectral response of strong RFI. 00635 Note: This can result in excessive flagging. 00636 00637 00638 unflag -- Unflag according to the data selection specified. 00639 00640 summary -- List the number of rows and data points flagged. 00641 00642 minrel -- Minimum number of flags (relative) to include in histogram 00643 default: 0.0 00644 00645 maxrel -- Maximum number of flags (relative) to include in histogram 00646 default: 1.0 00647 00648 minabs -- Minimum number of flags (absolute, inclusive) to include in histogram 00649 default: 0 00650 00651 maxabs -- Maximum number of flags (absolute, inclusive) to include in histogram 00652 To indicate infinity, use any negative number. 00653 default: -1 00654 00655 spwchan -- list the number of flags per spw and per channel. 00656 default: False 00657 00658 spwcorr -- list the number of flags per spw and per correlation. 00659 default: False 00660 00661 basecnt -- list the number of flags per baseline 00662 default: False 00663 00664 In summary mode, the task returns a dictionary of flagging statistics. 00665 Example: 00666 00667 s = flagdata(..., mode='summary') 00668 00669 Then s will be a dictionary which contains 00670 s['total'] : total number of data 00671 s['flagged'] : amount of flagged data 00672 00673 00674 00675 action -- Action to perform in MS/cal table or in the input list of parameters. 00676 options: 'none', 'apply','calculate' 00677 default: 'apply' 00678 00679 'apply' -- Apply the flags to the MS. 00680 00681 display -- Display data and/or end-of-MS reports at run-time. 00682 default: 'none' 00683 options: 'none', 'data', 'report', 'both' 00684 00685 'none' --> It will not display anything. 00686 00687 'data' --> display data and flags per-chunk at run-time, within an interactive GUI. 00688 00689 This option opens a GUI to show the 2D time-freq planes of 00690 the data with old and new flags, for all correlations per baseline. 00691 -- The GUI allows stepping through all baselines (prev/next) in 00692 the current chunk (set by 'ntime'), and stepping to the next-chunk. 00693 -- The 'flagdata' task can be quit from the GUI, in case it becomes 00694 obvious that the current set of parameters is just wrong. 00695 -- There is an option to stop the display but continue flagging. 00696 00697 'report' --> displays end-of-MS reports on the screen. 00698 00699 'both' --> displays data per chunk and end-of-MS reports on the screen 00700 00701 flagbackup -- Automatically backup flags before running the tool. 00702 Flagversion names are chosen automatically, and are based on the 00703 mode being used. 00704 default: True 00705 options: True/False 00706 00707 'calculate' -- Only calculate the flags but do not write them to the MS. This is 00708 useful if used together with the display to analyse the results before 00709 writing to the MS. 00710 00711 display -- Display data and/or end-of-MS reports at run-time. See extended description 00712 above. 00713 default: 'none' 00714 options: 'none', 'data', 'report', 'both' 00715 00716 ' ' -- When set to empty, the underlying tool will not be executed and no flags 00717 will be produced. No data selection will be done either. This is useful 00718 when used together with the parameter savepars to only save the current 00719 parameters (or list of parameters) to the FLAG_CMD sub-table or to an 00720 external file. 00721 00722 00723 savepars -- Save the current parameters to the FLAG_CMD table of the MS or to an output text file. 00724 Note that when display is set to anything other than 'none', savepars 00725 will be disabled. This is done because in an interactive mode, the user 00726 may skip data which may invalidate the initial input parameters and there 00727 is no way to save the interactive commands. 00728 default: False 00729 options: True/False 00730 00731 cmdreason -- A string containing a reason to save to the FLAG_CMD table or to an 00732 output text file given by the outfile sub-parameter. If the input 00733 contains any reason, they will be replaced with this one. At the 00734 moment it is not possible to add more than one reason. 00735 default: ' '; no reason will be added to output. 00736 example: cmdreason='CLIP_ZEROS' 00737 00738 outfile -- Name of output file to save the current parameters. 00739 default: ' '; it will save the parameters to the FLAG_CMD table of the MS. 00740 example: outfile='flags.txt' will save the parameters in a text file. 00741 00742 00743 ---- EXAMPLES ---- 00744 00745 NOTE: The vector mode of the previous flagdata task can be achieved with this task by using it 00746 with mode='list' and the commands given in a list in inpmode=[]. Example: 00747 00748 flagdata('my.ms', inpmode='list', inpfile=["mode='clip' clipzeros=True","mode='shadow']) 00749 00750 00751 1) Manually flag scans 1~3 and save the parameters to the FLAG_CMD sub-table. 00752 00753 flagdata('my.ms', scan='1~3, mode='manual', savepars=True) 00754 00755 2) Save the parameters to a file that is open in append mode. 00756 00757 flagdata('my.ms', scan='1~3, mode='manual', savepars=True, outfile='flags.txt') 00758 00759 3a) Flag all the commands given in the Python list of strings. 00760 00761 cmd = ["scan='1~3' mode='manual'", 00762 "spw='9' mode='tfcrop' correlation='ABS_RR,LL' ntime=51.0", 00763 "mode='extend' extendpols=True"] 00764 00765 flagdata('my.ms', mode='list', inpfile=cmd) 00766 00767 3b) Flag all the commands given in the file called flags.txt. 00768 00769 > cat flags.txt 00770 scan='1~3' mode='manual' 00771 spw='9' mode='tfcrop' correlation='ABS_RR,LL' ntime=51.0 00772 mode='extend' extendpols=True 00773 00774 flagdata('my.ms', mode='list', inpfile='flags.txt') 00775 00776 4) Display the data and flags per-chunk and do not write flags to the MS. 00777 00778 flagdata('my.ms', mode='list', inpfile='flags.txt', action='calculate', display='data') 00779 00780 5) Flag all the antennas except antenna=5. 00781 00782 flagdata(vis='my.ms', antenna='!5', mode='manual) 00783 00784 6) Clip the NaN in the data. An empty clipminmax will flag only NaN. 00785 00786 flagdata('my.ms', mode='clip') 00787 00788 7) Clip only the water vapour radiometer data. 00789 00790 flagdata('my.ms',mode='clip',clipminmax=[0,50], correlation='ABS_WVR') 00791 00792 8) Clip only zero-value data. 00793 00794 flagdata('my.ms',mode='clip',clipzeros=True) 00795 00796 9a) Flag only auto-correlations using the autocorr parameter. 00797 00798 flagdata('my.ms', autocorr=True) 00799 00800 9b) Flag only auto-correlations using the antenna selection. 00801 00802 flagdata('my.ms', mode='manual', antenna='*&&&') 00803 00804 10a) Flag based on selected reasons from a file. 00805 00806 > cat flags.txt 00807 scan='1~3' mode='manual' reason='MYREASON' 00808 spw='9' mode='clip' clipzeros=True reason='CLIPZEROS' 00809 mode='manual' scan='4' reason='MYREASON' 00810 00811 flagdata('my.ms', mode='list', inpfile='flags.txt', reason='MYREASON') 00812 00813 10b) The same result of 10a can be achieved using the task flagcmd. 00814 00815 flagcmd('my.ms', inpmode='file', inpfile='flags.txt', action='apply', reason='MYREASON') 00816 00817 11) Automatic flagging using 'rflag', using auto-thresholds, and specifying 00818 a threshold scale-factor to use for flagging. 00819 00820 flagdata('my.ms', mode='rflag',spw='9',timedevscale=4.0,action='apply') 00821 00822 12) Save the interface parameters to the FLAG_CMD sub-table of the MS. Add a reason 00823 to the flag command. This cmdreason will be added to the REASON column of the 00824 FLAG_CMD sub-table. Apply flags in flagcmd. 00825 00826 flagdata('my.ms', mode='clip',channelavg=False, clipminmax=[30., 60.], spw='0:0~10', 00827 correlation='ABS_XX,XY', action='', savepars=True, cmdreason='CLIPXX_XY') 00828 00829 > Select based on the reason. 00830 flagcmd('my.ms', action='apply', reason='CLIPXX_XY') 00831 00832 13) Flag antennas that are shadowed by antennas not present in the MS. 00833 00834 > Create a text file with information about the antennas. 00835 > cat ant.txt 00836 name=VLA01 00837 diameter=25.0 00838 position=[-1601144.96146691, -5041998.01971858, 3554864.76811967] 00839 name=VLA02 00840 diameter=25.0 00841 position=[-1601105.7664601889, -5042022.3917835914, 3554847.245159178] 00842 name=VLA09 00843 diameter=25.0 00844 position=[-1601197.2182404203, -5041974.3604805721, 3554875.1995636248] 00845 name=VLA10 00846 diameter=25.0 00847 position=[-1601227.3367843349,-5041975.7011900628,3554859.1642644769] 00848 00849 00850 flagdata('my.vis', mode='shadow', tolerance=10.0, addantenna='ant.txt') 00851 00852 The antenna information can also be given as a Python dictionary. To create the 00853 dictionary using the flaghelper functions, do the following inside casapy: 00854 00855 > import flaghelper as fh 00856 > antdic = fh.readAntennaList(antfile) 00857 00858 flagdata('my.vis', mode='shadow', tolerance=10.0, addantenna=antdic) 00859 00860 14) Apply the online flags that come from importasdm. 00861 00862 > In importasdm, save the online flags to a file. 00863 importasdm('myasdm', 'asdm.ms', process_flags=True, savecmds=True, outfile='online_flags.txt') 00864 00865 > You can edit the online_flags.txt to add other flagging commands or apply it directly. 00866 flagdata('asdm.ms', mode='list', inpfile='online_flags.txt') 00867 00868 > The same result can be achieved using the task flagcmd. 00869 flagcmd('asdm.ms', inpmode='file', inpfile='online_flags.txt', action='apply') 00870 00871 15) Clip zero data from a calibration table. 00872 00873 flagdata('cal-X54.B1', mode='clip', clipzeros=True, datacolumn='CPARAM') 00874 00875 16) Clip data with SNR <4.0. 00876 00877 flagdata('cal-X54.B1', mode='clip', clipminmax=[0.0,4.0], clipoutside=False, datacolumn='SNR') 00878 00879 00880 ---- SYNTAX FOR COMMANDS GIVEN IN A FILE or LIST OF STRINGS ---- 00881 00882 Basic Syntax Rules 00883 00884 Commands are strings (which may contain internal "strings") consisting of 00885 KEY=VALUE pairs separated by whitespace. 00886 00887 NOTE: There should be no whitespace between KEY=VALUE or within each KEY or 00888 VALUE, since the simple parser first breaks command lines on whitespace, 00889 then on "=". 00890 00891 Use only white spaces to separate the parameters (no commas). 00892 00893 Each key should only appear once on a given command line/string. 00894 00895 There is an implicit "mode" for each command, with the default 00896 being 'manual' if not given. 00897 00898 Comment lines can start with '#' and will be ignored. 00899 00900 Example: 00901 00902 scan='1~3' mode='manual' 00903 # this line will ignored 00904 spw='9' mode='tfcrop' correlation='ABS_XX,YY' ntime=51.0 00905 mode='extend' extendpols=True 00906 scan='1~3,10~12' mode='quack' quackinterval=1.0 00907 00908 00909 """ 00910 if not hasattr(self, "__globals__") or self.__globals__ == None : 00911 self.__globals__=sys._getframe(len(inspect.stack())-1).f_globals 00912 #casac = self.__globals__['casac'] 00913 casalog = self.__globals__['casalog'] 00914 #casalog = casac.casac.logsink() 00915 self.__globals__['__last_task'] = 'flagdata' 00916 self.__globals__['taskname'] = 'flagdata' 00917 ### 00918 self.__globals__['update_params'](func=self.__globals__['taskname'],printtext=False,ipython_globals=self.__globals__) 00919 ### 00920 ### 00921 #Handle globals or user over-ride of arguments 00922 # 00923 function_signature_defaults=dict(zip(self.__call__.func_code.co_varnames,self.__call__.func_defaults)) 00924 useLocalDefaults = False 00925 00926 for item in function_signature_defaults.iteritems(): 00927 key,val = item 00928 keyVal = eval(key) 00929 if (keyVal == None): 00930 #user hasn't set it - use global/default 00931 pass 00932 else: 00933 #user has set it - use over-ride 00934 if (key != 'self') : 00935 useLocalDefaults = True 00936 00937 myparams = {} 00938 if useLocalDefaults : 00939 for item in function_signature_defaults.iteritems(): 00940 key,val = item 00941 keyVal = eval(key) 00942 exec('myparams[key] = keyVal') 00943 self.parameters[key] = keyVal 00944 if (keyVal == None): 00945 exec('myparams[key] = '+ key + ' = self.itsdefault(key)') 00946 keyVal = eval(key) 00947 if(type(keyVal) == dict) : 00948 if len(keyVal) > 0 : 00949 exec('myparams[key] = ' + key + ' = keyVal[len(keyVal)-1][\'value\']') 00950 else : 00951 exec('myparams[key] = ' + key + ' = {}') 00952 00953 else : 00954 async = self.parameters['async'] 00955 myparams['vis'] = vis = self.parameters['vis'] 00956 myparams['mode'] = mode = self.parameters['mode'] 00957 myparams['autocorr'] = autocorr = self.parameters['autocorr'] 00958 myparams['inpfile'] = inpfile = self.parameters['inpfile'] 00959 myparams['reason'] = reason = self.parameters['reason'] 00960 myparams['spw'] = spw = self.parameters['spw'] 00961 myparams['field'] = field = self.parameters['field'] 00962 myparams['antenna'] = antenna = self.parameters['antenna'] 00963 myparams['uvrange'] = uvrange = self.parameters['uvrange'] 00964 myparams['timerange'] = timerange = self.parameters['timerange'] 00965 myparams['correlation'] = correlation = self.parameters['correlation'] 00966 myparams['scan'] = scan = self.parameters['scan'] 00967 myparams['intent'] = intent = self.parameters['intent'] 00968 myparams['array'] = array = self.parameters['array'] 00969 myparams['observation'] = observation = self.parameters['observation'] 00970 myparams['feed'] = feed = self.parameters['feed'] 00971 myparams['clipminmax'] = clipminmax = self.parameters['clipminmax'] 00972 myparams['datacolumn'] = datacolumn = self.parameters['datacolumn'] 00973 myparams['clipoutside'] = clipoutside = self.parameters['clipoutside'] 00974 myparams['channelavg'] = channelavg = self.parameters['channelavg'] 00975 myparams['clipzeros'] = clipzeros = self.parameters['clipzeros'] 00976 myparams['quackinterval'] = quackinterval = self.parameters['quackinterval'] 00977 myparams['quackmode'] = quackmode = self.parameters['quackmode'] 00978 myparams['quackincrement'] = quackincrement = self.parameters['quackincrement'] 00979 myparams['tolerance'] = tolerance = self.parameters['tolerance'] 00980 myparams['addantenna'] = addantenna = self.parameters['addantenna'] 00981 myparams['lowerlimit'] = lowerlimit = self.parameters['lowerlimit'] 00982 myparams['upperlimit'] = upperlimit = self.parameters['upperlimit'] 00983 myparams['ntime'] = ntime = self.parameters['ntime'] 00984 myparams['combinescans'] = combinescans = self.parameters['combinescans'] 00985 myparams['timecutoff'] = timecutoff = self.parameters['timecutoff'] 00986 myparams['freqcutoff'] = freqcutoff = self.parameters['freqcutoff'] 00987 myparams['timefit'] = timefit = self.parameters['timefit'] 00988 myparams['freqfit'] = freqfit = self.parameters['freqfit'] 00989 myparams['maxnpieces'] = maxnpieces = self.parameters['maxnpieces'] 00990 myparams['flagdimension'] = flagdimension = self.parameters['flagdimension'] 00991 myparams['usewindowstats'] = usewindowstats = self.parameters['usewindowstats'] 00992 myparams['halfwin'] = halfwin = self.parameters['halfwin'] 00993 myparams['winsize'] = winsize = self.parameters['winsize'] 00994 myparams['timedev'] = timedev = self.parameters['timedev'] 00995 myparams['freqdev'] = freqdev = self.parameters['freqdev'] 00996 myparams['timedevscale'] = timedevscale = self.parameters['timedevscale'] 00997 myparams['freqdevscale'] = freqdevscale = self.parameters['freqdevscale'] 00998 myparams['spectralmax'] = spectralmax = self.parameters['spectralmax'] 00999 myparams['spectralmin'] = spectralmin = self.parameters['spectralmin'] 01000 myparams['extendpols'] = extendpols = self.parameters['extendpols'] 01001 myparams['growtime'] = growtime = self.parameters['growtime'] 01002 myparams['growfreq'] = growfreq = self.parameters['growfreq'] 01003 myparams['growaround'] = growaround = self.parameters['growaround'] 01004 myparams['flagneartime'] = flagneartime = self.parameters['flagneartime'] 01005 myparams['flagnearfreq'] = flagnearfreq = self.parameters['flagnearfreq'] 01006 myparams['minrel'] = minrel = self.parameters['minrel'] 01007 myparams['maxrel'] = maxrel = self.parameters['maxrel'] 01008 myparams['minabs'] = minabs = self.parameters['minabs'] 01009 myparams['maxabs'] = maxabs = self.parameters['maxabs'] 01010 myparams['spwchan'] = spwchan = self.parameters['spwchan'] 01011 myparams['spwcorr'] = spwcorr = self.parameters['spwcorr'] 01012 myparams['basecnt'] = basecnt = self.parameters['basecnt'] 01013 myparams['action'] = action = self.parameters['action'] 01014 myparams['display'] = display = self.parameters['display'] 01015 myparams['flagbackup'] = flagbackup = self.parameters['flagbackup'] 01016 myparams['savepars'] = savepars = self.parameters['savepars'] 01017 myparams['cmdreason'] = cmdreason = self.parameters['cmdreason'] 01018 myparams['outfile'] = outfile = self.parameters['outfile'] 01019 01020 01021 result = None 01022 01023 # 01024 # The following is work around to avoid a bug with current python translation 01025 # 01026 mytmp = {} 01027 01028 mytmp['vis'] = vis 01029 mytmp['mode'] = mode 01030 mytmp['autocorr'] = autocorr 01031 mytmp['inpfile'] = inpfile 01032 mytmp['reason'] = reason 01033 mytmp['spw'] = spw 01034 mytmp['field'] = field 01035 mytmp['antenna'] = antenna 01036 mytmp['uvrange'] = uvrange 01037 mytmp['timerange'] = timerange 01038 mytmp['correlation'] = correlation 01039 mytmp['scan'] = scan 01040 mytmp['intent'] = intent 01041 mytmp['array'] = array 01042 mytmp['observation'] = observation 01043 mytmp['feed'] = feed 01044 mytmp['clipminmax'] = clipminmax 01045 mytmp['datacolumn'] = datacolumn 01046 mytmp['clipoutside'] = clipoutside 01047 mytmp['channelavg'] = channelavg 01048 mytmp['clipzeros'] = clipzeros 01049 mytmp['quackinterval'] = quackinterval 01050 mytmp['quackmode'] = quackmode 01051 mytmp['quackincrement'] = quackincrement 01052 mytmp['tolerance'] = tolerance 01053 mytmp['addantenna'] = addantenna 01054 mytmp['lowerlimit'] = lowerlimit 01055 mytmp['upperlimit'] = upperlimit 01056 mytmp['ntime'] = ntime 01057 mytmp['combinescans'] = combinescans 01058 mytmp['timecutoff'] = timecutoff 01059 mytmp['freqcutoff'] = freqcutoff 01060 mytmp['timefit'] = timefit 01061 mytmp['freqfit'] = freqfit 01062 mytmp['maxnpieces'] = maxnpieces 01063 mytmp['flagdimension'] = flagdimension 01064 mytmp['usewindowstats'] = usewindowstats 01065 mytmp['halfwin'] = halfwin 01066 mytmp['winsize'] = winsize 01067 mytmp['timedev'] = timedev 01068 mytmp['freqdev'] = freqdev 01069 mytmp['timedevscale'] = timedevscale 01070 mytmp['freqdevscale'] = freqdevscale 01071 mytmp['spectralmax'] = spectralmax 01072 mytmp['spectralmin'] = spectralmin 01073 mytmp['extendpols'] = extendpols 01074 mytmp['growtime'] = growtime 01075 mytmp['growfreq'] = growfreq 01076 mytmp['growaround'] = growaround 01077 mytmp['flagneartime'] = flagneartime 01078 mytmp['flagnearfreq'] = flagnearfreq 01079 mytmp['minrel'] = minrel 01080 mytmp['maxrel'] = maxrel 01081 mytmp['minabs'] = minabs 01082 mytmp['maxabs'] = maxabs 01083 mytmp['spwchan'] = spwchan 01084 mytmp['spwcorr'] = spwcorr 01085 mytmp['basecnt'] = basecnt 01086 mytmp['action'] = action 01087 mytmp['display'] = display 01088 mytmp['flagbackup'] = flagbackup 01089 mytmp['savepars'] = savepars 01090 mytmp['cmdreason'] = cmdreason 01091 mytmp['outfile'] = outfile 01092 pathname='file:///'+os.environ.get('CASAPATH').split()[0]+'/share/xml/' 01093 trec = casac.casac.utils().torecord(pathname+'flagdata.xml') 01094 01095 casalog.origin('flagdata') 01096 try : 01097 #if not trec.has_key('flagdata') or not casac.casac.utils().verify(mytmp, trec['flagdata']) : 01098 #return False 01099 01100 casac.casac.utils().verify(mytmp, trec['flagdata'], True) 01101 scriptstr=[''] 01102 saveinputs = self.__globals__['saveinputs'] 01103 saveinputs('flagdata', 'flagdata.last', myparams, self.__globals__,scriptstr=scriptstr) 01104 if async : 01105 count = 0 01106 keybase = time.strftime("%y%m%d.%H%M%S") 01107 key = keybase + "_" + str(count) 01108 while self.__async__.has_key(key) : 01109 count += 1 01110 key = keybase + "_" + str(count) 01111 result = tm.execute('flagdata', vis, mode, autocorr, inpfile, reason, spw, field, antenna, uvrange, timerange, correlation, scan, intent, array, observation, feed, clipminmax, datacolumn, clipoutside, channelavg, clipzeros, quackinterval, quackmode, quackincrement, tolerance, addantenna, lowerlimit, upperlimit, ntime, combinescans, timecutoff, freqcutoff, timefit, freqfit, maxnpieces, flagdimension, usewindowstats, halfwin, winsize, timedev, freqdev, timedevscale, freqdevscale, spectralmax, spectralmin, extendpols, growtime, growfreq, growaround, flagneartime, flagnearfreq, minrel, maxrel, minabs, maxabs, spwchan, spwcorr, basecnt, action, display, flagbackup, savepars, cmdreason, outfile) 01112 print "Use: " 01113 print " tm.retrieve(return_value) # to retrieve the status" 01114 print 01115 self.rkey = key 01116 self.__async__[key] = result 01117 else : 01118 tname = 'flagdata' 01119 spaces = ' '*(18-len(tname)) 01120 casalog.post('\n##########################################'+ 01121 '\n##### Begin Task: ' + tname + spaces + ' #####') 01122 casalog.post(scriptstr[1][1:]+'\n', 'INFO') 01123 result = flagdata(vis, mode, autocorr, inpfile, reason, spw, field, antenna, uvrange, timerange, correlation, scan, intent, array, observation, feed, clipminmax, datacolumn, clipoutside, channelavg, clipzeros, quackinterval, quackmode, quackincrement, tolerance, addantenna, lowerlimit, upperlimit, ntime, combinescans, timecutoff, freqcutoff, timefit, freqfit, maxnpieces, flagdimension, usewindowstats, halfwin, winsize, timedev, freqdev, timedevscale, freqdevscale, spectralmax, spectralmin, extendpols, growtime, growfreq, growaround, flagneartime, flagnearfreq, minrel, maxrel, minabs, maxabs, spwchan, spwcorr, basecnt, action, display, flagbackup, savepars, cmdreason, outfile) 01124 casalog.post('##### End Task: ' + tname + ' ' + spaces + ' #####'+ 01125 '\n##########################################') 01126 01127 except Exception, instance: 01128 if(self.__globals__.has_key('__rethrow_casa_exceptions') and self.__globals__['__rethrow_casa_exceptions']) : 01129 raise 01130 else : 01131 #print '**** Error **** ',instance 01132 tname = 'flagdata' 01133 casalog.post('An error occurred running task '+tname+'.', 'ERROR') 01134 pass 01135 01136 gc.collect() 01137 return result 01138 # 01139 # 01140 # 01141 def paramgui(self, useGlobals=True, ipython_globals=None): 01142 """ 01143 Opens a parameter GUI for this task. If useGlobals is true, then any relevant global parameter settings are used. 01144 """ 01145 import paramgui 01146 if not hasattr(self, "__globals__") or self.__globals__ == None : 01147 self.__globals__=sys._getframe(len(inspect.stack())-1).f_globals 01148 01149 if useGlobals: 01150 if ipython_globals == None: 01151 myf=self.__globals__ 01152 else: 01153 myf=ipython_globals 01154 01155 paramgui.setGlobals(myf) 01156 else: 01157 paramgui.setGlobals({}) 01158 01159 paramgui.runTask('flagdata', myf['_ip']) 01160 paramgui.setGlobals({}) 01161 01162 # 01163 # 01164 # 01165 def defaults(self, param=None, ipython_globals=None, paramvalue=None, subparam=None): 01166 if not hasattr(self, "__globals__") or self.__globals__ == None : 01167 self.__globals__=sys._getframe(len(inspect.stack())-1).f_globals 01168 if ipython_globals == None: 01169 myf=self.__globals__ 01170 else: 01171 myf=ipython_globals 01172 01173 a = odict() 01174 a['vis'] = '' 01175 a['mode'] = 'manual' 01176 a['action'] = 'apply' 01177 a['savepars'] = False 01178 01179 a['async']=False 01180 a['mode'] = { 01181 0:odict([{'value':'manual'}, {'field':''}, {'spw':''}, {'antenna':''}, {'timerange':''}, {'correlation':''}, {'scan':''}, {'intent':''}, {'array':''}, {'uvrange':''}, {'observation':''}, {'feed':''}, {'autocorr':False}]), 01182 1:odict([{'value':'manualflag'}, {'field':''}, {'spw':''}, {'antenna':''}, {'timerange':''}, {'correlation':''}, {'scan':''}, {'intent':''}, {'array':''}, {'uvrange':''}, {'observation':''}, {'feed':''}, {'autocorr':False}]), 01183 2:odict([{'value':'list'}, {'inpfile':''}, {'reason':'any'}]), 01184 3:odict([{'value':'clip'}, {'field':''}, {'spw':''}, {'antenna':''}, {'timerange':''}, {'correlation':''}, {'scan':''}, {'intent':''}, {'array':''}, {'uvrange':''}, {'observation':''}, {'feed':''}, {'datacolumn':'DATA'}, {'clipminmax':[]}, {'clipoutside':True}, {'channelavg':False}, {'clipzeros':False}]), 01185 4:odict([{'value':'quack'}, {'field':''}, {'spw':''}, {'antenna':''}, {'timerange':''}, {'correlation':''}, {'scan':''}, {'intent':''}, {'array':''}, {'uvrange':''}, {'observation':''}, {'feed':''}, {'quackinterval':0.0}, {'quackmode':'beg'}, {'quackincrement':False}]), 01186 5:odict([{'value':'shadow'}, {'field':''}, {'spw':''}, {'antenna':''}, {'timerange':''}, {'correlation':''}, {'scan':''}, {'intent':''}, {'array':''}, {'uvrange':''}, {'observation':''}, {'feed':''}, {'tolerance':0.0}, {'addantenna':''}]), 01187 6:odict([{'value':'elevation'}, {'field':''}, {'spw':''}, {'antenna':''}, {'timerange':''}, {'correlation':''}, {'scan':''}, {'intent':''}, {'array':''}, {'uvrange':''}, {'observation':''}, {'feed':''}, {'lowerlimit':0.0}, {'upperlimit':90.0}]), 01188 7:odict([{'value':'tfcrop'}, {'field':''}, {'spw':''}, {'antenna':''}, {'timerange':''}, {'correlation':''}, {'scan':''}, {'intent':''}, {'array':''}, {'uvrange':''}, {'observation':''}, {'feed':''}, {'ntime':'scan'}, {'combinescans':False}, {'datacolumn':'DATA'}, {'timecutoff':4.0}, {'freqcutoff':3.0}, {'timefit':'line'}, {'freqfit':'poly'}, {'maxnpieces':7}, {'flagdimension':'freqtime'}, {'usewindowstats':'none'}, {'halfwin':1}]), 01189 8:odict([{'value':'rflag'}, {'field':''}, {'spw':''}, {'antenna':''}, {'timerange':''}, {'correlation':''}, {'scan':''}, {'intent':''}, {'array':''}, {'uvrange':''}, {'observation':''}, {'feed':''}, {'ntime':'scan'}, {'combinescans':False}, {'datacolumn':'DATA'}, {'winsize':3}, {'timedev':''}, {'freqdev':''}, {'timedevscale':5.0}, {'freqdevscale':5.0}, {'spectralmax':1E6}, {'spectralmin':0.0}]), 01190 9:odict([{'value':'extend'}, {'field':''}, {'spw':''}, {'antenna':''}, {'timerange':''}, {'correlation':''}, {'scan':''}, {'intent':''}, {'array':''}, {'uvrange':''}, {'observation':''}, {'feed':''}, {'ntime':'scan'}, {'combinescans':False}, {'extendpols':True}, {'growtime':50.0}, {'growfreq':50.0}, {'growaround':False}, {'flagneartime':False}, {'flagnearfreq':False}]), 01191 10:odict([{'value':'unflag'}, {'field':''}, {'spw':''}, {'antenna':''}, {'timerange':''}, {'correlation':''}, {'scan':''}, {'intent':''}, {'array':''}, {'uvrange':''}, {'observation':''}, {'feed':''}]), 01192 11:odict([{'value':'summary'}, {'field':''}, {'spw':''}, {'antenna':''}, {'timerange':''}, {'correlation':''}, {'scan':''}, {'intent':''}, {'array':''}, {'uvrange':''}, {'observation':''}, {'feed':''}, {'minrel':0.0}, {'maxrel':1.0}, {'minabs':0}, {'maxabs':-1}, {'spwchan':False}, {'spwcorr':False}, {'basecnt':False}])} 01193 a['action'] = { 01194 0:odict([{'value':'apply'}, {'display':''}, {'flagbackup':True}]), 01195 1:odict([{'value':'calculate'}, {'display':''}]), 01196 2:{'value':''}, 01197 3:{'value':'none'}} 01198 a['savepars'] = { 01199 0:{'value':False}, 01200 1:odict([{'value':True}, {'cmdreason':''}, {'outfile':''}])} 01201 01202 ### This function sets the default values but also will return the list of 01203 ### parameters or the default value of a given parameter 01204 if(param == None): 01205 myf['__set_default_parameters'](a) 01206 elif(param == 'paramkeys'): 01207 return a.keys() 01208 else: 01209 if(paramvalue==None and subparam==None): 01210 if(a.has_key(param)): 01211 return a[param] 01212 else: 01213 return self.itsdefault(param) 01214 else: 01215 retval=a[param] 01216 if(type(a[param])==dict): 01217 for k in range(len(a[param])): 01218 valornotval='value' 01219 if(a[param][k].has_key('notvalue')): 01220 valornotval='notvalue' 01221 if((a[param][k][valornotval])==paramvalue): 01222 retval=a[param][k].copy() 01223 retval.pop(valornotval) 01224 if(subparam != None): 01225 if(retval.has_key(subparam)): 01226 retval=retval[subparam] 01227 else: 01228 retval=self.itsdefault(subparam) 01229 else: 01230 retval=self.itsdefault(subparam) 01231 return retval 01232 01233 01234 # 01235 # 01236 def check_params(self, param=None, value=None, ipython_globals=None): 01237 if ipython_globals == None: 01238 myf=self.__globals__ 01239 else: 01240 myf=ipython_globals 01241 # print 'param:', param, 'value:', value 01242 try : 01243 if str(type(value)) != "<type 'instance'>" : 01244 value0 = value 01245 value = myf['cu'].expandparam(param, value) 01246 matchtype = False 01247 if(type(value) == numpy.ndarray): 01248 if(type(value) == type(value0)): 01249 myf[param] = value.tolist() 01250 else: 01251 #print 'value:', value, 'value0:', value0 01252 #print 'type(value):', type(value), 'type(value0):', type(value0) 01253 myf[param] = value0 01254 if type(value0) != list : 01255 matchtype = True 01256 else : 01257 myf[param] = value 01258 value = myf['cu'].verifyparam({param:value}) 01259 if matchtype: 01260 value = False 01261 except Exception, instance: 01262 #ignore the exception and just return it unchecked 01263 myf[param] = value 01264 return value 01265 # 01266 # 01267 def description(self, key='flagdata', subkey=None): 01268 desc={'flagdata': 'All-purpose flagging task based on data-selections and flagging modes/algorithms.', 01269 'vis': 'Name of MS file or calibration table to flag', 01270 'mode': 'Flagging mode (list/manual/clip/shadow/quack/\ 01271 elevation/tfcrop/rflag/extend/unflag/summary)', 01272 'autocorr': 'Flag auto-correlations', 01273 'inpfile': 'Input ASCII file or Python list of strings with flag commands.', 01274 'reason': 'Select by REASON types', 01275 'spw': 'Spectral-window/frequency/channel: \'\' ==> all, spw=\'0:17~19\'', 01276 'field': 'Field names or field index numbers: \'\' ==> all, field=\'0~2,3C286\'', 01277 'antenna': 'Antenna/baselines: \'\' ==> all, antenna =\'3,VA04\'', 01278 'uvrange': 'UV range: \'\' ==> all; uvrange =\'0~100klambda\', default units=meters', 01279 'timerange': 'Time range: \'\' ==> all,timerange=\'09:14:0~09:54:0\'', 01280 'correlation': 'Correlation: \'\' ==> all, correlation=\'XX,YY\'', 01281 'scan': 'Scan numbers: \'\' ==> all', 01282 'intent': 'Observation intent: \'\' ==> all, intent=\'CAL*POINT*\'', 01283 'array': '(Sub)array numbers: \'\' ==> all', 01284 'observation': 'Observation ID: \'\' ==> all', 01285 'feed': 'Multi-feed numbers: Not yet implemented', 01286 'clipminmax': 'Range to use for clipping', 01287 'datacolumn': 'Data column on which to operate (data,corrected,model,residual)', 01288 'clipoutside': 'Clip outside the range, or within it', 01289 'channelavg': 'Average over channels (scalar average)', 01290 'clipzeros': 'Clip zero-value data', 01291 'quackinterval': 'Quack n seconds from scan beginning or end', 01292 'quackmode': 'Quack mode. \'beg\' ==> first n seconds of scan.\'endb\' ==> last n seconds of scan. \'end\' ==> all but first n seconds of scan. \'tail\' ==> all but last n seconds of scan.', 01293 'quackincrement': 'Flag incrementally in time?', 01294 'tolerance': 'Amount of shadow allowed (in meters)', 01295 'addantenna': 'File name or dictionary with additional antenna names, positions and diameters', 01296 'lowerlimit': 'Lower limiting elevation (in degrees)', 01297 'upperlimit': 'Upper limiting elevation (in degrees)', 01298 'ntime': 'Time-range to use for each chunk (in seconds or minutes)', 01299 'combinescans': 'Accumulate data across scans.', 01300 'timecutoff': 'Flagging thresholds in units of deviation from the fit', 01301 'freqcutoff': 'Flagging thresholds in units of deviation from the fit', 01302 'timefit': 'Fitting function for the time direction (poly/line)', 01303 'freqfit': 'Fitting function for the frequency direction (poly/line)', 01304 'maxnpieces': 'Number of pieces in the polynomial-fits (for \'freqfit\' or \'timefit\' = \'poly\')', 01305 'flagdimension': 'Dimensions along which to calculate fits (freq/time/freqtime/timefreq)', 01306 'usewindowstats': 'Calculate additional flags using sliding window statistics (none,sum,std,both)', 01307 'halfwin': 'Half-width of sliding window to use with \'usewindowstats\' (1,2,3).', 01308 'winsize': 'Number of timesteps in the sliding time window [aips:fparm(1)]', 01309 'timedev': 'Time-series noise estimate [aips:noise]', 01310 'freqdev': 'Spectral noise estimate [aips:scutoff]', 01311 'timedevscale': 'Threshold scaling for timedev [aips:fparm(9)]', 01312 'freqdevscale': 'Threshold scaling for freqdev [aips:fparm(10)]', 01313 'spectralmax': 'Flag whole spectrum if freqdev is greater than spectralmax [aips:fparm(6)]', 01314 'spectralmin': 'Flag whole spectrum if freqdev is less than spectralmin [aips:fparm(5)] ', 01315 'extendpols': 'If any correlation is flagged, flag all correlations', 01316 'growtime': 'Flag all \'ntime\' integrations if more than X% of the timerange is flagged (0-100)', 01317 'growfreq': 'Flag all selected channels if more than X% of the frequency range is flagged(0-100)', 01318 'growaround': 'Flag data based on surrounding flags', 01319 'flagneartime': 'Flag one timestep before and after a flagged one (True/False)', 01320 'flagnearfreq': 'Flag one channel before and after a flagged one (True/False)', 01321 'minrel': 'minimum number of flags (relative)', 01322 'maxrel': 'maximum number of flags (relative)', 01323 'minabs': 'minimum number of flags (absolute)', 01324 'maxabs': 'maximum number of flags (absolute). Use a negative value to indicate infinity.', 01325 'spwchan': 'Print summary of channels per spw', 01326 'spwcorr': 'Print summary of correlation per spw', 01327 'basecnt': 'Print summary counts per baseline', 01328 'action': 'Action to perform in MS and/or in inpfile (none/apply/calculate)', 01329 'display': 'Display data and/or end-of-MS reports at runtime (data/report/both).', 01330 'flagbackup': 'Back up the state of flags before the run', 01331 'savepars': 'Save the current parameters to the FLAG_CMD table or to a file', 01332 'cmdreason': 'Reason to save to output file or to FLAG_CMD table.', 01333 'outfile': 'Name of output file to save current parameters. If empty, save to FLAG_CMD', 01334 01335 'async': 'If true the taskname must be started using flagdata(...)' 01336 } 01337 01338 # 01339 # Set subfields defaults if needed 01340 # 01341 01342 if(desc.has_key(key)) : 01343 return desc[key] 01344 01345 def itsdefault(self, paramname) : 01346 a = {} 01347 a['vis'] = '' 01348 a['mode'] = 'manual' 01349 a['autocorr'] = False 01350 a['inpfile'] = '' 01351 a['reason'] = 'any' 01352 a['spw'] = '' 01353 a['field'] = '' 01354 a['antenna'] = '' 01355 a['uvrange'] = '' 01356 a['timerange'] = '' 01357 a['correlation'] = '' 01358 a['scan'] = '' 01359 a['intent'] = '' 01360 a['array'] = '' 01361 a['observation'] = '' 01362 a['feed'] = '' 01363 a['clipminmax'] = [] 01364 a['datacolumn'] = 'DATA' 01365 a['clipoutside'] = True 01366 a['channelavg'] = False 01367 a['clipzeros'] = False 01368 a['quackinterval'] = 1.0 01369 a['quackmode'] = 'beg' 01370 a['quackincrement'] = False 01371 a['tolerance'] = 0.0 01372 a['addantenna'] = '' 01373 a['lowerlimit'] = 0.0 01374 a['upperlimit'] = 90.0 01375 a['ntime'] = 'scan' 01376 a['combinescans'] = False 01377 a['timecutoff'] = 4.0 01378 a['freqcutoff'] = 3.0 01379 a['timefit'] = 'line' 01380 a['freqfit'] = 'poly' 01381 a['maxnpieces'] = 7 01382 a['flagdimension'] = 'freqtime' 01383 a['usewindowstats'] = 'none' 01384 a['halfwin'] = 1 01385 a['winsize'] = 3 01386 a['timedev'] = '' 01387 a['freqdev'] = '' 01388 a['timedevscale'] = 5.0 01389 a['freqdevscale'] = 5.0 01390 a['spectralmax'] = 1E6 01391 a['spectralmin'] = 0.0 01392 a['extendpols'] = True 01393 a['growtime'] = 50.0 01394 a['growfreq'] = 50.0 01395 a['growaround'] = False 01396 a['flagneartime'] = False 01397 a['flagnearfreq'] = False 01398 a['minrel'] = 0.0 01399 a['maxrel'] = 1.0 01400 a['minabs'] = 0 01401 a['maxabs'] = -1 01402 a['spwchan'] = False 01403 a['spwcorr'] = False 01404 a['basecnt'] = False 01405 a['action'] = 'apply' 01406 a['display'] = '' 01407 a['flagbackup'] = True 01408 a['savepars'] = False 01409 a['cmdreason'] = '' 01410 a['outfile'] = '' 01411 01412 #a = sys._getframe(len(inspect.stack())-1).f_globals 01413 01414 if self.parameters['mode'] == 'manual': 01415 a['field'] = '' 01416 a['spw'] = '' 01417 a['antenna'] = '' 01418 a['timerange'] = '' 01419 a['correlation'] = '' 01420 a['scan'] = '' 01421 a['intent'] = '' 01422 a['array'] = '' 01423 a['uvrange'] = '' 01424 a['observation'] = '' 01425 a['feed'] = '' 01426 a['autocorr'] = False 01427 01428 if self.parameters['mode'] == 'manualflag': 01429 a['field'] = '' 01430 a['spw'] = '' 01431 a['antenna'] = '' 01432 a['timerange'] = '' 01433 a['correlation'] = '' 01434 a['scan'] = '' 01435 a['intent'] = '' 01436 a['array'] = '' 01437 a['uvrange'] = '' 01438 a['observation'] = '' 01439 a['feed'] = '' 01440 a['autocorr'] = False 01441 01442 if self.parameters['mode'] == 'list': 01443 a['inpfile'] = '' 01444 a['reason'] = 'any' 01445 01446 if self.parameters['mode'] == 'clip': 01447 a['field'] = '' 01448 a['spw'] = '' 01449 a['antenna'] = '' 01450 a['timerange'] = '' 01451 a['correlation'] = '' 01452 a['scan'] = '' 01453 a['intent'] = '' 01454 a['array'] = '' 01455 a['uvrange'] = '' 01456 a['observation'] = '' 01457 a['feed'] = '' 01458 a['datacolumn'] = 'DATA' 01459 a['clipminmax'] = [] 01460 a['clipoutside'] = True 01461 a['channelavg'] = False 01462 a['clipzeros'] = False 01463 01464 if self.parameters['mode'] == 'quack': 01465 a['field'] = '' 01466 a['spw'] = '' 01467 a['antenna'] = '' 01468 a['timerange'] = '' 01469 a['correlation'] = '' 01470 a['scan'] = '' 01471 a['intent'] = '' 01472 a['array'] = '' 01473 a['uvrange'] = '' 01474 a['observation'] = '' 01475 a['feed'] = '' 01476 a['quackinterval'] = 0.0 01477 a['quackmode'] = 'beg' 01478 a['quackincrement'] = False 01479 01480 if self.parameters['mode'] == 'shadow': 01481 a['field'] = '' 01482 a['spw'] = '' 01483 a['antenna'] = '' 01484 a['timerange'] = '' 01485 a['correlation'] = '' 01486 a['scan'] = '' 01487 a['intent'] = '' 01488 a['array'] = '' 01489 a['uvrange'] = '' 01490 a['observation'] = '' 01491 a['feed'] = '' 01492 a['tolerance'] = 0.0 01493 a['addantenna'] = '' 01494 01495 if self.parameters['mode'] == 'elevation': 01496 a['field'] = '' 01497 a['spw'] = '' 01498 a['antenna'] = '' 01499 a['timerange'] = '' 01500 a['correlation'] = '' 01501 a['scan'] = '' 01502 a['intent'] = '' 01503 a['array'] = '' 01504 a['uvrange'] = '' 01505 a['observation'] = '' 01506 a['feed'] = '' 01507 a['lowerlimit'] = 0.0 01508 a['upperlimit'] = 90.0 01509 01510 if self.parameters['mode'] == 'tfcrop': 01511 a['field'] = '' 01512 a['spw'] = '' 01513 a['antenna'] = '' 01514 a['timerange'] = '' 01515 a['correlation'] = '' 01516 a['scan'] = '' 01517 a['intent'] = '' 01518 a['array'] = '' 01519 a['uvrange'] = '' 01520 a['observation'] = '' 01521 a['feed'] = '' 01522 a['ntime'] = 'scan' 01523 a['combinescans'] = False 01524 a['datacolumn'] = 'DATA' 01525 a['timecutoff'] = 4.0 01526 a['freqcutoff'] = 3.0 01527 a['timefit'] = 'line' 01528 a['freqfit'] = 'poly' 01529 a['maxnpieces'] = 7 01530 a['flagdimension'] = 'freqtime' 01531 a['usewindowstats'] = 'none' 01532 a['halfwin'] = 1 01533 01534 if self.parameters['mode'] == 'rflag': 01535 a['field'] = '' 01536 a['spw'] = '' 01537 a['antenna'] = '' 01538 a['timerange'] = '' 01539 a['correlation'] = '' 01540 a['scan'] = '' 01541 a['intent'] = '' 01542 a['array'] = '' 01543 a['uvrange'] = '' 01544 a['observation'] = '' 01545 a['feed'] = '' 01546 a['ntime'] = 'scan' 01547 a['combinescans'] = False 01548 a['datacolumn'] = 'DATA' 01549 a['winsize'] = 3 01550 a['timedev'] = '' 01551 a['freqdev'] = '' 01552 a['timedevscale'] = 5.0 01553 a['freqdevscale'] = 5.0 01554 a['spectralmax'] = 1E6 01555 a['spectralmin'] = 0.0 01556 01557 if self.parameters['mode'] == 'extend': 01558 a['field'] = '' 01559 a['spw'] = '' 01560 a['antenna'] = '' 01561 a['timerange'] = '' 01562 a['correlation'] = '' 01563 a['scan'] = '' 01564 a['intent'] = '' 01565 a['array'] = '' 01566 a['uvrange'] = '' 01567 a['observation'] = '' 01568 a['feed'] = '' 01569 a['ntime'] = 'scan' 01570 a['combinescans'] = False 01571 a['extendpols'] = True 01572 a['growtime'] = 50.0 01573 a['growfreq'] = 50.0 01574 a['growaround'] = False 01575 a['flagneartime'] = False 01576 a['flagnearfreq'] = False 01577 01578 if self.parameters['mode'] == 'unflag': 01579 a['field'] = '' 01580 a['spw'] = '' 01581 a['antenna'] = '' 01582 a['timerange'] = '' 01583 a['correlation'] = '' 01584 a['scan'] = '' 01585 a['intent'] = '' 01586 a['array'] = '' 01587 a['uvrange'] = '' 01588 a['observation'] = '' 01589 a['feed'] = '' 01590 01591 if self.parameters['mode'] == 'summary': 01592 a['field'] = '' 01593 a['spw'] = '' 01594 a['antenna'] = '' 01595 a['timerange'] = '' 01596 a['correlation'] = '' 01597 a['scan'] = '' 01598 a['intent'] = '' 01599 a['array'] = '' 01600 a['uvrange'] = '' 01601 a['observation'] = '' 01602 a['feed'] = '' 01603 a['minrel'] = 0.0 01604 a['maxrel'] = 1.0 01605 a['minabs'] = 0 01606 a['maxabs'] = -1 01607 a['spwchan'] = False 01608 a['spwcorr'] = False 01609 a['basecnt'] = False 01610 01611 if self.parameters['action'] == 'apply': 01612 a['display'] = '' 01613 a['flagbackup'] = True 01614 01615 if self.parameters['action'] == 'calculate': 01616 a['display'] = '' 01617 01618 if self.parameters['savepars'] == True: 01619 a['cmdreason'] = '' 01620 a['outfile'] = '' 01621 01622 if a.has_key(paramname) : 01623 return a[paramname] 01624 flagdata_cli = flagdata_cli_()