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


Python EnggUtils.get_ws_indices_for_bank方法代码示例

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


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

示例1: _divide_by_curves

# 需要导入模块: import EnggUtils [as 别名]
# 或者: from EnggUtils import get_ws_indices_for_bank [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: _fit_curves_per_bank

# 需要导入模块: import EnggUtils [as 别名]
# 或者: from EnggUtils import get_ws_indices_for_bank [as 别名]
    def _fit_curves_per_bank(self, vanadium_ws, banks, spline_breaks, prog):
        """
        Fits one curve to every bank (where for every bank the data fitted is the result of
        summing up all the spectra of the bank). The fitting is done in d-spacing.

        @param vanadium_ws :: Vanadium run workspace to fit, expected in TOF units as they are archived
        @param banks :: list of banks to consider which is normally all the banks of the instrument
        @param spline_breaks :: number of break points when fitting spline functions
        @param prog :: progress reporter

        @returns a workspace with fitting results for all banks (3 spectra per bank). The spectra
        are in dSpacing units.
        """
        curves = {}
        for bank_number, bank in enumerate(banks):
            prog.report("Fitting bank {} of {}".format(bank_number + 1, len(banks)))
            indices = EnggUtils.get_ws_indices_for_bank(vanadium_ws, bank)
            if not indices:
                # no indices at all for this bank, not interested in it, don't add it to the dictionary
                # (as when doing Calibrate (not-full)) which does CropData() the original workspace
                continue

            prog.report("Cropping")
            ws_to_fit = EnggUtils.crop_data(self, vanadium_ws, indices)
            prog.report("Converting to d-spacing")
            ws_to_fit = EnggUtils.convert_to_d_spacing(self, ws_to_fit)
            prog.report("Summing spectra")
            ws_to_fit = EnggUtils.sum_spectra(self, ws_to_fit)

            prog.report("Fitting bank {} to curve".format(bank_number))
            fit_ws = self._fit_bank_curve(ws_to_fit, bank, spline_breaks, prog)
            curves.update({bank: fit_ws})

        curves_ws = self._prepare_curves_ws(curves)

        return curves_ws
开发者ID:samueljackson92,项目名称:mantid,代码行数:38,代码来源:EnggVanadiumCorrections.py


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