AeroViz 0.1.3__py3-none-any.whl → 0.1.4__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 (121) hide show
  1. AeroViz/__init__.py +7 -5
  2. AeroViz/{config → data}/DEFAULT_DATA.csv +1 -1
  3. AeroViz/dataProcess/Chemistry/__init__.py +40 -40
  4. AeroViz/dataProcess/Chemistry/_calculate.py +15 -15
  5. AeroViz/dataProcess/Chemistry/_isoropia.py +72 -68
  6. AeroViz/dataProcess/Chemistry/_mass_volume.py +158 -161
  7. AeroViz/dataProcess/Chemistry/_ocec.py +109 -109
  8. AeroViz/dataProcess/Chemistry/_partition.py +19 -18
  9. AeroViz/dataProcess/Chemistry/_teom.py +9 -11
  10. AeroViz/dataProcess/Chemistry/isrpia.cnf +21 -0
  11. AeroViz/dataProcess/Optical/Angstrom_exponent.py +20 -0
  12. AeroViz/dataProcess/Optical/_IMPROVE.py +40 -41
  13. AeroViz/dataProcess/Optical/__init__.py +29 -44
  14. AeroViz/dataProcess/Optical/_absorption.py +21 -47
  15. AeroViz/dataProcess/Optical/_extinction.py +31 -25
  16. AeroViz/dataProcess/Optical/_mie.py +5 -7
  17. AeroViz/dataProcess/Optical/_mie_sd.py +89 -90
  18. AeroViz/dataProcess/Optical/_scattering.py +19 -20
  19. AeroViz/dataProcess/SizeDistr/__init__.py +39 -39
  20. AeroViz/dataProcess/SizeDistr/__merge.py +159 -158
  21. AeroViz/dataProcess/SizeDistr/_merge.py +155 -154
  22. AeroViz/dataProcess/SizeDistr/_merge_v1.py +162 -161
  23. AeroViz/dataProcess/SizeDistr/_merge_v2.py +153 -152
  24. AeroViz/dataProcess/SizeDistr/_merge_v3.py +327 -327
  25. AeroViz/dataProcess/SizeDistr/_merge_v4.py +273 -275
  26. AeroViz/dataProcess/SizeDistr/_size_distr.py +51 -51
  27. AeroViz/dataProcess/VOC/__init__.py +9 -9
  28. AeroViz/dataProcess/VOC/_potential_par.py +53 -55
  29. AeroViz/dataProcess/__init__.py +28 -6
  30. AeroViz/dataProcess/core/__init__.py +59 -65
  31. AeroViz/plot/__init__.py +7 -2
  32. AeroViz/plot/bar.py +126 -0
  33. AeroViz/plot/box.py +69 -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 +196 -0
  40. AeroViz/plot/scatter.py +165 -0
  41. AeroViz/plot/templates/__init__.py +2 -4
  42. AeroViz/plot/templates/ammonium_rich.py +34 -0
  43. AeroViz/plot/templates/contour.py +25 -25
  44. AeroViz/plot/templates/corr_matrix.py +86 -93
  45. AeroViz/plot/templates/diurnal_pattern.py +28 -26
  46. AeroViz/plot/templates/koschmieder.py +59 -123
  47. AeroViz/plot/templates/metal_heatmap.py +135 -37
  48. AeroViz/plot/timeseries/__init__.py +1 -0
  49. AeroViz/plot/timeseries/template.py +47 -0
  50. AeroViz/plot/timeseries/timeseries.py +324 -264
  51. AeroViz/plot/utils/__init__.py +2 -1
  52. AeroViz/plot/utils/_color.py +57 -57
  53. AeroViz/plot/utils/_unit.py +48 -48
  54. AeroViz/plot/utils/plt_utils.py +92 -0
  55. AeroViz/plot/utils/sklearn_utils.py +49 -0
  56. AeroViz/plot/utils/units.json +5 -0
  57. AeroViz/plot/violin.py +80 -0
  58. AeroViz/process/__init__.py +17 -17
  59. AeroViz/process/core/DataProc.py +9 -9
  60. AeroViz/process/core/SizeDist.py +81 -81
  61. AeroViz/process/method/PyMieScatt_update.py +488 -488
  62. AeroViz/process/method/mie_theory.py +231 -229
  63. AeroViz/process/method/prop.py +40 -40
  64. AeroViz/process/script/AbstractDistCalc.py +103 -103
  65. AeroViz/process/script/Chemical.py +168 -167
  66. AeroViz/process/script/IMPACT.py +40 -40
  67. AeroViz/process/script/IMPROVE.py +152 -152
  68. AeroViz/process/script/Others.py +45 -45
  69. AeroViz/process/script/PSD.py +26 -26
  70. AeroViz/process/script/PSD_dry.py +69 -70
  71. AeroViz/process/script/retrieve_RI.py +50 -51
  72. AeroViz/rawDataReader/__init__.py +53 -58
  73. AeroViz/rawDataReader/config/supported_instruments.py +155 -0
  74. AeroViz/rawDataReader/core/__init__.py +233 -356
  75. AeroViz/rawDataReader/script/AE33.py +17 -18
  76. AeroViz/rawDataReader/script/AE43.py +18 -21
  77. AeroViz/rawDataReader/script/APS_3321.py +30 -30
  78. AeroViz/rawDataReader/script/Aurora.py +23 -24
  79. AeroViz/rawDataReader/script/BC1054.py +36 -40
  80. AeroViz/rawDataReader/script/EPA_vertical.py +37 -9
  81. AeroViz/rawDataReader/script/GRIMM.py +16 -23
  82. AeroViz/rawDataReader/script/IGAC.py +90 -0
  83. AeroViz/rawDataReader/script/MA350.py +32 -39
  84. AeroViz/rawDataReader/script/Minion.py +103 -0
  85. AeroViz/rawDataReader/script/NEPH.py +69 -74
  86. AeroViz/rawDataReader/script/SMPS_TH.py +25 -25
  87. AeroViz/rawDataReader/script/SMPS_aim11.py +32 -32
  88. AeroViz/rawDataReader/script/SMPS_genr.py +31 -31
  89. AeroViz/rawDataReader/script/Sunset_OCEC.py +60 -0
  90. AeroViz/rawDataReader/script/TEOM.py +30 -28
  91. AeroViz/rawDataReader/script/Table.py +13 -14
  92. AeroViz/rawDataReader/script/VOC.py +26 -0
  93. AeroViz/rawDataReader/script/__init__.py +18 -20
  94. AeroViz/tools/database.py +64 -66
  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.3.dist-info → AeroViz-0.1.4.dist-info}/METADATA +5 -4
  99. AeroViz-0.1.4.dist-info/RECORD +112 -0
  100. AeroViz/plot/improve/__init__.py +0 -1
  101. AeroViz/plot/improve/improve.py +0 -240
  102. AeroViz/plot/optical/aethalometer.py +0 -77
  103. AeroViz/plot/templates/event_evolution.py +0 -65
  104. AeroViz/plot/templates/regression.py +0 -256
  105. AeroViz/plot/templates/scatter.py +0 -130
  106. AeroViz/plot/templates/templates.py +0 -398
  107. AeroViz/plot/utils/_decorator.py +0 -74
  108. AeroViz/rawDataReader/script/IGAC_TH.py +0 -104
  109. AeroViz/rawDataReader/script/IGAC_ZM.py +0 -90
  110. AeroViz/rawDataReader/script/OCEC_LCRES.py +0 -34
  111. AeroViz/rawDataReader/script/OCEC_RES.py +0 -28
  112. AeroViz/rawDataReader/script/VOC_TH.py +0 -30
  113. AeroViz/rawDataReader/script/VOC_ZM.py +0 -37
  114. AeroViz/rawDataReader/utils/__init__.py +0 -0
  115. AeroViz/rawDataReader/utils/config.py +0 -169
  116. AeroViz-0.1.3.dist-info/RECORD +0 -111
  117. /AeroViz/{config → data}/DEFAULT_PNSD_DATA.csv +0 -0
  118. /AeroViz/{config → rawDataReader/config}/__init__.py +0 -0
  119. {AeroViz-0.1.3.dist-info → AeroViz-0.1.4.dist-info}/LICENSE +0 -0
  120. {AeroViz-0.1.3.dist-info → AeroViz-0.1.4.dist-info}/WHEEL +0 -0
  121. {AeroViz-0.1.3.dist-info → AeroViz-0.1.4.dist-info}/top_level.txt +0 -0
@@ -1,32 +1,33 @@
1
1
  from datetime import datetime as dtm
2
+
3
+ import numpy as np
2
4
  from pandas import DataFrame, to_datetime
3
5
  # from scipy.interpolate import interp1d
4
6
  from scipy.interpolate import UnivariateSpline as unvpline, interp1d
5
- import numpy as np
6
7
 
7
8
  __all__ = ['_merge_SMPS_APS']
8
9
 
9
10
 
10
11
  def __test_plot(smpsx, smps, apsx, aps, mergex, merge, mergeox, mergeo, _sh):
11
- from matplotlib.pyplot import subplots, close, show, rcParams
12
+ from matplotlib.pyplot import subplots, close, show
12
13
 
13
- ## parameter
14
- # '''
15
- ## plot
16
- fig, ax = subplots()
14
+ ## parameter
15
+ # '''
16
+ ## plot
17
+ fig, ax = subplots()
17
18
 
18
- ax.plot(smpsx, smps, c='#ff794c', label='smps', marker='o', lw=2)
19
- ax.plot(apsx, aps, c='#4c79ff', label='aps', marker='o', lw=2)
20
- ax.plot(mergex, merge, c='#79796a', label='merge')
21
- # ax.plot(mergeox,mergeo,c='#111111',label='mergeo',marker='o',lw=.75)
19
+ ax.plot(smpsx, smps, c='#ff794c', label='smps', marker='o', lw=2)
20
+ ax.plot(apsx, aps, c='#4c79ff', label='aps', marker='o', lw=2)
21
+ ax.plot(mergex, merge, c='#79796a', label='merge')
22
+ # ax.plot(mergeox,mergeo,c='#111111',label='mergeo',marker='o',lw=.75)
22
23
 
23
- ax.set(xscale='log', yscale='log', )
24
+ ax.set(xscale='log', yscale='log', )
24
25
 
25
- ax.legend(framealpha=0, )
26
- ax.set_title((_sh ** 2)[0], fontsize=13)
26
+ ax.legend(framealpha=0, )
27
+ ax.set_title((_sh ** 2)[0], fontsize=13)
27
28
 
28
- show()
29
- close()
29
+ show()
30
+ close()
30
31
 
31
32
 
32
33
  # '''
@@ -36,78 +37,78 @@ def __test_plot(smpsx, smps, apsx, aps, mergex, merge, mergeox, mergeo, _sh):
36
37
  ## Create a fitting func. by smps data
37
38
  ## return : shift factor
38
39
  def _overlap_fitting(_smps_ori, _aps_ori, _smps_lb, _aps_hb):
39
- print(f"\t\t{dtm.now().strftime('%m/%d %X')} : \033[92moverlap range fitting\033[0m")
40
+ print(f"\t\t{dtm.now().strftime('%m/%d %X')} : \033[92moverlap range fitting\033[0m")
40
41
 
41
- ## overlap fitting
42
- ## parmeter
43
- _dt_indx = _smps_ori.index
42
+ ## overlap fitting
43
+ ## parmeter
44
+ _dt_indx = _smps_ori.index
44
45
 
45
- ## overlap diameter data
46
- _aps = _aps_ori[_aps_ori.keys()[_aps_ori.keys() < _aps_hb]].copy()
47
- _smps = _smps_ori[_smps_ori.keys()[_smps_ori.keys() > _smps_lb]].copy()
46
+ ## overlap diameter data
47
+ _aps = _aps_ori[_aps_ori.keys()[_aps_ori.keys() < _aps_hb]].copy()
48
+ _smps = _smps_ori[_smps_ori.keys()[_smps_ori.keys() > _smps_lb]].copy()
48
49
 
49
- ## use SMPS data apply power law fitting
50
- ## y = Ax^B, A = e**coefa, B = coefb, x = logx, y = logy
51
- ## ref : http://mathworld.wolfram.com/LeastSquaresFittingPowerLaw.html
52
- ## power law fit to SMPS num conc at upper bins to log curve
50
+ ## use SMPS data apply power law fitting
51
+ ## y = Ax^B, A = e**coefa, B = coefb, x = logx, y = logy
52
+ ## ref : http://mathworld.wolfram.com/LeastSquaresFittingPowerLaw.html
53
+ ## power law fit to SMPS num conc at upper bins to log curve
53
54
 
54
- ## coefficient A, B
55
- _smps_qc_cond = ((_smps != 0) & np.isfinite(_smps))
56
- _smps_qc = _smps.where(_smps_qc_cond)
55
+ ## coefficient A, B
56
+ _smps_qc_cond = ((_smps != 0) & np.isfinite(_smps))
57
+ _smps_qc = _smps.where(_smps_qc_cond)
57
58
 
58
- _size = _smps_qc_cond.sum(axis=1)
59
- _size = _size.where(_size != 0.).copy()
59
+ _size = _smps_qc_cond.sum(axis=1)
60
+ _size = _size.where(_size != 0.).copy()
60
61
 
61
- _logx, _logy = np.log(_smps_qc.keys()._data.astype(float)), np.log(_smps_qc)
62
- _x, _y, _xy, _xx = _logx.sum(), _logy.sum(axis=1), (_logx * _logy).sum(axis=1), (_logx ** 2).sum()
62
+ _logx, _logy = np.log(_smps_qc.keys()._data.astype(float)), np.log(_smps_qc)
63
+ _x, _y, _xy, _xx = _logx.sum(), _logy.sum(axis=1), (_logx * _logy).sum(axis=1), (_logx ** 2).sum()
63
64
 
64
- _coeB = ((_size * _xy - _x * _y) / (_size * _xx - _x ** 2.))
65
- _coeA = np.exp((_y - _coeB * _x) / _size).values.reshape(-1, 1)
66
- _coeB = _coeB.values.reshape(-1, 1)
65
+ _coeB = ((_size * _xy - _x * _y) / (_size * _xx - _x ** 2.))
66
+ _coeA = np.exp((_y - _coeB * _x) / _size).values.reshape(-1, 1)
67
+ _coeB = _coeB.values.reshape(-1, 1)
67
68
 
68
- ## rebuild shift smps data by coe. A, B
69
- ## x_shift = (y_ori/A)**(1/B)
70
- _aps_shift_x = (_aps / _coeA) ** (1 / _coeB)
71
- _aps_shift_x = _aps_shift_x.where(np.isfinite(_aps_shift_x))
69
+ ## rebuild shift smps data by coe. A, B
70
+ ## x_shift = (y_ori/A)**(1/B)
71
+ _aps_shift_x = (_aps / _coeA) ** (1 / _coeB)
72
+ _aps_shift_x = _aps_shift_x.where(np.isfinite(_aps_shift_x))
72
73
 
73
- ## the least squares of diameter
74
- ## the shift factor which the cklosest to 1
75
- _shift_factor = (_aps_shift_x.keys()._data.astype(float) / _aps_shift_x)
76
- _shift_factor.columns = range(len(_aps_shift_x.keys()))
74
+ ## the least squares of diameter
75
+ ## the shift factor which the cklosest to 1
76
+ _shift_factor = (_aps_shift_x.keys()._data.astype(float) / _aps_shift_x)
77
+ _shift_factor.columns = range(len(_aps_shift_x.keys()))
77
78
 
78
- _dropna_idx = _shift_factor.dropna(how='all').index.copy()
79
+ _dropna_idx = _shift_factor.dropna(how='all').index.copy()
79
80
 
80
- ## use the target function to get the similar aps and smps bin
81
- ## S2 = sum( (smps_fit_line(dia) - aps(dia*shift_factor) )**2 )
82
- ## assumption : the same diameter between smps and aps should get the same conc.
81
+ ## use the target function to get the similar aps and smps bin
82
+ ## S2 = sum( (smps_fit_line(dia) - aps(dia*shift_factor) )**2 )
83
+ ## assumption : the same diameter between smps and aps should get the same conc.
83
84
 
84
- ## be sure they art in log value
85
- _S2 = DataFrame(index=_aps_shift_x.index)
86
- _dia_table = DataFrame(np.full(_aps_shift_x.shape, _aps_shift_x.keys()),
87
- columns=_aps_shift_x.keys(), index=_aps_shift_x.index)
88
- for _idx, _factor in _shift_factor.items():
89
- _smps_fit_df = _coeA * (_dia_table / _factor.to_frame().values) ** _coeB
90
- _S2[_idx] = ((_smps_fit_df - _aps) ** 2).sum(axis=1)
85
+ ## be sure they art in log value
86
+ _S2 = DataFrame(index=_aps_shift_x.index)
87
+ _dia_table = DataFrame(np.full(_aps_shift_x.shape, _aps_shift_x.keys()),
88
+ columns=_aps_shift_x.keys(), index=_aps_shift_x.index)
89
+ for _idx, _factor in _shift_factor.items():
90
+ _smps_fit_df = _coeA * (_dia_table / _factor.to_frame().values) ** _coeB
91
+ _S2[_idx] = ((_smps_fit_df - _aps) ** 2).sum(axis=1)
91
92
 
92
- _least_squ_idx = _S2.idxmin(axis=1).loc[_dropna_idx]
93
+ _least_squ_idx = _S2.idxmin(axis=1).loc[_dropna_idx]
93
94
 
94
- _shift_factor_out = DataFrame(_shift_factor.loc[_dropna_idx].values[range(len(_dropna_idx)), _least_squ_idx.values],
95
- index=_dropna_idx).reindex(_dt_indx)
95
+ _shift_factor_out = DataFrame(_shift_factor.loc[_dropna_idx].values[range(len(_dropna_idx)), _least_squ_idx.values],
96
+ index=_dropna_idx).reindex(_dt_indx)
96
97
 
97
- return _shift_factor_out, (DataFrame(_coeA, index=_dt_indx), DataFrame(_coeB, index=_dt_indx))
98
+ return _shift_factor_out, (DataFrame(_coeA, index=_dt_indx), DataFrame(_coeB, index=_dt_indx))
98
99
 
99
100
 
100
101
  ## Remove big shift data ()
101
102
  ## Return : aps, smps, shift (without big shift data)
102
103
  def _shift_data_process(_shift):
103
- print(f"\t\t{dtm.now().strftime('%m/%d %X')} : \033[92mshift-data quality control\033[0m")
104
+ print(f"\t\t{dtm.now().strftime('%m/%d %X')} : \033[92mshift-data quality control\033[0m")
104
105
 
105
- _rho = _shift ** 2
106
- _shift = _shift.mask((~np.isfinite(_shift)) | (_rho > 2) | (_rho < 0.3))
106
+ _rho = _shift ** 2
107
+ _shift = _shift.mask((~np.isfinite(_shift)) | (_rho > 2) | (_rho < 0.3))
107
108
 
108
- _qc_index = _shift.mask((_rho < 0.6) | (_shift.isna())).dropna().index
109
+ _qc_index = _shift.mask((_rho < 0.6) | (_shift.isna())).dropna().index
109
110
 
110
- return _qc_index, _shift
111
+ return _qc_index, _shift
111
112
 
112
113
 
113
114
  # return _smps.loc[~_big_shift], _aps.loc[~_big_shift], _shift[~_big_shift].reshape(-1,1)
@@ -117,134 +118,134 @@ def _shift_data_process(_shift):
117
118
  ## shift all smps bin and remove the aps bin which smaller than the latest old smps bin
118
119
  ## Return : merge bins, merge data, density
119
120
  def _merge_data(_smps_ori, _aps_ori, _shift_ori, _shift_mode, _smps_lb, _aps_hb, _coe):
120
- print(f"\t\t{dtm.now().strftime('%m/%d %X')} : \033[92mcreate merge data\033[0m")
121
+ print(f"\t\t{dtm.now().strftime('%m/%d %X')} : \033[92mcreate merge data\033[0m")
121
122
 
122
- _ori_idx = _smps_ori.index
123
- _merge_idx = _smps_ori.loc[_aps_ori.dropna(how='all').index].dropna(how='all').index
123
+ _ori_idx = _smps_ori.index
124
+ _merge_idx = _smps_ori.loc[_aps_ori.dropna(how='all').index].dropna(how='all').index
124
125
 
125
- _uni_idx, _count = np.unique(np.hstack((_smps_ori.dropna(how='all').index, _aps_ori.dropna(how='all').index,
126
- _shift_ori.dropna(how='all').index)), return_counts=True)
126
+ _uni_idx, _count = np.unique(np.hstack((_smps_ori.dropna(how='all').index, _aps_ori.dropna(how='all').index,
127
+ _shift_ori.dropna(how='all').index)), return_counts=True)
127
128
 
128
- _merge_idx = to_datetime(np.unique(_uni_idx[_count == 3]))
129
+ _merge_idx = to_datetime(np.unique(_uni_idx[_count == 3]))
129
130
 
130
- _smps, _aps, _shift = _smps_ori.loc[_merge_idx], _aps_ori.loc[_merge_idx], _shift_ori.loc[_merge_idx].values
131
+ _smps, _aps, _shift = _smps_ori.loc[_merge_idx], _aps_ori.loc[_merge_idx], _shift_ori.loc[_merge_idx].values
131
132
 
132
- ## parameter
133
- _coeA, _coeB = _coe[0].loc[_merge_idx], _coe[1].loc[_merge_idx]
134
- _smps_key, _aps_key = _smps.keys()._data.astype(float), _aps.keys()._data.astype(float)
133
+ ## parameter
134
+ _coeA, _coeB = _coe[0].loc[_merge_idx], _coe[1].loc[_merge_idx]
135
+ _smps_key, _aps_key = _smps.keys()._data.astype(float), _aps.keys()._data.astype(float)
135
136
 
136
- _test = 1000
137
+ _test = 1000
137
138
 
138
- # _cntr = (_smps_lb+_aps_hb)/2
139
- _cntr = _test
140
- _bin_lb = _smps_key[-1]
139
+ # _cntr = (_smps_lb+_aps_hb)/2
140
+ _cntr = _test
141
+ _bin_lb = _smps_key[-1]
141
142
 
142
- ## make shift bins
143
- _smps_bin = np.full(_smps.shape, _smps_key)
144
- _aps_bin = np.full(_aps.shape, _aps_key)
145
- # _std_bin = _smps_key.tolist()+_aps_key[_aps_key>_smps_key[-1]].tolist()
146
- _std_bin = np.geomspace(_smps_key[0], _aps_key[-1], 230)
147
- _std_bin_merge = _std_bin[(_std_bin < _cntr) & (_std_bin > _bin_lb)]
148
- _std_bin_inte1 = _std_bin[_std_bin <= _bin_lb]
149
- _std_bin_inte2 = _std_bin[_std_bin >= _cntr]
143
+ ## make shift bins
144
+ _smps_bin = np.full(_smps.shape, _smps_key)
145
+ _aps_bin = np.full(_aps.shape, _aps_key)
146
+ # _std_bin = _smps_key.tolist()+_aps_key[_aps_key>_smps_key[-1]].tolist()
147
+ _std_bin = np.geomspace(_smps_key[0], _aps_key[-1], 230)
148
+ _std_bin_merge = _std_bin[(_std_bin < _cntr) & (_std_bin > _bin_lb)]
149
+ _std_bin_inte1 = _std_bin[_std_bin <= _bin_lb]
150
+ _std_bin_inte2 = _std_bin[_std_bin >= _cntr]
150
151
 
151
- if _shift_mode == 'mobility':
152
- _aps_bin /= _shift
152
+ if _shift_mode == 'mobility':
153
+ _aps_bin /= _shift
153
154
 
154
- elif _shift_mode == 'aerodynamic':
155
- _smps_bin *= _shift
155
+ elif _shift_mode == 'aerodynamic':
156
+ _smps_bin *= _shift
156
157
 
157
- ## merge
158
- _merge_lst = []
159
- for _bin_smps, _bin_aps, _dt_smps, _dt_aps, _sh in zip(_smps_bin, _aps_bin, _smps.values, _aps.values, _shift):
160
- ## remove
158
+ ## merge
159
+ _merge_lst = []
160
+ for _bin_smps, _bin_aps, _dt_smps, _dt_aps, _sh in zip(_smps_bin, _aps_bin, _smps.values, _aps.values, _shift):
161
+ ## remove
161
162
 
162
- ## keep complete smps bins and data
163
- ## remove the aps bin data lower than smps bin
164
- _condi = _bin_aps >= _bin_smps[-1]
163
+ ## keep complete smps bins and data
164
+ ## remove the aps bin data lower than smps bin
165
+ _condi = _bin_aps >= _bin_smps[-1]
165
166
 
166
- _merge_bin = np.hstack((_bin_smps, _bin_aps[_condi]))
167
- _merge_dt = np.hstack((_dt_smps, _dt_aps[_condi]))
167
+ _merge_bin = np.hstack((_bin_smps, _bin_aps[_condi]))
168
+ _merge_dt = np.hstack((_dt_smps, _dt_aps[_condi]))
168
169
 
169
- # _merge_fit_loc = (_merge_bin<_aps_hb)&(_merge_bin>_smps_lb)
170
- _merge_fit_loc = (_merge_bin < 1500) & (_merge_bin > _smps_lb)
170
+ # _merge_fit_loc = (_merge_bin<_aps_hb)&(_merge_bin>_smps_lb)
171
+ _merge_fit_loc = (_merge_bin < 1500) & (_merge_bin > _smps_lb)
171
172
 
172
- ## coeA and coeB
173
- _unvpl_fc = unvpline(np.log(_merge_bin[_merge_fit_loc]), np.log(_merge_dt[_merge_fit_loc]), s=50)
174
- # _unvpl_fc = unvpline(_merge_bin[_merge_fit_loc],_merge_dt[_merge_fit_loc],s=150)
175
- # _inte_log_fc = interp1d(n.log10(_merge_bin[_merge_fit_loc]),n.log10(_merge_dt[_merge_fit_loc]),
176
- # kind='linear',fill_value='extrapolate')
177
- _inte_fc = interp1d(_merge_bin, _merge_dt, kind='linear', fill_value='extrapolate')
173
+ ## coeA and coeB
174
+ _unvpl_fc = unvpline(np.log(_merge_bin[_merge_fit_loc]), np.log(_merge_dt[_merge_fit_loc]), s=50)
175
+ # _unvpl_fc = unvpline(_merge_bin[_merge_fit_loc],_merge_dt[_merge_fit_loc],s=150)
176
+ # _inte_log_fc = interp1d(n.log10(_merge_bin[_merge_fit_loc]),n.log10(_merge_dt[_merge_fit_loc]),
177
+ # kind='linear',fill_value='extrapolate')
178
+ _inte_fc = interp1d(_merge_bin, _merge_dt, kind='linear', fill_value='extrapolate')
178
179
 
179
- __merge = np.exp(_unvpl_fc(np.log(_std_bin_merge)))
180
- # __merge = _unvpl_fc(_std_bin_merge)
180
+ __merge = np.exp(_unvpl_fc(np.log(_std_bin_merge)))
181
+ # __merge = _unvpl_fc(_std_bin_merge)
181
182
 
182
- _merge_dt_fit = np.hstack((_inte_fc(_std_bin_inte1), __merge, _inte_fc(_std_bin_inte2)))
183
- # _merge_dt_fit = __merge
184
- # __test_plot(_bin_smps,_dt_smps,_bin_aps,_dt_aps,_std_bin,_merge_dt_fit,_merge_bin,_merge_dt,_sh)
183
+ _merge_dt_fit = np.hstack((_inte_fc(_std_bin_inte1), __merge, _inte_fc(_std_bin_inte2)))
184
+ # _merge_dt_fit = __merge
185
+ # __test_plot(_bin_smps,_dt_smps,_bin_aps,_dt_aps,_std_bin,_merge_dt_fit,_merge_bin,_merge_dt,_sh)
185
186
 
186
- _merge_lst.append(_merge_dt_fit)
187
+ _merge_lst.append(_merge_dt_fit)
187
188
 
188
- _df_merge = DataFrame(_merge_lst, columns=_std_bin, index=_merge_idx)
189
- _df_merge = _df_merge.mask(_df_merge < 0)
189
+ _df_merge = DataFrame(_merge_lst, columns=_std_bin, index=_merge_idx)
190
+ _df_merge = _df_merge.mask(_df_merge < 0)
190
191
 
191
- ## process output df
192
- ## average, align with index
193
- def _out_df(*_df_arg, **_df_kwarg):
194
- _df = DataFrame(*_df_arg, **_df_kwarg).reindex(_ori_idx)
195
- _df.index.name = 'time'
196
- return _df
192
+ ## process output df
193
+ ## average, align with index
194
+ def _out_df(*_df_arg, **_df_kwarg):
195
+ _df = DataFrame(*_df_arg, **_df_kwarg).reindex(_ori_idx)
196
+ _df.index.name = 'time'
197
+ return _df
197
198
 
198
- return _out_df(_df_merge), _out_df(_shift_ori ** 2)
199
+ return _out_df(_df_merge), _out_df(_shift_ori ** 2)
199
200
 
200
201
 
201
202
  ## aps_fit_highbound : the diameter I choose randomly
202
203
  def _merge_SMPS_APS(df_smps, df_aps, aps_unit, shift_mode, smps_overlap_lowbound, aps_fit_highbound):
203
- # print(f'\nMerge data :')
204
- # print(f' APS fittint higher diameter : {aps_fit_highbound:4d} nm')
205
- # print(f' SMPS overlap lower diameter : {smps_overlap_lowbound:4d} nm')
206
- # print(f' Average time : {self.data_freq:>4s}\n')
204
+ # print(f'\nMerge data :')
205
+ # print(f' APS fittint higher diameter : {aps_fit_highbound:4d} nm')
206
+ # print(f' SMPS overlap lower diameter : {smps_overlap_lowbound:4d} nm')
207
+ # print(f' Average time : {self.data_freq:>4s}\n')
207
208
 
208
- ## get data, remove 'total' and 'mode'
209
- ## set to the same units
210
- smps, aps = df_smps, df_aps
211
- smps.columns = smps.keys().to_numpy(float)
212
- aps.columns = aps.keys().to_numpy(float)
209
+ ## get data, remove 'total' and 'mode'
210
+ ## set to the same units
211
+ smps, aps = df_smps, df_aps
212
+ smps.columns = smps.keys().to_numpy(float)
213
+ aps.columns = aps.keys().to_numpy(float)
213
214
 
214
- if aps_unit == 'um':
215
- aps.columns = aps.keys() * 1e3
215
+ if aps_unit == 'um':
216
+ aps.columns = aps.keys() * 1e3
216
217
 
217
- ## shift infomation, calculate by powerlaw fitting
218
- shift, coe = _overlap_fitting(smps, aps, smps_overlap_lowbound, aps_fit_highbound)
218
+ ## shift infomation, calculate by powerlaw fitting
219
+ shift, coe = _overlap_fitting(smps, aps, smps_overlap_lowbound, aps_fit_highbound)
219
220
 
220
- ## process data by shift infomation, and average data
221
- qc_cond, shift = _shift_data_process(shift)
221
+ ## process data by shift infomation, and average data
222
+ qc_cond, shift = _shift_data_process(shift)
222
223
 
223
- ## merge aps and smps..
224
- merge_data, density = _merge_data(smps, aps, shift, shift_mode, smps_overlap_lowbound, aps_fit_highbound, coe)
225
- density.columns = ['density']
224
+ ## merge aps and smps..
225
+ merge_data, density = _merge_data(smps, aps, shift, shift_mode, smps_overlap_lowbound, aps_fit_highbound, coe)
226
+ density.columns = ['density']
226
227
 
227
- ## add total and mode
228
- # merge_total = merge_data.sum(axis=1,min_count=1).copy()
229
- # merge_mode = merge_data.idxmax(axis=1).astype(float).copy()
228
+ ## add total and mode
229
+ # merge_total = merge_data.sum(axis=1,min_count=1).copy()
230
+ # merge_mode = merge_data.idxmax(axis=1).astype(float).copy()
230
231
 
231
- # merge_data['total'] = merge_total
232
- # merge_data['mode'] = merge_mode
232
+ # merge_data['total'] = merge_total
233
+ # merge_data['mode'] = merge_mode
233
234
 
234
- ## out
235
- out_dic = {
236
- 'data_all': merge_data,
237
- 'data_qc': merge_data.loc[qc_cond],
238
- 'density_all': density,
239
- 'density_qc': density.loc[qc_cond],
240
- }
235
+ ## out
236
+ out_dic = {
237
+ 'data_all': merge_data,
238
+ 'data_qc': merge_data.loc[qc_cond],
239
+ 'density_all': density,
240
+ 'density_qc': density.loc[qc_cond],
241
+ }
241
242
 
242
- ## process data
243
+ ## process data
243
244
 
244
- for _nam, _df in out_dic.items():
245
- out_dic[_nam] = _df.reindex(df_aps.index).copy()
245
+ for _nam, _df in out_dic.items():
246
+ out_dic[_nam] = _df.reindex(df_aps.index).copy()
246
247
 
247
- # merge_data = merge_data.reindex(df_aps.index)
248
- # density = density.reindex(df_aps.index)
248
+ # merge_data = merge_data.reindex(df_aps.index)
249
+ # density = density.reindex(df_aps.index)
249
250
 
250
- return out_dic
251
+ return out_dic