From the bundled dataset, aunps_water()
, we measure the surface plasmon resonance shift when adding gold nanoparticles to water, then adding the protein, Bovine Serum Albumin.
Configure notebook style (see NBCONFIG.ipynb), add imports and paths. The %run magic used below requires IPython 2.0 or higher.
#%run NBCONFIG.ipynb
%pylab inline
Populating the interactive namespace from numpy and matplotlib
from skspec.data import aunps_water
ts = aunps_water()
ts.iloc[0:5, 0:5]
['dti', 'd', 'h', 'm', 'us', 's', 'ms', 'intvl', 'ns']
/home/adam/Enthought/Canopy_32bit/User/lib/python2.7/site-packages/pytz/__init__.py:29: UserWarning: Module argparse was already imported from /home/adam/Canopy/appdata/canopy-1.4.0.1938.rh5-x86/lib/python2.7/argparse.pyc, but /home/adam/Enthought/Canopy_32bit/User/lib/python2.7/site-packages is being added to sys.path from pkg_resources import resource_stream
2013-02-04 15:40:48 | 2013-02-04 15:41:34 | 2013-02-04 15:42:20 | 2013-02-04 15:43:06 | 2013-02-04 15:43:52 | |
---|---|---|---|---|---|
200 | 305.53 | 306.31 | 305.23 | 305.17 | 307.22 |
201 | 311.67 | 313.43 | 312.75 | 314.12 | 314.88 |
202 | 318.09 | 319.56 | 319.12 | 319.51 | 319.13 |
203 | 323.47 | 324.90 | 322.34 | 324.48 | 325.61 |
204 | 340.97 | 340.09 | 340.86 | 342.99 | 341.78 |
ax = ts.plot()
ts.reference = 0
ts.varunit = 's'
ts.baseline.T.plot(color='k', ls='--', ax=ax)
ts.reference.T.plot(color='magenta', ls = '--', ax=ax);
WARNING:skspec.core.spectra:Spectrum does not have subtracted baseline; could affect result in specious absorbance data.
ts = ts.nearby[400:700]
ts.sub_base()
ts.norm = 'a'
ts.plot(cbar=True)
CRITICAL:skspec.core.spectra:Subtracting baseline, but may not have all: elements being equal. Fix index
<matplotlib.axes.AxesSubplot at 0xb6414ac>
aunps = ts.nearby[400:700]
aunps.plot(kind='waterfall', cmap='seismic', cbar=True)
aunps.name='SPR peak of nanoparticles'
mask = aunps.max() > 0.1
aunps_cut = aunps[aunps.columns[mask]]
aunps_cut.plot();
aunps_cut.idxmax().plot(title='SPR shift vs. time')
plt.ylabel('Peak Wavelength (nm)')
<matplotlib.text.Text at 0xc4dbb4c>
As an excercise, we can add some noise to the spectra,
noise = np.random.rand( *aunps_cut.shape )
aunps_noisy = aunps_cut + 0.035*noise
aunps_noisy.plot(kind='spec3d', color='k');
We merely demo how to visualize the 2D synchronous correlation spectrum of our data.
from skspec.correlation import Corr2d
from skspec.data import aunps_water
%pylab inline
ts = aunps_water().nearby[:600].as_norm('a').as_varunit('s')
cspec = Corr2d(ts)
cspec.async.plot(contours=128,cbar=True);
Populating the interactive namespace from numpy and matplotlib
from skspec.interact import SpectraModel, SpectraGui
specmodel = SpectraModel(spec=aunps)
gui = SpectraGui(model=specmodel)
gui
:0: FutureWarning: IPython widgets are experimental and may change in the future.
gui.tight_layout() #Formats gui layout