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


Python EnggUtils.convert_to_TOF方法代码示例

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


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

示例1: _divide_by_curves

# 需要导入模块: import EnggUtils [as 别名]
# 或者: from EnggUtils import convert_to_TOF [as 别名]
    def _divide_by_curves(self, ws, curves):
        """
        Expects a workspace in ToF units. All operations are done in-place (the workspace is
        input/output). For every bank-curve pair, divides the corresponding spectra in the
        workspace by the (simulated) fitted curve. The division is done in d-spacing (the
        input workspace is converted to d-spacing inside this method, but results are converted
        back to ToF before returning from this method). The curves workspace is expected in
        d-spacing units (since it comes from fitting a sum of spectra for a bank or group of
        detectors).

        This method is capable of dealing with workspaces with range and bin size different from
        the range and bin size of the curves. It will rebin the curves workspace to match the
        input 'ws' workspace (using the algorithm RebinToWorkspace).

        @param ws :: workspace with (sample) spectra to divide by curves fitted to Vanadium spectra

        @param curves :: dictionary of fitting workspaces (in d-spacing), one per bank. The keys are
        the bank identifier and the values are their fitting workspaces. The fitting workspaces are
        expected as returned by the algorithm 'Fit': 3 spectra: original data, simulated data with fit,
        difference between original and simulated data.
        """
        # Note that this division could use the algorithm 'Divide'
        # This is simple and more efficient than using divide workspace, which requires
        # cropping separate workspaces, dividing them separately, then appending them
        # with AppendSpectra, etc.
        ws = EnggUtils.convert_to_d_spacing(self, ws)
        for b in curves:
            # process all the spectra (indices) in one bank
            fitted_curve = curves[b]
            idxs = EnggUtils.get_ws_indices_for_bank(ws, b)

            if not idxs:
                pass

            # This RebinToWorkspace is required here: normal runs will have narrower range of X values,
            # and possibly different bin size, as compared to (long) Vanadium runs. Same applies to short
            # Ceria runs (for Calibrate -non-full) and even long Ceria runs (for Calibrate-Full).
            rebinned_fit_curve = mantid.RebinToWorkspace(WorkspaceToRebin=fitted_curve, WorkspaceToMatch=ws,
                                                         StoreInADS=False)

            for i in idxs:
                # take values of the second spectrum of the workspace (fit simulation - fitted curve)
                ws.setY(i, np.divide(ws.dataY(i), rebinned_fit_curve.readY(1)))

        # finally, convert back to ToF
        EnggUtils.convert_to_TOF(self, ws)
开发者ID:samueljackson92,项目名称:mantid,代码行数:48,代码来源:EnggVanadiumCorrections.py

示例2: PyExec

# 需要导入模块: import EnggUtils [as 别名]
# 或者: from EnggUtils import convert_to_TOF [as 别名]
    def PyExec(self):
        # Get the run workspace
        input_ws = self.getProperty('InputWorkspace').value

        # Get spectra indices either from bank or direct list of indices, checking for errors
        bank = self.getProperty('Bank').value
        spectra = self.getProperty(self.INDICES_PROP_NAME).value
        indices = EnggUtils.get_ws_indices_from_input_properties(input_ws, bank, spectra)

        detector_positions = self.getProperty("DetectorPositions").value
        n_reports = 8
        prog = Progress(self, start=0, end=1, nreports=n_reports)

        # Leave only the data for the bank/spectra list requested
        prog.report('Selecting spectra from input workspace')
        input_ws = EnggUtils.crop_data(self, input_ws, indices)

        prog.report('Masking some bins if requested')
        self._mask_bins(input_ws, self.getProperty('MaskBinsXMins').value, self.getProperty('MaskBinsXMaxs').value)

        prog.report('Applying vanadium corrections')
        # Leave data for the same bank in the vanadium workspace too
        vanadium_ws = self.getProperty('VanadiumWorkspace').value
        van_integration_ws = self.getProperty('VanIntegrationWorkspace').value
        van_curves_ws = self.getProperty('VanCurvesWorkspace').value
        EnggUtils.apply_vanadium_corrections(parent=self, ws=input_ws, indices=indices, vanadium_ws=vanadium_ws,
                                             van_integration_ws=van_integration_ws, van_curves_ws=van_curves_ws,
                                             progress_range=(0.65, 0.8))

        prog.report("Applying calibration if requested")
        # Apply calibration
        if detector_positions:
            self._apply_calibration(input_ws, detector_positions)

        # Convert to dSpacing
        prog.report("Converting to d")
        input_ws = EnggUtils.convert_to_d_spacing(self, input_ws)

        prog.report('Summing spectra')
        # Sum the values across spectra
        input_ws = EnggUtils.sum_spectra(self, input_ws)

        prog.report('Preparing output workspace')
        # Convert back to time of flight
        input_ws = EnggUtils.convert_to_TOF(self, input_ws)

        prog.report('Normalizing input workspace if needed')
        if self.getProperty('NormaliseByCurrent').value:
            self._normalize_by_current(input_ws)

        # OpenGenie displays distributions instead of pure counts (this is done implicitly when
        # converting units), so I guess that's what users will expect
        self._convert_to_distribution(input_ws)

        if bank:
            self._add_bank_number(input_ws, bank)

        self.setProperty("OutputWorkspace", input_ws)
开发者ID:stuartcampbell,项目名称:mantid,代码行数:60,代码来源:EnggFocus.py


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