• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python simpleapi.AnalysisDataService类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中mantid.simpleapi.AnalysisDataService的典型用法代码示例。如果您正苦于以下问题:Python AnalysisDataService类的具体用法?Python AnalysisDataService怎么用?Python AnalysisDataService使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了AnalysisDataService类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: parseSpiceData

    def parseSpiceData(self, expno, scanno, detefftablews=None):
        """ Load SPICE data to MDWorkspaces from raw table workspace
        """
        # Get reduction manager
        try:
            wsmanager = self._myWorkspaceDict[ (int(expno), int(scanno) )]
        except KeyError:
            raise NotImplementedError("Exp %d Scan %d has not been loaded yet." % (int(expno),int(scanno)))

        # Convert to MDWorkspace
        tablews = wsmanager.getRawSpiceTable()
        infows  = wsmanager.getRawInfoMatrixWS()

        basewsname = tablews.name().split('_RawTable')[0]
        datamdwsname = basewsname + "_DataMD"
        monitorwsname = basewsname + "_MonitorMD"
        api.ConvertSpiceDataToRealSpace(InputWorkspace=tablews,
                                        RunInfoWorkspace=infows,
                                        OutputWorkspace=datamdwsname,
                                        OutputMonitorWorkspace=monitorwsname,
                                        DetectorEfficiencyTableWorkspace=detefftablews)

        datamdws = AnalysisDataService.retrieve(datamdwsname)
        monitormdws = AnalysisDataService.retrieve(monitorwsname)

        if datamdws is None or monitormdws is None:
            raise NotImplementedError("Failed to convert SPICE data to MDEventWorkspaces \
                    for experiment %d and scan %d." % (expno, scanno))

        # Manager:
        wsmanager.setupMDWrokspaces(datamdws, monitormdws)
        self._myWorkspaceDict[(expno, scanno)] = wsmanager

        return True
开发者ID:mducle,项目名称:mantid,代码行数:34,代码来源:HfirPDReductionControl.py


示例2: loadSpicePDData

    def loadSpicePDData(self, expno, scanno, datafilename):
        """ Load SPICE powder diffraction data to MDEventsWorkspaces
        """
        # Create base workspace name
        try:
            basewsname = os.path.basename(datafilename).split(".")[0]
        except AttributeError as e:
            raise NotImplementedError("Unable to parse data file name due to %s." % (str(e)))

        # load SPICE
        tablewsname = basewsname + "_RawTable"
        infowsname  = basewsname + "ExpInfo"
        api.LoadSpiceAscii(Filename=datafilename,
                           OutputWorkspace=tablewsname, RunInfoWorkspace=infowsname)

        tablews = AnalysisDataService.retrieve(tablewsname)
        infows  = AnalysisDataService.retrieve(infowsname)
        if tablews is None or infows is None:
            raise NotImplementedError('Unable to retrieve either spice table workspace %s or log workspace %s' % (
                tablewsname, infowsname))

        # Create a reduction manager and add workspaces to it
        wsmanager = PDRManager(expno, scanno)
        wsmanager.set_raw_workspaces(tablews, infows)
        self._myWorkspaceDict[(int(expno), int(scanno))] = wsmanager

        return
开发者ID:mducle,项目名称:mantid,代码行数:27,代码来源:HfirPDReductionControl.py


示例3: scanEventWorkspaces

    def scanEventWorkspaces(self):
        """
        """
        wsnames = AnalysisDataService.getObjectNames()

        eventwsnames = []
        for wsname in wsnames:
            wksp = AnalysisDataService.retrieve(wsname)
            if wksp.__class__.__name__.count("Event") == 1:
                eventwsnames.append(wsname)
        # ENDFOR

        if len(eventwsnames) > 0:
            self.ui.comboBox.clear()
            self.ui.comboBox.addItems(eventwsnames)
开发者ID:mantidproject,项目名称:mantid,代码行数:15,代码来源:eventFilterGUI.py


示例4: _searchTableWorkspaces

    def _searchTableWorkspaces(self):
        """ Search table workspaces and add to 'comboBox_corrWS'
        """
        wsnames = AnalysisDataService.getObjectNames()

        tablewsnames = []
        for wsname in wsnames:
            wksp = AnalysisDataService.retrieve(wsname)
            if isinstance(wksp, mantid.api.ITableWorkspace):
                tablewsnames.append(wsname)
        # ENDFOR

        self.ui.comboBox_corrWS.clear()
        if len(tablewsnames) > 0:
            self.ui.comboBox_corrWS.addItems(tablewsnames)
开发者ID:mantidproject,项目名称:mantid,代码行数:15,代码来源:eventFilterGUI.py


示例5: getVectorProcessVanToPlot

    def getVectorProcessVanToPlot(self, exp, scan, tempdata=False):
        """ Get vec x and y for the processed vanadium spectrum
        """
        # get on hold of processed vanadium data workspace
        wsmanager = self.getWorkspace(exp, scan, raiseexception=True)

        if tempdata is True:
            procVanWs = wsmanager.getProcessedVanadiumWSTemp()
        else:
            procVanWs = wsmanager.getProcessedVanadiumWS()
            #procVanWs = wsmanager._processedVanWS

        if procVanWs is None:
            raise NotImplementedError("Exp %d Scan %d does not have processed vanadium workspace." % (exp, scan))

        # convert to point data if necessary
        if len(procVanWs.readX(0)) != len(procVanWs.readY(0)):
            wsname = procVanWs.name() + "_pd"
            api.ConvertToPointData(InputWorkspace=procVanWs, OutputWorkspace=wsname)
            outws = AnalysisDataService.retrieve(wsname)
        else:
            outws = procVanWs

        # get vectors
        return outws.readX(0), outws.readY(0)
开发者ID:mducle,项目名称:mantid,代码行数:25,代码来源:HfirPDReductionControl.py


示例6: reduceSpicePDData

    def reduceSpicePDData(self, exp, scan, unit, xmin, xmax, binsize, wavelength=None, excludeddetlist=None,scalefactor=None):
        """ Reduce SPICE powder diffraction data.
        Return - Boolean as reduction is successful or not
        """
        # Default
        if excludeddetlist is None:
            excludeddetlist = None

        # Get reduction manager
        try:
            wsmanager = self._myWorkspaceDict[(int(exp), int(scan))]
        except KeyError:
            raise NotImplementedError("SPICE data for Exp %d Scan %d has not been loaded." % (
                int(exp), int(scan)))

        datamdws = wsmanager.datamdws
        monitormdws = wsmanager.monitormdws

        # binning from MD to single spectrum ws
        # set up binning parameters
        if xmin is None or xmax is None:
            binpar = "%.7f" % (binsize)
        else:
            binpar = "%.7f, %.7f, %.7f" % (xmin, binsize, xmax)

        # scale-factor
        if scalefactor is None:
            scalefactor = 1.
        else:
            scalefactor = float(scalefactor)

        basewsname = datamdws.name().split("_DataMD")[0]
        outwsname = basewsname + "_Reduced"
        print "[DB]", numpy.array(excludeddetlist)
        api.ConvertCWPDMDToSpectra(InputWorkspace=datamdws,
                InputMonitorWorkspace=monitormdws,
                OutputWorkspace=outwsname,
                BinningParams=binpar,
                UnitOutput = unit,
                NeutronWaveLength=wavelength,
                ExcludedDetectorIDs=numpy.array(excludeddetlist),
                ScaleFactor=scalefactor)

        print "[DB] Reduction is finished.  Data is in workspace %s. " % (outwsname)

        # Set up class variable for min/max and
        outws = AnalysisDataService.retrieve(outwsname)
        if outws is None:
            raise NotImplementedError("Failed to bin the MDEventWorkspaces to MatrixWorkspace.")

        # Manager:
        wsmanager = PDRManager(exp, scan)
        wsmanager.setup(datamdws, monitormdws, outws, unit, binsize)
        wsmanager.setWavelength(wavelength)

        self._myWorkspaceDict[(exp, scan)] = wsmanager

        return True
开发者ID:nimgould,项目名称:mantid,代码行数:58,代码来源:HfirPDReductionControl.py


示例7: use_existWS

    def use_existWS(self):
        """ Set up workspace to an existing one
        """
        wsname = str(self.ui.comboBox.currentText())

        try:
            dataws = AnalysisDataService.retrieve(wsname)
            self._importDataWorkspace(dataws)
        except KeyError:
            pass

        # Reset GUI
        self._resetGUI(resetfilerun=True)
开发者ID:mantidproject,项目名称:mantid,代码行数:13,代码来源:eventFilterGUI.py


示例8: getMergedVector

    def getMergedVector(self, mkey):
        """ Get vector X and Y from merged scans
        """
        if self._myMergedWSDict.has_key(mkey) is True:
            wksp = self._myMergedWSDict[mkey]

            # convert to point data if necessary
            if len(wksp.readX(0)) != len(wksp.readY(0)):
                wsname = wksp.name() + "_pd"
                api.ConvertToPointData(InputWorkspace=wksp, OutputWorkspace=wsname)
                wksp = AnalysisDataService.retrieve(wsname)

            vecx = wksp.readX(0)
            vecy = wksp.readY(0)
        else:
            raise NotImplementedError("No merged workspace for key = %s." % (str(mkey)))

        return (vecx, vecy)
开发者ID:mducle,项目名称:mantid,代码行数:18,代码来源:HfirPDReductionControl.py


示例9: getVectorToPlot

    def getVectorToPlot(self, exp, scan):
        """ Get vec x and vec y of the reduced workspace to plot
        """
        # get on hold of reduced workspace
        wsmanager = self.getWorkspace(exp, scan, raiseexception=True)
        reducedws = wsmanager.reducedws
        if reducedws is None:
            raise NotImplementedError("Exp %d Scan %d does not have reduced workspace." % (exp, scan))

        # convert to point data if necessary
        if len(reducedws.readX(0)) != len(reducedws.readY(0)):
            wsname = reducedws.name() + "_pd"
            api.ConvertToPointData(InputWorkspace=reducedws, OutputWorkspace=wsname)
            outws = AnalysisDataService.retrieve(wsname)
        else:
            outws = reducedws

        # get vectors
        return outws.readX(0), outws.readY(0)
开发者ID:mducle,项目名称:mantid,代码行数:19,代码来源:HfirPDReductionControl.py


示例10: _plotTimeCounts

    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
开发者ID:rosswhitfield,项目名称:mantid,代码行数:68,代码来源:eventFilterGUI.py


示例11: mergeReduceSpiceData

    def mergeReduceSpiceData(self, expno, scannolist, unit, xmin, xmax, binsize):
        """ Merge and reduce SPICE data files
        Arguements:
         - expscanfilelist: list of 3 tuples: expnumber, scannumber and file name
        """
        # Collect data MD workspaces and monitor MD workspaces
        datamdwslist = []
        monitormdwslist = []
        self._lastWkspToMerge = []

        print "[Checkpoint 0] Scans = ", str(scannolist)
        for scanno in sorted(scannolist):
            try:
                wsmanager = self.getWorkspace(expno, scanno, True)
                datamdwslist.append(wsmanager.datamdws)
                monitormdwslist.append(wsmanager.monitormdws)
                self._lastWkspToMerge.append(wsmanager)
            except KeyError as ne:
                print '[Error] Unable to retrieve MDWorkspaces for Exp %d Scan %d due to %s.' % (
                    expno, scanno, str(ne))
                scannolist.remove(scanno)
        # ENDFOR

        print "[Checkpoing 1] Scans = ", str(scannolist)

        # Merge and binning
        if len(datamdwslist) > 1:
            mg_datamdws = datamdwslist[0] +  datamdwslist[1]
            mg_monitormdws = monitormdwslist[0] + monitormdwslist[1]
        else:
            mg_datamdws = datamdwslist[0]
            mg_monitormdws = monitormdwslist[0]
        for iw in xrange(2, len(datamdwslist)):
            mg_datamdws += datamdwslist[iw]
            mg_monitormdws += monitormdwslist[iw]

        # Set up binning parameters
        if xmin is None or xmax is None:
            binpar = "%.7f" % (binsize)
        else:
            binpar = "%.7f, %.7f, %.7f" % (xmin, binsize, xmax)

        # set up output workspace's name
        scannolist = sorted(scannolist)
        outwsname = "Merged_Exp%d_Scan%s_%s" % (expno, scannolist[0], scannolist[-1])

        # Merge
        wavelength = self.getWavelength(expno, scannolist[0])
        api.ConvertCWPDMDToSpectra(InputWorkspace=mg_datamdws,
                                   InputMonitorWorkspace=mg_monitormdws,
                                   OutputWorkspace=outwsname,
                                   BinningParams=binpar,
                                   UnitOutput=unit,
                                   NeutronWaveLength=wavelength)
        moutws = AnalysisDataService.retrieve(outwsname)
        if moutws is None:
            raise NotImplementedError("Merge failed.")

        key = (expno, str(scannolist))
        self._myMergedWSDict[key] = moutws

        return key
开发者ID:mducle,项目名称:mantid,代码行数:62,代码来源:HfirPDReductionControl.py



注:本文中的mantid.simpleapi.AnalysisDataService类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python simpleapi.CreateWorkspace类代码示例发布时间:2022-05-27
下一篇:
Python logger.notice函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap