parameters: (self,origin,tof_range,rebin,chunk_num,n_chunks)
docstring: Chop part of the original workspace and sets it up to this run as new original.
  
             Return the pointer to the original workspace (the chunk has been taken) if the
             chunk is not the last one, or pointer to last chunk if the last chunk was taken
             (original workspace was destroyed in this case)
docstring_summary: Chop part of the original workspace and sets it up to this run as new original.
docstring_tokens: Chop part of the original workspace and sets it up to this run as new original .
function: def chop_ws_part(self,origin,tof_range,rebin,chunk_num,n_chunks):
          """Chop part of the original workspace and sets it up to this run as new original.
  
             Return the pointer to the original workspace (the chunk has been taken) if the
             chunk is not the last one, or pointer to last chunk if the last chunk was taken
             (original workspace was destroyed in this case)
          """
          if not origin:
              origin = self.get_workspace()
  
          origin_name = origin.name()
          # Check separate monitor's ws, attached to origin workspace (not to runWorkspace)
          try:
              mon_ws = origin.getMonitorWorkspace()
          except RuntimeError:
              mon_ws_name = origin_name+'_monitors'
              if mon_ws_name in mtd:
                  mon_ws = mtd[mon_ws_name]
                  origin.setMonitorWorkspace(mon_ws)
              else: # may be monitors are stored together with ws. We can not chop it
                  # so only way ahead is: TODO: Its possible to perform better here (take only monitors)
                  mon_ws = CloneWorkspace(InputWorkspace=origin_name,OutputWorkspace=origin_name + '_monitors')
                  origin.setMonitorWorkspace(mon_ws)
          #
  
          target_name = '#{0}/{1}#'.format(chunk_num,n_chunks) + origin_name
          if chunk_num == n_chunks:
              RenameWorkspace(InputWorkspace=origin_name,OutputWorkspace=target_name,RenameMonitors=True)
              origin_name = target_name
          else:
              if mon_ws:
                  mon_ws = CloneWorkspace(InputWorkspace=mon_ws,OutputWorkspace=target_name + '_monitors')
  
          if rebin: # debug and compatibility mode with old reduction
              target=Rebin(origin_name,OutputWorkspace=target_name,Params=[tof_range[0],tof_range[1],tof_range[2]],PreserveEvents=False)
              # Rebin in place does not conserves mon_ws?
              origin_deleted = True
          else:
              target = CropWorkspace(origin_name,OutputWorkspace=target_name,XMin=tof_range[0],XMax=tof_range[2])
              if origin_name == target_name:
                  origin_deleted = True
              else:
                  origin_deleted = False
          if mon_ws:
              target.setMonitorWorkspace(mon_ws)
  
          self._set_ws_as_source(mtd[target_name])
          if origin_deleted:
              return self.get_workspace()
          else:
              return mtd[origin_name]
function_tokens: def chop_ws_part ( self , origin , tof_range , rebin , chunk_num , n_chunks ) : if not origin : origin = self . get_workspace ( ) origin_name = origin . name ( ) # Check separate monitor's ws, attached to origin workspace (not to runWorkspace) try : mon_ws = origin . getMonitorWorkspace ( ) except RuntimeError : mon_ws_name = origin_name + '_monitors' if mon_ws_name in mtd : mon_ws = mtd [ mon_ws_name ] origin . setMonitorWorkspace ( mon_ws ) else : # may be monitors are stored together with ws. We can not chop it # so only way ahead is: TODO: Its possible to perform better here (take only monitors) mon_ws = CloneWorkspace ( InputWorkspace = origin_name , OutputWorkspace = origin_name + '_monitors' ) origin . setMonitorWorkspace ( mon_ws ) # target_name = '#{0}/{1}#' . format ( chunk_num , n_chunks ) + origin_name if chunk_num == n_chunks : RenameWorkspace ( InputWorkspace = origin_name , OutputWorkspace = target_name , RenameMonitors = True ) origin_name = target_name else : if mon_ws : mon_ws = CloneWorkspace ( InputWorkspace = mon_ws , OutputWorkspace = target_name + '_monitors' ) if rebin : # debug and compatibility mode with old reduction target = Rebin ( origin_name , OutputWorkspace = target_name , Params = [ tof_range [ 0 ] , tof_range [ 1 ] , tof_range [ 2 ] ] , PreserveEvents = False ) # Rebin in place does not conserves mon_ws? origin_deleted = True else : target = CropWorkspace ( origin_name , OutputWorkspace = target_name , XMin = tof_range [ 0 ] , XMax = tof_range [ 2 ] ) if origin_name == target_name : origin_deleted = True else : origin_deleted = False if mon_ws : target . setMonitorWorkspace ( mon_ws ) self . _set_ws_as_source ( mtd [ target_name ] ) if origin_deleted : return self . get_workspace ( ) else : return mtd [ origin_name ]