parameters: (state, r_min = 0.06, max_iter=10, position_1_start = 0.0, position_2_start = 0.0,
                         tolerance = 0.0001251, component=DetectorType.LAB)
return_statement: return {"pos1": centre1, "pos2": centre2}
docstring: Finds the beam centre from an initial guess.
  
      This function finds the centre of the beam by splitting the workspace up into 4 quadrants and running a reduction on
      each. The (left, right) and (up, down) reductions are then compared producing residuals which are minimised through
      repeated iteration.
      :param state: This is a sans state, to find the beam centre for.
      :param r_min: This is the radius of the central beam to mask out.
      :param position_1_start: This is the starting position of the search on the x axis.
      :param position_2_start: This is the starting position of the search on the y axis.
      :param tolerance: This is the tolerance for the search.
docstring_summary: Finds the beam centre from an initial guess.
docstring_tokens: Finds the beam centre from an initial guess .
function: def centre_finder_mass(state, r_min = 0.06, max_iter=10, position_1_start = 0.0, position_2_start = 0.0,
                         tolerance = 0.0001251, component=DetectorType.LAB):
      """
      Finds the beam centre from an initial guess.
  
      This function finds the centre of the beam by splitting the workspace up into 4 quadrants and running a reduction on
      each. The (left, right) and (up, down) reductions are then compared producing residuals which are minimised through
      repeated iteration.
      :param state: This is a sans state, to find the beam centre for.
      :param r_min: This is the radius of the central beam to mask out.
      :param position_1_start: This is the starting position of the search on the x axis.
      :param position_2_start: This is the starting position of the search on the y axis.
      :param tolerance: This is the tolerance for the search.
      """
      # ------------------------------------------------------------------------------------------------------------------
      # Load the data
      # ------------------------------------------------------------------------------------------------------------------
      workspace_to_name = {SANSDataType.SAMPLE_SCATTER: "SampleScatterWorkspace"}
  
      workspace_to_monitor = {SANSDataType.SAMPLE_SCATTER: "SampleScatterMonitorWorkSpace"}
  
      workspaces, monitors = provide_loaded_data(state, False, workspace_to_name, workspace_to_monitor)
  
      # ------------------------------------------------------------------------------------------------------------------
      # Get reduction settings
      # Split into individual bundles which can be reduced individually. We split here if we have multiple periods or
      # sliced times for example. For the beam centre finder we only use the first period.
      # ------------------------------------------------------------------------------------------------------------------
      reduction_packages = get_reduction_packages(state, workspaces, monitors)
      reduction_package = reduction_packages[0]
      # ------------------------------------------------------------------------------------------------------------------
      # Run reductions (one at a time)
      # ------------------------------------------------------------------------------------------------------------------
      beam_centre_finder = "SANSBeamCentreFinderMassMethod"
      beam_centre_finder_options = {"RMin": r_min/1000, "Centre1": position_1_start,
                                    "Centre2": position_2_start, "Tolerance": tolerance, "Component": component.value}
      beam_centre_alg = create_managed_non_child_algorithm(beam_centre_finder, **beam_centre_finder_options)
      beam_centre_alg.setChild(False)
  
      # -----------------------------------
      # Set the properties on the algorithm.
      # -----------------------------------
      set_properties_for_beam_centre_algorithm(beam_centre_alg, reduction_package,
                                               workspace_to_name, workspace_to_monitor)
      # -----------------------------------
      #  Run the algorithm.
      # -----------------------------------
      beam_centre_alg.execute()
  
      # -----------------------------------
      #  Get the outputs
      # -----------------------------------
  
      centre1 = beam_centre_alg.getProperty("Centre1").value
      centre2 = beam_centre_alg.getProperty("Centre2").value
  
      return {"pos1": centre1, "pos2": centre2}
function_tokens: def centre_finder_mass ( state , r_min = 0.06 , max_iter = 10 , position_1_start = 0.0 , position_2_start = 0.0 , tolerance = 0.0001251 , component = DetectorType . LAB ) : # ------------------------------------------------------------------------------------------------------------------ # Load the data # ------------------------------------------------------------------------------------------------------------------ workspace_to_name = { SANSDataType . SAMPLE_SCATTER : "SampleScatterWorkspace" } workspace_to_monitor = { SANSDataType . SAMPLE_SCATTER : "SampleScatterMonitorWorkSpace" } workspaces , monitors = provide_loaded_data ( state , False , workspace_to_name , workspace_to_monitor ) # ------------------------------------------------------------------------------------------------------------------ # Get reduction settings # Split into individual bundles which can be reduced individually. We split here if we have multiple periods or # sliced times for example. For the beam centre finder we only use the first period. # ------------------------------------------------------------------------------------------------------------------ reduction_packages = get_reduction_packages ( state , workspaces , monitors ) reduction_package = reduction_packages [ 0 ] # ------------------------------------------------------------------------------------------------------------------ # Run reductions (one at a time) # ------------------------------------------------------------------------------------------------------------------ beam_centre_finder = "SANSBeamCentreFinderMassMethod" beam_centre_finder_options = { "RMin" : r_min / 1000 , "Centre1" : position_1_start , "Centre2" : position_2_start , "Tolerance" : tolerance , "Component" : component . value } beam_centre_alg = create_managed_non_child_algorithm ( beam_centre_finder , * * beam_centre_finder_options ) beam_centre_alg . setChild ( False ) # ----------------------------------- # Set the properties on the algorithm. # ----------------------------------- set_properties_for_beam_centre_algorithm ( beam_centre_alg , reduction_package , workspace_to_name , workspace_to_monitor ) # ----------------------------------- #  Run the algorithm. # ----------------------------------- beam_centre_alg . execute ( ) # ----------------------------------- #  Get the outputs # ----------------------------------- centre1 = beam_centre_alg . getProperty ( "Centre1" ) . value centre2 = beam_centre_alg . getProperty ( "Centre2" ) . value return { "pos1" : centre1 , "pos2" : centre2 }