本文整理汇总了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
示例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)
示例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)