本文整理汇总了Python中mantid.simpleapi.AnalysisDataService.doesExist方法的典型用法代码示例。如果您正苦于以下问题:Python AnalysisDataService.doesExist方法的具体用法?Python AnalysisDataService.doesExist怎么用?Python AnalysisDataService.doesExist使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mantid.simpleapi.AnalysisDataService
的用法示例。
在下文中一共展示了AnalysisDataService.doesExist方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _plotTimeCounts
# 需要导入模块: from mantid.simpleapi import AnalysisDataService [as 别名]
# 或者: from mantid.simpleapi.AnalysisDataService import doesExist [as 别名]
def _plotTimeCounts(self, wksp):
""" Plot time/counts
"""
import datetime
# Rebin events by pulse time
try:
# Get run start and run stop
if wksp.getRun().hasProperty("run_start"):
runstart = wksp.getRun().getProperty("run_start").value
else:
runstart = wksp.getRun().getProperty("proton_charge").times[0]
runstop = wksp.getRun().getProperty("proton_charge").times[-1]
runstart = str(runstart).split(".")[0].strip()
runstop = str(runstop).split(".")[0].strip()
t0 = datetime.datetime.strptime(runstart, "%Y-%m-%dT%H:%M:%S")
tf = datetime.datetime.strptime(runstop, "%Y-%m-%dT%H:%M:%S")
# Calcualte
dt = tf-t0
timeduration = dt.days*3600*24 + dt.seconds
timeres = float(timeduration)/MAXTIMEBINSIZE
if timeres < 1.0:
timeres = 1.0
sumwsname = "_Summed_%s"%(str(wksp))
if AnalysisDataService.doesExist(sumwsname) is False:
sumws = api.SumSpectra(InputWorkspace=wksp, OutputWorkspace=sumwsname)
sumws = api.RebinByPulseTimes(InputWorkspace=sumws, OutputWorkspace = sumwsname,
Params="%f"%(timeres))
sumws = api.ConvertToPointData(InputWorkspace=sumws, OutputWorkspace=sumwsname)
else:
sumws = AnalysisDataService.retrieve(sumwsname)
except RuntimeError as e:
return str(e)
vecx = sumws.readX(0)
vecy = sumws.readY(0)
xmin = min(vecx)
xmax = max(vecx)
ymin = min(vecy)
ymax = max(vecy)
# Reset graph
self.ui.mainplot.set_xlim(xmin, xmax)
self.ui.mainplot.set_ylim(ymin, ymax)
self.ui.mainplot.set_xlabel('Time (seconds)', fontsize=13)
self.ui.mainplot.set_ylabel('Counts', fontsize=13)
# Set up main line
setp(self.mainline, xdata=vecx, ydata=vecy)
# Reset slide
newslidery = [min(vecy), max(vecy)]
newleftx = xmin + (xmax-xmin)*self._leftSlideValue*0.01
setp(self.leftslideline, xdata=[newleftx, newleftx], ydata=newslidery)
newrightx = xmin + (xmax-xmin)*self._rightSlideValue*0.01
setp(self.rightslideline, xdata=[newrightx, newrightx], ydata=newslidery)
self.ui.graphicsView.draw()
return