def add_runs( runs, # noqa: C901 inst='sans2d', defType='.nxs', rawTypes=('.raw', '.s*', 'add', '.RAW'), lowMem=False, binning='Monitors', saveAsEvent=False, isOverlay=False, time_shifts=None, outFile=None, outFile_monitors=None, save_directory=None): if inst.upper() == "SANS2DTUBES": inst = "SANS2D" #check if there is at least one file in the list if len(runs) < 1: return if not defType.startswith('.'): defType = '.' + defType # Create the correct format of adding files if time_shifts is None: time_shifts = [] adder = AddOperation(isOverlay, time_shifts) #these input arguments need to be arrays of strings, enforce this if isinstance(runs, str): runs = (runs, ) if isinstance(rawTypes, str): rawTypes = (rawTypes, ) if lowMem: lowMem = _can_load_periods(runs, defType, rawTypes) if lowMem: period = 1 else: period = _NO_INDIVIDUAL_PERIODS userEntry = runs[0] counter_run = 0 while True: isFirstDataSetEvent = False is_first_data_set_group_workspace = False #we need to catch all exceptions to ensure that a dialog box is raised with the error try: lastPath, lastFile, logFile, num_periods, isFirstDataSetEvent = _loadWS( userEntry, defType, inst, ADD_FILES_SUM_TEMPORARY, rawTypes, period) is_not_allowed_instrument = inst.upper() not in { 'SANS2D', 'LARMOR', 'ZOOM' } if is_not_allowed_instrument and isFirstDataSetEvent: error = 'Adding event data not supported for ' + inst + ' for now' print(error) sanslog.error(error) for workspaceName in (ADD_FILES_SUM_TEMPORARY, ADD_FILES_SUM_TEMPORARY_MONITORS): if workspaceName in mtd: DeleteWorkspace(workspaceName) return "" for i in range(len(runs) - 1): userEntry = runs[i + 1] lastPath, lastFile, logFile, dummy, isDataSetEvent = _loadWS( userEntry, defType, inst, ADD_FILES_NEW_TEMPORARY, rawTypes, period) if isDataSetEvent != isFirstDataSetEvent: error = 'Datasets added must be either ALL histogram data or ALL event data' print(error) sanslog.error(error) for workspaceName in (ADD_FILES_SUM_TEMPORARY, ADD_FILES_SUM_TEMPORARY_MONITORS, ADD_FILES_NEW_TEMPORARY, ADD_FILES_NEW_TEMPORARY_MONITORS): if workspaceName in mtd: DeleteWorkspace(workspaceName) return "" adder.add(LHS_workspace=ADD_FILES_SUM_TEMPORARY, RHS_workspace=ADD_FILES_NEW_TEMPORARY, output_workspace=ADD_FILES_SUM_TEMPORARY, run_to_add=counter_run) if isFirstDataSetEvent: adder.add( LHS_workspace=ADD_FILES_SUM_TEMPORARY_MONITORS, RHS_workspace=ADD_FILES_NEW_TEMPORARY_MONITORS, output_workspace=ADD_FILES_SUM_TEMPORARY_MONITORS, run_to_add=counter_run) DeleteWorkspace(ADD_FILES_NEW_TEMPORARY) if isFirstDataSetEvent: DeleteWorkspace(ADD_FILES_NEW_TEMPORARY_MONITORS) # Increment the run number counter_run += 1 except ValueError as e: error = 'Error opening file ' + userEntry + ': ' + str(e) print(error) sanslog.error(error) if ADD_FILES_SUM_TEMPORARY in mtd: DeleteWorkspace(ADD_FILES_SUM_TEMPORARY) return "" except Exception as e: error = 'Error finding files: ' + str(e) print(error) sanslog.error(error) for workspaceName in (ADD_FILES_SUM_TEMPORARY, ADD_FILES_NEW_TEMPORARY): if workspaceName in mtd: DeleteWorkspace(workspaceName) return "" # in case of event file force it into a histogram workspace if this is requested if isFirstDataSetEvent and not saveAsEvent: handle_saving_event_workspace_when_saving_as_histogram( binning, is_first_data_set_group_workspace, runs, defType, inst) lastFile = os.path.splitext(lastFile)[0] # now save the added file outFile = lastFile + '-add.' + 'nxs' if outFile is None else outFile outFile_monitors = lastFile + '-add_monitors.' + 'nxs' if outFile_monitors is None else outFile_monitors if save_directory: outFile = save_directory + outFile outFile_monitors = save_directory + outFile_monitors sanslog.notice('writing file: ' + outFile) if period == 1 or period == _NO_INDIVIDUAL_PERIODS: #replace the file the first time around SaveNexusProcessed(InputWorkspace=ADD_FILES_SUM_TEMPORARY, Filename=outFile, Append=False) # If we are saving event data, then we need to save also the monitor file if isFirstDataSetEvent and saveAsEvent: SaveNexusProcessed( InputWorkspace=ADD_FILES_SUM_TEMPORARY_MONITORS, Filename=outFile_monitors, Append=False) else: #then append SaveNexusProcessed(ADD_FILES_SUM_TEMPORARY, outFile, Append=True) if isFirstDataSetEvent and saveAsEvent: SaveNexusProcessed(ADD_FILES_SUM_TEMPORARY_MONITORS, outFile_monitors, Append=True) DeleteWorkspace(ADD_FILES_SUM_TEMPORARY) if isFirstDataSetEvent: DeleteWorkspace(ADD_FILES_SUM_TEMPORARY_MONITORS) if period == num_periods: break if period == _NO_INDIVIDUAL_PERIODS: break else: period += 1 if isFirstDataSetEvent and saveAsEvent: filename, ext = _makeFilename(runs[0], defType, inst) workspace_type = get_workspace_type(filename) is_multi_period = True if workspace_type is WorkspaceType.MultiperiodEvent else False outFile = bundle_added_event_data_as_group(outFile, outFile_monitors, is_multi_period) #this adds the path to the filename path, base = os.path.split(outFile) if path == '' or base not in os.listdir(path): # Try the default save directory path_prefix = save_directory if save_directory else config[ "defaultsave.directory"] path = path_prefix + path # If the path is still an empty string check in the current working directory if path == '': path = os.getcwd() assert base in os.listdir(path) pathout = path if logFile: _copyLog(lastPath, logFile, pathout) return 'The following file has been created:\n' + outFile
def add_runs(runs, inst='sans2d', defType='.nxs', rawTypes=('.raw', '.s*', 'add','.RAW'), lowMem=False, binning='Monitors', saveAsEvent=False, isOverlay = False, time_shifts = []): if inst.upper() == "SANS2DTUBES": inst = "SANS2D" #check if there is at least one file in the list if len(runs) < 1 : return if not defType.startswith('.') : defType = '.'+defType # Create the correct format of adding files adder = AddOperation(isOverlay, time_shifts) #these input arguments need to be arrays of strings, enforce this if type(runs) == str : runs = (runs, ) if type(rawTypes) == str : rawTypes = (rawTypes, ) if lowMem: lowMem = _can_load_periods(runs, defType, rawTypes) if lowMem: period = 1 else: period = _NO_INDIVIDUAL_PERIODS userEntry = runs[0] counter_run = 0 while True: isFirstDataSetEvent = False #we need to catch all exceptions to ensure that a dialog box is raised with the error try : lastPath, lastFile, logFile, num_periods, isFirstDataSetEvent = _loadWS(\ userEntry, defType, inst, 'AddFilesSumTempory', rawTypes, period) # if event data prevent loop over periods makes no sense if isFirstDataSetEvent: period = _NO_INDIVIDUAL_PERIODS if inst.upper() != 'SANS2D' and isFirstDataSetEvent: error = 'Adding event data not supported for ' + inst + ' for now' print error logger.notice(error) for workspaceName in ('AddFilesSumTempory','AddFilesSumTempory_monitors'): if workspaceName in mtd: DeleteWorkspace(workspaceName) return "" for i in range(len(runs)-1): userEntry = runs[i+1] lastPath, lastFile, logFile, dummy, isDataSetEvent = _loadWS(\ userEntry, defType, inst,'AddFilesNewTempory', rawTypes, period) if isDataSetEvent != isFirstDataSetEvent: error = 'Datasets added must be either ALL histogram data or ALL event data' print error logger.notice(error) for workspaceName in ('AddFilesSumTempory','AddFilesNewTempory'): if workspaceName in mtd: DeleteWorkspace(workspaceName) return "" adder.add(LHS_workspace='AddFilesSumTempory',RHS_workspace= 'AddFilesNewTempory', output_workspace= 'AddFilesSumTempory', run_to_add = counter_run) if isFirstDataSetEvent: adder.add(LHS_workspace='AddFilesSumTempory_monitors',RHS_workspace= 'AddFilesNewTempory_monitors', output_workspace= 'AddFilesSumTempory_monitors', run_to_add = counter_run) DeleteWorkspace("AddFilesNewTempory") if isFirstDataSetEvent: DeleteWorkspace("AddFilesNewTempory_monitors") # Increment the run number counter_run +=1 except ValueError as e: error = 'Error opening file ' + userEntry+': ' + str(e) print error logger.notice(error) if 'AddFilesSumTempory' in mtd : DeleteWorkspace('AddFilesSumTempory') return "" except Exception as e: error = 'Error finding files: ' + str(e) print error logger.notice(error) for workspaceName in ('AddFilesSumTempory','AddFilesNewTempory'): if workspaceName in mtd: DeleteWorkspace(workspaceName) return "" # in case of event file force it into a histogram workspace if isFirstDataSetEvent and saveAsEvent == False: wsInMonitor = mtd['AddFilesSumTempory_monitors'] if binning == 'Monitors': monX = wsInMonitor.dataX(0) binning = str(monX[0]) binGap = monX[1] - monX[0] binning = binning + "," + str(binGap) for j in range(2,len(monX)): nextBinGap = monX[j] - monX[j-1] if nextBinGap != binGap: binGap = nextBinGap binning = binning + "," + str(monX[j-1]) + "," + str(binGap) binning = binning + "," + str(monX[len(monX)-1]) logger.notice(binning) Rebin(InputWorkspace='AddFilesSumTempory',OutputWorkspace='AddFilesSumTempory_Rebin',Params= binning, PreserveEvents=False) # loading the nexus file using LoadNexus is necessary because it has some metadata # that is not in LoadEventNexus. This must be fixed. filename, ext = _makeFilename(runs[0], defType, inst) LoadNexus(Filename=filename, OutputWorkspace='AddFilesSumTempory', SpectrumMax=wsInMonitor.getNumberHistograms()) # User may have selected a binning which is different from the default Rebin(InputWorkspace='AddFilesSumTempory',OutputWorkspace='AddFilesSumTempory',Params= binning) # For now the monitor binning must be the same as the detector binning # since otherwise both cannot exist in the same output histogram file Rebin(InputWorkspace='AddFilesSumTempory_monitors',OutputWorkspace='AddFilesSumTempory_monitors',Params= binning) wsInMonitor = mtd['AddFilesSumTempory_monitors'] wsOut = mtd['AddFilesSumTempory'] wsInDetector = mtd['AddFilesSumTempory_Rebin'] # We loose added sample log information since we reload a single run workspace # and conjoin with the added workspace. In order to preserve some added sample # logs we need to transfer them at this point transfer_special_sample_logs(from_ws = wsInDetector, to_ws = wsOut) mon_n = wsInMonitor.getNumberHistograms() for i in range(mon_n): wsOut.setY(i,wsInMonitor.dataY(i)) wsOut.setE(i,wsInMonitor.dataE(i)) ConjoinWorkspaces(wsOut, wsInDetector, CheckOverlapping=True) if 'AddFilesSumTempory_Rebin' in mtd : DeleteWorkspace('AddFilesSumTempory_Rebin') lastFile = os.path.splitext(lastFile)[0] # now save the added file outFile = lastFile+'-add.'+'nxs' outFile_monitors = lastFile+'-add_monitors.'+'nxs' logger.notice('writing file: '+outFile) if period == 1 or period == _NO_INDIVIDUAL_PERIODS: #replace the file the first time around SaveNexusProcessed(InputWorkspace="AddFilesSumTempory", Filename=outFile, Append=False) # If we are saving event data, then we need to save also the monitor file if isFirstDataSetEvent and saveAsEvent: SaveNexusProcessed(InputWorkspace="AddFilesSumTempory_monitors", Filename=outFile_monitors , Append=False) else: #then append SaveNexusProcessed("AddFilesSumTempory", outFile, Append=True) if isFirstDataSetEvent and saveAsEvent: SaveNexusProcessed("AddFilesSumTempory_monitors", outFile_monitors , Append=True) DeleteWorkspace("AddFilesSumTempory") if isFirstDataSetEvent: DeleteWorkspace("AddFilesSumTempory_monitors") if period == num_periods: break if period == _NO_INDIVIDUAL_PERIODS: break else: period += 1 if isFirstDataSetEvent and saveAsEvent: outFile = bundle_added_event_data_as_group(outFile, outFile_monitors) #this adds the path to the filename path,base = os.path.split(outFile) if path == '' or base not in os.listdir(path): # Try the default save directory path = config['defaultsave.directory'] + path # If the path is still an empty string check in the current working directory if path == '': path = os.getcwd() assert base in os.listdir(path) pathout = path if logFile: _copyLog(lastPath, logFile, pathout) return 'The following file has been created:\n'+outFile
def add_runs(runs, # noqa: C901 inst='sans2d', defType='.nxs', rawTypes=('.raw', '.s*', 'add','.RAW'), lowMem=False, binning='Monitors', saveAsEvent=False, isOverlay=False, time_shifts=None, outFile=None, outFile_monitors=None): if inst.upper() == "SANS2DTUBES": inst = "SANS2D" #check if there is at least one file in the list if len(runs) < 1 : return if not defType.startswith('.') : defType = '.'+defType # Create the correct format of adding files if time_shifts is None: time_shifts = [] adder = AddOperation(isOverlay, time_shifts) #these input arguments need to be arrays of strings, enforce this if isinstance(runs, str) : runs = (runs, ) if isinstance(rawTypes, str) : rawTypes = (rawTypes, ) if lowMem: lowMem = _can_load_periods(runs, defType, rawTypes) if lowMem: period = 1 else: period = _NO_INDIVIDUAL_PERIODS userEntry = runs[0] counter_run = 0 while True: isFirstDataSetEvent = False is_first_data_set_group_workspace = False #we need to catch all exceptions to ensure that a dialog box is raised with the error try : lastPath, lastFile, logFile, num_periods, isFirstDataSetEvent = _loadWS( userEntry, defType, inst, ADD_FILES_SUM_TEMPORARY, rawTypes, period) is_not_allowed_instrument = inst.upper() not in {'SANS2D', 'LARMOR', 'ZOOM'} if is_not_allowed_instrument and isFirstDataSetEvent: error = 'Adding event data not supported for ' + inst + ' for now' print(error) sanslog.error(error) for workspaceName in (ADD_FILES_SUM_TEMPORARY,ADD_FILES_SUM_TEMPORARY_MONITORS): if workspaceName in mtd: DeleteWorkspace(workspaceName) return "" for i in range(len(runs)-1): userEntry = runs[i+1] lastPath, lastFile, logFile, dummy, isDataSetEvent = _loadWS( userEntry, defType, inst, ADD_FILES_NEW_TEMPORARY, rawTypes, period) if isDataSetEvent != isFirstDataSetEvent: error = 'Datasets added must be either ALL histogram data or ALL event data' print(error) sanslog.error(error) for workspaceName in (ADD_FILES_SUM_TEMPORARY, ADD_FILES_SUM_TEMPORARY_MONITORS, ADD_FILES_NEW_TEMPORARY, ADD_FILES_NEW_TEMPORARY_MONITORS): if workspaceName in mtd: DeleteWorkspace(workspaceName) return "" adder.add(LHS_workspace=ADD_FILES_SUM_TEMPORARY,RHS_workspace=ADD_FILES_NEW_TEMPORARY, output_workspace=ADD_FILES_SUM_TEMPORARY, run_to_add=counter_run) if isFirstDataSetEvent: adder.add(LHS_workspace=ADD_FILES_SUM_TEMPORARY_MONITORS, RHS_workspace= ADD_FILES_NEW_TEMPORARY_MONITORS, output_workspace=ADD_FILES_SUM_TEMPORARY_MONITORS, run_to_add = counter_run) DeleteWorkspace(ADD_FILES_NEW_TEMPORARY) if isFirstDataSetEvent: DeleteWorkspace(ADD_FILES_NEW_TEMPORARY_MONITORS) # Increment the run number counter_run +=1 except ValueError as e: error = 'Error opening file ' + userEntry+': ' + str(e) print(error) sanslog.error(error) if ADD_FILES_SUM_TEMPORARY in mtd : DeleteWorkspace(ADD_FILES_SUM_TEMPORARY) return "" except Exception as e: error = 'Error finding files: ' + str(e) print(error) sanslog.error(error) for workspaceName in (ADD_FILES_SUM_TEMPORARY, ADD_FILES_NEW_TEMPORARY): if workspaceName in mtd: DeleteWorkspace(workspaceName) return "" # in case of event file force it into a histogram workspace if this is requested if isFirstDataSetEvent and not saveAsEvent: handle_saving_event_workspace_when_saving_as_histogram(binning, is_first_data_set_group_workspace, runs, defType, inst) lastFile = os.path.splitext(lastFile)[0] # now save the added file outFile = lastFile+'-add.'+'nxs' if outFile is None else outFile outFile_monitors = lastFile+'-add_monitors.'+'nxs' if outFile_monitors is None else outFile_monitors sanslog.notice('writing file: '+outFile) if period == 1 or period == _NO_INDIVIDUAL_PERIODS: #replace the file the first time around SaveNexusProcessed(InputWorkspace=ADD_FILES_SUM_TEMPORARY, Filename=outFile, Append=False) # If we are saving event data, then we need to save also the monitor file if isFirstDataSetEvent and saveAsEvent: SaveNexusProcessed(InputWorkspace=ADD_FILES_SUM_TEMPORARY_MONITORS, Filename=outFile_monitors, Append=False) else: #then append SaveNexusProcessed(ADD_FILES_SUM_TEMPORARY, outFile, Append=True) if isFirstDataSetEvent and saveAsEvent: SaveNexusProcessed(ADD_FILES_SUM_TEMPORARY_MONITORS, outFile_monitors , Append=True) DeleteWorkspace(ADD_FILES_SUM_TEMPORARY) if isFirstDataSetEvent: DeleteWorkspace(ADD_FILES_SUM_TEMPORARY_MONITORS) if period == num_periods: break if period == _NO_INDIVIDUAL_PERIODS: break else: period += 1 if isFirstDataSetEvent and saveAsEvent: filename, ext = _makeFilename(runs[0], defType, inst) workspace_type = get_workspace_type(filename) is_multi_period = True if workspace_type is WorkspaceType.MultiperiodEvent else False outFile = bundle_added_event_data_as_group(outFile, outFile_monitors, is_multi_period) #this adds the path to the filename path,base = os.path.split(outFile) if path == '' or base not in os.listdir(path): # Try the default save directory path = config['defaultsave.directory'] + path # If the path is still an empty string check in the current working directory if path == '': path = os.getcwd() assert base in os.listdir(path) pathout = path if logFile: _copyLog(lastPath, logFile, pathout) return 'The following file has been created:\n'+outFile
def add_runs(runs, inst='sans2d', defType='.nxs', rawTypes=('.raw', '.s*', 'add', '.RAW'), lowMem=False, binning='Monitors', saveAsEvent=False, isOverlay=False, time_shifts=[]): if inst.upper() == "SANS2DTUBES": inst = "SANS2D" #check if there is at least one file in the list if len(runs) < 1: return if not defType.startswith('.'): defType = '.' + defType # Create the correct format of adding files adder = AddOperation(isOverlay, time_shifts) #these input arguments need to be arrays of strings, enforce this if type(runs) == str: runs = (runs, ) if type(rawTypes) == str: rawTypes = (rawTypes, ) if lowMem: lowMem = _can_load_periods(runs, defType, rawTypes) if lowMem: period = 1 else: period = _NO_INDIVIDUAL_PERIODS userEntry = runs[0] counter_run = 0 while True: isFirstDataSetEvent = False #we need to catch all exceptions to ensure that a dialog box is raised with the error try: lastPath, lastFile, logFile, num_periods, isFirstDataSetEvent = _loadWS(\ userEntry, defType, inst, 'AddFilesSumTempory', rawTypes, period) # if event data prevent loop over periods makes no sense if isFirstDataSetEvent: period = _NO_INDIVIDUAL_PERIODS if inst.upper() != 'SANS2D' and isFirstDataSetEvent: error = 'Adding event data not supported for ' + inst + ' for now' print error logger.notice(error) for workspaceName in ('AddFilesSumTempory', 'AddFilesSumTempory_monitors'): if workspaceName in mtd: DeleteWorkspace(workspaceName) return "" for i in range(len(runs) - 1): userEntry = runs[i + 1] lastPath, lastFile, logFile, dummy, isDataSetEvent = _loadWS(\ userEntry, defType, inst,'AddFilesNewTempory', rawTypes, period) if isDataSetEvent != isFirstDataSetEvent: error = 'Datasets added must be either ALL histogram data or ALL event data' print error logger.notice(error) for workspaceName in ('AddFilesSumTempory', 'AddFilesNewTempory'): if workspaceName in mtd: DeleteWorkspace(workspaceName) return "" adder.add(LHS_workspace='AddFilesSumTempory', RHS_workspace='AddFilesNewTempory', output_workspace='AddFilesSumTempory', run_to_add=counter_run) if isFirstDataSetEvent: adder.add(LHS_workspace='AddFilesSumTempory_monitors', RHS_workspace='AddFilesNewTempory_monitors', output_workspace='AddFilesSumTempory_monitors', run_to_add=counter_run) DeleteWorkspace("AddFilesNewTempory") if isFirstDataSetEvent: DeleteWorkspace("AddFilesNewTempory_monitors") # Increment the run number counter_run += 1 except ValueError as e: error = 'Error opening file ' + userEntry + ': ' + str(e) print error logger.notice(error) if 'AddFilesSumTempory' in mtd: DeleteWorkspace('AddFilesSumTempory') return "" except Exception as e: error = 'Error finding files: ' + str(e) print error logger.notice(error) for workspaceName in ('AddFilesSumTempory', 'AddFilesNewTempory'): if workspaceName in mtd: DeleteWorkspace(workspaceName) return "" # in case of event file force it into a histogram workspace if isFirstDataSetEvent and saveAsEvent == False: wsInMonitor = mtd['AddFilesSumTempory_monitors'] if binning == 'Monitors': monX = wsInMonitor.dataX(0) binning = str(monX[0]) binGap = monX[1] - monX[0] binning = binning + "," + str(binGap) for j in range(2, len(monX)): nextBinGap = monX[j] - monX[j - 1] if nextBinGap != binGap: binGap = nextBinGap binning = binning + "," + str( monX[j - 1]) + "," + str(binGap) binning = binning + "," + str(monX[len(monX) - 1]) logger.notice(binning) Rebin(InputWorkspace='AddFilesSumTempory', OutputWorkspace='AddFilesSumTempory_Rebin', Params=binning, PreserveEvents=False) # loading the nexus file using LoadNexus is necessary because it has some metadata # that is not in LoadEventNexus. This must be fixed. filename, ext = _makeFilename(runs[0], defType, inst) LoadNexus(Filename=filename, OutputWorkspace='AddFilesSumTempory', SpectrumMax=wsInMonitor.getNumberHistograms()) # User may have selected a binning which is different from the default Rebin(InputWorkspace='AddFilesSumTempory', OutputWorkspace='AddFilesSumTempory', Params=binning) # For now the monitor binning must be the same as the detector binning # since otherwise both cannot exist in the same output histogram file Rebin(InputWorkspace='AddFilesSumTempory_monitors', OutputWorkspace='AddFilesSumTempory_monitors', Params=binning) wsInMonitor = mtd['AddFilesSumTempory_monitors'] wsOut = mtd['AddFilesSumTempory'] wsInDetector = mtd['AddFilesSumTempory_Rebin'] # We loose added sample log information since we reload a single run workspace # and conjoin with the added workspace. In order to preserve some added sample # logs we need to transfer them at this point transfer_special_sample_logs(from_ws=wsInDetector, to_ws=wsOut) mon_n = wsInMonitor.getNumberHistograms() for i in range(mon_n): wsOut.setY(i, wsInMonitor.dataY(i)) wsOut.setE(i, wsInMonitor.dataE(i)) ConjoinWorkspaces(wsOut, wsInDetector, CheckOverlapping=True) if 'AddFilesSumTempory_Rebin' in mtd: DeleteWorkspace('AddFilesSumTempory_Rebin') lastFile = os.path.splitext(lastFile)[0] # now save the added file outFile = lastFile + '-add.' + 'nxs' outFile_monitors = lastFile + '-add_monitors.' + 'nxs' logger.notice('writing file: ' + outFile) if period == 1 or period == _NO_INDIVIDUAL_PERIODS: #replace the file the first time around SaveNexusProcessed(InputWorkspace="AddFilesSumTempory", Filename=outFile, Append=False) # If we are saving event data, then we need to save also the monitor file if isFirstDataSetEvent and saveAsEvent: SaveNexusProcessed( InputWorkspace="AddFilesSumTempory_monitors", Filename=outFile_monitors, Append=False) else: #then append SaveNexusProcessed("AddFilesSumTempory", outFile, Append=True) if isFirstDataSetEvent and saveAsEvent: SaveNexusProcessed("AddFilesSumTempory_monitors", outFile_monitors, Append=True) DeleteWorkspace("AddFilesSumTempory") if isFirstDataSetEvent: DeleteWorkspace("AddFilesSumTempory_monitors") if period == num_periods: break if period == _NO_INDIVIDUAL_PERIODS: break else: period += 1 if isFirstDataSetEvent and saveAsEvent: outFile = bundle_added_event_data_as_group(outFile, outFile_monitors) #this adds the path to the filename path, base = os.path.split(outFile) if path == '' or base not in os.listdir(path): # Try the default save directory path = config['defaultsave.directory'] + path # If the path is still an empty string check in the current working directory if path == '': path = os.getcwd() assert base in os.listdir(path) pathout = path if logFile: _copyLog(lastPath, logFile, pathout) return 'The following file has been created:\n' + outFile