def save_workspaces(self, workspaces_to_save=None): """ Use the private method _get_workspaces_to_save to get a list of workspaces that are present in the ADS to save to the directory that was passed at object creation time, it will also add each of them to the output_list private instance variable on the WorkspaceSaver class. :param workspaces_to_save: List of Strings; The workspaces that are to be saved to the project. """ # Handle getting here and nothing has been given passed if workspaces_to_save is None: return for workspace_name in workspaces_to_save: # Get the workspace from the ADS workspace = ADS.retrieve(workspace_name) place_to_save_workspace = os.path.join(self.directory, workspace_name) from mantid.simpleapi import SaveMD, SaveNexusProcessed try: if isinstance(workspace, MDHistoWorkspace) or isinstance(workspace, IMDEventWorkspace): # Save normally using SaveMD SaveMD(InputWorkspace=workspace_name, Filename=place_to_save_workspace + ".nxs") else: # Save normally using SaveNexusProcessed SaveNexusProcessed(InputWorkspace=workspace_name, Filename=place_to_save_workspace + ".nxs") except Exception: logger.warning("Couldn't save workspace in project: " + workspace) self.output_list.append(workspace_name)
def validate(self): results = 'SCDR_output' reference = 'SingleCrystalDiffuseReduction.nxs' Load(Filename=reference,OutputWorkspace=reference) checker = AlgorithmManager.create("CompareMDWorkspaces") checker.setLogging(True) checker.setPropertyValue("Workspace1",results) checker.setPropertyValue("Workspace2",reference) checker.setPropertyValue("Tolerance", "1e-7") checker.execute() if checker.getPropertyValue("Equals") != "1": print(" Workspaces do not match, result: ",checker.getPropertyValue("Result")) print(self.__class__.__name__) SaveMD(InputWorkspace=results,Filename=self.__class__.__name__+'-mismatch.nxs') return False return True
def validate(self): results = 'CMRSCMD_output_HKL' reference = 'ConvertMultipleRunsToSingleCrystalMD_HKL.nxs' Load(Filename=reference,OutputWorkspace=reference) checker = AlgorithmManager.create("CompareMDWorkspaces") checker.setLogging(True) checker.setPropertyValue("Workspace1",results) checker.setPropertyValue("Workspace2",reference) checker.setPropertyValue("Tolerance", "1e-5") checker.setPropertyValue("IgnoreBoxID", "1") checker.execute() if checker.getPropertyValue("Equals") != "1": print(" Workspaces do not match, result: ",checker.getPropertyValue("Result")) print(self.__class__.__name__) SaveMD(InputWorkspace=results,Filename=self.__class__.__name__+'-mismatch.nxs') return False return True
SolidAngle='/SNS/CORELLI/shared/Vanadium/2016B/SolidAngle20160720NoCC.nxs', Flux='/SNS/CORELLI/shared/Vanadium/2016B/Spectrum20160720NoCC.nxs', UBMatrix="/SNS/CORELLI/IPTS-15526/shared/benzil_Hexagonal.mat", OutputWorkspace='benzil_300k', SetGoniometer=True, Axis0="BL9:Mot:Sample:Axis1,0,1,0,1", Uproj='1,1,0', Vproj='1,-1,0', Wproj='0,0,1', BinningDim0='-7.525,7.525,301', BinningDim1='-13.16875,13.16875,301', BinningDim2='-3.1,3.1,31', SymmetryOps="P 31 2 1") #Plot2DMD(mtd['benzil_300k'],'/SNS/users/rwp/corelli/IPTS-15526-Benzil/benzil_300k.png',vmin=0,vmax=1e-5,cmap='hot') SaveMD('benzil_300k','/SNS/users/rwp/corelli/IPTS-15526-Benzil/benzil_300k.nxs') SingleCrystalDiffuseReduction(Filename=','.join('/SNS/CORELLI/IPTS-15526/shared/autoreduce/CORELLI_'+str(run)+'_elastic.nxs' for run in range(29782,29818)), Background='/SNS/CORELLI/IPTS-15796/shared/autoreduce/CORELLI_28124_elastic.nxs', BackgroundScale=0.95, SolidAngle='/SNS/CORELLI/shared/Vanadium/2016B/SolidAngle20160720NoCC.nxs', Flux='/SNS/CORELLI/shared/Vanadium/2016B/Spectrum20160720NoCC.nxs', UBMatrix="/SNS/CORELLI/IPTS-15526/shared/benzil_Hexagonal.mat", OutputWorkspace='benzil_300k_elastic', SetGoniometer=True, Axis0="BL9:Mot:Sample:Axis1,0,1,0,1", Uproj='1,1,0', Vproj='1,-1,0', Wproj='0,0,1', BinningDim0='-7.525,7.525,301', BinningDim1='-13.16875,13.16875,301',
mtd['__ws'].run().getGoniometer().getR()) convertToHKL('__ws', OutputWorkspace=data, UB=ub, Append=True, Uproj=Uproj, Vproj=Vproj, Wproj=Wproj, BinningDim0=BinningDim0, BinningDim1=BinningDim1, BinningDim2=BinningDim2) convertToHKL('cal', OutputWorkspace=norm, UB=ub, Append=True, Uproj=Uproj, Vproj=Vproj, Wproj=Wproj, scale=mtd['__ws'].run().getProtonCharge(), BinningDim0=BinningDim0, BinningDim1=BinningDim1, BinningDim2=BinningDim2) DeleteWorkspace('__ws') SaveMD( data, iptsdir + 'shared/{}_MDH_{}_to_{}_every_{}.nxs'.format( data, first_run, last_run, load_every)) SaveMD( norm, iptsdir + 'shared/{}_MDH_{}_to_{}_every_{}.nxs'.format( norm, first_run, last_run, load_every))
from mantid.simpleapi import SaveMD windows = 4 hostnames = ['ndav1.sns.gov', 'ndav2.sns.gov','ndav3.sns.gov'] node_numbers = windows * len(hostnames) try: window = int(os.environ['WINDOW']) except KeyError: exit("Run in screen") if window >= windows: exit("window out of range") try: hostname = hostnames.index(os.environ['HOSTNAME']) except ValueError: exit("Hostname not in list") node = hostname * windows + window print("Node {} out of {}".format(node, node_numbers)) all_runs = range(4756,6557+1) runs = np.array_split(all_runs, node_numbers)[node] for run in runs: in_file = '/HFIR/HB2C/IPTS-7776/nexus/HB2C_{}.nxs.h5'.format(run) out_file = '/SNS/snfs1/testing/ndav/rwp/PNO/HB2C_{}_MDE.nxs'.format(run) SaveMD(convertToQSample(loadIntegrateData(in_file)), out_file)
LoadHistory=False, OutputWorkspace='__md') except ValueError: filename = iptsdir + 'nexus/HB2C_{}.nxs.h5'.format(run) LoadWAND(filename, OutputWorkspace='__ws') ConvertToMD('__ws', QDimensions='Q3D', dEAnalysisMode='Elastic', Q3DFrames='Q_sample', OutputWorkspace='__md', MinValues='-10,-1,-10', MaxValues='10,1,10') accumulateMD('__md', OutputWorkspace=name_MDE) SaveMD( name_MDE, iptsdir + 'shared/' + name + '_MDE_{}_to_{}_every_{}.nxs'.format(first_run, last_run, load_every)) # Convert MD Event workspace to MD Histo workspace name_MDH = name + '_MDH' BinMD(InputWorkspace=name_MDE, AlignedDim0='Q_sample_x,' + BinningDim0, AlignedDim1='Q_sample_y,' + BinningDim1, AlignedDim2='Q_sample_z,' + BinningDim2, OutputWorkspace=name_MDH) SaveMD( name_MDH, iptsdir + 'shared/' + name + '_MDH_{}_to_{}_every_{}.nxs'.format(first_run, last_run, load_every))