In [12]:
from atmPy.instruments.LAS.las_sd import LAS
from atmPy.instruments.DMA.smps import SMPS
from atmPy.instruments.DMA import dma
from atmPy import atmosphere as atm
import matplotlib.pyplot as plt
import numpy as np
import matplotlib

import scipy as sp
from scipy import stats
from matplotlib.ticker import LogLocator
%matplotlib inline

In [2]:
las = LAS()

In [3]:
las.read_data()


[ 0.02068348  0.02066534  0.02064787  0.02066903  0.02064378  0.02068725
  0.02064664  0.0206669   0.02067233  0.02066339  0.02066926  0.020658
  0.0206567   0.02066162  0.02066961  0.02065546  0.02068565  0.02064761
  0.02066887  0.02066233  0.0206664   0.02066022  0.02067593  0.02066131
  0.02066382  0.02066445  0.02066147  0.02066628  0.02066328  0.02066342
  0.02066414  0.02066329  0.02065914  0.02066943  0.02066212  0.02066444
  0.02066436  0.0206682   0.0206581   0.02067056  0.02065833  0.0206696
  0.02066072  0.02066299  0.02066676  0.02066429  0.02066498  0.02066134
  0.02066619  0.02066258  0.02066703  0.02066388  0.02066409  0.02066504
  0.02066105  0.02066444  0.02066545  0.02066552  0.02066279  0.02066407
  0.02066399  0.02066581  0.02066234  0.02066628  0.02066334  0.02066316
  0.02066522  0.0206633   0.02066513  0.02066456  0.02066328  0.02066412
  0.02066467  0.02066438  0.02066409  0.02066438  0.02066435  0.0206644
  0.02066361  0.0206644   0.02066447  0.02066386  0.02066439  0.02066384
  0.0206646   0.02066441  0.02066371  0.02066425  0.02066448  0.02066376
  0.02066468  0.02066432  0.02066377  0.02066435  0.02066435  0.02066437
  0.02066379  0.02066436]

In [4]:
las.convertSD()


Converting from standard.

In [5]:
# Get some SMPS data
noaaDma = dma.NoaaWide()
nSMPS = SMPS(noaaDma)

In [6]:
nSMPS.openFiles()

In [7]:
nSMPS.getLag(0,delta=5)


C:\Anaconda3\lib\site-packages\pandas\core\index.py:687: FutureWarning: slice indexers when using iloc should be integers and not floating point
  "and not floating point",FutureWarning)

In [8]:
nSMPS.proc_files()


C:/Users/mrichardson/Desktop/SMPS vs LAS 6-1-15/SCAN_20150601_13_38_19.txt

In [10]:
f,ax = plt.subplots()
for i in range(1196,1259):
    p = las.dndlogdp.iloc[i,:].plot(ax = ax, logx=True, xlim=[10,1000])
    
p = ax.plot(nSMPS.diam_interp, nSMPS.dn_interp[0,:])
p = ax.plot(nSMPS.diam_interp, nSMPS.dn_interp[1,:])
ax.yaxis.set_minor_locator(LogLocator())
ax.yaxis.grid(which='major')
ax.yaxis.grid(which='minor')
ax.xaxis.grid(which='major')
ax.xaxis.grid(which='minor')
ax.set_xlabel('Dp (nm)')
ax.set_ylabel('dNdlogDp (cm-3 um-1)')
ax.set_title('Normalized CN concentrations')
plt.savefig('test.pdf')



In [12]:
f,ax = plt.subplots()
for i in range(1196,1259):
    p = las.sd.iloc[i,:].plot(ax = ax, logx=True, xlim=[10,1000])
    
p = ax.plot(nSMPS.diam[0], nSMPS.cn_smoothed[0])
p = ax.plot(nSMPS.diam[1], nSMPS.cn_smoothed[1])
p = ax.plot(nSMPS.diam[0], nSMPS.cn_raw[0])
p = ax.plot(nSMPS.diam[1], nSMPS.cn_raw[1])
ax.yaxis.set_minor_locator(LogLocator())
ax.yaxis.grid(which='major')
ax.yaxis.grid(which='minor')
ax.xaxis.grid(which='major')
ax.xaxis.grid(which='minor')
ax.set_xlabel('Dp (nm)')
ax.set_ylabel('[CN] (cm-3)')
ax.set_title('CN concentrations not normalized')
plt.savefig('raw.pdf')



In [30]:
273.15/297*830/1013.25


Out[30]:
0.7533663803093854

In [76]:
dist = getattr(stats, 'lognorm')

In [77]:
dist


Out[77]:
<scipy.stats._continuous_distns.lognorm_gen at 0xaf03dd8>

In [78]:
param = dist.fit(nSMPS.cn_raw[0])

In [89]:
mean, var, skew, kurt = dist.stats(param, moments='mvsk')

In [90]:
mean


Out[90]:
array([  2.59762878e+00,              nan,   2.09376633e+93])

In [85]:
nSMPS.diam
# df_fitted = dist.pdf(nSMPS.diam[0], *param[:-2],loc=param[-2], scale=param[-1])*np.sum(nSMPS.cn_raw[0])
df_fitted = dist.pdf(nSMPS.diam[0], s=param)


---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-85-9fbc50768054> in <module>()
      1 nSMPS.diam
      2 # df_fitted = dist.pdf(nSMPS.diam[0], *param[:-2],loc=param[-2], scale=param[-1])*np.sum(nSMPS.cn_raw[0])
----> 3 df_fitted = dist.pdf(nSMPS.diam[0], s=param)

C:\Anaconda3\lib\site-packages\scipy\stats\_distn_infrastructure.py in pdf(self, x, *args, **kwds)
   1565         cond0 = self._argcheck(*args) & (scale > 0)
   1566         cond1 = (scale > 0) & (x >= self.a) & (x <= self.b)
-> 1567         cond = cond0 & cond1
   1568         output = zeros(shape(cond), 'd')
   1569         putmask(output, (1-cond0)+np.isnan(x), self.badvalue)

ValueError: operands could not be broadcast together with shapes (3,) (300,) 

In [84]:
param[-2]


Out[84]:
-0.41690700691953386

In [82]:
f,ax = plt.subplots()

ax.plot(nSMPS.diam[0], df_fitted)
ax.plot(nSMPS.diam[0], nSMPS.cn_raw[0])
ax.xaxis.set_scale('log')


C:\Anaconda3\lib\site-packages\IPython\kernel\__main__.py:5: MatplotlibDeprecationWarning: The set_scale function was deprecated in version 1.3.

In [ ]:


In [ ]:


In [ ]: