##################### generated by xml-casa (v2) from hifa_gfluxscaleflag.xml #######
##################### c0591abdf9951a0579add1f561d7138b ##############################
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.hifa.cli import hifa_gfluxscaleflag as _hifa_gfluxscaleflag_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 _hifa_gfluxscaleflag:
"""
hifa_gfluxscaleflag ---- Derive the flux density scale with flagging
This task computes the flagging heuristics on the phase calibrator and flux
calibrator by calling hif_correctedampflag which looks for outlier
visibility points by statistically examining the scalar difference of
corrected amplitudes minus model amplitudes, and flags those outliers. The
philosophy is that only outlier data points that have remained outliers
after calibration will be flagged. The heuristic works equally well on
resolved calibrators and point sources because it is not performing a
vector difference, and thus is not sensitive to nulls in the flux density
vs. uvdistance domain. Note that the phase of the data is not assessed.
In further detail, the workflow is as follows: a snapshot of the flagging
state is preserved at the start, a preliminary phase and amplitude gaincal
solution is solved and applied, the flagging heuristics are run and
any outliers are marked for flagging, the flagging state is restored from the
snapshot. If any outliers were found, then these are flagged. Plots are
generated at two points in this workflow: after preliminary phase and
amplitude calibration but before flagging heuristics are run, and after
flagging heuristics have been run and applied. If no points were flagged,
the 'after' plots are not generated or displayed. The score for this stage
is the standard data flagging score, which depends on the fraction of data
flagged.
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 specified in the pipeline context.
example: vis=['M51.ms']
intent A string containing a comma delimited list of intents against
which the selected fields are matched. If undefined (default), it
will select all data with the AMPLITUDE, PHASE, and CHECK intents,
except for one case: if one of the AMPLITUDE intent fields was also
used for BANDPASS, then this task will select only data with PHASE
and CHECK intents.
example: intent='*PHASE*'
phaseupsolint The phase correction solution interval in CASA syntax.
example: phaseupsolint='300s'
solint Time and channel solution intervals in CASA syntax.
example: solint='inf,10ch', solint='inf'
minsnr Solutions below this SNR are rejected.
refant Reference antenna names. Defaults to the value(s) stored in the
pipeline context. If undefined in the pipeline context defaults to
the CASA reference antenna naming scheme.
example: refant='DV01', refant='DV06,DV07'
antnegsig Lower sigma threshold for identifying outliers as a result of bad
antennas within individual timestamps.
antpossig Upper sigma threshold for identifying outliers as a result of bad
antennas within individual timestamps.
tmantint Threshold for maximum fraction of timestamps that are allowed to
contain outliers.
tmint eshold for maximum fraction of "outlier timestamps" over
"total timestamps" that a baseline may be a part of.
tmbl Initial threshold for maximum fraction of "bad baselines" over "all
baselines" that an antenna may be a part of.
antblnegsig Lower sigma threshold for identifying outliers as a result of
"bad baselines" and/or "bad antennas" within baselines, across all
timestamps.
antblpossig threshold for identifying outliers as a result of
"bad baselines" and/or "bad antennas" within baselines, across all
timestamps.
relaxed_factor Relaxed value to set the threshold scaling factor to under
certain conditions (see task description).
niter Maximum number of times to iterate on evaluation of flagging
heuristics. If an iteration results in no new flags, then subsequent
iterations are skipped.
pipelinemode e 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.
default: 'automatic'.
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. run with recommended settings to create flux scale calibration with flagging
using recommended thresholds:
hifa_gfluxscaleflag()
"""
_info_group_ = """pipeline"""
_info_desc_ = """Derive the flux density scale with flagging"""
__schema = {'vis': {'type': 'cStrVec', 'coerce': [_coerce.to_list,_coerce.to_strvec]}, 'intent': {'type': 'cStr', 'coerce': _coerce.to_str}, 'phaseupsolint': {'type': 'cVariant', 'coerce': [_coerce.to_variant]}, 'solint': {'type': 'cVariant', 'coerce': [_coerce.to_variant]}, 'minsnr': {'type': 'cFloat', 'coerce': _coerce.to_float}, 'refant': {'type': 'cStr', 'coerce': _coerce.to_str}, 'antnegsig': {'type': 'cFloat', 'coerce': _coerce.to_float}, 'antpossig': {'type': 'cFloat', 'coerce': _coerce.to_float}, 'tmantint': {'type': 'cFloat', 'coerce': _coerce.to_float}, 'tmint': {'type': 'cFloat', 'coerce': _coerce.to_float}, 'tmbl': {'type': 'cFloat', 'coerce': _coerce.to_float}, 'antblnegsig': {'type': 'cFloat', 'coerce': _coerce.to_float}, 'antblpossig': {'type': 'cFloat', 'coerce': _coerce.to_float}, 'relaxed_factor': {'type': 'cFloat', 'coerce': _coerce.to_float}, 'niter': {'type': 'cInt'}, 'pipelinemode': {'type': 'cStr', 'coerce': _coerce.to_str, 'allowed': [ 'automatic', 'interactive', 'getinputs' ]}, '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 + 17 + 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 __pipelinemode_dflt( self, glb ):
return 'automatic'
def __pipelinemode( self, glb ):
if 'pipelinemode' in glb: return glb['pipelinemode']
return 'automatic'
#--------- return inp/go default --------------------------------------------------
def __dryrun_dflt( self, glb ):
if self.__pipelinemode( glb ) == "interactive": return bool(False)
return None
def __antblnegsig_dflt( self, glb ):
if self.__pipelinemode( glb ) == "interactive": return float(3.4)
return None
def __tmbl_dflt( self, glb ):
if self.__pipelinemode( glb ) == "interactive": return float(0.175)
return None
def __intent_dflt( self, glb ):
if self.__pipelinemode( glb ) == "interactive": return ""
return None
def __antpossig_dflt( self, glb ):
if self.__pipelinemode( glb ) == "interactive": return float(4.6)
return None
def __refant_dflt( self, glb ):
if self.__pipelinemode( glb ) == "interactive": return ""
return None
def __tmantint_dflt( self, glb ):
if self.__pipelinemode( glb ) == "interactive": return float(0.063)
return None
def __minsnr_dflt( self, glb ):
if self.__pipelinemode( glb ) == "interactive": return float(2.0)
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 __tmint_dflt( self, glb ):
if self.__pipelinemode( glb ) == "interactive": return float(0.085)
return None
def __relaxed_factor_dflt( self, glb ):
if self.__pipelinemode( glb ) == "interactive": return float(2.0)
return None
def __phaseupsolint_dflt( self, glb ):
if self.__pipelinemode( glb ) == "interactive": return "int"
return None
def __niter_dflt( self, glb ):
if self.__pipelinemode( glb ) == "interactive": return int(2)
return None
def __solint_dflt( self, glb ):
if self.__pipelinemode( glb ) == "interactive": return "inf"
return None
def __antnegsig_dflt( self, glb ):
if self.__pipelinemode( glb ) == "interactive": return float(4.0)
return None
def __antblpossig_dflt( self, glb ):
if self.__pipelinemode( glb ) == "interactive": return float(3.2)
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 __intent( self, glb ):
if 'intent' in glb: return glb['intent']
dflt = self.__intent_dflt( glb )
if dflt is not None: return dflt
return ''
def __phaseupsolint( self, glb ):
if 'phaseupsolint' in glb: return glb['phaseupsolint']
dflt = self.__phaseupsolint_dflt( glb )
if dflt is not None: return dflt
return 'int'
def __solint( self, glb ):
if 'solint' in glb: return glb['solint']
dflt = self.__solint_dflt( glb )
if dflt is not None: return dflt
return 'inf'
def __minsnr( self, glb ):
if 'minsnr' in glb: return glb['minsnr']
dflt = self.__minsnr_dflt( glb )
if dflt is not None: return dflt
return float(2.0)
def __refant( self, glb ):
if 'refant' in glb: return glb['refant']
dflt = self.__refant_dflt( glb )
if dflt is not None: return dflt
return ''
def __antnegsig( self, glb ):
if 'antnegsig' in glb: return glb['antnegsig']
dflt = self.__antnegsig_dflt( glb )
if dflt is not None: return dflt
return float(4.0)
def __antpossig( self, glb ):
if 'antpossig' in glb: return glb['antpossig']
dflt = self.__antpossig_dflt( glb )
if dflt is not None: return dflt
return float(4.6)
def __tmantint( self, glb ):
if 'tmantint' in glb: return glb['tmantint']
dflt = self.__tmantint_dflt( glb )
if dflt is not None: return dflt
return float(0.063)
def __tmint( self, glb ):
if 'tmint' in glb: return glb['tmint']
dflt = self.__tmint_dflt( glb )
if dflt is not None: return dflt
return float(0.085)
def __tmbl( self, glb ):
if 'tmbl' in glb: return glb['tmbl']
dflt = self.__tmbl_dflt( glb )
if dflt is not None: return dflt
return float(0.175)
def __antblnegsig( self, glb ):
if 'antblnegsig' in glb: return glb['antblnegsig']
dflt = self.__antblnegsig_dflt( glb )
if dflt is not None: return dflt
return float(3.4)
def __antblpossig( self, glb ):
if 'antblpossig' in glb: return glb['antblpossig']
dflt = self.__antblpossig_dflt( glb )
if dflt is not None: return dflt
return float(3.2)
def __relaxed_factor( self, glb ):
if 'relaxed_factor' in glb: return glb['relaxed_factor']
dflt = self.__relaxed_factor_dflt( glb )
if dflt is not None: return dflt
return float(2.0)
def __niter( self, glb ):
if 'niter' in glb: return glb['niter']
dflt = self.__niter_dflt( glb )
if dflt is not None: return dflt
return int(2)
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'
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%-14.14s =\x1B[0m %s%-23s%s' % ('vis',pre,self.__to_string_(value),post),description,9+len(pre)+len(post))
def __intent_inp(self):
if self.__intent_dflt( self.__globals_( ) ) is not None:
description = 'Set of data selection intents'
value = self.__intent( self.__globals_( ) )
(pre,post) = ('','') if self.__validate_({'intent': value},{'intent': self.__schema['intent']}) else ('\x1B[91m','\x1B[0m')
self.__do_inp_output(' \x1B[92m%-14.14s =\x1B[0m %s%-23s%s' % ('intent',pre,self.__to_string_(value),post),description,9+len(pre)+len(post))
def __phaseupsolint_inp(self):
if self.__phaseupsolint_dflt( self.__globals_( ) ) is not None:
description = 'Phaseup correction solution interval'
value = self.__phaseupsolint( self.__globals_( ) )
(pre,post) = ('','') if self.__validate_({'phaseupsolint': value},{'phaseupsolint': self.__schema['phaseupsolint']}) else ('\x1B[91m','\x1B[0m')
self.__do_inp_output(' \x1B[92m%-14.14s =\x1B[0m %s%-23s%s' % ('phaseupsolint',pre,self.__to_string_(value),post),description,9+len(pre)+len(post))
def __solint_inp(self):
if self.__solint_dflt( self.__globals_( ) ) is not None:
description = 'Solution intervals'
value = self.__solint( self.__globals_( ) )
(pre,post) = ('','') if self.__validate_({'solint': value},{'solint': self.__schema['solint']}) else ('\x1B[91m','\x1B[0m')
self.__do_inp_output(' \x1B[92m%-14.14s =\x1B[0m %s%-23s%s' % ('solint',pre,self.__to_string_(value),post),description,9+len(pre)+len(post))
def __minsnr_inp(self):
if self.__minsnr_dflt( self.__globals_( ) ) is not None:
description = 'Reject solutions below this SNR'
value = self.__minsnr( self.__globals_( ) )
(pre,post) = ('','') if self.__validate_({'minsnr': value},{'minsnr': self.__schema['minsnr']}) else ('\x1B[91m','\x1B[0m')
self.__do_inp_output(' \x1B[92m%-14.14s =\x1B[0m %s%-23s%s' % ('minsnr',pre,self.__to_string_(value),post),description,9+len(pre)+len(post))
def __refant_inp(self):
if self.__refant_dflt( self.__globals_( ) ) is not None:
description = 'Reference antenna names'
value = self.__refant( self.__globals_( ) )
(pre,post) = ('','') if self.__validate_({'refant': value},{'refant': self.__schema['refant']}) else ('\x1B[91m','\x1B[0m')
self.__do_inp_output(' \x1B[92m%-14.14s =\x1B[0m %s%-23s%s' % ('refant',pre,self.__to_string_(value),post),description,9+len(pre)+len(post))
def __antnegsig_inp(self):
if self.__antnegsig_dflt( self.__globals_( ) ) is not None:
description = 'Lower sigma threshold for identifying outliers as a result of bad antennas within individual timestamps'
value = self.__antnegsig( self.__globals_( ) )
(pre,post) = ('','') if self.__validate_({'antnegsig': value},{'antnegsig': self.__schema['antnegsig']}) else ('\x1B[91m','\x1B[0m')
self.__do_inp_output(' \x1B[92m%-14.14s =\x1B[0m %s%-23s%s' % ('antnegsig',pre,self.__to_string_(value),post),description,9+len(pre)+len(post))
def __antpossig_inp(self):
if self.__antpossig_dflt( self.__globals_( ) ) is not None:
description = 'Upper sigma threshold for identifying outliers as a result of bad antennas within individual timestamps'
value = self.__antpossig( self.__globals_( ) )
(pre,post) = ('','') if self.__validate_({'antpossig': value},{'antpossig': self.__schema['antpossig']}) else ('\x1B[91m','\x1B[0m')
self.__do_inp_output(' \x1B[92m%-14.14s =\x1B[0m %s%-23s%s' % ('antpossig',pre,self.__to_string_(value),post),description,9+len(pre)+len(post))
def __tmantint_inp(self):
if self.__tmantint_dflt( self.__globals_( ) ) is not None:
description = 'Threshold for maximum fraction of timestamps that are allowed to contain outliers'
value = self.__tmantint( self.__globals_( ) )
(pre,post) = ('','') if self.__validate_({'tmantint': value},{'tmantint': self.__schema['tmantint']}) else ('\x1B[91m','\x1B[0m')
self.__do_inp_output(' \x1B[92m%-14.14s =\x1B[0m %s%-23s%s' % ('tmantint',pre,self.__to_string_(value),post),description,9+len(pre)+len(post))
def __tmint_inp(self):
if self.__tmint_dflt( self.__globals_( ) ) is not None:
description = 'Initial threshold for maximum fraction of "outlier timestamps" over "total timestamps" that a baseline may be a part of'
value = self.__tmint( self.__globals_( ) )
(pre,post) = ('','') if self.__validate_({'tmint': value},{'tmint': self.__schema['tmint']}) else ('\x1B[91m','\x1B[0m')
self.__do_inp_output(' \x1B[92m%-14.14s =\x1B[0m %s%-23s%s' % ('tmint',pre,self.__to_string_(value),post),description,9+len(pre)+len(post))
def __tmbl_inp(self):
if self.__tmbl_dflt( self.__globals_( ) ) is not None:
description = 'Initial threshold for maximum fraction of "bad baselines" over "all baselines" that an antenna may be a part of'
value = self.__tmbl( self.__globals_( ) )
(pre,post) = ('','') if self.__validate_({'tmbl': value},{'tmbl': self.__schema['tmbl']}) else ('\x1B[91m','\x1B[0m')
self.__do_inp_output(' \x1B[92m%-14.14s =\x1B[0m %s%-23s%s' % ('tmbl',pre,self.__to_string_(value),post),description,9+len(pre)+len(post))
def __antblnegsig_inp(self):
if self.__antblnegsig_dflt( self.__globals_( ) ) is not None:
description = 'Lower sigma threshold for identifying outliers as a result of "bad baselines" and/or "bad antennas" within baselines (across all timestamps)'
value = self.__antblnegsig( self.__globals_( ) )
(pre,post) = ('','') if self.__validate_({'antblnegsig': value},{'antblnegsig': self.__schema['antblnegsig']}) else ('\x1B[91m','\x1B[0m')
self.__do_inp_output(' \x1B[92m%-14.14s =\x1B[0m %s%-23s%s' % ('antblnegsig',pre,self.__to_string_(value),post),description,9+len(pre)+len(post))
def __antblpossig_inp(self):
if self.__antblpossig_dflt( self.__globals_( ) ) is not None:
description = 'Upper sigma threshold for identifying outliers as a result of "bad baselines" and/or "bad antennas" within baselines (across all timestamps)'
value = self.__antblpossig( self.__globals_( ) )
(pre,post) = ('','') if self.__validate_({'antblpossig': value},{'antblpossig': self.__schema['antblpossig']}) else ('\x1B[91m','\x1B[0m')
self.__do_inp_output(' \x1B[92m%-14.14s =\x1B[0m %s%-23s%s' % ('antblpossig',pre,self.__to_string_(value),post),description,9+len(pre)+len(post))
def __relaxed_factor_inp(self):
if self.__relaxed_factor_dflt( self.__globals_( ) ) is not None:
description = 'Relaxed value to set the threshold scaling factor to under certain conditions (see task description)'
value = self.__relaxed_factor( self.__globals_( ) )
(pre,post) = ('','') if self.__validate_({'relaxed_factor': value},{'relaxed_factor': self.__schema['relaxed_factor']}) else ('\x1B[91m','\x1B[0m')
self.__do_inp_output(' \x1B[92m%-14.14s =\x1B[0m %s%-23s%s' % ('relaxed_factor',pre,self.__to_string_(value),post),description,9+len(pre)+len(post))
def __niter_inp(self):
if self.__niter_dflt( self.__globals_( ) ) is not None:
description = 'Maximum number of times to iterate on evaluation of flagging heuristics.'
value = self.__niter( self.__globals_( ) )
(pre,post) = ('','') if self.__validate_({'niter': value},{'niter': self.__schema['niter']}) else ('\x1B[91m','\x1B[0m')
self.__do_inp_output(' \x1B[92m%-14.14s =\x1B[0m %s%-23s%s' % ('niter',pre,self.__to_string_(value),post),description,9+len(pre)+len(post))
def __pipelinemode_inp(self):
description = 'The pipeline operations 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%-17.17s =\x1B[0m %s%-23s%s' % ('pipelinemode',pre,self.__to_string_(value),post),description,13+len(pre)+len(post))
def __dryrun_inp(self):
if self.__dryrun_dflt( self.__globals_( ) ) is not None:
description = 'Run the task (False) or list commands (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%-14.14s =\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 = 'Automatically apply results to 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%-14.14s =\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 'dryrun' in glb: del glb['dryrun']
if 'antblnegsig' in glb: del glb['antblnegsig']
if 'tmbl' in glb: del glb['tmbl']
if 'pipelinemode' in glb: del glb['pipelinemode']
if 'intent' in glb: del glb['intent']
if 'antpossig' in glb: del glb['antpossig']
if 'refant' in glb: del glb['refant']
if 'tmantint' in glb: del glb['tmantint']
if 'minsnr' in glb: del glb['minsnr']
if 'vis' in glb: del glb['vis']
if 'acceptresults' in glb: del glb['acceptresults']
if 'tmint' in glb: del glb['tmint']
if 'relaxed_factor' in glb: del glb['relaxed_factor']
if 'phaseupsolint' in glb: del glb['phaseupsolint']
if 'niter' in glb: del glb['niter']
if 'solint' in glb: del glb['solint']
if 'antnegsig' in glb: del glb['antnegsig']
if 'antblpossig' in glb: del glb['antblpossig']
#--------- inp function -----------------------------------------------------------
def inp(self):
print("# hifa_gfluxscaleflag -- %s" % self._info_desc_)
self.term_width, self.term_height = shutil.get_terminal_size(fallback=(80, 24))
self.__vis_inp( )
self.__intent_inp( )
self.__phaseupsolint_inp( )
self.__solint_inp( )
self.__minsnr_inp( )
self.__refant_inp( )
self.__antnegsig_inp( )
self.__antpossig_inp( )
self.__tmantint_inp( )
self.__tmint_inp( )
self.__tmbl_inp( )
self.__antblnegsig_inp( )
self.__antblpossig_inp( )
self.__relaxed_factor_inp( )
self.__niter_inp( )
self.__pipelinemode_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("hifa_gfluxscaleflag.last"):
filename = "hifa_gfluxscaleflag.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, intent=None, phaseupsolint=None, solint=None, minsnr=None, refant=None, antnegsig=None, antpossig=None, tmantint=None, tmint=None, tmbl=None, antblnegsig=None, antblpossig=None, relaxed_factor=None, niter=None, pipelinemode=None, dryrun=None, acceptresults=None ):
def noobj(s):
if s.startswith('<') and s.endswith('>'):
return "None"
else:
return s
_prefile = os.path.realpath('hifa_gfluxscaleflag.pre')
_postfile = os.path.realpath('hifa_gfluxscaleflag.last')
_return_result_ = None
_arguments = [vis,intent,phaseupsolint,solint,minsnr,refant,antnegsig,antpossig,tmantint,tmint,tmbl,antblnegsig,antblpossig,relaxed_factor,niter,pipelinemode,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 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['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['intent'] = self.__intent( _invocation_parameters ) if intent is None else intent
_invocation_parameters['phaseupsolint'] = self.__phaseupsolint( _invocation_parameters ) if phaseupsolint is None else phaseupsolint
_invocation_parameters['solint'] = self.__solint( _invocation_parameters ) if solint is None else solint
_invocation_parameters['minsnr'] = self.__minsnr( _invocation_parameters ) if minsnr is None else minsnr
_invocation_parameters['refant'] = self.__refant( _invocation_parameters ) if refant is None else refant
_invocation_parameters['antnegsig'] = self.__antnegsig( _invocation_parameters ) if antnegsig is None else antnegsig
_invocation_parameters['antpossig'] = self.__antpossig( _invocation_parameters ) if antpossig is None else antpossig
_invocation_parameters['tmantint'] = self.__tmantint( _invocation_parameters ) if tmantint is None else tmantint
_invocation_parameters['tmint'] = self.__tmint( _invocation_parameters ) if tmint is None else tmint
_invocation_parameters['tmbl'] = self.__tmbl( _invocation_parameters ) if tmbl is None else tmbl
_invocation_parameters['antblnegsig'] = self.__antblnegsig( _invocation_parameters ) if antblnegsig is None else antblnegsig
_invocation_parameters['antblpossig'] = self.__antblpossig( _invocation_parameters ) if antblpossig is None else antblpossig
_invocation_parameters['relaxed_factor'] = self.__relaxed_factor( _invocation_parameters ) if relaxed_factor is None else relaxed_factor
_invocation_parameters['niter'] = self.__niter( _invocation_parameters ) if niter is None else niter
_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['intent'] = self.__intent( self.__globals_( ) )
_invocation_parameters['phaseupsolint'] = self.__phaseupsolint( self.__globals_( ) )
_invocation_parameters['solint'] = self.__solint( self.__globals_( ) )
_invocation_parameters['minsnr'] = self.__minsnr( self.__globals_( ) )
_invocation_parameters['refant'] = self.__refant( self.__globals_( ) )
_invocation_parameters['antnegsig'] = self.__antnegsig( self.__globals_( ) )
_invocation_parameters['antpossig'] = self.__antpossig( self.__globals_( ) )
_invocation_parameters['tmantint'] = self.__tmantint( self.__globals_( ) )
_invocation_parameters['tmint'] = self.__tmint( self.__globals_( ) )
_invocation_parameters['tmbl'] = self.__tmbl( self.__globals_( ) )
_invocation_parameters['antblnegsig'] = self.__antblnegsig( self.__globals_( ) )
_invocation_parameters['antblpossig'] = self.__antblpossig( self.__globals_( ) )
_invocation_parameters['relaxed_factor'] = self.__relaxed_factor( self.__globals_( ) )
_invocation_parameters['niter'] = self.__niter( self.__globals_( ) )
_invocation_parameters['pipelinemode'] = self.__pipelinemode( 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("%-14s = %s\n" % (_i,noobj(repr(_invocation_parameters[_i]))))
_f.write("#hifa_gfluxscaleflag( ")
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_ = _hifa_gfluxscaleflag_t( _invocation_parameters['vis'],_invocation_parameters['intent'],_invocation_parameters['phaseupsolint'],_invocation_parameters['solint'],_invocation_parameters['minsnr'],_invocation_parameters['refant'],_invocation_parameters['antnegsig'],_invocation_parameters['antpossig'],_invocation_parameters['tmantint'],_invocation_parameters['tmint'],_invocation_parameters['tmbl'],_invocation_parameters['antblnegsig'],_invocation_parameters['antblpossig'],_invocation_parameters['relaxed_factor'],_invocation_parameters['niter'],_invocation_parameters['pipelinemode'],_invocation_parameters['dryrun'],_invocation_parameters['acceptresults'] )
except Exception as e:
from traceback import format_exc
from casatasks import casalog
casalog.origin('hifa_gfluxscaleflag')
casalog.post("Exception Reported: Error in hifa_gfluxscaleflag: %s" % str(e),'SEVERE')
casalog.post(format_exc( ))
_return_result_ = False
try:
os.rename(_prefile,_postfile)
except: pass
return _return_result_
hifa_gfluxscaleflag = _hifa_gfluxscaleflag( )