Пример #1
0
    def __call__(
        self,
        vis=None,
        outputvis=None,
        timerange=None,
        spw=None,
        subtime1=None,
        subtime2=None,
        splitsel=None,
        overwrite=None,
    ):
        """Vector-subtraction in UV using selected time ranges and spectral channels as background

	Detailed Description: 



Split is the general purpose program to make a new data set that is a
subset or averaged form of an existing data set.  General selection
parameters are included, and one or all of the various data columns
(DATA, LAG_DATA and/or FLOAT_DATA, and possibly MODEL_DATA and/or
CORRECTED_DATA) can be selected.

Split is often used after the initial calibration of the data to make a
smaller measurement set with only the data that will be used in
further flagging, imaging and/or self-calibration.  split can
average over frequency (channels) and time (integrations).

	Arguments :
		vis:	Name of input measurement set
		   Default Value: 

		outputvis:	Name of output measurement set
		   Default Value: 

		timerange:	Select the time range of the input visbility to be subtracted from
		   Default Value: 

		spw:	Select the spectral channels of the input visibility to be subtracted from
		   Default Value: 

		subtime1:	Select time range 1 as the background to be subtracted
		   Default Value: 

		subtime2:	Select time range 2 as the background to be subtracted
		   Default Value: 

		splitsel:	Split the selected timerange and spectral channels as outputvis
		   Default Value: True

		overwrite:	Overwrite the already existing output measurement set
		   Default Value: False


	Example :


    Subvs is a task to do UV vector-subtraction, by selecting time ranges 
    in the data as background. Subvs can be used to subtract the background
    continuum emission to separate the time-dependent emission, e.g. solar 
    coherent radio bursts. 
    
        Keyword arguments:
        vis -- Name of input visibility file
                default: none; example: vis='sun_type3.ms'
        outputvis -- Name of output visibility file
                default: none; example: outputvis='sun_type3.sub.ms'
	timerange -- Select the time range in the data to be subtracted from.
               timerange = 'YYYY/MM/DD/hh:mm:ss~YYYY/MM/DD/hh:mm:ss'
               Note: if YYYY/MM/DD is missing date, timerange defaults to the
               first day in the dataset
               timerange='09:14:0~09:54:0' picks 40 min on first day
               timerange='25:00:00~27:30:00' picks 1 hr to 3 hr 30min
               on next day
	spw -- Select spectral window/channel.
          	default = '' all the spectral channels. Example: spw='0:1~20'
	subtime1 -- Select the time range 1 of data as the background.
               Visibilities will be vector-averaged in time1 before subtraction. 
               default = '' (will raise an exception); examples,
               timerange = 'YYYY/MM/DD/hh:mm:ss~YYYY/MM/DD/hh:mm:ss'
               Note: if YYYY/MM/DD is missing date, timerange defaults to the
               first day in the dataset
               timerange='09:14:0~09:54:0' picks 40 min on first day
               timerange='25:00:00~27:30:00' picks 1 hr to 3 hr 30min
               on next day
	subtime2 -- Select the time range 2 of data as the background.
               Visibilities will be vector-averaged in time2 before subtraction.
	       if specified, then linear-interpolated values based on time1 and
	       time2 will be applied to the times specified by "subtime" for 
	       subtraction. 
	       if not specified, then only "time1" is used as the background	
               default = '' (none); examples,
               timerange = 'YYYY/MM/DD/hh:mm:ss~YYYY/MM/DD/hh:mm:ss'
               Note: if YYYY/MM/DD is missing date, timerange defaults to the
               first day in the dataset
               timerange='09:14:0~09:54:0' picks 40 min on first day
               timerange='25:00:00~27:30:00' picks 1 hr to 3 hr 30min
               on next day
        splitsel -- True of False. default = False. If splitsel = False, then the entire input 
	       measurement set is copied as the output measurement set (outputvis), with 
	       background subtracted at selected timerange and spectral channels. 
	       If splitsel = True,then only the selected timerange and spectral channels 
	       are copied into the output measurement set (outputvis).
	overwrite -- True or False. default = False. If overwrite = True and outputvis
	       already exists, the selected subtime and spw in the already existing 
	       output measurement set will be replaced with subtracted visibilities

        """
        if not hasattr(self, "__globals__") or self.__globals__ == None:
            self.__globals__ = sys._getframe(len(inspect.stack()) -
                                             1).f_globals
#casac = self.__globals__['casac']
        casalog = self.__globals__['casalog']
        casa = self.__globals__['casa']
        #casalog = casac.casac.logsink()
        self.__globals__['__last_task'] = 'subvs'
        self.__globals__['taskname'] = 'subvs'
        ###
        self.__globals__['update_params'](func=self.__globals__['taskname'],
                                          printtext=False,
                                          ipython_globals=self.__globals__)
        ###
        ###
        #Handle globals or user over-ride of arguments
        #
        if type(self.__call__.func_defaults) is NoneType:
            function_signature_defaults = {}
        else:
            function_signature_defaults = dict(
                zip(self.__call__.func_code.co_varnames[1:],
                    self.__call__.func_defaults))
        useLocalDefaults = False

        for item in function_signature_defaults.iteritems():
            key, val = item
            keyVal = eval(key)
            if (keyVal == None):
                #user hasn't set it - use global/default
                pass
            else:
                #user has set it - use over-ride
                if (key != 'self'):
                    useLocalDefaults = True

        myparams = {}
        if useLocalDefaults:
            for item in function_signature_defaults.iteritems():
                key, val = item
                keyVal = eval(key)
                exec('myparams[key] = keyVal')
                self.parameters[key] = keyVal
                if (keyVal == None):
                    exec('myparams[key] = ' + key + ' = self.itsdefault(key)')
                    keyVal = eval(key)
                    if (type(keyVal) == dict):
                        if len(keyVal) > 0:
                            exec('myparams[key] = ' + key +
                                 ' = keyVal[len(keyVal)-1][\'value\']')
                        else:
                            exec('myparams[key] = ' + key + ' = {}')

        else:
            print ''

            myparams['vis'] = vis = self.parameters['vis']
            myparams['outputvis'] = outputvis = self.parameters['outputvis']
            myparams['timerange'] = timerange = self.parameters['timerange']
            myparams['spw'] = spw = self.parameters['spw']
            myparams['subtime1'] = subtime1 = self.parameters['subtime1']
            myparams['subtime2'] = subtime2 = self.parameters['subtime2']
            myparams['splitsel'] = splitsel = self.parameters['splitsel']
            myparams['overwrite'] = overwrite = self.parameters['overwrite']

        result = None

        #
        #    The following is work around to avoid a bug with current python translation
        #
        mytmp = {}

        mytmp['vis'] = vis
        mytmp['outputvis'] = outputvis
        mytmp['timerange'] = timerange
        mytmp['spw'] = spw
        mytmp['subtime1'] = subtime1
        mytmp['subtime2'] = subtime2
        mytmp['splitsel'] = splitsel
        mytmp['overwrite'] = overwrite
        pathname = "file:///Users/binchen/Dropbox/bc_python/casa_task/"
        trec = casac.casac.utils().torecord(pathname + 'subvs.xml')

        casalog.origin('subvs')
        try:
            #if not trec.has_key('subvs') or not casac.casac.utils().verify(mytmp, trec['subvs']) :
            #return False

            casac.casac.utils().verify(mytmp, trec['subvs'], True)
            scriptstr = ['']
            saveinputs = self.__globals__['saveinputs']
            if type(self.__call__.func_defaults) is NoneType:
                saveinputs = ''
            else:
                saveinputs('subvs',
                           'subvs.last',
                           myparams,
                           self.__globals__,
                           scriptstr=scriptstr)
            tname = 'subvs'
            spaces = ' ' * (18 - len(tname))
            casalog.post('\n##########################################' +
                         '\n##### Begin Task: ' + tname + spaces + ' #####')
            if type(self.__call__.func_defaults) is NoneType:
                casalog.post(scriptstr[0] + '\n', 'INFO')
            else:
                casalog.post(scriptstr[1][1:] + '\n', 'INFO')
            result = subvs(vis, outputvis, timerange, spw, subtime1, subtime2,
                           splitsel, overwrite)
            casalog.post('##### End Task: ' + tname + '  ' + spaces +
                         ' #####' +
                         '\n##########################################')

        except Exception, instance:
            if (self.__globals__.has_key('__rethrow_casa_exceptions')
                    and self.__globals__['__rethrow_casa_exceptions']):
                raise
            else:
                #print '**** Error **** ',instance
                tname = 'subvs'
                casalog.post('An error occurred running task ' + tname + '.',
                             'ERROR')
                pass
Пример #2
0
    def __call__(
        self,
        vis=None,
        outputvis=None,
        timerange=None,
        spw=None,
        mode=None,
        subtime1=None,
        subtime2=None,
        smoothaxis=None,
        smoothtype=None,
        smoothwidth=None,
        splitsel=None,
        reverse=None,
        overwrite=None,
    ):
        """Vector-subtraction in UV using selected time ranges and spectral channels as background

	Detailed Description: 



Split is the general purpose program to make a new data set that is a
subset or averaged form of an existing data set.  General selection
parameters are included, and one or all of the various data columns
(DATA, LAG_DATA and/or FLOAT_DATA, and possibly MODEL_DATA and/or
CORRECTED_DATA) can be selected.

Split is often used after the initial calibration of the data to make a
smaller measurement set with only the data that will be used in
further flagging, imaging and/or self-calibration.  split can
average over frequency (channels) and time (integrations).

	Arguments :
		vis:	Name of input measurement set
		   Default Value: 

		outputvis:	Name of output measurement set
		   Default Value: 

		timerange:	Select the time range of the input visbility to be subtracted from
		   Default Value: 

		spw:	Select the spectral channels of the input visibility to be subtracted from
		   Default Value: 

		mode:	Operation: linear, highpass
		   Default Value: linear
		   Allowed Values:
				linear
				lowpass
				highpass

		subtime1:	Select the first time range as the background for uv subtraction 
		   Default Value: 

		subtime2:	Select the second time range as the background for uv subtraction 
		   Default Value: 

		smoothaxis:	Select the axis along which smooth is performed
		   Default Value: time

		smoothtype:	Select the smooth type
		   Default Value: flat

		smoothwidth:	Select the width of the smoothing window
		   Default Value: 5

		splitsel:	Split the selected timerange and spectral channels as outputvis
		   Default Value: True

		reverse:	Reverse the sign of the background-subtracted data (for absorptive structure)
		   Default Value: False

		overwrite:	Overwrite the already existing output measurement set
		   Default Value: False


	Example :


    Subvs is a task to do UV vector-subtraction, by selecting time ranges 
    in the data as background. Subvs can be used to subtract the background
    continuum emission to separate the time-dependent emission, e.g. solar 
    coherent radio bursts. 
    
    Keyword arguments:
    vis -- Name of input visibility file (MS)
            default: none; example: vis='ngc5921.ms'
    outputvis -- Name of output uv-subtracted visibility file (MS)
                  default: none; example: outputvis='ngc5921_src.ms'
    timerange -- Time range of performing the UV subtraction:
                 default='' means all times.  examples:
                 timerange = 'YYYY/MM/DD/hh:mm:ss~YYYY/MM/DD/hh:mm:ss'
                 timerange = 'hh:mm:ss~hh:mm:ss'
    spw -- Select spectral window/channel.
           default = '' all the spectral channels. Example: spw='0:1~20'
    mode -- operation mode
            default 'linear' 
                mode = 'linear': use a linear fit for the background to be subtracted
                mode = 'lowpass': act as a lowpass filter---smooth the data using different smooth
                        types and smooth window size. Can be performed along either time 
                        or frequency axis
                mode = 'highpass': act as a highpass filter---smooth the data first, and 
                        subtract the smoothed data from the original. Can be performed along either time
                        or frequency axis
            mode = 'linear' expandable parameters:
                subtime1 -- Time range 1 of the background to be subtracted from the data 
                             default='' means all times.  format:
                             timerange = 'YYYY/MM/DD/hh:mm:ss~YYYY/MM/DD/hh:mm:ss'
                             timerange = 'hh:mm:ss~hh:mm:ss'
                subtime2 -- Time range 2 of the backgroud to be subtracted from the data
                             default='' means all times.  examples:
                             timerange = 'YYYY/MM/DD/hh:mm:ss~YYYY/MM/DD/hh:mm:ss'
                             timerange = 'hh:mm:ss~hh:mm:ss'
            mode = 'lowpass' or 'highpass' expandable parameters:
                smoothaxis -- axis of smooth
                    Default: 'time'
                    smoothaxis = 'time': smooth is along the time axis
                    smoothaxis = 'freq': smooth is along the frequency axis
                smoothtype -- type of the smooth depending on the convolving kernel
                    Default: 'flat'
                    smoothtype = 'flat': convolving kernel is a flat rectangle,
                            equivalent to a boxcar moving smooth
                    smoothtype = 'hanning': Hanning smooth kernel. See numpy.hanning
                    smoothtype = 'hamming': Hamming smooth kernel. See numpy.hamming
                    smoothtype = 'bartlett': Bartlett smooth kernel. See numpy.bartlett
                    smoothtype = 'blackman': Blackman smooth kernel. See numpy.blackman
                smoothwidth -- width of the smooth kernel
                    Default: 5
                    Examples: smoothwidth=5, meaning the width is 5 pixels
    splitsel -- True or False. default = False. If splitsel = False, then the entire input
            measurement set is copied as the output measurement set (outputvis), with 
            background subtracted at selected timerange and spectral channels. 
            If splitsel = True,then only the selected timerange and spectral channels 
            are copied into the output measurement set (outputvis).
    reverse -- True or False. default = False. If reverse = False, then the times indicated
            by subtime1 and/or subtime2 are treated as background and subtracted; If reverse
            = True, then reverse the sign of the background-subtracted data. The option can 
            be used for mapping absorptive structure.
    overwrite -- True or False. default = False. If overwrite = True and
                outputvis already exists, the selected subtime and spw in the 
                output measurment set will be replaced with background subtracted 
                visibilities

        """
        if not hasattr(self, "__globals__") or self.__globals__ == None:
            self.__globals__ = sys._getframe(len(inspect.stack()) -
                                             1).f_globals
#casac = self.__globals__['casac']
        casalog = self.__globals__['casalog']
        casa = self.__globals__['casa']
        #casalog = casac.casac.logsink()
        self.__globals__['__last_task'] = 'subvs'
        self.__globals__['taskname'] = 'subvs'
        ###
        self.__globals__['update_params'](func=self.__globals__['taskname'],
                                          printtext=False,
                                          ipython_globals=self.__globals__)
        ###
        ###
        #Handle globals or user over-ride of arguments
        #
        if type(self.__call__.func_defaults) is NoneType:
            function_signature_defaults = {}
        else:
            function_signature_defaults = dict(
                zip(self.__call__.func_code.co_varnames[1:],
                    self.__call__.func_defaults))
        useLocalDefaults = False

        for item in function_signature_defaults.iteritems():
            key, val = item
            keyVal = eval(key)
            if (keyVal == None):
                #user hasn't set it - use global/default
                pass
            else:
                #user has set it - use over-ride
                if (key != 'self'):
                    useLocalDefaults = True

        myparams = {}
        if useLocalDefaults:
            for item in function_signature_defaults.iteritems():
                key, val = item
                keyVal = eval(key)
                exec('myparams[key] = keyVal')
                self.parameters[key] = keyVal
                if (keyVal == None):
                    exec('myparams[key] = ' + key + ' = self.itsdefault(key)')
                    keyVal = eval(key)
                    if (type(keyVal) == dict):
                        if len(keyVal) > 0:
                            exec('myparams[key] = ' + key +
                                 ' = keyVal[len(keyVal)-1][\'value\']')
                        else:
                            exec('myparams[key] = ' + key + ' = {}')

        else:
            print ''

            myparams['vis'] = vis = self.parameters['vis']
            myparams['outputvis'] = outputvis = self.parameters['outputvis']
            myparams['timerange'] = timerange = self.parameters['timerange']
            myparams['spw'] = spw = self.parameters['spw']
            myparams['mode'] = mode = self.parameters['mode']
            myparams['subtime1'] = subtime1 = self.parameters['subtime1']
            myparams['subtime2'] = subtime2 = self.parameters['subtime2']
            myparams['smoothaxis'] = smoothaxis = self.parameters['smoothaxis']
            myparams['smoothtype'] = smoothtype = self.parameters['smoothtype']
            myparams['smoothwidth'] = smoothwidth = self.parameters[
                'smoothwidth']
            myparams['splitsel'] = splitsel = self.parameters['splitsel']
            myparams['reverse'] = reverse = self.parameters['reverse']
            myparams['overwrite'] = overwrite = self.parameters['overwrite']

        result = None

        #
        #    The following is work around to avoid a bug with current python translation
        #
        mytmp = {}

        mytmp['vis'] = vis
        mytmp['outputvis'] = outputvis
        mytmp['timerange'] = timerange
        mytmp['spw'] = spw
        mytmp['mode'] = mode
        mytmp['subtime1'] = subtime1
        mytmp['subtime2'] = subtime2
        mytmp['smoothaxis'] = smoothaxis
        mytmp['smoothtype'] = smoothtype
        mytmp['smoothwidth'] = smoothwidth
        mytmp['splitsel'] = splitsel
        mytmp['reverse'] = reverse
        mytmp['overwrite'] = overwrite
        pathname = "file:///Users/binchen/Dropbox/bc_python/casa_task/"
        trec = casac.casac.utils().torecord(pathname + 'subvs.xml')

        casalog.origin('subvs')
        try:
            #if not trec.has_key('subvs') or not casac.casac.utils().verify(mytmp, trec['subvs']) :
            #return False

            casac.casac.utils().verify(mytmp, trec['subvs'], True)
            scriptstr = ['']
            saveinputs = self.__globals__['saveinputs']
            if type(self.__call__.func_defaults) is NoneType:
                saveinputs = ''
            else:
                saveinputs('subvs',
                           'subvs.last',
                           myparams,
                           self.__globals__,
                           scriptstr=scriptstr)
            tname = 'subvs'
            spaces = ' ' * (18 - len(tname))
            casalog.post('\n##########################################' +
                         '\n##### Begin Task: ' + tname + spaces + ' #####')
            if type(self.__call__.func_defaults) is NoneType:
                casalog.post(scriptstr[0] + '\n', 'INFO')
            else:
                casalog.post(scriptstr[1][1:] + '\n', 'INFO')
            result = subvs(vis, outputvis, timerange, spw, mode, subtime1,
                           subtime2, smoothaxis, smoothtype, smoothwidth,
                           splitsel, reverse, overwrite)
            casalog.post('##### End Task: ' + tname + '  ' + spaces +
                         ' #####' +
                         '\n##########################################')

        except Exception, instance:
            if (self.__globals__.has_key('__rethrow_casa_exceptions')
                    and self.__globals__['__rethrow_casa_exceptions']):
                raise
            else:
                #print '**** Error **** ',instance
                tname = 'subvs'
                casalog.post('An error occurred running task ' + tname + '.',
                             'ERROR')
                pass
Пример #3
0
def subvs(vis='',
          outputvis='',
          timerange='',
          spw='',
          mode='linear',
          subtime1='',
          subtime2='',
          smoothaxis='time',
          smoothtype='flat',
          smoothwidth=5,
          splitsel=True,
          reverse=False,
          overwrite=False):
    """Vector-subtraction in UV using selected time ranges and spectral channels as background

    Subvs is a task to do UV vector-subtraction, by selecting time ranges 
    in the data as background. Subvs can be used to subtract the background
    continuum emission to separate the time-dependent emission, e.g. solar 
    coherent radio bursts. 
    
    Keyword arguments:
    vis -- Name of input visibility file (MS)
            default: none; example: vis='ngc5921.ms'
    outputvis -- Name of output uv-subtracted visibility file (MS)
                  default: none; example: outputvis='ngc5921_src.ms'
    timerange -- Time range of performing the UV subtraction:
                 default='' means all times.  examples:
                 timerange = 'YYYY/MM/DD/hh:mm:ss~YYYY/MM/DD/hh:mm:ss'
                 timerange = 'hh:mm:ss~hh:mm:ss'
    spw -- Select spectral window/channel.
           default = '' all the spectral channels. Example: spw='0:1~20'
    mode -- operation mode
            default 'linear' 
                mode = 'linear': use a linear fit for the background to be subtracted
                mode = 'lowpass': act as a lowpass filter---smooth the data using different smooth
                        types and smooth window size. Can be performed along either time 
                        or frequency axis
                mode = 'highpass': act as a highpass filter---smooth the data first, and 
                        subtract the smoothed data from the original. Can be performed along either time
                        or frequency axis
            mode = 'linear' expandable parameters:
                subtime1 -- Time range 1 of the background to be subtracted from the data 
                             default='' means all times.  format:
                             timerange = 'YYYY/MM/DD/hh:mm:ss~YYYY/MM/DD/hh:mm:ss'
                             timerange = 'hh:mm:ss~hh:mm:ss'
                subtime2 -- Time range 2 of the backgroud to be subtracted from the data
                             default='' means all times.  examples:
                             timerange = 'YYYY/MM/DD/hh:mm:ss~YYYY/MM/DD/hh:mm:ss'
                             timerange = 'hh:mm:ss~hh:mm:ss'
            mode = 'lowpass' or 'highpass' expandable parameters:
                smoothaxis -- axis of smooth
                    Default: 'time'
                    smoothaxis = 'time': smooth is along the time axis
                    smoothaxis = 'freq': smooth is along the frequency axis
                smoothtype -- type of the smooth depending on the convolving kernel
                    Default: 'flat'
                    smoothtype = 'flat': convolving kernel is a flat rectangle,
                            equivalent to a boxcar moving smooth
                    smoothtype = 'hanning': Hanning smooth kernel. See numpy.hanning
                    smoothtype = 'hamming': Hamming smooth kernel. See numpy.hamming
                    smoothtype = 'bartlett': Bartlett smooth kernel. See numpy.bartlett
                    smoothtype = 'blackman': Blackman smooth kernel. See numpy.blackman
                smoothwidth -- width of the smooth kernel
                    Default: 5
                    Examples: smoothwidth=5, meaning the width is 5 pixels
    splitsel -- True or False. default = False. If splitsel = False, then the entire input
            measurement set is copied as the output measurement set (outputvis), with 
            background subtracted at selected timerange and spectral channels. 
            If splitsel = True,then only the selected timerange and spectral channels 
            are copied into the output measurement set (outputvis).
    reverse -- True or False. default = False. If reverse = False, then the times indicated
            by subtime1 and/or subtime2 are treated as background and subtracted; If reverse
            = True, then reverse the sign of the background-subtracted data. The option can 
            be used for mapping absorptive structure.
    overwrite -- True or False. default = False. If overwrite = True and
                outputvis already exists, the selected subtime and spw in the 
                output measurment set will be replaced with background subtracted 
                visibilities

        """

    #
    #    The following is work around to avoid a bug with current python translation
    #
    mytmp = {}

    mytmp['vis'] = vis
    mytmp['outputvis'] = outputvis
    mytmp['timerange'] = timerange
    mytmp['spw'] = spw
    mytmp['mode'] = mode
    mytmp['subtime1'] = subtime1
    mytmp['subtime2'] = subtime2
    mytmp['smoothaxis'] = smoothaxis
    mytmp['smoothtype'] = smoothtype
    mytmp['smoothwidth'] = smoothwidth
    mytmp['splitsel'] = splitsel
    mytmp['reverse'] = reverse
    mytmp['overwrite'] = overwrite
    pathname = "file:///Users/fisher/Dropbox/PycharmProjects/suncasa/tasks/"
    trec = casac.utils().torecord(pathname + 'subvs.xml')

    casalog.origin('subvs')
    if trec.has_key('subvs') and casac.utils().verify(mytmp, trec['subvs']):
        result = task_subvs.subvs(vis, outputvis, timerange, spw, mode,
                                  subtime1, subtime2, smoothaxis, smoothtype,
                                  smoothwidth, splitsel, reverse, overwrite)

    else:
        result = False
    return result
Пример #4
0
def subvs(vis='', outputvis='', timerange='', spw='', subtime1='', subtime2='', splitsel=True, reverse=False, overwrite=False):

        """Vector-subtraction in UV using selected time ranges and spectral channels as background

    Subvs is a task to do UV vector-subtraction, by selecting time ranges 
    in the data as background. Subvs can be used to subtract the background
    continuum emission to separate the time-dependent emission, e.g. solar 
    coherent radio bursts. 
    
        Keyword arguments:
        vis -- Name of input visibility file
                default: none; example: vis='sun_type3.ms'
        outputvis -- Name of output visibility file
                default: none; example: outputvis='sun_type3.sub.ms'
	timerange -- Select the time range in the data to be subtracted from.
               timerange = 'YYYY/MM/DD/hh:mm:ss~YYYY/MM/DD/hh:mm:ss'
               Note: if YYYY/MM/DD is missing date, timerange defaults to the
               first day in the dataset
               timerange='09:14:0~09:54:0' picks 40 min on first day
               timerange='25:00:00~27:30:00' picks 1 hr to 3 hr 30min
               on next day
	spw -- Select spectral window/channel.
          	default = '' all the spectral channels. Example: spw='0:1~20'
	subtime1 -- Select the time range 1 of data as the background.
               Visibilities will be vector-averaged in time1 before subtraction. 
               default = '' (will raise an exception); examples,
               timerange = 'YYYY/MM/DD/hh:mm:ss~YYYY/MM/DD/hh:mm:ss'
               Note: if YYYY/MM/DD is missing date, timerange defaults to the
               first day in the dataset
               timerange='09:14:0~09:54:0' picks 40 min on first day
               timerange='25:00:00~27:30:00' picks 1 hr to 3 hr 30min
               on next day
	subtime2 -- Select the time range 2 of data as the background.
               Visibilities will be vector-averaged in time2 before subtraction.
	       if specified, then linear-interpolated values based on time1 and
	       time2 will be applied to the times specified by "subtime" for 
	       subtraction. 
	       if not specified, then only "time1" is used as the background	
               default = '' (none); examples,
               timerange = 'YYYY/MM/DD/hh:mm:ss~YYYY/MM/DD/hh:mm:ss'
               Note: if YYYY/MM/DD is missing date, timerange defaults to the
               first day in the dataset
               timerange='09:14:0~09:54:0' picks 40 min on first day
               timerange='25:00:00~27:30:00' picks 1 hr to 3 hr 30min
               on next day
    splitsel -- True of False. default = False. If splitsel = False, then the entire input 
	       measurement set is copied as the output measurement set (outputvis), with 
	       background subtracted at selected timerange and spectral channels. 
	       If splitsel = True,then only the selected timerange and spectral channels 
	       are copied into the output measurement set (outputvis).
    reverse -- True or False. default = False. If reverse = False, then the times indicated
            by subtime1 and/or subtime2 are treated as background and subtracted; If reverse
            = True, then reverse the sign of the background-subtracted data. The option can 
            be used for mapping absorptive structure.
	overwrite -- True or False. default = False. If overwrite = True and outputvis
	       already exists, the selected subtime and spw in the already existing 
	       output measurement set will be replaced with subtracted visibilities

        """

#
#    The following is work around to avoid a bug with current python translation
#
        mytmp = {}

        mytmp['vis'] = vis
        mytmp['outputvis'] = outputvis
        mytmp['timerange'] = timerange
        mytmp['spw'] = spw
        mytmp['subtime1'] = subtime1
        mytmp['subtime2'] = subtime2
        mytmp['splitsel'] = splitsel
        mytmp['reverse'] = reverse
        mytmp['overwrite'] = overwrite
	pathname="file:///Users/binchen/Dropbox/bc_python/casa_task/"
	trec = casac.utils().torecord(pathname+'subvs.xml')

        casalog.origin('subvs')
        if trec.has_key('subvs') and casac.utils().verify(mytmp, trec['subvs']) :
	    result = task_subvs.subvs(vis, outputvis, timerange, spw, subtime1, subtime2, splitsel, reverse, overwrite)

	else :
	  result = False
        return result