Source code for calibeovsa

##################### generated by xml-casa (v2) from calibeovsa.xml ################
##################### eedbae6635ef6957829bc80cbf8bb7ff ##############################
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 suncasatasks import calibeovsa as _calibeovsa_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
[docs] class _calibeovsa: """ calibeovsa ---- Calibrating EOVSA one or more measurement sets using calibration products in the SQL database. Calibrating EOVSA one or more measurement sets using calibration products in the SQL database. This task currently only works on pipeline. --------- parameter descriptions --------------------------------------------- vis input EOVSA (uncalibrated) measurement set(s). caltype Types of calibrations to perform caltbdir Directory to place calibration tables. interp Temporal interpolation for phacal table(s) (nearest, linear or auto) docalib If False, only create the calibration tables but do not perform applycal. doflag If true then perform flagging. flagant Antennas to be flagged. Follow CASA syntax of "antenna". flagspw Spectral windows to be flagged. Follow CASA syntax of "spw". Note this flag only applies to phacal tables. doimage If True, produce a quicklook image after calibration (sunpy must be installed). imagedir directory to place output images. Default current directory. antenna antenna/baselines to be used for imaging. Follow CASA syntax of "antenna". timerange Timerange to be imaged. Follow CASA syntax of "timerange". Default is the entire duration of the ms. spw spectral windows to be imaged. Follow CASA syntax of "spw". stokes stokes to be imaged. Follow CASA syntax of "stokes". dosplit If True, plit the corrected data column as output visibility file. outputvis Name of output visibility file. Default is the name of the first vis file ended with ".corrected.ms". doconcat If True, and if more than one visibility dataset provided, concatenate all into one visibility. concatvis Name of output visibility file. Default is the name of the first + last vis file ended with ".corrected.ms". keep_orig_ms Keep the original seperated ms datasets after split? --------- examples ----------------------------------------------------------- Calibrating EOVSA one or more measurement sets using calibration products in the SQL database. Detailed Keyword arguments: vis -- Name of input EOVSA measurement set dataset(s) default: none. Must be supplied example: vis = 'IDB20160524000518.ms' example: vis = ['IDB20160524000518.ms','IDB20160524000528.ms'] caltype -- list. Type of calibrations to be applied. 'refpha': reference phase calibration 'refamp': reference amplitude calibration (not used anymore) 'phacal': daily phase calibration 'fluxcal': flux calibration based on total-power measurements default value: ['refpha','phacal'] *** note fluxcal is already implemented in udb_corr when doing importeovsa, should not be used anymore **** *** pipeline only uses ['refpha','phacal'] caltbdir -- string. Place to hold calibration tables. Default is current directory. Pipeline should use /data1/eovsa/caltable interp -- string. How interpolation is done for phacal? 'nearest', 'linear', or 'auto' docalib -- boolean. Default True. If False, only create the calibration tables but do not perform applycal doflag -- boolean. Default True. Peforming flags? flagant -- string. Follow CASA antenna selection syntax. Default '13~15'. flagspw -- string. Follow CASA spw selection syntax. Default '0~1'. doimage -- boolean. Default False. If true, make a quicklook image using the specified time range and specified spw range imagedir -- string. Directory to place the output image. antenna -- string. Default '0~12'. Antenna/baselines to be used for imaging. Follow CASA antenna selection syntax. timerange -- string. Default '' (the whole duration of the visibility data). Follow CASA timerange syntax. e.g., '2017/07/11/20:16:00~2017/07/11/20:17:00' spw -- string. Default '1~3'. Follow CASA spw selection syntax. stokes -- string. Which stokes for the quicklook image. CASA syntax. Default 'XX' dosplit -- boolean. Split the corrected data column? outputvis -- string. Output visibility file after split doconcat -- boolean. If more than one visibility dataset provided, concatenate all into one or make separate outputs if True concatvis -- string. Output visibility file after concatenation keep_orig_ms -- boolean. Default True. Inherited from suncasa.eovsa.concateovsa. Keep the original seperated ms datasets after concatenation? """
[docs] _info_group_ = """Calibration"""
[docs] _info_desc_ = """Calibrating EOVSA one or more measurement sets using calibration products in the SQL database."""
[docs] __schema = {'vis': {'anyof': [{'type': 'cStr', 'coerce': _coerce.to_str}, {'type': 'cStrVec', 'coerce': [_coerce.to_list,_coerce.to_strvec]}]}, 'caltype': {'anyof': [{'type': 'cStr', 'coerce': _coerce.to_str}, {'type': 'cStrVec', 'coerce': [_coerce.to_list,_coerce.to_strvec]}]}, 'caltbdir': {'type': 'cStr', 'coerce': _coerce.to_str}, 'interp': {'type': 'cStr', 'coerce': _coerce.to_str}, 'docalib': {'type': 'cBool'}, 'doflag': {'type': 'cBool'}, 'flagant': {'type': 'cStr', 'coerce': _coerce.to_str}, 'flagspw': {'type': 'cStr', 'coerce': _coerce.to_str}, 'doimage': {'type': 'cBool'}, 'imagedir': {'type': 'cStr', 'coerce': _coerce.to_str}, 'antenna': {'type': 'cStr', 'coerce': _coerce.to_str}, 'timerange': {'type': 'cStr', 'coerce': _coerce.to_str}, 'spw': {'type': 'cStr', 'coerce': _coerce.to_str}, 'stokes': {'type': 'cStr', 'coerce': _coerce.to_str}, 'dosplit': {'type': 'cBool'}, 'outputvis': {'anyof': [{'type': 'cStr', 'coerce': _coerce.to_str}, {'type': 'cStrVec', 'coerce': [_coerce.to_list,_coerce.to_strvec]}]}, 'doconcat': {'type': 'cBool'}, 'concatvis': {'type': 'cStr', 'coerce': _coerce.to_str}, 'keep_orig_ms': {'type': 'cBool'}}
def __init__(self):
[docs] self.__stdout = None
[docs] self.__stderr = None
[docs] self.__root_frame_ = None
[docs] 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_
[docs] def __to_string_(self,value): if type(value) is str: return "'%s'" % value else: return str(value)
[docs] def __validate_(self,doc,schema): return _pc.validate(doc,schema)
[docs] def __do_inp_output(self,param_prefix,description_str,formatting_chars): out = self.__stdout or sys.stdout description = description_str.split( ) prefix_width = 23 + 15 + 4 output = [ ] addon = '' first_addon = True if len(description) == 0: out.write(param_prefix + " #\n") return 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 ----------------------------------------------
[docs] def __doimage_dflt( self, glb ): return False
[docs] def __doimage( self, glb ): if 'doimage' in glb: return glb['doimage'] return False
[docs] def __vis_dflt( self, glb ): return ''
[docs] def __vis( self, glb ): if 'vis' in glb: return glb['vis'] return ''
[docs] def __caltbdir_dflt( self, glb ): return ''
[docs] def __caltbdir( self, glb ): if 'caltbdir' in glb: return glb['caltbdir'] return ''
[docs] def __docalib_dflt( self, glb ): return True
[docs] def __docalib( self, glb ): if 'docalib' in glb: return glb['docalib'] return True
[docs] def __interp_dflt( self, glb ): return 'nearest'
[docs] def __interp( self, glb ): if 'interp' in glb: return glb['interp'] return 'nearest'
[docs] def __caltype_dflt( self, glb ): return [ ]
[docs] def __caltype( self, glb ): if 'caltype' in glb: return glb['caltype'] return [ ]
[docs] def __doflag_dflt( self, glb ): return True
[docs] def __doflag( self, glb ): if 'doflag' in glb: return glb['doflag'] return True
[docs] def __flagspw_dflt( self, glb ): return '0~1'
[docs] def __flagspw( self, glb ): if 'flagspw' in glb: return glb['flagspw'] return '0~1'
[docs] def __dosplit_dflt( self, glb ): return False
[docs] def __dosplit( self, glb ): if 'dosplit' in glb: return glb['dosplit'] return False
[docs] def __doconcat_dflt( self, glb ): return False
[docs] def __doconcat( self, glb ): if 'doconcat' in glb: return glb['doconcat'] return False
#--------- return inp/go default --------------------------------------------------
[docs] def __antenna_dflt( self, glb ): if self.__doimage( glb ) == bool(True): return "0~12" return None
[docs] def __stokes_dflt( self, glb ): if self.__doimage( glb ) == bool(True): return "XX" return None
[docs] def __flagant_dflt( self, glb ): if self.__doflag( glb ) == bool(True): return "13~15" return None
[docs] def __concatvis_dflt( self, glb ): if self.__doconcat( glb ) == bool(True): return "" return None
[docs] def __outputvis_dflt( self, glb ): if self.__dosplit( glb ) == bool(True): return "" return None
[docs] def __keep_orig_ms_dflt( self, glb ): if self.__dosplit( glb ) == bool(True): return bool(True) if self.__doconcat( glb ) == bool(True): return bool(True) return None
[docs] def __imagedir_dflt( self, glb ): if self.__doimage( glb ) == bool(True): return "." return None
[docs] def __spw_dflt( self, glb ): if self.__doimage( glb ) == bool(True): return "1~3" return None
[docs] def __timerange_dflt( self, glb ): if self.__doimage( glb ) == bool(True): return "" return None
#--------- return subparam values -------------------------------------------------
[docs] def __flagant( self, glb ): if 'flagant' in glb: return glb['flagant'] dflt = self.__flagant_dflt( glb ) if dflt is not None: return dflt return '13~15'
def __flagspw( self, glb ): if 'flagspw' in glb: return glb['flagspw'] dflt = self.__flagspw_dflt( glb ) if dflt is not None: return dflt return '0~1'
[docs] def __imagedir( self, glb ): if 'imagedir' in glb: return glb['imagedir'] dflt = self.__imagedir_dflt( glb ) if dflt is not None: return dflt return '.'
[docs] def __antenna( self, glb ): if 'antenna' in glb: return glb['antenna'] dflt = self.__antenna_dflt( glb ) if dflt is not None: return dflt return '0~12'
[docs] def __timerange( self, glb ): if 'timerange' in glb: return glb['timerange'] dflt = self.__timerange_dflt( glb ) if dflt is not None: return dflt return ''
[docs] def __spw( self, glb ): if 'spw' in glb: return glb['spw'] dflt = self.__spw_dflt( glb ) if dflt is not None: return dflt return '1~3'
[docs] def __stokes( self, glb ): if 'stokes' in glb: return glb['stokes'] dflt = self.__stokes_dflt( glb ) if dflt is not None: return dflt return 'XX'
[docs] def __outputvis( self, glb ): if 'outputvis' in glb: return glb['outputvis'] dflt = self.__outputvis_dflt( glb ) if dflt is not None: return dflt return ''
[docs] def __concatvis( self, glb ): if 'concatvis' in glb: return glb['concatvis'] dflt = self.__concatvis_dflt( glb ) if dflt is not None: return dflt return ''
[docs] def __keep_orig_ms( self, glb ): if 'keep_orig_ms' in glb: return glb['keep_orig_ms'] dflt = self.__keep_orig_ms_dflt( glb ) if dflt is not None: return dflt return True
#--------- subparam inp output ----------------------------------------------------
[docs] def __vis_inp(self): def xml_default( ): ## play the crazy subparameter shell game dflt = self.__vis_dflt( self.__globals_( ) ) if dflt is not None: return dflt return '' description = '' value = self.__vis( self.__globals_( ) ) (pre,post) = (('','') if value == xml_default( ) else ('\x1B[34m','\x1B[0m')) if self.__validate_({'vis': value},{'vis': self.__schema['vis']}) else ('\x1B[91m','\x1B[0m') self.__do_inp_output('%-15.15s = %s%-23s%s' % ('vis',pre,self.__to_string_(value),post),description,0+len(pre)+len(post))
[docs] def __caltype_inp(self): def xml_default( ): ## play the crazy subparameter shell game dflt = self.__caltype_dflt( self.__globals_( ) ) if dflt is not None: return dflt return [ ] description = '' value = self.__caltype( self.__globals_( ) ) (pre,post) = (('','') if value == xml_default( ) else ('\x1B[34m','\x1B[0m')) if self.__validate_({'caltype': value},{'caltype': self.__schema['caltype']}) else ('\x1B[91m','\x1B[0m') self.__do_inp_output('%-15.15s = %s%-23s%s' % ('caltype',pre,self.__to_string_(value),post),description,0+len(pre)+len(post))
[docs] def __caltbdir_inp(self): def xml_default( ): ## play the crazy subparameter shell game dflt = self.__caltbdir_dflt( self.__globals_( ) ) if dflt is not None: return dflt return '' description = '' value = self.__caltbdir( self.__globals_( ) ) (pre,post) = (('','') if value == xml_default( ) else ('\x1B[34m','\x1B[0m')) if self.__validate_({'caltbdir': value},{'caltbdir': self.__schema['caltbdir']}) else ('\x1B[91m','\x1B[0m') self.__do_inp_output('%-15.15s = %s%-23s%s' % ('caltbdir',pre,self.__to_string_(value),post),description,0+len(pre)+len(post))
[docs] def __interp_inp(self): def xml_default( ): ## play the crazy subparameter shell game dflt = self.__interp_dflt( self.__globals_( ) ) if dflt is not None: return dflt return 'nearest' description = '' value = self.__interp( self.__globals_( ) ) (pre,post) = (('','') if value == xml_default( ) else ('\x1B[34m','\x1B[0m')) if self.__validate_({'interp': value},{'interp': self.__schema['interp']}) else ('\x1B[91m','\x1B[0m') self.__do_inp_output('%-15.15s = %s%-23s%s' % ('interp',pre,self.__to_string_(value),post),description,0+len(pre)+len(post))
[docs] def __docalib_inp(self): def xml_default( ): ## play the crazy subparameter shell game dflt = self.__docalib_dflt( self.__globals_( ) ) if dflt is not None: return dflt return True description = '' value = self.__docalib( self.__globals_( ) ) (pre,post) = (('','') if value == xml_default( ) else ('\x1B[34m','\x1B[0m')) if self.__validate_({'docalib': value},{'docalib': self.__schema['docalib']}) else ('\x1B[91m','\x1B[0m') self.__do_inp_output('%-15.15s = %s%-23s%s' % ('docalib',pre,self.__to_string_(value),post),description,0+len(pre)+len(post))
[docs] def __doflag_inp(self): def xml_default( ): ## play the crazy subparameter shell game dflt = self.__doflag_dflt( self.__globals_( ) ) if dflt is not None: return dflt return True description = '' value = self.__doflag( self.__globals_( ) ) (pre,post) = (('','') if value == xml_default( ) else ('\x1B[34m','\x1B[0m')) if self.__validate_({'doflag': value},{'doflag': self.__schema['doflag']}) else ('\x1B[91m','\x1B[0m') self.__do_inp_output('\x1B[1m\x1B[47m%-15.15s =\x1B[0m %s%-23s%s' % ('doflag',pre,self.__to_string_(value),post),description,13+len(pre)+len(post))
[docs] def __flagant_inp(self): def xml_default( ): ## play the crazy subparameter shell game dflt = self.__flagant_dflt( self.__globals_( ) ) if dflt is not None: return dflt return '13~15' if self.__flagant_dflt( self.__globals_( ) ) is not None: description = '' value = self.__flagant( self.__globals_( ) ) (pre,post) = (('','') if value == xml_default( ) else ('\x1B[34m','\x1B[0m')) if self.__validate_({'flagant': value},{'flagant': self.__schema['flagant']}) else ('\x1B[91m','\x1B[0m') self.__do_inp_output(' \x1B[92m%-12.12s =\x1B[0m %s%-23s%s' % ('flagant',pre,self.__to_string_(value),post),description,9+len(pre)+len(post))
[docs] def __flagspw_inp(self): def xml_default( ): ## play the crazy subparameter shell game dflt = self.__flagspw_dflt( self.__globals_( ) ) if dflt is not None: return dflt return '0~1' if self.__flagspw_dflt( self.__globals_( ) ) is not None: description = '' value = self.__flagspw( self.__globals_( ) ) (pre,post) = (('','') if value == xml_default( ) else ('\x1B[34m','\x1B[0m')) if self.__validate_({'flagspw': value},{'flagspw': self.__schema['flagspw']}) else ('\x1B[91m','\x1B[0m') self.__do_inp_output(' \x1B[92m%-12.12s =\x1B[0m %s%-23s%s' % ('flagspw',pre,self.__to_string_(value),post),description,9+len(pre)+len(post))
[docs] def __doimage_inp(self): def xml_default( ): ## play the crazy subparameter shell game dflt = self.__doimage_dflt( self.__globals_( ) ) if dflt is not None: return dflt return False description = '' value = self.__doimage( self.__globals_( ) ) (pre,post) = (('','') if value == xml_default( ) else ('\x1B[34m','\x1B[0m')) if self.__validate_({'doimage': value},{'doimage': self.__schema['doimage']}) else ('\x1B[91m','\x1B[0m') self.__do_inp_output('\x1B[1m\x1B[47m%-15.15s =\x1B[0m %s%-23s%s' % ('doimage',pre,self.__to_string_(value),post),description,13+len(pre)+len(post))
[docs] def __imagedir_inp(self): def xml_default( ): ## play the crazy subparameter shell game dflt = self.__imagedir_dflt( self.__globals_( ) ) if dflt is not None: return dflt return '.' if self.__imagedir_dflt( self.__globals_( ) ) is not None: description = '' value = self.__imagedir( self.__globals_( ) ) (pre,post) = (('','') if value == xml_default( ) else ('\x1B[34m','\x1B[0m')) if self.__validate_({'imagedir': value},{'imagedir': self.__schema['imagedir']}) else ('\x1B[91m','\x1B[0m') self.__do_inp_output(' \x1B[92m%-12.12s =\x1B[0m %s%-23s%s' % ('imagedir',pre,self.__to_string_(value),post),description,9+len(pre)+len(post))
[docs] def __antenna_inp(self): def xml_default( ): ## play the crazy subparameter shell game dflt = self.__antenna_dflt( self.__globals_( ) ) if dflt is not None: return dflt return '0~12' if self.__antenna_dflt( self.__globals_( ) ) is not None: description = '' value = self.__antenna( self.__globals_( ) ) (pre,post) = (('','') if value == xml_default( ) else ('\x1B[34m','\x1B[0m')) if self.__validate_({'antenna': value},{'antenna': self.__schema['antenna']}) else ('\x1B[91m','\x1B[0m') self.__do_inp_output(' \x1B[92m%-12.12s =\x1B[0m %s%-23s%s' % ('antenna',pre,self.__to_string_(value),post),description,9+len(pre)+len(post))
[docs] def __timerange_inp(self): def xml_default( ): ## play the crazy subparameter shell game dflt = self.__timerange_dflt( self.__globals_( ) ) if dflt is not None: return dflt return '' if self.__timerange_dflt( self.__globals_( ) ) is not None: description = '' value = self.__timerange( self.__globals_( ) ) (pre,post) = (('','') if value == xml_default( ) else ('\x1B[34m','\x1B[0m')) if self.__validate_({'timerange': value},{'timerange': self.__schema['timerange']}) else ('\x1B[91m','\x1B[0m') self.__do_inp_output(' \x1B[92m%-12.12s =\x1B[0m %s%-23s%s' % ('timerange',pre,self.__to_string_(value),post),description,9+len(pre)+len(post))
[docs] def __spw_inp(self): def xml_default( ): ## play the crazy subparameter shell game dflt = self.__spw_dflt( self.__globals_( ) ) if dflt is not None: return dflt return '1~3' if self.__spw_dflt( self.__globals_( ) ) is not None: description = '' value = self.__spw( self.__globals_( ) ) (pre,post) = (('','') if value == xml_default( ) else ('\x1B[34m','\x1B[0m')) if self.__validate_({'spw': value},{'spw': self.__schema['spw']}) else ('\x1B[91m','\x1B[0m') self.__do_inp_output(' \x1B[92m%-12.12s =\x1B[0m %s%-23s%s' % ('spw',pre,self.__to_string_(value),post),description,9+len(pre)+len(post))
[docs] def __stokes_inp(self): def xml_default( ): ## play the crazy subparameter shell game dflt = self.__stokes_dflt( self.__globals_( ) ) if dflt is not None: return dflt return 'XX' if self.__stokes_dflt( self.__globals_( ) ) is not None: description = '' value = self.__stokes( self.__globals_( ) ) (pre,post) = (('','') if value == xml_default( ) else ('\x1B[34m','\x1B[0m')) if self.__validate_({'stokes': value},{'stokes': self.__schema['stokes']}) else ('\x1B[91m','\x1B[0m') self.__do_inp_output(' \x1B[92m%-12.12s =\x1B[0m %s%-23s%s' % ('stokes',pre,self.__to_string_(value),post),description,9+len(pre)+len(post))
[docs] def __dosplit_inp(self): def xml_default( ): ## play the crazy subparameter shell game dflt = self.__dosplit_dflt( self.__globals_( ) ) if dflt is not None: return dflt return False description = '' value = self.__dosplit( self.__globals_( ) ) (pre,post) = (('','') if value == xml_default( ) else ('\x1B[34m','\x1B[0m')) if self.__validate_({'dosplit': value},{'dosplit': self.__schema['dosplit']}) else ('\x1B[91m','\x1B[0m') self.__do_inp_output('\x1B[1m\x1B[47m%-15.15s =\x1B[0m %s%-23s%s' % ('dosplit',pre,self.__to_string_(value),post),description,13+len(pre)+len(post))
[docs] def __outputvis_inp(self): def xml_default( ): ## play the crazy subparameter shell game dflt = self.__outputvis_dflt( self.__globals_( ) ) if dflt is not None: return dflt return '' if self.__outputvis_dflt( self.__globals_( ) ) is not None: description = '' value = self.__outputvis( self.__globals_( ) ) (pre,post) = (('','') if value == xml_default( ) else ('\x1B[34m','\x1B[0m')) if self.__validate_({'outputvis': value},{'outputvis': self.__schema['outputvis']}) else ('\x1B[91m','\x1B[0m') self.__do_inp_output(' \x1B[92m%-12.12s =\x1B[0m %s%-23s%s' % ('outputvis',pre,self.__to_string_(value),post),description,9+len(pre)+len(post))
[docs] def __doconcat_inp(self): def xml_default( ): ## play the crazy subparameter shell game dflt = self.__doconcat_dflt( self.__globals_( ) ) if dflt is not None: return dflt return False description = '' value = self.__doconcat( self.__globals_( ) ) (pre,post) = (('','') if value == xml_default( ) else ('\x1B[34m','\x1B[0m')) if self.__validate_({'doconcat': value},{'doconcat': self.__schema['doconcat']}) else ('\x1B[91m','\x1B[0m') self.__do_inp_output('\x1B[1m\x1B[47m%-15.15s =\x1B[0m %s%-23s%s' % ('doconcat',pre,self.__to_string_(value),post),description,13+len(pre)+len(post))
[docs] def __concatvis_inp(self): def xml_default( ): ## play the crazy subparameter shell game dflt = self.__concatvis_dflt( self.__globals_( ) ) if dflt is not None: return dflt return '' if self.__concatvis_dflt( self.__globals_( ) ) is not None: description = '' value = self.__concatvis( self.__globals_( ) ) (pre,post) = (('','') if value == xml_default( ) else ('\x1B[34m','\x1B[0m')) if self.__validate_({'concatvis': value},{'concatvis': self.__schema['concatvis']}) else ('\x1B[91m','\x1B[0m') self.__do_inp_output(' \x1B[92m%-12.12s =\x1B[0m %s%-23s%s' % ('concatvis',pre,self.__to_string_(value),post),description,9+len(pre)+len(post))
[docs] def __keep_orig_ms_inp(self): def xml_default( ): ## play the crazy subparameter shell game dflt = self.__keep_orig_ms_dflt( self.__globals_( ) ) if dflt is not None: return dflt return True if self.__keep_orig_ms_dflt( self.__globals_( ) ) is not None: description = '' value = self.__keep_orig_ms( self.__globals_( ) ) (pre,post) = (('','') if value == xml_default( ) else ('\x1B[34m','\x1B[0m')) if self.__validate_({'keep_orig_ms': value},{'keep_orig_ms': self.__schema['keep_orig_ms']}) else ('\x1B[91m','\x1B[0m') self.__do_inp_output(' \x1B[92m%-12.12s =\x1B[0m %s%-23s%s' % ('keep_orig_ms',pre,self.__to_string_(value),post),description,9+len(pre)+len(post))
#--------- global default implementation------------------------------------------- @static_var('state', __sf__('casa_inp_go_state'))
[docs] def set_global_defaults(self): self.set_global_defaults.state['last'] = self glb = self.__globals_( ) if 'antenna' in glb: del glb['antenna'] if 'stokes' in glb: del glb['stokes'] if 'flagant' in glb: del glb['flagant'] if 'concatvis' in glb: del glb['concatvis'] if 'dosplit' in glb: del glb['dosplit'] if 'doflag' in glb: del glb['doflag'] if 'outputvis' in glb: del glb['outputvis'] if 'keep_orig_ms' in glb: del glb['keep_orig_ms'] if 'vis' in glb: del glb['vis'] if 'flagspw' in glb: del glb['flagspw'] if 'interp' in glb: del glb['interp'] if 'caltype' in glb: del glb['caltype'] if 'docalib' in glb: del glb['docalib'] if 'doconcat' in glb: del glb['doconcat'] if 'imagedir' in glb: del glb['imagedir'] if 'doimage' in glb: del glb['doimage'] if 'caltbdir' in glb: del glb['caltbdir'] if 'spw' in glb: del glb['spw'] if 'timerange' in glb: del glb['timerange']
#--------- inp function -----------------------------------------------------------
[docs] def inp(self): print("# calibeovsa -- %s" % self._info_desc_) self.term_width, self.term_height = shutil.get_terminal_size(fallback=(80, 24)) self.__vis_inp( ) self.__caltype_inp( ) self.__caltbdir_inp( ) self.__interp_inp( ) self.__docalib_inp( ) self.__doflag_inp( ) self.__flagant_inp( ) self.__flagspw_inp( ) self.__doimage_inp( ) self.__imagedir_inp( ) self.__antenna_inp( ) self.__timerange_inp( ) self.__spw_inp( ) self.__stokes_inp( ) self.__dosplit_inp( ) self.__outputvis_inp( ) self.__doconcat_inp( ) self.__concatvis_inp( ) self.__keep_orig_ms_inp( )
#--------- tget function ---------------------------------------------------------- @static_var('state', __sf__('casa_inp_go_state'))
[docs] def tget(self,savefile=None): from casashell.private.stack_manip import find_frame from runpy import run_path filename = savefile if filename is None: filename = "calibeovsa.last" if os.path.isfile("calibeovsa.last") else "calibeovsa.saved" if os.path.isfile(filename): 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: %s\nsetting defaults instead..." % filename) self.set_global_defaults( )
#--------- tput function ----------------------------------------------------------
[docs] def tput(self,outfile=None): def noobj(s): if s.startswith('<') and s.endswith('>'): return "None" else: return s _postfile = outfile if outfile is not None else os.path.realpath('calibeovsa.last') _invocation_parameters = OrderedDict( ) _invocation_parameters['vis'] = self.__vis( self.__globals_( ) ) _invocation_parameters['caltype'] = self.__caltype( self.__globals_( ) ) _invocation_parameters['caltbdir'] = self.__caltbdir( self.__globals_( ) ) _invocation_parameters['interp'] = self.__interp( self.__globals_( ) ) _invocation_parameters['docalib'] = self.__docalib( self.__globals_( ) ) _invocation_parameters['doflag'] = self.__doflag( self.__globals_( ) ) _invocation_parameters['flagant'] = self.__flagant( self.__globals_( ) ) _invocation_parameters['flagspw'] = self.__flagspw( self.__globals_( ) ) _invocation_parameters['doimage'] = self.__doimage( self.__globals_( ) ) _invocation_parameters['imagedir'] = self.__imagedir( self.__globals_( ) ) _invocation_parameters['antenna'] = self.__antenna( self.__globals_( ) ) _invocation_parameters['timerange'] = self.__timerange( self.__globals_( ) ) _invocation_parameters['spw'] = self.__spw( self.__globals_( ) ) _invocation_parameters['stokes'] = self.__stokes( self.__globals_( ) ) _invocation_parameters['dosplit'] = self.__dosplit( self.__globals_( ) ) _invocation_parameters['outputvis'] = self.__outputvis( self.__globals_( ) ) _invocation_parameters['doconcat'] = self.__doconcat( self.__globals_( ) ) _invocation_parameters['concatvis'] = self.__concatvis( self.__globals_( ) ) _invocation_parameters['keep_orig_ms'] = self.__keep_orig_ms( self.__globals_( ) ) try: with open(_postfile,'w') as _f: for _i in _invocation_parameters: _f.write("%-12s = %s\n" % (_i,noobj(repr(_invocation_parameters[_i])))) _f.write("#calibeovsa( ") 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: return False return True
[docs] def __call__( self, vis=None, caltype=None, caltbdir=None, interp=None, docalib=None, doflag=None, flagant=None, flagspw=None, doimage=None, imagedir=None, antenna=None, timerange=None, spw=None, stokes=None, dosplit=None, outputvis=None, doconcat=None, concatvis=None, keep_orig_ms=None ): def noobj(s): if s.startswith('<') and s.endswith('>'): return "None" else: return s _prefile = os.path.realpath('calibeovsa.pre') _postfile = os.path.realpath('calibeovsa.last') _return_result_ = None _arguments = [vis,caltype,caltbdir,interp,docalib,doflag,flagant,flagspw,doimage,imagedir,antenna,timerange,spw,stokes,dosplit,outputvis,doconcat,concatvis,keep_orig_ms] _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 vis is not None: local_global['vis'] = vis if caltype is not None: local_global['caltype'] = caltype if caltbdir is not None: local_global['caltbdir'] = caltbdir if interp is not None: local_global['interp'] = interp if docalib is not None: local_global['docalib'] = docalib if doflag is not None: local_global['doflag'] = doflag if doimage is not None: local_global['doimage'] = doimage if dosplit is not None: local_global['dosplit'] = dosplit if doconcat is not None: local_global['doconcat'] = doconcat # the invocation parameters for the non-subparameters can now be set - this picks up those defaults _invocation_parameters['vis'] = self.__vis( local_global ) _invocation_parameters['caltype'] = self.__caltype( local_global ) _invocation_parameters['caltbdir'] = self.__caltbdir( local_global ) _invocation_parameters['interp'] = self.__interp( local_global ) _invocation_parameters['docalib'] = self.__docalib( local_global ) _invocation_parameters['doflag'] = self.__doflag( local_global ) _invocation_parameters['doimage'] = self.__doimage( local_global ) _invocation_parameters['dosplit'] = self.__dosplit( local_global ) _invocation_parameters['doconcat'] = self.__doconcat( 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['flagant'] = self.__flagant( _invocation_parameters ) if flagant is None else flagant _invocation_parameters['flagspw'] = self.__flagspw( _invocation_parameters ) if flagspw is None else flagspw _invocation_parameters['imagedir'] = self.__imagedir( _invocation_parameters ) if imagedir is None else imagedir _invocation_parameters['antenna'] = self.__antenna( _invocation_parameters ) if antenna is None else antenna _invocation_parameters['timerange'] = self.__timerange( _invocation_parameters ) if timerange is None else timerange _invocation_parameters['spw'] = self.__spw( _invocation_parameters ) if spw is None else spw _invocation_parameters['stokes'] = self.__stokes( _invocation_parameters ) if stokes is None else stokes _invocation_parameters['outputvis'] = self.__outputvis( _invocation_parameters ) if outputvis is None else outputvis _invocation_parameters['concatvis'] = self.__concatvis( _invocation_parameters ) if concatvis is None else concatvis _invocation_parameters['keep_orig_ms'] = self.__keep_orig_ms( _invocation_parameters ) if keep_orig_ms is None else keep_orig_ms else: # invoke with inp/go semantics _invocation_parameters['vis'] = self.__vis( self.__globals_( ) ) _invocation_parameters['caltype'] = self.__caltype( self.__globals_( ) ) _invocation_parameters['caltbdir'] = self.__caltbdir( self.__globals_( ) ) _invocation_parameters['interp'] = self.__interp( self.__globals_( ) ) _invocation_parameters['docalib'] = self.__docalib( self.__globals_( ) ) _invocation_parameters['doflag'] = self.__doflag( self.__globals_( ) ) _invocation_parameters['flagant'] = self.__flagant( self.__globals_( ) ) _invocation_parameters['flagspw'] = self.__flagspw( self.__globals_( ) ) _invocation_parameters['doimage'] = self.__doimage( self.__globals_( ) ) _invocation_parameters['imagedir'] = self.__imagedir( self.__globals_( ) ) _invocation_parameters['antenna'] = self.__antenna( self.__globals_( ) ) _invocation_parameters['timerange'] = self.__timerange( self.__globals_( ) ) _invocation_parameters['spw'] = self.__spw( self.__globals_( ) ) _invocation_parameters['stokes'] = self.__stokes( self.__globals_( ) ) _invocation_parameters['dosplit'] = self.__dosplit( self.__globals_( ) ) _invocation_parameters['outputvis'] = self.__outputvis( self.__globals_( ) ) _invocation_parameters['doconcat'] = self.__doconcat( self.__globals_( ) ) _invocation_parameters['concatvis'] = self.__concatvis( self.__globals_( ) ) _invocation_parameters['keep_orig_ms'] = self.__keep_orig_ms( self.__globals_( ) ) try: with open(_prefile,'w') as _f: for _i in _invocation_parameters: _f.write("%-12s = %s\n" % (_i,noobj(repr(_invocation_parameters[_i])))) _f.write("#calibeovsa( ") 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_ = _calibeovsa_t( _invocation_parameters['vis'],_invocation_parameters['caltype'],_invocation_parameters['caltbdir'],_invocation_parameters['interp'],_invocation_parameters['docalib'],_invocation_parameters['doflag'],_invocation_parameters['flagant'],_invocation_parameters['flagspw'],_invocation_parameters['doimage'],_invocation_parameters['imagedir'],_invocation_parameters['antenna'],_invocation_parameters['timerange'],_invocation_parameters['spw'],_invocation_parameters['stokes'],_invocation_parameters['dosplit'],_invocation_parameters['outputvis'],_invocation_parameters['doconcat'],_invocation_parameters['concatvis'],_invocation_parameters['keep_orig_ms'] ) except Exception as e: from traceback import format_exc from casatasks import casalog casalog.origin('calibeovsa') casalog.post("Exception Reported: Error in calibeovsa: %s" % str(e),'SEVERE') casalog.post(format_exc( )) _return_result_ = False try: os.rename(_prefile,_postfile) except: pass return _return_result_
[docs] calibeovsa = _calibeovsa( )