Size distribution
Heatmaps, per-scan curves and 3-D views of dN/dS/dV/dlogDp matrices, plus
lognormal curve fitting. Input is the matrix RawDataReader('SMPS' | 'APS')
returns (index = time, columns = diameters). Usage:
Visualization.
AeroViz.plot.distribution
Functions:
plot_dist
plot_dist(data: DataFrame | ndarray, data_std: DataFrame | None = None, std_scale: float | None = 1, unit: Literal['Number', 'Surface', 'Volume', 'Extinction'] = 'Number', additional: Literal['Std', 'Enhancement', 'Error'] = None, fig: Figure | None = None, ax: Axes | None = None, **kwargs) -> tuple[Figure, Axes]
Plot particle size distribution curves and optionally show enhancements.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
dict or list
|
If dict, keys are labels and values are arrays of distribution values. If listed, it should contain three arrays for different curves. |
required |
data_std
|
dict
|
Dictionary containing standard deviation data for ambient extinction distribution. |
None
|
std_scale
|
float
|
The width of standard deviation. |
1
|
unit
|
(Number, Surface, Volume, Extinction)
|
Unit of measurement for the data. |
'Number'
|
additional
|
(std, enhancement, error)
|
Whether to show enhancement curves. |
'std'
|
fig
|
Figure
|
Matplotlib Figure object to use. |
None
|
ax
|
AxesSubplot
|
Matplotlib AxesSubplot object to use. If not provided, a new subplot will be created. |
None
|
**kwargs
|
dict
|
Additional keyword arguments. |
{}
|
Returns:
| Name | Type | Description |
|---|---|---|
ax |
AxesSubplot
|
Matplotlib AxesSubplot. |
Examples:
heatmap
heatmap(data: DataFrame, unit: Literal['Number', 'Surface', 'Volume', 'Extinction'], cmap: str = 'Blues', colorbar: bool = False, magic_number: int = 11, ax: Axes | None = None, **kwargs) -> tuple[Figure, Axes]
Plot a heatmap of particle size distribution.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
DataFrame
|
The data containing particle size distribution values. Each column corresponds to a size bin, and each row corresponds to a different distribution. |
required |
unit
|
(Number, Surface, Volume, Extinction)
|
The unit of measurement for the data. |
'Number'
|
cmap
|
str
|
The colormap to use for the heatmap. |
'Blues'
|
colorbar
|
bool
|
Whether to show the colorbar. |
False
|
magic_number
|
int
|
The number of bins to use for the histogram. |
11
|
ax
|
Axes
|
The axes to plot the heatmap on. If not provided, a new subplot will be created. |
None
|
**kwargs
|
Additional keyword arguments to pass to matplotlib functions. |
{}
|
Returns:
| Type | Description |
|---|---|
Axes
|
The Axes object containing the heatmap. |
Examples:
Notes
This function calculates a 2D histogram of the log-transformed particle sizes and the distribution values. It then plots the heatmap using a logarithmic color scale.
heatmap_tms
heatmap_tms(data: DataFrame, unit: Literal['Number', 'Surface', 'Volume', 'Extinction'], cmap: str = 'jet', ax: Axes | None = None, **kwargs) -> tuple[Figure, Axes]
Plot the size distribution over time.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
DataFrame
|
A DataFrame of particle concentrations to plot the heatmap. |
required |
ax
|
Axis
|
An axis object to plot on. If none is provided, one will be created. |
None
|
unit
|
Literal['Number', 'Surface', 'Volume', 'Extinction']
|
default='Number' |
required |
cmap
|
colormap
|
The colormap to use. Can be anything other that 'jet'. |
'viridis'
|
Returns:
| Name | Type | Description |
|---|---|---|
ax |
Axis
|
|
Notes
Do not dropna when using this code.
Examples:
Plot a SPMS + APS data:
three_dimension
three_dimension(data: DataFrame | ndarray, unit: Literal['Number', 'Surface', 'Volume', 'Extinction'], cmap: str = 'Blues', ax: Axes | None = None, **kwargs) -> tuple[Figure, Axes]
Create a 3D plot with data from a pandas DataFrame or numpy array.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
DataFrame or ndarray
|
Input data containing the values to be plotted. |
required |
unit
|
(Number, Surface, Volume, Extinction)
|
Unit of measurement for the data. |
'Number'
|
cmap
|
str
|
The colormap to use for the facecolors. |
'Blues'
|
ax
|
AxesSubplot
|
Matplotlib AxesSubplot. If not provided, a new subplot will be created. |
None
|
**kwargs
|
Additional keyword arguments to customize the plot. |
{}
|
Returns:
| Type | Description |
|---|---|
Axes
|
Matplotlib Axes object representing the 3D plot. |
Notes
- The function creates a 3D plot with data provided in a pandas DataFrame or numpy array.
- The x-axis is logarithmically scaled, and ticks and labels are formatted accordingly.
- Additional customization can be done using the **kwargs.
Example
three_dimension(DataFrame(...), unit='Number', cmap='Blues')
curve_fitting
curve_fitting(dp: ndarray, dist: ndarray | Series | DataFrame, mode: int = None, unit: Literal['Number', 'Surface', 'Volume', 'Extinction'] = None, ax: Axes | None = None, **kwargs) -> tuple[Figure, Axes]
Fit a log-normal distribution to the given data and plot the result.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dp
|
array
|
Array of diameter values. |
required |
dist
|
array
|
Array of distribution values corresponding to each diameter. |
required |
mode
|
int
|
Number of log-normal distributions to fit. Defaults to None. |
None
|
**kwargs
|
Additional keyword arguments passed to the plot function. |
{}
|
Returns:
| Type | Description |
|---|---|
None
|
|
Notes
- The function fits a sum of log-normal distribution to the input data.
- The number of distribution is determined by the 'mode' parameter.
- Additional plotting customization can be done using the **kwargs.
Example
curve_fitting(dp, dist, mode=2, xlabel="Diameter (nm)", ylabel="Distribution")
Modules
distribution
Classes
Unit
Functions:
plot_dist
plot_dist(data: DataFrame | ndarray, data_std: DataFrame | None = None, std_scale: float | None = 1, unit: Literal['Number', 'Surface', 'Volume', 'Extinction'] = 'Number', additional: Literal['Std', 'Enhancement', 'Error'] = None, fig: Figure | None = None, ax: Axes | None = None, **kwargs) -> tuple[Figure, Axes]
Plot particle size distribution curves and optionally show enhancements.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
dict or list
|
If dict, keys are labels and values are arrays of distribution values. If listed, it should contain three arrays for different curves. |
required |
data_std
|
dict
|
Dictionary containing standard deviation data for ambient extinction distribution. |
None
|
std_scale
|
float
|
The width of standard deviation. |
1
|
unit
|
(Number, Surface, Volume, Extinction)
|
Unit of measurement for the data. |
'Number'
|
additional
|
(std, enhancement, error)
|
Whether to show enhancement curves. |
'std'
|
fig
|
Figure
|
Matplotlib Figure object to use. |
None
|
ax
|
AxesSubplot
|
Matplotlib AxesSubplot object to use. If not provided, a new subplot will be created. |
None
|
**kwargs
|
dict
|
Additional keyword arguments. |
{}
|
Returns:
| Name | Type | Description |
|---|---|---|
ax |
AxesSubplot
|
Matplotlib AxesSubplot. |
Examples:
heatmap
heatmap(data: DataFrame, unit: Literal['Number', 'Surface', 'Volume', 'Extinction'], cmap: str = 'Blues', colorbar: bool = False, magic_number: int = 11, ax: Axes | None = None, **kwargs) -> tuple[Figure, Axes]
Plot a heatmap of particle size distribution.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
DataFrame
|
The data containing particle size distribution values. Each column corresponds to a size bin, and each row corresponds to a different distribution. |
required |
unit
|
(Number, Surface, Volume, Extinction)
|
The unit of measurement for the data. |
'Number'
|
cmap
|
str
|
The colormap to use for the heatmap. |
'Blues'
|
colorbar
|
bool
|
Whether to show the colorbar. |
False
|
magic_number
|
int
|
The number of bins to use for the histogram. |
11
|
ax
|
Axes
|
The axes to plot the heatmap on. If not provided, a new subplot will be created. |
None
|
**kwargs
|
Additional keyword arguments to pass to matplotlib functions. |
{}
|
Returns:
| Type | Description |
|---|---|
Axes
|
The Axes object containing the heatmap. |
Examples:
Notes
This function calculates a 2D histogram of the log-transformed particle sizes and the distribution values. It then plots the heatmap using a logarithmic color scale.
heatmap_tms
heatmap_tms(data: DataFrame, unit: Literal['Number', 'Surface', 'Volume', 'Extinction'], cmap: str = 'jet', ax: Axes | None = None, **kwargs) -> tuple[Figure, Axes]
Plot the size distribution over time.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
DataFrame
|
A DataFrame of particle concentrations to plot the heatmap. |
required |
ax
|
Axis
|
An axis object to plot on. If none is provided, one will be created. |
None
|
unit
|
Literal['Number', 'Surface', 'Volume', 'Extinction']
|
default='Number' |
required |
cmap
|
colormap
|
The colormap to use. Can be anything other that 'jet'. |
'viridis'
|
Returns:
| Name | Type | Description |
|---|---|---|
ax |
Axis
|
|
Notes
Do not dropna when using this code.
Examples:
Plot a SPMS + APS data:
three_dimension
three_dimension(data: DataFrame | ndarray, unit: Literal['Number', 'Surface', 'Volume', 'Extinction'], cmap: str = 'Blues', ax: Axes | None = None, **kwargs) -> tuple[Figure, Axes]
Create a 3D plot with data from a pandas DataFrame or numpy array.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
DataFrame or ndarray
|
Input data containing the values to be plotted. |
required |
unit
|
(Number, Surface, Volume, Extinction)
|
Unit of measurement for the data. |
'Number'
|
cmap
|
str
|
The colormap to use for the facecolors. |
'Blues'
|
ax
|
AxesSubplot
|
Matplotlib AxesSubplot. If not provided, a new subplot will be created. |
None
|
**kwargs
|
Additional keyword arguments to customize the plot. |
{}
|
Returns:
| Type | Description |
|---|---|
Axes
|
Matplotlib Axes object representing the 3D plot. |
Notes
- The function creates a 3D plot with data provided in a pandas DataFrame or numpy array.
- The x-axis is logarithmically scaled, and ticks and labels are formatted accordingly.
- Additional customization can be done using the **kwargs.
Example
three_dimension(DataFrame(...), unit='Number', cmap='Blues')
curve_fitting
curve_fitting(dp: ndarray, dist: ndarray | Series | DataFrame, mode: int = None, unit: Literal['Number', 'Surface', 'Volume', 'Extinction'] = None, ax: Axes | None = None, **kwargs) -> tuple[Figure, Axes]
Fit a log-normal distribution to the given data and plot the result.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dp
|
array
|
Array of diameter values. |
required |
dist
|
array
|
Array of distribution values corresponding to each diameter. |
required |
mode
|
int
|
Number of log-normal distributions to fit. Defaults to None. |
None
|
**kwargs
|
Additional keyword arguments passed to the plot function. |
{}
|
Returns:
| Type | Description |
|---|---|
None
|
|
Notes
- The function fits a sum of log-normal distribution to the input data.
- The number of distribution is determined by the 'mode' parameter.
- Additional plotting customization can be done using the **kwargs.
Example
curve_fitting(dp, dist, mode=2, xlabel="Diameter (nm)", ylabel="Distribution")