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


Python EnggUtils.getWsIndicesForBank方法代码示例

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


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

示例1: _fitCurvesPerBank

# 需要导入模块: import EnggUtils [as 别名]
# 或者: from EnggUtils import getWsIndicesForBank [as 别名]
    def _fitCurvesPerBank(self, vanWS, banks, spline_breaks):
        """
        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 vanWS :: 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

        @returns a workspace with fitting results for all banks (3 spectra per bank). The spectra
        are in dSpacing units.
        """
        curves = {}
        for b in banks:
            indices = EnggUtils.getWsIndicesForBank(vanWS, b)
            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

            wsToFit = EnggUtils.cropData(self, vanWS, indices)
            wsToFit = EnggUtils.convertToDSpacing(self, wsToFit)
            wsToFit = EnggUtils.sumSpectra(self, wsToFit)

            fitWS = self._fitBankCurve(wsToFit, b, spline_breaks)
            curves.update({b: fitWS})

        curvesWS = self._prepareCurvesWS(curves)

        return curvesWS
开发者ID:mducle,项目名称:mantid,代码行数:32,代码来源:EnggVanadiumCorrections.py

示例2: _divideByCurves

# 需要导入模块: import EnggUtils [as 别名]
# 或者: from EnggUtils import getWsIndicesForBank [as 别名]
    def _divideByCurves(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.convertToDSpacing(self, ws)
        for b in curves:
            # process all the spectra (indices) in one bank
            fittedCurve = curves[b]
            idxs = EnggUtils.getWsIndicesForBank(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).
            rebinnedFitCurve = self._rebinToMatchWS(fittedCurve, ws)

            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), rebinnedFitCurve.readY(1)))

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


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