Skip to content
Snippets Groups Projects
Commit a31982f5 authored by Marina Ganeva's avatar Marina Ganeva
Browse files

Checks whether detector is masked.

parent d278965a
No related branches found
No related tags found
No related merge requests found
...@@ -97,10 +97,16 @@ class ComputeCalibrationCoefVan(PythonAlgorithm): ...@@ -97,10 +97,16 @@ class ComputeCalibrationCoefVan(PythonAlgorithm):
dataX = self.vanaws.readX(0) dataX = self.vanaws.readX(0)
coefY = np.zeros(nhist) coefY = np.zeros(nhist)
coefE = np.zeros(nhist) coefE = np.zeros(nhist)
instrument = self.vanaws.getInstrument()
detID_offset = self.get_detID_offset()
for idx in range(nhist): for idx in range(nhist):
prog_reporter.report("Setting %dth spectrum" % idx) prog_reporter.report("Setting %dth spectrum" % idx)
dataY = self.vanaws.readY(idx) dataY = self.vanaws.readY(idx)
if np.max(dataY) != 0: det = instrument.getDetector(idx + detID_offset)
if np.max(dataY) == 0 or det.isMasked():
coefY[idx] = 0.
coefE[idx] = 0.
else:
dataE = self.vanaws.readE(idx) dataE = self.vanaws.readE(idx)
peak_centre, sigma = mlzutils.do_fit_gaussian(self.vanaws, idx, self.log()) peak_centre, sigma = mlzutils.do_fit_gaussian(self.vanaws, idx, self.log())
fwhm = sigma*2.*np.sqrt(2.*np.log(2.)) fwhm = sigma*2.*np.sqrt(2.*np.log(2.))
...@@ -108,9 +114,6 @@ class ComputeCalibrationCoefVan(PythonAlgorithm): ...@@ -108,9 +114,6 @@ class ComputeCalibrationCoefVan(PythonAlgorithm):
idxmax = (np.fabs(dataX-peak_centre-3.*fwhm)).argmin() idxmax = (np.fabs(dataX-peak_centre-3.*fwhm)).argmin()
coefY[idx] = dwf[idx]*sum(dataY[idxmin:idxmax+1]) coefY[idx] = dwf[idx]*sum(dataY[idxmin:idxmax+1])
coefE[idx] = dwf[idx]*sum(dataE[idxmin:idxmax+1]) coefE[idx] = dwf[idx]*sum(dataE[idxmin:idxmax+1])
else:
coefY[idx] = 0.
coefE[idx] = 0.
# create X array, X data are the same for all detectors, so # create X array, X data are the same for all detectors, so
coefX = np.zeros(nhist) coefX = np.zeros(nhist)
...@@ -124,6 +127,12 @@ class ComputeCalibrationCoefVan(PythonAlgorithm): ...@@ -124,6 +127,12 @@ class ComputeCalibrationCoefVan(PythonAlgorithm):
self.setProperty("OutputWorkspace", outws) self.setProperty("OutputWorkspace", outws)
def get_detID_offset(self):
"""
returns ID of the first detector
"""
return self.vanaws.getSpectrum(0).getDetectorIDs()[0]
def calculate_dwf(self): def calculate_dwf(self):
""" """
Calculates Debye-Waller factor according to Calculates Debye-Waller factor according to
...@@ -134,11 +143,7 @@ class ComputeCalibrationCoefVan(PythonAlgorithm): ...@@ -134,11 +143,7 @@ class ComputeCalibrationCoefVan(PythonAlgorithm):
thetasort = np.zeros(nhist) # theta in radians !!!NOT 2Theta thetasort = np.zeros(nhist) # theta in radians !!!NOT 2Theta
instrument = self.vanaws.getInstrument() instrument = self.vanaws.getInstrument()
detID_offset = 0 detID_offset = self.get_detID_offset()
try:
instrument.getDetector(0)
except RuntimeError:
detID_offset = 1
for i in range(nhist): for i in range(nhist):
det = instrument.getDetector(i + detID_offset) det = instrument.getDetector(i + detID_offset)
......
...@@ -220,6 +220,5 @@ def do_fit_gaussian(workspace, index, logger): ...@@ -220,6 +220,5 @@ def do_fit_gaussian(workspace, index, logger):
logger.error(message) logger.error(message)
raise RuntimeError(message) raise RuntimeError(message)
result = param_table.column(1)[1:3]
# return list: [peak_centre, sigma] # return list: [peak_centre, sigma]
return result return param_table.column(1)[1:3]
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