We will demonstrate a faux pipeline that incorporates
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 ['dti', 'd', 'h', 'm', 'us', 's', 'ms', 'intvl', 'ns']
from pyuvvis.data import solvent_evap
help(solvent_evap)
Help on function solvent_evap in module pyuvvis.data: solvent_evap(*args, **kwargs) Model solvent evaporation dataset graciously shared by Dr. Isao Noda; used in his 2004 book Two-Dimensional Correlation Spectroscopy. From page 47: 'The system described here is a three-component solution mixture of polystyrene (PS) dissolved in a 50:50 blblend of metyl etyl ketone (MEK) and perdeuterated tolune. The initial concentration of PS is about 1.0wt%. Once the solution mixture is exposed to the open atmosphere, the solvents start evaporating, and the PS concentraiton increases with time. However, due to the substantial difference in the volatility of MEK and toluene coupled with their slightly dissimilar affinity to PS, the composition of the solution mixture changes as a function of time in a rather complex manner during hte spontaneous evaporation process. The transient IR spectra were collected as the two solvents evaporated, eventually leaving a PS film behind, as shown schematically in Figure 4.1 (A). The measurement was actually made using a horizontal attenuated total reflectance (ATR) prism. ... As expected, the intensities of bands at 2980 and 1720 cm-1 due to violatile MEK and those of bands at 2275 and 820cm-1 assigned to perdeuterated toluene gradually decrease, while those of PS bands at 3020 and 1450cm-1 increase with time.'
ts = solvent_evap()
ts.plot(cbar=True, colormap='cool_r');
WARNING:pyuvvis.core.spectra:Spectrum does not have subtracted baseline; could affect result in specious absorbance data.
With the above colormap, we can begin to see the order of events in the experiment. Let's choose three regions of interest to focus on. A good approach is to use plotly to interactively zoom in on separate regions in the dataset. Go ahead and play with it a bit. After doing this, I decided to focus on these regions of the spectrum:
import plotly.plotly as py
fig, ax = plt.subplots(1,1)
ts.plot(ax=ax, colormap='cool_r', title='Interactive Plot Through Plotly (interact with me)')
py.iplot_mpl(fig, update=_pyupdate); #_pyupdate defined in NBCONFIG
WARNING:pyuvvis.core.spectra:Spectrum does not have subtracted baseline; could affect result in specious absorbance data.
t1 = ts.nearby[1800:1650] #Slice using ts.nearby
t2 = ts.nearby[3150:2750]
fig, (ax1, ax2) = plt.subplots(1,2)
t1.plot(ax=ax1, title = 'Early Peak Fades')
t2.plot(ax=ax2,
cbar=True,
fig=fig, #pass fig required by colorbar
title= 'Later Peak Rising');
WARNING:pyuvvis.core.spectra:Spectrum does not have subtracted baseline; could affect result in specious absorbance data. WARNING:pyuvvis.core.spectra:Spectrum does not have subtracted baseline; could affect result in specious absorbance data.
from pyuvvis.plotting import areaplot
ax1 = areaplot(ts)
areaplot(t1, ax=ax1, color='r', ls='--')
areaplot(t2, ax=ax1, color='blue', ls='--')
plt.ylim(0,220)
plt.legend(['Total Area', 'Peak 1 Area', 'Peak 2 Area']);
WARNING:pyuvvis.plotting.basic_plots:Recomputing area from shape (1711, 13) to (13,) WARNING:pyuvvis.plotting.basic_plots:Recomputing area from shape (79, 13) to (13,) WARNING:pyuvvis.plotting.basic_plots:Recomputing area from shape (209, 13) to (13,)
We see from the above areaplot that Peak 2 doesn't really do much until 5 timeunits or so, and is done at 11 time units. Meanwhile, Peak 1 is done changing at timeunits 9. We can use slice these again using ix (or many other ways, see pandas indexing).
t1 = ts.nearby[1800:1650, 0:9] #Slice wavelengths and columns
t2 = ts.nearby[3150:2750, 5:11]
t1.plot(cbar=True, title='Peak 1, cropped time');
WARNING:pyuvvis.core.spectra:Spectrum does not have subtracted baseline; could affect result in specious absorbance data.
Since pyuvvis is build over numpy and pandas, it's very easy to apply numpy compatible operations such as integration, interpolation, transforms etc..., many of which are defined in scipy. We will demonstrate this using the scipy.signal
signal processing module. In particular, let's apply a Weiner filter. (I don't know much about this filter; just using it
Any numpy/scipy function can be applied using the ts.apply()
method. This will ensure a TimeSpectra is returned rather than just a numpy array.
from scipy.signal import wiener
t1_filtered = t1.apply(wiener, mysize=15)
t1_filtered.plot(title='Weiner Filtered; random parameter of 15 selected');
WARNING:pyuvvis.core.spectra:Spectrum does not have subtracted baseline; could affect result in specious absorbance data.
We can also do arithmetic on numpy arrays. For example, let's generate some random noise and just add it to our data. The noise should have the same dimension as our data to ensure it's added properly. We will use np.random to generate the noise. This module has about any kind of noise we could want (e.g. gaussian noise). For now, I'll just use random numbers from 0-1.
noise = 0.05 * np.random.randn(*t1.shape) #Reduce amplitude to 0.01
t1_noisy = t1 + noise # Add the noise (matrix addition)
t1_noisy.plot(title='Noisy Peak 1');
WARNING:pyuvvis.core.spectra:Spectrum does not have subtracted baseline; could affect result in specious absorbance data.
Please refer to the correlation analysis tutorials for a better explanation of the basics. In this guide, we focus on performing correlation analysis on multple wavelengths and time subsets in the data.
from pyuvvis.correlation import Corr2d
t1.varunit='s'
cspec = Corr2d(t1) #Since no time unit in dataset, assign one
cspec.plot();
WARNING:pyuvvis.core.spectra:Spectrum does not have subtracted baseline; could affect result in specious absorbance data.
from pyuvvis.plotting.plot_utils import hide_axis
cspec_2 = Corr2d(t2)
cspec_2.center()
fig, ((ax1, ax2), (ax3, ax4)) = plt.subplots(2,2) #2x2 multiplots
# Remove sideplots to allow for multiplot calls
cspec.plot(ax=ax1, sideplots=False, title='sync peak 1')
cspec_2.plot(ax=ax2, sideplots=False, title='sync peak 2')
cspec.plot(attr='async', ax=ax3, sideplots=False, title='async peak 1')
cspec_2.plot(attr='async', ax=ax4, sideplots=False, title='async peak 2');
# Remove tick marks from subplots as they are shared and tend to overcrowd figure
hide_axis(ax1, 'x')
hide_axis(ax2, 'both')
hide_axis(ax4, 'both');
The correlation matricies (synchronous, asynchronous, phase etc...) all natively support numpy arithmetic. They are stored in an object CorrFrame2d
, which is essentially a pyuvvis Spectra
. Let's play with some of these operations. Although we will be customizing the correlation spectra with various arithmetic operations, we can still pass the new matricies to cspec.plot(). This saves the hassle of going through a different plotting protocol for this use case.
print type(cspec.synchronous)
cspec.synchronous
<class 'pyuvvis.correlation.corr.Spec2d'>
1800.0 | 1798.1 | 1796.2 | 1794.2 | 1792.3 | 1790.4 | 1788.4 | 1786.5 | 1784.6 | 1782.7 | ... | 1666.9 | 1665.0 | 1663.0 | 1661.1 | 1659.2 | 1657.3 | 1655.3 | 1653.4 | 1651.5 | 1649.5 | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1800.0 | 0.000010 | 0.000008 | 5.746587e-06 | 0.000004 | 0.000000 | -0.000002 | -0.000004 | -0.000006 | -0.000008 | -0.000010 | ... | -0.000015 | -0.000014 | -0.000012 | -0.000011 | -0.000011 | -0.000011 | -0.000011 | -0.000008 | -0.000007 | -0.000008 |
1798.1 | 0.000008 | 0.000007 | 5.168760e-06 | 0.000004 | 0.000001 | -0.000000 | -0.000002 | -0.000003 | -0.000005 | -0.000006 | ... | -0.000007 | -0.000007 | -0.000006 | -0.000006 | -0.000005 | -0.000005 | -0.000005 | -0.000004 | -0.000003 | -0.000003 |
1796.2 | 0.000006 | 0.000005 | 4.406443e-06 | 0.000004 | 0.000002 | 0.000002 | 0.000001 | 0.000000 | -0.000000 | -0.000001 | ... | 0.000001 | 0.000001 | 0.000001 | 0.000001 | 0.000001 | 0.000001 | 0.000001 | 0.000001 | 0.000002 | 0.000002 |
1794.2 | 0.000004 | 0.000004 | 3.578850e-06 | 0.000003 | 0.000003 | 0.000003 | 0.000003 | 0.000003 | 0.000004 | 0.000004 | ... | 0.000010 | 0.000009 | 0.000008 | 0.000007 | 0.000007 | 0.000007 | 0.000007 | 0.000006 | 0.000006 | 0.000006 |
1792.3 | 0.000000 | 0.000001 | 2.417126e-06 | 0.000003 | 0.000005 | 0.000006 | 0.000007 | 0.000009 | 0.000010 | 0.000011 | ... | 0.000024 | 0.000022 | 0.000019 | 0.000017 | 0.000016 | 0.000016 | 0.000016 | 0.000014 | 0.000014 | 0.000014 |
1790.4 | -0.000002 | -0.000000 | 1.509277e-06 | 0.000003 | 0.000006 | 0.000009 | 0.000011 | 0.000013 | 0.000016 | 0.000017 | ... | 0.000036 | 0.000033 | 0.000028 | 0.000026 | 0.000025 | 0.000025 | 0.000024 | 0.000020 | 0.000020 | 0.000021 |
1788.4 | -0.000004 | -0.000002 | 7.657243e-07 | 0.000003 | 0.000007 | 0.000011 | 0.000014 | 0.000017 | 0.000020 | 0.000022 | ... | 0.000045 | 0.000041 | 0.000036 | 0.000033 | 0.000031 | 0.000031 | 0.000030 | 0.000025 | 0.000025 | 0.000026 |
1786.5 | -0.000006 | -0.000003 | 1.064351e-07 | 0.000003 | 0.000009 | 0.000013 | 0.000017 | 0.000020 | 0.000024 | 0.000027 | ... | 0.000054 | 0.000050 | 0.000043 | 0.000040 | 0.000038 | 0.000037 | 0.000036 | 0.000030 | 0.000030 | 0.000031 |
1784.6 | -0.000008 | -0.000005 | -4.630557e-07 | 0.000004 | 0.000010 | 0.000016 | 0.000020 | 0.000024 | 0.000029 | 0.000033 | ... | 0.000065 | 0.000060 | 0.000052 | 0.000047 | 0.000045 | 0.000045 | 0.000044 | 0.000036 | 0.000035 | 0.000037 |
1782.7 | -0.000010 | -0.000006 | -8.238546e-07 | 0.000004 | 0.000011 | 0.000017 | 0.000022 | 0.000027 | 0.000033 | 0.000037 | ... | 0.000073 | 0.000067 | 0.000058 | 0.000053 | 0.000051 | 0.000050 | 0.000049 | 0.000040 | 0.000040 | 0.000041 |
1780.7 | -0.000011 | -0.000007 | -1.218322e-06 | 0.000004 | 0.000012 | 0.000020 | 0.000025 | 0.000031 | 0.000037 | 0.000042 | ... | 0.000082 | 0.000076 | 0.000065 | 0.000060 | 0.000057 | 0.000057 | 0.000055 | 0.000046 | 0.000045 | 0.000047 |
1778.8 | -0.000013 | -0.000007 | -1.497224e-06 | 0.000004 | 0.000014 | 0.000021 | 0.000028 | 0.000034 | 0.000041 | 0.000046 | ... | 0.000090 | 0.000083 | 0.000072 | 0.000066 | 0.000063 | 0.000062 | 0.000061 | 0.000050 | 0.000049 | 0.000051 |
1776.9 | -0.000014 | -0.000009 | -1.916424e-06 | 0.000005 | 0.000015 | 0.000024 | 0.000030 | 0.000037 | 0.000045 | 0.000051 | ... | 0.000100 | 0.000092 | 0.000079 | 0.000073 | 0.000070 | 0.000069 | 0.000067 | 0.000055 | 0.000054 | 0.000057 |
1774.9 | -0.000017 | -0.000010 | -2.550249e-06 | 0.000005 | 0.000016 | 0.000026 | 0.000034 | 0.000041 | 0.000050 | 0.000056 | ... | 0.000110 | 0.000102 | 0.000088 | 0.000081 | 0.000077 | 0.000076 | 0.000074 | 0.000061 | 0.000060 | 0.000063 |
1773.0 | -0.000020 | -0.000012 | -3.547967e-06 | 0.000005 | 0.000018 | 0.000030 | 0.000039 | 0.000047 | 0.000057 | 0.000065 | ... | 0.000126 | 0.000116 | 0.000100 | 0.000092 | 0.000088 | 0.000087 | 0.000085 | 0.000070 | 0.000068 | 0.000071 |
1771.1 | -0.000023 | -0.000014 | -4.460287e-06 | 0.000005 | 0.000021 | 0.000034 | 0.000044 | 0.000054 | 0.000066 | 0.000074 | ... | 0.000144 | 0.000133 | 0.000115 | 0.000105 | 0.000101 | 0.000100 | 0.000097 | 0.000080 | 0.000078 | 0.000082 |
1769.2 | -0.000026 | -0.000016 | -5.185947e-06 | 0.000006 | 0.000022 | 0.000037 | 0.000048 | 0.000059 | 0.000072 | 0.000081 | ... | 0.000157 | 0.000144 | 0.000125 | 0.000114 | 0.000109 | 0.000108 | 0.000106 | 0.000087 | 0.000085 | 0.000089 |
1767.2 | -0.000029 | -0.000018 | -6.006388e-06 | 0.000006 | 0.000025 | 0.000041 | 0.000053 | 0.000066 | 0.000080 | 0.000090 | ... | 0.000174 | 0.000160 | 0.000139 | 0.000127 | 0.000122 | 0.000120 | 0.000118 | 0.000097 | 0.000094 | 0.000099 |
1765.3 | -0.000032 | -0.000020 | -6.848779e-06 | 0.000006 | 0.000027 | 0.000045 | 0.000058 | 0.000072 | 0.000088 | 0.000099 | ... | 0.000191 | 0.000176 | 0.000152 | 0.000140 | 0.000134 | 0.000132 | 0.000129 | 0.000106 | 0.000103 | 0.000108 |
1763.4 | -0.000036 | -0.000023 | -8.177989e-06 | 0.000007 | 0.000030 | 0.000050 | 0.000065 | 0.000080 | 0.000098 | 0.000110 | ... | 0.000213 | 0.000196 | 0.000169 | 0.000156 | 0.000149 | 0.000147 | 0.000144 | 0.000118 | 0.000115 | 0.000120 |
1761.4 | -0.000044 | -0.000028 | -1.012232e-05 | 0.000007 | 0.000035 | 0.000058 | 0.000076 | 0.000095 | 0.000115 | 0.000129 | ... | 0.000250 | 0.000230 | 0.000199 | 0.000182 | 0.000174 | 0.000173 | 0.000168 | 0.000138 | 0.000134 | 0.000141 |
1759.5 | -0.000049 | -0.000032 | -1.164401e-05 | 0.000008 | 0.000039 | 0.000065 | 0.000086 | 0.000106 | 0.000129 | 0.000146 | ... | 0.000281 | 0.000258 | 0.000223 | 0.000205 | 0.000196 | 0.000194 | 0.000189 | 0.000155 | 0.000151 | 0.000158 |
1757.6 | -0.000056 | -0.000036 | -1.337015e-05 | 0.000009 | 0.000043 | 0.000073 | 0.000096 | 0.000119 | 0.000145 | 0.000163 | ... | 0.000314 | 0.000289 | 0.000250 | 0.000230 | 0.000220 | 0.000217 | 0.000212 | 0.000173 | 0.000168 | 0.000177 |
1755.6 | -0.000061 | -0.000039 | -1.403130e-05 | 0.000010 | 0.000048 | 0.000081 | 0.000106 | 0.000132 | 0.000160 | 0.000180 | ... | 0.000347 | 0.000320 | 0.000276 | 0.000254 | 0.000243 | 0.000240 | 0.000234 | 0.000192 | 0.000186 | 0.000196 |
1753.7 | -0.000062 | -0.000039 | -1.339004e-05 | 0.000012 | 0.000051 | 0.000085 | 0.000111 | 0.000138 | 0.000167 | 0.000188 | ... | 0.000363 | 0.000334 | 0.000289 | 0.000265 | 0.000254 | 0.000251 | 0.000245 | 0.000201 | 0.000195 | 0.000205 |
1751.8 | -0.000062 | -0.000038 | -1.176816e-05 | 0.000014 | 0.000055 | 0.000090 | 0.000117 | 0.000144 | 0.000175 | 0.000197 | ... | 0.000382 | 0.000351 | 0.000304 | 0.000279 | 0.000267 | 0.000264 | 0.000257 | 0.000211 | 0.000206 | 0.000216 |
1749.9 | -0.000063 | -0.000038 | -1.024093e-05 | 0.000017 | 0.000060 | 0.000096 | 0.000125 | 0.000153 | 0.000186 | 0.000209 | ... | 0.000407 | 0.000374 | 0.000324 | 0.000297 | 0.000284 | 0.000281 | 0.000274 | 0.000225 | 0.000220 | 0.000230 |
1747.9 | -0.000064 | -0.000038 | -9.057977e-06 | 0.000020 | 0.000064 | 0.000103 | 0.000133 | 0.000163 | 0.000197 | 0.000222 | ... | 0.000435 | 0.000400 | 0.000346 | 0.000317 | 0.000303 | 0.000300 | 0.000293 | 0.000241 | 0.000236 | 0.000246 |
1746.0 | -0.000067 | -0.000040 | -8.725528e-06 | 0.000022 | 0.000069 | 0.000110 | 0.000142 | 0.000174 | 0.000210 | 0.000236 | ... | 0.000464 | 0.000427 | 0.000369 | 0.000339 | 0.000324 | 0.000320 | 0.000312 | 0.000258 | 0.000252 | 0.000263 |
1744.1 | -0.000072 | -0.000043 | -9.078597e-06 | 0.000024 | 0.000075 | 0.000119 | 0.000153 | 0.000188 | 0.000227 | 0.000255 | ... | 0.000501 | 0.000461 | 0.000399 | 0.000366 | 0.000349 | 0.000346 | 0.000337 | 0.000278 | 0.000272 | 0.000285 |
... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
1705.5 | -0.000333 | -0.000174 | 2.887386e-06 | 0.000175 | 0.000447 | 0.000684 | 0.000868 | 0.001053 | 0.001263 | 0.001413 | ... | 0.002863 | 0.002629 | 0.002274 | 0.002085 | 0.001992 | 0.001970 | 0.001921 | 0.001603 | 0.001577 | 0.001642 |
1703.6 | -0.000266 | -0.000139 | 1.924195e-06 | 0.000139 | 0.000357 | 0.000545 | 0.000692 | 0.000840 | 0.001007 | 0.001127 | ... | 0.002283 | 0.002096 | 0.001814 | 0.001663 | 0.001589 | 0.001571 | 0.001532 | 0.001278 | 0.001257 | 0.001310 |
1701.6 | -0.000219 | -0.000115 | 1.765894e-06 | 0.000115 | 0.000294 | 0.000450 | 0.000571 | 0.000693 | 0.000831 | 0.000930 | ... | 0.001883 | 0.001729 | 0.001496 | 0.001372 | 0.001311 | 0.001296 | 0.001264 | 0.001055 | 0.001037 | 0.001080 |
1699.7 | -0.000156 | -0.000082 | 2.441638e-07 | 0.000081 | 0.000207 | 0.000318 | 0.000403 | 0.000489 | 0.000587 | 0.000657 | ... | 0.001330 | 0.001221 | 0.001056 | 0.000969 | 0.000925 | 0.000915 | 0.000893 | 0.000744 | 0.000732 | 0.000762 |
1697.8 | -0.000134 | -0.000071 | -2.860309e-07 | 0.000068 | 0.000177 | 0.000272 | 0.000345 | 0.000419 | 0.000503 | 0.000562 | ... | 0.001137 | 0.001044 | 0.000903 | 0.000828 | 0.000791 | 0.000782 | 0.000763 | 0.000636 | 0.000626 | 0.000652 |
1695.8 | -0.000104 | -0.000056 | -1.270282e-06 | 0.000052 | 0.000135 | 0.000208 | 0.000264 | 0.000321 | 0.000386 | 0.000432 | ... | 0.000872 | 0.000800 | 0.000692 | 0.000635 | 0.000607 | 0.000600 | 0.000585 | 0.000488 | 0.000479 | 0.000499 |
1693.9 | -0.000088 | -0.000047 | -1.901405e-06 | 0.000042 | 0.000112 | 0.000173 | 0.000220 | 0.000268 | 0.000322 | 0.000360 | ... | 0.000726 | 0.000667 | 0.000577 | 0.000529 | 0.000506 | 0.000500 | 0.000488 | 0.000406 | 0.000399 | 0.000416 |
1692.0 | -0.000076 | -0.000041 | -2.154417e-06 | 0.000036 | 0.000096 | 0.000148 | 0.000189 | 0.000230 | 0.000276 | 0.000309 | ... | 0.000622 | 0.000571 | 0.000494 | 0.000453 | 0.000433 | 0.000428 | 0.000418 | 0.000348 | 0.000342 | 0.000356 |
1690.1 | -0.000065 | -0.000035 | -1.501287e-06 | 0.000031 | 0.000083 | 0.000127 | 0.000162 | 0.000197 | 0.000237 | 0.000265 | ... | 0.000534 | 0.000490 | 0.000424 | 0.000389 | 0.000372 | 0.000367 | 0.000358 | 0.000298 | 0.000293 | 0.000306 |
1688.1 | -0.000057 | -0.000030 | -9.582544e-07 | 0.000028 | 0.000073 | 0.000112 | 0.000143 | 0.000174 | 0.000208 | 0.000233 | ... | 0.000470 | 0.000432 | 0.000374 | 0.000343 | 0.000327 | 0.000324 | 0.000316 | 0.000263 | 0.000258 | 0.000269 |
1686.2 | -0.000050 | -0.000027 | -3.727002e-07 | 0.000025 | 0.000066 | 0.000101 | 0.000129 | 0.000156 | 0.000188 | 0.000210 | ... | 0.000424 | 0.000389 | 0.000337 | 0.000309 | 0.000295 | 0.000292 | 0.000285 | 0.000237 | 0.000233 | 0.000243 |
1684.3 | -0.000043 | -0.000022 | 3.805748e-07 | 0.000023 | 0.000058 | 0.000088 | 0.000112 | 0.000136 | 0.000163 | 0.000182 | ... | 0.000368 | 0.000338 | 0.000292 | 0.000268 | 0.000256 | 0.000253 | 0.000247 | 0.000206 | 0.000202 | 0.000211 |
1682.3 | -0.000041 | -0.000022 | 7.269375e-08 | 0.000021 | 0.000055 | 0.000084 | 0.000107 | 0.000130 | 0.000156 | 0.000174 | ... | 0.000351 | 0.000323 | 0.000279 | 0.000256 | 0.000245 | 0.000242 | 0.000236 | 0.000197 | 0.000193 | 0.000201 |
1680.4 | -0.000041 | -0.000022 | -1.144832e-07 | 0.000021 | 0.000054 | 0.000083 | 0.000105 | 0.000127 | 0.000153 | 0.000171 | ... | 0.000345 | 0.000317 | 0.000274 | 0.000251 | 0.000240 | 0.000237 | 0.000231 | 0.000193 | 0.000190 | 0.000198 |
1678.5 | -0.000039 | -0.000021 | 1.832914e-07 | 0.000020 | 0.000052 | 0.000080 | 0.000102 | 0.000123 | 0.000148 | 0.000166 | ... | 0.000334 | 0.000307 | 0.000266 | 0.000244 | 0.000233 | 0.000230 | 0.000224 | 0.000187 | 0.000184 | 0.000192 |
1676.5 | -0.000036 | -0.000019 | 6.065549e-07 | 0.000019 | 0.000049 | 0.000075 | 0.000095 | 0.000115 | 0.000138 | 0.000154 | ... | 0.000312 | 0.000286 | 0.000248 | 0.000227 | 0.000217 | 0.000215 | 0.000209 | 0.000175 | 0.000172 | 0.000179 |
1674.6 | -0.000030 | -0.000015 | 1.367405e-06 | 0.000018 | 0.000043 | 0.000066 | 0.000083 | 0.000100 | 0.000120 | 0.000134 | ... | 0.000272 | 0.000250 | 0.000216 | 0.000198 | 0.000190 | 0.000187 | 0.000183 | 0.000153 | 0.000150 | 0.000156 |
1672.7 | -0.000027 | -0.000014 | 1.235808e-06 | 0.000016 | 0.000039 | 0.000059 | 0.000075 | 0.000091 | 0.000109 | 0.000122 | ... | 0.000247 | 0.000227 | 0.000196 | 0.000180 | 0.000172 | 0.000170 | 0.000166 | 0.000138 | 0.000136 | 0.000142 |
1670.8 | -0.000022 | -0.000011 | 1.295718e-06 | 0.000013 | 0.000033 | 0.000049 | 0.000062 | 0.000076 | 0.000091 | 0.000101 | ... | 0.000206 | 0.000189 | 0.000163 | 0.000150 | 0.000143 | 0.000141 | 0.000138 | 0.000115 | 0.000113 | 0.000118 |
1668.8 | -0.000018 | -0.000009 | 1.535328e-06 | 0.000011 | 0.000027 | 0.000040 | 0.000051 | 0.000062 | 0.000074 | 0.000082 | ... | 0.000168 | 0.000154 | 0.000133 | 0.000122 | 0.000117 | 0.000115 | 0.000112 | 0.000094 | 0.000093 | 0.000096 |
1666.9 | -0.000015 | -0.000007 | 1.447011e-06 | 0.000010 | 0.000024 | 0.000036 | 0.000045 | 0.000054 | 0.000065 | 0.000073 | ... | 0.000148 | 0.000136 | 0.000117 | 0.000108 | 0.000103 | 0.000102 | 0.000099 | 0.000083 | 0.000082 | 0.000085 |
1665.0 | -0.000014 | -0.000007 | 1.245197e-06 | 0.000009 | 0.000022 | 0.000033 | 0.000041 | 0.000050 | 0.000060 | 0.000067 | ... | 0.000136 | 0.000125 | 0.000108 | 0.000099 | 0.000094 | 0.000093 | 0.000091 | 0.000076 | 0.000075 | 0.000078 |
1663.0 | -0.000012 | -0.000006 | 1.148093e-06 | 0.000008 | 0.000019 | 0.000028 | 0.000036 | 0.000043 | 0.000052 | 0.000058 | ... | 0.000117 | 0.000108 | 0.000093 | 0.000085 | 0.000082 | 0.000081 | 0.000079 | 0.000066 | 0.000065 | 0.000067 |
1661.1 | -0.000011 | -0.000006 | 8.827548e-07 | 0.000007 | 0.000017 | 0.000026 | 0.000033 | 0.000040 | 0.000047 | 0.000053 | ... | 0.000108 | 0.000099 | 0.000085 | 0.000078 | 0.000075 | 0.000074 | 0.000072 | 0.000060 | 0.000059 | 0.000062 |
1659.2 | -0.000011 | -0.000005 | 8.139274e-07 | 0.000007 | 0.000016 | 0.000025 | 0.000031 | 0.000038 | 0.000045 | 0.000051 | ... | 0.000103 | 0.000094 | 0.000082 | 0.000075 | 0.000072 | 0.000071 | 0.000069 | 0.000058 | 0.000057 | 0.000059 |
1657.3 | -0.000011 | -0.000005 | 8.549846e-07 | 0.000007 | 0.000016 | 0.000025 | 0.000031 | 0.000037 | 0.000045 | 0.000050 | ... | 0.000102 | 0.000093 | 0.000081 | 0.000074 | 0.000071 | 0.000070 | 0.000068 | 0.000057 | 0.000056 | 0.000058 |
1655.3 | -0.000011 | -0.000005 | 6.987021e-07 | 0.000007 | 0.000016 | 0.000024 | 0.000030 | 0.000036 | 0.000044 | 0.000049 | ... | 0.000099 | 0.000091 | 0.000079 | 0.000072 | 0.000069 | 0.000068 | 0.000066 | 0.000056 | 0.000055 | 0.000057 |
1653.4 | -0.000008 | -0.000004 | 1.342622e-06 | 0.000006 | 0.000014 | 0.000020 | 0.000025 | 0.000030 | 0.000036 | 0.000040 | ... | 0.000083 | 0.000076 | 0.000066 | 0.000060 | 0.000058 | 0.000057 | 0.000056 | 0.000047 | 0.000046 | 0.000048 |
1651.5 | -0.000007 | -0.000003 | 1.820156e-06 | 0.000006 | 0.000014 | 0.000020 | 0.000025 | 0.000030 | 0.000035 | 0.000040 | ... | 0.000082 | 0.000075 | 0.000065 | 0.000059 | 0.000057 | 0.000056 | 0.000055 | 0.000046 | 0.000045 | 0.000047 |
1649.5 | -0.000008 | -0.000003 | 1.564158e-06 | 0.000006 | 0.000014 | 0.000021 | 0.000026 | 0.000031 | 0.000037 | 0.000041 | ... | 0.000085 | 0.000078 | 0.000067 | 0.000062 | 0.000059 | 0.000058 | 0.000057 | 0.000048 | 0.000047 | 0.000049 |
79 rows × 79 columns
sync = cspec.synchronous
async = cspec.asynchronous
cspec.plot(sync**2,
title=r'$\Phi(\nu_1, \nu_2)^2$');
cspec.plot(sync - async,
title=r'$\Phi(\nu_1, \nu_2) - \Psi(\nu_1, \nu_2)$');
cspec.plot(sync*async,
title=r'$\Phi(\nu_1, \nu_2) \cdot \Psi(\nu_1, \nu_2)$');
The side plots are still showing the mean of this new matrix. As usual, the min(), max()
and any other array can be projected onto these sideplots as shown in the basic correlation analysis tutorial.
crazydata = np.sin(sync) * np.tan(async**2)
cspec.plot(crazydata,
sideplots='max',
title=r'$\sin(\Phi) \cdot \tan^2(\Psi)$');
These operations alone are not scientifically relevant, but add flexibility to the data munging and experimentation in developing new analysis techniques.
cspec.phase.plot(kind='waterfall')
WARNING:pyuvvis.core.spectra:Spectrum does not have subtracted baseline; could affect result in specious absorbance data.
<matplotlib.axes._subplots.Axes3DSubplot at 0x3e85e10>
The synchronous
, asynchronous
and phase
matricies are subclasses of the pyuvvis Spectra
, so you can still slice/manipulate the objects directly. For example, using the nearby
slice method.
crazydata.nearby[1730:1700, 1730:1700].plot(
kind='waterfall',
cmap='jet');
WARNING:pyuvvis.core.spectra:Spectrum does not have subtracted baseline; could affect result in specious absorbance data.
While these Corr2dFrame
objects share attributes with the Spectra
, some attributes/methods like reference and baseline no longer retain their meaning. For example, a basline and reference, yet you are still permitted to use them.
ts.mean(axis=1)
3999.40 | 0.003293 |
---|---|
3997.50 | 0.003085 |
3995.50 | 0.003230 |
3993.60 | 0.002911 |
3991.70 | 0.002403 |
3989.80 | 0.002539 |
3987.80 | 0.002496 |
3985.90 | 0.002408 |
3984.00 | 0.002432 |
3982.00 | 0.002632 |
3980.10 | 0.002572 |
3978.20 | 0.002558 |
3976.20 | 0.002818 |
3974.30 | 0.002683 |
3972.40 | 0.002143 |
3970.50 | 0.002064 |
3968.50 | 0.002592 |
3966.60 | 0.002467 |
3964.70 | 0.002297 |
3962.70 | 0.002271 |
3960.80 | 0.002430 |
3958.90 | 0.002597 |
3957.00 | 0.002135 |
3955.00 | 0.001970 |
3953.10 | 0.001857 |
3951.20 | 0.001779 |
3949.20 | 0.001931 |
3947.30 | 0.002140 |
3945.40 | 0.002372 |
3943.50 | 0.002502 |
... | ... |
756.28 | 0.340199 |
754.35 | 0.329046 |
752.42 | 0.318718 |
750.49 | 0.310961 |
748.56 | 0.298576 |
746.63 | 0.271412 |
744.70 | 0.228529 |
742.77 | 0.183786 |
740.84 | 0.147312 |
738.92 | 0.120000 |
736.99 | 0.098722 |
735.06 | 0.080638 |
733.13 | 0.065893 |
731.20 | 0.055776 |
729.27 | 0.050166 |
727.34 | 0.048000 |
725.41 | 0.049635 |
723.48 | 0.057197 |
721.55 | 0.076270 |
719.62 | 0.111126 |
717.69 | 0.131725 |
715.76 | 0.123254 |
713.83 | 0.112808 |
711.91 | 0.114317 |
709.98 | 0.137207 |
708.05 | 0.193717 |
706.12 | 0.294448 |
704.19 | 0.446092 |
702.26 | 0.637184 |
700.33 | 0.833778 |
1711 rows × 1 columns
cspec.center(False)
cspec.data.mean()
WARNING:pyuvvis.correlation.corr:Data is already centered.
60 | 0.117834 |
---|---|
120 | 0.097871 |
180 | 0.071567 |
240 | 0.035585 |
300 | -0.003136 |
360 | -0.039637 |
420 | -0.072054 |
480 | -0.096940 |
540 | -0.111089 |
cspec = Corr2d.from_spectra(ts, col_unit='time') #Since no time unit, pass one
cspec.center()
#print cspec.shape
#cspec.synchronous[-1, :]
#cspec.plot()
--------------------------------------------------------------------------- AttributeError Traceback (most recent call last) <ipython-input-22-4bc514c7e94c> in <module>() ----> 1 cspec = Corr2d.from_spectra(ts, col_unit='time') #Since no time unit, pass one 2 cspec.center() 3 #print cspec.shape 4 #cspec.synchronous[-1, :] 5 #cspec.plot() AttributeError: type object 'Corr2d' has no attribute 'from_spectra'
ts.transpose().cov()
from pandas import read_csv
data = read_csv('/media/HP v100w/2D_Data/pskdt_data_synch_color_avg.csv', sep=',', index_col=0, header=0)
data
from pandas import DataFrame
df = DataFrame(cspec.synchronous, index=ts.index, columns=ts.index)
df.reindex(index=df.index[::-1], columns=df.columns[::-1])