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

Python general_functions.create_unmanaged_algorithm函数代码示例

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

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



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

示例1: provide_workspace_with_proton_charge

def provide_workspace_with_proton_charge(is_event=True):
    sample_name = "CreateSampleWorkspace"
    sample_options = {"OutputWorkspace": "dummy",
                      "NumBanks": 1,
                      "BankPixelWidth": 2}
    if is_event:
        sample_options.update({"WorkspaceType": "Event"})
    else:
        sample_options.update({"WorkspaceType": "Histogram"})

    sample_alg = create_unmanaged_algorithm(sample_name, **sample_options)
    sample_alg.execute()
    workspace = sample_alg.getProperty("OutputWorkspace").value

    # Provide a proton charge
    log_name = "AddTimeSeriesLog"
    log_options = {"Workspace": workspace,
                   "Name": "proton_charge",
                   "Type": "double"}
    log_alg = create_unmanaged_algorithm(log_name, **log_options)
    time = DateAndTime("2010-01-01T00:10:00")
    for index in range(0, 10):
        time += 1000000000
        value = 1.0
        log_alg.setProperty("Time", str(time))
        log_alg.setProperty("Value", value)
        log_alg.execute()
    return workspace
开发者ID:mantidproject,项目名称:mantid,代码行数:28,代码来源:SANSSliceEventTest.py


示例2: _compare_workspace

    def _compare_workspace(self, workspace, reference_file_name, check_spectra_map=True):
        # Load the reference file
        load_name = "LoadNexusProcessed"
        load_options = {"Filename": reference_file_name,
                        "OutputWorkspace": EMPTY_NAME}
        load_alg = create_unmanaged_algorithm(load_name, **load_options)
        load_alg.execute()
        reference_workspace = load_alg.getProperty("OutputWorkspace").value

        # Compare reference file with the output_workspace
        # We need to disable the instrument comparison, it takes way too long
        # We need to disable the sample -- Not clear why yet
        # operation how many entries can be found in the sample logs
        compare_name = "CompareWorkspaces"
        compare_options = {"Workspace1": workspace,
                           "Workspace2": reference_workspace,
                           "Tolerance": 1e-6,
                           "CheckInstrument": False,
                           "CheckSample": False,
                           "ToleranceRelErr": True,
                           "CheckAllData": True,
                           "CheckMasking": True,
                           "CheckType": True,
                           "CheckAxes": True,
                           "CheckSpectraMap": check_spectra_map}
        compare_alg = create_unmanaged_algorithm(compare_name, **compare_options)
        compare_alg.setChild(False)
        compare_alg.execute()
        result = compare_alg.getProperty("Result").value
        self.assertTrue(result)
开发者ID:samueljackson92,项目名称:mantid,代码行数:30,代码来源:SANSSingleReductionTest.py


示例3: _get_sample_workspace

    def _get_sample_workspace(with_zero_errors, convert_to_numeric_axis=False):
        create_name = "CreateSimulationWorkspace"
        create_options = {"Instrument": "LARMOR",
                          "BinParams": '1,10,1000',
                          "UnitX": 'MomentumTransfer',
                          "OutputWorkspace": EMPTY_NAME}
        create_alg = create_unmanaged_algorithm(create_name, **create_options)
        create_alg.execute()
        workspace = create_alg.getProperty("OutputWorkspace").value

        crop_name = "CropWorkspace"
        crop_options = {"InputWorkspace": workspace,
                        "OutputWorkspace": EMPTY_NAME,
                        "EndWorkspaceIndex": 0}
        crop_alg = create_unmanaged_algorithm(crop_name, **crop_options)
        crop_alg.execute()
        workspace = crop_alg.getProperty("OutputWorkspace").value

        if convert_to_numeric_axis:
            convert_name = "ConvertSpectrumAxis"
            convert_options = {"InputWorkspace": workspace,
                               "OutputWorkspace": EMPTY_NAME,
                               "Target": 'ElasticQ',
                               "EFixed": 1}
            convert_alg = create_unmanaged_algorithm(convert_name, **convert_options)
            convert_alg.execute()
            workspace = convert_alg.getProperty("OutputWorkspace").value

        if with_zero_errors:
            errors = workspace.dataE(0)
            errors[0] = 0.0
            errors[14] = 0.0
            errors[45] = 0.0
        return workspace
开发者ID:mantidproject,项目名称:mantid,代码行数:34,代码来源:SANSSaveTest.py


示例4: mask_with_mask_files

def mask_with_mask_files(mask_info, workspace):
    """
    Apply mask files to the workspace

    Rolling our own MaskDetectors wrapper since masking is broken in a couple
    of places that affect us here.
    Calling MaskDetectors(Workspace=ws_name, MaskedWorkspace=mask_ws_name) is
    not something we can do because the algorithm masks by ws index rather than
    detector id, and unfortunately for SANS the detector table is not the same
    for MaskingWorkspaces as it is for the workspaces containing the data to be
    masked.  Basically, we get a mirror image of what we expect.  Instead, we
    have to extract the det IDs and use those via the DetectorList property.
    :param mask_info: a SANSStateMask object.
    :param workspace: the workspace to be masked.
    :return: the masked workspace.
    """
    mask_files = mask_info.mask_files
    if mask_files:
        idf_path = mask_info.idf_path

        # Mask loader
        load_name = "LoadMask"
        load_options = {"Instrument": idf_path,
                        "OutputWorkspace": EMPTY_NAME}
        load_alg = create_unmanaged_algorithm(load_name, **load_options)
        dummy_params = {"OutputWorkspace": EMPTY_NAME}
        mask_alg = create_unmanaged_algorithm("MaskInstrument", **dummy_params)
        clear_alg = create_unmanaged_algorithm("ClearMaskedSpectra", **dummy_params)

        # Masker
        for mask_file in mask_files:
            mask_file = find_full_file_path(mask_file)

            # Get the detector ids which need to be masked
            load_alg.setProperty("InputFile", mask_file)
            load_alg.execute()
            masking_workspace = load_alg.getProperty("OutputWorkspace").value
            # Could use MaskDetectors directly with masking_workspace but it does not
            # support MPI. Use a three step approach via a, b, and c instead.
            # a) Extract detectors to mask from MaskWorkspace
            det_ids = masking_workspace.getMaskedDetectors()
            # b) Mask the detector ids on the instrument
            mask_alg.setProperty("InputWorkspace", workspace)
            mask_alg.setProperty("OutputWorkspace", workspace)
            mask_alg.setProperty("DetectorIDs", det_ids)
            mask_alg.execute()
            workspace = mask_alg.getProperty("OutputWorkspace").value
        # c) Clear data in all spectra associated with masked detectors
        clear_alg.setProperty("InputWorkspace", workspace)
        clear_alg.setProperty("OutputWorkspace", workspace)
        clear_alg.execute()
        workspace = clear_alg.getProperty("OutputWorkspace").value
    return workspace
开发者ID:mantidproject,项目名称:mantid,代码行数:53,代码来源:mask_workspace.py


示例5: _get_wavelength_adjustment_workspace

    def _get_wavelength_adjustment_workspace(self, wavelength_adjustment_file, transmission_workspace,
                                             monitor_normalization_workspace, rebin_string):
        """
        This creates a workspace with wavelength adjustments, ie this will be a correction for the bins, but it will
        be the same for all pixels. This is essentially the product of several workspaces.
        The participating workspaces are:
        1. A workspace loaded from a calibration file
        2.. The workspace resulting from the monitor normalization
        3. The workspace resulting from the transmission calculation (using SANSCalculateTransmission) if applicable

        :param wavelength_adjustment_file: the file path to the wavelength adjustment file
        :param transmission_workspace: the calculated transmission workspace (which can be None)
        :param monitor_normalization_workspace: the monitor normalization workspace
        :param rebin_string: the parameters for rebinning
        :return: a general wavelength adjustment workspace
        """
        # 1. Get the wavelength correction workspace from the file
        wavelength_adjustment_workspaces = []
        if wavelength_adjustment_file:
            wavelength_correction_workspace_from_file = \
                self._load_wavelength_correction_file(wavelength_adjustment_file)
            wavelength_adjustment_workspaces.append(wavelength_correction_workspace_from_file)

        # 2. Normalization
        wavelength_adjustment_workspaces.append(monitor_normalization_workspace)

        # 3. Transmission Calculation
        if transmission_workspace:
            wavelength_adjustment_workspaces.append(transmission_workspace)

        # Multiply all workspaces
        wavelength_adjustment_workspace = None
        for workspace in wavelength_adjustment_workspaces:
            # First we need to change the binning such that is matches the binning of the main data workspace
            rebin_name = "Rebin"
            rebin_options = {"InputWorkspace": workspace,
                             "Params": rebin_string,
                             "OutputWorkspace": EMPTY_NAME}
            rebin_alg = create_unmanaged_algorithm(rebin_name, **rebin_options)
            rebin_alg.execute()
            rebinned_workspace = rebin_alg.getProperty("OutputWorkspace").value
            if wavelength_adjustment_workspace is None:
                wavelength_adjustment_workspace = rebinned_workspace
            else:
                multiply_name = "Multiply"
                multiply_options = {"LHSWorkspace": rebinned_workspace,
                                    "RHSWorkspace": wavelength_adjustment_workspace,
                                    "OutputWorkspace": EMPTY_NAME}
                multiply_alg = create_unmanaged_algorithm(multiply_name, **multiply_options)
                multiply_alg.execute()
                wavelength_adjustment_workspace = multiply_alg.getProperty("OutputWorkspace").value
        return wavelength_adjustment_workspace
开发者ID:mantidproject,项目名称:mantid,代码行数:52,代码来源:SANSCreateWavelengthAndPixelAdjustment.py


示例6: _compare_workspace

    def _compare_workspace(self, workspace, reference_file_name):
        # Load the reference file
        load_name = "LoadNexusProcessed"
        load_options = {"Filename": reference_file_name,
                        "OutputWorkspace": EMPTY_NAME}
        load_alg = create_unmanaged_algorithm(load_name, **load_options)
        load_alg.execute()
        reference_workspace = load_alg.getProperty("OutputWorkspace").value

        # Save the workspace out and reload it again. This equalizes it with the reference workspace
        f_name = os.path.join(mantid.config.getString('defaultsave.directory'),
                              'SANS_temp_single_core_reduction_testout.nxs')

        save_name = "SaveNexus"
        save_options = {"Filename": f_name,
                        "InputWorkspace": workspace}
        save_alg = create_unmanaged_algorithm(save_name, **save_options)
        save_alg.execute()
        load_alg.setProperty("Filename", f_name)
        load_alg.setProperty("OutputWorkspace", EMPTY_NAME)
        load_alg.execute()

        ws = load_alg.getProperty("OutputWorkspace").value

        # Compare reference file with the output_workspace
        # We need to disable the instrument comparison, it takes way too long
        # We need to disable the sample -- since the sample has been modified (more logs are being written)
        # operation how many entries can be found in the sample logs
        compare_name = "CompareWorkspaces"
        compare_options = {"Workspace1": ws,
                           "Workspace2": reference_workspace,
                           "Tolerance": 1e-6,
                           "CheckInstrument": False,
                           "CheckSample": False,
                           "ToleranceRelErr": True,
                           "CheckAllData": True,
                           "CheckMasking": True,
                           "CheckType": True,
                           "CheckAxes": True,
                           "CheckSpectraMap": True}
        compare_alg = create_unmanaged_algorithm(compare_name, **compare_options)
        compare_alg.setChild(False)
        compare_alg.execute()
        result = compare_alg.getProperty("Result").value
        message = compare_alg.getProperty("Messages").value
        self.assertTrue(result, message)

        # Remove file
        if os.path.exists(f_name):
            os.remove(f_name)
开发者ID:mantidproject,项目名称:mantid,代码行数:50,代码来源:SANSDiagnosticPageTest.py


示例7: _apply_user_mask_ranges

    def _apply_user_mask_ranges(self, cF, cR, nR, nF, merge_min, merge_max):
        merge_max = self._check_bins(merge_min, merge_max, cF, cR)

        mask_name = "MaskBins"
        mask_options = {"InputWorkspace": cF}
        mask_alg = create_unmanaged_algorithm(mask_name, **mask_options)

        mask_alg.setProperty("InputWorkspace", cF)
        mask_alg.setProperty("OutputWorkspace", EMPTY_NAME)
        mask_alg.setProperty("XMin", min(cF.dataX(0)))
        mask_alg.setProperty("XMax", merge_min)
        mask_alg.execute()
        cF = mask_alg.getProperty("OutputWorkspace").value

        mask_alg.setProperty("InputWorkspace", nF)
        mask_alg.setProperty("OutputWorkspace", EMPTY_NAME)
        mask_alg.setProperty("XMin", min(nF.dataX(0)))
        mask_alg.setProperty("XMax", merge_min)
        mask_alg.execute()
        nF = mask_alg.getProperty("OutputWorkspace").value

        mask_alg.setProperty("InputWorkspace", cR)
        mask_alg.setProperty("OutputWorkspace", EMPTY_NAME)
        mask_alg.setProperty("XMin", merge_max)
        mask_alg.setProperty("XMax", max(cR.dataX(0)))
        mask_alg.execute()
        cR = mask_alg.getProperty("OutputWorkspace").value

        mask_alg.setProperty("InputWorkspace", nR)
        mask_alg.setProperty("OutputWorkspace", EMPTY_NAME)
        mask_alg.setProperty("XMin", merge_max)
        mask_alg.setProperty("XMax", max(nR.dataX(0)))
        mask_alg.execute()
        nR = mask_alg.getProperty("OutputWorkspace").value
        return cR, cF, nR, nF
开发者ID:stuartcampbell,项目名称:mantid,代码行数:35,代码来源:SANSStitch.py


示例8: _convert_to_wavelength

    def _convert_to_wavelength(self, workspace, normalize_to_monitor_state):
        """
        Converts the workspace from time-of-flight units to wavelength units

        :param workspace: a time-of-flight workspace.
        :param normalize_to_monitor_state: a SANSStateNormalizeToMonitor object.
        :return: a wavelength workspace.
        """
        wavelength_low = normalize_to_monitor_state.wavelength_low
        wavelength_high = normalize_to_monitor_state.wavelength_high
        wavelength_step = normalize_to_monitor_state.wavelength_step
        wavelength_step_type = normalize_to_monitor_state.wavelength_step_type
        wavelength_rebin_mode = normalize_to_monitor_state.rebin_type
        convert_name = "SANSConvertToWavelengthAndRebin"
        convert_options = {"InputWorkspace": workspace,
                           "WavelengthLow": wavelength_low,
                           "WavelengthHigh": wavelength_high,
                           "WavelengthStep": wavelength_step,
                           "WavelengthStepType": RangeStepType.to_string(wavelength_step_type),
                           "RebinMode": RebinType.to_string(wavelength_rebin_mode)}

        convert_alg = create_unmanaged_algorithm(convert_name, **convert_options)
        convert_alg.setPropertyValue("OutputWorkspace", EMPTY_NAME)
        convert_alg.setProperty("OutputWorkspace", workspace)
        convert_alg.execute()
        return convert_alg.getProperty("OutputWorkspace").value
开发者ID:DanNixon,项目名称:mantid,代码行数:26,代码来源:SANSNormalizeToMonitor.py


示例9: _perform_rebin

 def _perform_rebin(self, rebin_type, rebin_options, workspace):
     rebin_name = "Rebin" if rebin_type is RebinType.Rebin else "InterpolatingRebin"
     rebin_alg = create_unmanaged_algorithm(rebin_name, **rebin_options)
     rebin_alg.setPropertyValue("OutputWorkspace", EMPTY_NAME)
     rebin_alg.setProperty("OutputWorkspace", workspace)
     rebin_alg.execute()
     return rebin_alg.getProperty("OutputWorkspace").value
开发者ID:DanNixon,项目名称:mantid,代码行数:7,代码来源:SANSConvertToWavelengthAndRebin.py


示例10: _run_test

    def _run_test(state, sample_data, sample_monitor_data, transmission_data, direct_data, is_lab=True, is_sample=True):
        adjustment_name = "SANSCreateAdjustmentWorkspaces"
        adjustment_options = {"SANSState": state,
                              "SampleData": sample_data,
                              "MonitorWorkspace": sample_monitor_data,
                              "TransmissionWorkspace": transmission_data,
                              "DirectWorkspace": direct_data,
                              "OutputWorkspaceWavelengthAdjustment": EMPTY_NAME,
                              "OutputWorkspacePixelAdjustment": EMPTY_NAME,
                              "OutputWorkspaceWavelengthAndPixelAdjustment": EMPTY_NAME}
        if is_sample:
            adjustment_options.update({"DataType": DataType.to_string(DataType.Sample)})
        else:
            adjustment_options.update({"DataType": DataType.to_string(DataType.Can)})
        if is_lab:
            adjustment_options.update({"Component": DetectorType.to_string(DetectorType.LAB)})
        else:
            adjustment_options.update({"Component": DetectorType.to_string(DetectorType.HAB)})

        adjustment_alg = create_unmanaged_algorithm(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 = adjustment_alg.getProperty("CalculatedTransmissionWorkspace").value
        unfitted_transmission = adjustment_alg.getProperty("UnfittedTransmissionWorkspace").value
        return wavelength_adjustment, pixel_adjustment, wavelength_and_pixel_adjustment,\
               calculated_transmission, unfitted_transmission
开发者ID:samueljackson92,项目名称:mantid,代码行数:29,代码来源:SANSCreateAdjustmentWorkspacesTest.py


示例11: rotate_component

def rotate_component(workspace, angle, direction, component_to_rotate):
    """
    Rotate a component on a workspace.

    :param workspace: the workspace which contains the component which is to be rotated.
    :param angle: the angle by which it is to be rotated in degrees.
    :param direction: the rotation direction. This is a unit vector encoded as a Coordinate vs Value map.
    :param component_to_rotate: name of the component which is to be rotated
    :return:
    """
    rotate_name = "RotateInstrumentComponent"
    rotate_options = {"Workspace": workspace,
                      "ComponentName": component_to_rotate,
                      "RelativeRotation": "1"}
    for key, value in list(direction.items()):
        if key is CanonicalCoordinates.X:
            rotate_options.update({"X": value})
        elif key is CanonicalCoordinates.Y:
            rotate_options.update({"Y": value})
        elif key is CanonicalCoordinates.Z:
            rotate_options.update({"Z": value})
        else:
            raise RuntimeError("SANSMove: Trying to rotate the components along an unknown direction. "
                               "See here: {0}".format(str(component_to_rotate)))
    rotate_options.update({"Angle": angle})
    alg = create_unmanaged_algorithm(rotate_name, **rotate_options)
    alg.execute()
开发者ID:DanNixon,项目名称:mantid,代码行数:27,代码来源:move_workspaces.py


示例12: _perform_prompt_peak_correction

    def _perform_prompt_peak_correction(self, workspace, prompt_peak_correction_min, prompt_peak_correction_max,
                                        prompt_peak_correction_enabled):
        """
        Prompt peak correction is performed if it is explicitly set by the user.

        :param workspace: the workspace to correct.
        :param prompt_peak_correction_min: the start time for the prompt peak correction.
        :param prompt_peak_correction_max: the stop time for the prompt peak correction.
        :prompt_peak_correction_enabled: flag if prompt peak correction should be enabled
        :return: a corrected workspace.
        """
        # We perform only a prompt peak correction if the start and stop values of the bins we want to remove,
        # were explicitly set. Some instruments require it, others don't.
        if prompt_peak_correction_enabled and prompt_peak_correction_min is not None and \
                        prompt_peak_correction_max is not None:  # noqa
            remove_name = "RemoveBins"
            remove_options = {"InputWorkspace": workspace,
                              "XMin": prompt_peak_correction_min,
                              "XMax": prompt_peak_correction_max,
                              "Interpolation": "Linear"}
            remove_alg = create_unmanaged_algorithm(remove_name, **remove_options)
            remove_alg.setPropertyValue("OutputWorkspace", EMPTY_NAME)
            remove_alg.setProperty("OutputWorkspace", workspace)
            remove_alg.execute()
            workspace = remove_alg.getProperty("OutputWorkspace").value
        return workspace
开发者ID:mantidproject,项目名称:mantid,代码行数:26,代码来源:SANSCalculateTransmission.py


示例13: mask_cylinder

def mask_cylinder(mask_info, workspace):
    """
    Masks  a (hollow) cylinder around (0,0)

    Two radii can be specified for the cylinder mask. An inner radius (radius_min) and an outer radius(radius_max)
    which specify a hollow cylinder mask.
    :param mask_info: a SANSStateMask object.
    :param workspace: the workspace which is about to be masked
    :return: the masked workspace.
    """
    radius_min = mask_info.radius_min
    radius_max = mask_info.radius_max

    xml = []
    # Set up the inner radius of the cylinder
    if radius_min is not None and radius_min > 0.0:
        add_cylinder(xml, radius_min, 0, 0, 'beam_stop')

    # Set up the outer radius of the cylinder
    if radius_max is not None and radius_max > 0.0:
        add_outside_cylinder(xml, radius_max, 0, 0, 'beam_area')

    # Mask the cylinder shape if there is anything to mask, else don't do anything
    if xml:
        mask_name = "MaskDetectorsInShape"
        mask_options = {"Workspace": workspace}
        mask_alg = create_unmanaged_algorithm(mask_name, **mask_options)
        for shape in xml:
            mask_alg.setProperty("Workspace", workspace)
            mask_alg.setProperty("ShapeXML", shape)
            mask_alg.execute()
            workspace = mask_alg.getProperty("Workspace").value
    return workspace
开发者ID:mantidproject,项目名称:mantid,代码行数:33,代码来源:mask_workspace.py


示例14: mask_beam_stop

def mask_beam_stop(mask_info, workspace, instrument, detector_names):
    """
    The beam stop is being masked here.

    :param mask_info: a SANSStateMask object.
    :param workspace: the workspace which is to be masked.
    :param instrument: the instrument associated with the current workspace.
    :return: a masked workspace
    """
    beam_stop_arm_width = mask_info.beam_stop_arm_width
    beam_stop_arm_angle = mask_info.beam_stop_arm_angle
    beam_stop_arm_pos1 = mask_info.beam_stop_arm_pos1
    beam_stop_arm_pos2 = mask_info.beam_stop_arm_pos2
    if beam_stop_arm_width is not None and beam_stop_arm_angle is not None:
        detector = workspace.getInstrument().getComponentByName(detector_names['LAB'])
        z_position = detector.getPos().getZ()
        start_point = [beam_stop_arm_pos1, beam_stop_arm_pos2, z_position]
        line_mask = create_line_mask(start_point, 100., beam_stop_arm_width, beam_stop_arm_angle)

        mask_name = "MaskDetectorsInShape"
        mask_options = {"Workspace": workspace,
                        "ShapeXML": line_mask}
        mask_alg = create_unmanaged_algorithm(mask_name, **mask_options)
        mask_alg.execute()
        workspace = mask_alg.getProperty("Workspace").value
    return workspace
开发者ID:mantidproject,项目名称:mantid,代码行数:26,代码来源:mask_workspace.py


示例15: mask_angle

def mask_angle(mask_info, workspace):
    """
    Creates a pizza slice mask on the detector around (0,0)

    :param mask_info: a SANSStateMask object
    :param workspace: the workspace which is to be masked.
    :return: a masked workspace
    """
    phi_mirror = mask_info.use_mask_phi_mirror
    phi_min = mask_info.phi_min
    phi_max = mask_info.phi_max
    if phi_min is not None and phi_max is not None and phi_mirror is not None:
        # Check for edge cases for the mirror
        if phi_mirror:
            if phi_min > phi_max:
                phi_min, phi_max = phi_max, phi_min

            if phi_max - phi_min == 180.0:
                phi_min = -90.0
                phi_max = 90.0

        # Create the phi mask and apply it if anything was created
        phi_mask = create_phi_mask('unique phi', [0, 0, 0], phi_min, phi_max, phi_mirror)

        if phi_mask:
            mask_name = "MaskDetectorsInShape"
            mask_options = {"Workspace": workspace,
                            "ShapeXML": phi_mask}
            mask_alg = create_unmanaged_algorithm(mask_name, **mask_options)
            mask_alg.execute()
            workspace = mask_alg.getProperty("Workspace").value
    return workspace
开发者ID:mantidproject,项目名称:mantid,代码行数:32,代码来源:mask_workspace.py


示例16: test_that_scales_the_workspace_correctly

    def test_that_scales_the_workspace_correctly(self):
        # Arrange
        workspace = self._get_workspace()
        width = 1.0
        height = 2.0
        scale = 7.2
        state = self._get_sample_state(width=width, height=height, thickness=3.0, scale=scale,
                                       shape=SampleShape.CylinderAxisUp)
        serialized_state = state.property_manager
        scale_name = "SANSScale"
        scale_options = {"SANSState": serialized_state,
                         "InputWorkspace": workspace,
                         "OutputWorkspace": EMPTY_NAME}
        scale_alg = create_unmanaged_algorithm(scale_name, **scale_options)

        # Act
        scale_alg.execute()
        output_workspace = scale_alg.getProperty("OutputWorkspace").value

        # Assert
        # We have a LOQ data set, hence we need to divide by pi
        expected_value = 0.3/(height * math.pi * math.pow(width, 2) / 4.0) * (scale / math.pi) * 100.
        data_y = output_workspace.dataY(0)
        tolerance = 1e-7
        self.assertTrue(abs(data_y[0] - expected_value) < tolerance)
开发者ID:DanNixon,项目名称:mantid,代码行数:25,代码来源:SANSScaleTest.py


示例17: _get_calculated_transmission_workspace

    def _get_calculated_transmission_workspace(self, state):
        """
        Creates the fitted transmission workspace.

        Note that this step is not mandatory. If no transmission and direct workspaces are provided, then we
        don't have to do anything here.
        :param state: a SANSState object.
        :return: a fitted transmission workspace and the unfitted data.
        """
        transmission_workspace = self.getProperty("TransmissionWorkspace").value
        direct_workspace = self.getProperty("DirectWorkspace").value
        if transmission_workspace and direct_workspace:
            data_type = self.getProperty("DataType").value
            transmission_name = "SANSCalculateTransmission"
            serialized_state = state.property_manager
            transmission_options = {"TransmissionWorkspace": transmission_workspace,
                                    "DirectWorkspace": direct_workspace,
                                    "SANSState": serialized_state,
                                    "DataType": data_type,
                                    "OutputWorkspace": EMPTY_NAME,
                                    "UnfittedData": EMPTY_NAME}
            transmission_alg = create_unmanaged_algorithm(transmission_name, **transmission_options)
            transmission_alg.execute()
            fitted_data = transmission_alg.getProperty("OutputWorkspace").value
            unfitted_data = transmission_alg.getProperty("UnfittedData").value
        else:
            fitted_data = None
            unfitted_data = None
        return fitted_data, unfitted_data
开发者ID:mantidproject,项目名称:mantid,代码行数:29,代码来源:SANSCreateAdjustmentWorkspaces.py


示例18: do_scale

    def do_scale(workspace, scale_factor):
        single_valued_name = "CreateSingleValuedWorkspace"
        single_valued_options = {"OutputWorkspace": EMPTY_NAME,
                                 "DataValue": scale_factor}
        single_valued_alg = create_unmanaged_algorithm(single_valued_name, **single_valued_options)
        single_valued_alg.execute()
        single_valued_workspace = single_valued_alg.getProperty("OutputWorkspace").value

        multiply_name = "Multiply"
        multiply_options = {"LHSWorkspace": workspace,
                            "RHSWorkspace": single_valued_workspace}
        multiply_alg = create_unmanaged_algorithm(multiply_name, **multiply_options)
        multiply_alg.setPropertyValue("OutputWorkspace", EMPTY_NAME)
        multiply_alg.setProperty("OutputWorkspace", workspace)
        multiply_alg.execute()
        return multiply_alg.getProperty("OutputWorkspace").value
开发者ID:mantidproject,项目名称:mantid,代码行数:16,代码来源:scale_helpers.py


示例19: move_component

def move_component(workspace, offsets, component_to_move, is_relative=True):
    """
    Move an individual component on a workspace

    :param workspace: the workspace which the component which is to be moved.
    :param offsets: a Coordinate vs. Value map of offsets.
    :param component_to_move: the name of a component on the instrument. This component must be name which exist.
                              on the instrument.
    :param is_relative: if the move is relative of not.
    :return:
    """
    move_name = "MoveInstrumentComponent"
    move_options = {"Workspace": workspace,
                    "ComponentName": component_to_move,
                    "RelativePosition": is_relative}
    for key, value in list(offsets.items()):
        if key is CanonicalCoordinates.X:
            move_options.update({"X": value})
        elif key is CanonicalCoordinates.Y:
            move_options.update({"Y": value})
        elif key is CanonicalCoordinates.Z:
            move_options.update({"Z": value})
        else:
            raise RuntimeError("SANSMove: Trying to move the components along an unknown direction. "
                               "See here: {0}".format(str(component_to_move)))
    alg = create_unmanaged_algorithm(move_name, **move_options)
    alg.execute()
开发者ID:DanNixon,项目名称:mantid,代码行数:27,代码来源:move_workspaces.py


示例20: _clone_workspace

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



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python state_gui_model.StateGuiModel类代码示例发布时间:2022-05-27
下一篇:
Python general_functions.create_child_algorithm函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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