Skip to content

Commit d0d061b

Browse files
committed
Powder pattern: only plot diff below max(sin(theta)/lambda)
1 parent eb15ac3 commit d0d061b

File tree

2 files changed

+128
-108
lines changed

2 files changed

+128
-108
lines changed

Diff for: examples/structure-solution-powder-pbso4.ipynb

+121-105
Large diffs are not rendered by default.

Diff for: src/pyobjcryst/powderpattern.py

+7-3
Original file line numberDiff line numberDiff line change
@@ -121,21 +121,25 @@ def plot(self, diff=None, hkl=None, figsize=(9, 4), fontsize_hkl=6, reset=False,
121121
plt.figure(figsize=figsize)
122122
plt.plot(x, obs, 'k', label='obs', linewidth=1)
123123
plt.plot(x, calc, 'r', label='calc', linewidth=1)
124+
m = self.GetMaxSinThetaOvLambda() * self.GetWavelength()
125+
mtth = np.rad2deg(np.arcsin(m)) * 2
124126
if plot_diff:
125-
plt.plot(x, calc - obs - obs.max() / 20, 'g', label='calc-obs',
127+
diff = calc - obs - obs.max() / 20
128+
# Mask difference above max sin(theta)/lambda
129+
diff = np.ma.masked_array(diff, x > mtth)
130+
plt.plot(x, diff, 'g', label='calc-obs',
126131
linewidth=0.5)
127132

128133
plt.legend(loc='upper right')
129134
if self.GetName() != "":
130135
plt.title("PowderPattern: %s" % self.GetName())
131136

132-
m = self.GetMaxSinThetaOvLambda() * self.GetWavelength()
133137
if self._plot_ylim is not None:
134138
plt.ylim(self._plot_ylim)
135139
if self._plot_xlim is not None:
136140
plt.xlim(self._plot_xlim)
137141
elif m < 1:
138-
plt.xlim(x.min(), np.rad2deg(np.arcsin(m)) * 2)
142+
plt.xlim(x.min(), mtth)
139143

140144
if plot_hkl:
141145
self._do_plot_hkl(nb_max=100, fontsize_hkl=fontsize_hkl)

0 commit comments

Comments
 (0)