parameters: (self, workspaces)
docstring: where workspaces is a tuple of form:
                  (filepath, ws name)
docstring_summary: where workspaces is a tuple of form:
                  (filepath, ws name)
docstring_tokens: where workspaces is a tuple of form : ( filepath ws name )
function: def merge_and_crop_workspaces(self, workspaces):
          """ where workspaces is a tuple of form:
                  (filepath, ws name)
          """
          workspace_name = self.getPropertyValue('GroupWorkspace')
          # detectors is a dictionary of {detector_name : [names_of_workspaces]}
          detectors = {f"{workspace_name}; Detector {x}": [] for x in range(1, 5)}
          # fill dictionary
          for workspace in workspaces:
              detector_number = workspace[0]
              detectors[f"{workspace_name}; Detector {detector_number}"].append(workspace)
          # initialise a group workspace
          overall_ws = WorkspaceGroup()
          # merge each workspace list in detectors into a single workspace
          for detector, workspace_list in detectors.items():
              if workspace_list:
                  # sort workspace list according to type_index
                  sorted_workspace_list = [None] * NUM_FILES_PER_DETECTOR
                  # sort workspace list according to type_index
                  for workspace in workspace_list:
                      data_type = workspace.rsplit("_")[1]
                      sorted_workspace_list[SPECTRUM_INDEX[data_type] - 1] = workspace
                  workspace_list = sorted_workspace_list
                  # create merged workspace
                  merged_ws = self.create_merged_workspace(workspace_list)
                  ConvertToHistogram(InputWorkspace=merged_ws, OutputWorkspace=detector)
                  minX, maxX = [], []
                  ws = AnalysisDataService.retrieve(detector)
                  for i in range(ws.getNumberHistograms()):
                      xdata = ws.readX(i)
                      minX.append(xdata[0])
                      if i == 2:
                          maxX.append(xdata[-1])
                      else:
                          maxX.append(xdata[-1] - 1)
                  CropWorkspaceRagged(InputWorkspace=detector, OutputWorkspace=detector, xmin = minX, xmax = maxX)
                  overall_ws.addWorkspace(AnalysisDataService.retrieve(detector))
          self.setProperty("GroupWorkspace", overall_ws)
function_tokens: def merge_and_crop_workspaces ( self , workspaces ) : workspace_name = self . getPropertyValue ( 'GroupWorkspace' ) # detectors is a dictionary of {detector_name : [names_of_workspaces]} detectors = { f"{workspace_name}; Detector {x}" : [ ] for x in range ( 1 , 5 ) } # fill dictionary for workspace in workspaces : detector_number = workspace [ 0 ] detectors [ f"{workspace_name}; Detector {detector_number}" ] . append ( workspace ) # initialise a group workspace overall_ws = WorkspaceGroup ( ) # merge each workspace list in detectors into a single workspace for detector , workspace_list in detectors . items ( ) : if workspace_list : # sort workspace list according to type_index sorted_workspace_list = [ None ] * NUM_FILES_PER_DETECTOR # sort workspace list according to type_index for workspace in workspace_list : data_type = workspace . rsplit ( "_" ) [ 1 ] sorted_workspace_list [ SPECTRUM_INDEX [ data_type ] - 1 ] = workspace workspace_list = sorted_workspace_list # create merged workspace merged_ws = self . create_merged_workspace ( workspace_list ) ConvertToHistogram ( InputWorkspace = merged_ws , OutputWorkspace = detector ) minX , maxX = [ ] , [ ] ws = AnalysisDataService . retrieve ( detector ) for i in range ( ws . getNumberHistograms ( ) ) : xdata = ws . readX ( i ) minX . append ( xdata [ 0 ] ) if i == 2 : maxX . append ( xdata [ - 1 ] ) else : maxX . append ( xdata [ - 1 ] - 1 ) CropWorkspaceRagged ( InputWorkspace = detector , OutputWorkspace = detector , xmin = minX , xmax = maxX ) overall_ws . addWorkspace ( AnalysisDataService . retrieve ( detector ) ) self . setProperty ( "GroupWorkspace" , overall_ws )