smps.GenericParticleSizer#
- class smps.GenericParticleSizer(data, bins, **kwargs)#
The base class for a Generic Size-Resolving Particle Instrument.
- Parameters
- datapd.DataFrame
A dataframe containing the binned particle data, timestamp column, and optional metadata columns.
- binsarray-like
A 3xn array defining the left, mid, and right boundaries for each particle size bin.
- dp_unitsstr, deafult=’um’
Define the units of particle bin sizes - one of (‘um’, ‘nm’)
- metadict, default=None
An optional dictionary containing meta information about the instrument.
- weightstr, default=’number’
The moment of the model. One of (‘number’, ‘surface’, ‘volume’).
- unitsstr, default=’dw/dlogdp’
The default data format in AIM-compatible string format.
- bin_weightsarray-like, default=ones
An optional array to set bin weights (e.g., counting efficiency). By default, all bin weights are 1.
- bin_prefixstr, default=’bin’
An optional kwarg to name the bins if not already named.
- fmtstr, default=’dn’
Optional kwarg describing the default data format. One of (‘dn’, ‘dndlogdp’).
See also
Examples
Initialize a base object with data and bins:
>>> obj = smps.models.GenericParticleSizer(data=df, bins=bins)
ATTRIBUTES
- dddlogdp#
Can otherwise be represented as \(dD/dlogD_p\).
- dlogdp#
Log difference between the upper and lower bound of each bin.
- dn#
The number concentration per bin. Can otherwise be represented as \(dN/dD_p\). Units are pp/cm3.
- dndlogdp#
The log normalized number concentration per bin. Can otherwise be represented as \(dN/dlogD_p\). Units are pp/cm3.
- ds#
Surface area per bin.
- dsdlogdp#
Log normalized surface area per bin. Otherwise represented as \(dS/dlogDp\). Units are: µm2/cm3.
- dv#
Volume per bin.
- dvdlogdp#
Log normalized volume per bin. Can otherwise be represented as \(dV/dlogDp\). Units are µm3/cm3.
- midpoints#
Midpoint particle diameter in each bin.
- s_multiplier#
Per particle surface area representing the mean particle in each bin.
- scan_stats#
Return the non-binned data.
- v_multiplier#
Per particle volume representing the mean particle in each bin.
METHODS
- __init__(data, bins, **kwargs)#
- copy()#
Return a copy of the GenericParticleSizer.
Examples
>>> obj = GenericParticleSize(data=df) >>> cpy = obj.copy()
- dump(filepath)#
Save a copy of the model to disk.
- Parameters
- filepathstr
The filepath to save the file at.
- Returns
- filepathlist
The list of filepaths where data was saved.
Examples
>>> model.dump(filepath="path-to-file.sav")
- integrate(weight='number', dmin=0.0, dmax=1.0, **kwargs)#
Integrate by weight for each record in time.
Compute the total number of particles, surface area, volume, or mass between any two particle diameters. Correct for hygroscopic growth by defining a hygroscopic growth factor, kappa.
- Parameters
- weightstr, default=’number’
The moment/variable to integrate. One of (‘number’, ‘surface’, ‘volume’, ‘mass’).
- dminfloat, default=0.0
The minimum particle diameter in µm.
- dmaxfloat, default=1.
The maximum particle diameter in µm.
- rhofloat or callable
The density as a float or a callable function which takes particle diameter as its only argument and returns the density at that diameter.
- kappafloat or callable
The kappa growth factor as a float or a callable function which takes particles diameter as its only argument and returns the kappa value at that diameter.
- rhstr
If kappa is defined, rh is the column of data corresponding to the relative humidity which is required to correct for hygroscopic growth.
- Returns
- datapd.Series
A series containing the integrated values.
Examples
Compute the total particle concentration under 1 µm:
>>> obj.integrate(weight='number', dmin=0., dmax=1.)
Compute PM1
>>> obj.integrate(weight='mass', dmin=0., dmax=1.)
Compute PM2.5 assuming a kappa=0.3
>>> obj.integrate(weight='mass', dmin=0., dmax=2.5, kappa=0.3, rh="sample_rh")
- resample(rs, inplace=False)#
Resample the data to a new time base.
- Parameters
- rsstr
The resample period using normal pandas convention. Examples include ‘1h’, ‘1d’, ‘15min’, etc.
- inplacebool, default=False
If True, modify the data inplace, otherwise return.
- Returns
- datapd.DataFrame or None
If inplace=False, return the dataframe with the resampled data.
Examples
Resample to 1h and modify in place
>>> obj.resample('1h', inplace=True)
- slice(start=None, end=None, inplace=False)#
Slice the data between two datetimes.
- Parameters
- startstr
The timestamp (as a string) to begin the slice.
- endstr
The timestamp (as a string) to end the slice.
- inplacebool, default=False
If True, replace the data with the specified slice of the data, otherwise return a copy of the sliced data.
- Returns
- datapd.DataFrame or None
If inplace=False, return the dataframe with the sliced data.
Examples
>>> obj.slice(start="2023-01-01", end="2023-02-15")
- stats(weight='number', dmin=0.0, dmax=1000.0, rho=1.65, **kwargs)#
Compute and return the aerosol size distribution statistics.
Calculate the total number of particles, surface area, volume, mass, arithmetic mean particle diameter, geometric mean particle diameter, and geometric standard deviation between any two particle diameters.
- Parameters
- weight: str, default=’number’
The moment to use to compute the statistics. Should be one of (‘number’, ‘surface’, ‘volume’, ‘mass’).
- dminfloat, default=0.0
The minimum particle diameter to consider. Units are in µm.
- dmaxfloat, default=1000.0
The maximum particle diameter to consider. Units are in µm.
- rhofloat, default=1.65
The particle density in units of g/cm3.
- Returns
- datapd.DataFrame
A dataframe containing the computed statistics at each point in time.
Examples
Compute the number-weighted stats
>>> obj.stats(weight='number')
Compute the volume-weighted stats for PM2.5
>>> obj.stats(weight='volume', dmin=0, dmax=2.5)