parameters: (workspace_names)
return_statement: return [workspace_names[0]]
docstring: Sum runs with chopped data.
docstring_summary: Sum runs with chopped data.
docstring_tokens: Sum runs with chopped data .
function: def sum_chopped_runs(workspace_names):
      """
      Sum runs with chopped data.
      """
      from mantid.simpleapi import (MergeRuns, Scale, DeleteWorkspace)
  
      try:
          num_merges = len(mtd[workspace_names[0]].getNames())
      except:
          raise RuntimeError('Not all runs have been chopped, cannot sum.')
  
      merges = list()
  
      # Generate a list of workspaces to be merged
      for idx in range(0, num_merges):
          merges.append({'detector': list(), 'monitor': list()})
  
          for ws_name in workspace_names:
              detector_ws_name = mtd[ws_name].getNames()[idx]
              monitor_ws_name = detector_ws_name + '_mon'
  
              merges[idx]['detector'].append(detector_ws_name)
              merges[idx]['monitor'].append(monitor_ws_name)
  
      for merge in merges:
          # Merge the chopped run segments
          MergeRuns(InputWorkspaces=','.join(merge['detector']),
                    OutputWorkspace=merge['detector'][0])
          MergeRuns(InputWorkspaces=','.join(merge['monitor']),
                    OutputWorkspace=merge['monitor'][0])
  
          # Scale the merged runs
          merge_size = len(merge['detector'])
          factor = 1.0 / merge_size
          Scale(InputWorkspace=merge['detector'][0],
                OutputWorkspace=merge['detector'][0],
                Factor=factor,
                Operation='Multiply')
          Scale(InputWorkspace=merge['monitor'][0],
                OutputWorkspace=merge['monitor'][0],
                Factor=factor,
                Operation='Multiply')
  
          # Remove the old workspaces
          for idx in range(1, merge_size):
              DeleteWorkspace(merge['detector'][idx])
              DeleteWorkspace(merge['monitor'][idx])
  
      # Only have the one workspace now
      return [workspace_names[0]]
function_tokens: def sum_chopped_runs ( workspace_names ) : from mantid . simpleapi import ( MergeRuns , Scale , DeleteWorkspace ) try : num_merges = len ( mtd [ workspace_names [ 0 ] ] . getNames ( ) ) except : raise RuntimeError ( 'Not all runs have been chopped, cannot sum.' ) merges = list ( ) # Generate a list of workspaces to be merged for idx in range ( 0 , num_merges ) : merges . append ( { 'detector' : list ( ) , 'monitor' : list ( ) } ) for ws_name in workspace_names : detector_ws_name = mtd [ ws_name ] . getNames ( ) [ idx ] monitor_ws_name = detector_ws_name + '_mon' merges [ idx ] [ 'detector' ] . append ( detector_ws_name ) merges [ idx ] [ 'monitor' ] . append ( monitor_ws_name ) for merge in merges : # Merge the chopped run segments MergeRuns ( InputWorkspaces = ',' . join ( merge [ 'detector' ] ) , OutputWorkspace = merge [ 'detector' ] [ 0 ] ) MergeRuns ( InputWorkspaces = ',' . join ( merge [ 'monitor' ] ) , OutputWorkspace = merge [ 'monitor' ] [ 0 ] ) # Scale the merged runs merge_size = len ( merge [ 'detector' ] ) factor = 1.0 / merge_size Scale ( InputWorkspace = merge [ 'detector' ] [ 0 ] , OutputWorkspace = merge [ 'detector' ] [ 0 ] , Factor = factor , Operation = 'Multiply' ) Scale ( InputWorkspace = merge [ 'monitor' ] [ 0 ] , OutputWorkspace = merge [ 'monitor' ] [ 0 ] , Factor = factor , Operation = 'Multiply' ) # Remove the old workspaces for idx in range ( 1 , merge_size ) : DeleteWorkspace ( merge [ 'detector' ] [ idx ] ) DeleteWorkspace ( merge [ 'monitor' ] [ idx ] ) # Only have the one workspace now return [ workspace_names [ 0 ] ]