[2]:
import atmPy.aerosols.size_distribution.sizedistribution as atmsd

SizeDist_TS (a time series of size distributions)

SizeDist_TS is a subclass of SizeDist with all its properties methods, etc. Here we will mostly focus on what is unique to the SizeDist_TS class.

Create instance

simulate a sizedistribution

[271]:
sd = atmsd.simulate_sizedistribution_timeseries(diameter=[10, 2500],
                                                numberOfDiameters=30,
                                                centerOfAerosolMode=200,
                                                widthOfAerosolMode=0.2,
                                                numberOfParticsInMode=1000,
                                                startDate='2014-11-24 17:00:00',
                                                endDate='2014-11-24 18:00:00',
                                                frequency=100,)

format your own data

data should have a similar structure as below. However, column names are not required as they are calculated based on bins

[272]:
sd.data
[272]:
bincenters 11.048638 13.365842 16.169028 19.560119 23.662416 28.625078 34.628546 41.891108 50.676829 61.305159 ... 411.502887 497.806397 602.210134 728.510216 881.298909 1066.131608 1289.728823 1560.220544 1887.441843 2283.290476
Time
2014-11-24 17:00:00 1.911539e-07 1.961036e-06 1.695719e-05 0.000124 0.000759 0.003931 0.017159 0.063122 0.195723 0.511528 ... 0.628429 0.250557 0.084202 0.023851 0.005694 0.001146 1.943746e-04 2.778965e-05 3.348824e-06 3.401474e-07
2014-11-24 17:01:40 1.621803e-09 2.237442e-08 2.601783e-07 0.000003 0.000021 0.000147 0.000861 0.004259 0.017761 0.062423 ... 1.483342 0.795320 0.359425 0.136912 0.043958 0.011896 2.713505e-03 5.217054e-04 8.454455e-05 1.154813e-05
2014-11-24 17:03:20 5.773237e-10 8.459389e-09 1.044779e-07 0.000001 0.000010 0.000071 0.000440 0.002312 0.010238 0.038217 ... 1.658889 0.944679 0.453437 0.183449 0.062557 0.017981 4.356151e-03 8.895361e-04 1.531052e-04 2.221171e-05
2014-11-24 17:05:00 1.190384e-08 1.456607e-07 1.502322e-06 0.000013 0.000096 0.000591 0.003077 0.013501 0.049931 0.155649 ... 1.114449 0.529984 0.212437 0.071774 0.020439 0.004906 9.925650e-04 1.692603e-04 2.432860e-05 2.947437e-06
2014-11-24 17:06:40 4.706680e-06 3.876759e-05 2.691463e-04 0.001575 0.007768 0.032295 0.113168 0.334250 0.832119 1.746082 ... 0.238763 0.076431 0.020622 0.004690 0.000899 0.000145 1.978151e-05 2.270673e-06 2.196926e-07 1.791604e-08
2014-11-24 17:08:20 6.223350e-04 3.503695e-03 1.662624e-02 0.066501 0.224195 0.637076 1.525884 3.080473 5.241782 7.518068 ... 0.022882 0.005007 0.000923 0.000144 0.000019 0.000002 1.933167e-07 1.516745e-08 1.003047e-09 5.591082e-11
2014-11-24 17:10:00 9.432527e-05 6.200413e-04 3.435412e-03 0.016044 0.063153 0.209530 0.585960 1.381193 2.744141 4.595408 ... 0.065858 0.016825 0.003623 0.000658 0.000101 0.000013 1.409726e-06 1.291422e-07 9.971660e-09 6.489816e-10
2014-11-24 17:11:40 1.911539e-07 1.961036e-06 1.695719e-05 0.000124 0.000759 0.003931 0.017159 0.063122 0.195723 0.511528 ... 0.628429 0.250557 0.084202 0.023851 0.005694 0.001146 1.943746e-04 2.778965e-05 3.348824e-06 3.401474e-07
2014-11-24 17:13:20 1.621803e-09 2.237442e-08 2.601783e-07 0.000003 0.000021 0.000147 0.000861 0.004259 0.017761 0.062423 ... 1.483342 0.795320 0.359425 0.136912 0.043958 0.011896 2.713505e-03 5.217054e-04 8.454455e-05 1.154813e-05
2014-11-24 17:15:00 5.773237e-10 8.459389e-09 1.044779e-07 0.000001 0.000010 0.000071 0.000440 0.002312 0.010238 0.038217 ... 1.658889 0.944679 0.453437 0.183449 0.062557 0.017981 4.356151e-03 8.895361e-04 1.531052e-04 2.221171e-05
2014-11-24 17:16:40 1.190384e-08 1.456607e-07 1.502322e-06 0.000013 0.000096 0.000591 0.003077 0.013501 0.049931 0.155649 ... 1.114449 0.529984 0.212437 0.071774 0.020439 0.004906 9.925650e-04 1.692603e-04 2.432860e-05 2.947437e-06
2014-11-24 17:18:20 4.706680e-06 3.876759e-05 2.691463e-04 0.001575 0.007768 0.032295 0.113168 0.334250 0.832119 1.746082 ... 0.238763 0.076431 0.020622 0.004690 0.000899 0.000145 1.978151e-05 2.270673e-06 2.196926e-07 1.791604e-08
2014-11-24 17:20:00 6.223350e-04 3.503695e-03 1.662624e-02 0.066501 0.224195 0.637076 1.525884 3.080473 5.241782 7.518068 ... 0.022882 0.005007 0.000923 0.000144 0.000019 0.000002 1.933167e-07 1.516745e-08 1.003047e-09 5.591082e-11
2014-11-24 17:21:40 9.432527e-05 6.200413e-04 3.435412e-03 0.016044 0.063153 0.209530 0.585960 1.381193 2.744141 4.595408 ... 0.065858 0.016825 0.003623 0.000658 0.000101 0.000013 1.409726e-06 1.291422e-07 9.971660e-09 6.489816e-10
2014-11-24 17:23:20 1.911539e-07 1.961036e-06 1.695719e-05 0.000124 0.000759 0.003931 0.017159 0.063122 0.195723 0.511528 ... 0.628429 0.250557 0.084202 0.023851 0.005694 0.001146 1.943746e-04 2.778965e-05 3.348824e-06 3.401474e-07
2014-11-24 17:25:00 1.621803e-09 2.237442e-08 2.601783e-07 0.000003 0.000021 0.000147 0.000861 0.004259 0.017761 0.062423 ... 1.483342 0.795320 0.359425 0.136912 0.043958 0.011896 2.713505e-03 5.217054e-04 8.454455e-05 1.154813e-05
2014-11-24 17:26:40 5.773237e-10 8.459389e-09 1.044779e-07 0.000001 0.000010 0.000071 0.000440 0.002312 0.010238 0.038217 ... 1.658889 0.944679 0.453437 0.183449 0.062557 0.017981 4.356151e-03 8.895361e-04 1.531052e-04 2.221171e-05
2014-11-24 17:28:20 1.190384e-08 1.456607e-07 1.502322e-06 0.000013 0.000096 0.000591 0.003077 0.013501 0.049931 0.155649 ... 1.114449 0.529984 0.212437 0.071774 0.020439 0.004906 9.925650e-04 1.692603e-04 2.432860e-05 2.947437e-06
2014-11-24 17:30:00 4.706680e-06 3.876759e-05 2.691463e-04 0.001575 0.007768 0.032295 0.113168 0.334250 0.832119 1.746082 ... 0.238763 0.076431 0.020622 0.004690 0.000899 0.000145 1.978151e-05 2.270673e-06 2.196926e-07 1.791604e-08
2014-11-24 17:31:40 6.223350e-04 3.503695e-03 1.662624e-02 0.066501 0.224195 0.637076 1.525884 3.080473 5.241782 7.518068 ... 0.022882 0.005007 0.000923 0.000144 0.000019 0.000002 1.933167e-07 1.516745e-08 1.003047e-09 5.591082e-11
2014-11-24 17:33:20 9.432527e-05 6.200413e-04 3.435412e-03 0.016044 0.063153 0.209530 0.585960 1.381193 2.744141 4.595408 ... 0.065858 0.016825 0.003623 0.000658 0.000101 0.000013 1.409726e-06 1.291422e-07 9.971660e-09 6.489816e-10
2014-11-24 17:35:00 1.911539e-07 1.961036e-06 1.695719e-05 0.000124 0.000759 0.003931 0.017159 0.063122 0.195723 0.511528 ... 0.628429 0.250557 0.084202 0.023851 0.005694 0.001146 1.943746e-04 2.778965e-05 3.348824e-06 3.401474e-07
2014-11-24 17:36:40 1.621803e-09 2.237442e-08 2.601783e-07 0.000003 0.000021 0.000147 0.000861 0.004259 0.017761 0.062423 ... 1.483342 0.795320 0.359425 0.136912 0.043958 0.011896 2.713505e-03 5.217054e-04 8.454455e-05 1.154813e-05
2014-11-24 17:38:20 5.773237e-10 8.459389e-09 1.044779e-07 0.000001 0.000010 0.000071 0.000440 0.002312 0.010238 0.038217 ... 1.658889 0.944679 0.453437 0.183449 0.062557 0.017981 4.356151e-03 8.895361e-04 1.531052e-04 2.221171e-05
2014-11-24 17:40:00 1.190384e-08 1.456607e-07 1.502322e-06 0.000013 0.000096 0.000591 0.003077 0.013501 0.049931 0.155649 ... 1.114449 0.529984 0.212437 0.071774 0.020439 0.004906 9.925650e-04 1.692603e-04 2.432860e-05 2.947437e-06
2014-11-24 17:41:40 4.706680e-06 3.876759e-05 2.691463e-04 0.001575 0.007768 0.032295 0.113168 0.334250 0.832119 1.746082 ... 0.238763 0.076431 0.020622 0.004690 0.000899 0.000145 1.978151e-05 2.270673e-06 2.196926e-07 1.791604e-08
2014-11-24 17:43:20 6.223350e-04 3.503695e-03 1.662624e-02 0.066501 0.224195 0.637076 1.525884 3.080473 5.241782 7.518068 ... 0.022882 0.005007 0.000923 0.000144 0.000019 0.000002 1.933167e-07 1.516745e-08 1.003047e-09 5.591082e-11
2014-11-24 17:45:00 9.432527e-05 6.200413e-04 3.435412e-03 0.016044 0.063153 0.209530 0.585960 1.381193 2.744141 4.595408 ... 0.065858 0.016825 0.003623 0.000658 0.000101 0.000013 1.409726e-06 1.291422e-07 9.971660e-09 6.489816e-10
2014-11-24 17:46:40 1.911539e-07 1.961036e-06 1.695719e-05 0.000124 0.000759 0.003931 0.017159 0.063122 0.195723 0.511528 ... 0.628429 0.250557 0.084202 0.023851 0.005694 0.001146 1.943746e-04 2.778965e-05 3.348824e-06 3.401474e-07
2014-11-24 17:48:20 1.621803e-09 2.237442e-08 2.601783e-07 0.000003 0.000021 0.000147 0.000861 0.004259 0.017761 0.062423 ... 1.483342 0.795320 0.359425 0.136912 0.043958 0.011896 2.713505e-03 5.217054e-04 8.454455e-05 1.154813e-05
2014-11-24 17:50:00 5.773237e-10 8.459389e-09 1.044779e-07 0.000001 0.000010 0.000071 0.000440 0.002312 0.010238 0.038217 ... 1.658889 0.944679 0.453437 0.183449 0.062557 0.017981 4.356151e-03 8.895361e-04 1.531052e-04 2.221171e-05
2014-11-24 17:51:40 1.190384e-08 1.456607e-07 1.502322e-06 0.000013 0.000096 0.000591 0.003077 0.013501 0.049931 0.155649 ... 1.114449 0.529984 0.212437 0.071774 0.020439 0.004906 9.925650e-04 1.692603e-04 2.432860e-05 2.947437e-06
2014-11-24 17:53:20 4.706680e-06 3.876759e-05 2.691463e-04 0.001575 0.007768 0.032295 0.113168 0.334250 0.832119 1.746082 ... 0.238763 0.076431 0.020622 0.004690 0.000899 0.000145 1.978151e-05 2.270673e-06 2.196926e-07 1.791604e-08
2014-11-24 17:55:00 6.223350e-04 3.503695e-03 1.662624e-02 0.066501 0.224195 0.637076 1.525884 3.080473 5.241782 7.518068 ... 0.022882 0.005007 0.000923 0.000144 0.000019 0.000002 1.933167e-07 1.516745e-08 1.003047e-09 5.591082e-11
2014-11-24 17:56:40 9.432527e-05 6.200413e-04 3.435412e-03 0.016044 0.063153 0.209530 0.585960 1.381193 2.744141 4.595408 ... 0.065858 0.016825 0.003623 0.000658 0.000101 0.000013 1.409726e-06 1.291422e-07 9.971660e-09 6.489816e-10
2014-11-24 17:58:20 1.911539e-07 1.961036e-06 1.695719e-05 0.000124 0.000759 0.003931 0.017159 0.063122 0.195723 0.511528 ... 0.628429 0.250557 0.084202 0.023851 0.005694 0.001146 1.943746e-04 2.778965e-05 3.348824e-06 3.401474e-07

36 rows × 29 columns

bins are the binedges. For an example of how they should be formatted look again to the sizedistribution generated above

[273]:
sd.bins
[273]:
array([  10.        ,   12.09727592,   14.63440848,   17.70364774,
         21.41659115,   25.90824126,   31.34191432,   37.91517855,
         45.86703767,   55.48662105,   67.1236965 ,   81.20138776,
         98.23155932,  118.83342776,  143.75607647,  173.90569229,
        210.37851445,  254.50069379,  307.87651158,  372.44671113,
        450.55906317,  545.05373075,  659.36653747,  797.65389392,
        964.9439247 , 1167.31929089, 1412.1383554 , 1708.3027329 ,
       2066.58095226, 2500.        ])

To see options for the distType argument see help file. This is what our generated was:

[274]:
sd.distributionType
[274]:
'dNdDp'

create the instance

[275]:
sdc = atmsd.SizeDist_TS(sd.data, sd.bins, sd.distributionType)

Methods

Plotting

[277]:
sd.plot()
[277]:
(<Figure size 1280x960 with 2 Axes>,
 <Axes: xlabel='Time (UTC)', ylabel='Diameter (nm)'>,
 <matplotlib.collections.QuadMesh at 0x7f011fc96e90>,
 <matplotlib.colorbar.Colorbar at 0x7f0123b27040>)
../_images/notebooks_aerosols_sizedistribution_SizeDist_TS_17_1.png

Conversion to Vertical profile

To convert the timeseries to a vertical profile one needs to attach a “housekeeping” file which it self needs to be a TimeSeries instance and has a column with the nam Altitude. BTW, the housekeeping file will also be converted into a vertical profile.

[292]:
import atmPy.general.timeseries as atmts
[ ]:
# connect the housekeeping, sorry for the awkward solution
hk = pd.DataFrame(index = sd.data.index, columns=['Altitude'], dtype=float)
hk.Altitude.iloc[[0,-1]] = [0,3000]
hk = hk.interpolate()

sd.housekeeping = atmts.TimeSeries(hk) #this will take care of interpolation if the timestamps are different
[295]:
# convert Vertical profile
sdvp = sd.convert2verticalprofile(layer_thickness=100)
[296]:
sdvp.plot()
[296]:
(<Figure size 1280x960 with 2 Axes>,
 <Axes: xlabel='Diameter (nm)', ylabel='Altitude (m)'>,
 <matplotlib.collections.QuadMesh at 0x7f01250a67d0>,
 <matplotlib.colorbar.Colorbar at 0x7f0121daf850>)
../_images/notebooks_aerosols_sizedistribution_SizeDist_TS_23_1.png

hygroscopic growth and optical properties

The difference to hygroscopic growth and optical properties of the SizeDist instance is that you can let the RH and refractive index change over time.

GOTCHA you can loose particles when applying growth!!! See help of sd.grow_sizedistribution function! There are functions that extrapolate size distributions assuming normal distributions. Consider using those.

[280]:
sd.optical_properties.parameters.refractive_index = 1.5
sd.optical_properties.parameters.wavelength = 500
[287]:
rh = pd.DataFrame(index = sd.data.index, columns=['RH'], dtype=float)
rh.RH.iloc[[0,-1]] = [0,95]
rh = rh.interpolate()
[282]:
sd.hygroscopicity.parameters.kappa = 1.5
sd.hygroscopicity.parameters.RH = rh
[283]:
sd.hygroscopicity.grown_size_distribution.plot()
[283]:
(<Figure size 1280x960 with 2 Axes>,
 <Axes: xlabel='Time (UTC)', ylabel='Diameter (nm)'>,
 <matplotlib.collections.QuadMesh at 0x7f0123095960>,
 <matplotlib.colorbar.Colorbar at 0x7f01201cd0f0>)
../_images/notebooks_aerosols_sizedistribution_SizeDist_TS_29_1.png
[284]:
a = sd.optical_properties.scattering_coeff.plot()
sd.hygroscopicity.grown_size_distribution.optical_properties.scattering_coeff.plot(ax = a)
[284]:
<Axes: xlabel='Time'>
../_images/notebooks_aerosols_sizedistribution_SizeDist_TS_30_1.png

Note, the refractive index of the hygroscopically grown size distribution is changing and approaches that of water.

[285]:
sd.hygroscopicity.grown_size_distribution.optical_properties.parameters
[285]:
asphericity      :  1
mie_result       :  None
refractive_index :                       index_of_refraction
2014-11-24 17:00:00             1.500000
2014-11-24 17:01:40             1.493171
2014-11-24 17:03:20             1.486523
2014-11-24 17:05:00             1.480048
2014-11-24 17:06:40             1.473740
2014-11-24 17:08:20             1.467592
2014-11-24 17:10:00             1.461598
2014-11-24 17:11:40             1.455753
2014-11-24 17:13:20             1.450052
2014-11-24 17:15:00             1.444488
2014-11-24 17:16:40             1.439057
2014-11-24 17:18:20             1.433754
2014-11-24 17:20:00             1.428575
2014-11-24 17:21:40             1.423515
2014-11-24 17:23:20             1.418571
2014-11-24 17:25:00             1.413739
2014-11-24 17:26:40             1.409014
2014-11-24 17:28:20             1.404393
2014-11-24 17:30:00             1.399874
2014-11-24 17:31:40             1.395451
2014-11-24 17:33:20             1.391124
2014-11-24 17:35:00             1.386887
2014-11-24 17:36:40             1.382739
2014-11-24 17:38:20             1.378677
2014-11-24 17:40:00             1.374698
2014-11-24 17:41:40             1.370800
2014-11-24 17:43:20             1.366980
2014-11-24 17:45:00             1.363236
2014-11-24 17:46:40             1.359565
2014-11-24 17:48:20             1.355966
2014-11-24 17:50:00             1.352437
2014-11-24 17:51:40             1.348974
2014-11-24 17:53:20             1.345578
2014-11-24 17:55:00             1.342245
2014-11-24 17:56:40             1.338974
2014-11-24 17:58:20             1.335763
wavelength       :  500
[ ]: