casa
$Rev:20696$
|
00001 # 00002 # This file was generated using xslt from its XML file 00003 # 00004 # Copyright 2009, Associated Universities Inc., Washington DC 00005 # 00006 import sys 00007 import os 00008 from casac import * 00009 import string 00010 from taskinit import casalog 00011 #from taskmanager import tm 00012 import task_sdflag 00013 def sdflag(infile='', antenna=0, specunit='', restfreq='', frame='', doppler='', scanlist=[], field='', iflist=[], pollist=[], maskflag=[], flagrow=[], clip=False, clipminmax=[], clipoutside=True, flagmode='flag', interactive=False, showflagged=False, outfile='', outform='ASAP', overwrite=True, plotlevel=0): 00014 00015 """ASAP SD spectral flagging task 00016 Keyword arguments: 00017 infile -- name of input SD dataset 00018 antenna -- antenna name or id (only effective for MS input). 00019 specunit -- units for spectral axis 00020 options: (str) 'channel','km/s','GHz','MHz','kHz','Hz','' 00021 default: '' (=current) 00022 example: this will be the units for maskflag 00023 >>> specunit expandable parameters 00024 restfreq -- rest frequency 00025 available type includes float, int, string, list of float, 00026 list of int, list of string, and list of dictionary. the 00027 default unit of restfreq in case of float, int, or string 00028 without unit is Hz. string input can be a value only 00029 (treated as Hz) or a value followed by unit for which 'GHz', 00030 'MHz','kHz',and 'Hz' are available. 00031 a list can be used to set different rest frequencies for 00032 each IF. the length of list input must be nIF. dictionary 00033 input should be a pair of molecule name and frequency with 00034 keys of 'name' and 'value', respectively. values in the 00035 dictionary input follows the same manner as for single 00036 float or string input. 00037 example: 345.796 00038 '1420MHz' 00039 [345.8, 347.0, 356.7] 00040 ['345.8MHz', '347.0MHz', '356.7MHz'] 00041 [{'name':'CO','value':345}] 00042 frame -- frequency frame for spectral axis 00043 options: (str) 'LSRK','REST','TOPO','LSRD','BARY', 00044 'GEO','GALACTO','LGROUP','CMB' 00045 default: currently set frame in scantable 00046 WARNING: frame='REST' not yet implemented 00047 doppler -- doppler mode 00048 options: (str) 'RADIO','OPTICAL','Z','BETA','GAMMA' 00049 default: currently set doppler in scantable 00050 scanlist -- list of scan numbers to process 00051 default: [] (use all scans) 00052 example: [21,22,23,24] 00053 this selection is in addition to field and iflist 00054 field -- selection string for selecting scans by name 00055 default: '' (no name selection) 00056 example: 'FLS3a*' 00057 this selection is in addition to scanlist, iflist, and pollist 00058 iflist -- list of IF id numbers to select 00059 default: [] (use all IFs) 00060 example: [15] 00061 this selection is in addition to scanlist, field, and pollist 00062 pollist -- list of polarization id numbers to select 00063 default: [] (use all polarizations) 00064 example: [1] 00065 this selection is in addition to scanlist, field, and iflist 00066 maskflag -- list of mask regions to apply flag/unflag 00067 Note, this parameter is ignored if one or more rows are 00068 given in flagrow, or clip=True. 00069 default: [] (entire spectrum) 00070 example: [[1000,3000],[5000,7000]] 00071 flagrow -- list of row numbers to apply flag/unflag 00072 Note, this parameter is effective only when one or more row 00073 numbers are given explicitly and also clip=False 00074 default: [] (no row selection) 00075 example: [0, 2, 3] 00076 clip -- flag data that are outside a specified range 00077 options: (bool)True,False 00078 default: False 00079 >>> clip expandable parameters 00080 clipminmax -- range of data that will NOT be flagged 00081 default: [] means do not use clip option 00082 example: [0.0,1.5] 00083 clipoutside -- clip OUTSIDE the range ? 00084 options: (bool)True,False 00085 default: True 00086 example: clipoutside=False means flag data WITHIN the range. 00087 flagmode -- flag mode 00088 default: 'flag' 00089 options: 'flag','unflag' 00090 interactive -- determines interactive flagging 00091 options: (bool) True,False 00092 default: False 00093 >>> interactive expandable parameters 00094 showflagged -- show flagged data on plots 00095 default: False 00096 outfile -- Name of output file 00097 default: '' 00098 Note: by default (outfile=''), actual output file name is set as follows: 00099 (1) if overwrite=True (default), infile (input) will be overwritten. 00100 WARNING: If the formats of input and ouput files are different, 00101 this causes complete loss of input file. 00102 (2) if overwrite=False, outfile will be <infile>_f. 00103 outform -- format of output file 00104 options: 'ASCII','SDFITS','MS','ASAP' 00105 default: 'ASAP' 00106 example: the ASAP format is easiest for further sd 00107 processing; use MS for CASA imaging. 00108 WARNING: Be sure outform is same as the input file format when you 00109 overwrite the input file by overwrite=True and outfile='' (default). 00110 overwrite -- overwrite the output file if already exists 00111 options: (bool) True,False 00112 default: True 00113 WARNING: input file is overwritten if overwrite=True and outfile='' (default). 00114 This causes the complete loss of input file if the formats of 00115 input and ouput files are different. 00116 plotlevel -- control for plotting of results 00117 options: (int) 0=none, 1=some, 2=more, <0=hardcopy 00118 default: 0 (no plotting) 00119 example: plotlevel<0 as abs(plotlevel), e.g. 00120 -1 => hardcopy of final plot (will be named 00121 <outfile>_flag.eps) 00122 WARNING: be careful plotting in fsotf mode! 00123 00124 ------------------------------------------------------------------- 00125 00126 DESCRIPTION: 00127 00128 Task sdflag performs both interactive and non-interactive channel/row 00129 based flagging on spectra. 00130 Currently, the available ways of non-interactive flagging include: 00131 (1) channel based flagging by specifying a range of spectral values 00132 with clip=True, (2) row based flagging by specifying a list of row 00133 numbers to the flagrow parameter, and (3) channel based flagging by 00134 specifying regions in channel to the maskflag parameter. 00135 These three ways of flagging can not be executed simultaneously. 00136 If more than one parameter above are specified, the task looks for 00137 them in the above order and operates the first specified way of 00138 flagging operation. 00139 00140 Interactive flagging is available when interactive=True. 00141 The available ways of interactive flagging include: 00142 (1) row based flagging by selecting 'panel' and (2) channel 00143 based flagging by selecting 'region's of channels on Flag plotter. 00144 Note that the Flag plotter is loaded after carrying out the 00145 non-interactive flag operation if any specified. See the cookbook for 00146 details of how to select channel regions and spectra on the plotter. 00147 00148 If plotlevel>=1, the task asks you if you really apply the 00149 flags before it is actually written to the data with a plot 00150 indicating flagged regions. 00151 Please note that this task is still experimental. 00152 00153 WARNING for overwrite option: 00154 Be sure 'outform' is the same as data format of input file when you 00155 overwrite it. Since CASA 3.1, the default value of the option 'overwrite' 00156 has been changed to True, thereby the current dataset (infile) is 00157 overwritten unless a different file name is set to outfile. 00158 There is a known issue in overwriting infile. If 'outform' differs to the 00159 data format of infile, the data is overwritten with the new data format 00160 (specified by 'outform') and the data in the original format will be lost. 00161 00162 WARNING for the GBT raw SDFITS format data as input: 00163 SDtasks are able to handle GBT raw SDFITS format data since the 00164 data filler is available. However, the functionality is not well 00165 tested yet, so that there may be unknown bugs. 00166 00167 00168 """ 00169 if type(scanlist)==int: scanlist=[scanlist] 00170 if type(iflist)==int: iflist=[iflist] 00171 if type(maskflag)==int: maskflag=[maskflag] 00172 if type(flagrow)==int: flagrow=[flagrow] 00173 00174 # 00175 # The following is work around to avoid a bug with current python translation 00176 # 00177 mytmp = {} 00178 00179 mytmp['infile'] = infile 00180 mytmp['antenna'] = antenna 00181 mytmp['specunit'] = specunit 00182 mytmp['restfreq'] = restfreq 00183 mytmp['frame'] = frame 00184 mytmp['doppler'] = doppler 00185 mytmp['scanlist'] = scanlist 00186 mytmp['field'] = field 00187 mytmp['iflist'] = iflist 00188 mytmp['pollist'] = pollist 00189 mytmp['maskflag'] = maskflag 00190 mytmp['flagrow'] = flagrow 00191 mytmp['clip'] = clip 00192 mytmp['clipminmax'] = clipminmax 00193 mytmp['clipoutside'] = clipoutside 00194 mytmp['flagmode'] = flagmode 00195 mytmp['interactive'] = interactive 00196 mytmp['showflagged'] = showflagged 00197 mytmp['outfile'] = outfile 00198 mytmp['outform'] = outform 00199 mytmp['overwrite'] = overwrite 00200 mytmp['plotlevel'] = plotlevel 00201 pathname='file:///'+os.environ.get('CASAPATH').split()[0]+'/share/xml/' 00202 trec = casac.utils().torecord(pathname+'sdflag.xml') 00203 00204 casalog.origin('sdflag') 00205 if trec.has_key('sdflag') and casac.utils().verify(mytmp, trec['sdflag']) : 00206 result = task_sdflag.sdflag(infile, antenna, specunit, restfreq, frame, doppler, scanlist, field, iflist, pollist, maskflag, flagrow, clip, clipminmax, clipoutside, flagmode, interactive, showflagged, outfile, outform, overwrite, plotlevel) 00207 00208 else : 00209 result = False 00210 return result