diff --git a/Code/Mantid/Framework/PythonInterface/plugins/algorithms/SuggestTibHYSPEC.py b/Code/Mantid/Framework/PythonInterface/plugins/algorithms/SuggestTibHYSPEC.py index 64aa3a82fa35..53563069596c 100644 --- a/Code/Mantid/Framework/PythonInterface/plugins/algorithms/SuggestTibHYSPEC.py +++ b/Code/Mantid/Framework/PythonInterface/plugins/algorithms/SuggestTibHYSPEC.py @@ -1,7 +1,7 @@ #pylint: disable=no-init from mantid.api import PythonAlgorithm, AlgorithmFactory from mantid.kernel import FloatBoundedValidator,Direction,logger -from numpy import sqrt,divide +import numpy class SuggestTibHYSPEC(PythonAlgorithm): @@ -33,7 +33,7 @@ def PyInit(self): return def e2v(self,energy): - return sqrt(energy/5.227e-6) + return numpy.sqrt(energy/5.227e-6) def PyExec(self): """ Main execution body @@ -50,7 +50,7 @@ def PyExec(self): t_det_us = dist_mm /self.e2v(energy) * 1000 + T0_moderator frame_start_us = t_det_us - 16667/2 frame_end_us = t_det_us + 16667/2 - index_under_frame = divide(int(t_det_us),16667) + index_under_frame = numpy.divide(int(t_det_us),16667) pre_lead_us = 16667 * index_under_frame pre_tail_us = pre_lead_us + tail_length_us post_lead_us = 16667 * (1+ index_under_frame) diff --git a/Code/Mantid/Testing/SystemTests/tests/analysis/ARCSReductionTest.py b/Code/Mantid/Testing/SystemTests/tests/analysis/ARCSReductionTest.py index 271b291ddc0c..bca0a9fd1572 100644 --- a/Code/Mantid/Testing/SystemTests/tests/analysis/ARCSReductionTest.py +++ b/Code/Mantid/Testing/SystemTests/tests/analysis/ARCSReductionTest.py @@ -32,30 +32,28 @@ def runTest(self): self.nxspeFile=os.path.join(config.getString('defaultsave.directory'),'ARCSsystemtest.nxspe') config['default.facility']="SNS" DgsReduction( - SampleInputFile="ARCS_23961_event.nxs", - OutputWorkspace="reduced", - IncidentBeamNormalisation="ByCurrent", - DetectorVanadiumInputFile="WBARCS.nxs", - UseBoundsForDetVan=True, - DetVanIntRangeLow=0.35, - DetVanIntRangeHigh=0.75, - DetVanIntRangeUnits="Wavelength", - SaveProcessedDetVan=True, - SaveProcDetVanFilename=self.vanFile0, - ) + SampleInputFile="ARCS_23961_event.nxs", + OutputWorkspace="reduced", + IncidentBeamNormalisation="ByCurrent", + DetectorVanadiumInputFile="WBARCS.nxs", + UseBoundsForDetVan=True, + DetVanIntRangeLow=0.35, + DetVanIntRangeHigh=0.75, + DetVanIntRangeUnits="Wavelength", + SaveProcessedDetVan=True, + SaveProcDetVanFilename=self.vanFile0) DgsReduction( - SampleInputFile="ARCS_23961_event.nxs", - OutputWorkspace="reduced", - IncidentBeamNormalisation="ByCurrent", - DetectorVanadiumInputFile="WBARCS.nxs", - UseBoundsForDetVan=True, - DetVanIntRangeLow=0.35, - DetVanIntRangeHigh=0.75, - DetVanIntRangeUnits="Wavelength", - MedianTestLevelsUp=1., - SaveProcessedDetVan=True, - SaveProcDetVanFilename=self.vanFile1, - ) + SampleInputFile="ARCS_23961_event.nxs", + OutputWorkspace="reduced", + IncidentBeamNormalisation="ByCurrent", + DetectorVanadiumInputFile="WBARCS.nxs", + UseBoundsForDetVan=True, + DetVanIntRangeLow=0.35, + DetVanIntRangeHigh=0.75, + DetVanIntRangeUnits="Wavelength", + MedianTestLevelsUp=1., + SaveProcessedDetVan=True, + SaveProcDetVanFilename=self.vanFile1) Ei=mtd["reduced"].run().get("Ei").value SaveNXSPE(InputWorkspace="reduced",Filename=self.nxspeFile,Efixed=Ei,psi=0,KiOverKfScaling=True) @@ -74,7 +72,7 @@ def validate(self): DeleteWorkspace(van0) DeleteWorkspace(van1) self.assertTrue(os.path.exists(self.nxspeFile)) - nxspe=LoadNXSPE(self.nxspeFile) + LoadNXSPE(self.nxspeFile,OutputWorkspace='nxspe') self.disableChecking.append('Instrument') return 'nxspe','ARCSsystemtest.nxs' diff --git a/Code/Mantid/Testing/SystemTests/tests/analysis/CNCSReductionTest.py b/Code/Mantid/Testing/SystemTests/tests/analysis/CNCSReductionTest.py index cfd34da88b93..fed01a40dcdb 100644 --- a/Code/Mantid/Testing/SystemTests/tests/analysis/CNCSReductionTest.py +++ b/Code/Mantid/Testing/SystemTests/tests/analysis/CNCSReductionTest.py @@ -38,25 +38,23 @@ def runTest(self): GenerateGroupingPowder(InputWorkspace="sum",AngleStep=0.5,GroupingFilename=self.groupingFile) Ei=mtd['sum'].getRun()['EnergyRequest'].firstValue() tib=SuggestTibCNCS(Ei) - erange=str(-Ei)+','+str(0.01*Ei)+','+str(0.95*Ei) DgsReduction( - SampleInputWorkspace="sum", - OutputWorkspace="reduced", - EnergyTransferRange="-0.2,0.05,2.2", - GroupingFile=self.groupingFile, - IncidentBeamNormalisation="ByCurrent", - TimeIndepBackgroundSub=True, - TibTofRangeStart=tib[0], - TibTofRangeEnd=tib[1], - DetectorVanadiumInputFile="CNCS_51936_event.nxs", - UseBoundsForDetVan=True, - DetVanIntRangeLow=52000.0, - DetVanIntRangeHigh=53000.0, - DetVanIntRangeUnits="TOF", - SaveProcessedDetVan=True, - SaveProcDetVanFilename=self.vanFile, - ) + SampleInputWorkspace="sum", + OutputWorkspace="reduced", + EnergyTransferRange="-0.2,0.05,2.2", + GroupingFile=self.groupingFile, + IncidentBeamNormalisation="ByCurrent", + TimeIndepBackgroundSub=True, + TibTofRangeStart=tib[0], + TibTofRangeEnd=tib[1], + DetectorVanadiumInputFile="CNCS_51936_event.nxs", + UseBoundsForDetVan=True, + DetVanIntRangeLow=52000.0, + DetVanIntRangeHigh=53000.0, + DetVanIntRangeUnits="TOF", + SaveProcessedDetVan=True, + SaveProcDetVanFilename=self.vanFile) rotationdevice="SERotator2" psi=mtd["reduced"].run().get(rotationdevice).value[0] @@ -70,7 +68,7 @@ def validate(self): self.assertEqual(van.getNumberHistograms(),51200) DeleteWorkspace(van) self.assertTrue(os.path.exists(self.nxspeFile)) - nxspe=LoadNXSPE(self.nxspeFile) + LoadNXSPE(self.nxspeFile,OutputWorkspace='nxspe') self.disableChecking.append('Instrument') return 'nxspe','CNCSReduction_TIBasEvents.nxs' diff --git a/Code/Mantid/Testing/SystemTests/tests/analysis/HYSPECReductionTest.py b/Code/Mantid/Testing/SystemTests/tests/analysis/HYSPECReductionTest.py index f7825dd17cc6..0642cf4249e5 100644 --- a/Code/Mantid/Testing/SystemTests/tests/analysis/HYSPECReductionTest.py +++ b/Code/Mantid/Testing/SystemTests/tests/analysis/HYSPECReductionTest.py @@ -24,9 +24,9 @@ def runTest(self): Load(Filename='HYS_13656-13658',OutputWorkspace='sum') FilterByLogValue(InputWorkspace='sum',OutputWorkspace='sum1',LogName='s1',MinimumValue='0',MaximumValue='24.5',LogBoundary='Left') DeleteWorkspace('sum') - GenerateEventsFilter(InputWorkspace='sum1',OutputWorkspace='splboth',InformationWorkspace='info', + GenerateEventsFilter( InputWorkspace='sum1',OutputWorkspace='splboth',InformationWorkspace='info', UnitOfTime='Nanoseconds',LogName='s1',MaximumLogValue='24.5',LogValueInterval='3') - FilterEvents(InputWorkspace='sum1',OutputWorkspaceBaseName='split',InformationWorkspace='info', + FilterEvents( InputWorkspace='sum1',OutputWorkspaceBaseName='split',InformationWorkspace='info', SplitterWorkspace='splboth',FilterByPulseTime='1',GroupWorkspaces='1') DeleteWorkspace('split_unfiltered') DeleteWorkspace("splboth") @@ -37,7 +37,7 @@ def runTest(self): self.groupingFile=os.path.join(config.getString('defaultsave.directory'),'group4x2.xml') GenerateGroupingSNSInelastic(AlongTubes="4",AcrossTubes="2",Instrument="HYSPEC",Filename=self.groupingFile) config['default.facility']="SNS" - DgsReduction(SampleInputWorkspace='splitc',IncidentBeamNormalisation='ByCurrent', + DgsReduction( SampleInputWorkspace='splitc',IncidentBeamNormalisation='ByCurrent', OutputWorkspace='reduced',GroupingFile=self.groupingFile, TimeIndepBackgroundSub ='1',TibTofRangeStart =10400,TibTofRangeEnd =12400,IncidentEnergyGuess=50) DeleteWorkspace('splitc') @@ -48,7 +48,7 @@ def runTest(self): DeleteWorkspace('reduced') MergeMD(InputWorkspaces='md',OutputWorkspace='merged') DeleteWorkspace("md") - BinMD(InputWorkspace='merged',AxisAligned='0',BasisVector0='[H,0,0],in 1.079 A^-1,1,0,0,0', + BinMD( InputWorkspace='merged',AxisAligned='0',BasisVector0='[H,0,0],in 1.079 A^-1,1,0,0,0', BasisVector1='[0,K,0],in 0.97 A^-1,0,1,0,0',BasisVector2='[0,0,L],in 1.972 A^-1,0,0,1,0', BasisVector3='DeltaE,DeltaE,0,0,0,1', OutputExtents='-3,3,-2,6,-4,-1.5,-3,3',OutputBins='1,100,100,1',Parallel='1',OutputWorkspace='slice') diff --git a/Code/Mantid/Testing/SystemTests/tests/analysis/PEARLSystemTest.py b/Code/Mantid/Testing/SystemTests/tests/analysis/PEARLSystemTest.py index ab1c8c2bbe44..6ab06e3f02a1 100644 --- a/Code/Mantid/Testing/SystemTests/tests/analysis/PEARLSystemTest.py +++ b/Code/Mantid/Testing/SystemTests/tests/analysis/PEARLSystemTest.py @@ -138,22 +138,22 @@ def PearlLoadMon(self, files,ext,outname): def PEARL_getmonitor(self, number,ext,spline_terms=20): - works="monitor"+str(number) - self.PearlLoadMon(number,ext,works) - ConvertUnits(InputWorkspace=works,OutputWorkspace=works,Target="Wavelength") - lmin,lmax=self.PEARL_getlambdarange() - CropWorkspace(InputWorkspace=works,OutputWorkspace=works,XMin=lmin,XMax=lmax) - ex_regions=n.zeros((2,4)) - ex_regions[:,0]=[3.45,3.7] - ex_regions[:,1]=[2.96,3.2] - ex_regions[:,2]=[2.1,2.26] - ex_regions[:,3]=[1.73,1.98] - - for reg in range(0,4): - MaskBins(InputWorkspace=works,OutputWorkspace=works,XMin=ex_regions[0,reg],XMax=ex_regions[1,reg]) - - SplineBackground(InputWorkspace=works,OutputWorkspace=works,WorkspaceIndex=0,NCoeff=spline_terms) - return works + works="monitor"+str(number) + self.PearlLoadMon(number,ext,works) + ConvertUnits(InputWorkspace=works,OutputWorkspace=works,Target="Wavelength") + lmin,lmax=self.PEARL_getlambdarange() + CropWorkspace(InputWorkspace=works,OutputWorkspace=works,XMin=lmin,XMax=lmax) + ex_regions=n.zeros((2,4)) + ex_regions[:,0]=[3.45,3.7] + ex_regions[:,1]=[2.96,3.2] + ex_regions[:,2]=[2.1,2.26] + ex_regions[:,3]=[1.73,1.98] + + for reg in range(0,4): + MaskBins(InputWorkspace=works,OutputWorkspace=works,XMin=ex_regions[0,reg],XMax=ex_regions[1,reg]) + + SplineBackground(InputWorkspace=works,OutputWorkspace=works,WorkspaceIndex=0,NCoeff=spline_terms) + return works def PEARL_read(self, number,ext,outname): diff --git a/Code/Mantid/Testing/SystemTests/tests/analysis/ReduceOneSCD_Run.py b/Code/Mantid/Testing/SystemTests/tests/analysis/ReduceOneSCD_Run.py index 8a199dcfc649..f1e5a6fbf4e2 100644 --- a/Code/Mantid/Testing/SystemTests/tests/analysis/ReduceOneSCD_Run.py +++ b/Code/Mantid/Testing/SystemTests/tests/analysis/ReduceOneSCD_Run.py @@ -13,13 +13,9 @@ #information. # # -import os -import sys -import shutil import time import stresstesting -import numpy from mantid.api import * @@ -96,14 +92,13 @@ def runTest(self): FilterByTofMin=min_tof, FilterByTofMax=max_tof ) if (calibration_file_1 is not None) or (calibration_file_2 is not None): - LoadIsawDetCal( event_ws, - Filename=calibration_file_1) + LoadIsawDetCal(event_ws, Filename=calibration_file_1) monitor_ws = LoadNexusMonitors( Filename=full_name ) - integrated_monitor_ws = Integration( InputWorkspace=monitor_ws, - RangeLower=min_monitor_tof, RangeUpper=max_monitor_tof, - StartWorkspaceIndex=monitor_index, EndWorkspaceIndex=monitor_index ) + integrated_monitor_ws = Integration(InputWorkspace=monitor_ws, + RangeLower=min_monitor_tof, RangeUpper=max_monitor_tof, + StartWorkspaceIndex=monitor_index, EndWorkspaceIndex=monitor_index) monitor_count = integrated_monitor_ws.dataY(0)[0] print "\n", run, " has calculated monitor count", monitor_count, "\n" @@ -112,16 +107,16 @@ def runTest(self): # Make MD workspace using Lorentz correction, to find peaks # MDEW = ConvertToMD( InputWorkspace=event_ws, QDimensions="Q3D", - dEAnalysisMode="Elastic", QConversionScales="Q in A^-1", - LorentzCorrection='1', MinValues="-50,-50,-50", MaxValues="50,50,50", - SplitInto='2', SplitThreshold='50',MaxRecursionDepth='11' ) + dEAnalysisMode="Elastic", QConversionScales="Q in A^-1", + LorentzCorrection='1', MinValues="-50,-50,-50", MaxValues="50,50,50", + SplitInto='2', SplitThreshold='50',MaxRecursionDepth='11' ) # # Find the requested number of peaks. Once the peaks are found, we no longer # need the weighted MD event workspace, so delete it. # distance_threshold = 0.9 * 6.28 / float(max_d) peaks_ws = FindPeaksMD( MDEW, MaxPeaks=num_peaks_to_find, - PeakDistanceThreshold=distance_threshold ) + PeakDistanceThreshold=distance_threshold ) AnalysisDataService.remove( MDEW.getName() ) # SaveIsawPeaks( InputWorkspace=peaks_ws, AppendFile=False, @@ -169,22 +164,22 @@ def runTest(self): # LorentzCorrection to do the raw sphere integration ) # MDEW = ConvertToDiffractionMDWorkspace( InputWorkspace=event_ws, - LorentzCorrection='0', OutputDimensions='Q (lab frame)', - SplitInto='2', SplitThreshold='500', MaxRecursionDepth='5' ) + LorentzCorrection='0', OutputDimensions='Q (lab frame)', + SplitInto='2', SplitThreshold='500', MaxRecursionDepth='5' ) - peaks_ws = IntegratePeaksMD( InputWorkspace=MDEW, PeakRadius=peak_radius, - BackgroundOuterRadius=bkg_outer_radius, - BackgroundInnerRadius=bkg_inner_radius, - PeaksWorkspace=peaks_ws, - IntegrateIfOnEdge=integrate_if_edge_peak ) + peaks_ws = IntegratePeaksMD(InputWorkspace=MDEW, PeakRadius=peak_radius, + BackgroundOuterRadius=bkg_outer_radius, + BackgroundInnerRadius=bkg_inner_radius, + PeaksWorkspace=peaks_ws, + IntegrateIfOnEdge=integrate_if_edge_peak ) elif use_fit_peaks_integration: - event_ws = Rebin( InputWorkspace=event_ws, - Params=rebin_params, PreserveEvents=preserve_events ) + event_ws = Rebin(InputWorkspace=event_ws, + Params=rebin_params, PreserveEvents=preserve_events ) peaks_ws = PeakIntegration( InPeaksWorkspace=peaks_ws, InputWorkspace=event_ws, - IkedaCarpenterTOF=use_ikeda_carpenter, - MatchingRunNo=True, - NBadEdgePixels=n_bad_edge_pixels ) + IkedaCarpenterTOF=use_ikeda_carpenter, + MatchingRunNo=True, + NBadEdgePixels=n_bad_edge_pixels ) # # Save the final integrated peaks, using the Niggli reduced cell. # This is the only file needed, for the driving script to get a combined @@ -203,8 +198,8 @@ def runTest(self): run_conventional_integrate_file = self.output_directory + "/" + run + "_" + \ cell_type + "_" + centering + ".integrate" SelectCellOfType( PeaksWorkspace=peaks_ws, - CellType=cell_type, Centering=centering, - Apply=True, Tolerance=tolerance ) + CellType=cell_type, Centering=centering, + Apply=True, Tolerance=tolerance ) # UNCOMMENT the line below to get new output values if an algorithm changes #SaveIsawPeaks( InputWorkspace=peaks_ws, AppendFile=False, Filename=run_conventional_integrate_file ) SaveIsawUB( InputWorkspace=peaks_ws, Filename=self.run_conventional_matrix_file ) diff --git a/Code/Mantid/Testing/SystemTests/tests/analysis/SEQUOIAreduction.py b/Code/Mantid/Testing/SystemTests/tests/analysis/SEQUOIAreduction.py index 6e3167a1732e..bf9c55906db4 100644 --- a/Code/Mantid/Testing/SystemTests/tests/analysis/SEQUOIAreduction.py +++ b/Code/Mantid/Testing/SystemTests/tests/analysis/SEQUOIAreduction.py @@ -126,15 +126,15 @@ def CreateMasksAndVanadiumNormalization(self,vanfile,maskfile=''): if not os.path.isfile(os.path.join(self.customDataDir, "van.nx5")): LoadEventNexus(Filename=vanfile,OutputWorkspace="VAN") - Rebin(InputWorkspace="VAN",OutputWorkspace="VAN",Params="1000,15000,16000",PreserveEvents=False) #integrate all events between 1000 and 16000 microseconds - NormaliseByCurrent(InputWorkspace="VAN",OutputWorkspace="VAN") #normalize by proton charge - MedianDetectorTest(InputWorkspace="VAN",OutputWorkspace="MASK",SignificanceTest=100,HighThreshold =100) #determine which detectors to mask, and store them in the "MASK" workspace + Rebin(InputWorkspace="VAN",OutputWorkspace="VAN",Params="1000,15000,16000",PreserveEvents=False) + NormaliseByCurrent(InputWorkspace="VAN",OutputWorkspace="VAN") + MedianDetectorTest(InputWorkspace="VAN",OutputWorkspace="MASK",SignificanceTest=100,HighThreshold =100) if len(maskfile)>0: LoadNexus(Filename=maskfile,OutputWorkspace="temp_mask") - MaskDetectors(Workspace="MASK",MaskedWorkspace="temp_mask") #add detectors masked in "temp_mask" to "MASK" + MaskDetectors(Workspace="MASK",MaskedWorkspace="temp_mask") DeleteWorkspace(Workspace="temp_mask") - MaskDetectors(Workspace="VAN",MaskedWorkspace="MASK") #Mask "VAN". This prevents dividing by 0 - DeleteWorkspace(Workspace="MASK") #Mask is carried by VAN workspace + MaskDetectors(Workspace="VAN",MaskedWorkspace="MASK") + DeleteWorkspace(Workspace="MASK") SaveNexus(InputWorkspace="VAN",Filename=os.path.join(self.customDataDir,"van.nx5")) else: LoadNexus(Filename=os.path.join(self.customDataDir,"van.nx5"),OutputWorkspace="VAN") @@ -159,7 +159,6 @@ def runTest(self): V_file=os.path.join(self.customDataDir, 'SEQ_12384_event.nxs') Eguess=35.0 #initial energy guess Erange="-10.0,0.25,32.0" #Energy bins: Emin,Estep,Emax - datadir=self.customDataDir #Data directory outdir=self.customDataDir #Output directory fout_prefix="Ei_35.0_" ang_offset=0.0 @@ -173,62 +172,60 @@ def runTest(self): anglestep=1. #angle step - this can be fine tuned for pixel arc over detectors if maskandnormalize: - self.CreateMasksAndVanadiumNormalization(V_file,maskfile=maskfile) #Creates a worspaces for Vanadium normalization and masking + self.CreateMasksAndVanadiumNormalization(V_file,maskfile=maskfile) - [paths,runs]=self.LoadPathMaker(runs,self.customDataDir,'SEQ_','_event.nxs') #process teh runlist - for flist,rlist,i in zip(paths,runs,range(len(paths))): #rlist is the inner list of runnumbers - psitmp=[] + [paths,runs]=self.LoadPathMaker(runs,self.customDataDir,'SEQ_','_event.nxs') + for flist,rlist,i in zip(paths,runs,range(len(paths))): for f,j in zip(flist,range(len(flist))): if j==0: - LoadEventNexus(Filename=f,OutputWorkspace="IWS") #Load an event Nexus file - LoadNexusMonitors(Filename=f,OutputWorkspace="monitor_ws") #Load monitors + LoadEventNexus(Filename=f,OutputWorkspace="IWS") + LoadNexusMonitors(Filename=f,OutputWorkspace="monitor_ws") else: - LoadEventNexus(Filename=f,OutputWorkspace="IWS_temp") #Load an event Nexus file - LoadNexusMonitors(Filename=f,OutputWorkspace="monitor_ws_temp") #Load monitors - Plus(LHSWorkspace="IWS",RHSWorkspace="IWS_temp",OutputWorkspace="IWS") #Add events to the original workspcace - Plus(LHSWorkspace="monitor_ws",RHSWorkspace="monitor_ws_temp",OutputWorkspace="monitor_ws") #Add monitors to the original monitor workspcace + LoadEventNexus(Filename=f,OutputWorkspace="IWS_temp") + LoadNexusMonitors(Filename=f,OutputWorkspace="monitor_ws_temp") + Plus(LHSWorkspace="IWS",RHSWorkspace="IWS_temp",OutputWorkspace="IWS") + Plus(LHSWorkspace="monitor_ws",RHSWorkspace="monitor_ws_temp",OutputWorkspace="monitor_ws") #cleanup DeleteWorkspace("IWS_temp") DeleteWorkspace("monitor_ws_temp") - w=mtd["IWS"] - psi=array(w.getRun()[angle_name].value).mean()+ang_offset - FilterBadPulses(InputWorkspace="IWS",OutputWorkspace = "IWS",LowerCutoff = 50) # get psi before filtering bad pulses - [Efixed,T0]=self.GetEiT0("monitor_ws",Eguess) #Get Ei and -T0 using the function defined before - ChangeBinOffset(InputWorkspace="IWS",OutputWorkspace="OWS",Offset=T0) #Change all TOF by -T0 - NormaliseByCurrent(InputWorkspace="OWS",OutputWorkspace="OWS") #normalize by proton charge - ConvertUnits(InputWorkspace="OWS",OutputWorkspace="OWS",Target="Wavelength",EMode="Direct",EFixed=Efixed) #The algorithm for He3 tube efficiency requires wavelength units - He3TubeEfficiency(InputWorkspace="OWS",OutputWorkspace="OWS") #Apply correction due to absorption in He3 - ConvertUnits(InputWorkspace="OWS",OutputWorkspace="OWS",Target="DeltaE",EMode="Direct",EFixed=Efixed) #Switch to energy transfer - CorrectKiKf(InputWorkspace="OWS",OutputWorkspace="OWS") # apply ki/kf correction - Rebin(InputWorkspace="OWS",OutputWorkspace="OWST",Params=Erange,PreserveEvents=False) # go to histogram mode (forget events) - ConvertToDistribution(Workspace="OWST") #Convert to differential cross section by dividing by the energy bin width - DeleteWorkspace("OWS") - if maskandnormalize: - MaskDetectors(Workspace="OWST",MaskedWorkspace="VAN") #apply overall mask - # the following is commented, since it's the same run, not a real vanadium - #Divide(LHSWorkspace="OWST",RHSWorkspace="VAN",OutputWorkspace="OWST") #normalize by Vanadium, if desired - if do_powder: - if i==0: - mapping=self.createanglelist("OWST",anglemin,anglemax,anglestep) - GroupDetectors(InputWorkspace="OWST",OutputWorkspace="OWST",MapFile=os.path.join(self.customDataDir,"group.map"),Behaviour="Sum") - SolidAngle(InputWorkspace="OWST",OutputWorkspace="sa") - Divide(LHSWorkspace="OWST",RHSWorkspace="sa",OutputWorkspace="OWST") - DeleteWorkspace("sa") - barefname = "%s%d_%g" % (fout_prefix,rlist[0],psi) - fname_out = os.path.join(outdir, barefname) - if flag_spe: - SaveSPE(InputWorkspace="OWST",Filename=fname_out+".spe") #save the data in spe format. - if i==0: - SavePHX(InputWorkspace="OWST",Filename=fname_out+".spe") - if flag_nxspe: - #save in NXSPE format - nxspe_name = fname_out+".nxspe" - self._nxspe_filename = nxspe_name + w=mtd["IWS"] + psi=array(w.getRun()[angle_name].value).mean()+ang_offset + FilterBadPulses(InputWorkspace="IWS",OutputWorkspace = "IWS",LowerCutoff = 50) + [Efixed,T0]=self.GetEiT0("monitor_ws",Eguess) + ChangeBinOffset(InputWorkspace="IWS",OutputWorkspace="OWS",Offset=T0) + NormaliseByCurrent(InputWorkspace="OWS",OutputWorkspace="OWS") + ConvertUnits(InputWorkspace="OWS",OutputWorkspace="OWS",Target="Wavelength",EMode="Direct",EFixed=Efixed) + He3TubeEfficiency(InputWorkspace="OWS",OutputWorkspace="OWS") + ConvertUnits(InputWorkspace="OWS",OutputWorkspace="OWS",Target="DeltaE",EMode="Direct",EFixed=Efixed) + CorrectKiKf(InputWorkspace="OWS",OutputWorkspace="OWS") + Rebin(InputWorkspace="OWS",OutputWorkspace="OWST",Params=Erange,PreserveEvents=False) + ConvertToDistribution(Workspace="OWST") + DeleteWorkspace("OWS") + if maskandnormalize: + MaskDetectors(Workspace="OWST",MaskedWorkspace="VAN") if do_powder: - SaveNXSPE(InputWorkspace="OWST",Filename=nxspe_name,Efixed=Efixed,psi=psi,KiOverKfScaling=True, - ParFile=os.path.join(outdir, "group.par")) - else: - SaveNXSPE(InputWorkspace="OWST",Filename=nxspe_name,Efixed=Efixed,psi=psi,KiOverKfScaling=True) + if i==0: + dummy_mapping=self.createanglelist("OWST",anglemin,anglemax,anglestep) + GroupDetectors( InputWorkspace="OWST",OutputWorkspace="OWST", + MapFile=os.path.join(self.customDataDir,"group.map"),Behaviour="Sum") + SolidAngle(InputWorkspace="OWST",OutputWorkspace="sa") + Divide(LHSWorkspace="OWST",RHSWorkspace="sa",OutputWorkspace="OWST") + DeleteWorkspace("sa") + barefname = "%s%d_%g" % (fout_prefix,rlist[0],psi) + fname_out = os.path.join(outdir, barefname) + if flag_spe: + SaveSPE(InputWorkspace="OWST",Filename=fname_out+".spe") #save the data in spe format. + if i==0: + SavePHX(InputWorkspace="OWST",Filename=fname_out+".spe") + if flag_nxspe: + #save in NXSPE format + nxspe_name = fname_out+".nxspe" + self._nxspe_filename = nxspe_name + if do_powder: + SaveNXSPE(InputWorkspace="OWST",Filename=nxspe_name,Efixed=Efixed,psi=psi,KiOverKfScaling=True, + ParFile=os.path.join(outdir, "group.par")) + else: + SaveNXSPE(InputWorkspace="OWST",Filename=nxspe_name,Efixed=Efixed,psi=psi,KiOverKfScaling=True) def validate(self): #check if required files are created