Ticket #8977: check_calculate_transmission.py

File check_calculate_transmission.py, 1.4 KB (added by Gesner Passos, 7 years ago)
Line 
1from mantid.simpleapi import * 
2#prepare data to the input of CalculateTransmission
3ws = LoadRaw("LOQ48097.raw", SpectrumMin=1, SpectrumMax=2);
4ws = ConvertUnits(ws, Target="Wavelength")
5m_dirWS = Rebin(ws, "6, 0.01, 7.5",OutputWorkspace="CalculateTransmissionTest_direct")
6m_transWS = Rebin(ws, "7.5, 0.01, 9",OutputWorkspace="CalculateTransmissionTest_trans")
7m_dirWS.setX(0, m_transWS.dataX(0))
8m_dirWS.setX(1, m_transWS.dataX(0))
9
10outlog = CalculateTransmission(m_transWS, m_dirWS, 1, 2,FitMethod='Log',OutputUnfittedData=True)
11out2 = CalculateTransmission(m_transWS, m_dirWS, 1, 2,FitMethod='Polynomial', PolynomialOrder=2,OutputUnfittedData=True)
12outlinear = CalculateTransmission(m_transWS, m_dirWS, 1, 2,FitMethod='Linear',OutputUnfittedData=True)
13
14
15unfitted = mtd['outlog_unfitted']
16unf_log = Logarithm(unfitted, Natural=True)
17func_name ='name=LinearBackground'
18func_name = "name=Polynomial,n=2"
19Fit(Function=func_name, InputWorkspace=unf_log, CreateOutput=True, Output='unf_log_fit')
20unf_log_fit = ExtractSingleSpectrum('unf_log_fit_Workspace',1)
21fitted = Exponential(unf_log_fit)
22
23fitted_err = CreateWorkspace(range(len(fitted.dataE(0))),fitted.dataE(0))
24out2 = out2[0]
25calc_err = CreateWorkspace(range(len(fitted.dataE(0))),out2.dataE(0))
26
27
28# if you plot outlog, out2 and outlinear they should be similar.
29
30# fitted and out2 should be identical (the error will be slightly different due to an error to be dealt in #9011