Skip to content
Snippets Groups Projects
Commit 46401b9b authored by Harriet Brown's avatar Harriet Brown
Browse files

Correct CalculatePlaczekSelfScattering and POLARIS script

CalculatePlaczekSelfScattering outputs non-distrebution workspace
correction to CalculatePlaczekSelfScattering algorithm and POLARIS
_generate_grouped_ts_pdf function makes self scattering correction
to the correct order of magnetude after processing
parent 22010426
No related branches found
No related tags found
No related merge requests found
......@@ -117,7 +117,7 @@ void CalculatePlaczekSelfScattering::exec() {
std::vector<double> eps1;
const double lambdaD = 1.44;
for (size_t i = 0; i < xLambda.size() - 1; i++) {
double xTerm = (xLambda[i] + dx) / lambdaD;
double xTerm = -(xLambda[i] + dx) / lambdaD;
eps1.push_back(xTerm * exp(xTerm) / (1.0 - exp(xTerm)));
}
/* Placzek
......@@ -168,7 +168,7 @@ void CalculatePlaczekSelfScattering::exec() {
2.0 * (term1 + term2 - 3) * sinThetaBy2 * sinThetaBy2 *
summationTerm;
x[xIndex] = wavelength.singleToTOF(xLambda[xIndex]);
y[xIndex] = inelasticPlaczekSelfCorrection;
y[xIndex] = 1 + inelasticPlaczekSelfCorrection;
}
x.back() = wavelength.singleToTOF(xLambda.back());
} else {
......@@ -181,6 +181,7 @@ void CalculatePlaczekSelfScattering::exec() {
}
auto incidentUnit = inWS->getAxis(0)->unit();
outputWS->getAxis(0)->unit() = incidentUnit;
outputWS->setDistribution(FALSE);
setProperty("OutputWorkspace", outputWS);
}
......
......@@ -151,16 +151,14 @@ def _generate_grouped_ts_pdf(run_number, focused_ws, q_lims, cal_file_name, samp
width_x = (max_x-min_x)/x_data.size
fit_spectra = mantid.FitIncidentSpectrum(InputWorkspace=monitor,
BinningForCalc=[min_x, 1*width_x, max_x],
BinningForFit=[min_x, 1*width_x, max_x],
BinningForFit=[min_x, 10*width_x, max_x],
FitSpectrumWith="CubicSpline")
placzek = mantid.CalculatePlaczekSelfScattering(InputWorkspace=raw_ws, IncidentSpecta=fit_spectra)
mantid.ConvertFromDistribution(Workspace=placzek)
cal_workspace = mantid.LoadCalFile(InputWorkspace=placzek,
CalFileName=cal_file_name,
Workspacename='cal_workspace',
MakeOffsetsWorkspace=False,
MakeMaskWorkspace=False)
placzek = mantid.AlignDetectors(InputWorkspace=placzek, CalibrationFile=cal_file_name)
placzek = mantid.DiffractionFocussing(InputWorkspace=placzek, GroupingFilename=cal_file_name)
n_pixel = np.zeros(placzek.getNumberHistograms())
for i in range(cal_workspace.getNumberHistograms()):
......@@ -169,8 +167,10 @@ def _generate_grouped_ts_pdf(run_number, focused_ws, q_lims, cal_file_name, samp
n_pixel[int(grouping[0]-1)] += 1
correction_ws = mantid.CreateWorkspace(DataY=n_pixel, DataX=[0, 1], NSpec=placzek.getNumberHistograms())
placzek = mantid.Divide(LHSWorkspace=placzek, RHSWorkspace=correction_ws)
mantid.ConvertToDistribution(Workspace=placzek)
placzek = mantid.ConvertUnits(InputWorkspace=placzek, Target="MomentumTransfer", EMode='Elastic')
placzek = mantid.RebinToWorkspace(WorkspaceToRebin=placzek, WorkspaceToMatch=focused_data_combined)
mantid.ConvertFromDistribution(Workspace=placzek)
mantid.Subtract(LHSWorkspace=focused_data_combined,
RHSWorkspace=placzek,
OutputWorkspace=focused_data_combined)
......@@ -197,10 +197,10 @@ def _generate_grouped_ts_pdf(run_number, focused_ws, q_lims, cal_file_name, samp
q_min[i] = pdf_x_array[np.amin(np.where(pdf_x_array >= q_min[i]))]
q_max[i] = pdf_x_array[np.amax(np.where(pdf_x_array <= q_max[i]))]
bin_width = min(pdf_x_array[1] - pdf_x_array[0], bin_width)
focused_data_combined = mantid.CropWorkspaceRagged(InputWorkspace=focused_data_combined, XMin=q_min, XMax=q_max)
mantid.MatchSpectra(InputWorkspace=focused_data_combined,
OutputWorkspace=focused_data_combined,
ReferenceSpectrum=1)
focused_data_combined = mantid.CropWorkspaceRagged(InputWorkspace=focused_data_combined, XMin=q_min, XMax=q_max)
focused_data_combined = mantid.Rebin(InputWorkspace=focused_data_combined,
Params=[min(q_min), bin_width, max(q_max)])
focused_data_combined = mantid.SumSpectra(InputWorkspace=focused_data_combined,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment