当前位置: 首页>>代码示例>>Python>>正文


Python DetectorType.from_string方法代码示例

本文整理汇总了Python中sans.common.enums.DetectorType.from_string方法的典型用法代码示例。如果您正苦于以下问题:Python DetectorType.from_string方法的具体用法?Python DetectorType.from_string怎么用?Python DetectorType.from_string使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在sans.common.enums.DetectorType的用法示例。


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

示例1: set_detector_names

# 需要导入模块: from sans.common.enums import DetectorType [as 别名]
# 或者: from sans.common.enums.DetectorType import from_string [as 别名]
def set_detector_names(state, ipf_path, invalid_detector_types=None):
    """
    Sets the detectors names on a State object which has a `detector` map entry, e.g. StateMask

    :param state: the state object
    :param ipf_path: the path to the Instrument Parameter File
    :param invalid_detector_types: a list of invalid detector types which don't exist for the instrument
    """
    if invalid_detector_types is None:
        invalid_detector_types = []

    lab_keyword = DetectorType.to_string(DetectorType.LAB)
    hab_keyword = DetectorType.to_string(DetectorType.HAB)
    detector_names = {lab_keyword: "low-angle-detector-name",
                      hab_keyword: "high-angle-detector-name"}
    detector_names_short = {lab_keyword: "low-angle-detector-short-name",
                            hab_keyword: "high-angle-detector-short-name"}

    names_to_search = []
    names_to_search.extend(list(detector_names.values()))
    names_to_search.extend(list(detector_names_short.values()))

    found_detector_names = get_named_elements_from_ipf_file(ipf_path, names_to_search, str)

    for detector_type in state.detectors:
        try:
            if DetectorType.from_string(detector_type) in invalid_detector_types:
                continue
            detector_name_tag = detector_names[detector_type]
            detector_name_short_tag = detector_names_short[detector_type]
            detector_name = found_detector_names[detector_name_tag]
            detector_name_short = found_detector_names[detector_name_short_tag]
        except KeyError:
            continue
        state.detectors[detector_type].detector_name = detector_name
        state.detectors[detector_type].detector_name_short = detector_name_short
开发者ID:DanNixon,项目名称:mantid,代码行数:38,代码来源:state_functions.py

示例2: _get_component

# 需要导入模块: from sans.common.enums import DetectorType [as 别名]
# 或者: from sans.common.enums.DetectorType import from_string [as 别名]
 def _get_component(self, workspace):
     component_as_string = self.getProperty("Component").value
     component = DetectorType.from_string(component_as_string)
     return get_component_name(workspace, component)
开发者ID:DanNixon,项目名称:mantid,代码行数:6,代码来源:SANSCrop.py

示例3: _get_component

# 需要导入模块: from sans.common.enums import DetectorType [as 别名]
# 或者: from sans.common.enums.DetectorType import from_string [as 别名]
 def _get_component(self):
     component_as_string = self.getProperty("Component").value
     return DetectorType.from_string(component_as_string)
开发者ID:DanNixon,项目名称:mantid,代码行数:5,代码来源:SANSMaskWorkspace.py


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