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
|
@@ -2,62 +2,62 @@ from ..core import _writter, _run_process
|
|
|
2
2
|
|
|
3
3
|
__all__ = [
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
'Chemistry',
|
|
6
6
|
|
|
7
7
|
]
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
class Chemistry(_writter):
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
12
|
+
## Reconstruction
|
|
13
|
+
@_run_process('Chemistry - reconstruction basic', 'reconstrc_basic')
|
|
14
|
+
def ReConstrc_basic(self, *df_chem, df_ref=None, df_water=None, df_density=None,
|
|
15
|
+
nam_lst=['NH4+', 'SO42-', 'NO3-', 'Fe', 'Na+', 'OC', 'EC']):
|
|
16
|
+
from ._mass_volume import _basic
|
|
17
17
|
|
|
18
|
-
|
|
18
|
+
out = _basic(df_chem, df_ref, df_water, df_density, nam_lst=nam_lst)
|
|
19
19
|
|
|
20
|
-
|
|
20
|
+
return self, out
|
|
21
21
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
22
|
+
## Partition
|
|
23
|
+
@_run_process('Chemistry - Partition', 'partition')
|
|
24
|
+
def Partition(self, *df_chem, nam_lst=['NH4+', 'SO42-', 'NO3-', 'Cl-', 'NO2', 'HNO3', 'SO2', 'NH3', 'HCl', 'temp']):
|
|
25
|
+
from ._partition import _basic
|
|
26
26
|
|
|
27
|
-
|
|
27
|
+
out = _basic(df_chem, nam_lst=nam_lst)
|
|
28
28
|
|
|
29
|
-
|
|
29
|
+
return self, out
|
|
30
30
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
31
|
+
## ISOROPIA
|
|
32
|
+
@_run_process('Chemistry - ISOROPIA', 'isoropia')
|
|
33
|
+
def ISOROPIA(self, *df_chem,
|
|
34
|
+
nam_lst=['Na+', 'SO42-', 'NH4+', 'NO3-', 'Cl-', 'Ca2+', 'K+', 'Mg2+', 'NH3', 'HNO3', 'HCl', 'RH',
|
|
35
|
+
'temp']):
|
|
36
|
+
from ._isoropia import _basic
|
|
37
37
|
|
|
38
|
-
|
|
39
|
-
|
|
38
|
+
if self.path_out is None:
|
|
39
|
+
raise ValueError('Please Input "path_out" !!')
|
|
40
40
|
|
|
41
|
-
|
|
41
|
+
out = _basic(df_chem, self.path_out, nam_lst=nam_lst)
|
|
42
42
|
|
|
43
|
-
|
|
43
|
+
return self, out
|
|
44
44
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
45
|
+
## OCEC
|
|
46
|
+
@_run_process('Chemistry - OC/EC basic', 'ocec_basic')
|
|
47
|
+
def OCEC_basic(self, df_lcres, df_res, df_mass=None, ocec_ratio=None, ocec_ratio_month=1, hr_lim=200,
|
|
48
|
+
least_square_range=(0.1, 2.5, 0.1), WISOC_OC_range=(0.2, 0.7, 0.01), ):
|
|
49
|
+
from ._ocec import _basic
|
|
50
50
|
|
|
51
|
-
|
|
52
|
-
|
|
51
|
+
out = _basic(df_lcres, df_res, df_mass, ocec_ratio, ocec_ratio_month, hr_lim, least_square_range,
|
|
52
|
+
WISOC_OC_range)
|
|
53
53
|
|
|
54
|
-
|
|
54
|
+
return self, out
|
|
55
55
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
56
|
+
## TEOM
|
|
57
|
+
@_run_process('Chemistry - TEOM basic', 'teom_basic')
|
|
58
|
+
def TEOM_basic(self, df_teom, df_check=None):
|
|
59
|
+
from ._teom import _basic
|
|
60
60
|
|
|
61
|
-
|
|
61
|
+
out = _basic(df_teom, df_check)
|
|
62
62
|
|
|
63
|
-
|
|
63
|
+
return self, out
|
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
from pandas import concat
|
|
1
|
+
from pandas import concat
|
|
2
2
|
|
|
3
3
|
# parameter
|
|
4
4
|
_mol_wg = {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
'SO42-': 96.06,
|
|
6
|
+
'NO3-': 62.00,
|
|
7
|
+
'Cl-': 35.4,
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
9
|
+
'Ca2+': 40.078,
|
|
10
|
+
'K+': 39.098,
|
|
11
|
+
'Mg2+': 24.305,
|
|
12
|
+
'Na+': 22.99,
|
|
13
|
+
'NH4+': 18.04,
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
|
|
17
17
|
# ug -> umol
|
|
18
18
|
def _ug2umol(_df):
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
_pt_ky = list(set(_df.keys()) & set(_mol_wg.keys()))
|
|
20
|
+
_gas_ky = list(set(_df.keys()) - set(_mol_wg.keys()) - set(['temp', 'RH']))
|
|
21
21
|
|
|
22
|
-
|
|
22
|
+
_par = (_df['temp'].to_frame() + 273.15) * .082
|
|
23
23
|
|
|
24
|
-
|
|
25
|
-
|
|
24
|
+
_df_pt = concat([(_df[_ky] / _mol_wg[_ky]).copy() for _ky in _pt_ky], axis=1)
|
|
25
|
+
_df_gas = _df[_gas_ky] / _par.values
|
|
26
26
|
|
|
27
|
-
|
|
27
|
+
return concat([_df_pt, _df_gas], axis=1)
|
|
@@ -1,99 +1,100 @@
|
|
|
1
|
+
from pathlib import Path
|
|
1
2
|
from subprocess import Popen, PIPE
|
|
2
|
-
|
|
3
|
-
from ._calculate import _ug2umol
|
|
3
|
+
|
|
4
4
|
import numpy as np
|
|
5
|
+
from pandas import concat, DataFrame, to_numeric, read_csv
|
|
5
6
|
|
|
6
|
-
from
|
|
7
|
+
from ._calculate import _ug2umol
|
|
7
8
|
|
|
8
9
|
|
|
9
10
|
def _basic(df_che, path_out, nam_lst):
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
# parameter
|
|
12
|
+
df_all = concat(df_che, axis=1)
|
|
13
|
+
index = df_all.index.copy()
|
|
14
|
+
df_all.columns = nam_lst
|
|
14
15
|
|
|
15
|
-
|
|
16
|
+
df_umol = _ug2umol(df_all)
|
|
16
17
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
18
|
+
## output
|
|
19
|
+
## Na, SO4, NH3, NO3, Cl, Ca, K, Mg, RH, TEMP
|
|
20
|
+
df_input = DataFrame(index=index)
|
|
21
|
+
df_out = DataFrame(index=index)
|
|
21
22
|
|
|
22
|
-
|
|
23
|
-
|
|
23
|
+
pth_input = path_out / '_temp_input.txt'
|
|
24
|
+
pth_output = path_out / '_temp_input.dat'
|
|
24
25
|
|
|
25
|
-
|
|
26
|
-
|
|
26
|
+
pth_input.unlink(missing_ok=True)
|
|
27
|
+
pth_output.unlink(missing_ok=True)
|
|
27
28
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
29
|
+
## header
|
|
30
|
+
_header = 'Input units (0=umol/m3, 1=ug/m3)\n' + '0\n\n' + \
|
|
31
|
+
'Problem type (0=forward, 1=reverse); Phase state (0=solid+liquid, 1=metastable)\n' + '0, 1\n\n' + \
|
|
32
|
+
'NH4-SO4 system case\n'
|
|
32
33
|
|
|
33
|
-
|
|
34
|
-
|
|
34
|
+
## software
|
|
35
|
+
path_iso = Path(__file__).parent / 'isrpia2.exe'
|
|
35
36
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
37
|
+
# make input file and output temp input (without index)
|
|
38
|
+
## NH3
|
|
39
|
+
df_input['NH3'] = df_umol['NH4+'].fillna(0).copy() + df_umol['NH3']
|
|
39
40
|
|
|
40
|
-
|
|
41
|
-
|
|
41
|
+
## NO3
|
|
42
|
+
df_input['NO3'] = df_umol['HNO3'].fillna(0).copy() + df_umol['NO3-']
|
|
42
43
|
|
|
43
|
-
|
|
44
|
-
|
|
44
|
+
## Cl
|
|
45
|
+
df_input['Cl'] = df_umol['HCl'].fillna(0).copy() + df_umol['Cl-']
|
|
45
46
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
47
|
+
## temp, RH
|
|
48
|
+
df_input['RH'] = df_all['RH'] / 100
|
|
49
|
+
df_input['TEMP'] = df_all['temp'] + 273.15
|
|
49
50
|
|
|
50
|
-
|
|
51
|
+
df_input[['Na', 'SO4', 'Ca', 'K', 'Mg']] = df_umol[['Na+', 'SO42-', 'Ca2+', 'K+', 'Mg2+']].copy()
|
|
51
52
|
|
|
52
|
-
|
|
53
|
+
df_input = df_input[['Na', 'SO4', 'NH3', 'NO3', 'Cl', 'Ca', 'K', 'Mg', 'RH', 'TEMP']].fillna('-').copy()
|
|
53
54
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
55
|
+
## output the input data
|
|
56
|
+
df_input.to_csv(pth_input, index=False)
|
|
57
|
+
with (pth_input).open('r+', encoding='utf-8', errors='ignore') as _f:
|
|
58
|
+
_cont = _f.read()
|
|
59
|
+
_f.seek(0)
|
|
59
60
|
|
|
60
|
-
|
|
61
|
-
|
|
61
|
+
_f.write(_header)
|
|
62
|
+
_f.write(_cont)
|
|
62
63
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
64
|
+
# use ISOROPIA2
|
|
65
|
+
run = Popen([path_iso], stdin=PIPE, stdout=PIPE, stderr=PIPE)
|
|
66
|
+
scrn_res, run_res = run.communicate(input=str(pth_input.resolve()).encode())
|
|
66
67
|
|
|
67
|
-
|
|
68
|
-
|
|
68
|
+
# read dat file and transform to the normal name
|
|
69
|
+
cond_idx = df_all[['SO42-', 'NH4+', 'NO3-']].dropna().index
|
|
69
70
|
|
|
70
|
-
|
|
71
|
-
|
|
71
|
+
with (pth_output).open('r', encoding='utf-8', errors='ignore') as f:
|
|
72
|
+
df_res = read_csv(f, delimiter='\s+').apply(to_numeric, errors='coerce').set_index(index)
|
|
72
73
|
|
|
73
|
-
|
|
74
|
+
df_out['H'] = df_res['HLIQ'] / (df_res['WATER'] / 1000)
|
|
74
75
|
|
|
75
|
-
|
|
76
|
-
|
|
76
|
+
df_out.loc[cond_idx, 'pH'] = -np.log10(df_out['H'].loc[cond_idx])
|
|
77
|
+
df_out['pH'] = df_out['pH'].where((df_all['RH'] <= 95) & (df_all['RH'] >= 20))
|
|
77
78
|
|
|
78
|
-
|
|
79
|
-
|
|
79
|
+
cond_idx = df_out['pH'].dropna().index
|
|
80
|
+
df_out.loc[cond_idx, 'ALWC'] = df_res['WATER'].loc[cond_idx]
|
|
80
81
|
|
|
81
|
-
|
|
82
|
-
|
|
82
|
+
df_out[['NH3', 'HNO3', 'HCl', 'NH4+', 'NO3-', 'Cl-']] = df_res[
|
|
83
|
+
['GNH3', 'GHNO3', 'GHCL', 'NH4AER', 'NO3AER', 'CLAER']]
|
|
83
84
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
85
|
+
# calculate partition
|
|
86
|
+
# df_out['epls_NO3-'] = df_umol['NO3-'] / (df_umol['NO3-'] + df_umol['HNO3'])
|
|
87
|
+
# df_out['epls_NH4+'] = df_umol['NH4+'] / (df_umol['NH4+'] + df_umol['NH3'])
|
|
88
|
+
# df_out['epls_Cl-'] = df_umol['Cl-'] / (df_umol['Cl-'] + df_umol['HCl'])
|
|
88
89
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
90
|
+
# remove _temp file (input and output)
|
|
91
|
+
pth_input.unlink(missing_ok=True)
|
|
92
|
+
pth_output.unlink(missing_ok=True)
|
|
92
93
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
94
|
+
# output input and output
|
|
95
|
+
out = {
|
|
96
|
+
'input': df_input,
|
|
97
|
+
'output': df_out,
|
|
98
|
+
}
|
|
98
99
|
|
|
99
|
-
|
|
100
|
+
return out
|
|
@@ -1,175 +1,175 @@
|
|
|
1
|
-
from pandas import
|
|
1
|
+
from pandas import concat, DataFrame
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
def _basic(df_che, df_ref, df_water, df_density, nam_lst):
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
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
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
5
|
+
df_all = concat(df_che, axis=1)
|
|
6
|
+
index = df_all.index.copy()
|
|
7
|
+
df_all.columns = nam_lst
|
|
8
|
+
|
|
9
|
+
## parameter
|
|
10
|
+
mol_A, mol_S, mol_N = df_all['NH4+'] / 18, df_all['SO42-'] / 96, df_all['NO3-'] / 62
|
|
11
|
+
df_all['status'] = (mol_A) / (2 * mol_S + mol_N)
|
|
12
|
+
|
|
13
|
+
convert_nam = {'AS': 'SO42-',
|
|
14
|
+
'AN': 'NO3-',
|
|
15
|
+
'OM': 'OC',
|
|
16
|
+
'Soil': 'Fe',
|
|
17
|
+
'SS': 'Na+',
|
|
18
|
+
'EC': 'EC',
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
mass_coe = {'AS': 1.375,
|
|
22
|
+
'AN': 1.29,
|
|
23
|
+
'OM': 1.8,
|
|
24
|
+
'Soil': 28.57,
|
|
25
|
+
'SS': 2.54,
|
|
26
|
+
'EC': 1,
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
vol_coe = {'AS': 1.76,
|
|
30
|
+
'AN': 1.73,
|
|
31
|
+
'OM': 1.4,
|
|
32
|
+
'Soil': 2.6,
|
|
33
|
+
'SS': 2.16,
|
|
34
|
+
'EC': 1.5,
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
RI_coe = {'550': {'ALWC': 1.333 + 0j,
|
|
38
|
+
'AS': 1.53 + 0j,
|
|
39
|
+
'AN': 1.55 + 0j,
|
|
40
|
+
'OM': 1.55 + 0.0163j,
|
|
41
|
+
'Soil': 1.56 + 0.006j,
|
|
42
|
+
'SS': 1.54 + 0j,
|
|
43
|
+
'EC': 1.80 + 0.72j,
|
|
44
|
+
},
|
|
45
|
+
|
|
46
|
+
## m + kj -> m value is same as 550 current
|
|
47
|
+
'450': {'ALWC': 1.333 + 0j,
|
|
48
|
+
'AS': 1.57 + 0j,
|
|
49
|
+
'AN': 1.57 + 0j,
|
|
50
|
+
'OM': 1.58 + 0.056,
|
|
51
|
+
'Soil': 1.56 + 0.009j,
|
|
52
|
+
'SS': 1.54 + 0j,
|
|
53
|
+
'EC': 1.80 + 0.79j,
|
|
54
|
+
},
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
## mass
|
|
58
|
+
## NH4 Enough
|
|
59
|
+
df_mass = DataFrame()
|
|
60
|
+
df_enough = df_all.where(df_all['status'] >= 1).dropna().copy()
|
|
61
|
+
|
|
62
|
+
for _mass_nam, _coe in mass_coe.items():
|
|
63
|
+
df_mass[_mass_nam] = df_all[convert_nam[_mass_nam]] * _coe
|
|
64
|
+
|
|
65
|
+
## NH4 Deficiency
|
|
66
|
+
defic_idx = df_all['status'] < 1
|
|
67
|
+
|
|
68
|
+
if defic_idx.any():
|
|
69
|
+
residual = mol_A - 2 * mol_S
|
|
70
|
+
|
|
71
|
+
## residual > 0
|
|
72
|
+
_status = residual > 0
|
|
73
|
+
if _status.any():
|
|
74
|
+
_cond = _status & (residual <= mol_N)
|
|
75
|
+
df_mass.loc[_cond, 'AN'] = residual.loc[_cond] * 80
|
|
76
|
+
|
|
77
|
+
_cond = _status & (residual > mol_N)
|
|
78
|
+
df_mass.loc[_cond, 'AN'] = mol_N.loc[_cond] * 80
|
|
79
|
+
|
|
80
|
+
## residual < 0
|
|
81
|
+
_status = residual <= 0
|
|
82
|
+
if _status.any():
|
|
83
|
+
df_mass.loc[_status, 'AN'] = 0
|
|
84
|
+
|
|
85
|
+
_cond = _status & (mol_A <= 2 * mol_S)
|
|
86
|
+
df_mass.loc[_cond, 'AS'] = mol_A.loc[_cond] / 2 * 132
|
|
87
|
+
|
|
88
|
+
_cond = _status & (mol_A > 2 * mol_S)
|
|
89
|
+
df_mass.loc[_cond, 'AS'] = mol_S.loc[_cond] * 132
|
|
90
|
+
|
|
91
|
+
df_mass_cal = df_mass.dropna().copy()
|
|
92
|
+
df_mass['total'] = df_mass.sum(axis=1, min_count=6)
|
|
93
|
+
|
|
94
|
+
qc_ratio = df_mass['total'] / df_ref
|
|
95
|
+
qc_cond = (qc_ratio >= 0.7) & (qc_ratio <= 1.3)
|
|
96
|
+
|
|
97
|
+
## volume
|
|
98
|
+
df_vol = DataFrame()
|
|
99
|
+
for _vol_nam, _coe in vol_coe.items():
|
|
100
|
+
df_vol[_vol_nam] = df_mass_cal[_vol_nam] / _coe
|
|
101
|
+
|
|
102
|
+
if df_water is not None:
|
|
103
|
+
df_vol['ALWC'] = df_water
|
|
104
|
+
df_vol = df_vol.dropna()
|
|
105
|
+
df_vol['total_wet'] = df_vol.sum(axis=1, min_count=6)
|
|
106
|
+
|
|
107
|
+
df_vol['total_dry'] = df_vol[vol_coe.keys()].sum(axis=1, min_count=6)
|
|
108
|
+
|
|
109
|
+
## density
|
|
110
|
+
df_vol_cal = DataFrame()
|
|
111
|
+
df_den_rec = df_mass['total'] / df_vol['total_dry']
|
|
112
|
+
if df_density is not None:
|
|
113
|
+
df_den_all = concat([df_all[['SO42-', 'NO3-', 'NH4+', 'EC']], df_density, df_mass['OM']], axis=1).dropna()
|
|
114
|
+
|
|
115
|
+
df_vol_cal = (df_den_all[['SO42-', 'NO3-', 'NH4+']].sum(axis=1) / 1.75) + \
|
|
116
|
+
df_den_all['Cl-'] / 1.52 + \
|
|
117
|
+
df_den_all['OM'] / 1.4 + df_den_all['EC'] / 1.77
|
|
118
|
+
|
|
119
|
+
df_den = df_den_all.sum(axis=1, min_count=6) / df_vol_cal
|
|
120
|
+
# df_den = df_den_all.sum(axis=1) / df_vol_cal
|
|
121
|
+
# df_den = df_mass['total'].loc[df_den_all.index] / df_vol_cal
|
|
122
|
+
|
|
123
|
+
## refractive index
|
|
124
|
+
ri_dic = {}
|
|
125
|
+
for _lambda, _coe in RI_coe.items():
|
|
126
|
+
|
|
127
|
+
df_RI = DataFrame()
|
|
128
|
+
|
|
129
|
+
for _ky, _df in df_vol.items():
|
|
130
|
+
if 'total' in _ky: continue
|
|
131
|
+
df_RI[_ky] = (_df * _coe[_ky])
|
|
132
|
+
|
|
133
|
+
df_RI['RI_wet'] = None
|
|
134
|
+
if df_water is not None:
|
|
135
|
+
df_RI['RI_wet'] = (df_RI / df_vol['total_wet'].to_frame().values).sum(axis=1)
|
|
136
136
|
|
|
137
|
-
|
|
137
|
+
df_RI['RI_dry'] = (df_RI[vol_coe.keys()] / df_vol['total_dry'].to_frame().values).sum(axis=1)
|
|
138
138
|
|
|
139
|
-
|
|
139
|
+
ri_dic[f'RI_{_lambda}'] = df_RI[['RI_dry', 'RI_wet']]
|
|
140
140
|
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
141
|
+
## mole and equivalent
|
|
142
|
+
df_eq = concat((mol_A, mol_S, mol_N, mol_A * 1, mol_S * 2, mol_N * 1), axis=1)
|
|
143
|
+
df_eq.columns = ['mol_NH4', 'mol_SO4', 'mol_NO3', 'eq_NH4', 'eq_SO4', 'eq_NO3', ]
|
|
144
144
|
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
145
|
+
## out
|
|
146
|
+
out = {'mass': df_mass,
|
|
147
|
+
'volume': df_vol,
|
|
148
|
+
'vol_cal': df_vol_cal,
|
|
149
|
+
'eq': df_eq,
|
|
150
|
+
'density_mat': df_den,
|
|
151
|
+
'density_rec': df_den_rec,
|
|
152
|
+
}
|
|
153
|
+
out.update(ri_dic)
|
|
154
154
|
|
|
155
|
-
|
|
156
|
-
|
|
155
|
+
for _ky, _df in out.items():
|
|
156
|
+
out[_ky] = _df.reindex(index).where(qc_cond)
|
|
157
157
|
|
|
158
|
-
|
|
158
|
+
return out
|
|
159
159
|
|
|
160
160
|
|
|
161
161
|
# '''
|
|
162
162
|
|
|
163
163
|
|
|
164
164
|
def mass_ratio(_df):
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
165
|
+
if _df['PM25'] >= _df['total_mass']:
|
|
166
|
+
_df['others'] = _df['PM25'] - _df['total_mass']
|
|
167
|
+
for _val, _species in zip(_df.values, _df.index):
|
|
168
|
+
_df[f'{_species}_ratio'] = _val / _df['PM25'].__round__(3)
|
|
169
169
|
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
170
|
+
if _df['PM25'] < _df['total_mass']:
|
|
171
|
+
_df['others'] = 0
|
|
172
|
+
for _val, _species in zip(_df.values, _df.index):
|
|
173
|
+
_df[f'{_species}_ratio'] = _val / _df['PM25'].__round__(3)
|
|
174
174
|
|
|
175
|
-
|
|
175
|
+
return _df['others':].drop(labels=['PM25_ratio', 'total_mass_ratio'])
|