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
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
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' )
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
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
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)
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)
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')
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))
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))
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()
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()
def __init__(self, **kwargs): super(sdflagmanager_worker,self).__init__(**kwargs) self.infile_abs = sdutil.get_abspath(self.infile)
def __init__(self, **kwargs): super(sdflagmanager_worker, self).__init__(**kwargs) self.infile_abs = sdutil.get_abspath(self.infile)