當前位置: 首頁>>代碼示例>>Python>>正文


Python Load.getRun方法代碼示例

本文整理匯總了Python中mantid.simpleapi.Load.getRun方法的典型用法代碼示例。如果您正苦於以下問題:Python Load.getRun方法的具體用法?Python Load.getRun怎麽用?Python Load.getRun使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在mantid.simpleapi.Load的用法示例。


在下文中一共展示了Load.getRun方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: _run_number_changed

# 需要導入模塊: from mantid.simpleapi import Load [as 別名]
# 或者: from mantid.simpleapi.Load import getRun [as 別名]
    def _run_number_changed(self):
        """ Handling event if run number is changed... If it is a valid run number,
        the load the meta data
        """

        # 1. Form the file
        newrunnumberstr = self._content.run_number_edit.text()
        instrument = self._instrument_name
        eventnxsname = "%s_%s_event.nxs" % (instrument, newrunnumberstr)
        msg = str("Load event nexus file %s" % (eventnxsname))
        self._content.info_text_browser.setText(msg)

        # 2. Load file
        metawsname = "%s_%s_meta" % (instrument, newrunnumberstr)
        try:
            metaws = Load(Filename=str(eventnxsname), OutputWorkspace=str(metawsname), MetaDataOnly=True)
        except ValueError:
            metaws = None

        # 3. Update the log name combo box
        if metaws is None:
            self._content.info_text_browser.setText(
                str("Error! Failed to load data file %s.  Current working directory is %s. " % (eventnxsname, os.getcwd())))
        else:
            self._metaws = metaws

            # a) Clear
            self._content.log_name_combo.clear()

            # b) Get properties
            wsrun = metaws.getRun()
            ps = wsrun.getProperties()
            properties = []
            for p in ps:
                if p.__class__.__name__ == "FloatTimeSeriesProperty":
                    if p.size() > 1:
                        properties.append(p.name)
                        Logger('FilterSetupWidget').information('{}[{}]'.format(p.name, p.size()))
            # ENDFOR p
            properties = sorted(properties)

            # c) Add
            for p in properties:
                self._content.log_name_combo.addItem(p)
開發者ID:mantidproject,項目名稱:mantid,代碼行數:46,代碼來源:diffraction_filter_setup.py

示例2: reduceOneKeepingEvents

# 需要導入模塊: from mantid.simpleapi import Load [as 別名]
# 或者: from mantid.simpleapi.Load import getRun [as 別名]
def reduceOneKeepingEvents(nxsfile, angle, eiguess, eaxis, outfile, t0guess=0.):
    """reduce nxs from one angle of a single crystal scan, keeping events
    (only do tof->E conversion)

    nxsfile: input path
    angle: psi in degrees
    eiguess: Ei in meV
    eaxis: Emin, Emax, dE
    outfile: output path
    """
    from mantid.simpleapi import DgsReduction, SofQW3, SaveNexus, SaveNXSPE, LoadInstrument, Load, MoveInstrumentComponent, AddSampleLog
    outfile = os.path.abspath(outfile)
    print "* working on reducing %s to %s" % (nxsfile, outfile)
    # load workspace from input nexus file
    workspace = Load(nxsfile)

    # workspace name have to be unique
    unique_name = os.path.dirname(nxsfile).split('/')[-1]
    wsname = 'reduced-%s' % unique_name

    # Ei
    if eiguess == 0.:
        # If user does not supply Ei, we try to get it from the samplelog,
        # because mcvine-generated SEQUOIA data files are mantid-processed nexus file
        # with sample logs of Ei and t0.
        # If we don't have them from sample logs, we just set Ei and T0 to None
        run = workspace.getRun()
        UseIncidentEnergyGuess = False
        try:
            Ei = run.getLogData('mcvine-Ei').value
            UseIncidentEnergyGuess = True
        except:
            Ei = None
        try:
            T0 = run.getLogData('mcvine-t0').value
        except:
            T0 = None
    else:
        # user specified Ei, just use that
        Ei = eiguess
        T0 = t0guess
        UseIncidentEnergyGuess = True
    # keep events (need to then run RebinToWorkspace and ConvertToDistribution)
    Emin, Emax, dE = eaxis
    eaxis = '%s,%s,%s' % (Emin,dE, Emax)
    DgsReduction(
        SampleInputWorkspace = workspace,
        IncidentEnergyGuess = Ei,
        TimeZeroGuess = T0,
        UseIncidentEnergyGuess=UseIncidentEnergyGuess,
        OutputWorkspace=wsname,
        SofPhiEIsDistribution='0',
        EnergyTransferRange = eaxis,
        )

    AddSampleLog(Workspace=wsname,LogName="psi",LogText=str(angle),LogType="Number")
    SaveNexus(
        InputWorkspace=wsname,
        Filename = outfile,
        Title = 'reduced',
        )
    return
開發者ID:mcvine,項目名稱:workflow,代碼行數:64,代碼來源:reduction.py


注:本文中的mantid.simpleapi.Load.getRun方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。