def plot_grid(self): refresh=False (nx,ny,cellx,celly,mapcenter) = self.__get_grid_parameters(True) #print "Gridding scantable: npix = (%d, %d), cell = (%s, %s), center = %s" % (nx, ny, cellx, celly, mapcenter) self.__dogrid(nx, ny, cellx, celly, mapcenter) # Now set fluxunit, specunit, frame, and doppler sdutil.set_fluxunit(self.scan, self.fluxunit, telescopeparam='fix') sdutil.set_spectral_unit(self.scan, self.specunit) sdutil.set_freqframe(self.scan, self.frame) sdutil.set_doppler(self.scan, self.doppler) if self.scan.nchan()==1: errmsg="Trying to plot the continuum/total power data in 'spectra' mode, please use other plottype options" raise Exception,errmsg # Smooth the spectrum (if desired) self.__dosmooth() sd.plotter.set_data(self.scan,refresh=refresh) # Set colormap, linestyles, and linewidth of plots self.__setup_plotter() # Need to specify center and spacing in the epoch and # unit of DIRECTION column (currently assuming J2000 and rad) # TODO: need checking epoch and unit of DIRECTION in scantable spacing = [] if cellx != '': spacing.append(cellx) if celly != '': spacing.append(celly) #sd.plotter.plotgrid(center=crad,spacing=spacing,rows=ny,cols=nx) sd.plotter.plotgrid(center=mapcenter,spacing=spacing,rows=ny,cols=nx) self.__print_header(asaplot=True)
def initialize_scan(self): # load the data without averaging sorg = sd.scantable(self.infile, average=False, antenna=self.antenna) # restorer self.restorer = sdutil.scantable_restore_factory( sorg, self.infile, self.fluxunit, sorg.get_unit(), self.frame, self.doppler, self.restfreq) # Select scan and field sorg.set_selection(self.get_selector(sorg)) # this is bit tricky # set fluxunit here instead of self.set_to_scan # and remove fluxunit attribute to disable additional # call of set_fluxunit in self.set_to_scan self.scan = sdutil.set_fluxunit(sorg, self.fluxunit, self.telescopeparam, False) self.fluxunit_saved = self.fluxunit del self.fluxunit if self.scan: # Restore flux unit in original table before deleting self.restorer.restore() del self.restorer self.restorer = None else: self.scan = sorg
def initialize_scan(self): # load the data without averaging sorg = sd.scantable(self.infile,average=False,antenna=self.antenna) # restorer self.restorer = sdutil.scantable_restore_factory(sorg, self.infile, self.fluxunit, sorg.get_unit(), self.frame, self.doppler, self.restfreq) # Select scan and field sorg.set_selection(self.get_selector(sorg)) # this is bit tricky # set fluxunit here instead of self.set_to_scan # and remove fluxunit attribute to disable additional # call of set_fluxunit in self.set_to_scan self.scan = sdutil.set_fluxunit(sorg, self.fluxunit, self.telescopeparam, False) self.fluxunit_saved = self.fluxunit del self.fluxunit if self.scan: # Restore flux unit in original table before deleting self.restorer.restore() del self.restorer self.restorer = None else: self.scan = sorg
def plot_grid(self): refresh = False (nx, ny, cellx, celly, mapcenter) = self.__get_grid_parameters(True) #print "Gridding scantable: npix = (%d, %d), cell = (%s, %s), center = %s" % (nx, ny, cellx, celly, mapcenter) self.__dogrid(nx, ny, cellx, celly, mapcenter) # Now set fluxunit, specunit, frame, and doppler sdutil.set_fluxunit(self.scan, self.fluxunit, telescopeparam='fix') sdutil.set_spectral_unit(self.scan, self.specunit) sdutil.set_freqframe(self.scan, self.frame) sdutil.set_doppler(self.scan, self.doppler) if self.scan.nchan() == 1: errmsg = "Trying to plot the continuum/total power data in 'spectra' mode, please use other plottype options" raise Exception, errmsg # Smooth the spectrum (if desired) self.__dosmooth() sd.plotter.set_data(self.scan, refresh=refresh) # Set colormap, linestyles, and linewidth of plots self.__setup_plotter() # Need to specify center and spacing in the epoch and # unit of DIRECTION column (currently assuming J2000 and rad) # TODO: need checking epoch and unit of DIRECTION in scantable spacing = [] if cellx != '': spacing.append(cellx) if celly != '': spacing.append(celly) #sd.plotter.plotgrid(center=crad,spacing=spacing,rows=ny,cols=nx) sd.plotter.plotgrid(center=mapcenter, spacing=spacing, rows=ny, cols=nx) self.__print_header(asaplot=True)
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)
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)