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


Python SANSUtility.get_measurement_time_from_file方法代码示例

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


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

示例1: _match_IDF

# 需要导入模块: import SANSUtility [as 别名]
# 或者: from SANSUtility import get_measurement_time_from_file [as 别名]
    def _match_IDF(self, run):
        '''
        Compares the IDF in the stored instrument with the IDF in the workspace.
        If they are the same all is well. If they diff, then load the adequate
        user file.
        @param run: name of the run for which the file is to be extracted
        '''
        # We need the instrument name and the measurement time to determine
        # the IDF
        measurement_time = None
        instrument_name = self.get_instrument_name()
        # We need to be able to handle file-based and workspace-based queries
        # If we have a workspace we look at the end time, else we
        # need a sophisticated extraction mechanism
        if isinstance(run, Workspace):
            ws = None
            if isinstance(run, WorkspaceGroup):
                # Just look at the first element in a workspace group
                ws = run[0]
            else:
                ws = run
            measurement_time = str(ws.getRun().endTime()).strip()
        else:
            if run is None or run == "":
                return
            measurement_time = su.get_measurement_time_from_file(run)

        # Get the path to the instrument definition file
        idf_path_workspace = ExperimentInfo.getInstrumentFilename(instrument_name, measurement_time)
        idf_path_workspace = os.path.normpath(idf_path_workspace)

        # Get the idf from the reducer
        idf_path_reducer = self.get_idf_file_path()
        idf_path_reducer = os.path.normpath(idf_path_reducer)

        # Now check if both idf paths and underlying files. If they are, then don't do anything
        # else switch the underlying instrument
        if idf_path_reducer == idf_path_workspace and su.are_two_files_identical(idf_path_reducer, idf_path_reducer):
            return
        else:
            logger.notice("Updating the IDF of the Reducer. Switching from " +
                          str(idf_path_reducer) + " to " + str(idf_path_workspace))
            idf_path = os.path.basename(idf_path_workspace)
            instrument = self._get_correct_instrument(instrument_name, idf_path)

            # Get detector of the old instrument
            old_instrument = self.get_instrument()
            old_detector_selection = old_instrument.get_detector_selection()

            if instrument is not None:
                self.set_instrument(instrument)

                # We need to update the instrument, by reloading the user file.
                # This is pretty bad, but looking at the reducer architecture this
                # seems to be the only reasonable way to do this.
                self.user_settings.execute(self)

                # Now we set the correct detector, this is also being done in the GUI
                self.get_instrument().setDetector(old_detector_selection)
开发者ID:liyulun,项目名称:mantid,代码行数:61,代码来源:isis_reducer.py

示例2: _do_test

# 需要导入模块: import SANSUtility [as 别名]
# 或者: from SANSUtility import get_measurement_time_from_file [as 别名]
 def _do_test(self, file_name, expected_time):
     exists, full_path =  get_full_path_SANS_system_test(file_name)
     if exists:
         measurement_time = su.get_measurement_time_from_file(full_path)
         self.assertEqual(measurement_time, expected_time)
     else:
         print("Missing data files. Path to system test data needs to be set.")
         self.assertTrue(False)
开发者ID:mantidproject,项目名称:mantid,代码行数:10,代码来源:SANSFileChecking.py

示例3: _get_idf_path_for_workspace

# 需要导入模块: import SANSUtility [as 别名]
# 或者: from SANSUtility import get_measurement_time_from_file [as 别名]
 def _get_idf_path_for_workspace(self, filename, instrument_name):
     exists, full_path =  get_full_path_SANS_system_test(filename)
     idf_path_workspace = None
     if exists:
         measurement_time = su.get_measurement_time_from_file(full_path)
         idf_path_workspace = ExperimentInfo.getInstrumentFilename(instrument_name, measurement_time)
     else:
         print("Missing data files. Path to system test data needs to be set.")
         self.assertTrue(False)
     return idf_path_workspace
开发者ID:mantidproject,项目名称:mantid,代码行数:12,代码来源:SANSFileChecking.py


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