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


Python SANSUtility.get_correct_combinDet_setting方法代码示例

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


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

示例1: BatchReduce

# 需要导入模块: import SANSUtility [as 别名]
# 或者: from SANSUtility import get_correct_combinDet_setting [as 别名]
def BatchReduce(filename, format, plotresults=False, saveAlgs={'SaveRKH':'txt'},verbose=False, # noqa: C901
                centreit=False, reducer=None, combineDet=None, save_as_zero_error_free=False):
    """
        @param filename: the CSV file with the list of runs to analyse
        @param format: type of file to load, nxs for Nexus, etc.
        @param plotresults: if true and this function is run from Mantidplot a graph will be created for the results of each reduction
        @param saveAlgs: this named algorithm will be passed the name of the results workspace and filename (default = 'SaveRKH').
            Pass a tuple of strings to save to multiple file formats
        @param verbose: set to true to write more information to the log (default=False)
        @param centreit: do centre finding (default=False)
        @param reducer: if to use the command line (default) or GUI reducer object
        @param combineDet: that will be forward to WavRangeReduction (rear, front, both, merged, None)
        @param save_as_zero_error_free: Should the reduced workspaces contain zero errors or not
        @return final_setings: A dictionary with some values of the Reduction - Right Now:(scale, shift)
    """
    if not format.startswith('.'):
        format = '.' + format

    # Read CSV file and store information in runinfo using format IN_FORMAT
    file_handle = open(filename, 'r')
    runinfo = []
    for line in file_handle:
        # See how many pieces of information have been provided;
        # brackets delineate the field separator (nothing for space-delimited, ',' for comma-seperated)
        parts = line.rstrip().split(',')
        if addRunToStore(parts, runinfo) > 0:
            issueWarning('Incorrect structure detected in input file "' + filename + '" at line \n"' + line + '"\nEntry skipped\n')
    file_handle.close()

    if reducer:
        ReductionSingleton().replace(reducer)
    ins_name = ReductionSingleton().instrument.name()
    # is used for SaveCanSAS1D go give the detectors names
    detnames = ', '.join(ReductionSingleton().instrument.listDetectors())

    # LARMOR has just one detector, but, it defines two because ISISInstrument is defined as two banks! #8395
    if ins_name == 'LARMOR':
        detnames = ReductionSingleton().instrument.cur_detector().name()

    scale_shift = {'scale':1.0000, 'shift':0.0000}
    #first copy the user settings in case running the reductionsteps can change it
    settings = copy.deepcopy(ReductionSingleton().reference())
    prop_man_settings = ReductionSingleton().settings.clone("TEMP_SETTINGS")

    # Make a note of the original user file, as we want to set it
    original_user_file = ReductionSingleton().user_settings.filename
    current_user_file = original_user_file

    # Store the original combineDet which was set either by the input. this should be used whenever we are using the
    # original user file
    original_combine_det = combineDet

    # Now loop over all the lines and do a reduction (hopefully) for each
    for run in runinfo:
        # Set the user file, if it is required
        try:
            current_user_file = setUserFileInBatchMode(new_user_file=run['user_file'],
                                                       current_user_file=current_user_file,
                                                       original_user_file=original_user_file,
                                                       original_settings = settings,
                                                       original_prop_man_settings = prop_man_settings)

            if current_user_file == original_user_file:
                combineDet = original_combine_det
            else:
                # When we set a new user file, that means that the combineDet feature could be invalid,
                # ie if the detector under investigation changed in the user file. We need to change this
                # here too. But only if it is not None.
                if combineDet is not None:
                    new_combineDet = ReductionSingleton().instrument.get_detector_selection()
                    combineDet = su.get_correct_combinDet_setting(ins_name, new_combineDet)
        except (RuntimeError, ValueError) as e:
            raise RuntimeError("Error in Batchmode user files: Could not reset the specified user file {0}. More info: {1}"
                               .format(str(run['user_file']), str(e)))

        local_settings = copy.deepcopy(ReductionSingleton().reference())
        local_prop_man_settings = ReductionSingleton().settings.clone("TEMP_SETTINGS")

        raw_workspaces = []
        geometry_properties = {}
        try:
            # Load in the sample runs specified in the csv file
            raw_workspaces.append(read_run(run, 'sample_sans', format))

            #Transmission runs to be applied to the sample
            raw_workspaces += read_trans_runs(run, 'sample', format)

            # Can run
            raw_workspaces.append(read_run(run, 'can_sans', format))

            #Transmission runs for the can
            raw_workspaces += read_trans_runs(run, 'can', format)

            if centreit == 1:
                if verbose == 1:
                    FindBeamCentre(50.,170.,12)

            try:
                geometry_properties = get_geometry_properties(ReductionSingleton())
            except RuntimeError as e:
#.........这里部分代码省略.........
开发者ID:mantidproject,项目名称:mantid,代码行数:103,代码来源:SANSBatchMode.py


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