diff --git a/neutronpy/instrument.py b/neutronpy/instrument.py index 74bf662..7ae033f 100644 --- a/neutronpy/instrument.py +++ b/neutronpy/instrument.py @@ -1057,6 +1057,12 @@ def calc_resolution_in_Q_coords(self, Q, W): else: s2theta = np.real(s2theta) + # correct sign of curvatures + monorh = monorh * sm + monorv = monorv * sm + anarh = anarh * sa + anarv = anarv * sa + thetas = s2theta / 2. phi = np.arctan2(-kf * np.sin(s2theta), ki - kf * np.cos(s2theta)) diff --git a/neutronpy/instrument_tools.py b/neutronpy/instrument_tools.py index 9c62823..77e1464 100644 --- a/neutronpy/instrument_tools.py +++ b/neutronpy/instrument_tools.py @@ -74,13 +74,13 @@ def ellipse(saxis1, saxis2, phi=0, origin=None, npts=31): def get_bragg_widths(RM): - bragg = [np.sqrt(8 * np.log(2)) / np.sqrt(RM[0, 0]), - np.sqrt(8 * np.log(2)) / np.sqrt(RM[1, 1]), - np.sqrt(8 * np.log(2)) / np.sqrt(RM[2, 2]), - get_phonon_width(0, RM, [0, 0, 0, 1])[1], - np.sqrt(8 * np.log(2)) / np.sqrt(RM[3, 3])] + bragg = np.array([np.sqrt(8 * np.log(2)) / np.sqrt(RM[0, 0]), + np.sqrt(8 * np.log(2)) / np.sqrt(RM[1, 1]), + np.sqrt(8 * np.log(2)) / np.sqrt(RM[2, 2]), + get_phonon_width(0, RM, [0, 0, 0, 1])[1], + np.sqrt(8 * np.log(2)) / np.sqrt(RM[3, 3])]) - return bragg + return bragg * 2 def get_phonon_width(r0, M, C): diff --git a/tests/test_resolution.py b/tests/test_resolution.py index 8bbf852..9389fe4 100644 --- a/tests/test_resolution.py +++ b/tests/test_resolution.py @@ -195,7 +195,7 @@ def test_cooper_nathans(self): NP = EXP.RMS R = EXP.R0 BraggWidths = get_bragg_widths(NP) - angles = self.EXP_popovici.get_angles_and_Q(hkle)[0] + angles = self.EXP_coopernathans.get_angles_and_Q(hkle)[0] ResVol = (2 * np.pi) ** 2 / np.sqrt(np.linalg.det(NP)) * 2 self.assertTrue(np.all(np.abs((RMS - NP)) < 100))