示例#1
0
 def parameter_check(self):
     if isinstance(self.factor, str):
         casalog.post('read factor from \'%s\'' % self.factor)
         self.factor = sdutil.read_factor_file(self.factor)
示例#2
0
    def execute(self):
        # insert varnames into expr
        varnames = self.varnames

        for i in range(len(self.infiles)):
            infile_key = 'IN' + str(i)
            varnames[infile_key] = self.infiles[i]
        
        for key in varnames.keys():
            regex = re.compile( key )
            if isinstance( varnames[key], str ):
                self.expr = regex.sub( '\"%s\"' % varnames[key], self.expr )
            else:
                self.expr = regex.sub( "varnames['%s']" % key, self.expr )

        # default flux unit
        fluxunit_now = self.fluxunit
        
        # set filename list
        self.__parse()

        # selector
        sel = None

        # actual operation
        scanlist = {}
        for i in range(len(self.filenames)):
            skey='s'+str(i)
            isfactor = None
            # file type check
            if os.path.isdir( self.filenames[i] ):
                isfactor = False
            else:
                f = open( self.filenames[i] )
                line = f.readline().rstrip('\n')
                f.close()
                del f
                try:
                    isfactor = True
                    vtmp = float( line[0] )
                    del line
                except ValueError, e:
                    isfactor = False
                    del line
                
            if isfactor:
                # variable
                scanlist[skey] = sdutil.read_factor_file(self.filenames[i])
            else:
                # scantable
                thisscan=sd.scantable(self.filenames[i],average=False,antenna=self.antenna)

                # selector
                if sel is None:
                    sel = self.get_selector(thisscan)
                # Apply the selection
                thisscan.set_selection(sel)
                if fluxunit_now == '':
                    fluxunit_now = thisscan.get_fluxunit()
                # copy scantable since convert_flux overwrites spectral data
                if self.is_disk_storage:
                    casalog.post('copy data to keep original one')
                    s = thisscan.copy()
                else:
                    s = thisscan
                sdutil.set_fluxunit(s, self.fluxunit, self.telescopeparam, True)
                scanlist[skey] = s

            #regex=re.compile('[\',\"]')
            regex=re.compile('[\',\"]%s[\',\"]' % self.filenames[i])
            #expr=regex.sub('',expr)
            self.expr=regex.sub("scanlist['%s']" % skey ,self.expr)
示例#3
0
 def parameter_check(self):
     if isinstance( self.factor, str ):
         casalog.post( 'read factor from \'%s\'' %self.factor )
         self.factor = sdutil.read_factor_file(self.factor)
示例#4
0
    def execute(self):
        # insert varnames into expr
        varnames = self.varnames

        for i in range(len(self.infiles)):
            infile_key = 'IN' + str(i)
            varnames[infile_key] = self.infiles[i]

        for key in varnames.keys():
            regex = re.compile(key)
            if isinstance(varnames[key], str):
                self.expr = regex.sub('\"%s\"' % varnames[key], self.expr)
            else:
                self.expr = regex.sub("varnames['%s']" % key, self.expr)

        # default flux unit
        fluxunit_now = self.fluxunit

        # set filename list
        self.__parse()

        # selector
        sel = None

        # actual operation
        scanlist = {}
        for i in range(len(self.filenames)):
            skey = 's' + str(i)
            isfactor = None
            # file type check
            if os.path.isdir(self.filenames[i]):
                isfactor = False
            else:
                f = open(self.filenames[i])
                line = f.readline().rstrip('\n')
                f.close()
                del f
                try:
                    isfactor = True
                    vtmp = float(line[0])
                    del line
                except ValueError, e:
                    isfactor = False
                    del line

            if isfactor:
                # variable
                scanlist[skey] = sdutil.read_factor_file(self.filenames[i])
            else:
                # scantable
                thisscan = sd.scantable(self.filenames[i],
                                        average=False,
                                        antenna=self.antenna)

                # selector
                if sel is None:
                    sel = self.get_selector(thisscan)
                # Apply the selection
                thisscan.set_selection(sel)
                if fluxunit_now == '':
                    fluxunit_now = thisscan.get_fluxunit()
                # copy scantable since convert_flux overwrites spectral data
                if self.is_disk_storage:
                    casalog.post('copy data to keep original one')
                    s = thisscan.copy()
                else:
                    s = thisscan
                sdutil.set_fluxunit(s, self.fluxunit, self.telescopeparam,
                                    True)
                scanlist[skey] = s

            #regex=re.compile('[\',\"]')
            regex = re.compile('[\',\"]%s[\',\"]' % self.filenames[i])
            #expr=regex.sub('',expr)
            self.expr = regex.sub("scanlist['%s']" % skey, self.expr)