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.

Files changed (112) hide show
  1. AeroViz/__init__.py +4 -4
  2. AeroViz/config/DEFAULT_DATA.csv +1417 -0
  3. AeroViz/config/DEFAULT_PNSD_DATA.csv +1417 -0
  4. AeroViz/dataProcess/Chemistry/__init__.py +38 -38
  5. AeroViz/dataProcess/Chemistry/_calculate.py +15 -15
  6. AeroViz/dataProcess/Chemistry/_isoropia.py +69 -68
  7. AeroViz/dataProcess/Chemistry/_mass_volume.py +158 -158
  8. AeroViz/dataProcess/Chemistry/_ocec.py +109 -109
  9. AeroViz/dataProcess/Chemistry/_partition.py +19 -18
  10. AeroViz/dataProcess/Chemistry/_teom.py +8 -11
  11. AeroViz/dataProcess/Optical/_IMPROVE.py +40 -39
  12. AeroViz/dataProcess/Optical/__init__.py +35 -35
  13. AeroViz/dataProcess/Optical/_absorption.py +35 -35
  14. AeroViz/dataProcess/Optical/_extinction.py +25 -24
  15. AeroViz/dataProcess/Optical/_mie.py +5 -6
  16. AeroViz/dataProcess/Optical/_mie_sd.py +89 -90
  17. AeroViz/dataProcess/Optical/_scattering.py +16 -16
  18. AeroViz/dataProcess/SizeDistr/__init__.py +37 -37
  19. AeroViz/dataProcess/SizeDistr/__merge.py +159 -158
  20. AeroViz/dataProcess/SizeDistr/_merge.py +155 -154
  21. AeroViz/dataProcess/SizeDistr/_merge_v1.py +162 -161
  22. AeroViz/dataProcess/SizeDistr/_merge_v2.py +153 -152
  23. AeroViz/dataProcess/SizeDistr/_merge_v3.py +326 -326
  24. AeroViz/dataProcess/SizeDistr/_merge_v4.py +272 -274
  25. AeroViz/dataProcess/SizeDistr/_size_distr.py +51 -51
  26. AeroViz/dataProcess/VOC/__init__.py +7 -7
  27. AeroViz/dataProcess/VOC/_potential_par.py +53 -55
  28. AeroViz/dataProcess/VOC/voc_par.json +464 -0
  29. AeroViz/dataProcess/__init__.py +4 -4
  30. AeroViz/dataProcess/core/__init__.py +59 -58
  31. AeroViz/plot/__init__.py +6 -1
  32. AeroViz/plot/bar.py +126 -0
  33. AeroViz/plot/box.py +68 -0
  34. AeroViz/plot/distribution/distribution.py +421 -427
  35. AeroViz/plot/meteorology/meteorology.py +240 -292
  36. AeroViz/plot/optical/__init__.py +0 -1
  37. AeroViz/plot/optical/optical.py +230 -230
  38. AeroViz/plot/pie.py +198 -0
  39. AeroViz/plot/regression.py +210 -0
  40. AeroViz/plot/scatter.py +99 -0
  41. AeroViz/plot/templates/__init__.py +0 -3
  42. AeroViz/plot/templates/contour.py +25 -25
  43. AeroViz/plot/templates/corr_matrix.py +86 -93
  44. AeroViz/plot/templates/diurnal_pattern.py +24 -24
  45. AeroViz/plot/templates/koschmieder.py +106 -106
  46. AeroViz/plot/templates/metal_heatmap.py +34 -34
  47. AeroViz/plot/timeseries/timeseries.py +53 -60
  48. AeroViz/plot/utils/__init__.py +2 -1
  49. AeroViz/plot/utils/_color.py +57 -57
  50. AeroViz/plot/utils/_unit.py +48 -48
  51. AeroViz/plot/utils/fRH.json +390 -0
  52. AeroViz/plot/utils/plt_utils.py +92 -0
  53. AeroViz/plot/utils/sklearn_utils.py +49 -0
  54. AeroViz/plot/utils/units.json +84 -0
  55. AeroViz/plot/violin.py +79 -0
  56. AeroViz/process/__init__.py +15 -15
  57. AeroViz/process/core/DataProc.py +9 -9
  58. AeroViz/process/core/SizeDist.py +81 -81
  59. AeroViz/process/method/PyMieScatt_update.py +488 -488
  60. AeroViz/process/method/mie_theory.py +231 -229
  61. AeroViz/process/method/prop.py +40 -40
  62. AeroViz/process/script/AbstractDistCalc.py +103 -103
  63. AeroViz/process/script/Chemical.py +166 -166
  64. AeroViz/process/script/IMPACT.py +40 -40
  65. AeroViz/process/script/IMPROVE.py +152 -152
  66. AeroViz/process/script/Others.py +45 -45
  67. AeroViz/process/script/PSD.py +26 -26
  68. AeroViz/process/script/PSD_dry.py +69 -70
  69. AeroViz/process/script/retrieve_RI.py +50 -51
  70. AeroViz/rawDataReader/__init__.py +57 -57
  71. AeroViz/rawDataReader/core/__init__.py +328 -326
  72. AeroViz/rawDataReader/script/AE33.py +18 -18
  73. AeroViz/rawDataReader/script/AE43.py +20 -20
  74. AeroViz/rawDataReader/script/APS_3321.py +30 -30
  75. AeroViz/rawDataReader/script/Aurora.py +23 -23
  76. AeroViz/rawDataReader/script/BC1054.py +40 -40
  77. AeroViz/rawDataReader/script/EPA_vertical.py +9 -9
  78. AeroViz/rawDataReader/script/GRIMM.py +21 -21
  79. AeroViz/rawDataReader/script/IGAC_TH.py +67 -67
  80. AeroViz/rawDataReader/script/IGAC_ZM.py +59 -59
  81. AeroViz/rawDataReader/script/MA350.py +39 -39
  82. AeroViz/rawDataReader/script/NEPH.py +74 -74
  83. AeroViz/rawDataReader/script/OCEC_LCRES.py +21 -21
  84. AeroViz/rawDataReader/script/OCEC_RES.py +16 -16
  85. AeroViz/rawDataReader/script/SMPS_TH.py +25 -25
  86. AeroViz/rawDataReader/script/SMPS_aim11.py +32 -32
  87. AeroViz/rawDataReader/script/SMPS_genr.py +31 -31
  88. AeroViz/rawDataReader/script/TEOM.py +28 -28
  89. AeroViz/rawDataReader/script/Table.py +12 -12
  90. AeroViz/rawDataReader/script/VOC_TH.py +16 -16
  91. AeroViz/rawDataReader/script/VOC_ZM.py +28 -28
  92. AeroViz/rawDataReader/script/__init__.py +20 -20
  93. AeroViz/rawDataReader/utils/config.py +161 -161
  94. AeroViz/tools/database.py +65 -65
  95. AeroViz/tools/dataclassifier.py +106 -106
  96. AeroViz/tools/dataprinter.py +51 -51
  97. AeroViz/tools/datareader.py +38 -38
  98. {AeroViz-0.1.2.dist-info → AeroViz-0.1.3b0.dist-info}/METADATA +5 -4
  99. AeroViz-0.1.3b0.dist-info/RECORD +110 -0
  100. AeroViz/config/__init__.py +0 -0
  101. AeroViz/plot/improve/__init__.py +0 -1
  102. AeroViz/plot/improve/improve.py +0 -240
  103. AeroViz/plot/optical/aethalometer.py +0 -77
  104. AeroViz/plot/templates/event_evolution.py +0 -65
  105. AeroViz/plot/templates/regression.py +0 -256
  106. AeroViz/plot/templates/scatter.py +0 -130
  107. AeroViz/plot/templates/templates.py +0 -398
  108. AeroViz/plot/utils/_decorator.py +0 -74
  109. AeroViz-0.1.2.dist-info/RECORD +0 -106
  110. {AeroViz-0.1.2.dist-info → AeroViz-0.1.3b0.dist-info}/LICENSE +0 -0
  111. {AeroViz-0.1.2.dist-info → AeroViz-0.1.3b0.dist-info}/WHEEL +0 -0
  112. {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
- '_basic',
9
- # '_ocec_ratio_cal',
8
+ '_basic',
9
+ # '_ocec_ratio_cal',
10
10
  ]
11
11
 
12
12
 
13
13
  def _min_Rsq(_oc, _ec, _rng):
14
- _val_mesh, _oc_mesh = np.meshgrid(_rng, _oc)
15
- _val_mesh, _ec_mesh = np.meshgrid(_rng, _ec)
14
+ _val_mesh, _oc_mesh = np.meshgrid(_rng, _oc)
15
+ _val_mesh, _ec_mesh = np.meshgrid(_rng, _ec)
16
16
 
17
- _out_table = DataFrame(_oc_mesh - _val_mesh * _ec_mesh, index=_oc.index, columns=_rng)
17
+ _out_table = DataFrame(_oc_mesh - _val_mesh * _ec_mesh, index=_oc.index, columns=_rng)
18
18
 
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()
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
- _x, _y = _df[0], _df[1]
26
- _opt, _ = curve_fit(_func, _x, _y)
25
+ _x, _y = _df[0], _df[1]
26
+ _opt, _ = curve_fit(_func, _x, _y)
27
27
 
28
- _tss = np.sum((_y - _y.mean()) ** 2.)
29
- _rss = np.sum((_y - _func(_x, *_opt)) ** 2.)
28
+ _tss = np.sum((_y - _y.mean()) ** 2.)
29
+ _rss = np.sum((_y - _func(_x, *_opt)) ** 2.)
30
30
 
31
- _r2_dic[round(_ocec, 3)] = 1. - _rss / _tss
31
+ _r2_dic[round(_ocec, 3)] = 1. - _rss / _tss
32
32
 
33
- ## get the min R2
34
- _ratio = DataFrame(_r2_dic, index=[0]).idxmin(axis=1).values[0]
33
+ ## get the min R2
34
+ _ratio = DataFrame(_r2_dic, index=[0]).idxmin(axis=1).values[0]
35
35
 
36
- return _ratio, _out_table[_ratio]
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
- ## 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']
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
- ## real data OC/EC
46
- _ocec_ratio_real = (_oc / _ec).quantile(.5)
45
+ ## real data OC/EC
46
+ _ocec_ratio_real = (_oc / _ec).quantile(.5)
47
47
 
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}']
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
- ## 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 !!')
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
- _out[[f'OC/EC_{_nam}', f'POC_{_nam}', f'SOC_{_nam}', f'WISOC/OC_{_nam}', f'WSOC_{_nam}',
59
- f'WISOC_{_nam}']] = np.nan
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
- return _out
61
+ return _out
62
62
 
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
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
- return _out
67
+ return _out
68
68
 
69
- ## OC/EC
70
- _ocec_ratio = False
71
- _st, _ed, _stp = _range_
69
+ ## OC/EC
70
+ _ocec_ratio = False
71
+ _st, _ed, _stp = _range_
72
72
 
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)
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
- _ocec_ratio, _soc = _min_Rsq(_oc, _ec, _ocec_rng)
79
+ _ocec_ratio, _soc = _min_Rsq(_oc, _ec, _ocec_rng)
80
80
 
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)
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
- ## 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}']
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
- 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}']]
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
- _lcres, _res, _mass = _union_index(_lcres, _res, _mass)
99
+ _lcres, _res, _mass = _union_index(_lcres, _res, _mass)
100
100
 
101
- _out = {}
101
+ _out = {}
102
102
 
103
- ## OC1, OC2, OC3, OC4, PC
104
- _df_bsc = _res / _lcres['Sample_Volume'].to_frame().values.copy()
103
+ ## OC1, OC2, OC3, OC4, PC
104
+ _df_bsc = _res / _lcres['Sample_Volume'].to_frame().values.copy()
105
105
 
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 !!')
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
- _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']
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
- 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))
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
- _prcs_df = concat(_df_lst)
125
+ _prcs_df = concat(_df_lst)
126
126
 
127
- _df_bsc = concat((_df_bsc.copy(), _prcs_df), axis=1)
127
+ _df_bsc = concat((_df_bsc.copy(), _prcs_df), axis=1)
128
128
 
129
- ## ratio
130
- _df_ratio = DataFrame(index=_df_bsc.index)
129
+ ## ratio
130
+ _df_ratio = DataFrame(index=_df_bsc.index)
131
131
 
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']
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
- if _mass is not None:
138
- for _ky, _val in _df_bsc.items():
139
- _df_ratio[f'{_ky}/PM'] = _val / _mass
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
- _df_ratio[f'Thermal_OC/PM'] = _lcres['Thermal_OC'] / _mass
142
- _df_ratio[f'Thermal_EC/PM'] = _lcres['Thermal_EC'] / _mass
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
- _df_ratio[f'Optical_OC/PM'] = _lcres['Optical_OC'] / _mass
145
- _df_ratio[f'Optical_EC/PM'] = _lcres['Optical_EC'] / _mass
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
- ## ratio status
148
- _df_bsc = concat((_lcres, _df_bsc.copy()), axis=1)
147
+ ## ratio status
148
+ _df_bsc = concat((_lcres, _df_bsc.copy()), axis=1)
149
149
 
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')
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
- ## out
155
- _out['ratio'] = _df_ratio
156
- _out['basic'] = _df_bsc
154
+ ## out
155
+ _out['ratio'] = _df_ratio
156
+ _out['basic'] = _df_bsc
157
157
 
158
- return _out
158
+ return _out
159
159
 
160
160
 
161
161
  '''
@@ -1,29 +1,30 @@
1
- from pandas import date_range, concat, DataFrame, to_numeric
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
- # parameter
7
- df_all = concat(df_che, axis=1)
8
- index = df_all.index.copy()
9
- df_all.columns = nam_lst
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
- df_umol = _ug2umol(df_all)
12
+ df_umol = _ug2umol(df_all)
12
13
 
13
- # calculate
14
- df_out = DataFrame(index=df_umol.index)
14
+ # calculate
15
+ df_out = DataFrame(index=df_umol.index)
15
16
 
16
- # df_out['NTR'] = df_umol['NH4+'] / (df_umol['NH4+'] + df_all['NH3'] / 22.4)
17
- df_out['NTR+'] = df_umol['NH4+'] / (df_umol['NH4+'] + df_umol['NH3'])
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
- df_out['NOR'] = df_umol['NO3-'] / (df_umol['NO3-'] + df_umol['NO2'])
20
- df_out['NOR_2'] = (df_umol['NO3-'] + df_umol['HNO3']) / (df_umol['NO3-'] + df_umol['NO2'] + df_umol['HNO3'])
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
- df_out['SOR'] = df_umol['SO42-'] / (df_umol['SO42-'] + df_umol['SO2'])
23
+ df_out['SOR'] = df_umol['SO42-'] / (df_umol['SO42-'] + df_umol['SO2'])
23
24
 
24
- df_out['epls_NO3-'] = df_umol['NO3-'] / (df_umol['NO3-'] + df_umol['HNO3'])
25
- df_out['epls_NH4+'] = df_umol['NH4+'] / (df_umol['NH4+'] + df_umol['NH3'])
26
- df_out['epls_SO42-'] = df_out['SOR']
27
- df_out['epls_Cl-'] = df_umol['Cl-'] / (df_umol['Cl-'] + df_umol['HCl'])
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
- return df_out
30
+ return df_out
@@ -1,16 +1,13 @@
1
- import numpy as np
2
-
3
-
4
1
  def _basic(_teom, _check):
5
- _teom['Volatile_Fraction'] = (_teom['PM_Total'] - _teom['PM_NV']) / _teom['PM_Total']
2
+ _teom['Volatile_Fraction'] = (_teom['PM_Total'] - _teom['PM_NV']) / _teom['PM_Total']
6
3
 
7
- _teom.loc[(_teom['Volatile_Fraction'] < 0) | (_teom['Volatile_Fraction'] > 1)] = n.nan
4
+ _teom.loc[(_teom['Volatile_Fraction'] < 0) | (_teom['Volatile_Fraction'] > 1)] = n.nan
8
5
 
9
- if _check is not None:
10
- _ratio = _teom['PM_NV'] / _check
11
- _teom['PM_Check'] = _check
6
+ if _check is not None:
7
+ _ratio = _teom['PM_NV'] / _check
8
+ _teom['PM_Check'] = _check
12
9
 
13
- _teom.loc[_teom.dropna().index, 'status'] = 'Warning'
14
- _teom.loc[(_ratio > 0) & (_ratio < 1), 'status'] = 'Normal'
10
+ _teom.loc[_teom.dropna().index, 'status'] = 'Warning'
11
+ _teom.loc[(_ratio > 0) & (_ratio < 1), 'status'] = 'Normal'
15
12
 
16
- return _teom
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
- _df_mass, _df_RH = _union_index(_df_mass, _df_RH)
11
+ _df_mass, _df_RH = _union_index(_df_mass, _df_RH)
11
12
 
12
- ## fRH
13
- with (Path(__file__).parent / 'fRH.pkl').open('rb') as f:
14
- _fRH = pkl.load(f)
15
- _fRH.loc[np.nan] = np.nan
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
- def fRH(_RH):
18
- if _RH is not None:
19
- _RH = _RH.mask(_RH > 95, 95).round(0)
20
- return _fRH.loc[_RH].values.T
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
- return 1, 1, 1, 1
23
+ return 1, 1, 1, 1
23
24
 
24
- ## different mode
25
- ## mass < 20 :
26
- ## large = mass**2/20
27
- ## small = mass-large
28
- ## mass >= 20 :
29
- ## large = mass
30
- ## small = 0
31
- _df_mode = _df_mass[['AS', 'AN', 'OM']].copy()
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
- _df_mass[['L_AS', 'L_AN', 'L_OM']] = _df_mode.mask(_df_mode < 20, _df_mode ** 2 / 20)
34
- _df_mass[['S_AS', 'S_AN', 'S_OM']] = _df_mode.values - _df_mass[['L_AS', 'L_AN', 'L_OM']]
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
- ## apply IMPROVE ccoe.
37
- def _ext_cal(_RH=None):
37
+ ## apply IMPROVE ccoe.
38
+ def _ext_cal(_RH=None):
38
39
 
39
- _frh, _frhss, _frhs, _frhl = fRH(_RH)
40
- _df = DataFrame(index=_df_mass.index)
40
+ _frh, _frhss, _frhs, _frhl = fRH(_RH)
41
+ _df = DataFrame(index=_df_mass.index)
41
42
 
42
- _df['AS'] = 2.2 * _frhs * _df_mass['S_AS'] + 4.8 * _frhl * _df_mass['L_AS']
43
- _df['AN'] = 2.4 * _frhs * _df_mass['S_AN'] + 5.1 * _frhl * _df_mass['L_AN']
44
- _df['OM'] = 2.8 * _df_mass['S_OM'] + 6.1 * _frhl * _df_mass['L_OM']
45
- _df['Soil'] = _df_mass['Soil']
46
- _df['SS'] = 1.7 * _frhss * _df_mass['SS']
47
- _df['EC'] = 10 * _df_mass['EC']
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
- _df['total'] = _df.sum(axis=1)
50
+ _df['total'] = _df.sum(axis=1)
50
51
 
51
- return _df.dropna().reindex(_df_mass.index)
52
+ return _df.dropna().reindex(_df_mass.index)
52
53
 
53
- ## calculate
54
- _out = {}
54
+ ## calculate
55
+ _out = {}
55
56
 
56
- _out['dry'] = _ext_cal()
57
+ _out['dry'] = _ext_cal()
57
58
 
58
- if _df_RH is not None:
59
- _out['wet'] = _ext_cal(_df_RH)
59
+ if _df_RH is not None:
60
+ _out['wet'] = _ext_cal(_df_RH)
60
61
 
61
- return _out
62
+ return _out
@@ -2,61 +2,61 @@ from ..core import _writter, _run_process
2
2
 
3
3
  __all__ = [
4
4
 
5
- 'Optical',
5
+ 'Optical',
6
6
 
7
7
  ]
8
8
 
9
9
 
10
10
  class Optical(_writter):
11
11
 
12
- ## scatter
13
- @_run_process('Optical - SAE', 'SAE')
14
- def SAE(self, df_sca):
15
- from ._scattering import _SAE
12
+ ## scatter
13
+ @_run_process('Optical - SAE', 'SAE')
14
+ def SAE(self, df_sca):
15
+ from ._scattering import _SAE
16
16
 
17
- out = _SAE(df_sca)
17
+ out = _SAE(df_sca)
18
18
 
19
- return self, out
19
+ return self, out
20
20
 
21
- ## absorption
22
- @_run_process('Optical - absCoe', 'absCoe')
23
- def absCoe(self, df_ae33, abs_band=[550]):
24
- from ._absorption import _absCoe
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
- out = _absCoe(df_ae33, abs_band)
26
+ out = _absCoe(df_ae33, abs_band)
27
27
 
28
- return self, out
28
+ return self, out
29
29
 
30
- @_run_process('Optical - AAE', 'AAE')
31
- def AAE(self, df_abs):
32
- from ._absorption import _AAE
30
+ @_run_process('Optical - AAE', 'AAE')
31
+ def AAE(self, df_abs):
32
+ from ._absorption import _AAE
33
33
 
34
- out = _AAE(df_abs)
34
+ out = _AAE(df_abs)
35
35
 
36
- return self, out
36
+ return self, out
37
37
 
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
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
- out = _basic(df_abs, df_sca, df_ec, df_mass, df_no2)
43
+ out = _basic(df_abs, df_sca, df_ec, df_mass, df_no2)
44
44
 
45
- return self, out
45
+ return self, out
46
46
 
47
- @_run_process('Optical - Mie', 'Mie')
48
- def Mie(self, df_psd, df_m, wave_length=550):
49
- from ._mie import _mie
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
- out = _mie(df_psd, df_m, wave_length)
51
+ out = _mie(df_psd, df_m, wave_length)
52
52
 
53
- return self, out
53
+ return self, out
54
54
 
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
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
- out = _revised(df_mass, df_RH)
60
+ out = _revised(df_mass, df_RH)
61
61
 
62
- return self, out
62
+ return self, out
@@ -1,54 +1,54 @@
1
1
  def _absCoe(df, abs_band):
2
- import numpy as n
3
- from scipy.optimize import curve_fit
2
+ import numpy as n
3
+ from scipy.optimize import curve_fit
4
4
 
5
- band = n.array([370, 470, 520, 590, 660, 880, 950])
5
+ band = n.array([370, 470, 520, 590, 660, 880, 950])
6
6
 
7
- df_out = {}
7
+ df_out = {}
8
8
 
9
- def _get_slope(__df):
10
- func = lambda _x, _sl, _int: _sl * _x + _int
11
- popt, pcov = curve_fit(func, band, __df.values)
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
- return func(n.array(abs_band), *popt)
13
+ return func(n.array(abs_band), *popt)
14
14
 
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()
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
- 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]
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
- df_out['eBC'] = df['BC6']
21
+ df_out['eBC'] = df['BC6']
22
22
 
23
- return df_out
23
+ return df_out
24
24
 
25
25
 
26
26
  def _AAE(df):
27
- import numpy as n
28
- from scipy.optimize import curve_fit
27
+ import numpy as n
28
+ from scipy.optimize import curve_fit
29
29
 
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
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
- ## 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))
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
- return popt
42
+ return popt
43
43
 
44
- ## calculate
45
- _AAE = _df.apply(_get_slope, axis=1, result_type='expand')
46
- _AAE.columns = ['slope', 'intercept']
44
+ ## calculate
45
+ _AAE = _df.apply(_get_slope, axis=1, result_type='expand')
46
+ _AAE.columns = ['slope', 'intercept']
47
47
 
48
- return _AAE
48
+ return _AAE
49
49
 
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()
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
- df_out['eBC'] = df['BC6']
54
- return df_out.reindex(df.index)
53
+ df_out['eBC'] = df['BC6']
54
+ return df_out.reindex(df.index)