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
|
@@ -12,97 +12,90 @@ from AeroViz.plot.utils import *
|
|
|
12
12
|
__all__ = ['corr_matrix']
|
|
13
13
|
|
|
14
14
|
|
|
15
|
-
@set_figure
|
|
15
|
+
@set_figure
|
|
16
16
|
def corr_matrix(data: pd.DataFrame,
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
)
|
|
103
|
-
|
|
104
|
-
ax.legend(handles=[point2], labels=['p < 0.05'], bbox_to_anchor=(0.05, 1, 0.1, 0.05))
|
|
105
|
-
|
|
106
|
-
plt.show()
|
|
107
|
-
|
|
108
|
-
return fig, ax
|
|
17
|
+
cmap: str = "RdBu",
|
|
18
|
+
ax: Axes | None = None,
|
|
19
|
+
**kwargs
|
|
20
|
+
) -> tuple[Figure, Axes]:
|
|
21
|
+
fig, ax = plt.subplots(**kwargs.get('fig_kws', {})) if ax is None else (ax.get_figure(), ax)
|
|
22
|
+
|
|
23
|
+
_corr = data.corr()
|
|
24
|
+
corr = pd.melt(_corr.reset_index(), id_vars='index')
|
|
25
|
+
corr.columns = ['x', 'y', 'value']
|
|
26
|
+
|
|
27
|
+
p_values = _corr.apply(lambda col1: _corr.apply(lambda col2: pearsonr(col1, col2)[1]))
|
|
28
|
+
p_values = p_values.mask(p_values > 0.05)
|
|
29
|
+
p_values = pd.melt(p_values.reset_index(), id_vars='index').dropna()
|
|
30
|
+
p_values.columns = ['x', 'y', 'value']
|
|
31
|
+
|
|
32
|
+
# Mapping from column names to integer coordinates
|
|
33
|
+
x_labels = [v for v in sorted(corr['x'].unique())]
|
|
34
|
+
y_labels = [v for v in sorted(corr['y'].unique())]
|
|
35
|
+
x_to_num = {p[1]: p[0] for p in enumerate(x_labels)}
|
|
36
|
+
y_to_num = {p[1]: p[0] for p in enumerate(y_labels)}
|
|
37
|
+
|
|
38
|
+
# Show column labels on the axes
|
|
39
|
+
ax.set_xticks([x_to_num[v] for v in x_labels])
|
|
40
|
+
ax.set_xticklabels(x_labels, rotation=90, horizontalalignment='center')
|
|
41
|
+
ax.set_yticks([y_to_num[v] for v in y_labels])
|
|
42
|
+
ax.set_yticklabels(y_labels)
|
|
43
|
+
|
|
44
|
+
# ax.tick_params(axis='both', which='major', direction='out', top=True, left=True)
|
|
45
|
+
|
|
46
|
+
ax.grid(False, 'major')
|
|
47
|
+
ax.grid(True, 'minor')
|
|
48
|
+
ax.set_xticks([t + 0.5 for t in ax.get_xticks()], minor=True)
|
|
49
|
+
ax.set_yticks([t + 0.5 for t in ax.get_yticks()], minor=True)
|
|
50
|
+
|
|
51
|
+
ax.set_xlim([-0.5, max([v for v in x_to_num.values()]) + 0.5])
|
|
52
|
+
ax.set_ylim([-0.5, max([v for v in y_to_num.values()]) + 0.5])
|
|
53
|
+
|
|
54
|
+
n_colors = 256 # Use 256 colors for the diverging color palette
|
|
55
|
+
palette = sns.color_palette(cmap, n_colors=n_colors) # Create the palette
|
|
56
|
+
|
|
57
|
+
# Range of values that will be mapped to the palette, i.e. min and max possible correlation
|
|
58
|
+
color_min, color_max = [-1, 1]
|
|
59
|
+
|
|
60
|
+
def value_to_color(val):
|
|
61
|
+
val_position = float((val - color_min)) / (color_max - color_min)
|
|
62
|
+
ind = int(val_position * (n_colors - 1)) # target index in the color palette
|
|
63
|
+
return palette[ind]
|
|
64
|
+
|
|
65
|
+
point = ax.scatter(
|
|
66
|
+
x=corr['x'].map(x_to_num),
|
|
67
|
+
y=corr['y'].map(y_to_num),
|
|
68
|
+
s=corr['value'].abs() * 70,
|
|
69
|
+
c=corr['value'].apply(value_to_color), # Vector of square color values, mapped to color palette
|
|
70
|
+
marker='s',
|
|
71
|
+
label='$R^{2}$'
|
|
72
|
+
)
|
|
73
|
+
|
|
74
|
+
axes_image = plt.cm.ScalarMappable(cmap=colormaps[cmap])
|
|
75
|
+
|
|
76
|
+
cax = inset_axes(ax, width="5%",
|
|
77
|
+
height="100%",
|
|
78
|
+
loc='lower left',
|
|
79
|
+
bbox_to_anchor=(1.02, 0., 1, 1),
|
|
80
|
+
bbox_transform=ax.transAxes,
|
|
81
|
+
borderpad=0)
|
|
82
|
+
|
|
83
|
+
cbar = plt.colorbar(mappable=axes_image, cax=cax, label=r'$R^{2}$')
|
|
84
|
+
|
|
85
|
+
cbar.set_ticks([0, 0.25, 0.5, 0.75, 1])
|
|
86
|
+
cbar.set_ticklabels(np.linspace(-1, 1, 5))
|
|
87
|
+
|
|
88
|
+
point2 = ax.scatter(
|
|
89
|
+
x=p_values['x'].map(x_to_num),
|
|
90
|
+
y=p_values['y'].map(y_to_num),
|
|
91
|
+
s=10,
|
|
92
|
+
marker='*',
|
|
93
|
+
color='k',
|
|
94
|
+
label='p < 0.05'
|
|
95
|
+
)
|
|
96
|
+
|
|
97
|
+
ax.legend(handles=[point2], labels=['p < 0.05'], bbox_to_anchor=(0.05, 1, 0.1, 0.05))
|
|
98
|
+
|
|
99
|
+
plt.show()
|
|
100
|
+
|
|
101
|
+
return fig, ax
|
|
@@ -8,35 +8,35 @@ from AeroViz.plot.utils import *
|
|
|
8
8
|
__all__ = ['diurnal_pattern']
|
|
9
9
|
|
|
10
10
|
|
|
11
|
-
@set_figure
|
|
11
|
+
@set_figure
|
|
12
12
|
def diurnal_pattern(data_set: pd.DataFrame,
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
13
|
+
data_std: pd.DataFrame,
|
|
14
|
+
y: str | list[str],
|
|
15
|
+
std_area=0.5,
|
|
16
|
+
ax: Axes | None = None,
|
|
17
|
+
**kwargs) -> tuple[Figure, Axes]:
|
|
18
|
+
fig, ax = plt.subplots(**kwargs.get('fig_kws', {})) if ax is None else (ax.get_figure(), ax)
|
|
19
19
|
|
|
20
|
-
|
|
20
|
+
Hour = range(0, 24)
|
|
21
21
|
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
mean = data_set[y]
|
|
23
|
+
std = data_std[y] * std_area
|
|
24
24
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
25
|
+
# Plot Diurnal pattern
|
|
26
|
+
ax.plot(Hour, mean, 'blue')
|
|
27
|
+
ax.fill_between(Hour, y1=mean + std, y2=mean - std, alpha=0.5, color='blue', edgecolor=None)
|
|
28
28
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
29
|
+
ax.set(xlabel=kwargs.get('xlabel', 'Hours'),
|
|
30
|
+
ylabel=kwargs.get('ylabel', Unit(y)),
|
|
31
|
+
xlim=kwargs.get('xlim', (0, 23)),
|
|
32
|
+
ylim=kwargs.get('ylim', (None, None)),
|
|
33
|
+
xticks=kwargs.get('xticks', [0, 4, 8, 12, 16, 20]))
|
|
34
34
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
35
|
+
ax.tick_params(axis='both', which='major')
|
|
36
|
+
ax.tick_params(axis='x', which='minor')
|
|
37
|
+
ax.xaxis.set_minor_locator(AutoMinorLocator())
|
|
38
|
+
ax.ticklabel_format(axis='y', style='sci', scilimits=(-2, 3), useMathText=True)
|
|
39
39
|
|
|
40
|
-
|
|
40
|
+
plt.show()
|
|
41
41
|
|
|
42
|
-
|
|
42
|
+
return fig, ax
|
|
@@ -13,144 +13,144 @@ __all__ = ['koschmieder']
|
|
|
13
13
|
|
|
14
14
|
@set_figure(fs=12)
|
|
15
15
|
def koschmieder(df: pd.DataFrame,
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
16
|
+
y: Literal['Vis_Naked', 'Vis_LPV'],
|
|
17
|
+
function: Literal['log', 'reciprocal'] = 'log',
|
|
18
|
+
ax: Axes | None = None,
|
|
19
|
+
**kwargs) -> tuple[Figure, Axes]:
|
|
20
|
+
# x = Visibility, y = Extinction, log-log fit!!
|
|
21
|
+
def _log_fit(x, y, func=lambda x, a: -x + a):
|
|
22
|
+
x_log = np.log(x)
|
|
23
|
+
y_log = np.log(y)
|
|
24
|
+
|
|
25
|
+
popt, pcov = curve_fit(func, x_log, y_log)
|
|
26
26
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
27
|
+
residuals = y_log - func(x_log, *popt)
|
|
28
|
+
ss_res = np.sum(residuals ** 2)
|
|
29
|
+
ss_total = np.sum((y_log - np.mean(y_log)) ** 2)
|
|
30
|
+
r_squared = 1 - (ss_res / ss_total)
|
|
31
|
+
print(f'Const_Log = {popt[0].round(3)}')
|
|
32
|
+
print(f'Const = {np.exp(popt)[0].round(3)}')
|
|
33
|
+
print(f'R^2 = {r_squared.round(3)}')
|
|
34
|
+
return np.exp(popt)[0], pcov
|
|
35
|
+
|
|
36
|
+
def _reciprocal_fit(x, y, func=lambda x, a, b: a / (x ** b)):
|
|
37
|
+
popt, pcov = curve_fit(func, x, y)
|
|
38
38
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
39
|
+
residuals = y - func(x, *popt)
|
|
40
|
+
ss_res = np.sum(residuals ** 2)
|
|
41
|
+
ss_total = np.sum((y - np.mean(y)) ** 2)
|
|
42
|
+
r_squared = 1 - (ss_res / ss_total)
|
|
43
|
+
print(f'Const = {popt.round(3)}')
|
|
44
|
+
print(f' R^2 = {r_squared.round(3)}')
|
|
45
|
+
return popt, pcov
|
|
46
46
|
|
|
47
|
-
|
|
47
|
+
fig, ax = plt.subplots(**kwargs.get('fig_kws', {})) if ax is None else (ax.get_figure(), ax)
|
|
48
48
|
|
|
49
|
-
|
|
50
|
-
|
|
49
|
+
_df1 = df[['Extinction', 'ExtinctionByGas', y]].dropna().copy()
|
|
50
|
+
_df2 = df[['total_ext_dry', 'ExtinctionByGas', y]].dropna().copy()
|
|
51
51
|
|
|
52
|
-
|
|
53
|
-
|
|
52
|
+
x_data1 = _df1[y]
|
|
53
|
+
y_data1 = _df1['Extinction'] + _df1['ExtinctionByGas']
|
|
54
54
|
|
|
55
|
-
|
|
56
|
-
|
|
55
|
+
x_data2 = _df2[y]
|
|
56
|
+
y_data2 = _df2['total_ext_dry'] + _df2['ExtinctionByGas']
|
|
57
57
|
|
|
58
|
-
|
|
59
|
-
|
|
58
|
+
para_coeff = []
|
|
59
|
+
boxcolors = ['#3f83bf', '#a5bf6b']
|
|
60
60
|
|
|
61
|
-
|
|
62
|
-
|
|
61
|
+
for i, (df_, x_data, y_data) in enumerate(zip([_df1, _df2], [x_data1, x_data2], [y_data1, y_data2])):
|
|
62
|
+
df_['Total_Ext'] = y_data
|
|
63
63
|
|
|
64
|
-
|
|
65
|
-
|
|
64
|
+
if y == 'Vis_Naked':
|
|
65
|
+
df_grp = df_.groupby(f'{y}')
|
|
66
66
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
67
|
+
vals, median_vals, vis = [], [], []
|
|
68
|
+
for j, (name, subdf) in enumerate(df_grp):
|
|
69
|
+
if len(subdf['Total_Ext'].dropna()) > 20:
|
|
70
|
+
vis.append('{:.0f}'.format(name))
|
|
71
|
+
vals.append(subdf['Total_Ext'].dropna().values)
|
|
72
|
+
median_vals.append(subdf['Total_Ext'].dropna().median())
|
|
73
73
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
74
|
+
plt.boxplot(vals, labels=vis, positions=np.array(vis, dtype='int'), widths=0.4,
|
|
75
|
+
showfliers=False, showmeans=True, meanline=False, patch_artist=True,
|
|
76
|
+
boxprops=dict(facecolor=boxcolors[i], alpha=.7),
|
|
77
|
+
meanprops=dict(marker='o', markerfacecolor='white', markeredgecolor='k', markersize=4),
|
|
78
|
+
medianprops=dict(color='#000000', ls='-'))
|
|
79
79
|
|
|
80
|
-
|
|
80
|
+
plt.scatter(x_data, y_data, marker='.', s=10, facecolor='white', edgecolor=boxcolors[i], alpha=0.1)
|
|
81
81
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
82
|
+
if y == 'Vis_LPV':
|
|
83
|
+
bins = np.linspace(0, 70, 36)
|
|
84
|
+
wid = (bins + (bins[1] - bins[0]) / 2)[0:-1]
|
|
85
85
|
|
|
86
|
-
|
|
86
|
+
df_[f'{x_data.name}' + '_bins'] = pd.cut(x=x_data, bins=bins, labels=wid)
|
|
87
87
|
|
|
88
|
-
|
|
88
|
+
grouped = df_.groupby(f'{x_data.name}' + '_bins', observed=False)
|
|
89
89
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
90
|
+
vals, median_vals, vis = [], [], []
|
|
91
|
+
for j, (name, subdf) in enumerate(grouped):
|
|
92
|
+
if len(subdf['Total_Ext'].dropna()) > 20:
|
|
93
|
+
vis.append('{:.1f}'.format(name))
|
|
94
|
+
vals.append(subdf['Total_Ext'].dropna().values)
|
|
95
|
+
median_vals.append(subdf['Total_Ext'].dropna().mean())
|
|
96
96
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
97
|
+
plt.boxplot(vals, labels=vis, positions=np.array(vis, dtype='float'), widths=(bins[1] - bins[0]) / 2.5,
|
|
98
|
+
showfliers=False, showmeans=True, meanline=False, patch_artist=True,
|
|
99
|
+
boxprops=dict(facecolor=boxcolors[i], alpha=.7),
|
|
100
|
+
meanprops=dict(marker='o', markerfacecolor='white', markeredgecolor='k', markersize=4),
|
|
101
|
+
medianprops=dict(color='#000000', ls='-'))
|
|
102
102
|
|
|
103
|
-
|
|
103
|
+
plt.scatter(x_data, y_data, marker='.', s=10, facecolor='white', edgecolor=boxcolors[i], alpha=0.1)
|
|
104
104
|
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
105
|
+
# fit curve
|
|
106
|
+
_x = np.array(vis, dtype='float')
|
|
107
|
+
_y = np.array(median_vals, dtype='float')
|
|
108
108
|
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
109
|
+
if function == 'log':
|
|
110
|
+
func = lambda x, a: a / x
|
|
111
|
+
coeff, pcov = _log_fit(_x, _y)
|
|
112
112
|
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
113
|
+
else:
|
|
114
|
+
func = lambda x, a, b: a / (x ** b)
|
|
115
|
+
coeff, pcov = _reciprocal_fit(_x, _y)
|
|
116
116
|
|
|
117
|
-
|
|
117
|
+
para_coeff.append(coeff)
|
|
118
118
|
|
|
119
|
-
|
|
120
|
-
|
|
119
|
+
# Plot lines (ref & Measurement)
|
|
120
|
+
x_fit = np.linspace(0.1, 70, 1000)
|
|
121
121
|
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
122
|
+
if function == 'log':
|
|
123
|
+
line1, = ax.plot(x_fit, func(x_fit, para_coeff[0]), c='b', lw=3)
|
|
124
|
+
line2, = ax.plot(x_fit, func(x_fit, para_coeff[1]), c='g', lw=3)
|
|
125
125
|
|
|
126
|
-
|
|
127
|
-
|
|
126
|
+
labels = ['Vis (km) = ' + f'{round(para_coeff[0])}' + ' / Ext (Dry Extinction)',
|
|
127
|
+
'Vis (km) = ' + f'{round(para_coeff[1])}' + ' / Ext (Amb Extinction)']
|
|
128
128
|
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
129
|
+
else:
|
|
130
|
+
x_fit = np.linspace(0.1, 70, 1000)
|
|
131
|
+
line1, = ax.plot(x_fit, func(x_fit, *para_coeff[0]), c='b', lw=3)
|
|
132
|
+
line2, = ax.plot(x_fit, func(x_fit, *para_coeff[1]), c='g', lw=3)
|
|
133
133
|
|
|
134
|
-
|
|
135
|
-
|
|
134
|
+
labels = [f'Ext = ' + '{:.0f} / Vis ^ {:.3f}'.format(*para_coeff[0]) + ' (Dry Extinction)',
|
|
135
|
+
f'Ext = ' + '{:.0f} / Vis ^ {:.3f}'.format(*para_coeff[1]) + ' (Amb Extinction)']
|
|
136
136
|
|
|
137
|
-
|
|
138
|
-
|
|
137
|
+
plt.legend(handles=[line1, line2], labels=labels, loc='upper right', prop=dict(size=10, weight='bold'),
|
|
138
|
+
bbox_to_anchor=(0.99, 0.99))
|
|
139
139
|
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
140
|
+
plt.xticks(ticks=np.array(range(0, 51, 5)), labels=np.array(range(0, 51, 5)))
|
|
141
|
+
plt.xlim(0, 50)
|
|
142
|
+
plt.ylim(0, 700)
|
|
143
|
+
plt.title(r'$\bf Koschmieder\ relationship$')
|
|
144
|
+
plt.xlabel(f'{y} (km)')
|
|
145
|
+
plt.ylabel(r'$\bf Extinction\ coefficient\ (1/Mm)$')
|
|
146
146
|
|
|
147
|
-
|
|
147
|
+
plt.show()
|
|
148
148
|
|
|
149
|
-
|
|
149
|
+
return fig, ax
|
|
150
150
|
|
|
151
151
|
|
|
152
152
|
if __name__ == '__main__':
|
|
153
|
-
|
|
153
|
+
from AeroViz.tools import DataBase
|
|
154
154
|
|
|
155
|
-
|
|
156
|
-
|
|
155
|
+
koschmieder(DataBase(), 'Vis_LPV', 'log')
|
|
156
|
+
# koschmieder(DataBase, 'Vis_Naked', 'reciprocal')
|
|
@@ -9,49 +9,49 @@ from AeroViz.plot.utils import *
|
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
def process_data(df):
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
12
|
+
# detected_limit = 0.0001
|
|
13
|
+
df = df.where(df >= 0.0001, np.nan)
|
|
14
|
+
# Normalize the data
|
|
15
|
+
df = DataFrame(StandardScaler().fit_transform(df), index=df.index, columns=df.columns)
|
|
16
|
+
# Remove outliers
|
|
17
|
+
df = df[(np.abs(df) < 6)]
|
|
18
|
+
# Interpolate the missing values
|
|
19
|
+
df = df.interpolate(method='linear')
|
|
20
|
+
# Smooth the data
|
|
21
|
+
df = df.rolling(window=3, min_periods=1).mean()
|
|
22
22
|
|
|
23
|
-
|
|
23
|
+
return df
|
|
24
24
|
|
|
25
25
|
|
|
26
26
|
@set_figure(figsize=(12, 3), fs=6)
|
|
27
27
|
def metal_heatmaps(df, major_freq='24h', minor_freq='12h', ax: Axes | None = None, title=None, **kwargs
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
28
|
+
) -> tuple[Figure, Axes]:
|
|
29
|
+
items = ['Al', 'Zr', 'Si', 'Ca', 'Ti', 'Mn', 'Fe', 'V', 'Cl', 'K',
|
|
30
|
+
'Sr', 'Ba', 'Bi', 'Pd', 'Sn', 'Cr', 'W', 'Cu', 'Zn',
|
|
31
|
+
'As', 'Co', 'Se', 'Br', 'Cd', 'Sb', 'In', 'Pb', 'Ni']
|
|
32
32
|
|
|
33
|
-
|
|
33
|
+
df = df[items]
|
|
34
34
|
|
|
35
|
-
|
|
35
|
+
fig, ax = plt.subplots(**kwargs.get('fig_kws', {})) if ax is None else (ax.get_figure(), ax)
|
|
36
36
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
37
|
+
sns.heatmap(df.T, vmax=3, cmap="jet", xticklabels=False, yticklabels=True,
|
|
38
|
+
cbar_kws={'label': 'Z score'})
|
|
39
|
+
ax.grid(color='gray', linestyle='-', linewidth=0.3)
|
|
40
|
+
# Set x-tick positions and labels
|
|
41
|
+
major_tick = date_range(start=df.index[0], end=df.index[-1], freq=major_freq)
|
|
42
|
+
minor_tick = date_range(start=df.index[0], end=df.index[-1], freq=minor_freq)
|
|
43
43
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
44
|
+
# Set the major and minor ticks
|
|
45
|
+
ax.set_xticks(ticks=[df.index.get_loc(t) for t in major_tick])
|
|
46
|
+
ax.set_xticks(ticks=[df.index.get_loc(t) for t in minor_tick], minor=True)
|
|
47
|
+
ax.set_xticklabels(major_tick.strftime('%F'))
|
|
48
|
+
ax.tick_params(axis='y', rotation=0)
|
|
49
49
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
50
|
+
ax.set_title(f"{title}", fontsize=10)
|
|
51
|
+
ax.set(xlabel='',
|
|
52
|
+
ylabel='',
|
|
53
|
+
)
|
|
54
54
|
|
|
55
|
-
|
|
55
|
+
plt.show()
|
|
56
56
|
|
|
57
|
-
|
|
57
|
+
return fig, ax
|