Skip to content

Commit

Permalink
Few python files modified by hand. Refs #11293
Browse files Browse the repository at this point in the history
  • Loading branch information
AndreiSavici committed Mar 9, 2015
1 parent db83eac commit a38ba81
Show file tree
Hide file tree
Showing 7 changed files with 135 additions and 147 deletions.
@@ -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):
Expand Down Expand Up @@ -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
Expand All @@ -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)
Expand Down
46 changes: 22 additions & 24 deletions Code/Mantid/Testing/SystemTests/tests/analysis/ARCSReductionTest.py
Expand Up @@ -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)
Expand All @@ -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'
Expand Down
34 changes: 16 additions & 18 deletions Code/Mantid/Testing/SystemTests/tests/analysis/CNCSReductionTest.py
Expand Up @@ -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]
Expand All @@ -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'
Expand Down
Expand Up @@ -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")
Expand All @@ -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')
Expand All @@ -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')
Expand Down
32 changes: 16 additions & 16 deletions Code/Mantid/Testing/SystemTests/tests/analysis/PEARLSystemTest.py
Expand Up @@ -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):
Expand Down
49 changes: 22 additions & 27 deletions Code/Mantid/Testing/SystemTests/tests/analysis/ReduceOneSCD_Run.py
Expand Up @@ -13,13 +13,9 @@
#information.
#
#
import os
import sys
import shutil
import time

import stresstesting
import numpy


from mantid.api import *
Expand Down Expand Up @@ -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"
Expand All @@ -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,
Expand Down Expand Up @@ -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
Expand All @@ -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 )
Expand Down

0 comments on commit a38ba81

Please sign in to comment.