def runTest(self): ws = DirectILLCollectData('ILL/IN6/164192.nxs', ElasticChannel='Default Elastic Channel', FlatBkg='Flat Bkg OFF', Normalisation='Normalisation OFF') for i in range(ws.getNumberHistograms()): ws.dataY(i).fill(1) dE = ConvertUnits(ws, 'DeltaE', 'Direct') corr = DetectorEfficiencyCorUser(dE) Ei = corr.run().get('Ei').value def det_corr(x): high = x > 5.113 low = x <= 5.113 c = numpy.empty_like(x) c[high] = 0.94 * (1. - numpy.exp(-3.284 / numpy.sqrt(x[high]))) c[low] = numpy.exp(-0.0565 / numpy.sqrt(x[low])) * ( 1. - numpy.exp(-3.284 / numpy.sqrt(x[low]))) return c corr_at_Ei = det_corr(numpy.array([Ei]))[0] for i in range(corr.getNumberHistograms()): x = (corr.readX(i)[:-1] + corr.readX(i)[1:]) / 2. e = Ei - x numpy.testing.assert_almost_equal(corr.readY(i), corr_at_Ei / det_corr(e))
def runTest(self): ws = DirectILLCollectData('ILL/IN4/084446.nxs', ElasticChannel='Default Elastic Channel', FlatBkg='Flat Bkg OFF', Normalisation='Normalisation OFF') for i in range(ws.getNumberHistograms()): ws.dataY(i).fill(1) dE = ConvertUnits(ws, 'DeltaE', 'Direct') corr = DetectorEfficiencyCorUser(dE) Ei = corr.run().get('Ei').value def rosace_corr(x): return 1.0 - numpy.exp(-6.1343 / numpy.sqrt(x)) def wide_angle_corr(x): return 0.951 * numpy.exp(-0.0887 / numpy.sqrt(x)) * (1 - numpy.exp(-5.597 / numpy.sqrt(x))) def eff_factor(x, corr_func): return corr_func(Ei) / corr_func(x) # Wide-angle detectors are at ws indices 0-299 for i in range(0, 300): x = (corr.readX(i)[:-1] + corr.readX(i)[1:]) / 2. e = Ei - x assert_almost_equal(corr.readY(i), eff_factor(e, wide_angle_corr)) # Rosace detectors are at ws indices 300-395 for i in range(300, 396): x = (corr.readX(i)[:-1] + corr.readX(i)[1:]) / 2. e = Ei - x assert_almost_equal(corr.readY(i), eff_factor(e, rosace_corr))
def runTest(self): config['default.facility'] = 'ILL' config['default.instrument'] = 'IN4' DirectILLCollectData(Run='ILL/IN4/085801-085802.nxs', OutputWorkspace='vanadium', OutputEPPWorkspace='vanadium-epps', OutputRawWorkspace='vanadium-raw', MonitorPeakWidthInSigmas=3.0) DirectILLIntegrateVanadium(InputWorkspace='vanadium', OutputWorkspace='integrated', EPPWorkspace='vanadium-epps') DirectILLDiagnostics( InputWorkspace='vanadium-raw', OutputWorkspace='diagnostics', SubalgorithmLogging='Logging ON', EPPWorkspace='vanadium-epps', ) # Samples DirectILLCollectData(Run='ILL/IN4/087294+087295.nxs', OutputWorkspace='sample', OutputIncidentEnergyWorkspace='Ei', OutputElasticChannelWorkspace='Elp', MonitorPeakWidthInSigmas=3.0) # Containers DirectILLCollectData(Run='ILL/IN4/087306-087309.nxs', OutputWorkspace='container', IncidentEnergyWorkspace='Ei', ElasticChannelWorkspace='Elp', MonitorPeakWidthInSigmas=3.0) geometry = { 'Shape': 'HollowCylinder', 'Height': 4.0, 'InnerRadius': 1.9, 'OuterRadius': 2.0, 'Center': [0.0, 0.0, 0.0] } material = {'ChemicalFormula': 'Cd S', 'SampleNumberDensity': 0.01} SetSample('sample', geometry, material) DirectILLSelfShielding(InputWorkspace='sample', OutputWorkspace='corrections', EventsPerPoint=20000) DirectILLApplySelfShielding( InputWorkspace='sample', OutputWorkspace='corrected', SelfShieldingCorrectionWorkspace='corrections', EmptyContainerWorkspace='container') DirectILLReduction(InputWorkspace='corrected', OutputWorkspace='SofQW', IntegratedVanadiumWorkspace='integrated', DiagnosticsWorkspace='diagnostics') CropWorkspace(InputWorkspace='SofQW', OutputWorkspace='cropped', XMin=1., XMax=2.75, StartWorkspaceIndex=83, EndWorkspaceIndex=222) # The 'run_title' property has been deliberately erased from the test numor. # We need to add it manually because Save/LoadNexus will do the same for # the reference file. mtd['cropped'].mutableRun().addProperty('run_title', '', True)
def runTest(self): ws = DirectILLCollectData('ILL/IN4/084446.nxs', ElasticChannel='Default Elastic Channel', FlatBkg='Flat Bkg OFF', Normalisation='Normalisation OFF') for i in range(ws.getNumberHistograms()): ws.dataY(i).fill(1) dE = ConvertUnits(ws, 'DeltaE', 'Direct') corr = DetectorEfficiencyCorUser(dE) Ei = corr.run().get('Ei').value def rosace_corr(x): return 1.0 - numpy.exp(-6.1343 / numpy.sqrt(x)) def wide_angle_corr(x): return 0.951 * numpy.exp(-0.0887 / numpy.sqrt(x)) * (1 - numpy.exp(-5.597 / numpy.sqrt(x))) def eff_factor(x, corr_func): return corr_func(Ei) / corr_func(x) # Wide-angle detectors are at ws indices 0-299 for i in range(0, 300): x = (corr.readX(i)[:-1] + corr.readX(i)[1:]) / 2. e = Ei - x numpy.testing.assert_almost_equal(corr.readY(i), eff_factor(e, wide_angle_corr)) # Rosace detectors are at ws indices 300-395 for i in range(300, 396): x = (corr.readX(i)[:-1] + corr.readX(i)[1:]) / 2. e = Ei - x numpy.testing.assert_almost_equal(corr.readY(i), eff_factor(e, rosace_corr))
def runTest(self): config['default.facility'] = 'ILL' config['default.instrument'] = 'IN5' DirectILLCollectData( Run='ILL/IN5/095893.nxs', OutputWorkspace='vanadium', OutputEPPWorkspace='vanadium-epps', ) DirectILLDiagnostics(InputWorkspace='vanadium', OutputWorkspace='diagnostics', MaskedComponents='tube_320') DirectILLTubeBackground(InputWorkspace='vanadium', OutputWorkspace='bkg', EPPWorkspace='vanadium-epps', DiagnosticsWorkspace='diagnostics') Subtract(LHSWorkspace='vanadium', RHSWorkspace='bkg', OutputWorkspace='vanadium') DeleteWorkspace('bkg') DirectILLIntegrateVanadium(InputWorkspace='vanadium', OutputWorkspace='integrated', EPPWorkspace='vanadium-epps') DeleteWorkspace('vanadium') DeleteWorkspace('vanadium-epps') DirectILLCollectData(Run='ILL/IN5/096003.nxs', OutputWorkspace='sample', OutputEppWorkspace='epps') DirectILLTubeBackground(InputWorkspace='sample', OutputWorkspace='bkg', EPPWorkspace='epps', DiagnosticsWorkspace='diagnostics') Subtract(LHSWorkspace='sample', RHSWorkspace='bkg', OutputWorkspace='sample') DirectILLReduction(InputWorkspace='sample', OutputWorkspace='SofQW', IntegratedVanadiumWorkspace='integrated', DiagnosticsWorkspace='diagnostics') CropWorkspace(InputWorkspace='SofQW', OutputWorkspace='cropped', XMin=0.5, XMax=2.1, StartWorkspaceIndex=375, EndWorkspaceIndex=720) # The 'run_title' property has been deliberately erased from the test numor. # We need to add it manually because Save/LoadNexus will do the same for # the reference file. mtd['cropped'].mutableRun().addProperty('run_title', '', True)
def runTest(self): ws = DirectILLCollectData('ILL/IN5/104007.nxs', ElasticChannel='Default Elastic Channel', FlatBkg='Flat Bkg OFF', Normalisation='Normalisation OFF') for i in range(ws.getNumberHistograms()): ws.dataY(i).fill(1) dE = ConvertUnits(ws, 'DeltaE', 'Direct') corr = DetectorEfficiencyCorUser(dE) Ei = corr.run().get('Ei').value def tube_corr(x): return 1. - numpy.exp(-5.6 / numpy.sqrt(x)) corr_at_Ei = tube_corr(Ei) for i in range(corr.getNumberHistograms()): x = (corr.readX(i)[:-1] + corr.readX(i)[1:]) / 2. e = Ei - x assert_almost_equal(corr.readY(i), corr_at_Ei / tube_corr(e))
def runTest(self): ws = DirectILLCollectData('ILL/IN5/104007.nxs', ElasticChannel='Default Elastic Channel', FlatBkg='Flat Bkg OFF', Normalisation='Normalisation OFF') for i in range(ws.getNumberHistograms()): ws.dataY(i).fill(1) dE = ConvertUnits(ws, 'DeltaE', 'Direct') corr = DetectorEfficiencyCorUser(dE) Ei = corr.run().get('Ei').value def tube_corr(x): return 1. - numpy.exp(-5.6 / numpy.sqrt(x)) corr_at_Ei = tube_corr(Ei) for i in range(corr.getNumberHistograms()): x = (corr.readX(i)[:-1] + corr.readX(i)[1:]) / 2. e = Ei - x numpy.testing.assert_almost_equal(corr.readY(i), corr_at_Ei / tube_corr(e))
def runTest(self): config['default.facility'] = 'ILL' config['default.instrument'] = 'IN6' DirectILLCollectData(Run='ILL/IN6/164192.nxs', OutputWorkspace='vanadium', OutputEPPWorkspace='vanadium-epps', OutputRawWorkspace='vanadium-raw') DirectILLIntegrateVanadium(InputWorkspace='vanadium', OutputWorkspace='integrated', EPPWorkspace='vanadium-epps') DirectILLDiagnostics( InputWorkspace='vanadium-raw', OutputWorkspace='diagnostics', EPPWorkspace='vanadium-epps', ) # Simulate sample with vanadium DirectILLCollectData(Run='ILL/IN6/164192.nxs', OutputWorkspace='sample') DirectILLReduction(InputWorkspace='sample', OutputWorkspace='SofQW', IntegratedVanadiumWorkspace='integrated', EnergyRebinningParams='-100, 0.01, 4.', DiagnosticsWorkspace='diagnostics') CropWorkspace(InputWorkspace='SofQW', OutputWorkspace='cropped', XMin=0.7, XMax=2.1, StartWorkspaceIndex=9588, EndWorkspaceIndex=10280) # GetEiMonDet produces slightly different results on different system. We better # check the calibrated energy logs here and set them to fixed values to # enable CompareWorkspaces to do its job. This hack could be removed later if # CompareWorkspaces supported tolerances for sample log comparison. ws = mtd['cropped'] run = ws.mutableRun() self.assertAlmostEqual(run.getProperty('Ei').value, 4.72233, places=4) run.addProperty('Ei', 4.72, True) self.assertAlmostEqual(run.getProperty('wavelength').value, 4.16207, places=4) run.addProperty('wavelength', 4.16, True) # The 'run_title' property has been deliberately erased from the test numor. # We need to add it manually because Save/LoadNexus will do the same for # the reference file. mtd['cropped'].mutableRun().addProperty('run_title', '', True)
def setUpClass(cls): workspace = DirectILLCollectData( 'ILL/IN4/084446.nxs', EPPCreationMethod='Calculate EPP', IncidentEnergyCalibration='Energy Calibration OFF', FlatBkg='Flat Bkg OFF', Normalisation='Normalisation OFF', StoreInADS=False) cls._sqw = DirectILLReduction(workspace, OutputWorkspace='unused', StoreInADS=False)
def runTest(self): ws = DirectILLCollectData('ILL/IN6/164192.nxs', ElasticChannel='Default Elastic Channel', FlatBkg='Flat Bkg OFF', Normalisation='Normalisation OFF') for i in range(ws.getNumberHistograms()): ws.dataY(i).fill(1) dE = ConvertUnits(ws, 'DeltaE', 'Direct') corr = DetectorEfficiencyCorUser(dE) Ei = corr.run().get('Ei').value def det_corr(x): high = x > 5.113 low = x <= 5.113 c = numpy.empty_like(x) c[high] = 0.94 * (1. - numpy.exp(-3.284/numpy.sqrt(x[high]))) c[low] = numpy.exp(-0.0565 / numpy.sqrt(x[low])) * (1.- numpy.exp(-3.284 / numpy.sqrt(x[low]))) return c corr_at_Ei = det_corr(numpy.array([Ei]))[0] for i in range(corr.getNumberHistograms()): x = (corr.readX(i)[:-1] + corr.readX(i)[1:]) / 2. e = Ei - x numpy.testing.assert_almost_equal(corr.readY(i), corr_at_Ei / det_corr(e))
def runTest(self): run = 'ILL/IN5/176053.nxs' DirectILLCollectData(Run=run, Normalisation='Normalisation Time', OutputIncidentEnergyWorkspace='Ei', OutputElasticChannelWorkspace='Elc', OutputWorkspace='raw', OutputEPPWorkspace='Epp') ws = Load(run, ConvertToTOF=True) self.ecrase(ws) DirectILLCollectData(InputWorkspace='ws', Normalisation='Normalisation Time', IncidentEnergyWorkspace='Ei', ElasticChannelWorkspace='Elc', OutputWorkspace='Eone') DirectILLReduction(InputWorkspace='Eone', EnergyRebinning='a', QBinningParams='', OutputWorkspace='red')
def test_plotconstE_and_plotconstQ_plot_equal_value_at_crossing(self): DirectILLCollectData( Run='ILL/IN4/084447.nxs', OutputWorkspace='sample', IncidentEnergyCalibration='Energy Calibration OFF', FlatBkg='Flat Bkg OFF', ) DirectILLReduction(InputWorkspace='sample', OutputWorkspace='reduced') Q = 2.5 figure, axes, cuts = directtools.plotconstQ('reduced', Q, 0.01) lineDataQ = axes.get_lines()[0].get_data() E = 2.2 figure, axes, cuts = directtools.plotconstE('reduced', E, 0.01) lineDataE = axes.get_lines()[0].get_data() indexE = numpy.argmin(numpy.abs(lineDataQ[0] - E)) indexQ = numpy.argmin(numpy.abs(lineDataE[0] - Q)) self.assertEquals(lineDataQ[1][indexE], lineDataE[1][indexQ])