Initial commit. hdf5_lib.py contains functions to read hdf5 file as dataframe. and napp_plotlib contains functions to plot image and spectra. jupyter notebook included to illustrate functions.
This commit is contained in:
45
napp_plotlib.py
Normal file
45
napp_plotlib.py
Normal file
@@ -0,0 +1,45 @@
|
||||
import pandas as pd
|
||||
import numpy as np
|
||||
import matplotlib.pyplot as plt
|
||||
|
||||
def plot_image(dataframe,filter):
|
||||
|
||||
for meas_idx in dataframe.loc[filter,:].index:
|
||||
meas = dataframe.loc[meas_idx,:] # pandas Series
|
||||
fig = plt.figure()
|
||||
ax = plt.gca()
|
||||
rows, cols = meas['image'].shape
|
||||
scientaEkin_eV = meas['scientaEkin_eV'].flatten()
|
||||
x_min, x_max = np.min(scientaEkin_eV), np.max(scientaEkin_eV)
|
||||
y_min, y_max = 0, rows
|
||||
ax.imshow(meas['image'],extent = [x_min,x_max,y_min,y_max])
|
||||
ax.set_xlabel('scientaEkin_eV')
|
||||
ax.set_ylabel('Replicates')
|
||||
ax.set_title(meas['name'][0]+ '\n'+meas['sample'][0]+ '\n' + meas['lastModifiedDatestr'][0])
|
||||
|
||||
def plot_spectrum(dataframe,filter,):
|
||||
|
||||
fig = plt.figure()
|
||||
ax = plt.gca()
|
||||
|
||||
for meas_idx in dataframe.loc[filter,:].index:
|
||||
meas = dataframe.loc[meas_idx,:] # pandas Series
|
||||
|
||||
rows, cols = meas['image'].shape
|
||||
bindingEnergy_eV = meas['bindingEnergy_eV'].flatten()
|
||||
spectrum_countsPerSecond = meas['spectrum_countsPerSecond'].flatten()
|
||||
x_min, x_max = np.min(bindingEnergy_eV), np.max(bindingEnergy_eV)
|
||||
y_min, y_max = 0, rows
|
||||
#for i in range(cols):
|
||||
ax.plot(bindingEnergy_eV, spectrum_countsPerSecond,label = meas['name'][0])
|
||||
#ax.plot(bindingEnergy_eV, np.mean(meas['image'],axis=0))
|
||||
ax.set_xlabel('bindingEnergy_eV')
|
||||
ax.set_ylabel('counts Per Second')
|
||||
if len(meas)>1:
|
||||
ax.set_title('\n'+meas['sample'][0]+ '\n' + meas['lastModifiedDatestr'][0])
|
||||
else:
|
||||
ax.set_title(meas['name'][0] + '\n'+meas['sample'][0]+ '\n' + meas['lastModifiedDatestr'][0])
|
||||
ax.legend()
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user