Coverage for /wheeldirectory/casa-6.7.0-12-py3.10.el8/lib/py/lib/python3.10/site-packages/casatasks/sdbaseline.py: 56%
27 statements
« prev ^ index » next coverage.py v7.6.4, created at 2024-10-31 18:48 +0000
« prev ^ index » next coverage.py v7.6.4, created at 2024-10-31 18:48 +0000
1##################### generated by xml-casa (v2) from sdbaseline.xml ################
2##################### 4530469d254eac6ebd5f62b408a92603 ##############################
3from __future__ import absolute_import
4import numpy
5from casatools.typecheck import CasaValidator as _val_ctor
6_pc = _val_ctor( )
7from casatools.coercetype import coerce as _coerce
8from casatools.errors import create_error_string
9from .private.task_sdbaseline import sdbaseline as _sdbaseline_t
10from casatasks.private.task_logging import start_log as _start_log
11from casatasks.private.task_logging import end_log as _end_log
12from casatasks.private.task_logging import except_log as _except_log
14class _sdbaseline:
15 """
16 sdbaseline ---- Fit/subtract a spectral baseline
19 Task sdbaseline fits and/or subtracts baseline from single-dish spectra.
20 Given baseline parameters (baseline type, order, etc.), sdbaseline
21 computes the best-fit baseline for each spectrum by least-square fitting
22 method and, if you want, subtracts it. The best-fit baseline parameters
23 (including baseline type, coefficients of basis functions, etc.) and
24 other values such as residual rms can be saved in various formats
25 including ascii text (in human-readable format or CSV format) or baseline
26 table (a CASA table).
27 Sdbaseline has another mode to 'apply' a baseline table to a MS data;
28 for each spectrum in MS, the best-fit baseline is reproduced from the
29 baseline parameters stored in the given baseline table and subtracted.
30 Putting 'fit' and 'subtract' into separate processes can be useful for
31 pipeline processing for huge dataset.
34 --------- parameter descriptions ---------------------------------------------
36 infile name of input SD dataset
37 datacolumn name of data column to be used ["data", "float_data", or "corrected"]
38 antenna select data by antenna name or ID, e.g. "PM03"
39 field select data by field IDs and names, e.g. "3C2*" (""=all)
40 spw select data by IF IDs (spectral windows), e.g. "3,5,7" (""=all)
41 timerange select data by time range, e.g. "09:14:0~09:54:0" (""=all) (see examples in help)
42 scan select data by scan numbers, e.g. "21~23" (""=all)
43 pol select data by polarization IDs, e.g. "XX,YY" (""=all)
44 intent select data by observational intent, e.g. "*ON_SOURCE*" (""=all)
45 reindex Re-index indices in subtables based on data selection. Ignored when blmode='apply'.
46 maskmode mode of setting additional channel masks. "list" and "auto" are available now.
47 thresh S/N threshold for linefinder
48 avg_limit channel averaging for broad lines
49 minwidth the minimum channel width to detect as a line
50 edge channels to drop at beginning and end of spectrum
51 blmode baselining mode ["fit" or "apply"]
52 dosubtract subtract baseline from input data [True, False]
53 blformat format(s) of file(s) in which best-fit parameters are written ["text", "csv", "table" or ""]
54 bloutput name(s) of file(s) in which best-fit parameters are written
55 bltable name of baseline table to apply
56 blfunc baseline model function ["poly", "chebyshev", "cspline", "sinusoid", or "variable"(expert mode)]
57 order order of baseline model function
58 npiece number of element polynomials for cubic spline curve
59 applyfft automatically set wave numbers of sinusoids
60 fftmethod method for automatically set wave numbers of sinusoids
61 fftthresh threshold to select wave numbers of sinusoids
62 addwn additional wave numbers to use
63 rejwn wave numbers NOT to use
64 clipthresh clipping threshold for iterative fitting
65 clipniter maximum iteration number for iterative fitting
66 blparam text file that stores per spectrum fit parameters
67 verbose output fitting parameters to logger
68 updateweight update WEIGHT column based on sigmavalue computed over unmasked range
69 sigmavalue value used for computing weight ["stddev" or "rms"]
70 showprogress (NOT SUPPORTED YET) show progress status for large data
71 minnrow (NOT SUPPORTED YET) minimum number of input spectra to show progress status
72 outfile name of output file
73 overwrite overwrite the output file if already exists
74 [1;42mRETURNS[1;m void
76 --------- examples -----------------------------------------------------------
79 -----------------
80 Keyword arguments
81 -----------------
82 infile -- name of input SD dataset
83 datacolumn -- name of data column to be used
84 options: 'data', 'float_data', or 'corrected'
85 default: 'data'
86 antenna -- select data by antenna name or ID
87 default: '' (use all antennas)
88 example: 'PM03'
89 field -- select data by field IDs and names
90 default: '' (use all fields)
91 example: field='3C2*' (all names starting with 3C2)
92 field='0,4,5~7' (field IDs 0,4,5,6,7)
93 field='0,3C273' (field ID 0 or field named 3C273)
94 this selection is in addition to the other selections to data
95 spw -- select data by IF IDs (spectral windows)/channels
96 default: '' (use all IFs and channels)
97 example: spw='3,5,7' (IF IDs 3,5,7; all channels)
98 spw='<2' (IF IDs less than 2, i.e., 0,1; all channels)
99 spw='30~45GHz' (IF IDs with the center frequencies in range 30-45GHz; all channels)
100 spw='0:5~61' (IF ID 0; channels 5 to 61; all channels)
101 spw='3:10~20;50~60' (select multiple channel ranges within IF ID 3)
102 spw='3:10~20,4:0~30' (select different channel ranges for IF IDs 3 and 4)
103 spw='1~4;6:15~48' (for channels 15 through 48 for IF IDs 1,2,3,4 and 6)
104 this selection is in addition to the other selections to data
105 timerange -- select data by time range
106 default: '' (use all)
107 example: timerange = 'YYYY/MM/DD/hh:mm:ss~YYYY/MM/DD/hh:mm:ss'
108 Note: YYYY/MM/DD can be dropped as needed:
109 timerange='09:14:00~09:54:00' # this time range
110 timerange='09:44:00' # data within one integration of time
111 timerange='>10:24:00' # data after this time
112 timerange='09:44:00+00:13:00' #data 13 minutes after time
113 this selection is in addition to the other selections to data
114 scan -- select data by scan numbers
115 default: '' (use all scans)
116 example: scan='21~23' (scan IDs 21,22,23)
117 this selection is in addition to the other selections to data
118 pol -- select data by polarization IDs
119 default: '' (use all polarizations)
120 example: pol='XX,YY' (polarizations XX and YY)
121 this selection is in addition to the other selections to data
122 intent -- select data by observational intent, also referred to as 'scan intent'
123 default: '' (use all scan intents)
124 example: intent='*ON_SOURCE*' (any valid scan-intent expression accepted by the MSSelection module can be specified)
125 this selection is in addition to the other selections to data
126 reindex -- Re-index indices in subtables based on data selection.
127 Ignored when blmode='apply'.
128 If True, DATA_DESCRIPTION, FEED, SPECTRAL_WINDOW, STATE, and SOURCE
129 subtables are filtered based on data selection and re-indexed in output MS.
130 default: True
131 maskmode -- mode of setting additional channel masks. When blmode='apply'
132 and/or blfunc='variable', maskmode and its subparameters
133 are ignored.
134 options: 'list', 'auto'
135 default: 'list'
136 example: maskmode='list' uses channel masks specified with the
137 spw parameter. Note that additional channel masks may
138 be applied in case you turn on iterative sigma clipping
139 by setting a positive number to the clipniter parameter,
140 but linefinder doesn't run with this mode.
141 maskmode='auto' runs linefinder to detect line regions
142 to be excluded from fitting. this mode requires four
143 expandable parameters: thresh, avg_limit, minwidth, and edge.
144 NOTE maskmode='auto' is EXPERIMENTAL.
145 USE WITH CARE! May need to tweak the expandable parameters.
146 Note also that channel masks given with the spw parameters
147 and additional masks set by iterative sigma clipping are
148 effective; the actual channel mask will be a composite
149 of these masks (i.e., linefinder + spw + sigma clipping).
150 >>> maskmode expandable parameters
151 thresh -- S/N threshold for linefinder. a single channel S/N ratio
152 above which the channel is considered to be a detection.
153 default: 5
154 avg_limit -- channel averaging for broad lines. a number of
155 consecutive channels not greater than this parameter
156 can be averaged to search for broad lines.
157 default: 4
158 minwidth -- the minimum channel width to detect as a line.
159 a line with number of consecutive channels less
160 than this parameter will not be detected as a line.
161 default: 4
162 edge -- channels to drop at beginning and end of spectrum
163 default: 0
164 example: edge=[1000] drops 1000 channels at beginning AND end.
165 edge=[1000,500] drops 1000 from beginning and 500
166 from end.
167 Note: For bad baselines threshold should be increased,
168 and avg_limit decreased (r even switched off completely by
169 setting this parameter to 1) to avoid detecting baseline
170 undulations instead of real lines.
171 blmode -- baselining mode.
172 options: 'fit', 'apply'
173 default: 'fit'
174 example: blmode='fit' calculates the best-fit baseline based on
175 given baseline type, then (if you set dosubtract=True)
176 subtract it from each spectrum. The information about
177 best-fit baselines (baseline type, order, coefficients,
178 etc.) can be stored in various formats (cf. blformat).
179 blmode='apply' reads a baseline table as well as input
180 MS, reproduces the best-fit baseline via info written
181 in the baseline table, then subtracts it from each
182 spectrum.
183 >>> blmode expandable parameters
184 dosubtract -- execute baseline subtraction in addition to fitting.
185 Note that MS is not output when dosubtract=False.
186 Also, sdbaseline will abort when dosubtract=False
187 and blformat=''.
188 options: (bool) True, False
189 default: True
190 blformat -- format(s) of file(s) in which best-fit parameters are
191 written.
192 options: 'text', 'csv', 'table', and '' can be set for
193 a single output. In case you want to output
194 fitting results in multiple formats, a list
195 containing the above keywords is accepted as well.
196 default: 'text'
197 example: (1) blformat='text' outputs an ascii text file
198 with the best-fit baseline parameters written
199 in human-readable format. It may be good to read,
200 but you should mind it might be huge.
201 (2) blformat='csv' outputs a CSV file. For example,
202 output of csv with blfunc='poly' is as below:
203 #scan, beam, spw, pol, MJD[s], fitrange (i.e. inverse mask), blfunc, order, fitting coefficients, rms, number of clipped channels
204 4,0,17,0,4915973292.23,[[252;3828]],poly,1,767.647,-0.00956208,26.3036,0
205 ... .
206 (3) blformat='table' outputs a baseline table
207 which can be used to apply afterwards.
208 (4) blformat='' doesn't output any parameter file.
209 (5) blformat=['csv','table'] outputs both a CSV
210 file and a baseline table.
211 (6) If one or more ''s appear in blformat, they
212 are all ignored. For example, if blformat=['',
213 'text',''] is given, only 'text' will be output.
214 (7) Elements of blformat other than '' must not
215 be duplicated. For example, blformat=['text','',
216 'text'] is not accepted.
217 bloutput -- name(s) of file(s) in which best-fit parameters are
218 written. If bloutput is a null string '', name(s) of
219 baseline parameter file(s) will be set as follows:
220 <outfile>_blparam.txt for blformat='text',
221 <outfile>_blparam.csv for blformat='csv', and
222 <outfile>_blparam.bltable for blformat='table'.
223 Otherwise, blformat and bloutput must have the same
224 length, and one-to-one correspondence is assumed
225 between them. If there are '' elements in bloutput,
226 output file names will be set by following the above
227 rules. If there are '' elements in blformat, the
228 corresponding bloutput elements will be ignored.
229 Also, non-'' bloutput elements correspoding to
230 non-'' blformat elements must not be duplicated.
231 default: ''
232 example: (1) bloutput='' and blformat=['csv','table']:
233 outputs a csv file '<outfile>_blparam.csv'
234 and a baseline table '<outfile>_blparam.bltable'.
235 (2) bloutput=['foo.csv',''] and blformat=['csv',
236 'table']: outputs a csv file 'foo.csv' and a
237 baseline table '<outfile>_blparam.bltable'.
238 (3) bloutput=['foo.csv','bar.blt'] and blformat=
239 ['csv','']: outputs a csv file 'foo.csv' only.
240 (4) bloutput=['foo.csv','foo.csv','bar.blt'] and
241 blformat=['csv','','table']: the second 'foo.csv'
242 is ignored because it corresponds to the blformat
243 element '', and thus outputs a csv file 'foo.csv'
244 and a baseline table 'bar.blt'.
245 (5) bloutput=['foo.csv','foo.csv','bar.blt'] and
246 blformat=['csv','text','table']: will be error
247 since 'foo.csv' is duplicated.
248 (6) bloutput=['foo.csv','bar.blt'] and blformat=
249 ['csv','','table']: will be error since bloutput
250 and blformat have different lengths.
251 bltable -- name of baseline table to apply
252 default: ''
253 blfunc -- baseline model function. In cases blmode='apply' or blparam is
254 set, blfunc and its subparameters are ignored.
255 options: 'poly', 'chebyshev', 'cspline', 'sinusoid' or 'variable'
256 default: 'poly'
257 example: blfunc='poly' uses a single polynomial line of
258 any order which should be given as an expandable
259 parameter 'order' to fit baseline.
260 blfunc='chebyshev' uses Chebyshev polynomials.
261 blfunc='cspline' uses a cubic spline function, a piecewise
262 cubic polynomial having C2-continuity (i.e., the second
263 derivative is continuous at the joining points).
264 blfunc='sinusoid' uses a combination of sinusoidal curves.
265 NOTE blfunc='variable' IS EXPERT MODE!!!
266 >>> blfunc expandable parameters
267 order -- order of baseline model function
268 options: (int) (<0 turns off baseline fitting)
269 default: 5
270 example: typically in range 2-9 (higher values
271 seem to be needed for GBT)
272 npiece -- number of the element polynomials of cubic spline curve
273 options: (int) (<0 turns off baseline fitting)
274 default: 2
275 applyfft -- automatically choose an appropriate set of sinusoidal
276 wave numbers via FFT for each spectrum data.
277 options: (bool) True, False
278 default: True
279 fftmethod -- method to be used when applyfft=True. Now only
280 'fft' is available and it is the default.
281 fftthresh -- threshold on Fourier-domain spectrum data to pick up
282 appropriate wave numbers to be used for sinusoidal
283 fitting. both (float) and (str) accepted.
284 given a float value, the unit is set to sigma.
285 for string values, allowed formats include:
286 'xsigma' or 'x' (= above x-sigma level. e.g., '3sigma')
287 or 'topx' (= the x strongest ones, e.g. 'top5').
288 default is 3.0 (i.e., above 3sigma level).
289 addwn -- additional wave number(s) of sinusoids to be used
290 for fitting.
291 (list) and (int) are accepted to specify every
292 wave numbers. also (str) can be used in case
293 you need to specify wave numbers in a certain range.
294 default: [0] (i.e., constant is subtracted at least)
295 example: 0
296 [0,1,2]
297 '0,1,2'
298 'a-b' (= a, a+1, ..., b)
299 'a~b' (= a, a+1, ..., b)
300 '<a' (= 0,1,...,a-2,a-1)
301 '>=a' (= a, a+1, ... up to the maximum wave
302 number corresponding to the Nyquist
303 frequency for the case of FFT)
304 rejwn -- wave number(s) of sinusoid NOT to be used for fitting.
305 can be set just as addwn but has higher priority:
306 wave numbers which are specified both in addwn
307 and rejwn will NOT be used.
308 note also that rejwn value takes precedence over those
309 automatically selected by setting applyfft=True as well.
310 default: []
311 clipthresh -- clipping threshold for iterative fitting
312 default: 3
313 clipniter -- maximum iteration number for iterative fitting
314 default: 0 (no iteration, i.e., no clipping)
315 blparam -- the name of text file that stores per spectrum fit
316 parameters. See below for details of format.
317 verbose -- output fitting parameters to logger (ONLY available
318 for blfunc='variable'. if False, the fitting parameters are
319 not output to the CASA logger.
320 options: (bool) True, False
321 default: False
322 updateweight -- update WEIGHT column of output MS based on sigmavalue
323 computed over unmasked ranges of post-subtraction
324 spectra for each row. Note that SIGMA_SPECTRUM and
325 WEIGHT_SPECTRUM columns are removed if they exist.
326 options: (bool) True, False
327 default: False
328 >>> updateweight expandable parameter
329 sigmavalue -- value used to compute weight as 1/(sigmavalue)^2
330 options: stddev, rms
331 default: stddev
332 showprogress -- (NOT SUPPORTED YET) show progress status for large data
333 options: (bool) False (this capability is currently unavailable.)
334 default: False
335 >>> showprogress expandable parameter
336 minnrow -- (NOT SUPPORTED YET) minimum number of input spectra to show progress status
337 default: 1000
338 outfile -- name of output file
339 default: '' (<infile>_bs)
340 overwrite -- overwrite the output files (outfile and bloutput) if they
341 already exist
342 options: (bool) True, False
343 default: False
344 NOTE this parameter is ignored when outform='ASCII'
347 -----------
348 DESCRIPTION
349 -----------
351 Task sdbaseline performs baseline fitting/subtraction for single-dish spectra.
352 The fit parameters, terms and rms of baseline can be saved into an ascii file
353 or baseline table. Subtracting baseline from data in input MS using existing
354 baseline table is also possible.
356 -----------------------
357 BASELINE MODEL FUNCTION
358 -----------------------
359 The list of available model functions are shown above (see Keyword arguments
360 section). In general 'cspline' or 'chebyshev' are recommended since they are
361 more stable than others. 'poly' will work for lower order but will be unstable
362 for higher order fitting. 'sinusoid' is kind of special mode that will be
363 useful for the data that clearly shows standing wave in the spectral baseline.
365 ----------------------------------
366 SIGMA CLIPPING (ITERATIVE FITTING)
367 ----------------------------------
368 In general least square fitting is strongly affected by an extreme data
369 so that the resulting fit makes worse. Sigma clipping is an iterative
370 baseline fitting with data clipping based on a certain threshold. Threshold
371 is set as a certain factor times rms of the resulting (baseline subtracted)
372 spectra. If sigma clipping is on, baseline fit/removal is performed several
373 times. After each baseline subtraction, the data whose absolute value is
374 above threshold are detected and those data are excluded from the next round
375 of fitting. By using sigma clipping, extreme data are excluded from the
376 fit so that resulting fit is more robust.
378 The user is able to control a multiplication factor using parameter
379 clipthresh for clipping threshold based on rms. Actual threshold for sigma
380 clipping will be (clipthresh) x (rms of spectra). Also, the user can specify
381 number of maximum iteration to the parameter clipniter.
383 In general, sigma clipping will lower the performance since it increases
384 number of fits per spectra. However, it is strongly recommended to turn
385 on sigma clipping unless you are sure that the data is free from any kind
386 of extreme values that may affect the fit.
389 ----------------------------------
390 PER-SPECTRUM FIT PARAMETERS
391 ----------------------------------
392 Per-spectrum baseline fitting parameters can be applied when blfunc='variable'.
394 The fitting parameters can be defined in a text file and specified in a
395 parameter 'blparam'. Each line of the text file should store baseline fitting
396 parameters for its corresponding spectrum in the input MS. It must be a
397 comma-separated text and contain values in the following order:
399 (1) 'row': row index
400 (2) 'pol': polarization index in the specified row
401 (3) 'mask': channel range(s) used for the fitting (see examples below).
402 (4) 'clipniter': maximum number of times of iterative fitting (identical to
403 the task parameter 'clipniter')
404 (5) 'clipthresh': clipping threshold for iterative fitting (identical to
405 the task parameter 'clipthresh')
406 (6) 'use_linefinder': 'true' or 'false'. Note that linefinder does not run
407 with per-spectrum fitting now even if setting 'true',
408 due to a bug which will be fixed in the future
409 (7) 'thresh': S/N threshold for linefinder (identical to the task parameter
410 'thresh'). Blank is accepted when you don't use linefinder
411 (8) 'left_edge': channels to drop at beginning of spectrum (identical to the
412 first element of the task parameter 'edge')
413 (9) 'right_edge': channels to drop at end of spectrum (identical to the
414 second element of the task parameter 'edge')
415 (10) 'avg_limit': channel averaging for broad lines (identical to the task
416 parameter 'avg_limit')
417 (11) 'blfunc': baseline model function (identical to the task parameter
418 'blfunc')
419 (12) 'order': order of polynomial function (identical to the task parameter
420 'order'). Needed when (11) is 'poly' or 'chebyshev'. It will
421 be ignored when other values are set for blfunc
422 (13) 'npiece': number of the element polynomials of cubic spline curve.
423 Needed when (11) is 'cspline' (identical to the task
424 parameter 'npiece')
425 (14) 'nwave': a list of sinusoidal wave numbers. Needed when (11) is
426 'sinusoid' though, actually, sinusoidal fitting is yet to be
427 available with per-spectrum fitting
429 Note that the following task parameters will be ignored/overwritten when
430 blfunc='variable' is specified (i.e., when per-spectrum fitting is executed):
432 * for iterative clipping: clipniter, clipthresh
433 * for linefinder: thresh, edge, avg_limit
434 * for baseline model function: blfunc, order, npiece, applyfft,
435 fftmethod, fftthresh, addwn, rejwn
437 Note also that:
439 (1) lines starting with '#' will be ignored and can be used as comments
440 (2) for MS spectra which have no corresponding line in the text file,
441 baseline fitting is not executed
443 Examples of text file:
445 (1) a simple one:
447 0,0,,2,3,false,,,,,poly,5,,[]
448 0,1,1500~7500,0,3.,false,0.,0,0,0,chebyshev,10,0,[]
449 1,0,,4,2.5,true,5.,70,80,3,cspline,,6,[]
450 1,1,0~4000;6000~8000,0,,false,,,,,sinusoid,,,[0,1,2,3,4,5,6,7]
451 #2,0,,0,,false,,,,,poly,10,,[]
453 (2) same setting as (1), but with detailed comments:
455 # for row 0, pol 0: no channel mask,
456 # iterative (twice at maximum) clipping at 3 sigma,
457 # no linefinder,
458 # fitting with polynomial of order 5
459 0,0,,2,3,false,,,,,poly,5,,[]
460 # for row 0, pol 1: use channel range 1500 to 7500,
461 # no iterative clipping (clipniter=0),
462 # no linefinder,
463 # fitting with Chebyshev polynomial of order 10
464 0,1,1500~7500,0,3.,false,0.,0,0,0,chebyshev,10,0,[]
465 # for row 1, pol 0: no channel mask,
466 # iterative (4 times at maximum) clipping at 2.5 sigma,
467 # using linefinder (thresh: 5.0 sigma,
468 # left_edge: 70 channels,
469 # right_edge: 80 channels,
470 # avg_limit: 3),
471 # fitting with cubic spline with 6 elements
472 1,0,,4,2.5,true,5.,70,80,3,cspline,,6,[]
473 # for row 1, pol 1: use channel ranges (0 to 4000) and (6000 to 8000),
474 # no iterative clipping,
475 # no linefinder,
476 # fitting with sinusoids with wave numbers up to 7
477 1,1,0~4000;6000~8000,0,,false,,,,,sinusoid,,,[0,1,2,3,4,5,6,7]
478 # for row 2, pol 0: no baseline fitting as the line is commented out
479 #2,0,,0,,false,,,,,poly,10,,[]
485 """
487 _info_group_ = """single dish"""
488 _info_desc_ = """Fit/subtract a spectral baseline """
490 def __call__( self, infile='', datacolumn='data', antenna='', field='', spw='', timerange='', scan='', pol='', intent='', reindex=True, maskmode='list', thresh=float(5.0), avg_limit=int(4), minwidth=int(4), edge=[ int(0),int(0) ], blmode='fit', dosubtract=True, blformat='text', bloutput='', bltable='', blfunc='poly', order=int(5), npiece=int(2), applyfft=True, fftmethod='fft', fftthresh=float(3.0), addwn=[ int(0) ], rejwn=[ ], clipthresh=float(3.0), clipniter=int(0), blparam='', verbose=False, updateweight=False, sigmavalue='stddev', showprogress=False, minnrow=int(1000), outfile='', overwrite=False ):
491 schema = {'infile': {'type': 'cReqPath', 'coerce': _coerce.expand_path}, 'datacolumn': {'type': 'cStr', 'coerce': _coerce.to_str, 'allowed': [ 'DATA', 'corrected', 'FLOAT_DATA', 'CORRECTED', 'float_data', 'data' ]}, 'antenna': {'type': 'cStr', 'coerce': _coerce.to_str}, 'field': {'type': 'cStr', 'coerce': _coerce.to_str}, 'spw': {'type': 'cStr', 'coerce': _coerce.to_str}, 'timerange': {'type': 'cStr', 'coerce': _coerce.to_str}, 'scan': {'type': 'cStr', 'coerce': _coerce.to_str}, 'pol': {'type': 'cStr', 'coerce': _coerce.to_str}, 'intent': {'type': 'cStr', 'coerce': _coerce.to_str}, 'reindex': {'type': 'cBool'}, 'maskmode': {'type': 'cStr', 'coerce': _coerce.to_str, 'allowed': [ 'list', 'auto', 'LIST', 'AUTO' ]}, 'thresh': {'type': 'cFloat', 'coerce': _coerce.to_float}, 'avg_limit': {'type': 'cInt'}, 'minwidth': {'type': 'cInt'}, 'edge': {'type': 'cIntVec', 'coerce': [_coerce.to_list,_coerce.to_intvec]}, 'blmode': {'type': 'cStr', 'coerce': _coerce.to_str}, 'dosubtract': {'type': 'cBool'}, 'blformat': {'anyof': [{'type': 'cStr', 'coerce': _coerce.to_str}, {'type': 'cStrVec', 'coerce': [_coerce.to_list,_coerce.to_strvec]}]}, 'bloutput': {'anyof': [{'type': 'cStr', 'coerce': _coerce.to_str}, {'type': 'cStrVec', 'coerce': [_coerce.to_list,_coerce.to_strvec]}]}, 'bltable': {'type': 'cStr', 'coerce': _coerce.to_str}, 'blfunc': {'type': 'cStr', 'coerce': _coerce.to_str, 'allowed': [ 'variable', 'cspline', 'SINUSOID', 'CSPLINE', 'sinusoid', 'VARIABLE', 'POLY', 'poly', 'chebyshev', 'CHEBYSHEV' ]}, 'order': {'type': 'cInt'}, 'npiece': {'type': 'cInt'}, 'applyfft': {'type': 'cBool'}, 'fftmethod': {'type': 'cStr', 'coerce': _coerce.to_str, 'allowed': [ 'fft', 'FFT' ]}, 'fftthresh': {'type': 'cVariant', 'coerce': [_coerce.to_variant]}, 'addwn': {'type': 'cVariant', 'coerce': [_coerce.to_variant]}, 'rejwn': {'type': 'cVariant', 'coerce': [_coerce.to_variant]}, 'clipthresh': {'type': 'cFloat', 'coerce': _coerce.to_float}, 'clipniter': {'type': 'cInt'}, 'blparam': {'type': 'cStr', 'coerce': _coerce.to_str}, 'verbose': {'type': 'cBool'}, 'updateweight': {'type': 'cBool'}, 'sigmavalue': {'type': 'cStr', 'coerce': _coerce.to_str, 'allowed': [ 'stddev', 'rms' ]}, 'showprogress': {'type': 'cBool'}, 'minnrow': {'type': 'cInt'}, 'outfile': {'type': 'cStr', 'coerce': _coerce.to_str}, 'overwrite': {'type': 'cBool'}}
492 doc = {'infile': infile, 'datacolumn': datacolumn, 'antenna': antenna, 'field': field, 'spw': spw, 'timerange': timerange, 'scan': scan, 'pol': pol, 'intent': intent, 'reindex': reindex, 'maskmode': maskmode, 'thresh': thresh, 'avg_limit': avg_limit, 'minwidth': minwidth, 'edge': edge, 'blmode': blmode, 'dosubtract': dosubtract, 'blformat': blformat, 'bloutput': bloutput, 'bltable': bltable, 'blfunc': blfunc, 'order': order, 'npiece': npiece, 'applyfft': applyfft, 'fftmethod': fftmethod, 'fftthresh': fftthresh, 'addwn': addwn, 'rejwn': rejwn, 'clipthresh': clipthresh, 'clipniter': clipniter, 'blparam': blparam, 'verbose': verbose, 'updateweight': updateweight, 'sigmavalue': sigmavalue, 'showprogress': showprogress, 'minnrow': minnrow, 'outfile': outfile, 'overwrite': overwrite}
493 assert _pc.validate(doc,schema), create_error_string(_pc.errors)
494 _logging_state_ = _start_log( 'sdbaseline', [ 'infile=' + repr(_pc.document['infile']), 'datacolumn=' + repr(_pc.document['datacolumn']), 'antenna=' + repr(_pc.document['antenna']), 'field=' + repr(_pc.document['field']), 'spw=' + repr(_pc.document['spw']), 'timerange=' + repr(_pc.document['timerange']), 'scan=' + repr(_pc.document['scan']), 'pol=' + repr(_pc.document['pol']), 'intent=' + repr(_pc.document['intent']), 'reindex=' + repr(_pc.document['reindex']), 'maskmode=' + repr(_pc.document['maskmode']), 'thresh=' + repr(_pc.document['thresh']), 'avg_limit=' + repr(_pc.document['avg_limit']), 'minwidth=' + repr(_pc.document['minwidth']), 'edge=' + repr(_pc.document['edge']), 'blmode=' + repr(_pc.document['blmode']), 'dosubtract=' + repr(_pc.document['dosubtract']), 'blformat=' + repr(_pc.document['blformat']), 'bloutput=' + repr(_pc.document['bloutput']), 'bltable=' + repr(_pc.document['bltable']), 'blfunc=' + repr(_pc.document['blfunc']), 'order=' + repr(_pc.document['order']), 'npiece=' + repr(_pc.document['npiece']), 'applyfft=' + repr(_pc.document['applyfft']), 'fftmethod=' + repr(_pc.document['fftmethod']), 'fftthresh=' + repr(_pc.document['fftthresh']), 'addwn=' + repr(_pc.document['addwn']), 'rejwn=' + repr(_pc.document['rejwn']), 'clipthresh=' + repr(_pc.document['clipthresh']), 'clipniter=' + repr(_pc.document['clipniter']), 'blparam=' + repr(_pc.document['blparam']), 'verbose=' + repr(_pc.document['verbose']), 'updateweight=' + repr(_pc.document['updateweight']), 'sigmavalue=' + repr(_pc.document['sigmavalue']), 'showprogress=' + repr(_pc.document['showprogress']), 'minnrow=' + repr(_pc.document['minnrow']), 'outfile=' + repr(_pc.document['outfile']), 'overwrite=' + repr(_pc.document['overwrite']) ] )
495 task_result = None
496 try:
497 task_result = _sdbaseline_t( _pc.document['infile'], _pc.document['datacolumn'], _pc.document['antenna'], _pc.document['field'], _pc.document['spw'], _pc.document['timerange'], _pc.document['scan'], _pc.document['pol'], _pc.document['intent'], _pc.document['reindex'], _pc.document['maskmode'], _pc.document['thresh'], _pc.document['avg_limit'], _pc.document['minwidth'], _pc.document['edge'], _pc.document['blmode'], _pc.document['dosubtract'], _pc.document['blformat'], _pc.document['bloutput'], _pc.document['bltable'], _pc.document['blfunc'], _pc.document['order'], _pc.document['npiece'], _pc.document['applyfft'], _pc.document['fftmethod'], _pc.document['fftthresh'], _pc.document['addwn'], _pc.document['rejwn'], _pc.document['clipthresh'], _pc.document['clipniter'], _pc.document['blparam'], _pc.document['verbose'], _pc.document['updateweight'], _pc.document['sigmavalue'], _pc.document['showprogress'], _pc.document['minnrow'], _pc.document['outfile'], _pc.document['overwrite'] )
498 except Exception as exc:
499 _except_log('sdbaseline', exc)
500 raise
501 finally:
502 task_result = _end_log( _logging_state_, 'sdbaseline', task_result )
503 return task_result
505sdbaseline = _sdbaseline( )