Ejemplo n.º 1
0
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 assoicated 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
Ejemplo n.º 2
0
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
Ejemplo n.º 3
0
def mask_beam_stop(mask_info, workspace):
    """
    The beam stop is being masked here.

    :param mask_info: a SANSStateMask object.
    :param workspace: the workspace which is to be masked.
    :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 not beam_stop_arm_width or not beam_stop_arm_angle:
        return workspace

    lab_ipf_key = "low-angle-detector-name"

    lab_component_name = workspace.getInstrument().getStringParameter(
        lab_ipf_key)
    if not lab_component_name:
        raise KeyError("{0} was not found in the IPF file for this instrument")
    lab_component_name = lab_component_name[0]

    comp_info = workspace.componentInfo()
    detector_index = comp_info.indexOfAny(lab_component_name)
    detector_pos = comp_info.position(detector_index)
    z_position = detector_pos.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