Skip to content
Snippets Groups Projects
Commit 0bd1497f authored by Loïc Le Guyader's avatar Loïc Le Guyader
Browse files

Merge branch 'xas_bin_centers' into 'master'

Returns bin center instead of energy mean in xas()

Closes #9

See merge request !84
parents 44491d94 cab9bd35
No related branches found
No related tags found
2 merge requests!85import updates from master,!84Returns bin center instead of energy mean in xas()
...@@ -138,7 +138,7 @@ def xas(nrun, bins=None, Iokey='SCS_SA3', Itkey='MCP3apd', nrjkey='nrj', ...@@ -138,7 +138,7 @@ def xas(nrun, bins=None, Iokey='SCS_SA3', Itkey='MCP3apd', nrjkey='nrj',
Outputs: Outputs:
a dictionnary containing: a dictionnary containing:
nrj: the mean of photon energy in each bin nrj: the bin centers
muA: the absorption muA: the absorption
sigmaA: standard deviation on the absorption sigmaA: standard deviation on the absorption
sterrA: standard error on the absorption sterrA: standard error on the absorption
...@@ -193,12 +193,11 @@ def xas(nrun, bins=None, Iokey='SCS_SA3', Itkey='MCP3apd', nrjkey='nrj', ...@@ -193,12 +193,11 @@ def xas(nrun, bins=None, Iokey='SCS_SA3', Itkey='MCP3apd', nrjkey='nrj',
bins_c = 0.5*(bins[1:] + bins[:-1]) bins_c = 0.5*(bins[1:] + bins[:-1])
bin_idx = np.digitize(rundata['nrj'], bins) bin_idx = np.digitize(rundata['nrj'], bins)
nrj = np.array([ np.mean(rundata['nrj'][idx+1==bin_idx]) for idx in range(len(bins)-1)])
if plot: if plot:
f = plt.figure(figsize=(6.5,6)) f = plt.figure(figsize=(6.5,6))
gs = gridspec.GridSpec(2,1,height_ratios=[4,1]) gs = gridspec.GridSpec(2,1,height_ratios=[4,1])
ax1 = plt.subplot(gs[0]) ax1 = plt.subplot(gs[0])
ax1.plot(nrj, muA, color='C1', label=r'$\sigma$') ax1.plot(bins_c, muA, color='C1', label=r'$\sigma$')
if fluorescence: if fluorescence:
ax1.set_ylabel('XAS (fluorescence)') ax1.set_ylabel('XAS (fluorescence)')
else: else:
...@@ -206,7 +205,7 @@ def xas(nrun, bins=None, Iokey='SCS_SA3', Itkey='MCP3apd', nrjkey='nrj', ...@@ -206,7 +205,7 @@ def xas(nrun, bins=None, Iokey='SCS_SA3', Itkey='MCP3apd', nrjkey='nrj',
ax1.set_xlabel('Energy (eV)') ax1.set_xlabel('Energy (eV)')
ax1.legend() ax1.legend()
ax1_twin = ax1.twinx() ax1_twin = ax1.twinx()
ax1_twin.bar(nrj, nosample['muIo'], width=0.80*(bins_c[1]-bins_c[0]), ax1_twin.bar(bins_c, nosample['muIo'], width=0.80*(bins_c[1]-bins_c[0]),
color='C1', alpha=0.2) color='C1', alpha=0.2)
ax1_twin.set_ylabel('Io') ax1_twin.set_ylabel('Io')
try: try:
...@@ -217,13 +216,13 @@ def xas(nrun, bins=None, Iokey='SCS_SA3', Itkey='MCP3apd', nrjkey='nrj', ...@@ -217,13 +216,13 @@ def xas(nrun, bins=None, Iokey='SCS_SA3', Itkey='MCP3apd', nrjkey='nrj',
f.suptitle(nrun.attrs['plot_title']) f.suptitle(nrun.attrs['plot_title'])
ax2 = plt.subplot(gs[1]) ax2 = plt.subplot(gs[1])
ax2.bar(nrj, nosample['counts'], width=0.80*(bins_c[1]-bins_c[0]), ax2.bar(bins_c, nosample['counts'], width=0.80*(bins_c[1]-bins_c[0]),
color='C0', alpha=0.2) color='C0', alpha=0.2)
ax2.set_xlabel('Energy (eV)') ax2.set_xlabel('Energy (eV)')
ax2.set_ylabel('counts') ax2.set_ylabel('counts')
plt.tight_layout() plt.tight_layout()
return {'nrj':nrj, 'muA':muA, 'sterrA':sterrA, 'sigmaA':nosample['sigmaA'], return {'nrj':bins_c, 'muA':muA, 'sterrA':sterrA, 'sigmaA':nosample['sigmaA'],
'muIo':nosample['muIo'], 'counts':nosample['counts']} 'muIo':nosample['muIo'], 'counts':nosample['counts']}
def xasxmcd(dataP, dataN): def xasxmcd(dataP, dataN):
......
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