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