• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python general_functions.create_child_algorithm函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中sans.common.general_functions.create_child_algorithm函数的典型用法代码示例。如果您正苦于以下问题:Python create_child_algorithm函数的具体用法?Python create_child_algorithm怎么用?Python create_child_algorithm使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: _perform_initial_move

    def _perform_initial_move(self, workspaces, state):
        move_name = "SANSMove"
        state_dict = state.property_manager

        zero_options = {"SANSState": state_dict,
                        "MoveType": "SetToZero",
                        "Component": ""}
        zero_alg = create_child_algorithm(self, move_name, **zero_options)

        move_options = {"SANSState": state_dict,
                        "MoveType": "InitialMove"}
        move_alg = create_child_algorithm(self, move_name, **move_options)

        # The workspaces are stored in a dict: workspace_names (sample_scatter, etc) : ListOfWorkspaces
        for key, workspace_list in workspaces.items():
            if SANSDataType.to_string(key) in ("SampleTransmission", "CanTransmission", "CanDirect", "SampleDirect"):
                is_trans = True
            else:
                is_trans = False
            move_alg.setProperty("IsTransmissionWorkspace", is_trans)
            for workspace in workspace_list:
                zero_alg.setProperty("Workspace", workspace)
                zero_alg.execute()
                zeroed_workspace = zero_alg.getProperty("Workspace").value

                # If beam centre was specified then use it
                beam_coordinates = self.getProperty("BeamCoordinates").value
                if beam_coordinates:
                    move_alg.setProperty("BeamCoordinates", beam_coordinates)

                # ZOOM and LARMOR only have LAB, SANS2D and LOQ move both at once.
                move_alg.setProperty("Component", "LAB")
                move_alg.setProperty("Workspace", zeroed_workspace)
                move_alg.execute()
开发者ID:mantidproject,项目名称:mantid,代码行数:34,代码来源:SANSLoad.py


示例2: _adjustment

    def _adjustment(self, state_serialized, workspace, monitor_workspace, component_as_string, data_type):
        transmission_workspace = self._get_transmission_workspace()
        direct_workspace = self._get_direct_workspace()

        adjustment_name = "SANSCreateAdjustmentWorkspaces"
        adjustment_options = {"SANSState": state_serialized,
                              "Component": component_as_string,
                              "DataType": data_type,
                              "MonitorWorkspace": monitor_workspace,
                              "SampleData": workspace,
                              "OutputWorkspaceWavelengthAdjustment": EMPTY_NAME,
                              "OutputWorkspacePixelAdjustment": EMPTY_NAME,
                              "OutputWorkspaceWavelengthAndPixelAdjustment": EMPTY_NAME}
        if transmission_workspace:
            transmission_workspace = self._move(state_serialized, transmission_workspace, component_as_string,
                                                is_transmission=True)
            adjustment_options.update({"TransmissionWorkspace": transmission_workspace})

        if direct_workspace:
            direct_workspace = self._move(state_serialized, direct_workspace, component_as_string, is_transmission=True)
            adjustment_options.update({"DirectWorkspace": direct_workspace})

        adjustment_alg = create_child_algorithm(self, adjustment_name, **adjustment_options)
        adjustment_alg.execute()

        wavelength_adjustment = adjustment_alg.getProperty("OutputWorkspaceWavelengthAdjustment").value
        pixel_adjustment = adjustment_alg.getProperty("OutputWorkspacePixelAdjustment").value
        wavelength_and_pixel_adjustment = adjustment_alg.getProperty(
                                           "OutputWorkspaceWavelengthAndPixelAdjustment").value
        calculated_transmission_workspace = adjustment_alg.getProperty("CalculatedTransmissionWorkspace").value
        unfitted_transmission_workspace = adjustment_alg.getProperty("UnfittedTransmissionWorkspace").value
        return wavelength_adjustment, pixel_adjustment, wavelength_and_pixel_adjustment, \
            calculated_transmission_workspace, unfitted_transmission_workspace
开发者ID:samueljackson92,项目名称:mantid,代码行数:33,代码来源:SANSReductionCore.py


示例3: _run_quartile_reduction

 def _run_quartile_reduction(self, scatter_workspace, transmission_workspace, direct_workspace, data_type,
                             scatter_monitor_workspace, component, state, centre1, centre2, r_min, r_max):
     algorithm_name = "SANSBeamCentreFinderCore"
     alg_options = {"ScatterWorkspace": scatter_workspace,
                    "ScatterMonitorWorkspace": scatter_monitor_workspace,
                    "TransmissionWorkspace": transmission_workspace,
                    "DirectWorkspace": direct_workspace,
                    "Component": component,
                    "SANSState": state,
                    "DataType": data_type,
                    "Centre1": centre1,
                    "Centre2": centre2,
                    "OutputWorkspaceLeft": EMPTY_NAME,
                    "OutputWorkspaceRight": EMPTY_NAME,
                    "OutputWorkspaceTop": EMPTY_NAME,
                    "OutputWorkspaceBottom": EMPTY_NAME,
                    "RMax": r_max,
                    "RMin": r_min}
     alg = create_child_algorithm(self, algorithm_name, **alg_options)
     alg.execute()
     out_left = strip_end_nans(alg.getProperty("OutputWorkspaceLeft").value, self)
     out_right = strip_end_nans(alg.getProperty("OutputWorkspaceRight").value, self)
     out_top = strip_end_nans(alg.getProperty("OutputWorkspaceTop").value, self)
     out_bottom = strip_end_nans(alg.getProperty("OutputWorkspaceBottom").value, self)
     return {MaskingQuadrant.Left: out_left, MaskingQuadrant.Right: out_right, MaskingQuadrant.Top: out_top,
             MaskingQuadrant.Bottom: out_bottom}
开发者ID:samueljackson92,项目名称:mantid,代码行数:26,代码来源:SANSBeamCentreFinder.py


示例4: _get_cloned_workspace

 def _get_cloned_workspace(self, workspace):
     clone_name = "CloneWorkspace"
     clone_options = {"InputWorkspace": workspace,
                      "OutputWorkspace": EMPTY_NAME}
     clone_alg = create_child_algorithm(self, clone_name, **clone_options)
     clone_alg.execute()
     return clone_alg.getProperty("OutputWorkspace").value
开发者ID:mantidproject,项目名称:mantid,代码行数:7,代码来源:SANSBeamCentreFinderMassMethod.py


示例5: _convert_to_q

    def _convert_to_q(self, state_serialized, workspace, wavelength_adjustment_workspace, pixel_adjustment_workspace,
                      wavelength_and_pixel_adjustment_workspace):
        """
        A conversion to momentum transfer is performed in this step.

        The conversion can be either to the modulus of Q in which case the output is a 1D workspace, or it can
        be a 2D reduction where the y axis is Qy, ie it is a numeric axis.
        @param state: a SANSState object
        @param workspace: the workspace to convert to momentum transfer.
        @param wavelength_adjustment_workspace: the wavelength adjustment workspace.
        @param pixel_adjustment_workspace: the pixel adjustment workspace.
        @param wavelength_and_pixel_adjustment_workspace: the wavelength and pixel adjustment workspace.
        @return: a reduced workspace
        """
        convert_name = "SANSConvertToQ"
        convert_options = {"InputWorkspace": workspace,
                           "OutputWorkspace": EMPTY_NAME,
                           "SANSState": state_serialized,
                           "OutputParts": True}
        if wavelength_adjustment_workspace:
            convert_options.update({"InputWorkspaceWavelengthAdjustment": wavelength_adjustment_workspace})
        if pixel_adjustment_workspace:
            convert_options.update({"InputWorkspacePixelAdjustment": pixel_adjustment_workspace})
        if wavelength_and_pixel_adjustment_workspace:
            convert_options.update({"InputWorkspaceWavelengthAndPixelAdjustment":
                                    wavelength_and_pixel_adjustment_workspace})
        convert_alg = create_child_algorithm(self, convert_name, **convert_options)
        convert_alg.execute()
        data_workspace = convert_alg.getProperty("OutputWorkspace").value
        sum_of_counts = convert_alg.getProperty("SumOfCounts").value
        sum_of_norms = convert_alg.getProperty("SumOfNormFactors").value
        return data_workspace, sum_of_counts, sum_of_norms
开发者ID:samueljackson92,项目名称:mantid,代码行数:32,代码来源:SANSReductionCore.py


示例6: correct

    def correct(self, workspaces, parent_alg):
        """
        For LOQ we want to apply a different instrument definition for the transmission runs.

        :param workspaces: a dictionary of data types, e.g. SampleScatter vs. a workspace
        :param parent_alg: a handle to the parent algorithm
        """
        # Get the transmission and the direct workspaces and apply the correction to them
        workspace_which_require_transmission_correction = []
        for data_type, _ in list(workspaces.items()):
            if is_transmission_type(data_type):
                workspace_which_require_transmission_correction.append(workspaces[data_type])

        # We want to apply a different instrument for the transmission runs

        for workspace in workspace_which_require_transmission_correction:
            assert len(workspace) == 1
            workspace = workspace[0]
            instrument = workspace.getInstrument()
            has_m4 = instrument.getComponentByName("monitor4")
            if has_m4 is None:
                trans_definition_file = os.path.join(config.getString('instrumentDefinition.directory'),
                                                     'LOQ_trans_Definition.xml')
            else:
                trans_definition_file = os.path.join(config.getString('instrumentDefinition.directory'),
                                                     'LOQ_trans_Definition_M4.xml')
            # Done
            instrument_name = "LoadInstrument"
            instrument_options = {"Workspace": workspace,
                                  "Filename": trans_definition_file,
                                  "RewriteSpectraMap": False}
            instrument_alg = create_child_algorithm(parent_alg, instrument_name, **instrument_options)
            instrument_alg.execute()
开发者ID:DanNixon,项目名称:mantid,代码行数:33,代码来源:load_data.py


示例7: apply_missing_parameters

def apply_missing_parameters(calibration_workspace, workspace, missing_parameters, parent_alg):
    """
    Transfers missing properties from the data workspace to the calibration workspace.

    :param calibration_workspace: the calibration workspace.
    :param workspace: the data workspace.
    :param missing_parameters: a list of missing parameters which exist on the data workspace but not on the calibration
                               workspace.
    :param parent_alg: a handle to the parent algorithm
    """
    instrument = workspace.getInstrument()
    component_name = instrument.getName()
    component_name = sanitise_instrument_name(component_name)
    set_instrument_name = "SetInstrumentParameter"
    set_instrument_parameter_options = {"Workspace": calibration_workspace,
                                        "ComponentName": component_name}
    alg = create_child_algorithm(parent_alg, set_instrument_name, **set_instrument_parameter_options)

    # For now only string, int and double are handled
    type_options = {"string": "String", "int": "Number", "double": "Number"}
    value_options = {"string": instrument.getStringParameter,
                     "int": instrument.getIntParameter,
                     "double": instrument.getNumberParameter}
    try:
        for missing_parameter in missing_parameters:
            parameter_type = instrument.getParameterType(missing_parameter)
            type_to_save = type_options[parameter_type]
            value = value_options[parameter_type](missing_parameter)

            alg.setProperty("ParameterName", missing_parameter)
            alg.setProperty("ParameterType", type_to_save)
            alg.setProperty("Value", str(value[0]))
    except KeyError:
        raise RuntimeError("SANSCalibration: An Instrument Parameter File value of unknown type"
                           "was going to be copied. Cannot handle this currently.")
开发者ID:mantidproject,项目名称:mantid,代码行数:35,代码来源:calibration.py


示例8: get_calibration_workspace

def get_calibration_workspace(full_file_path, use_loaded, parent_alg):
    """
    Load the calibration workspace from the specified file

    :param full_file_path: Path to the calibration file.
    :param use_loaded: Allows us to check for the calibration file on the ADS.
    :param parent_alg: a handle to the parent algorithm
    :return: the calibration workspace.
    """
    calibration_workspace = None
    # Here we can avoid reloading of the calibration workspace
    if use_loaded:
        calibration_workspace = get_already_loaded_calibration_workspace(full_file_path)

    if calibration_workspace is None:
        if not isfile(full_file_path):
            raise RuntimeError("SANSCalibration: The file for  {0} does not seem to exist".format(full_file_path))
        loader_name = "LoadNexusProcessed"
        loader_options = {"Filename": full_file_path,
                          "OutputWorkspace": "dummy"}
        loader = create_child_algorithm(parent_alg, loader_name, **loader_options)
        loader.execute()
        calibration_workspace = loader.getProperty("OutputWorkspace").value

    return calibration_workspace
开发者ID:mantidproject,项目名称:mantid,代码行数:25,代码来源:calibration.py


示例9: _mask

 def _mask(self, state_serialized, workspace, component):
     mask_name = "SANSMaskWorkspace"
     mask_options = {"SANSState": state_serialized,
                     "Workspace": workspace,
                     "Component": component}
     mask_alg = create_child_algorithm(self, mask_name, **mask_options)
     mask_alg.execute()
     return mask_alg.getProperty("Workspace").value
开发者ID:mantidproject,项目名称:mantid,代码行数:8,代码来源:SANSBeamCentreFinderMassMethod.py


示例10: _scale

 def _scale(self, state_serialized, workspace):
     scale_name = "SANSScale"
     scale_options = {"SANSState": state_serialized,
                      "InputWorkspace": workspace,
                      "OutputWorkspace": EMPTY_NAME}
     scale_alg = create_child_algorithm(self, scale_name, **scale_options)
     scale_alg.execute()
     return scale_alg.getProperty("OutputWorkspace").value
开发者ID:mantidproject,项目名称:mantid,代码行数:8,代码来源:SANSBeamCentreFinderMassMethod.py


示例11: apply_mask

def apply_mask(state, workspace, component):
    state_serialized = state.property_manager
    mask_name = "SANSMaskWorkspace"
    mask_options = {"SANSState": state_serialized,
                    "Workspace": workspace,
                    "Component": component}
    mask_alg = create_child_algorithm('', mask_name, **mask_options)
    mask_alg.execute()
    return mask_alg.getProperty("Workspace").value
开发者ID:mantidproject,项目名称:mantid,代码行数:9,代码来源:diagnostics_page_model.py


示例12: _get_cropped_workspace

 def _get_cropped_workspace(self, component):
     scatter_workspace = self.getProperty("SampleScatterWorkspace").value
     crop_name = "SANSCrop"
     crop_options = {"InputWorkspace": scatter_workspace,
                     "OutputWorkspace": EMPTY_NAME,
                     "Component": component}
     crop_alg = create_child_algorithm(self, crop_name, **crop_options)
     crop_alg.execute()
     return crop_alg.getProperty("OutputWorkspace").value
开发者ID:mantidproject,项目名称:mantid,代码行数:9,代码来源:SANSBeamCentreFinderMassMethod.py


示例13: _convert_to_wavelength

 def _convert_to_wavelength(self, state_serialized, workspace):
     wavelength_name = "SANSConvertToWavelength"
     wavelength_options = {"SANSState": state_serialized,
                           "InputWorkspace": workspace}
     wavelength_alg = create_child_algorithm(self, wavelength_name, **wavelength_options)
     wavelength_alg.setPropertyValue("OutputWorkspace", EMPTY_NAME)
     wavelength_alg.setProperty("OutputWorkspace", workspace)
     wavelength_alg.execute()
     return wavelength_alg.getProperty("OutputWorkspace").value
开发者ID:mantidproject,项目名称:mantid,代码行数:9,代码来源:SANSBeamCentreFinderMassMethod.py


示例14: _run_center_of_mass_position

    def _run_center_of_mass_position(self, scatter_workspace, centre1, centre2, r_min, tolerance):
        algorithm_name = "FindCenterOfMassPosition"
        alg_options = {"InputWorkspace": scatter_workspace,
                       "CenterX": centre1,
                       "CenterY": centre2,
                       "BeamRadius": r_min,
                       "Tolerance": tolerance,
                       "DirectBeam": False}
        alg = create_child_algorithm(self, algorithm_name, **alg_options)
        alg.execute()

        return alg.getProperty("CenterOfMass").value
开发者ID:mantidproject,项目名称:mantid,代码行数:12,代码来源:SANSBeamCentreFinderMassMethod.py


示例15: calibrate

def calibrate(calibration_workspace, workspace_to_calibrate, parent_alg):
    """
    Performs a calibration. The instrument parameters are copied from the calibration workspace to the data workspace.

    :param calibration_workspace: the calibration workspace
    :param workspace_to_calibrate: the workspace which has the calibration applied to it.
    :param parent_alg: a handle to the parent algorithm
    """
    copy_instrument_name = "CopyInstrumentParameters"
    copy_instrument_options = {"InputWorkspace": calibration_workspace,
                               "OutputWorkspace": workspace_to_calibrate}
    alg = create_child_algorithm(parent_alg, copy_instrument_name, **copy_instrument_options)
    alg.execute()
开发者ID:mantidproject,项目名称:mantid,代码行数:13,代码来源:calibration.py


示例16: _convert_to_histogram

    def _convert_to_histogram(self, workspace):
        if isinstance(workspace, IEventWorkspace):
            convert_name = "RebinToWorkspace"
            convert_options = {"WorkspaceToRebin": workspace,
                               "WorkspaceToMatch": workspace,
                               "OutputWorkspace": "OutputWorkspace",
                               "PreserveEvents": False}
            convert_alg = create_child_algorithm(self, convert_name, **convert_options)
            convert_alg.execute()
            workspace = convert_alg.getProperty("OutputWorkspace").value
            append_to_sans_file_tag(workspace, "_histogram")

        return workspace
开发者ID:mantidproject,项目名称:mantid,代码行数:13,代码来源:SANSBeamCentreFinderMassMethod.py


示例17: get_cloned_calibration_workspace

def get_cloned_calibration_workspace(calibration_workspace, parent_alg):
    """
    Creates a clone from a calibration workspace, in order to consume it later.

    :param calibration_workspace: the calibration workspace which is being cloned
    :param parent_alg: a handle to the parent algorithm
    :return: a cloned calibration workspace
    """
    clone_name = "CloneWorkspace"
    clone_options = {"InputWorkspace": calibration_workspace,
                     "OutputWorkspace": EMPTY_NAME}
    alg = create_child_algorithm(parent_alg, clone_name, **clone_options)
    alg.execute()
    return alg.getProperty("OutputWorkspace").value
开发者ID:mantidproject,项目名称:mantid,代码行数:14,代码来源:calibration.py


示例18: loader_for_raw

def loader_for_raw(file_information, is_transmission, period, parent_alg):
    """
    Get the load algorithm information for an raw file

    :param file_information: a SANSFileInformation object.
    :param is_transmission: if the workspace is a transmission workspace.
    :param period: the period to load.
    :param parent_alg: a handle to the parent algorithm
    :return: the name of the load algorithm and the selected load options.
    """
    loader_name = "LoadRaw"
    loader_options = {"Filename": file_information.get_file_name(),
                      "OutputWorkspace": EMPTY_NAME}
    if is_transmission:
        loader_options.update({"LoadMonitors": "Include"})
    else:
        loader_options.update({"LoadMonitors": "Separate"})

    if period != StateData.ALL_PERIODS:
        loader_options.update({"PeriodList": period})
    loader_alg = create_child_algorithm(parent_alg, loader_name, **loader_options)
    workspaces, monitor_workspaces = run_loader(loader_alg, file_information, is_transmission, period, parent_alg)

    # Add the sample details to the loaded workspace
    sample_name = "LoadSampleDetailsFromRaw"
    sample_options = {"Filename": file_information.get_file_name()}
    sample_alg = create_child_algorithm(parent_alg, sample_name, **sample_options)

    for workspace in workspaces:
        sample_alg.setProperty("InputWorkspace", workspace)
        sample_alg.execute()

    for monitor_workspace in monitor_workspaces:
        sample_alg.setProperty("InputWorkspace", monitor_workspace)
        sample_alg.execute()

    return workspaces, monitor_workspaces
开发者ID:DanNixon,项目名称:mantid,代码行数:37,代码来源:load_data.py


示例19: _slice

    def _slice(self, state_serialized, workspace, monitor_workspace, data_type_as_string):
        slice_name = "SANSSliceEvent"
        slice_options = {"SANSState": state_serialized,
                         "InputWorkspace": workspace,
                         "InputWorkspaceMonitor": monitor_workspace,
                         "OutputWorkspace": EMPTY_NAME,
                         "OutputWorkspaceMonitor": "dummy2",
                         "DataType": data_type_as_string}
        slice_alg = create_child_algorithm(self, slice_name, **slice_options)
        slice_alg.execute()

        workspace = slice_alg.getProperty("OutputWorkspace").value
        monitor_workspace = slice_alg.getProperty("OutputWorkspaceMonitor").value
        slice_event_factor = slice_alg.getProperty("SliceEventFactor").value
        return workspace, monitor_workspace, slice_event_factor
开发者ID:mantidproject,项目名称:mantid,代码行数:15,代码来源:SANSBeamCentreFinderMassMethod.py


示例20: strip_end_nans

def strip_end_nans(workspace, parent_alg=None):
    """
    This function removes the INFs and NANs from the start and end of a 1D workspace.

    :param workspace: The workspace which is about to be
    :param parent_alg: a handle to the parent algorithm
    :return: A trimmed NAN- and INF-trimmed workspace
    """
    # If the workspace is larger than 1D, then there is nothing we can do
    if workspace is None or workspace.getNumberHistograms() != 1:
        return workspace
    data = workspace.readY(0)
    # Find the index at which the first legal value appears

    start_index = next((index for index in range(len(data)) if is_valid_data(data[index])), None)
    end_index = next((index for index in range(len(data)-1, -1, -1) if is_valid_data(data[index])), None)

    # If an index was not found then we return the current workspace. This means that all entries are either INFs
    # or NANs.

    if start_index is None or end_index is None:
        return workspace

    # Get the corresponding Q values
    q_values = workspace.readX(0)

    start_q = q_values[start_index]

    # Make sure we're inside the bin that we want to crop. This is part of the old framework. It looks like a bug fix,
    # hence we leave it in here for now. In general this is risky, and it should be a fraction of a bin width by which
    # we increase the end value
    is_point_data = len(workspace.dataX(0)) == len(workspace.dataY(0))
    if is_point_data:
        end_q = 1.001 * q_values[end_index]
    else:
        end_q = 1.001 * q_values[end_index + 1]

    # Crop the workspace in place
    crop_name = "CropWorkspace"
    crop_options = {"InputWorkspace": workspace,
                    "XMin": start_q,
                    "XMax": end_q}
    crop_alg = create_child_algorithm(parent_alg, crop_name, **crop_options)
    crop_alg.setProperty("OutputWorkspace", EMPTY_NAME)
    crop_alg.execute()
    ws = crop_alg.getProperty("OutputWorkspace").value
    return ws
开发者ID:DanNixon,项目名称:mantid,代码行数:47,代码来源:strip_end_nans_and_infs.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap