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

Python find_data.find_data函数代码示例

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

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



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

示例1: SensitivityCorrection

def SensitivityCorrection(
        flood_data,
        min_sensitivity=0.5,
        max_sensitivity=1.5,
        dark_current=None,
        use_sample_dc=False):
    flood_data = find_data(
        flood_data,
        instrument=ReductionSingleton().get_instrument())
    if dark_current is not None:
        dark_current = find_data(
            dark_current,
            instrument=ReductionSingleton().get_instrument())

    ReductionSingleton().reduction_properties["SensitivityFile"] = flood_data
    ReductionSingleton().reduction_properties[
        "MinEfficiency"] = min_sensitivity
    ReductionSingleton().reduction_properties[
        "MaxEfficiency"] = max_sensitivity
    if dark_current is not None:
        ReductionSingleton().reduction_properties[
            "SensitivityDarkCurrentFile"] = dark_current
    elif "SensitivityDarkCurrentFile" in ReductionSingleton().reduction_properties:
        del ReductionSingleton().reduction_properties[
            "SensitivityDarkCurrentFile"]
    if "SensitivityBeamCenterX" in ReductionSingleton().reduction_properties:
        del ReductionSingleton().reduction_properties["SensitivityBeamCenterX"]
    if "SensitivityBeamCenterY" in ReductionSingleton().reduction_properties:
        del ReductionSingleton().reduction_properties["SensitivityBeamCenterY"]
    ReductionSingleton().reduction_properties["UseDefaultDC"] = use_sample_dc
开发者ID:mantidproject,项目名称:mantid,代码行数:30,代码来源:hfir_command_interface.py


示例2: Background

def Background(datafile):
    if isinstance(datafile, list):
        datafile = ','.join(datafile)
    find_data(
        datafile,
        instrument=ReductionSingleton().get_instrument(),
        allow_multiple=True)
    ReductionSingleton().reduction_properties["BackgroundFiles"] = datafile
开发者ID:mantidproject,项目名称:mantid,代码行数:8,代码来源:hfir_command_interface.py


示例3: DirectBeamCenter

def DirectBeamCenter(datafile):
    datafile = find_data(
        datafile,
        instrument=ReductionSingleton().get_instrument())
    ReductionSingleton().reduction_properties[
        "BeamCenterMethod"] = "DirectBeam"
    ReductionSingleton().reduction_properties["BeamCenterFile"] = datafile
开发者ID:mantidproject,项目名称:mantid,代码行数:7,代码来源:hfir_command_interface.py


示例4: _multiple_load

 def _multiple_load(self, data_file, workspace, property_manager, property_manager_name):
     instrument = ''
     if property_manager.existsProperty('InstrumentName'):
         property_manager.existsProperty('InstrumentName')
         instrument = property_manager.getProperty('InstrumentName').value
     else:
         property_manager.existsProperty('InstrumentName')
     output_str = ''
     if type(data_file) == str:
         if AnalysisDataService.doesExist(data_file):
             data_file = [data_file]
         else:
             data_file = find_data(data_file, instrument=instrument, allow_multiple=True)
     if type(data_file) == list:
         for i in range(len(data_file)):
             if i == 0:
                 output_str += self._load_data(data_file[i], workspace, property_manager, property_manager_name)
                 continue
             output_str += self._load_data(data_file[i], '__tmp_wksp', property_manager, property_manager_name)
             api.Plus(LHSWorkspace=workspace, RHSWorkspace='__tmp_wksp', OutputWorkspace=workspace)
         if AnalysisDataService.doesExist('__tmp_wksp'):
             AnalysisDataService.remove('__tmp_wksp')
     else:
         output_str += 'Loaded %s\n' % data_file
         output_str += self._load_data(data_file, workspace, property_manager, property_manager_name)
     return output_str
开发者ID:jkrueger1,项目名称:mantid,代码行数:26,代码来源:SANSReduction.py


示例5: _multiple_load

    def _multiple_load(self, data_file, workspace, 
                       property_manager, property_manager_name):
        # Check whether we have a list of files that need merging
        #   Make sure we process a list of files written as a string
        def _load_data(filename, output_ws):
            if not property_manager.existsProperty("LoadAlgorithm"):
                raise RuntimeError, "SANS reduction not set up properly: missing load algorithm"
            p=property_manager.getProperty("LoadAlgorithm")
            alg=Algorithm.fromString(p.valueAsStr)
            alg.setProperty("Filename", filename)
            alg.setProperty("OutputWorkspace", output_ws)
            if alg.existsProperty("ReductionProperties"):
                alg.setProperty("ReductionProperties", property_manager_name)
            alg.execute()
            msg = "Loaded %s\n" % filename
            if alg.existsProperty("OutputMessage"):
                msg = alg.getProperty("OutputMessage").value
            return msg
            
        # Get instrument to use with FileFinder
        instrument = ''
        if property_manager.existsProperty("InstrumentName"):
            instrument = property_manager.getProperty("InstrumentName").value

        output_str = ''
        if type(data_file)==str:
            data_file = find_data(data_file, instrument=instrument, allow_multiple=True)
        if type(data_file)==list:
            monitor = 0.0
            timer = 0.0 
            for i in range(len(data_file)):
                output_str += "Loaded %s\n" % data_file[i]
                if i==0:
                    output_str += _load_data(data_file[i], workspace)
                else:
                    output_str += _load_data(data_file[i], '__tmp_wksp')
                    api.Plus(LHSWorkspace=workspace,
                         RHSWorkspace='__tmp_wksp',
                         OutputWorkspace=workspace)
                    # Get the monitor and timer values
                    ws = AnalysisDataService.retrieve('__tmp_wksp')
                    monitor += ws.getRun().getProperty("monitor").value
                    timer += ws.getRun().getProperty("timer").value
            
            # Get the monitor and timer of the first file, which haven't yet
            # been added to the total
            ws = AnalysisDataService.retrieve(workspace)
            monitor += ws.getRun().getProperty("monitor").value
            timer += ws.getRun().getProperty("timer").value
                    
            # Update the timer and monitor
            ws.getRun().addProperty("monitor", monitor, True)
            ws.getRun().addProperty("timer", timer, True)
            
            if AnalysisDataService.doesExist('__tmp_wksp'):
                AnalysisDataService.remove('__tmp_wksp')              
        else:
            output_str += "Loaded %s\n" % data_file
            output_str += _load_data(data_file, workspace)
        return output_str
开发者ID:trnielsen,项目名称:mantid,代码行数:60,代码来源:HFIRSANSReduction.py


示例6: ScatteringBeamCenter

def ScatteringBeamCenter(datafile, beam_radius=3.0):
    datafile = find_data(
        datafile,
        instrument=ReductionSingleton().get_instrument())
    ReductionSingleton().reduction_properties[
        "BeamCenterMethod"] = "Scattering"
    ReductionSingleton().reduction_properties["BeamRadius"] = beam_radius
    ReductionSingleton().reduction_properties["BeamCenterFile"] = datafile
开发者ID:mantidproject,项目名称:mantid,代码行数:8,代码来源:hfir_command_interface.py


示例7: BckTransmissionDarkCurrent

def BckTransmissionDarkCurrent(dark_current=None):
    if dark_current is not None:
        dark_current = find_data(
            dark_current,
            instrument=ReductionSingleton().get_instrument())
        ReductionSingleton().reduction_properties[
            "BckTransmissionDarkCurrentFile"] = dark_current
    elif "BckTransmissionDarkCurrentFile" in ReductionSingleton().reduction_properties:
        del ReductionSingleton().reduction_properties[
            "BckTransmissionDarkCurrentFile"]
开发者ID:mantidproject,项目名称:mantid,代码行数:10,代码来源:hfir_command_interface.py


示例8: BckDirectBeamTransmission

def BckDirectBeamTransmission(
        sample_file,
        empty_file,
        beam_radius=3.0,
        theta_dependent=True):
    sample_file = find_data(
        sample_file,
        instrument=ReductionSingleton().get_instrument())
    empty_file = find_data(
        empty_file,
        instrument=ReductionSingleton().get_instrument())
    ReductionSingleton().reduction_properties[
        "BckTransmissionMethod"] = "DirectBeam"
    ReductionSingleton().reduction_properties[
        "BckTransmissionBeamRadius"] = beam_radius
    ReductionSingleton().reduction_properties[
        "BckTransmissionSampleDataFile"] = sample_file
    ReductionSingleton().reduction_properties[
        "BckTransmissionEmptyDataFile"] = empty_file
    ReductionSingleton().reduction_properties[
        "BckThetaDependentTransmission"] = theta_dependent
开发者ID:mantidproject,项目名称:mantid,代码行数:21,代码来源:hfir_command_interface.py


示例9: BckBeamSpreaderTransmission

def BckBeamSpreaderTransmission(
        sample_spreader,
        direct_spreader,
        sample_scattering,
        direct_scattering,
        spreader_transmission=1.0,
        spreader_transmission_err=0.0,
        theta_dependent=True):
    sample_spreader = find_data(
        sample_spreader,
        instrument=ReductionSingleton().get_instrument())
    direct_spreader = find_data(
        direct_spreader,
        instrument=ReductionSingleton().get_instrument())
    sample_scattering = find_data(
        sample_scattering,
        instrument=ReductionSingleton().get_instrument())
    direct_scattering = find_data(
        direct_scattering,
        instrument=ReductionSingleton().get_instrument())

    ReductionSingleton().reduction_properties[
        "BckTransmissionMethod"] = "BeamSpreader"
    ReductionSingleton().reduction_properties[
        "BckTransSampleSpreaderFilename"] = sample_spreader
    ReductionSingleton().reduction_properties[
        "BckTransDirectSpreaderFilename"] = direct_spreader
    ReductionSingleton().reduction_properties[
        "BckTransSampleScatteringFilename"] = sample_scattering
    ReductionSingleton().reduction_properties[
        "BckTransDirectScatteringFilename"] = direct_scattering
    ReductionSingleton().reduction_properties[
        "BckSpreaderTransmissionValue"] = spreader_transmission
    ReductionSingleton().reduction_properties[
        "BckSpreaderTransmissionError"] = spreader_transmission_err
    ReductionSingleton().reduction_properties[
        "BckThetaDependentTransmission"] = theta_dependent
开发者ID:mantidproject,项目名称:mantid,代码行数:37,代码来源:hfir_command_interface.py


示例10: _multiple_load

 def _multiple_load(self, data_file, workspace, property_manager, property_manager_name):
     instrument = ""
     if property_manager.existsProperty("InstrumentName"):
         property_manager.existsProperty("InstrumentName")
         instrument = property_manager.getProperty("InstrumentName").value
     else:
         property_manager.existsProperty("InstrumentName")
     output_str = ""
     if type(data_file) == str:
         data_file = find_data(data_file, instrument=instrument, allow_multiple=True)
     if type(data_file) == list:
         for i in range(len(data_file)):
             output_str += "Loaded %s\n" % data_file[i]
             if i == 0:
                 output_str += self._load_data(data_file[i], workspace, property_manager, property_manager_name)
                 continue
             output_str += self._load_data(data_file[i], "__tmp_wksp", property_manager, property_manager_name)
             api.Plus(LHSWorkspace=workspace, RHSWorkspace="__tmp_wksp", OutputWorkspace=workspace)
         if AnalysisDataService.doesExist("__tmp_wksp"):
             AnalysisDataService.remove("__tmp_wksp")
     else:
         output_str += "Loaded %s\n" % data_file
         output_str += self._load_data(data_file, workspace, property_manager, property_manager_name)
     return output_str
开发者ID:trnielsen,项目名称:mantid,代码行数:24,代码来源:SANSReduction.py


示例11: DarkCurrent

def DarkCurrent(datafile):
    datafile = find_data(
        datafile,
        instrument=ReductionSingleton().get_instrument())
    ReductionSingleton().reduction_properties["DarkCurrentFile"] = datafile
开发者ID:mantidproject,项目名称:mantid,代码行数:5,代码来源:hfir_command_interface.py


示例12: _hfir_scaling

    def _hfir_scaling(self, property_manager):
        property_manager_name = self.getProperty("ReductionProperties").value
        input_ws = self.getProperty("InputWorkspace").value
        output_ws_name = self.getPropertyValue("OutputWorkspace")
        output_msg = ""

        # Load data file
        data_file = self.getProperty("ReferenceDataFilename").value
        filepath = find_data(data_file, instrument=self.instrument)

        ref_basename = os.path.basename(filepath)
        ref_ws_name = "__abs_scale_%s" % ref_basename

        def _load_data(filename, output_ws):
            if not property_manager.existsProperty("LoadAlgorithm"):
                Logger("SANSDirectBeamTransmission").error("SANS reduction not set up properly: missing load algorithm")
                raise RuntimeError, "SANS reduction not set up properly: missing load algorithm"
            p=property_manager.getProperty("LoadAlgorithm")
            alg=Algorithm.fromString(p.valueAsStr)
            alg.setChild(True)
            alg.setProperty("Filename", filename)
            alg.setProperty("OutputWorkspace", output_ws)
            if alg.existsProperty("ReductionProperties"):
                alg.setProperty("ReductionProperties", property_manager_name)
            alg.execute()
            msg = ''
            if alg.existsProperty("OutputMessage"):
                msg = alg.getProperty("OutputMessage").value
            ws = alg.getProperty("OutputWorkspace").value
            return ws, msg

        ref_ws, msg = _load_data(filepath, ref_ws_name)
        output_msg += msg+'\n'

        # Get monitor value:
        # This call is left unprotected because it should fail if that property
        # doesn't exist. It's the responsibility of the parent algorithm to
        # catch that error.
        monitor_prop = property_manager.getProperty("NormaliseAlgorithm")
        alg=Algorithm.fromString(monitor_prop.valueAsStr)
        monitor_id = alg.getPropertyValue("NormalisationType").lower()

        monitor_value = ref_ws.getRun().getProperty(monitor_id.lower()).value
        # HFIR-specific: If we count for monitor we need to multiply by 1e8
        # Need to be consistent with the Normalization step
        if monitor_id == "monitor":
            monitor_value /= 1.0e8

        # Get sample-detector distance
        sdd = ref_ws.getRun().getProperty("sample_detector_distance").value

        # Get the beamstop diameter
        beam_diameter = self.getProperty("BeamstopDiameter").value
        if beam_diameter <= 0:
            if ref_ws.getRun().hasProperty("beam-diameter"):
                beam_diameter = ref_ws.getRun().getProperty("beam-diameter").value
                Logger("SANSAbsoluteScale").debug("Found beamstop diameter: %g" % beam_diameter)
            else:
                raise RuntimeError, "AbsoluteScale could not read the beam radius and none was provided"

        # Apply sensitivity correction
        apply_sensitivity = self.getProperty("ApplySensitivity").value
        if apply_sensitivity and property_manager.existsProperty("SensitivityAlgorithm"):
            p=property_manager.getProperty("SensitivityAlgorithm")
            alg=Algorithm.fromString(p.valueAsStr)
            alg.setChild(True)
            alg.setProperty("InputWorkspace", ref_ws)
            alg.setProperty("OutputWorkspace", ref_ws)
            if alg.existsProperty("ReductionProperties"):
                alg.setProperty("ReductionProperties", property_manager_name)
            alg.execute()
            if alg.existsProperty("OutputMessage"):
                output_msg += alg.getProperty("OutputMessage").value+'\n'

        # Get the reference count
        Logger("SANSAbsoluteScale").information("Using beamstop diameter: %g" % beam_diameter)
        det_count = 1
        cylXML = '<infinite-cylinder id="asbsolute_scale">' + \
                   '<centre x="0.0" y="0.0" z="0.0" />' + \
                   '<axis x="0.0" y="0.0" z="1.0" />' + \
                   '<radius val="%12.10f" />' % (beam_diameter/2000.0) + \
                 '</infinite-cylinder>\n'

        alg = AlgorithmManager.create("FindDetectorsInShape")
        alg.initialize()
        alg.setChild(True)
        alg.setProperty("Workspace", ref_ws)
        alg.setPropertyValue("ShapeXML", cylXML)
        alg.execute()
        det_list = alg.getProperty("DetectorList").value
        det_list_str = alg.getPropertyValue("DetectorList")

        det_count_ws_name = "__absolute_scale"
        alg = AlgorithmManager.create("GroupDetectors")
        alg.initialize()
        alg.setChild(True)
        alg.setProperty("InputWorkspace", ref_ws)
        alg.setProperty("OutputWorkspace", det_count_ws_name)
        alg.setPropertyValue("KeepUngroupedSpectra", "0")
        alg.setPropertyValue("DetectorList", det_list_str)
#.........这里部分代码省略.........
开发者ID:BigShows,项目名称:mantid,代码行数:101,代码来源:SANSAbsoluteScale.py


示例13: PyExec

    def PyExec(self):        
        # Get the reduction property manager
        property_manager_name = self.getProperty("ReductionProperties").value
        property_manager = PropertyManagerDataService.retrieve(property_manager_name)
        
        # Build the name we are going to give the transmission workspace
        sample_scatt = self.getPropertyValue("SampleScatteringFilename")
        sample_basename = os.path.basename(sample_scatt)
        entry_name = "TransmissionSpreader%s" % sample_scatt
        trans_ws_name = "__transmission_fit_%s" % sample_basename
        trans_ws = None
        
        # If we have already computed the transmission, used the 
        # previously computed workspace
        if property_manager.existsProperty(entry_name):
            trans_ws_name = property_manager.getProperty(entry_name)
            if AnalysisDataService.doesExist(trans_ws_name):
                trans_ws = AnalysisDataService.retrieve(trans_ws_name)
        
        # Get instrument to use with FileFinder
        instrument = ''
        if property_manager.existsProperty("InstrumentName"):
            instrument = property_manager.getProperty("InstrumentName").value

        # Get the data loader
        def _load_data(filename, output_ws):
            if not property_manager.existsProperty("LoadAlgorithm"):
                Logger("SANSBeamSpreaderTransmission").error("SANS reduction not set up properly: missing load algorithm")
                raise RuntimeError, "SANS reduction not set up properly: missing load algorithm"
            p=property_manager.getProperty("LoadAlgorithm")
            alg=Algorithm.fromString(p.valueAsStr)
            alg.setProperty("Filename", filename)
            alg.setProperty("OutputWorkspace", output_ws)
            if alg.existsProperty("ReductionProperties"):
                alg.setProperty("ReductionProperties", property_manager_name)
            alg.execute()
            msg = ''
            if alg.existsProperty("OutputMessage"):
                msg = alg.getProperty("OutputMessage").value
            return msg

        # Compute the transmission if we don't already have it
        if trans_ws is None:
            # Load data files
            sample_spreader_ws = "__trans_sample_spreader"
            direct_spreader_ws = "__trans_direct_spreader"
            sample_scatt_ws = "__trans_sample_scatt"
            direct_scatt_ws = "__trans_direct_scatt"
            
            sample_spread = self.getPropertyValue("SampleSpreaderFilename")
            direct_spread = self.getPropertyValue("DirectSpreaderFilename")
            direct_scatt = self.getPropertyValue("DirectScatteringFilename")
            
            ws_names = [[sample_spread, sample_spreader_ws],
                        [direct_spread, direct_spreader_ws],
                        [sample_scatt, sample_scatt_ws],
                        [direct_scatt, direct_scatt_ws]]
            dark_current_data = self.getPropertyValue("DarkCurrentFilename")

            for f in ws_names:
                filepath = find_data(f[0], instrument=instrument)
                _load_data(filepath, f[1])
                self._subtract_dark_current(f[1], property_manager)
            
            # Get normalization for transmission calculation
            monitor_det_ID = None
            if property_manager.existsProperty("TransmissionNormalisation"):
                sample_ws = AnalysisDataService.retrieve(sample_scatt_ws)
                if property_manager.getProperty("TransmissionNormalisation").value=="Monitor":
                    monitor_det_ID = int(sample_ws.getInstrument().getNumberParameter("default-incident-monitor-spectrum")[0])
                else:
                    monitor_det_ID = int(sample_ws.getInstrument().getNumberParameter("default-incident-timer-spectrum")[0])
            elif property_manager.existsProperty("NormaliseAlgorithm"):
                def _normalise(workspace):
                    p=property_manager.getProperty("NormaliseAlgorithm")
                    alg=Algorithm.fromString(p.valueAsStr)
                    alg.setProperty("InputWorkspace", workspace)
                    alg.setProperty("OutputWorkspace", workspace)
                    if alg.existsProperty("ReductionProperties"):
                        alg.setProperty("ReductionProperties", property_manager_name)
                    alg.execute()
                    msg = ''
                    if alg.existsProperty("OutputMessage"):
                        msg += alg.getProperty("OutputMessage").value+'\n'
                    return msg
                for f in ws_names:
                    _normalise(f[1])
            
            # Calculate transmission. Use the reduction method's normalization channel (time or beam monitor)
            # as the monitor channel.
            spreader_t_value = self.getPropertyValue("SpreaderTransmissionValue")
            spreader_t_error = self.getPropertyValue("SpreaderTransmissionError")
 
            alg = AlgorithmManager.createUnmanaged('CalculateTransmissionBeamSpreader')
            alg.initialize()
            alg.setProperty("SampleSpreaderRunWorkspace", sample_spreader_ws)
            alg.setProperty("DirectSpreaderRunWorkspace", direct_spreader_ws)
            alg.setProperty("SampleScatterRunWorkspace", sample_scatt_ws)
            alg.setProperty("DirectScatterRunWorkspace", direct_scatt_ws)
            alg.setProperty("IncidentBeamMonitor", monitor_det_ID)
#.........这里部分代码省略.........
开发者ID:jkrueger1,项目名称:mantid,代码行数:101,代码来源:SANSBeamSpreaderTransmission.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python models.get_settings函数代码示例发布时间:2022-05-26
下一篇:
Python reduction_workflow.find_data函数代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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