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


Python TubeCalibFitParams.setMargin方法代码示例

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


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

示例1: calibrate

# 需要导入模块: from tube_calib_fit_params import TubeCalibFitParams [as 别名]
# 或者: from tube_calib_fit_params.TubeCalibFitParams import setMargin [as 别名]

#.........这里部分代码省略.........
    if kwargs.has_key(FITPAR):
        fitPar = kwargs[FITPAR]
        #fitPar must be a TubeCalibFitParams
        if not isinstance(fitPar, TubeCalibFitParams):
            raise RuntimeError("Wrong argument %s. This argument, when given, must be a valid TubeCalibFitParams object"%FITPAR)
    else:
        # create a fit parameters guessing centre positions
        # the guessing obeys the following rule:
        #
        # centre_pixel = known_pos * ndets/tube_length + ndets / 2
        #
        # Get tube length and number of detectors
        tube_length = tubeSet.getTubeLength(0)
        #ndets = len(wsp_index_for_tube0)
        id1, ndets, step = tubeSet.getDetectorInfoFromTube(0)

        known_pos = idealTube.getArray()
        # position of the peaks in pixels
        centre_pixel = known_pos * ndets/tube_length + ndets * 0.5

        fitPar = TubeCalibFitParams(centre_pixel)
        # make it automatic, it means, that for every tube,
        # the parameters for fit will be re-evaluated, from the first
        # guess positions given by centre_pixel
        fitPar.setAutomatic(True)


    # check the MARGIN paramter (optional)
    if kwargs.has_key(MARGIN):
        try:
            margin = float(kwargs[MARGIN])
        except:
            raise RuntimeError("Wrong argument %s. It was expected a number!"%MARGIN)
        fitPar.setMargin(margin)

    #deal with RANGELIST parameter
    if kwargs.has_key(RANGELIST):
        rangeList = kwargs[RANGELIST]
        if isinstance(rangeList,int):
            rangeList = [rangeList]
        try:
            # this deals with list and tuples and iterables to make sure
            # rangeList becomes a list
            rangeList = list(rangeList)
        except:
            raise RuntimeError("Wrong argument %s. It expects a list of indexes for calibration"%RANGELIST)
    else:
        rangeList = range(tubeSet.getNumTubes())

    # check if the user passed the option calibTable
    if kwargs.has_key(CALIBTABLE):
        calibTable = kwargs[CALIBTABLE]
        #ensure the correct type is passed
        # if a string was passed, transform it in mantid object
        if isinstance(calibTable,str):
            calibTable = mtd[calibTable]
        #check that calibTable has the expected form
        try:
            if not isinstance(calibTable,ITableWorkspace):
                raise 1
            if calibTable.columnCount() != 2:
                raise 2
            colNames = calibTable.getColumnNames()
            if colNames[0] != 'Detector ID' or colNames[1] != 'Detector Position':
                raise 3
        except:
开发者ID:nimgould,项目名称:mantid,代码行数:70,代码来源:tube.py


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