本文整理汇总了Python中taskinit.casalog.post函数的典型用法代码示例。如果您正苦于以下问题:Python post函数的具体用法?Python post怎么用?Python post使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了post函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: execute
def execute(self):
# CAS-5410 Use private tools inside task scripts
qa = qatool()
scan = self.worker.scan
if self.kernel == 'regrid':
if not qa.isquantity(self.chanwidth):
errstr = "Invalid quantity chanwidth "+self.chanwidth
raise Exception, errstr
qchw = qa.quantity(self.chanwidth)
oldUnit = scan.get_unit()
if qchw['unit'] in ("", "channel", "pixel"):
scan.set_unit("channel")
elif qa.compare(self.chanwidth,"1Hz") or \
qa.compare(self.chanwidth,"1m/s"):
scan.set_unit(qchw['unit'])
else:
errstr = "Invalid dimension of quantity chanwidth "+self.chanwidth
raise Exception, errstr
casalog.post( "Regridding spectra in width "+self.chanwidth )
scan.regrid_channel(width=qchw['value'],plot=self.verify,insitu=True)
scan.set_unit(oldUnit)
else:
casalog.post( "Smoothing spectra with kernel "+self.kernel )
scan.smooth(kernel=self.kernel,width=self.kwidth,plot=self.verify,insitu=True)
示例2: execute
def execute(self):
# set various attributes to self.scan
self.set_to_scan()
#WORKAROUND for new tasks (in future this should be done in sdutil)
if not self.timeaverage: self.scanaverage = False
# Average data if necessary
self.scan = sdutil.doaverage(self.scan, self.scanaverage, self.timeaverage, self.tweight, self.polaverage, self.pweight)
# Reload plotter if necessary
sd.plotter._assert_plotter(action="reload")
# Set subplot layout
if self.subplot > 10:
row = int(self.subplot/10)
col = (self.subplot % 10)
sd.plotter.set_layout(rows=row,cols=col,refresh=False)
else:
if self.subplot > -1:
casalog.post(("Invalid subplot value, %d, is ignored. It should be in between 11 and 99." % self.subplot),priority="WARN")
sd.plotter.set_layout(refresh=False)
# Set subplot margins
if self.margin != sd.plotter._margins:
sd.plotter.set_margin(margin=self.margin,refresh=False)
# Actual plotting
getattr(self,'plot_%s'%(self.plottype))()
示例3: __set_mask
def __set_mask(self):
self.msk = None
if self.interactive:
# Interactive masking
self.msk = sdutil.interactive_mask(self.scan,
self.masklist,
False,
purpose='to calculate statistics')
msks = self.scan.get_masklist(self.msk)
if len(msks) < 1:
raise Exception, 'No channel is selected. Exit without calculation.'
lbl=self.scan.get_unit()
casalog.post( 'final mask list ('+lbl+') = '+str(msks) )
del msks
# set the mask region
elif ( len(self.masklist) > 0 and self.masklist!=[[]]):
self.msk=self.scan.create_mask(self.masklist,invert=False)
msks=self.scan.get_masklist(self.msk)
if len(msks) < 1:
del self.msk, msks
raise Exception, 'Selected mask lists are out of range. Exit without calculation.'
del msks
else:
# Full region
casalog.post( 'Using full region' )
示例4: __init__
def __init__(self, nh, nv, brightnessunit, direction_label, direction_reference,
spectral_label, spectral_unit, ticksize, title='',
separatepanel=True,
showaxislabel=False, showtick=False, showticklabel=False,
figsize=None,
clearpanel=True):
self.nh = nh
self.nv = nv
self.ticksize = ticksize
self.brightnessunit = brightnessunit
self.numeric_formatter = pl.FormatStrFormatter('%.2f')
self.direction_label = direction_label
self.direction_reference = direction_reference
self.separatepanel = separatepanel
self.spectral_label = spectral_label
self.spectral_unit = spectral_unit
self.showaxislabel = showaxislabel
self.showtick = showtick
self.showticklabel = showticklabel
self.title = title
self.figsize = figsize
casalog.post('figsize={figsize}'.format(figsize=self.figsize), priority='DEBUG')
self._axes_spmap = None
# to resize matplotlib window to specified size
pl.figure(self.MATPLOTLIB_FIGURE_ID)
pl.close()
if self.figsize is None:
pl.figure(self.MATPLOTLIB_FIGURE_ID)
else:
pl.figure(self.MATPLOTLIB_FIGURE_ID, figsize=self.figsize)
if clearpanel:
pl.clf()
示例5: _set_linelist_interact
def _set_linelist_interact(self, scantab=None):
if scantab is None:
scantab = self.scan
# Interactive masking
new_mask = sdutil.init_interactive_mask(scantab,
self.maskline,
False)
self.defaultmask = sdutil.get_interactive_mask(new_mask,
purpose='to fit lines')
self.linelist=scantab.get_masklist(self.defaultmask)
self.nlines=len(self.linelist)
if self.nlines < 1:
msg='No channel is selected. Exit without fittinging.'
raise Exception(msg)
print '%d region(s) is selected as a linemask' % self.nlines
print 'The final mask list ('+scantab._getabcissalabel()+') ='+str(self.linelist)
print 'Number of line(s) to fit: nfit =',self.nfit
ans=raw_input('Do you want to reassign nfit? [N/y]: ')
if (ans.upper() == 'Y'):
ans=input('Input nfit = ')
if type(ans) == list: self.nfit = ans
elif type(ans) == int: self.nfit = [ans]
else:
msg='Invalid definition of nfit. Setting nfit=[1] and proceed.'
casalog.post(msg, priority='WARN')
self.nfit = [1]
casalog.post('List of line number reassigned.\n nfit = '+str(self.nfit))
sdutil.finalize_interactive_mask(new_mask)
示例6: __calc_stats
def __calc_stats(self):
usr = get_user()
tmpfile = '/tmp/tmp_'+usr+'_casapy_asap_scantable_stats'
self.result = {}
# calculate regular statistics
statsname = ['max', 'min', 'max_abc', 'min_abc',
'sum', 'mean', 'median', 'rms',
'stddev']
for name in statsname:
v = self.scan.stats(name,self.msk,self.format_string, None, True)
self.result[name] = list(v) # if len(v) > 1 else v[0]
if sd.rcParams['verbose']:
self.savestats += get_text_from_file(tmpfile)
# calculate additional statistics (eqw and integrated intensity)
self.__calc_eqw_and_integf()
if sd.rcParams['verbose']:
# Print equivalent width
out = self.__get_statstext('eqw', self.abclbl, 'eqw')
self.savestats += out
# Print integrated flux
outp = self.__get_statstext('Integrated intensity', self.intlbl, 'totint')
self.savestats += outp
# to logger
casalog.post(out[:-2]+outp)
示例7: __antenna_summary
def __antenna_summary(self):
"""Print summary of antenna setup"""
if not self.is_antenna_set:
self.__notset_message()
return
casalog.post("diameter: %f m" % (self.antenna_diam_m))
casalog.post("blockage: %f m" % (self.antenna_block_m))
示例8: check_job
def check_job(self, jobId, verbose=True):
"""Check the status of a non-blocking job"""
jobId_list = list(jobId)
command_response_list = self.__command_client.get_command_response(jobId_list,block=False,verbose=verbose)
# Aggregate exceptions and completed jobIds
error_msg = ''
completed_jobs = []
for command_response in command_response_list:
if not command_response['successful']:
if len(error_msg) > 0: error_msg += "\n"
error_msg += "Exception executing command in server %s: %s" % (command_response['server'],
command_response['traceback'])
else:
completed_jobs.append(command_response['id'])
# Re-throw aggregated exception
if len(error_msg) > 0:
casalog.post(error_msg,"SEVERE","MPIInterfaceCore::check_job")
raise Exception(error_msg)
# Check that all jobs have been completed
completed = True
for jobId in jobId_list:
if jobId not in completed_jobs:
completed = False
break
# Return completion status
return completed
示例9: __initial_guess
def __initial_guess(self, scantab, dbw, numfit, comps, irow):
llist = self.linelist[irow] if self.fitmode == 'auto' \
else self.linelist
if len(llist) > 0:
# guesses: [maxlist, cenlist, fwhmlist]
guesses = [[],[],[]]
for x in llist:
x.sort()
casalog.post( "detected line: "+str(x) )
msk = scantab.create_mask(x, row=irow)
guess = self.__get_initial_guess(scantab,msk,x,dbw,irow)
for i in xrange(3):
guesses[i] = guesses[i] + [guess[i]]
else:
guess = self.__get_initial_guess(scantab,self.defaultmask,[],dbw,irow)
guesses = [[guess[i]] for i in xrange(3)]
# Guesses using max, cen, and fwhm=0.7*eqw
# NOTE: should there be user options here?
n = 0
for i in range(numfit):
# cannot guess for multiple comps yet
if ( comps[i] == 1 ):
# use guess
#getattr(self.fitter,'set_%s_parameters'%(self.fitfunc))(maxl[i], cenl[i], fwhm[i], component=n)
guess = (guesses[k][i] for k in xrange(3))
getattr(self.fitter,'set_%s_parameters'%(self.fitfunc))(*guess, component=n)
n += comps[i]
示例10: __sampling_summary
def __sampling_summary(self):
"""Print summary of sampling setup"""
if not self.is_sampling_set:
self.__notset_message()
return
casalog.post("sampling interval: %s arcsec" % str(self.sampling_arcsec))
casalog.post("position angle: %s" % (self.pa))
示例11: __load_contour
def __load_contour( self, vwr, panel, contour ):
## here we can assume we have a dictionary
## that specifies what needs to be done...
data = None
if not contour.has_key('file'):
return panel
if type(contour['file']) != str or not os.path.exists(contour['file']) or \
vwr.fileinfo(contour['file'])['type'] != 'image':
casalog.post( str(contour['file']) + " does not exist or is not an image", 'SEVERE')
raise Exception, contour['file'] + " does not exist or is not an image"
if panel is None:
panel = self.__panel(vwr)
data = vwr.load( contour['file'], 'contour', panel=panel )
if contour.has_key('levels'):
vwr.contourlevels( self.__checknumeric(contour['levels'], float, "contour levels", array_size=0), data=data )
if contour.has_key('unit'):
vwr.contourlevels( unitlevel=self.__checknumeric(contour['unit'], float, "contour unitlevel"), data=data )
if contour.has_key('base'):
vwr.contourlevels( baselevel=self.__checknumeric(contour['base'], float, "contour baselevel"), data=data )
try:
if contour.has_key('thickness'):
vwr.contourthickness( thickness=self.__checknumeric(contour['thickness'], float, "contour thickness"), data=data )
if contour.has_key('color'):
vwr.contourcolor( contour['color'], data=data )
except:
print "viewertool error: %s" % sys.exc_info()[1]
return panel
示例12: select
def select(self, rowid=None, rasterid=None):
if not ((rowid is None) ^ (rasterid is None)):
raise RuntimeError('one of rowid or rasterid must be specified')
if (rowid is not None) and (rowid >= self.nrow):
raise IndexError('row index %s is out of range (number of rows detected: %s)'%(rowid,self.nrow))
if (rasterid is not None) and (rasterid >= self.nraster):
raise IndexError('row index %s is out of range (number of rasters detected: %s)'%(rasterid,self.nraster))
with selection_manager(self.scantab, self.original_selection, types=0, ifs=self.spw, pols=self.pol) as s:
alltimes = numpy.array(map(lambda x: qa.quantity(x)['value'], s.get_time(prec=16)))
mean_interval = numpy.array(s.get_inttime()).mean()
self.margin = 0.1 * mean_interval
mjd_margin = self.margin / 86400.0
if rowid is not None:
times = alltimes[self.gaplist[rowid]:self.gaplist[rowid+1]]
else:
times = alltimes[self.gaplist_raster[rasterid]:self.gaplist_raster[rasterid+1]]
tmp_mjd_range = (times.min() - mjd_margin, times.max() + mjd_margin,)
tmp_mjd_range_nomargin = (times.min(), times.max(),)
casalog.post('time range: %s ~ %s'%(tmp_mjd_range_nomargin), priority='DEBUG')
if rowid is not None:
self.mjd_range = tmp_mjd_range
self.mjd_range_nomargin = tmp_mjd_range_nomargin
else:
self.mjd_range_raster = tmp_mjd_range
self.mjd_range_nomargin_raster = tmp_mjd_range_nomargin
示例13: __get_mapsize
def __get_mapsize(self):
if self.subplot < 11:
casalog.post("Setting default subplot layout (1x1).",priority="WARN")
self.subplot = 11
nx = (self.subplot % 10)
ny = int(self.subplot/10)
return (nx,ny)
示例14: plotprofilemap
def plotprofilemap(imagename=None, figfile=None, overwrite=None, transparent=None,
pol=None, spectralaxis=None, restfreq=None, plotrange=None, title=None,
linecolor=None, linestyle=None, linewidth=None,
separatepanel=None, plotmasked=None, maskedcolor=None,
showaxislabel=None, showtick=None, showticklabel=None,
figsize=None, numpanels=None):
casalog.origin('plotprofilemap')
try:
if len(figfile) > 0 and os.path.exists(figfile) and overwrite == False:
raise RuntimeError('overwrite is False and output file exists: \'%s\''%(figfile))
image = SpectralImage(imagename)
npol = len(image.stokes)
if pol < 0 or pol > npol - 1:
raise RuntimeError('pol {pol} is out of range (Stokes axis {stokes})'.format(pol=pol,stokes=image.stokes))
parsed_size = parse_figsize(figsize)
nx, ny = parse_numpanels(numpanels)
if (not isinstance(restfreq, str)) or len(restfreq) == 0:
restfreq = None
plot_profile_map(image, figfile, pol, spectralaxis, restfreq, title, linecolor, linestyle, linewidth,
separatepanel, plotmasked, maskedcolor,
showaxislabel, showtick, showticklabel, parsed_size,
nx, ny, transparent, plotrange)
except Exception, e:
casalog.post('Error: %s'%(str(e)), priority='SEVERE')
import traceback
casalog.post(traceback.format_exc(), priority='DEBUG')
raise e
示例15: __execute_imaging
def __execute_imaging(self):
#if pointingcolumn.upper()=="OFFSET":
# pointingcolumn="POINTING_OFFSET"
#print "pointingcolumn=",pointingcolumn
#print "Imaging...."
casalog.post( "pointingcolumn used: %s" % self.pointingcolumn )
casalog.post( "Imaging...." )
self.open_imager(self.infile)
self.imager.selectvis(spw=self.spw, baseline=self.antsel)
#self.imager.selectvis(field=0, spw=self.spw, baseline=self.antsel)
#self.imager.selectvis(vis=infile, field=0, spw=spw, baseline=antsel)
#self.imager.defineimage(nx=nx, ny=ny, cellx=cellx, celly=celly, phasecenter=phasecenter, spw=0, stokes=stokes, movingsource=ephemsrcname)
self.imager.defineimage(nx=self.nx, ny=self.ny, cellx=self.cellx, celly=self.celly, phasecenter=self.phasecenter, spw=self.spw, stokes=self.stokes, movingsource=self.ephemsrcname)
#self.imager.defineimage(nx=nx, ny=ny, cellx=cellx, celly=celly, phasecenter=phasecenter, spw=0, stokes=stokes, movingsource=ephemsrcname,restfreq=1.14e11)
self.imager.setoptions(ftmachine='sd', gridfunction=self.gridfunction)
#self.imager.setsdoptions(convsupport=5)
self.imager.setsdoptions(pointingcolumntouse=self.pointingcolumn, convsupport=-1, truncate=-1, gwidth=-1, jwidth=-1)
self.imager.makeimage(type='singledish-observed', image=self.outfile)
#self.imager.makeimage(type='singledish', image=self.outfile)
# create temporal weight image for masking
weightfile_temp = self.outfile+".weight."+str(time.time()).replace('.', '_')
self.imager.makeimage(type='coverage', image=weightfile_temp)
self.close_imager()
# Handle mask
my_ia = gentools(['ia'])[0]
my_ia.open(self.outfile)
my_ia.calcmask("'%s'>%f" % (weightfile_temp,0.0), asdefault=True)
my_ia.close()
shutil.rmtree(weightfile_temp)