Source code for pipeline.hifa.cli.gotasks.hifa_gfluxscale

##################### generated by xml-casa (v2) from hifa_gfluxscale.xml ###########
##################### 14474d323db3bbc71601c88c1026f415 ##############################
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_gfluxscale as _hifa_gfluxscale_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_gfluxscale: """ hifa_gfluxscale ---- Derive flux density scales from standard calibrators Derive flux densities for point source transfer calibrators using flux models for reference calibrators. Flux values are determined by: o computing complex gain phase only solutions for all the science spectral windows using the calibrator data selected by the 'reference' and 'refintent' parameters and the 'transfer' and 'transintent' parameters, and the value of the 'phaseupsolint' parameter. o computing complex amplitude only solutions for all the science spectral windows using calibrator data selected with 'reference' and 'refintent' parameters and the 'transfer' and 'transintent' parameters, the value of the 'solint' parameter. o transferring the flux scale from the reference calibrators to the transfer calibrators using refspwmap for windows without data in the reference calibrators o extracted the computed flux values from the CASA logs and inserting them into the MODEL_DATA column. Resolved calibrators are handled via antenna selection either automatically, hm_resolvedcals='automatic' or manually, hm_resolvedcals='manual'. In the former case antennas closer to the reference antenna than the uv distance where visibilities fall to 'peak_fraction' of the peak are used. In manual mode the antennas specified in 'antenna' are used. Note that the flux corrected calibration table computed internally is not currently used in later pipeline apply calibration steps. Issues Should we add a spw window selection option here? The code which extracts the flux scales from the logs needs to be replaced with code which uses the values returned from the CASA fluxscale task. --------- parameter descriptions --------------------------------------------- vis The list of input MeasurementSets. Defaults to the list of MeasurementSets specified in the pipeline context example: ['M32A.ms', 'M32B.ms'] reference A string containing a comma delimited list of field names defining the reference calibrators. Defaults to field names with intent '*AMP*'. example: reference='M82,3C273' transfer A string containing a comma delimited list of field names defining the transfer calibrators. Defaults to field names with intent '*PHASE*'. example: transfer='J1328+041,J1206+30' refintent A string containing a comma delimited list of intents used to select the reference calibrators. Defaults to 'AMPLITUDE'. example: refintent='', refintent='AMPLITUDE' transintent A string containing a comma delimited list of intents defining the transfer calibrators. Defaults to 'PHASE,BANDPASS,CHECK,POLARIZATION,POLANGLE,POLLEAKAGE'. example: transintent='', transintent='PHASE,BANDPASS' refspwmap Vector of spectral window ids enabling scaling across spectral windows. Defaults to no scaling. example: refspwmap=[1,1,3,3] - (4 spws, reference fields in 1 and 3, transfer fields in 0,1,2,3 reffile Path to a file containing flux densities for calibrators unknown to CASA. Values given in this file take precedence over the CASA-derived values for all calibrators except solar system calibrators. By default the path is set to the CSV file created by hifa_importdata, consisting of catalogue fluxes extracted from the ASDM and / or edited by the user. example: reffile='', reffile='working/flux.csv' phaseupsolint Time solution intervals in CASA syntax for the phase solution. example: phaseupsolint='inf', phaseupsolint='int', phaseupsolint='100sec' solint Time solution intervals in CASA syntax for the amplitude solution. example: solint='inf', solint='int', solint='100sec' minsnr Minimum signal to noise ratio for gain calibration solutions. example: minsnr=1.5, minsnr=0.0 refant A string specifying the reference antenna(s). By default this is read from the context. example: refant='DV05' hm_resolvedcals Heuristics method for handling resolved calibrators. The options are 'automatic' and 'manual'. In automatic mode antennas closer to the reference antenna than the uv distance where visibilities fall to 'peak_fraction' of the peak are used. In manual mode the antennas specified in 'antenna' are used. antenna A comma delimited string specifying the antenna names or ids to be used for the fluxscale determination. Used in hm_resolvedcals='manual' mode. example: antenna='DV16,DV07,DA12,DA08' peak_fraction The limiting UV distance from the reference antenna for antennas to be included in the flux calibration. Defined as the point where the calibrator visibilities have fallen to 'peak_fraction' of the peak value. 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 users can check the settings of all pipeline parameters without running the task. 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. Compute flux values for the phase calibrator using model data from the amplitude calibrator: hifa_gfluxscale() """ _info_group_ = """pipeline""" _info_desc_ = """Derive flux density scales from standard calibrators""" __schema = {'vis': {'type': 'cStr', 'coerce': _coerce.to_str}, 'reference': {'type': 'cVariant', 'coerce': [_coerce.to_variant]}, 'transfer': {'type': 'cVariant', 'coerce': [_coerce.to_variant]}, 'refintent': {'type': 'cStr', 'coerce': _coerce.to_str}, 'transintent': {'type': 'cStr', 'coerce': _coerce.to_str}, 'refspwmap': {'type': 'cIntVec', 'coerce': [_coerce.to_list,_coerce.to_intvec]}, 'reffile': {'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}, 'hm_resolvedcals': {'type': 'cStr', 'coerce': _coerce.to_str, 'allowed': [ 'automatic', 'manual' ]}, 'antenna': {'type': 'cStr', 'coerce': _coerce.to_str}, 'peak_fraction': {'type': 'cFloat', 'coerce': _coerce.to_float}, '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 + 16 + 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 __solint_dflt( self, glb ): return 'inf' def __solint( self, glb ): if 'solint' in glb: return glb['solint'] return 'inf' def __phaseupsolint_dflt( self, glb ): return 'int' def __phaseupsolint( self, glb ): if 'phaseupsolint' in glb: return glb['phaseupsolint'] return 'int' def __pipelinemode_dflt( self, glb ): return 'automatic' def __pipelinemode( self, glb ): if 'pipelinemode' in glb: return glb['pipelinemode'] return 'automatic' def __minsnr_dflt( self, glb ): return float(2.0) def __minsnr( self, glb ): if 'minsnr' in glb: return glb['minsnr'] return float(2.0) #--------- return non subparam/when values --------------------------------------------- def __hm_resolvedcals( self, glb ): if 'hm_resolvedcals' in glb: return glb['hm_resolvedcals'] return 'automatic' #--------- return inp/go default -------------------------------------------------- def __antenna_dflt( self, glb ): if self.__hm_resolvedcals( glb ) == "manual": return "" return None def __reference_dflt( self, glb ): if self.__pipelinemode( glb ) == "interactive": return { } if self.__pipelinemode( glb ) == "getinputs": return { } return None def __dryrun_dflt( self, glb ): if self.__pipelinemode( glb ) == "interactive": return bool(False) return None def __peak_fraction_dflt( self, glb ): if self.__hm_resolvedcals( glb ) == "automatic": return float(0.2) return None def __transintent_dflt( self, glb ): if self.__pipelinemode( glb ) == "interactive": return "" if self.__pipelinemode( glb ) == "getinputs": return "" return None def __refant_dflt( self, glb ): if self.__pipelinemode( glb ) == "interactive": return "" if self.__pipelinemode( glb ) == "getinputs": return "" 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 __refintent_dflt( self, glb ): if self.__pipelinemode( glb ) == "interactive": return "" if self.__pipelinemode( glb ) == "getinputs": return "" return None def __transfer_dflt( self, glb ): if self.__pipelinemode( glb ) == "interactive": return { } if self.__pipelinemode( glb ) == "getinputs": return { } return None def __refspwmap_dflt( self, glb ): if self.__pipelinemode( glb ) == "interactive": return [] if self.__pipelinemode( glb ) == "getinputs": return [] return None def __hm_resolvedcals_dflt( self, glb ): if self.__pipelinemode( glb ) == "interactive": return "automatic" if self.__pipelinemode( glb ) == "getinputs": return "automatic" return None def __reffile_dflt( self, glb ): if self.__pipelinemode( glb ) == "interactive": return "" if self.__pipelinemode( glb ) == "getinputs": return "" 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 __reference( self, glb ): if 'reference' in glb: return glb['reference'] dflt = self.__reference_dflt( glb ) if dflt is not None: return dflt return '' def __transfer( self, glb ): if 'transfer' in glb: return glb['transfer'] dflt = self.__transfer_dflt( glb ) if dflt is not None: return dflt return '' def __refintent( self, glb ): if 'refintent' in glb: return glb['refintent'] dflt = self.__refintent_dflt( glb ) if dflt is not None: return dflt return '' def __transintent( self, glb ): if 'transintent' in glb: return glb['transintent'] dflt = self.__transintent_dflt( glb ) if dflt is not None: return dflt return '' def __refspwmap( self, glb ): if 'refspwmap' in glb: return glb['refspwmap'] dflt = self.__refspwmap_dflt( glb ) if dflt is not None: return dflt return [ ] def __reffile( self, glb ): if 'reffile' in glb: return glb['reffile'] dflt = self.__reffile_dflt( glb ) if dflt is not None: return dflt return '' 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 __antenna( self, glb ): if 'antenna' in glb: return glb['antenna'] dflt = self.__antenna_dflt( glb ) if dflt is not None: return dflt return '' def __peak_fraction( self, glb ): if 'peak_fraction' in glb: return glb['peak_fraction'] dflt = self.__peak_fraction_dflt( glb ) if dflt is not None: return dflt return float(0.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%-13.13s =\x1B[0m %s%-23s%s' % ('vis',pre,self.__to_string_(value),post),description,9+len(pre)+len(post)) def __reference_inp(self): if self.__reference_dflt( self.__globals_( ) ) is not None: description = 'Reference calibrator field name(s)' value = self.__reference( self.__globals_( ) ) (pre,post) = ('','') if self.__validate_({'reference': value},{'reference': self.__schema['reference']}) else ('\x1B[91m','\x1B[0m') self.__do_inp_output(' \x1B[92m%-13.13s =\x1B[0m %s%-23s%s' % ('reference',pre,self.__to_string_(value),post),description,9+len(pre)+len(post)) def __transfer_inp(self): if self.__transfer_dflt( self.__globals_( ) ) is not None: description = 'Transfer calibrator field name(s)' value = self.__transfer( self.__globals_( ) ) (pre,post) = ('','') if self.__validate_({'transfer': value},{'transfer': self.__schema['transfer']}) else ('\x1B[91m','\x1B[0m') self.__do_inp_output(' \x1B[92m%-13.13s =\x1B[0m %s%-23s%s' % ('transfer',pre,self.__to_string_(value),post),description,9+len(pre)+len(post)) def __refintent_inp(self): if self.__refintent_dflt( self.__globals_( ) ) is not None: description = 'Observing intent of reference fields' value = self.__refintent( self.__globals_( ) ) (pre,post) = ('','') if self.__validate_({'refintent': value},{'refintent': self.__schema['refintent']}) else ('\x1B[91m','\x1B[0m') self.__do_inp_output(' \x1B[92m%-13.13s =\x1B[0m %s%-23s%s' % ('refintent',pre,self.__to_string_(value),post),description,9+len(pre)+len(post)) def __transintent_inp(self): if self.__transintent_dflt( self.__globals_( ) ) is not None: description = 'Observing intent of transfer fields' value = self.__transintent( self.__globals_( ) ) (pre,post) = ('','') if self.__validate_({'transintent': value},{'transintent': self.__schema['transintent']}) else ('\x1B[91m','\x1B[0m') self.__do_inp_output(' \x1B[92m%-13.13s =\x1B[0m %s%-23s%s' % ('transintent',pre,self.__to_string_(value),post),description,9+len(pre)+len(post)) def __refspwmap_inp(self): if self.__refspwmap_dflt( self.__globals_( ) ) is not None: description = 'Map across spectral window boundaries' value = self.__refspwmap( self.__globals_( ) ) (pre,post) = ('','') if self.__validate_({'refspwmap': value},{'refspwmap': self.__schema['refspwmap']}) else ('\x1B[91m','\x1B[0m') self.__do_inp_output(' \x1B[92m%-13.13s =\x1B[0m %s%-23s%s' % ('refspwmap',pre,self.__to_string_(value),post),description,9+len(pre)+len(post)) def __reffile_inp(self): if self.__reffile_dflt( self.__globals_( ) ) is not None: description = 'Path to file with fluxes for non-solar system calibrators' value = self.__reffile( self.__globals_( ) ) (pre,post) = ('','') if self.__validate_({'reffile': value},{'reffile': self.__schema['reffile']}) else ('\x1B[91m','\x1B[0m') self.__do_inp_output(' \x1B[92m%-13.13s =\x1B[0m %s%-23s%s' % ('reffile',pre,self.__to_string_(value),post),description,9+len(pre)+len(post)) def __phaseupsolint_inp(self): 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('%-16.16s = %s%-23s%s' % ('phaseupsolint',pre,self.__to_string_(value),post),description,0+len(pre)+len(post)) def __solint_inp(self): description = 'Amplitude correction solution interval' 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('%-16.16s = %s%-23s%s' % ('solint',pre,self.__to_string_(value),post),description,0+len(pre)+len(post)) def __minsnr_inp(self): description = 'Minimum SNR for gain solutions' 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('%-16.16s = %s%-23s%s' % ('minsnr',pre,self.__to_string_(value),post),description,0+len(pre)+len(post)) def __refant_inp(self): if self.__refant_dflt( self.__globals_( ) ) is not None: description = 'The name or ID of the reference antenna' 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%-13.13s =\x1B[0m %s%-23s%s' % ('refant',pre,self.__to_string_(value),post),description,9+len(pre)+len(post)) def __hm_resolvedcals_inp(self): description = 'The resolved calibrators heuristics method' value = self.__hm_resolvedcals( self.__globals_( ) ) (pre,post) = ('','') if self.__validate_({'hm_resolvedcals': value},{'hm_resolvedcals': self.__schema['hm_resolvedcals']}) else ('\x1B[91m','\x1B[0m') self.__do_inp_output('\x1B[1m\x1B[47m%-16.16s =\x1B[0m %s%-23s%s' % ('hm_resolvedcals',pre,self.__to_string_(value),post),description,13+len(pre)+len(post)) def __antenna_inp(self): if self.__antenna_dflt( self.__globals_( ) ) is not None: description = 'Antennas to be used in fluxscale' value = self.__antenna( self.__globals_( ) ) (pre,post) = ('','') if self.__validate_({'antenna': value},{'antenna': self.__schema['antenna']}) else ('\x1B[91m','\x1B[0m') self.__do_inp_output(' \x1B[92m%-13.13s =\x1B[0m %s%-23s%s' % ('antenna',pre,self.__to_string_(value),post),description,9+len(pre)+len(post)) def __peak_fraction_inp(self): if self.__peak_fraction_dflt( self.__globals_( ) ) is not None: description = 'Fraction of peak visibility at uv-distance limit of antennas to be used' value = self.__peak_fraction( self.__globals_( ) ) (pre,post) = ('','') if self.__validate_({'peak_fraction': value},{'peak_fraction': self.__schema['peak_fraction']}) else ('\x1B[91m','\x1B[0m') self.__do_inp_output(' \x1B[92m%-13.13s =\x1B[0m %s%-23s%s' % ('peak_fraction',pre,self.__to_string_(value),post),description,9+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%-16.16s =\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 display 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%-13.13s =\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 accept results into 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%-13.13s =\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 'antenna' in glb: del glb['antenna'] if 'reference' in glb: del glb['reference'] if 'dryrun' in glb: del glb['dryrun'] if 'peak_fraction' in glb: del glb['peak_fraction'] if 'pipelinemode' in glb: del glb['pipelinemode'] if 'transintent' in glb: del glb['transintent'] if 'refant' in glb: del glb['refant'] if 'minsnr' in glb: del glb['minsnr'] if 'vis' in glb: del glb['vis'] if 'acceptresults' in glb: del glb['acceptresults'] if 'refintent' in glb: del glb['refintent'] if 'transfer' in glb: del glb['transfer'] if 'refspwmap' in glb: del glb['refspwmap'] if 'phaseupsolint' in glb: del glb['phaseupsolint'] if 'hm_resolvedcals' in glb: del glb['hm_resolvedcals'] if 'solint' in glb: del glb['solint'] if 'reffile' in glb: del glb['reffile'] #--------- inp function ----------------------------------------------------------- def inp(self): print("# hifa_gfluxscale -- %s" % self._info_desc_) self.term_width, self.term_height = shutil.get_terminal_size(fallback=(80, 24)) self.__vis_inp( ) self.__reference_inp( ) self.__transfer_inp( ) self.__refintent_inp( ) self.__transintent_inp( ) self.__refspwmap_inp( ) self.__reffile_inp( ) self.__phaseupsolint_inp( ) self.__solint_inp( ) self.__minsnr_inp( ) self.__refant_inp( ) self.__hm_resolvedcals_inp( ) self.__antenna_inp( ) self.__peak_fraction_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_gfluxscale.last"): filename = "hifa_gfluxscale.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, reference=None, transfer=None, refintent=None, transintent=None, refspwmap=None, reffile=None, phaseupsolint=None, solint=None, minsnr=None, refant=None, hm_resolvedcals=None, antenna=None, peak_fraction=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_gfluxscale.pre') _postfile = os.path.realpath('hifa_gfluxscale.last') _return_result_ = None _arguments = [vis,reference,transfer,refintent,transintent,refspwmap,reffile,phaseupsolint,solint,minsnr,refant,hm_resolvedcals,antenna,peak_fraction,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 phaseupsolint is not None: local_global['phaseupsolint'] = phaseupsolint if solint is not None: local_global['solint'] = solint if minsnr is not None: local_global['minsnr'] = minsnr if hm_resolvedcals is not None: local_global['hm_resolvedcals'] = hm_resolvedcals 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['phaseupsolint'] = self.__phaseupsolint( local_global ) _invocation_parameters['solint'] = self.__solint( local_global ) _invocation_parameters['minsnr'] = self.__minsnr( local_global ) _invocation_parameters['hm_resolvedcals'] = self.__hm_resolvedcals( 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['reference'] = self.__reference( _invocation_parameters ) if reference is None else reference _invocation_parameters['transfer'] = self.__transfer( _invocation_parameters ) if transfer is None else transfer _invocation_parameters['refintent'] = self.__refintent( _invocation_parameters ) if refintent is None else refintent _invocation_parameters['transintent'] = self.__transintent( _invocation_parameters ) if transintent is None else transintent _invocation_parameters['refspwmap'] = self.__refspwmap( _invocation_parameters ) if refspwmap is None else refspwmap _invocation_parameters['reffile'] = self.__reffile( _invocation_parameters ) if reffile is None else reffile _invocation_parameters['refant'] = self.__refant( _invocation_parameters ) if refant is None else refant _invocation_parameters['antenna'] = self.__antenna( _invocation_parameters ) if antenna is None else antenna _invocation_parameters['peak_fraction'] = self.__peak_fraction( _invocation_parameters ) if peak_fraction is None else peak_fraction _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['reference'] = self.__reference( self.__globals_( ) ) _invocation_parameters['transfer'] = self.__transfer( self.__globals_( ) ) _invocation_parameters['refintent'] = self.__refintent( self.__globals_( ) ) _invocation_parameters['transintent'] = self.__transintent( self.__globals_( ) ) _invocation_parameters['refspwmap'] = self.__refspwmap( self.__globals_( ) ) _invocation_parameters['reffile'] = self.__reffile( 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['hm_resolvedcals'] = self.__hm_resolvedcals( self.__globals_( ) ) _invocation_parameters['antenna'] = self.__antenna( self.__globals_( ) ) _invocation_parameters['peak_fraction'] = self.__peak_fraction( 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("%-13s = %s\n" % (_i,noobj(repr(_invocation_parameters[_i])))) _f.write("#hifa_gfluxscale( ") 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_gfluxscale_t( _invocation_parameters['vis'],_invocation_parameters['reference'],_invocation_parameters['transfer'],_invocation_parameters['refintent'],_invocation_parameters['transintent'],_invocation_parameters['refspwmap'],_invocation_parameters['reffile'],_invocation_parameters['phaseupsolint'],_invocation_parameters['solint'],_invocation_parameters['minsnr'],_invocation_parameters['refant'],_invocation_parameters['hm_resolvedcals'],_invocation_parameters['antenna'],_invocation_parameters['peak_fraction'],_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_gfluxscale') casalog.post("Exception Reported: Error in hifa_gfluxscale: %s" % str(e),'SEVERE') casalog.post(format_exc( )) _return_result_ = False try: os.rename(_prefile,_postfile) except: pass return _return_result_ hifa_gfluxscale = _hifa_gfluxscale( )