We seek to try out various heuristics to quantify spectral data; these are a prototype which ultimately will be used to correlate gold nanoparticle coverage in SEM images with spectral data.
Configure notebook style (see NBCONFIG.ipynb), add imports and paths. The %run magic used below requires IPython 2.0 or higher.
%run NBCONFIG.ipynb
Populating the interactive namespace from numpy and matplotlib
from skspec.data import aunps_glass
ts = aunps_glass()
ts.baseline = 220.0
ts.sub_base()
ts = ts.ix[440.0:680.0]
ts.plot(color='bone');
WARNING:skspec.core.timespectra:SpecIndex unit was changed internally from "None" to "nm" CRITICAL:skspec.core.timespectra:Subtracting baseline, but may not have all: elements being equal. Fix index
<matplotlib.axes.AxesSubplot at 0x4cf6250>
ts.reference = 0
ts_norm = ts.as_iunit('r')
ts_norm.plot(cbar=True);
ts_int = ts.as_interval('m')
ts_int.plot(cbar=True);
def flippy_s(s, style='decrease'):
y_flippy_s = [s[0]]
shift = 0
for i in range(1,len(s)):
dy = s[i]-s[i-1]
if style == 'decrease':
if dy > 0:
shift -= 2*dy
elif style == 'increase':
if dy < 0:
shift -= 2*dy
else:
raise AttributeError('style should be decrease and increase')
y_flippy_s.append(s[i]+shift)
return y_flippy_s
ts_1=ts.apply(flippy_s, axis=1)
ts_1.plot(cbar=True)
<matplotlib.axes.AxesSubplot at 0x71eb050>
ts_1 = ts_1 + 5000
ts_1.plot()
<matplotlib.axes.AxesSubplot at 0x70125d0>
from skspec.plotting import splot
from skspec.plotting import slice_plot
slice_plot(ts, 6);
WARNING:skspec.core.utilities:Returning uneven sampling for (n=6) along axis 1of size 158
[<matplotlib.axes.AxesSubplot at 0x60e1b10>, <matplotlib.axes.AxesSubplot at 0x5abc210>, <matplotlib.axes.AxesSubplot at 0x5aa6810>, <matplotlib.axes.AxesSubplot at 0x7b4b050>, <matplotlib.axes.AxesSubplot at 0x7b6f910>, <matplotlib.axes.AxesSubplot at 0x7b82750>]
tx = ts[ts.columns[120:160]]
tx.reference=0
absplot(tx)
--------------------------------------------------------------------------- NameError Traceback (most recent call last) <ipython-input-9-c5682ba32f0b> in <module>() 2 3 tx.reference=0 ----> 4 absplot(tx) NameError: name 'absplot' is not defined
p1.reference.plot()