예제 #1
0
 def parameter_check(self):
     # If outfile is set, sd.rcParams['verbose'] must be True
     self.verbose_saved = sd.rcParams['verbose']
     if (len(self.outfile) > 0):
         if ( not os.path.exists(sdutil.get_abspath(self.outfile)) \
              or self.overwrite ):
             sd.rcParams['verbose'] = True
예제 #2
0
 def parameter_check(self):
     # If outfile is set, sd.rcParams['verbose'] must be True
     self.verbose_saved = sd.rcParams['verbose']
     if ( len(self.outfile) > 0 ):
         if ( not os.path.exists(sdutil.get_abspath(self.outfile)) \
              or self.overwrite ):
             sd.rcParams['verbose']=True
예제 #3
0
 def save(self):
     if ( len(self.outfile) > 0 ):
         if ( not os.path.exists(sdutil.get_abspath(self.outfile)) \
              or self.overwrite ):
             f=open(self.outfile,'w')
             f.write(self.savestats)
             f.close()
         else:
             casalog.post( 'File '+self.outfile+' already exists.\nStatistics results are not written into the file.', priority = 'WARN' )
예제 #4
0
    def parameter_check(self):
        # by default, the task overwrite infile
        if len(self.outfile) == 0:
            self.project = self.infile
        else:
            self.project = self.outfile

        sdutil.assert_outfile_canoverwrite_or_nonexistent(
            self.project, self.outform, self.overwrite)

        #check the format of the infile
        filename = sdutil.get_abspath(self.infile)
        if isinstance(self.infile, str):
            if is_scantable(filename):
                informat = 'ASAP'
            elif is_ms(filename):
                informat = 'MS2'
            else:
                informat = 'SDFITS'
        else:
            informat = 'UNDEFINED'

        # Check the formats of infile and outfile are identical when overwrite=True.
        # (CAS-3096). If not, print warning message and exit.
        outformat = self.outform.upper()
        if (outformat == 'MS'): outformat = 'MS2'
        if self.overwrite and os.path.exists(self.project) \
           and (sdutil.get_abspath(self.project) == sdutil.get_abspath(self.infile)) \
           and (outformat != informat):
            msg = "The input and output data format must be identical when "
            msg += "their names are identical and overwrite=True. "
            msg += "%s and %s given for input and output, respectively." % (
                informat, outformat)
            raise Exception, msg

        # check restfreq
        self.rfset = (self.restfreq != '') and (self.restfreq != [])
        self.restore = self.rfset

        if self.mode.lower()[0] not in self.valid_modes:
            raise Exception, "Invalide mode, '%s'" % self.mode

        # check whether any flag operation is done or not
        self.anyflag = False
예제 #5
0
    def parameter_check(self):
        # by default, the task overwrite infile
        if len(self.outfile)==0: 
            self.project = self.infile
        else:
            self.project = self.outfile

        sdutil.assert_outfile_canoverwrite_or_nonexistent(self.project,
                                                          self.outform,
                                                          self.overwrite)
        
        #check the format of the infile
        filename = sdutil.get_abspath(self.infile)
        if isinstance(self.infile, str):
            if is_scantable(filename):
                informat = 'ASAP'
            elif is_ms(filename):
                informat = 'MS2'
            else:
                informat = 'SDFITS'
        else:
            informat = 'UNDEFINED'
                
        # Check the formats of infile and outfile are identical when overwrite=True.
        # (CAS-3096). If not, print warning message and exit.
        outformat = self.outform.upper()
        if (outformat == 'MS'): outformat = 'MS2'
        if self.overwrite and os.path.exists(self.project) \
           and (sdutil.get_abspath(self.project) == sdutil.get_abspath(self.infile)) \
           and (outformat != informat):
            msg = "The input and output data format must be identical when "
            msg += "their names are identical and overwrite=True. "
            msg += "%s and %s given for input and output, respectively." % (informat, outformat)
            raise Exception, msg

        # check restfreq
        self.rfset = (self.restfreq != '') and (self.restfreq != [])
        self.restore = self.rfset

        if self.mode.lower()[0] not in self.valid_modes:
            raise Exception, "Invalide mode, '%s'" % self.mode

        # check whether any flag operation is done or not
        self.anyflag = False
예제 #6
0
    def initialize_scan(self):
        sorg = sd.scantable(self.infile, average=False, antenna=self.antenna)

        if (abs(self.plotlevel) > 1):
            casalog.post("Initial Scantable:")
            sorg._summary()

        # Copy the original data (CAS-3987)
        if self.is_disk_storage \
           and (sdutil.get_abspath(self.project) != sdutil.get_abspath(self.infile)):
            self.scan = sorg.copy()
        else:
            self.scan = sorg

        # data selection
        #self.scan.set_selection(self.get_selector())
        selector = self.get_selector()
        if len(self.rasterrow) > 0:
            selector = self.select_by_raster(selector)
        self.scan.set_selection(selector)
예제 #7
0
    def initialize_scan(self):
        sorg = sd.scantable(self.infile,average=False,antenna=self.antenna)

        if ( abs(self.plotlevel) > 1 ):
            casalog.post( "Initial Scantable:" )
            sorg._summary()

        # Copy the original data (CAS-3987)
        if self.is_disk_storage \
           and (sdutil.get_abspath(self.project) != sdutil.get_abspath(self.infile)):
            self.scan = sorg.copy()
        else:
            self.scan = sorg

        # data selection
        #self.scan.set_selection(self.get_selector())
        selector = self.get_selector()
        if len(self.rasterrow) > 0:
            selector = self.select_by_raster(selector)
        self.scan.set_selection(selector)
예제 #8
0
 def save(self):
     if (len(self.outfile) > 0):
         if ( not os.path.exists(sdutil.get_abspath(self.outfile)) \
              or self.overwrite ):
             f = open(self.outfile, 'w')
             f.write(self.savestats)
             f.close()
         else:
             casalog.post(
                 'File ' + self.outfile +
                 ' already exists.\nStatistics results are not written into the file.',
                 priority='WARN')
예제 #9
0
    def save(self):
        self.scan.set_selection(None)
        #sdutil.save(self.scan, self.project, self.outform, self.overwrite)
        sdutil.assert_outfile_canoverwrite_or_nonexistent(self.project,
                                                          self.outform,
                                                          self.overwrite)
        outform_local = self.outform.upper()
        if outform_local == 'MS': outform_local = 'MS2'
        if outform_local not in ['ASAP','ASCII','MS2','SDFITS']:
            outform_local = 'ASAP'

        # SHOULD NOT remove infile if disk storage and infile==outfile
        outfilename = sdutil.get_abspath(self.project)
        if self.overwrite and os.path.exists(outfilename):
            if not self.is_disk_storage or \
                    (outfilename != sdutil.get_abspath(self.infile)):
                os.system('rm -rf %s' % outfilename)

        self.scan.save(self.project, outform_local, self.overwrite)

        if outform_local!='ASCII':
            casalog.post('Wrote output %s file %s'%(outform_local,self.project))
예제 #10
0
    def save(self):
        self.scan.set_selection(None)
        #sdutil.save(self.scan, self.project, self.outform, self.overwrite)
        sdutil.assert_outfile_canoverwrite_or_nonexistent(
            self.project, self.outform, self.overwrite)
        outform_local = self.outform.upper()
        if outform_local == 'MS': outform_local = 'MS2'
        if outform_local not in ['ASAP', 'ASCII', 'MS2', 'SDFITS']:
            outform_local = 'ASAP'

        # SHOULD NOT remove infile if disk storage and infile==outfile
        outfilename = sdutil.get_abspath(self.project)
        if self.overwrite and os.path.exists(outfilename):
            if not self.is_disk_storage or \
                    (outfilename != sdutil.get_abspath(self.infile)):
                os.system('rm -rf %s' % outfilename)

        self.scan.save(self.project, outform_local, self.overwrite)

        if outform_local != 'ASCII':
            casalog.post('Wrote output %s file %s' %
                         (outform_local, self.project))
예제 #11
0
    def __store_fit(self):
        outf = file(sdutil.get_abspath(self.outfile), 'w')

        #header
        header = "#%-4s %-4s %-4s %-12s " % ("SCAN", "IF", "POL", "Function")
        numparam = 3  # gaussian fitting is assumed (max, center, fwhm)
        for i in xrange(numparam):
            header += '%-12s ' % ('P%d' % (i))
        outf.write(header + '\n')

        #data
        for i in xrange(len(self.fitparams)):
            dattmp=" %-4d %-4d %-4d " \
                    %(self.scan.getscan(i), self.scan.getif(i), self.scan.getpol(i))
            for j in xrange(len(self.fitparams[i])):
                if (self.fitparams[i][j][0] != 0.0):
                    datstr = dattmp + '%-12s ' % ('%s%d' % (self.fitfunc, j))
                    for k in xrange(len(self.fitparams[i][j])):
                        datstr += "%3.8f " % (self.fitparams[i][j][k])
                    outf.write(datstr + '\n')

        outf.close()
예제 #12
0
    def __store_fit(self):
        outf = file(sdutil.get_abspath(self.outfile),'w')

        #header 
        header="#%-4s %-4s %-4s %-12s " %("SCAN", "IF", "POL", "Function")
        numparam=3     # gaussian fitting is assumed (max, center, fwhm)
        for i in xrange(numparam):
            header+='%-12s '%('P%d'%(i))
        outf.write(header+'\n')

        #data
        for i in xrange(len(self.fitparams)):
            dattmp=" %-4d %-4d %-4d " \
                    %(self.scan.getscan(i), self.scan.getif(i), self.scan.getpol(i))
            for j in xrange(len(self.fitparams[i])):
                if ( self.fitparams[i][j][0]!=0.0): 
                    datstr=dattmp+'%-12s '%('%s%d'%(self.fitfunc,j))
                    for k in xrange(len(self.fitparams[i][j])):
                        datstr+="%3.8f " %(self.fitparams[i][j][k])
                    outf.write(datstr+'\n')
                        
        outf.close()
예제 #13
0
 def __init__(self, **kwargs):
     super(sdflagmanager_worker,self).__init__(**kwargs)
     self.infile_abs = sdutil.get_abspath(self.infile)
예제 #14
0
 def __init__(self, **kwargs):
     super(sdflagmanager_worker, self).__init__(**kwargs)
     self.infile_abs = sdutil.get_abspath(self.infile)