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
|
@@ -1,161 +1,161 @@
|
|
|
1
|
-
from AeroViz.dataProcess.core import _union_index
|
|
2
|
-
|
|
3
|
-
from pandas import date_range, concat, DataFrame, to_numeric
|
|
4
|
-
from scipy.optimize import curve_fit
|
|
5
1
|
import numpy as np
|
|
2
|
+
from pandas import concat, DataFrame
|
|
3
|
+
from scipy.optimize import curve_fit
|
|
4
|
+
|
|
5
|
+
from AeroViz.dataProcess.core import _union_index
|
|
6
6
|
|
|
7
7
|
__all__ = [
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
'_basic',
|
|
9
|
+
# '_ocec_ratio_cal',
|
|
10
10
|
]
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
def _min_Rsq(_oc, _ec, _rng):
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
_val_mesh, _oc_mesh = np.meshgrid(_rng, _oc)
|
|
15
|
+
_val_mesh, _ec_mesh = np.meshgrid(_rng, _ec)
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
_out_table = DataFrame(_oc_mesh - _val_mesh * _ec_mesh, index=_oc.index, columns=_rng)
|
|
18
18
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
19
|
+
## calculate R2
|
|
20
|
+
_r2_dic = {}
|
|
21
|
+
_func = lambda _x, _sl, _inte: _sl * _x + _inte
|
|
22
|
+
for _ocec, _out in _out_table.items():
|
|
23
|
+
_df = DataFrame([_out.values, _ec.values]).T.dropna()
|
|
24
24
|
|
|
25
|
-
|
|
26
|
-
|
|
25
|
+
_x, _y = _df[0], _df[1]
|
|
26
|
+
_opt, _ = curve_fit(_func, _x, _y)
|
|
27
27
|
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
_tss = np.sum((_y - _y.mean()) ** 2.)
|
|
29
|
+
_rss = np.sum((_y - _func(_x, *_opt)) ** 2.)
|
|
30
30
|
|
|
31
|
-
|
|
31
|
+
_r2_dic[round(_ocec, 3)] = 1. - _rss / _tss
|
|
32
32
|
|
|
33
|
-
|
|
34
|
-
|
|
33
|
+
## get the min R2
|
|
34
|
+
_ratio = DataFrame(_r2_dic, index=[0]).idxmin(axis=1).values[0]
|
|
35
35
|
|
|
36
|
-
|
|
36
|
+
return _ratio, _out_table[_ratio]
|
|
37
37
|
|
|
38
38
|
|
|
39
39
|
def _ocec_ratio_cal(_nam, _lcres_splt, _hr_lim, _range_, _wisoc_range_):
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
40
|
+
## parameter
|
|
41
|
+
_out = DataFrame(index=_lcres_splt.index)
|
|
42
|
+
(_, _oc), (_, _ec) = _lcres_splt.items()
|
|
43
|
+
# _oc, _ec = _lcres_splt['Thermal_OC'], _lcres_splt['Thermal_EC']
|
|
44
44
|
|
|
45
|
-
|
|
46
|
-
|
|
45
|
+
## real data OC/EC
|
|
46
|
+
_ocec_ratio_real = (_oc / _ec).quantile(.5)
|
|
47
47
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
48
|
+
_out[f'OC/EC_real_{_nam}'] = _ocec_ratio_real
|
|
49
|
+
_out[f'POC_real_{_nam}'] = _ocec_ratio_real * _ec
|
|
50
|
+
_out[f'SOC_real_{_nam}'] = _oc - _out[f'POC_real_{_nam}']
|
|
51
51
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
52
|
+
## the least R2 method
|
|
53
|
+
## estimated OC/EC
|
|
54
|
+
if (len(_lcres_splt) <= _hr_lim):
|
|
55
|
+
print(f"\t\t{_lcres_splt.index[0].strftime('%Y-%m-%d %X')} to {_lcres_splt.index[-1].strftime('%Y-%m-%d %X')}")
|
|
56
|
+
print('\t\tPlease Modify the Values of "hour_limit" or Input Sufficient Amount of Data !!')
|
|
57
57
|
|
|
58
|
-
|
|
59
|
-
|
|
58
|
+
_out[[f'OC/EC_{_nam}', f'POC_{_nam}', f'SOC_{_nam}', f'WISOC/OC_{_nam}', f'WSOC_{_nam}',
|
|
59
|
+
f'WISOC_{_nam}']] = np.nan
|
|
60
60
|
|
|
61
|
-
|
|
61
|
+
return _out
|
|
62
62
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
63
|
+
if (len(_lcres_splt.dropna()) == 0):
|
|
64
|
+
_out[[f'OC/EC_{_nam}', f'POC_{_nam}', f'SOC_{_nam}', f'WISOC/OC_{_nam}', f'WSOC_{_nam}',
|
|
65
|
+
f'WISOC_{_nam}']] = np.nan
|
|
66
66
|
|
|
67
|
-
|
|
67
|
+
return _out
|
|
68
68
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
69
|
+
## OC/EC
|
|
70
|
+
_ocec_ratio = False
|
|
71
|
+
_st, _ed, _stp = _range_
|
|
72
72
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
73
|
+
for _ in range(2):
|
|
74
|
+
if _ocec_ratio:
|
|
75
|
+
_ocec_rng = np.arange(_ocec_ratio - _stp / 2, _ocec_ratio + _stp / 2, .01).round(3)
|
|
76
|
+
else:
|
|
77
|
+
_ocec_rng = np.arange(_st, _ed + _stp, _stp).round(3)
|
|
78
78
|
|
|
79
|
-
|
|
79
|
+
_ocec_ratio, _soc = _min_Rsq(_oc, _ec, _ocec_rng)
|
|
80
80
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
81
|
+
## WISOC
|
|
82
|
+
_st, _ed, _stp = _wisoc_range_
|
|
83
|
+
_wisoc_rng = (np.arange(_st, _ed + _stp, _stp) * _ocec_ratio).round(5)
|
|
84
|
+
_wisoc_ratio, _wsoc = _min_Rsq(_oc, _ec, _wisoc_rng)
|
|
85
85
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
86
|
+
## out
|
|
87
|
+
_out[f'OC/EC_{_nam}'] = _ocec_ratio
|
|
88
|
+
_out[f'SOC_{_nam}'] = _soc
|
|
89
|
+
_out[f'POC_{_nam}'] = _oc - _out[f'SOC_{_nam}']
|
|
90
|
+
_out[f'WISOC/OC_{_nam}'] = _wisoc_ratio
|
|
91
|
+
_out[f'WSOC_{_nam}'] = _wsoc
|
|
92
|
+
_out[f'WISOC_{_nam}'] = _oc - _out[f'WSOC_{_nam}']
|
|
93
93
|
|
|
94
|
-
|
|
95
|
-
|
|
94
|
+
return _out[[f'OC/EC_{_nam}', f'POC_{_nam}', f'SOC_{_nam}', f'WISOC/OC_{_nam}', f'WSOC_{_nam}', f'WISOC_{_nam}',
|
|
95
|
+
f'OC/EC_real_{_nam}', f'POC_real_{_nam}', f'SOC_real_{_nam}']]
|
|
96
96
|
|
|
97
97
|
|
|
98
98
|
def _basic(_lcres, _res, _mass, _ocec_ratio, _ocec_ratio_month, _hr_lim, _range, _wisoc_range):
|
|
99
|
-
|
|
99
|
+
_lcres, _res, _mass = _union_index(_lcres, _res, _mass)
|
|
100
100
|
|
|
101
|
-
|
|
101
|
+
_out = {}
|
|
102
102
|
|
|
103
|
-
|
|
104
|
-
|
|
103
|
+
## OC1, OC2, OC3, OC4, PC
|
|
104
|
+
_df_bsc = _res / _lcres['Sample_Volume'].to_frame().values.copy()
|
|
105
105
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
106
|
+
## SOC, POC, OC/EC
|
|
107
|
+
if _ocec_ratio is not None:
|
|
108
|
+
try:
|
|
109
|
+
iter(_ocec_ratio)
|
|
110
|
+
except TypeError:
|
|
111
|
+
raise TypeError('"ocec_ratio" Only Accept a Single Value !!')
|
|
112
112
|
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
113
|
+
_prcs_df = DataFrame(index=_df_bsc.index)
|
|
114
|
+
_prcs_df['OC/EC'] = _ocec_ratio
|
|
115
|
+
_prcs_df['POC'] = _ocec_ratio * _lcres['Thermal_EC']
|
|
116
|
+
_prcs_df['SOC'] = _lcres['Thermal_OC'] - _prcs_df['POC']
|
|
117
117
|
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
118
|
+
else:
|
|
119
|
+
_df_lst = []
|
|
120
|
+
for _, _df in _lcres.resample(f'{_ocec_ratio_month}MS', closed='left'):
|
|
121
|
+
_thm_cal = _ocec_ratio_cal('thm', _df[['Thermal_OC', 'Thermal_EC']], _hr_lim, _range, _wisoc_range)
|
|
122
|
+
_opt_cal = _ocec_ratio_cal('opt', _df[['Optical_OC', 'Optical_EC']], _hr_lim, _range, _wisoc_range)
|
|
123
|
+
_df_lst.append(concat([_thm_cal, _opt_cal], axis=1))
|
|
124
124
|
|
|
125
|
-
|
|
125
|
+
_prcs_df = concat(_df_lst)
|
|
126
126
|
|
|
127
|
-
|
|
127
|
+
_df_bsc = concat((_df_bsc.copy(), _prcs_df), axis=1)
|
|
128
128
|
|
|
129
|
-
|
|
130
|
-
|
|
129
|
+
## ratio
|
|
130
|
+
_df_ratio = DataFrame(index=_df_bsc.index)
|
|
131
131
|
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
132
|
+
for _ky, _val in _df_bsc.items():
|
|
133
|
+
if 'OC/EC' in _ky: continue
|
|
134
|
+
_df_ratio[f'{_ky}/Thermal_OC'] = _val / _lcres['Thermal_OC']
|
|
135
|
+
_df_ratio[f'{_ky}/Optical_OC'] = _val / _lcres['Optical_OC']
|
|
136
136
|
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
137
|
+
if _mass is not None:
|
|
138
|
+
for _ky, _val in _df_bsc.items():
|
|
139
|
+
_df_ratio[f'{_ky}/PM'] = _val / _mass
|
|
140
140
|
|
|
141
|
-
|
|
142
|
-
|
|
141
|
+
_df_ratio[f'Thermal_OC/PM'] = _lcres['Thermal_OC'] / _mass
|
|
142
|
+
_df_ratio[f'Thermal_EC/PM'] = _lcres['Thermal_EC'] / _mass
|
|
143
143
|
|
|
144
|
-
|
|
145
|
-
|
|
144
|
+
_df_ratio[f'Optical_OC/PM'] = _lcres['Optical_OC'] / _mass
|
|
145
|
+
_df_ratio[f'Optical_EC/PM'] = _lcres['Optical_EC'] / _mass
|
|
146
146
|
|
|
147
|
-
|
|
148
|
-
|
|
147
|
+
## ratio status
|
|
148
|
+
_df_bsc = concat((_lcres, _df_bsc.copy()), axis=1)
|
|
149
149
|
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
150
|
+
for _ky, _df in _df_ratio.items():
|
|
151
|
+
_df_bsc[f'{_ky}_status'] = 'Normal'
|
|
152
|
+
_df_bsc[f'{_ky}_status'] = _df_bsc[f'{_ky}_status'].mask(_df > 1, 'Warning')
|
|
153
153
|
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
154
|
+
## out
|
|
155
|
+
_out['ratio'] = _df_ratio
|
|
156
|
+
_out['basic'] = _df_bsc
|
|
157
157
|
|
|
158
|
-
|
|
158
|
+
return _out
|
|
159
159
|
|
|
160
160
|
|
|
161
161
|
'''
|
|
@@ -1,29 +1,30 @@
|
|
|
1
|
-
from pandas import
|
|
1
|
+
from pandas import concat, DataFrame
|
|
2
|
+
|
|
2
3
|
from ._calculate import _ug2umol
|
|
3
4
|
|
|
4
5
|
|
|
5
6
|
def _basic(df_che, nam_lst):
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
# parameter
|
|
8
|
+
df_all = concat(df_che, axis=1)
|
|
9
|
+
index = df_all.index.copy()
|
|
10
|
+
df_all.columns = nam_lst
|
|
10
11
|
|
|
11
|
-
|
|
12
|
+
df_umol = _ug2umol(df_all)
|
|
12
13
|
|
|
13
|
-
|
|
14
|
-
|
|
14
|
+
# calculate
|
|
15
|
+
df_out = DataFrame(index=df_umol.index)
|
|
15
16
|
|
|
16
|
-
|
|
17
|
-
|
|
17
|
+
# df_out['NTR'] = df_umol['NH4+'] / (df_umol['NH4+'] + df_all['NH3'] / 22.4)
|
|
18
|
+
df_out['NTR+'] = df_umol['NH4+'] / (df_umol['NH4+'] + df_umol['NH3'])
|
|
18
19
|
|
|
19
|
-
|
|
20
|
-
|
|
20
|
+
df_out['NOR'] = df_umol['NO3-'] / (df_umol['NO3-'] + df_umol['NO2'])
|
|
21
|
+
df_out['NOR_2'] = (df_umol['NO3-'] + df_umol['HNO3']) / (df_umol['NO3-'] + df_umol['NO2'] + df_umol['HNO3'])
|
|
21
22
|
|
|
22
|
-
|
|
23
|
+
df_out['SOR'] = df_umol['SO42-'] / (df_umol['SO42-'] + df_umol['SO2'])
|
|
23
24
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
25
|
+
df_out['epls_NO3-'] = df_umol['NO3-'] / (df_umol['NO3-'] + df_umol['HNO3'])
|
|
26
|
+
df_out['epls_NH4+'] = df_umol['NH4+'] / (df_umol['NH4+'] + df_umol['NH3'])
|
|
27
|
+
df_out['epls_SO42-'] = df_out['SOR']
|
|
28
|
+
df_out['epls_Cl-'] = df_umol['Cl-'] / (df_umol['Cl-'] + df_umol['HCl'])
|
|
28
29
|
|
|
29
|
-
|
|
30
|
+
return df_out
|
|
@@ -1,16 +1,13 @@
|
|
|
1
|
-
import numpy as np
|
|
2
|
-
|
|
3
|
-
|
|
4
1
|
def _basic(_teom, _check):
|
|
5
|
-
|
|
2
|
+
_teom['Volatile_Fraction'] = (_teom['PM_Total'] - _teom['PM_NV']) / _teom['PM_Total']
|
|
6
3
|
|
|
7
|
-
|
|
4
|
+
_teom.loc[(_teom['Volatile_Fraction'] < 0) | (_teom['Volatile_Fraction'] > 1)] = n.nan
|
|
8
5
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
6
|
+
if _check is not None:
|
|
7
|
+
_ratio = _teom['PM_NV'] / _check
|
|
8
|
+
_teom['PM_Check'] = _check
|
|
12
9
|
|
|
13
|
-
|
|
14
|
-
|
|
10
|
+
_teom.loc[_teom.dropna().index, 'status'] = 'Warning'
|
|
11
|
+
_teom.loc[(_ratio > 0) & (_ratio < 1), 'status'] = 'Normal'
|
|
15
12
|
|
|
16
|
-
|
|
13
|
+
return _teom
|
|
@@ -1,61 +1,62 @@
|
|
|
1
1
|
import pickle as pkl
|
|
2
2
|
from pathlib import Path
|
|
3
|
+
|
|
3
4
|
import numpy as np
|
|
5
|
+
from pandas import DataFrame
|
|
4
6
|
|
|
5
|
-
from pandas import date_range, concat, DataFrame, to_numeric
|
|
6
7
|
from AeroViz.dataProcess.core import _union_index
|
|
7
8
|
|
|
8
9
|
|
|
9
10
|
def _revised(_df_mass, _df_RH):
|
|
10
|
-
|
|
11
|
+
_df_mass, _df_RH = _union_index(_df_mass, _df_RH)
|
|
11
12
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
## fRH
|
|
14
|
+
with (Path(__file__).parent / 'fRH.pkl').open('rb') as f:
|
|
15
|
+
_fRH = pkl.load(f)
|
|
16
|
+
_fRH.loc[np.nan] = np.nan
|
|
16
17
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
18
|
+
def fRH(_RH):
|
|
19
|
+
if _RH is not None:
|
|
20
|
+
_RH = _RH.mask(_RH > 95, 95).round(0)
|
|
21
|
+
return _fRH.loc[_RH].values.T
|
|
21
22
|
|
|
22
|
-
|
|
23
|
+
return 1, 1, 1, 1
|
|
23
24
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
25
|
+
## different mode
|
|
26
|
+
## mass < 20 :
|
|
27
|
+
## large = mass**2/20
|
|
28
|
+
## small = mass-large
|
|
29
|
+
## mass >= 20 :
|
|
30
|
+
## large = mass
|
|
31
|
+
## small = 0
|
|
32
|
+
_df_mode = _df_mass[['AS', 'AN', 'OM']].copy()
|
|
32
33
|
|
|
33
|
-
|
|
34
|
-
|
|
34
|
+
_df_mass[['L_AS', 'L_AN', 'L_OM']] = _df_mode.mask(_df_mode < 20, _df_mode ** 2 / 20)
|
|
35
|
+
_df_mass[['S_AS', 'S_AN', 'S_OM']] = _df_mode.values - _df_mass[['L_AS', 'L_AN', 'L_OM']]
|
|
35
36
|
|
|
36
|
-
|
|
37
|
-
|
|
37
|
+
## apply IMPROVE ccoe.
|
|
38
|
+
def _ext_cal(_RH=None):
|
|
38
39
|
|
|
39
|
-
|
|
40
|
-
|
|
40
|
+
_frh, _frhss, _frhs, _frhl = fRH(_RH)
|
|
41
|
+
_df = DataFrame(index=_df_mass.index)
|
|
41
42
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
43
|
+
_df['AS'] = 2.2 * _frhs * _df_mass['S_AS'] + 4.8 * _frhl * _df_mass['L_AS']
|
|
44
|
+
_df['AN'] = 2.4 * _frhs * _df_mass['S_AN'] + 5.1 * _frhl * _df_mass['L_AN']
|
|
45
|
+
_df['OM'] = 2.8 * _df_mass['S_OM'] + 6.1 * _frhl * _df_mass['L_OM']
|
|
46
|
+
_df['Soil'] = _df_mass['Soil']
|
|
47
|
+
_df['SS'] = 1.7 * _frhss * _df_mass['SS']
|
|
48
|
+
_df['EC'] = 10 * _df_mass['EC']
|
|
48
49
|
|
|
49
|
-
|
|
50
|
+
_df['total'] = _df.sum(axis=1)
|
|
50
51
|
|
|
51
|
-
|
|
52
|
+
return _df.dropna().reindex(_df_mass.index)
|
|
52
53
|
|
|
53
|
-
|
|
54
|
-
|
|
54
|
+
## calculate
|
|
55
|
+
_out = {}
|
|
55
56
|
|
|
56
|
-
|
|
57
|
+
_out['dry'] = _ext_cal()
|
|
57
58
|
|
|
58
|
-
|
|
59
|
-
|
|
59
|
+
if _df_RH is not None:
|
|
60
|
+
_out['wet'] = _ext_cal(_df_RH)
|
|
60
61
|
|
|
61
|
-
|
|
62
|
+
return _out
|
|
@@ -2,61 +2,61 @@ from ..core import _writter, _run_process
|
|
|
2
2
|
|
|
3
3
|
__all__ = [
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
'Optical',
|
|
6
6
|
|
|
7
7
|
]
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
class Optical(_writter):
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
12
|
+
## scatter
|
|
13
|
+
@_run_process('Optical - SAE', 'SAE')
|
|
14
|
+
def SAE(self, df_sca):
|
|
15
|
+
from ._scattering import _SAE
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
out = _SAE(df_sca)
|
|
18
18
|
|
|
19
|
-
|
|
19
|
+
return self, out
|
|
20
20
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
21
|
+
## absorption
|
|
22
|
+
@_run_process('Optical - absCoe', 'absCoe')
|
|
23
|
+
def absCoe(self, df_ae33, abs_band=[550]):
|
|
24
|
+
from ._absorption import _absCoe
|
|
25
25
|
|
|
26
|
-
|
|
26
|
+
out = _absCoe(df_ae33, abs_band)
|
|
27
27
|
|
|
28
|
-
|
|
28
|
+
return self, out
|
|
29
29
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
30
|
+
@_run_process('Optical - AAE', 'AAE')
|
|
31
|
+
def AAE(self, df_abs):
|
|
32
|
+
from ._absorption import _AAE
|
|
33
33
|
|
|
34
|
-
|
|
34
|
+
out = _AAE(df_abs)
|
|
35
35
|
|
|
36
|
-
|
|
36
|
+
return self, out
|
|
37
37
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
38
|
+
## extinction
|
|
39
|
+
@_run_process('Optical - basic', 'opt_basic')
|
|
40
|
+
def basic(self, df_abs, df_sca, df_ec=None, df_mass=None, df_no2=None):
|
|
41
|
+
from ._extinction import _basic
|
|
42
42
|
|
|
43
|
-
|
|
43
|
+
out = _basic(df_abs, df_sca, df_ec, df_mass, df_no2)
|
|
44
44
|
|
|
45
|
-
|
|
45
|
+
return self, out
|
|
46
46
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
47
|
+
@_run_process('Optical - Mie', 'Mie')
|
|
48
|
+
def Mie(self, df_psd, df_m, wave_length=550):
|
|
49
|
+
from ._mie import _mie
|
|
50
50
|
|
|
51
|
-
|
|
51
|
+
out = _mie(df_psd, df_m, wave_length)
|
|
52
52
|
|
|
53
|
-
|
|
53
|
+
return self, out
|
|
54
54
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
55
|
+
@_run_process('Optical - IMPROVE', 'IMPROVE')
|
|
56
|
+
def IMPROVE(self, df_mass, df_RH, method='revised'):
|
|
57
|
+
# _fc = __import__(f'_IMPROVE._{method}')
|
|
58
|
+
from ._IMPROVE import _revised
|
|
59
59
|
|
|
60
|
-
|
|
60
|
+
out = _revised(df_mass, df_RH)
|
|
61
61
|
|
|
62
|
-
|
|
62
|
+
return self, out
|
|
@@ -1,54 +1,54 @@
|
|
|
1
1
|
def _absCoe(df, abs_band):
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
import numpy as n
|
|
3
|
+
from scipy.optimize import curve_fit
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
band = n.array([370, 470, 520, 590, 660, 880, 950])
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
df_out = {}
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
def _get_slope(__df):
|
|
10
|
+
func = lambda _x, _sl, _int: _sl * _x + _int
|
|
11
|
+
popt, pcov = curve_fit(func, band, __df.values)
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
return func(n.array(abs_band), *popt)
|
|
14
14
|
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
MAE = n.array([18.47, 14.54, 13.14, 11.58, 10.35, 7.77, 7.19]) * 1e-3
|
|
16
|
+
df_abs = (df.copy() * MAE).dropna().copy()
|
|
17
17
|
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
df_out = df_abs.apply(_get_slope, axis=1, result_type='expand').reindex(df.index)
|
|
19
|
+
df_out.columns = [f'abs_{_band}' for _band in abs_band]
|
|
20
20
|
|
|
21
|
-
|
|
21
|
+
df_out['eBC'] = df['BC6']
|
|
22
22
|
|
|
23
|
-
|
|
23
|
+
return df_out
|
|
24
24
|
|
|
25
25
|
|
|
26
26
|
def _AAE(df):
|
|
27
|
-
|
|
28
|
-
|
|
27
|
+
import numpy as n
|
|
28
|
+
from scipy.optimize import curve_fit
|
|
29
29
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
30
|
+
def _AAEcalc(_df):
|
|
31
|
+
## parameter
|
|
32
|
+
MAE = n.array([18.47, 14.54, 13.14, 11.58, 10.35, 7.77, 7.19]) * 1e-3
|
|
33
|
+
band = n.array([370, 470, 520, 590, 660, 880, 950])
|
|
34
|
+
_df *= MAE
|
|
35
35
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
36
|
+
## 7 pts fitting
|
|
37
|
+
## function
|
|
38
|
+
def _get_slope(__df):
|
|
39
|
+
func = lambda _x, _sl, _int: _sl * _x + _int
|
|
40
|
+
popt, pcov = curve_fit(func, n.log(band), n.log(__df))
|
|
41
41
|
|
|
42
|
-
|
|
42
|
+
return popt
|
|
43
43
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
44
|
+
## calculate
|
|
45
|
+
_AAE = _df.apply(_get_slope, axis=1, result_type='expand')
|
|
46
|
+
_AAE.columns = ['slope', 'intercept']
|
|
47
47
|
|
|
48
|
-
|
|
48
|
+
return _AAE
|
|
49
49
|
|
|
50
|
-
|
|
51
|
-
|
|
50
|
+
df_out = _AAEcalc(df[['BC1', 'BC2', 'BC3', 'BC4', 'BC5', 'BC6', 'BC7']].dropna())
|
|
51
|
+
df_out = df_out.mask((-df_out.slope < 0.8) | (-df_out.slope > 2.)).copy()
|
|
52
52
|
|
|
53
|
-
|
|
54
|
-
|
|
53
|
+
df_out['eBC'] = df['BC6']
|
|
54
|
+
return df_out.reindex(df.index)
|