diff --git a/src/toolbox_scs/detectors/viking.py b/src/toolbox_scs/detectors/viking.py index 8afc56552160457e22301fc92b655685200c0e53..6bcf553eda1ec1f3952e57384787f5b130828de2 100644 --- a/src/toolbox_scs/detectors/viking.py +++ b/src/toolbox_scs/detectors/viking.py @@ -8,8 +8,8 @@ from .hrixs import gauss1d __all__ = ['Viking'] -def plot_viking_xas(xas, plot_errors=True, xas_ylim=(-1, 3)): - fig, ax = plt.subplots(3, 1, figsize=(7, 7), sharex=True) +def plot_viking_xas(xas, plot_errors=True, xas_ylim=(-1, 4)): + fig, ax = plt.subplots(4, 1, figsize=(7, 9), sharex=True) ax[0].plot(xas.newt_x, xas['I0']) ax[0].grid() ax[0].set_title('I0 spectra') @@ -18,10 +18,14 @@ def plot_viking_xas(xas, plot_errors=True, xas_ylim=(-1, 3)): ax[1].grid() ax[1].set_title('It spectra') - ax[2].plot(xas.newt_x, xas['absorptionCoef']) - ax[2].set_ylim(*xas_ylim) + ax[2].plot(xas.newt_x, xas['It'] / xas['I0']) ax[2].grid() - ax[2].set_title('XAS') + ax[2].set_title('Transmission It / I0') + + ax[3].plot(xas.newt_x, xas['absorptionCoef']) + ax[3].set_ylim(*xas_ylim) + ax[3].grid() + ax[3].set_title('XAS -log(It/I0)/thickness') if plot_errors: ax[0].fill_between(xas.newt_x, @@ -32,7 +36,7 @@ def plot_viking_xas(xas, plot_errors=True, xas_ylim=(-1, 3)): xas['It'] - 1.96*xas['It_stderr'], xas['It'] + 1.96*xas['It_stderr'], alpha=0.2) - ax[2].fill_between(xas.newt_x, + ax[3].fill_between(xas.newt_x, xas['absorptionCoef'] - 1.96*xas['absorptionCoef_stderr'], xas['absorptionCoef'] + 1.96*xas['absorptionCoef_stderr'], alpha=0.2) @@ -169,6 +173,7 @@ class Viking: roi = {'newton': {'newton': {'roi': (self.Y_RANGE, self.X_RANGE), 'dim': ['newt_y', 'newt_x']}}} run, newton = tb.load(self.PROPOSAL, runNB, 'newton', rois=roi) + newton = newton.shift(trainId=-1).astype(float) #load the rest fields = [f for f in self.FIELDS if f != 'newton'] @@ -178,8 +183,8 @@ class Viking: run, data = tb.load(self.PROPOSAL, runNB, fields=fields) data = data.merge(newton, join='inner') - data = data.assign_coords(newt_x=np.polyval(self.ENERGY_CALIB, - data['newt_x'])) + calib = np.polyval(self.ENERGY_CALIB, np.arange(0, 2048)) + data = data.assign_coords(newt_x=calib[self.X_RANGE]) if add_attrs: params = self.get_camera_params(run) for k, v in params.items():