Skip to content
Snippets Groups Projects
Commit 7c713b0f authored by Laurent Mercadier's avatar Laurent Mercadier
Browse files

rename xas variables, improve plotting

parent f5daddba
No related branches found
No related tags found
1 merge request!240Functions for Viking spectrometer analysis
...@@ -195,12 +195,12 @@ class Viking: ...@@ -195,12 +195,12 @@ class Viking:
std_err_ref = std_ref / np.sqrt(data_ref.sizes['trainId']) std_err_ref = std_ref / np.sqrt(data_ref.sizes['trainId'])
ds = xr.Dataset() ds = xr.Dataset()
ds['sample'] = spectrum ds['It'] = spectrum
ds['sample_std'] = std ds['It_std'] = std
ds['sample_std_err'] = std_err ds['It_std_err'] = std_err
ds['ref'] = spectrum_ref ds['I0'] = spectrum_ref
ds['ref_std'] = std ds['I0_std'] = std
ds['ref_std_err'] = std_err ds['I0_std_err'] = std_err
ds['absorption'] = spectrum_ref / spectrum ds['absorption'] = spectrum_ref / spectrum
ds['absorption_std'] = np.abs(ds['absorption']) * np.sqrt( ds['absorption_std'] = np.abs(ds['absorption']) * np.sqrt(
std_ref**2 / spectrum_ref**2 + std**2 / spectrum**2) std_ref**2 / spectrum_ref**2 + std**2 / spectrum**2)
...@@ -215,25 +215,28 @@ class Viking: ...@@ -215,25 +215,28 @@ class Viking:
return ds return ds
def plot_viking_xas(xas, plot_errors=True, xas_ylim=(-1, 3)): def plot_viking_xas(xas, plot_errors=True, xas_ylim=(-1, 3)):
fig, ax = plt.subplots(3, 1, figsize=(8,8), sharex=True) fig, ax = plt.subplots(3, 1, figsize=(7,7), sharex=True)
ax[0].plot(xas.newt_x, xas['ref']) ax[0].plot(xas.newt_x, xas['I0'])
ax[0].grid() ax[0].grid()
ax[0].set_title('I0 spectra')
ax[1].plot(xas.newt_x, xas['sample']) ax[1].plot(xas.newt_x, xas['It'])
ax[1].grid() ax[1].grid()
ax[1].set_title('It spectra')
ax[2].plot(xas.newt_x, xas['absorptionCoef']) ax[2].plot(xas.newt_x, xas['absorptionCoef'])
ax[2].set_ylim(*xas_ylim) ax[2].set_ylim(*xas_ylim)
ax[2].grid() ax[2].grid()
ax[2].set_title('XAS')
if plot_errors: if plot_errors:
ax[0].fill_between(xas.newt_x, ax[0].fill_between(xas.newt_x,
xas['ref'] - 1.96*xas['ref_std_err'], xas['I0'] - 1.96*xas['I0_std_err'],
xas['ref'] + 1.96*xas['ref_std_err'], xas['I0'] + 1.96*xas['I0_std_err'],
alpha=0.2) alpha=0.2)
ax[1].fill_between(xas.newt_x, ax[1].fill_between(xas.newt_x,
xas['sample'] - 1.96*xas['sample_std_err'], xas['It'] - 1.96*xas['It_std_err'],
xas['sample'] + 1.96*xas['sample_std_err'], xas['It'] + 1.96*xas['It_std_err'],
alpha=0.2) alpha=0.2)
ax[2].fill_between(xas.newt_x, ax[2].fill_between(xas.newt_x,
xas['absorptionCoef'] - 1.96*xas['absorptionCoef_stderr'], xas['absorptionCoef'] - 1.96*xas['absorptionCoef_stderr'],
......
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