AeroViz 0.1.2__py3-none-any.whl → 0.1.3b0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of AeroViz might be problematic. Click here for more details.
- AeroViz/__init__.py +4 -4
- AeroViz/config/DEFAULT_DATA.csv +1417 -0
- AeroViz/config/DEFAULT_PNSD_DATA.csv +1417 -0
- AeroViz/dataProcess/Chemistry/__init__.py +38 -38
- AeroViz/dataProcess/Chemistry/_calculate.py +15 -15
- AeroViz/dataProcess/Chemistry/_isoropia.py +69 -68
- AeroViz/dataProcess/Chemistry/_mass_volume.py +158 -158
- AeroViz/dataProcess/Chemistry/_ocec.py +109 -109
- AeroViz/dataProcess/Chemistry/_partition.py +19 -18
- AeroViz/dataProcess/Chemistry/_teom.py +8 -11
- AeroViz/dataProcess/Optical/_IMPROVE.py +40 -39
- AeroViz/dataProcess/Optical/__init__.py +35 -35
- AeroViz/dataProcess/Optical/_absorption.py +35 -35
- AeroViz/dataProcess/Optical/_extinction.py +25 -24
- AeroViz/dataProcess/Optical/_mie.py +5 -6
- AeroViz/dataProcess/Optical/_mie_sd.py +89 -90
- AeroViz/dataProcess/Optical/_scattering.py +16 -16
- AeroViz/dataProcess/SizeDistr/__init__.py +37 -37
- AeroViz/dataProcess/SizeDistr/__merge.py +159 -158
- AeroViz/dataProcess/SizeDistr/_merge.py +155 -154
- AeroViz/dataProcess/SizeDistr/_merge_v1.py +162 -161
- AeroViz/dataProcess/SizeDistr/_merge_v2.py +153 -152
- AeroViz/dataProcess/SizeDistr/_merge_v3.py +326 -326
- AeroViz/dataProcess/SizeDistr/_merge_v4.py +272 -274
- AeroViz/dataProcess/SizeDistr/_size_distr.py +51 -51
- AeroViz/dataProcess/VOC/__init__.py +7 -7
- AeroViz/dataProcess/VOC/_potential_par.py +53 -55
- AeroViz/dataProcess/VOC/voc_par.json +464 -0
- AeroViz/dataProcess/__init__.py +4 -4
- AeroViz/dataProcess/core/__init__.py +59 -58
- AeroViz/plot/__init__.py +6 -1
- AeroViz/plot/bar.py +126 -0
- AeroViz/plot/box.py +68 -0
- AeroViz/plot/distribution/distribution.py +421 -427
- AeroViz/plot/meteorology/meteorology.py +240 -292
- AeroViz/plot/optical/__init__.py +0 -1
- AeroViz/plot/optical/optical.py +230 -230
- AeroViz/plot/pie.py +198 -0
- AeroViz/plot/regression.py +210 -0
- AeroViz/plot/scatter.py +99 -0
- AeroViz/plot/templates/__init__.py +0 -3
- AeroViz/plot/templates/contour.py +25 -25
- AeroViz/plot/templates/corr_matrix.py +86 -93
- AeroViz/plot/templates/diurnal_pattern.py +24 -24
- AeroViz/plot/templates/koschmieder.py +106 -106
- AeroViz/plot/templates/metal_heatmap.py +34 -34
- AeroViz/plot/timeseries/timeseries.py +53 -60
- AeroViz/plot/utils/__init__.py +2 -1
- AeroViz/plot/utils/_color.py +57 -57
- AeroViz/plot/utils/_unit.py +48 -48
- AeroViz/plot/utils/fRH.json +390 -0
- AeroViz/plot/utils/plt_utils.py +92 -0
- AeroViz/plot/utils/sklearn_utils.py +49 -0
- AeroViz/plot/utils/units.json +84 -0
- AeroViz/plot/violin.py +79 -0
- AeroViz/process/__init__.py +15 -15
- AeroViz/process/core/DataProc.py +9 -9
- AeroViz/process/core/SizeDist.py +81 -81
- AeroViz/process/method/PyMieScatt_update.py +488 -488
- AeroViz/process/method/mie_theory.py +231 -229
- AeroViz/process/method/prop.py +40 -40
- AeroViz/process/script/AbstractDistCalc.py +103 -103
- AeroViz/process/script/Chemical.py +166 -166
- AeroViz/process/script/IMPACT.py +40 -40
- AeroViz/process/script/IMPROVE.py +152 -152
- AeroViz/process/script/Others.py +45 -45
- AeroViz/process/script/PSD.py +26 -26
- AeroViz/process/script/PSD_dry.py +69 -70
- AeroViz/process/script/retrieve_RI.py +50 -51
- AeroViz/rawDataReader/__init__.py +57 -57
- AeroViz/rawDataReader/core/__init__.py +328 -326
- AeroViz/rawDataReader/script/AE33.py +18 -18
- AeroViz/rawDataReader/script/AE43.py +20 -20
- AeroViz/rawDataReader/script/APS_3321.py +30 -30
- AeroViz/rawDataReader/script/Aurora.py +23 -23
- AeroViz/rawDataReader/script/BC1054.py +40 -40
- AeroViz/rawDataReader/script/EPA_vertical.py +9 -9
- AeroViz/rawDataReader/script/GRIMM.py +21 -21
- AeroViz/rawDataReader/script/IGAC_TH.py +67 -67
- AeroViz/rawDataReader/script/IGAC_ZM.py +59 -59
- AeroViz/rawDataReader/script/MA350.py +39 -39
- AeroViz/rawDataReader/script/NEPH.py +74 -74
- AeroViz/rawDataReader/script/OCEC_LCRES.py +21 -21
- AeroViz/rawDataReader/script/OCEC_RES.py +16 -16
- AeroViz/rawDataReader/script/SMPS_TH.py +25 -25
- AeroViz/rawDataReader/script/SMPS_aim11.py +32 -32
- AeroViz/rawDataReader/script/SMPS_genr.py +31 -31
- AeroViz/rawDataReader/script/TEOM.py +28 -28
- AeroViz/rawDataReader/script/Table.py +12 -12
- AeroViz/rawDataReader/script/VOC_TH.py +16 -16
- AeroViz/rawDataReader/script/VOC_ZM.py +28 -28
- AeroViz/rawDataReader/script/__init__.py +20 -20
- AeroViz/rawDataReader/utils/config.py +161 -161
- AeroViz/tools/database.py +65 -65
- AeroViz/tools/dataclassifier.py +106 -106
- AeroViz/tools/dataprinter.py +51 -51
- AeroViz/tools/datareader.py +38 -38
- {AeroViz-0.1.2.dist-info → AeroViz-0.1.3b0.dist-info}/METADATA +5 -4
- AeroViz-0.1.3b0.dist-info/RECORD +110 -0
- AeroViz/config/__init__.py +0 -0
- AeroViz/plot/improve/__init__.py +0 -1
- AeroViz/plot/improve/improve.py +0 -240
- AeroViz/plot/optical/aethalometer.py +0 -77
- AeroViz/plot/templates/event_evolution.py +0 -65
- AeroViz/plot/templates/regression.py +0 -256
- AeroViz/plot/templates/scatter.py +0 -130
- AeroViz/plot/templates/templates.py +0 -398
- AeroViz/plot/utils/_decorator.py +0 -74
- AeroViz-0.1.2.dist-info/RECORD +0 -106
- {AeroViz-0.1.2.dist-info → AeroViz-0.1.3b0.dist-info}/LICENSE +0 -0
- {AeroViz-0.1.2.dist-info → AeroViz-0.1.3b0.dist-info}/WHEEL +0 -0
- {AeroViz-0.1.2.dist-info → AeroViz-0.1.3b0.dist-info}/top_level.txt +0 -0
AeroViz/plot/bar.py
ADDED
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
from typing import Literal
|
|
2
|
+
|
|
3
|
+
import matplotlib.pyplot as plt
|
|
4
|
+
import numpy as np
|
|
5
|
+
import pandas as pd
|
|
6
|
+
from matplotlib.pyplot import Figure, Axes
|
|
7
|
+
from pandas import DataFrame
|
|
8
|
+
|
|
9
|
+
from AeroViz.plot.utils import *
|
|
10
|
+
|
|
11
|
+
__all__ = ['bar']
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
@set_figure(fw='bold')
|
|
15
|
+
def bar(data_set: DataFrame | dict,
|
|
16
|
+
data_std: DataFrame | None,
|
|
17
|
+
labels: list[str],
|
|
18
|
+
unit: str,
|
|
19
|
+
style: Literal["stacked", "dispersed"] = "dispersed",
|
|
20
|
+
orientation: Literal["va", "ha"] = 'va',
|
|
21
|
+
ax: Axes | None = None,
|
|
22
|
+
symbol=True,
|
|
23
|
+
**kwargs
|
|
24
|
+
) -> tuple[Figure, Axes]:
|
|
25
|
+
"""
|
|
26
|
+
Parameters
|
|
27
|
+
----------
|
|
28
|
+
data_set : pd.DataFrame or dict
|
|
29
|
+
A mapping from category names to a list of species mean or a DataFrame with columns as categories and values as means.
|
|
30
|
+
data_std : pd.DataFrame or None
|
|
31
|
+
A DataFrame with standard deviations corresponding to data_set, or None if standard deviations are not provided.
|
|
32
|
+
labels : list of str
|
|
33
|
+
The species names.
|
|
34
|
+
unit : str
|
|
35
|
+
The unit for the values.
|
|
36
|
+
style : {'stacked', 'dispersed'}, default 'dispersed'
|
|
37
|
+
Whether to display the bars stacked or dispersed.
|
|
38
|
+
orientation : {'va', 'ha'}, default 'va'
|
|
39
|
+
The orientation of the bars, 'va' for vertical and 'ha' for horizontal.
|
|
40
|
+
ax : plt.Axes or None, default None
|
|
41
|
+
The Axes object to plot on. If None, a new figure and Axes are created.
|
|
42
|
+
symbol : bool, default True
|
|
43
|
+
Whether to display values for each bar.
|
|
44
|
+
kwargs : dict
|
|
45
|
+
Additional keyword arguments passed to the barplot function.
|
|
46
|
+
|
|
47
|
+
Returns
|
|
48
|
+
-------
|
|
49
|
+
matplotlib.Axes
|
|
50
|
+
The Axes object containing the plot.
|
|
51
|
+
|
|
52
|
+
"""
|
|
53
|
+
# data process
|
|
54
|
+
data = data_set.values
|
|
55
|
+
|
|
56
|
+
if data_std is None:
|
|
57
|
+
data_std = np.zeros(data.shape)
|
|
58
|
+
else:
|
|
59
|
+
data_std = data_std.values
|
|
60
|
+
|
|
61
|
+
groups, species = data.shape
|
|
62
|
+
groups_arr = np.arange(groups)
|
|
63
|
+
species_arr = np.arange(species)
|
|
64
|
+
|
|
65
|
+
total = np.array([data.sum(axis=1), ] * species).T
|
|
66
|
+
|
|
67
|
+
pct_data = data / total * 100
|
|
68
|
+
data_cum = pct_data.cumsum(axis=1)
|
|
69
|
+
|
|
70
|
+
# figure info
|
|
71
|
+
category_names = kwargs.get('ticks') or list(data_set.index)
|
|
72
|
+
title = kwargs.get('title', '')
|
|
73
|
+
colors = kwargs.get('colors') or (Color.colors1 if species == 6 else Color.getColor(num=species))
|
|
74
|
+
|
|
75
|
+
fig, ax = plt.subplots(**kwargs.get('fig_kws', {})) if ax is None else (ax.get_figure(), ax)
|
|
76
|
+
|
|
77
|
+
if style == "stacked":
|
|
78
|
+
for i in range(species):
|
|
79
|
+
widths = pct_data[:, i]
|
|
80
|
+
starts = data_cum[:, i] - pct_data[:, i]
|
|
81
|
+
|
|
82
|
+
if orientation == 'va':
|
|
83
|
+
_ = ax.bar(groups_arr, widths, bottom=starts, width=0.7, color=colors[i], label=labels[i],
|
|
84
|
+
edgecolor=None, capsize=None)
|
|
85
|
+
else:
|
|
86
|
+
_ = ax.barh(groups_arr, widths, left=starts, height=0.7, color=colors[i], label=labels[i],
|
|
87
|
+
edgecolor=None, capsize=None)
|
|
88
|
+
if symbol:
|
|
89
|
+
ax.bar_label(_, fmt=auto_label_pct, label_type='center', padding=0, fontsize=8, weight='bold')
|
|
90
|
+
|
|
91
|
+
if style == "dispersed":
|
|
92
|
+
width = 0.1
|
|
93
|
+
block = width / 4
|
|
94
|
+
|
|
95
|
+
for i in range(species):
|
|
96
|
+
val = data[:, i]
|
|
97
|
+
std = (0,) * groups, data_std[:, i]
|
|
98
|
+
if orientation == 'va':
|
|
99
|
+
_ = ax.bar(groups_arr + (i + 1) * (width + block), val, yerr=std, width=width, color=colors[i],
|
|
100
|
+
edgecolor=None, capsize=None)
|
|
101
|
+
else:
|
|
102
|
+
_ = ax.barh(groups_arr + (i + 1) * (width + block), val, xerr=std, height=width, color=colors[i],
|
|
103
|
+
edgecolor=None, capsize=None)
|
|
104
|
+
if symbol:
|
|
105
|
+
ax.bar_label(_, fmt=auto_label_pct, label_type='center', padding=0, fontsize=8, weight='bold')
|
|
106
|
+
|
|
107
|
+
if orientation == 'va':
|
|
108
|
+
xticks = groups_arr + (species / 2 + 0.5) * (width + block) if style == "dispersed" else groups_arr
|
|
109
|
+
ax.set_xticks(xticks, category_names, weight='bold')
|
|
110
|
+
ax.set_ylabel(Unit(unit) if style == "dispersed" else '$Contribution (\\%)$')
|
|
111
|
+
ax.set_ylim(0, None if style == "dispersed" else 100)
|
|
112
|
+
ax.legend(labels, bbox_to_anchor=(1, 1), loc='upper left', prop={'size': 8})
|
|
113
|
+
|
|
114
|
+
if orientation == 'ha':
|
|
115
|
+
ax.invert_yaxis()
|
|
116
|
+
yticks = groups_arr + 3.5 * (width + block) if style == "dispersed" else groups_arr
|
|
117
|
+
ax.set_yticks(yticks, category_names, weight='bold')
|
|
118
|
+
ax.set_xlabel(Unit(unit) if style == "dispersed" else '$Contribution (\\%)$')
|
|
119
|
+
ax.set_xlim(0, None if style == "dispersed" else 100)
|
|
120
|
+
ax.legend(labels, bbox_to_anchor=(1, 1), loc='upper left', prop={'size': 8})
|
|
121
|
+
|
|
122
|
+
# fig.savefig(f"Barplot_{title}")
|
|
123
|
+
|
|
124
|
+
plt.show()
|
|
125
|
+
|
|
126
|
+
return fig, ax
|
AeroViz/plot/box.py
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import matplotlib.pyplot as plt
|
|
2
|
+
import numpy as np
|
|
3
|
+
import pandas as pd
|
|
4
|
+
from matplotlib.pyplot import Figure, Axes
|
|
5
|
+
|
|
6
|
+
from AeroViz.plot.utils import *
|
|
7
|
+
|
|
8
|
+
__all__ = ['box']
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
@set_figure
|
|
12
|
+
def box(df: pd.DataFrame,
|
|
13
|
+
x: str,
|
|
14
|
+
y: str,
|
|
15
|
+
x_bins: list | np.ndarray = None,
|
|
16
|
+
add_scatter: bool = True,
|
|
17
|
+
ax: Axes | None = None,
|
|
18
|
+
**kwargs) -> tuple[Figure, Axes]:
|
|
19
|
+
fig, ax = plt.subplots(**kwargs.get('fig_kws', {})) if ax is None else (ax.get_figure(), ax)
|
|
20
|
+
|
|
21
|
+
df = df.dropna(subset=[x, y]).copy()
|
|
22
|
+
x_data, y_data = df[x].to_numpy(), df[y].to_numpy()
|
|
23
|
+
|
|
24
|
+
bins = np.array(x_bins)
|
|
25
|
+
bins = np.round(bins)
|
|
26
|
+
wid = (bins + (bins[1] - bins[0]) / 2)[0:-1]
|
|
27
|
+
|
|
28
|
+
df[x + '_bin'] = pd.cut(x=x_data, bins=bins, labels=wid)
|
|
29
|
+
|
|
30
|
+
group = x + '_bin'
|
|
31
|
+
column = y
|
|
32
|
+
grouped = df.groupby(group, observed=False)
|
|
33
|
+
|
|
34
|
+
names, vals = [], []
|
|
35
|
+
|
|
36
|
+
for i, (name, subdf) in enumerate(grouped):
|
|
37
|
+
names.append('{:.0f}'.format(name))
|
|
38
|
+
vals.append(subdf[column].dropna().values)
|
|
39
|
+
|
|
40
|
+
plt.boxplot(vals, labels=names, positions=wid, widths=(bins[1] - bins[0]) / 3,
|
|
41
|
+
showfliers=False, showmeans=True, meanline=True, patch_artist=True,
|
|
42
|
+
boxprops=dict(facecolor='#f2c872', alpha=.7),
|
|
43
|
+
meanprops=dict(color='#000000', ls='none'),
|
|
44
|
+
medianprops=dict(ls='-', color='#000000'))
|
|
45
|
+
|
|
46
|
+
ax.set(xlim=kwargs.get('xlim', (x_data.min(), x_data.max())),
|
|
47
|
+
ylim=kwargs.get('ylim', (y_data.min(), y_data.max())),
|
|
48
|
+
xlabel=kwargs.get('xlabel', Unit(x)),
|
|
49
|
+
ylabel=kwargs.get('ylabel', Unit(y)),
|
|
50
|
+
title=kwargs.get('title', ''))
|
|
51
|
+
|
|
52
|
+
ax.set_xticks(bins, labels=bins.astype(int))
|
|
53
|
+
|
|
54
|
+
if add_scatter:
|
|
55
|
+
for i, (name, subdf) in enumerate(grouped):
|
|
56
|
+
jitter = np.random.normal(0, 0.5, len(subdf))
|
|
57
|
+
ax.scatter([name] * len(subdf) + jitter, subdf[column], s=10, c='gray', alpha=0.5)
|
|
58
|
+
|
|
59
|
+
plt.show()
|
|
60
|
+
|
|
61
|
+
return fig, ax
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
if __name__ == '__main__':
|
|
65
|
+
from AeroViz import DataBase
|
|
66
|
+
|
|
67
|
+
df = DataBase(load_data=True)
|
|
68
|
+
box(df, x='PM25', y='Extinction', x_bins=np.arange(0, 120, 10))
|