##################### generated by xml-casa (v2) from hsd_flagdata.xml ##############
##################### d5d4042975e6c648a73bc29b7547f0e6 ##############################
from __future__ import absolute_import
from casashell.private.stack_manip import find_local as __sf__
from casashell.private.stack_manip import find_frame as _find_frame
from casatools.typecheck import validator as _pc
from casatools.coercetype import coerce as _coerce
from pipeline.hsd.cli import hsd_flagdata as _hsd_flagdata_t
from collections import OrderedDict
import numpy
import sys
import os
import shutil
[docs]def static_var(varname, value):
def decorate(func):
setattr(func, varname, value)
return func
return decorate
class _hsd_flagdata:
"""
hsd_flagdata ---- Do basic flagging of a list of MeasurementSets
The hsd_flagdata data performs basic flagging operations on a list of
MeasurementSets including:
o applying online flags
o applying a flagging template
o shadowed antenna data flagging
o scan-based flagging by intent or scan number
o edge channel flagging
Output:
results -- If pipeline mode is 'getinputs' then None is returned. Otherwise
the results object for the pipeline task is returned.
--------- parameter descriptions ---------------------------------------------
vis The list of input MeasurementSets. Defaults to the list of MeasurementSets
defined in the pipeline context.
autocorr Flag autocorrelation data.
shadow Flag shadowed antennas.
scan Flag a list of specified scans.
scannumber A string containing a comma delimited list of scans to be
flagged.
intents A string containing a comma delimited list of intents against
which the scans to be flagged are matched.
example: '*BANDPASS*'
edgespw Flag the edge spectral window channels.
fracspw Fraction of the baseline correlator TDM edge channels to be flagged.
fracspwfps Fraction of the ACS correlator TDM edge channels to be flagged.
online Apply the online flags.
fileonline File containing the online flags. These are computed by the
h_init or hif_importdata data tasks. If the online flags files
are undefined a name of the form 'msname.flagonline.txt' is assumed.
template Apply a flagging template.
filetemplate The name of a text file that contains the flagging template
for RFI, birdies, telluric lines, etc. If the template flags files
is undefined a name of the form 'msname.flagtemplate.txt' is assumed.
pointing Apply a flagging template for pointing flag.
filepointing The name of a text file that contains the flagging template
for pointing flag. If the template flags files is undefined a name of
the form 'msname.flagpointing.txt' is assumed.
incompleteraster Apply commands to flag incomplete raster sequence.
If this is False, relevant commands in filepointing are
simply commented out.
hm_tbuff The heuristic for computing the default time interval padding parameter.
The options are 'halfint' and 'manual'. In 'halfint' mode tbuff is set to
half the maximum of the median integration time of the science and calibrator target
observations.
tbuff The time in seconds used to pad flagging command time intervals if
hm_tbuff='manual'.
qa0 QA0 flags
qa2 QA2 flags
pipelinemode The pipeline operating mode. In 'automatic' mode the pipeline
determines the values of all context defined pipeline inputs automatically.
In interactive mode the user can set the pipeline context defined parameters
manually. In 'getinputs' mode the user can check the settings of all
pipeline parameters without running the task.
flagbackup Back up any pre-existing flags before applying new ones.
dryrun Run the commands (True) or generate the commands to be run but
do not execute (False).
acceptresults Add the results of the task to the pipeline context (True) or
reject them (False).
--------- examples -----------------------------------------------------------
1. Do basic flagging on a MeasurementSet
hsd_flagdata()
2. Do basic flagging on a MeasurementSet flagging additional scans selected
by number as well.
hsd_flagdata(scannumber='13,18')
"""
_info_group_ = """pipeline"""
_info_desc_ = """Do basic flagging of a list of MeasurementSets"""
__schema = {'vis': {'type': 'cStrVec', 'coerce': [_coerce.to_list,_coerce.to_strvec]}, 'autocorr': {'type': 'cBool'}, 'shadow': {'type': 'cBool'}, 'scan': {'type': 'cBool'}, 'scannumber': {'type': 'cStr', 'coerce': _coerce.to_str}, 'intents': {'type': 'cStr', 'coerce': _coerce.to_str}, 'edgespw': {'type': 'cBool'}, 'fracspw': {'type': 'cVariant', 'coerce': [_coerce.to_variant]}, 'fracspwfps': {'type': 'cFloat', 'coerce': _coerce.to_float}, 'online': {'type': 'cBool'}, 'fileonline': {'type': 'cStr', 'coerce': _coerce.to_str}, 'template': {'type': 'cBool'}, 'filetemplate': {'type': 'cStrVec', 'coerce': [_coerce.to_list,_coerce.to_strvec]}, 'pointing': {'type': 'cBool'}, 'filepointing': {'type': 'cStrVec', 'coerce': [_coerce.to_list,_coerce.to_strvec]}, 'incompleteraster': {'type': 'cBool'}, 'hm_tbuff': {'type': 'cStr', 'coerce': _coerce.to_str, 'allowed': [ 'halfint', 'manual' ]}, 'tbuff': {'anyof': [{'type': 'cFloat', 'coerce': _coerce.to_float}, {'type': 'cFloatVec', 'coerce': [_coerce.to_list,_coerce.to_floatvec]}]}, 'qa0': {'type': 'cBool'}, 'qa2': {'type': 'cBool'}, 'pipelinemode': {'type': 'cStr', 'coerce': _coerce.to_str, 'allowed': [ 'automatic', 'interactive', 'getinputs' ]}, 'flagbackup': {'type': 'cBool'}, 'dryrun': {'type': 'cBool'}, 'acceptresults': {'type': 'cBool'}}
def __init__(self):
self.__stdout = None
self.__stderr = None
self.__root_frame_ = None
def __globals_(self):
if self.__root_frame_ is None:
self.__root_frame_ = _find_frame( )
assert self.__root_frame_ is not None, "could not find CASAshell global frame"
return self.__root_frame_
def __to_string_(self,value):
if type(value) is str:
return "'%s'" % value
else:
return str(value)
def __validate_(self,doc,schema):
return _pc.validate(doc,schema)
def __do_inp_output(self,param_prefix,description_str,formatting_chars):
out = self.__stdout or sys.stdout
description = description_str.split( )
prefix_width = 23 + 19 + 4
output = [ ]
addon = ''
first_addon = True
while len(description) > 0:
## starting a new line.....................................................................
if len(output) == 0:
## for first line add parameter information............................................
if len(param_prefix)-formatting_chars > prefix_width - 1:
output.append(param_prefix)
continue
addon = param_prefix + ' #'
first_addon = True
addon_formatting = formatting_chars
else:
## for subsequent lines space over prefix width........................................
addon = (' ' * prefix_width) + '#'
first_addon = False
addon_formatting = 0
## if first word of description puts us over the screen width, bail........................
if len(addon + description[0]) - addon_formatting + 1 > self.term_width:
## if we're doing the first line make sure it's output.................................
if first_addon: output.append(addon)
break
while len(description) > 0:
## if the next description word puts us over break for the next line...................
if len(addon + description[0]) - addon_formatting + 1 > self.term_width: break
addon = addon + ' ' + description[0]
description.pop(0)
output.append(addon)
out.write('\n'.join(output) + '\n')
#--------- return nonsubparam values ----------------------------------------------
def __template_dflt( self, glb ):
return True
def __template( self, glb ):
if 'template' in glb: return glb['template']
return True
def __qa2_dflt( self, glb ):
return True
def __qa2( self, glb ):
if 'qa2' in glb: return glb['qa2']
return True
def __shadow_dflt( self, glb ):
return True
def __shadow( self, glb ):
if 'shadow' in glb: return glb['shadow']
return True
def __online_dflt( self, glb ):
return True
def __online( self, glb ):
if 'online' in glb: return glb['online']
return True
def __edgespw_dflt( self, glb ):
return True
def __edgespw( self, glb ):
if 'edgespw' in glb: return glb['edgespw']
return True
def __scan_dflt( self, glb ):
return True
def __scan( self, glb ):
if 'scan' in glb: return glb['scan']
return True
def __autocorr_dflt( self, glb ):
return False
def __autocorr( self, glb ):
if 'autocorr' in glb: return glb['autocorr']
return False
def __pipelinemode_dflt( self, glb ):
return 'automatic'
def __pipelinemode( self, glb ):
if 'pipelinemode' in glb: return glb['pipelinemode']
return 'automatic'
def __pointing_dflt( self, glb ):
return True
def __pointing( self, glb ):
if 'pointing' in glb: return glb['pointing']
return True
def __hm_tbuff_dflt( self, glb ):
return 'halfint'
def __hm_tbuff( self, glb ):
if 'hm_tbuff' in glb: return glb['hm_tbuff']
return 'halfint'
def __qa0_dflt( self, glb ):
return True
def __qa0( self, glb ):
if 'qa0' in glb: return glb['qa0']
return True
#--------- return inp/go default --------------------------------------------------
def __dryrun_dflt( self, glb ):
if self.__pipelinemode( glb ) == "interactive": return bool(False)
return None
def __filetemplate_dflt( self, glb ):
if self.__template( glb ) == bool(True): return []
return None
def __fracspw_dflt( self, glb ):
if self.__edgespw( glb ) == bool(True): return "1.875GHz"
return None
def __incompleteraster_dflt( self, glb ):
if self.__pointing( glb ) == bool(True): return bool(True)
return None
def __filepointing_dflt( self, glb ):
if self.__pointing( glb ) == bool(True): return []
return None
def __fracspwfps_dflt( self, glb ):
if self.__edgespw( glb ) == bool(True): return float(0.048387)
return None
def __vis_dflt( self, glb ):
if self.__pipelinemode( glb ) == "interactive": return []
if self.__pipelinemode( glb ) == "getinputs": return []
return None
def __acceptresults_dflt( self, glb ):
if self.__pipelinemode( glb ) == "interactive": return bool(True)
return None
def __intents_dflt( self, glb ):
if self.__scan( glb ) == bool(True): return "POINTING,FOCUS,ATMOSPHERE,SIDEBAND,CHECK"
return None
def __scannumber_dflt( self, glb ):
if self.__scan( glb ) == bool(True): return ""
return None
def __fileonline_dflt( self, glb ):
if self.__online( glb ) == bool(True): return ""
return None
def __tbuff_dflt( self, glb ):
if self.__hm_tbuff( glb ) == "manual": return 0.0
return None
def __flagbackup_dflt( self, glb ):
if self.__pipelinemode( glb ) == "interactive": return bool(False)
if self.__pipelinemode( glb ) == "getinputs": return bool(False)
return None
#--------- return subparam values -------------------------------------------------
def __vis( self, glb ):
if 'vis' in glb: return glb['vis']
dflt = self.__vis_dflt( glb )
if dflt is not None: return dflt
return [ ]
def __scannumber( self, glb ):
if 'scannumber' in glb: return glb['scannumber']
dflt = self.__scannumber_dflt( glb )
if dflt is not None: return dflt
return ''
def __intents( self, glb ):
if 'intents' in glb: return glb['intents']
dflt = self.__intents_dflt( glb )
if dflt is not None: return dflt
return 'POINTING,FOCUS,ATMOSPHERE,SIDEBAND,CHECK'
def __fracspw( self, glb ):
if 'fracspw' in glb: return glb['fracspw']
dflt = self.__fracspw_dflt( glb )
if dflt is not None: return dflt
return '1.875GHz'
def __fracspwfps( self, glb ):
if 'fracspwfps' in glb: return glb['fracspwfps']
dflt = self.__fracspwfps_dflt( glb )
if dflt is not None: return dflt
return float(0.048387)
def __fileonline( self, glb ):
if 'fileonline' in glb: return glb['fileonline']
dflt = self.__fileonline_dflt( glb )
if dflt is not None: return dflt
return ''
def __filetemplate( self, glb ):
if 'filetemplate' in glb: return glb['filetemplate']
dflt = self.__filetemplate_dflt( glb )
if dflt is not None: return dflt
return [ ]
def __filepointing( self, glb ):
if 'filepointing' in glb: return glb['filepointing']
dflt = self.__filepointing_dflt( glb )
if dflt is not None: return dflt
return [ ]
def __incompleteraster( self, glb ):
if 'incompleteraster' in glb: return glb['incompleteraster']
dflt = self.__incompleteraster_dflt( glb )
if dflt is not None: return dflt
return True
def __tbuff( self, glb ):
if 'tbuff' in glb: return glb['tbuff']
dflt = self.__tbuff_dflt( glb )
if dflt is not None: return dflt
return float(0.0)
def __flagbackup( self, glb ):
if 'flagbackup' in glb: return glb['flagbackup']
dflt = self.__flagbackup_dflt( glb )
if dflt is not None: return dflt
return False
def __dryrun( self, glb ):
if 'dryrun' in glb: return glb['dryrun']
dflt = self.__dryrun_dflt( glb )
if dflt is not None: return dflt
return False
def __acceptresults( self, glb ):
if 'acceptresults' in glb: return glb['acceptresults']
dflt = self.__acceptresults_dflt( glb )
if dflt is not None: return dflt
return True
#--------- subparam inp output ----------------------------------------------------
def __vis_inp(self):
if self.__vis_dflt( self.__globals_( ) ) is not None:
description = 'List of input MeasurementSets to flag'
value = self.__vis( self.__globals_( ) )
(pre,post) = ('','') if self.__validate_({'vis': value},{'vis': self.__schema['vis']}) else ('\x1B[91m','\x1B[0m')
self.__do_inp_output(' \x1B[92m%-16.16s =\x1B[0m %s%-23s%s' % ('vis',pre,self.__to_string_(value),post),description,9+len(pre)+len(post))
def __autocorr_inp(self):
description = 'Flag autocorrelation data'
value = self.__autocorr( self.__globals_( ) )
(pre,post) = ('','') if self.__validate_({'autocorr': value},{'autocorr': self.__schema['autocorr']}) else ('\x1B[91m','\x1B[0m')
self.__do_inp_output('%-19.19s = %s%-23s%s' % ('autocorr',pre,self.__to_string_(value),post),description,0+len(pre)+len(post))
def __shadow_inp(self):
description = 'Flag shadowed antennas'
value = self.__shadow( self.__globals_( ) )
(pre,post) = ('','') if self.__validate_({'shadow': value},{'shadow': self.__schema['shadow']}) else ('\x1B[91m','\x1B[0m')
self.__do_inp_output('%-19.19s = %s%-23s%s' % ('shadow',pre,self.__to_string_(value),post),description,0+len(pre)+len(post))
def __scan_inp(self):
description = 'Flag specified scans'
value = self.__scan( self.__globals_( ) )
(pre,post) = ('','') if self.__validate_({'scan': value},{'scan': self.__schema['scan']}) else ('\x1B[91m','\x1B[0m')
self.__do_inp_output('\x1B[1m\x1B[47m%-19.19s =\x1B[0m %s%-23s%s' % ('scan',pre,self.__to_string_(value),post),description,13+len(pre)+len(post))
def __scannumber_inp(self):
if self.__scannumber_dflt( self.__globals_( ) ) is not None:
description = 'List of scans to be flagged'
value = self.__scannumber( self.__globals_( ) )
(pre,post) = ('','') if self.__validate_({'scannumber': value},{'scannumber': self.__schema['scannumber']}) else ('\x1B[91m','\x1B[0m')
self.__do_inp_output(' \x1B[92m%-16.16s =\x1B[0m %s%-23s%s' % ('scannumber',pre,self.__to_string_(value),post),description,9+len(pre)+len(post))
def __intents_inp(self):
if self.__intents_dflt( self.__globals_( ) ) is not None:
description = 'List of intents of scans to be flagged'
value = self.__intents( self.__globals_( ) )
(pre,post) = ('','') if self.__validate_({'intents': value},{'intents': self.__schema['intents']}) else ('\x1B[91m','\x1B[0m')
self.__do_inp_output(' \x1B[92m%-16.16s =\x1B[0m %s%-23s%s' % ('intents',pre,self.__to_string_(value),post),description,9+len(pre)+len(post))
def __edgespw_inp(self):
description = 'Flag edge channels'
value = self.__edgespw( self.__globals_( ) )
(pre,post) = ('','') if self.__validate_({'edgespw': value},{'edgespw': self.__schema['edgespw']}) else ('\x1B[91m','\x1B[0m')
self.__do_inp_output('\x1B[1m\x1B[47m%-19.19s =\x1B[0m %s%-23s%s' % ('edgespw',pre,self.__to_string_(value),post),description,13+len(pre)+len(post))
def __fracspw_inp(self):
if self.__fracspw_dflt( self.__globals_( ) ) is not None:
description = 'Fraction of baseline correlator edge channels to be flagged'
value = self.__fracspw( self.__globals_( ) )
(pre,post) = ('','') if self.__validate_({'fracspw': value},{'fracspw': self.__schema['fracspw']}) else ('\x1B[91m','\x1B[0m')
self.__do_inp_output(' \x1B[92m%-16.16s =\x1B[0m %s%-23s%s' % ('fracspw',pre,self.__to_string_(value),post),description,9+len(pre)+len(post))
def __fracspwfps_inp(self):
if self.__fracspwfps_dflt( self.__globals_( ) ) is not None:
description = 'Fraction of ACA correlator edge channels to be flagged'
value = self.__fracspwfps( self.__globals_( ) )
(pre,post) = ('','') if self.__validate_({'fracspwfps': value},{'fracspwfps': self.__schema['fracspwfps']}) else ('\x1B[91m','\x1B[0m')
self.__do_inp_output(' \x1B[92m%-16.16s =\x1B[0m %s%-23s%s' % ('fracspwfps',pre,self.__to_string_(value),post),description,9+len(pre)+len(post))
def __online_inp(self):
description = 'Apply the online flags'
value = self.__online( self.__globals_( ) )
(pre,post) = ('','') if self.__validate_({'online': value},{'online': self.__schema['online']}) else ('\x1B[91m','\x1B[0m')
self.__do_inp_output('\x1B[1m\x1B[47m%-19.19s =\x1B[0m %s%-23s%s' % ('online',pre,self.__to_string_(value),post),description,13+len(pre)+len(post))
def __fileonline_inp(self):
if self.__fileonline_dflt( self.__globals_( ) ) is not None:
description = 'File of online flags to be applied'
value = self.__fileonline( self.__globals_( ) )
(pre,post) = ('','') if self.__validate_({'fileonline': value},{'fileonline': self.__schema['fileonline']}) else ('\x1B[91m','\x1B[0m')
self.__do_inp_output(' \x1B[92m%-16.16s =\x1B[0m %s%-23s%s' % ('fileonline',pre,self.__to_string_(value),post),description,9+len(pre)+len(post))
def __template_inp(self):
description = 'Apply a flagging template'
value = self.__template( self.__globals_( ) )
(pre,post) = ('','') if self.__validate_({'template': value},{'template': self.__schema['template']}) else ('\x1B[91m','\x1B[0m')
self.__do_inp_output('\x1B[1m\x1B[47m%-19.19s =\x1B[0m %s%-23s%s' % ('template',pre,self.__to_string_(value),post),description,13+len(pre)+len(post))
def __filetemplate_inp(self):
if self.__filetemplate_dflt( self.__globals_( ) ) is not None:
description = 'File that contains the flagging template'
value = self.__filetemplate( self.__globals_( ) )
(pre,post) = ('','') if self.__validate_({'filetemplate': value},{'filetemplate': self.__schema['filetemplate']}) else ('\x1B[91m','\x1B[0m')
self.__do_inp_output(' \x1B[92m%-16.16s =\x1B[0m %s%-23s%s' % ('filetemplate',pre,self.__to_string_(value),post),description,9+len(pre)+len(post))
def __pointing_inp(self):
description = 'Apply a flagging template for pointing flag'
value = self.__pointing( self.__globals_( ) )
(pre,post) = ('','') if self.__validate_({'pointing': value},{'pointing': self.__schema['pointing']}) else ('\x1B[91m','\x1B[0m')
self.__do_inp_output('\x1B[1m\x1B[47m%-19.19s =\x1B[0m %s%-23s%s' % ('pointing',pre,self.__to_string_(value),post),description,13+len(pre)+len(post))
def __filepointing_inp(self):
if self.__filepointing_dflt( self.__globals_( ) ) is not None:
description = 'File that contains the flagging template for pointing flag'
value = self.__filepointing( self.__globals_( ) )
(pre,post) = ('','') if self.__validate_({'filepointing': value},{'filepointing': self.__schema['filepointing']}) else ('\x1B[91m','\x1B[0m')
self.__do_inp_output(' \x1B[92m%-16.16s =\x1B[0m %s%-23s%s' % ('filepointing',pre,self.__to_string_(value),post),description,9+len(pre)+len(post))
def __incompleteraster_inp(self):
if self.__incompleteraster_dflt( self.__globals_( ) ) is not None:
description = 'Apply commands to flag incomplete raster sequence'
value = self.__incompleteraster( self.__globals_( ) )
(pre,post) = ('','') if self.__validate_({'incompleteraster': value},{'incompleteraster': self.__schema['incompleteraster']}) else ('\x1B[91m','\x1B[0m')
self.__do_inp_output(' \x1B[92m%-16.16s =\x1B[0m %s%-23s%s' % ('incompleteraster',pre,self.__to_string_(value),post),description,9+len(pre)+len(post))
def __hm_tbuff_inp(self):
description = 'The time buffer computation heuristic'
value = self.__hm_tbuff( self.__globals_( ) )
(pre,post) = ('','') if self.__validate_({'hm_tbuff': value},{'hm_tbuff': self.__schema['hm_tbuff']}) else ('\x1B[91m','\x1B[0m')
self.__do_inp_output('\x1B[1m\x1B[47m%-19.19s =\x1B[0m %s%-23s%s' % ('hm_tbuff',pre,self.__to_string_(value),post),description,13+len(pre)+len(post))
def __tbuff_inp(self):
if self.__tbuff_dflt( self.__globals_( ) ) is not None:
description = 'List of time buffers (sec) to pad timerange in flag commands'
value = self.__tbuff( self.__globals_( ) )
(pre,post) = ('','') if self.__validate_({'tbuff': value},{'tbuff': self.__schema['tbuff']}) else ('\x1B[91m','\x1B[0m')
self.__do_inp_output(' \x1B[92m%-16.16s =\x1B[0m %s%-23s%s' % ('tbuff',pre,self.__to_string_(value),post),description,9+len(pre)+len(post))
def __qa0_inp(self):
description = 'QA0 flags'
value = self.__qa0( self.__globals_( ) )
(pre,post) = ('','') if self.__validate_({'qa0': value},{'qa0': self.__schema['qa0']}) else ('\x1B[91m','\x1B[0m')
self.__do_inp_output('%-19.19s = %s%-23s%s' % ('qa0',pre,self.__to_string_(value),post),description,0+len(pre)+len(post))
def __qa2_inp(self):
description = 'QA2 flags'
value = self.__qa2( self.__globals_( ) )
(pre,post) = ('','') if self.__validate_({'qa2': value},{'qa2': self.__schema['qa2']}) else ('\x1B[91m','\x1B[0m')
self.__do_inp_output('%-19.19s = %s%-23s%s' % ('qa2',pre,self.__to_string_(value),post),description,0+len(pre)+len(post))
def __pipelinemode_inp(self):
description = 'The pipeline operating mode'
value = self.__pipelinemode( self.__globals_( ) )
(pre,post) = ('','') if self.__validate_({'pipelinemode': value},{'pipelinemode': self.__schema['pipelinemode']}) else ('\x1B[91m','\x1B[0m')
self.__do_inp_output('\x1B[1m\x1B[47m%-19.19s =\x1B[0m %s%-23s%s' % ('pipelinemode',pre,self.__to_string_(value),post),description,13+len(pre)+len(post))
def __flagbackup_inp(self):
if self.__flagbackup_dflt( self.__globals_( ) ) is not None:
description = 'Backup pre-existing flags'
value = self.__flagbackup( self.__globals_( ) )
(pre,post) = ('','') if self.__validate_({'flagbackup': value},{'flagbackup': self.__schema['flagbackup']}) else ('\x1B[91m','\x1B[0m')
self.__do_inp_output(' \x1B[92m%-16.16s =\x1B[0m %s%-23s%s' % ('flagbackup',pre,self.__to_string_(value),post),description,9+len(pre)+len(post))
def __dryrun_inp(self):
if self.__dryrun_dflt( self.__globals_( ) ) is not None:
description = 'Run the task (False) or display the command (True)'
value = self.__dryrun( self.__globals_( ) )
(pre,post) = ('','') if self.__validate_({'dryrun': value},{'dryrun': self.__schema['dryrun']}) else ('\x1B[91m','\x1B[0m')
self.__do_inp_output(' \x1B[92m%-16.16s =\x1B[0m %s%-23s%s' % ('dryrun',pre,self.__to_string_(value),post),description,9+len(pre)+len(post))
def __acceptresults_inp(self):
if self.__acceptresults_dflt( self.__globals_( ) ) is not None:
description = 'Add the results into the pipeline context'
value = self.__acceptresults( self.__globals_( ) )
(pre,post) = ('','') if self.__validate_({'acceptresults': value},{'acceptresults': self.__schema['acceptresults']}) else ('\x1B[91m','\x1B[0m')
self.__do_inp_output(' \x1B[92m%-16.16s =\x1B[0m %s%-23s%s' % ('acceptresults',pre,self.__to_string_(value),post),description,9+len(pre)+len(post))
#--------- global default implementation-------------------------------------------
@static_var('state', __sf__('casa_inp_go_state'))
def set_global_defaults(self):
self.set_global_defaults.state['last'] = self
glb = self.__globals_( )
if 'pointing' in glb: del glb['pointing']
if 'shadow' in glb: del glb['shadow']
if 'qa0' in glb: del glb['qa0']
if 'dryrun' in glb: del glb['dryrun']
if 'filetemplate' in glb: del glb['filetemplate']
if 'fracspw' in glb: del glb['fracspw']
if 'pipelinemode' in glb: del glb['pipelinemode']
if 'online' in glb: del glb['online']
if 'incompleteraster' in glb: del glb['incompleteraster']
if 'hm_tbuff' in glb: del glb['hm_tbuff']
if 'filepointing' in glb: del glb['filepointing']
if 'fracspwfps' in glb: del glb['fracspwfps']
if 'scan' in glb: del glb['scan']
if 'vis' in glb: del glb['vis']
if 'acceptresults' in glb: del glb['acceptresults']
if 'qa2' in glb: del glb['qa2']
if 'intents' in glb: del glb['intents']
if 'scannumber' in glb: del glb['scannumber']
if 'template' in glb: del glb['template']
if 'fileonline' in glb: del glb['fileonline']
if 'tbuff' in glb: del glb['tbuff']
if 'flagbackup' in glb: del glb['flagbackup']
if 'edgespw' in glb: del glb['edgespw']
if 'autocorr' in glb: del glb['autocorr']
#--------- inp function -----------------------------------------------------------
def inp(self):
print("# hsd_flagdata -- %s" % self._info_desc_)
self.term_width, self.term_height = shutil.get_terminal_size(fallback=(80, 24))
self.__vis_inp( )
self.__autocorr_inp( )
self.__shadow_inp( )
self.__scan_inp( )
self.__scannumber_inp( )
self.__intents_inp( )
self.__edgespw_inp( )
self.__fracspw_inp( )
self.__fracspwfps_inp( )
self.__online_inp( )
self.__fileonline_inp( )
self.__template_inp( )
self.__filetemplate_inp( )
self.__pointing_inp( )
self.__filepointing_inp( )
self.__incompleteraster_inp( )
self.__hm_tbuff_inp( )
self.__tbuff_inp( )
self.__qa0_inp( )
self.__qa2_inp( )
self.__pipelinemode_inp( )
self.__flagbackup_inp( )
self.__dryrun_inp( )
self.__acceptresults_inp( )
#--------- tget function ----------------------------------------------------------
@static_var('state', __sf__('casa_inp_go_state'))
def tget(self,file=None):
from casashell.private.stack_manip import find_frame
from runpy import run_path
filename = None
if file is None:
if os.path.isfile("hsd_flagdata.last"):
filename = "hsd_flagdata.last"
elif isinstance(file, str):
if os.path.isfile(file):
filename = file
if filename is not None:
glob = find_frame( )
newglob = run_path( filename, init_globals={ } )
for i in newglob:
glob[i] = newglob[i]
self.tget.state['last'] = self
else:
print("could not find last file, setting defaults instead...")
self.set_global_defaults( )
def __call__( self, vis=None, autocorr=None, shadow=None, scan=None, scannumber=None, intents=None, edgespw=None, fracspw=None, fracspwfps=None, online=None, fileonline=None, template=None, filetemplate=None, pointing=None, filepointing=None, incompleteraster=None, hm_tbuff=None, tbuff=None, qa0=None, qa2=None, pipelinemode=None, flagbackup=None, dryrun=None, acceptresults=None ):
def noobj(s):
if s.startswith('<') and s.endswith('>'):
return "None"
else:
return s
_prefile = os.path.realpath('hsd_flagdata.pre')
_postfile = os.path.realpath('hsd_flagdata.last')
_return_result_ = None
_arguments = [vis,autocorr,shadow,scan,scannumber,intents,edgespw,fracspw,fracspwfps,online,fileonline,template,filetemplate,pointing,filepointing,incompleteraster,hm_tbuff,tbuff,qa0,qa2,pipelinemode,flagbackup,dryrun,acceptresults]
_invocation_parameters = OrderedDict( )
if any(map(lambda x: x is not None,_arguments)):
# invoke python style
# set the non sub-parameters that are not None
local_global = { }
if autocorr is not None: local_global['autocorr'] = autocorr
if shadow is not None: local_global['shadow'] = shadow
if scan is not None: local_global['scan'] = scan
if edgespw is not None: local_global['edgespw'] = edgespw
if online is not None: local_global['online'] = online
if template is not None: local_global['template'] = template
if pointing is not None: local_global['pointing'] = pointing
if hm_tbuff is not None: local_global['hm_tbuff'] = hm_tbuff
if qa0 is not None: local_global['qa0'] = qa0
if qa2 is not None: local_global['qa2'] = qa2
if pipelinemode is not None: local_global['pipelinemode'] = pipelinemode
# the invocation parameters for the non-subparameters can now be set - this picks up those defaults
_invocation_parameters['autocorr'] = self.__autocorr( local_global )
_invocation_parameters['shadow'] = self.__shadow( local_global )
_invocation_parameters['scan'] = self.__scan( local_global )
_invocation_parameters['edgespw'] = self.__edgespw( local_global )
_invocation_parameters['online'] = self.__online( local_global )
_invocation_parameters['template'] = self.__template( local_global )
_invocation_parameters['pointing'] = self.__pointing( local_global )
_invocation_parameters['hm_tbuff'] = self.__hm_tbuff( local_global )
_invocation_parameters['qa0'] = self.__qa0( local_global )
_invocation_parameters['qa2'] = self.__qa2( local_global )
_invocation_parameters['pipelinemode'] = self.__pipelinemode( local_global )
# the sub-parameters can then be set. Use the supplied value if not None, else the function, which gets the appropriate default
_invocation_parameters['vis'] = self.__vis( _invocation_parameters ) if vis is None else vis
_invocation_parameters['scannumber'] = self.__scannumber( _invocation_parameters ) if scannumber is None else scannumber
_invocation_parameters['intents'] = self.__intents( _invocation_parameters ) if intents is None else intents
_invocation_parameters['fracspw'] = self.__fracspw( _invocation_parameters ) if fracspw is None else fracspw
_invocation_parameters['fracspwfps'] = self.__fracspwfps( _invocation_parameters ) if fracspwfps is None else fracspwfps
_invocation_parameters['fileonline'] = self.__fileonline( _invocation_parameters ) if fileonline is None else fileonline
_invocation_parameters['filetemplate'] = self.__filetemplate( _invocation_parameters ) if filetemplate is None else filetemplate
_invocation_parameters['filepointing'] = self.__filepointing( _invocation_parameters ) if filepointing is None else filepointing
_invocation_parameters['incompleteraster'] = self.__incompleteraster( _invocation_parameters ) if incompleteraster is None else incompleteraster
_invocation_parameters['tbuff'] = self.__tbuff( _invocation_parameters ) if tbuff is None else tbuff
_invocation_parameters['flagbackup'] = self.__flagbackup( _invocation_parameters ) if flagbackup is None else flagbackup
_invocation_parameters['dryrun'] = self.__dryrun( _invocation_parameters ) if dryrun is None else dryrun
_invocation_parameters['acceptresults'] = self.__acceptresults( _invocation_parameters ) if acceptresults is None else acceptresults
else:
# invoke with inp/go semantics
_invocation_parameters['vis'] = self.__vis( self.__globals_( ) )
_invocation_parameters['autocorr'] = self.__autocorr( self.__globals_( ) )
_invocation_parameters['shadow'] = self.__shadow( self.__globals_( ) )
_invocation_parameters['scan'] = self.__scan( self.__globals_( ) )
_invocation_parameters['scannumber'] = self.__scannumber( self.__globals_( ) )
_invocation_parameters['intents'] = self.__intents( self.__globals_( ) )
_invocation_parameters['edgespw'] = self.__edgespw( self.__globals_( ) )
_invocation_parameters['fracspw'] = self.__fracspw( self.__globals_( ) )
_invocation_parameters['fracspwfps'] = self.__fracspwfps( self.__globals_( ) )
_invocation_parameters['online'] = self.__online( self.__globals_( ) )
_invocation_parameters['fileonline'] = self.__fileonline( self.__globals_( ) )
_invocation_parameters['template'] = self.__template( self.__globals_( ) )
_invocation_parameters['filetemplate'] = self.__filetemplate( self.__globals_( ) )
_invocation_parameters['pointing'] = self.__pointing( self.__globals_( ) )
_invocation_parameters['filepointing'] = self.__filepointing( self.__globals_( ) )
_invocation_parameters['incompleteraster'] = self.__incompleteraster( self.__globals_( ) )
_invocation_parameters['hm_tbuff'] = self.__hm_tbuff( self.__globals_( ) )
_invocation_parameters['tbuff'] = self.__tbuff( self.__globals_( ) )
_invocation_parameters['qa0'] = self.__qa0( self.__globals_( ) )
_invocation_parameters['qa2'] = self.__qa2( self.__globals_( ) )
_invocation_parameters['pipelinemode'] = self.__pipelinemode( self.__globals_( ) )
_invocation_parameters['flagbackup'] = self.__flagbackup( self.__globals_( ) )
_invocation_parameters['dryrun'] = self.__dryrun( self.__globals_( ) )
_invocation_parameters['acceptresults'] = self.__acceptresults( self.__globals_( ) )
try:
with open(_prefile,'w') as _f:
for _i in _invocation_parameters:
_f.write("%-16s = %s\n" % (_i,noobj(repr(_invocation_parameters[_i]))))
_f.write("#hsd_flagdata( ")
count = 0
for _i in _invocation_parameters:
_f.write("%s=%s" % (_i,noobj(repr(_invocation_parameters[_i]))))
count += 1
if count < len(_invocation_parameters): _f.write(",")
_f.write(" )\n")
except: pass
try:
_return_result_ = _hsd_flagdata_t( _invocation_parameters['vis'],_invocation_parameters['autocorr'],_invocation_parameters['shadow'],_invocation_parameters['scan'],_invocation_parameters['scannumber'],_invocation_parameters['intents'],_invocation_parameters['edgespw'],_invocation_parameters['fracspw'],_invocation_parameters['fracspwfps'],_invocation_parameters['online'],_invocation_parameters['fileonline'],_invocation_parameters['template'],_invocation_parameters['filetemplate'],_invocation_parameters['pointing'],_invocation_parameters['filepointing'],_invocation_parameters['incompleteraster'],_invocation_parameters['hm_tbuff'],_invocation_parameters['tbuff'],_invocation_parameters['qa0'],_invocation_parameters['qa2'],_invocation_parameters['pipelinemode'],_invocation_parameters['flagbackup'],_invocation_parameters['dryrun'],_invocation_parameters['acceptresults'] )
except Exception as e:
from traceback import format_exc
from casatasks import casalog
casalog.origin('hsd_flagdata')
casalog.post("Exception Reported: Error in hsd_flagdata: %s" % str(e),'SEVERE')
casalog.post(format_exc( ))
_return_result_ = False
try:
os.rename(_prefile,_postfile)
except: pass
return _return_result_
hsd_flagdata = _hsd_flagdata( )