AeroViz 0.1.4__tar.gz → 0.1.5__tar.gz

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 (124) hide show
  1. {aeroviz-0.1.4 → aeroviz-0.1.5}/AeroViz/dataProcess/Chemistry/__init__.py +21 -20
  2. {aeroviz-0.1.4 → aeroviz-0.1.5}/AeroViz/dataProcess/Chemistry/_isoropia.py +9 -12
  3. {aeroviz-0.1.4 → aeroviz-0.1.5}/AeroViz/dataProcess/Chemistry/_ocec.py +20 -45
  4. aeroviz-0.1.5/AeroViz/dataProcess/Chemistry/isrpia2.exe +0 -0
  5. aeroviz-0.1.5/AeroViz/dataProcess/Optical/fRH.pkl +0 -0
  6. {aeroviz-0.1.4 → aeroviz-0.1.5}/AeroViz/dataProcess/VOC/__init__.py +1 -6
  7. aeroviz-0.1.5/AeroViz/dataProcess/VOC/_potential_par.py +108 -0
  8. aeroviz-0.1.4/AeroViz/dataProcess/VOC/voc_par.json → aeroviz-0.1.5/AeroViz/dataProcess/VOC/support_voc.json +321 -339
  9. aeroviz-0.1.5/AeroViz/rawDataReader/__init__.py +112 -0
  10. {aeroviz-0.1.4 → aeroviz-0.1.5}/AeroViz/rawDataReader/config/supported_instruments.py +15 -22
  11. {aeroviz-0.1.4 → aeroviz-0.1.5}/AeroViz/rawDataReader/core/__init__.py +25 -15
  12. {aeroviz-0.1.4 → aeroviz-0.1.5}/AeroViz/rawDataReader/script/AE33.py +3 -3
  13. {aeroviz-0.1.4 → aeroviz-0.1.5}/AeroViz/rawDataReader/script/AE43.py +2 -2
  14. {aeroviz-0.1.4 → aeroviz-0.1.5}/AeroViz/rawDataReader/script/APS_3321.py +2 -2
  15. {aeroviz-0.1.4 → aeroviz-0.1.5}/AeroViz/rawDataReader/script/Aurora.py +5 -2
  16. {aeroviz-0.1.4 → aeroviz-0.1.5}/AeroViz/rawDataReader/script/BC1054.py +2 -2
  17. {aeroviz-0.1.4 → aeroviz-0.1.5}/AeroViz/rawDataReader/script/EPA_vertical.py +2 -2
  18. {aeroviz-0.1.4 → aeroviz-0.1.5}/AeroViz/rawDataReader/script/GRIMM.py +4 -4
  19. {aeroviz-0.1.4 → aeroviz-0.1.5}/AeroViz/rawDataReader/script/IGAC.py +2 -2
  20. {aeroviz-0.1.4 → aeroviz-0.1.5}/AeroViz/rawDataReader/script/MA350.py +2 -2
  21. {aeroviz-0.1.4 → aeroviz-0.1.5}/AeroViz/rawDataReader/script/Minion.py +2 -2
  22. {aeroviz-0.1.4 → aeroviz-0.1.5}/AeroViz/rawDataReader/script/NEPH.py +9 -14
  23. {aeroviz-0.1.4 → aeroviz-0.1.5}/AeroViz/rawDataReader/script/SMPS_TH.py +2 -2
  24. {aeroviz-0.1.4 → aeroviz-0.1.5}/AeroViz/rawDataReader/script/SMPS_aim11.py +2 -2
  25. {aeroviz-0.1.4 → aeroviz-0.1.5}/AeroViz/rawDataReader/script/SMPS_genr.py +2 -2
  26. {aeroviz-0.1.4 → aeroviz-0.1.5}/AeroViz/rawDataReader/script/Sunset_OCEC.py +23 -17
  27. {aeroviz-0.1.4 → aeroviz-0.1.5}/AeroViz/rawDataReader/script/TEOM.py +2 -2
  28. {aeroviz-0.1.4 → aeroviz-0.1.5}/AeroViz/rawDataReader/script/Table.py +3 -3
  29. aeroviz-0.1.5/AeroViz/rawDataReader/script/VOC.py +33 -0
  30. {aeroviz-0.1.4 → aeroviz-0.1.5}/AeroViz.egg-info/PKG-INFO +1 -1
  31. {aeroviz-0.1.4 → aeroviz-0.1.5}/AeroViz.egg-info/SOURCES.txt +3 -1
  32. {aeroviz-0.1.4 → aeroviz-0.1.5}/MANIFEST.in +4 -0
  33. {aeroviz-0.1.4 → aeroviz-0.1.5}/PKG-INFO +1 -1
  34. {aeroviz-0.1.4 → aeroviz-0.1.5}/setup.py +1 -1
  35. aeroviz-0.1.4/AeroViz/dataProcess/VOC/_potential_par.py +0 -74
  36. aeroviz-0.1.4/AeroViz/rawDataReader/__init__.py +0 -63
  37. aeroviz-0.1.4/AeroViz/rawDataReader/script/VOC.py +0 -26
  38. {aeroviz-0.1.4 → aeroviz-0.1.5}/AeroViz/__init__.py +0 -0
  39. {aeroviz-0.1.4 → aeroviz-0.1.5}/AeroViz/data/DEFAULT_DATA.csv +0 -0
  40. {aeroviz-0.1.4 → aeroviz-0.1.5}/AeroViz/data/DEFAULT_PNSD_DATA.csv +0 -0
  41. {aeroviz-0.1.4 → aeroviz-0.1.5}/AeroViz/dataProcess/Chemistry/_calculate.py +0 -0
  42. {aeroviz-0.1.4 → aeroviz-0.1.5}/AeroViz/dataProcess/Chemistry/_mass_volume.py +0 -0
  43. {aeroviz-0.1.4 → aeroviz-0.1.5}/AeroViz/dataProcess/Chemistry/_partition.py +0 -0
  44. {aeroviz-0.1.4 → aeroviz-0.1.5}/AeroViz/dataProcess/Chemistry/_teom.py +0 -0
  45. {aeroviz-0.1.4 → aeroviz-0.1.5}/AeroViz/dataProcess/Chemistry/isrpia.cnf +0 -0
  46. {aeroviz-0.1.4 → aeroviz-0.1.5}/AeroViz/dataProcess/Optical/Angstrom_exponent.py +0 -0
  47. {aeroviz-0.1.4 → aeroviz-0.1.5}/AeroViz/dataProcess/Optical/_IMPROVE.py +0 -0
  48. {aeroviz-0.1.4 → aeroviz-0.1.5}/AeroViz/dataProcess/Optical/__init__.py +0 -0
  49. {aeroviz-0.1.4 → aeroviz-0.1.5}/AeroViz/dataProcess/Optical/_absorption.py +0 -0
  50. {aeroviz-0.1.4 → aeroviz-0.1.5}/AeroViz/dataProcess/Optical/_extinction.py +0 -0
  51. {aeroviz-0.1.4 → aeroviz-0.1.5}/AeroViz/dataProcess/Optical/_mie.py +0 -0
  52. {aeroviz-0.1.4 → aeroviz-0.1.5}/AeroViz/dataProcess/Optical/_mie_sd.py +0 -0
  53. {aeroviz-0.1.4 → aeroviz-0.1.5}/AeroViz/dataProcess/Optical/_scattering.py +0 -0
  54. {aeroviz-0.1.4 → aeroviz-0.1.5}/AeroViz/dataProcess/SizeDistr/__init__.py +0 -0
  55. {aeroviz-0.1.4 → aeroviz-0.1.5}/AeroViz/dataProcess/SizeDistr/__merge.py +0 -0
  56. {aeroviz-0.1.4 → aeroviz-0.1.5}/AeroViz/dataProcess/SizeDistr/_merge.py +0 -0
  57. {aeroviz-0.1.4 → aeroviz-0.1.5}/AeroViz/dataProcess/SizeDistr/_merge_v1.py +0 -0
  58. {aeroviz-0.1.4 → aeroviz-0.1.5}/AeroViz/dataProcess/SizeDistr/_merge_v2.py +0 -0
  59. {aeroviz-0.1.4 → aeroviz-0.1.5}/AeroViz/dataProcess/SizeDistr/_merge_v3.py +0 -0
  60. {aeroviz-0.1.4 → aeroviz-0.1.5}/AeroViz/dataProcess/SizeDistr/_merge_v4.py +0 -0
  61. {aeroviz-0.1.4 → aeroviz-0.1.5}/AeroViz/dataProcess/SizeDistr/_size_distr.py +0 -0
  62. {aeroviz-0.1.4 → aeroviz-0.1.5}/AeroViz/dataProcess/__init__.py +0 -0
  63. {aeroviz-0.1.4 → aeroviz-0.1.5}/AeroViz/dataProcess/core/__init__.py +0 -0
  64. {aeroviz-0.1.4 → aeroviz-0.1.5}/AeroViz/plot/__init__.py +0 -0
  65. {aeroviz-0.1.4 → aeroviz-0.1.5}/AeroViz/plot/bar.py +0 -0
  66. {aeroviz-0.1.4 → aeroviz-0.1.5}/AeroViz/plot/box.py +0 -0
  67. {aeroviz-0.1.4 → aeroviz-0.1.5}/AeroViz/plot/distribution/__init__.py +0 -0
  68. {aeroviz-0.1.4 → aeroviz-0.1.5}/AeroViz/plot/distribution/distribution.py +0 -0
  69. {aeroviz-0.1.4 → aeroviz-0.1.5}/AeroViz/plot/meteorology/__init__.py +0 -0
  70. {aeroviz-0.1.4 → aeroviz-0.1.5}/AeroViz/plot/meteorology/meteorology.py +0 -0
  71. {aeroviz-0.1.4 → aeroviz-0.1.5}/AeroViz/plot/optical/__init__.py +0 -0
  72. {aeroviz-0.1.4 → aeroviz-0.1.5}/AeroViz/plot/optical/optical.py +0 -0
  73. {aeroviz-0.1.4 → aeroviz-0.1.5}/AeroViz/plot/pie.py +0 -0
  74. {aeroviz-0.1.4 → aeroviz-0.1.5}/AeroViz/plot/regression.py +0 -0
  75. {aeroviz-0.1.4 → aeroviz-0.1.5}/AeroViz/plot/scatter.py +0 -0
  76. {aeroviz-0.1.4 → aeroviz-0.1.5}/AeroViz/plot/templates/__init__.py +0 -0
  77. {aeroviz-0.1.4 → aeroviz-0.1.5}/AeroViz/plot/templates/ammonium_rich.py +0 -0
  78. {aeroviz-0.1.4 → aeroviz-0.1.5}/AeroViz/plot/templates/contour.py +0 -0
  79. {aeroviz-0.1.4 → aeroviz-0.1.5}/AeroViz/plot/templates/corr_matrix.py +0 -0
  80. {aeroviz-0.1.4 → aeroviz-0.1.5}/AeroViz/plot/templates/diurnal_pattern.py +0 -0
  81. {aeroviz-0.1.4 → aeroviz-0.1.5}/AeroViz/plot/templates/koschmieder.py +0 -0
  82. {aeroviz-0.1.4 → aeroviz-0.1.5}/AeroViz/plot/templates/metal_heatmap.py +0 -0
  83. {aeroviz-0.1.4 → aeroviz-0.1.5}/AeroViz/plot/timeseries/__init__.py +0 -0
  84. {aeroviz-0.1.4 → aeroviz-0.1.5}/AeroViz/plot/timeseries/template.py +0 -0
  85. {aeroviz-0.1.4 → aeroviz-0.1.5}/AeroViz/plot/timeseries/timeseries.py +0 -0
  86. {aeroviz-0.1.4 → aeroviz-0.1.5}/AeroViz/plot/utils/__init__.py +0 -0
  87. {aeroviz-0.1.4 → aeroviz-0.1.5}/AeroViz/plot/utils/_color.py +0 -0
  88. {aeroviz-0.1.4 → aeroviz-0.1.5}/AeroViz/plot/utils/_unit.py +0 -0
  89. {aeroviz-0.1.4 → aeroviz-0.1.5}/AeroViz/plot/utils/fRH.json +0 -0
  90. {aeroviz-0.1.4 → aeroviz-0.1.5}/AeroViz/plot/utils/plt_utils.py +0 -0
  91. {aeroviz-0.1.4 → aeroviz-0.1.5}/AeroViz/plot/utils/sklearn_utils.py +0 -0
  92. {aeroviz-0.1.4 → aeroviz-0.1.5}/AeroViz/plot/utils/units.json +0 -0
  93. {aeroviz-0.1.4 → aeroviz-0.1.5}/AeroViz/plot/violin.py +0 -0
  94. {aeroviz-0.1.4 → aeroviz-0.1.5}/AeroViz/process/__init__.py +0 -0
  95. {aeroviz-0.1.4 → aeroviz-0.1.5}/AeroViz/process/core/DataProc.py +0 -0
  96. {aeroviz-0.1.4 → aeroviz-0.1.5}/AeroViz/process/core/SizeDist.py +0 -0
  97. {aeroviz-0.1.4 → aeroviz-0.1.5}/AeroViz/process/core/__init__.py +0 -0
  98. {aeroviz-0.1.4 → aeroviz-0.1.5}/AeroViz/process/method/PyMieScatt_update.py +0 -0
  99. {aeroviz-0.1.4 → aeroviz-0.1.5}/AeroViz/process/method/__init__.py +0 -0
  100. {aeroviz-0.1.4 → aeroviz-0.1.5}/AeroViz/process/method/mie_theory.py +0 -0
  101. {aeroviz-0.1.4 → aeroviz-0.1.5}/AeroViz/process/method/prop.py +0 -0
  102. {aeroviz-0.1.4 → aeroviz-0.1.5}/AeroViz/process/script/AbstractDistCalc.py +0 -0
  103. {aeroviz-0.1.4 → aeroviz-0.1.5}/AeroViz/process/script/Chemical.py +0 -0
  104. {aeroviz-0.1.4 → aeroviz-0.1.5}/AeroViz/process/script/IMPACT.py +0 -0
  105. {aeroviz-0.1.4 → aeroviz-0.1.5}/AeroViz/process/script/IMPROVE.py +0 -0
  106. {aeroviz-0.1.4 → aeroviz-0.1.5}/AeroViz/process/script/Others.py +0 -0
  107. {aeroviz-0.1.4 → aeroviz-0.1.5}/AeroViz/process/script/PSD.py +0 -0
  108. {aeroviz-0.1.4 → aeroviz-0.1.5}/AeroViz/process/script/PSD_dry.py +0 -0
  109. {aeroviz-0.1.4 → aeroviz-0.1.5}/AeroViz/process/script/__init__.py +0 -0
  110. {aeroviz-0.1.4 → aeroviz-0.1.5}/AeroViz/process/script/retrieve_RI.py +0 -0
  111. {aeroviz-0.1.4 → aeroviz-0.1.5}/AeroViz/rawDataReader/config/__init__.py +0 -0
  112. {aeroviz-0.1.4 → aeroviz-0.1.5}/AeroViz/rawDataReader/script/__init__.py +0 -0
  113. {aeroviz-0.1.4 → aeroviz-0.1.5}/AeroViz/tools/__init__.py +0 -0
  114. {aeroviz-0.1.4 → aeroviz-0.1.5}/AeroViz/tools/database.py +0 -0
  115. {aeroviz-0.1.4 → aeroviz-0.1.5}/AeroViz/tools/dataclassifier.py +0 -0
  116. {aeroviz-0.1.4 → aeroviz-0.1.5}/AeroViz/tools/dataprinter.py +0 -0
  117. {aeroviz-0.1.4 → aeroviz-0.1.5}/AeroViz/tools/datareader.py +0 -0
  118. {aeroviz-0.1.4 → aeroviz-0.1.5}/AeroViz.egg-info/dependency_links.txt +0 -0
  119. {aeroviz-0.1.4 → aeroviz-0.1.5}/AeroViz.egg-info/requires.txt +0 -0
  120. {aeroviz-0.1.4 → aeroviz-0.1.5}/AeroViz.egg-info/top_level.txt +0 -0
  121. {aeroviz-0.1.4 → aeroviz-0.1.5}/LICENSE +0 -0
  122. {aeroviz-0.1.4 → aeroviz-0.1.5}/README.md +0 -0
  123. {aeroviz-0.1.4 → aeroviz-0.1.5}/requirements.txt +0 -0
  124. {aeroviz-0.1.4 → aeroviz-0.1.5}/setup.cfg +0 -0
@@ -1,40 +1,42 @@
1
1
  from ..core import Writer, run_process
2
2
 
3
- __all__ = [
4
-
5
- 'Chemistry',
6
-
7
- ]
3
+ __all__ = ['Chemistry']
8
4
 
9
5
 
10
6
  class Chemistry(Writer):
11
-
12
- ## Reconstruction
7
+ # Reconstruction
13
8
  @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']):
9
+ def ReConstrc_basic(self, *df_chem, df_ref=None, df_water=None, df_density=None, nam_lst=None):
16
10
  from ._mass_volume import _basic
17
11
 
12
+ if nam_lst is None:
13
+ nam_lst = ['NH4+', 'SO42-', 'NO3-', 'Fe', 'Na+', 'OC', 'EC']
14
+
18
15
  out = _basic(df_chem, df_ref, df_water, df_density, nam_lst=nam_lst)
19
16
 
20
17
  return self, out
21
18
 
22
- ## Partition
19
+ # Partition
23
20
  @run_process('Chemistry - Partition', 'partition')
24
- def Partition(self, *df_chem, nam_lst=['NH4+', 'SO42-', 'NO3-', 'Cl-', 'NO2', 'HNO3', 'SO2', 'NH3', 'HCl', 'temp']):
21
+ def Partition(self, *df_chem, nam_lst=None):
25
22
  from ._partition import _basic
26
23
 
24
+ if nam_lst is None:
25
+ nam_lst = ['NH4+', 'SO42-', 'NO3-', 'Cl-', 'NO2', 'HNO3', 'SO2', 'NH3', 'HCl', 'temp']
26
+
27
27
  out = _basic(df_chem, nam_lst=nam_lst)
28
28
 
29
29
  return self, out
30
30
 
31
- ## ISOROPIA
31
+ # ISOROPIA
32
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']):
33
+ def ISOROPIA(self, *df_chem, nam_lst=None):
36
34
  from ._isoropia import _basic
37
35
 
36
+ if nam_lst is None:
37
+ nam_lst = ['Na+', 'SO42-', 'NH4+', 'NO3-', 'Cl-', 'Ca2+',
38
+ 'K+', 'Mg2+', 'NH3', 'HNO3', 'HCl', 'RH', 'temp']
39
+
38
40
  if self.path_out is None:
39
41
  raise ValueError('Please Input "path_out" !!')
40
42
 
@@ -42,18 +44,17 @@ class Chemistry(Writer):
42
44
 
43
45
  return self, out
44
46
 
45
- ## OCEC
47
+ # OCEC
46
48
  @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,
49
+ def OCEC_basic(self, df_lcres, df_mass=None, ocec_ratio=None, ocec_ratio_month=1, hr_lim=200,
48
50
  least_square_range=(0.1, 2.5, 0.1), WISOC_OC_range=(0.2, 0.7, 0.01), ):
49
51
  from ._ocec import _basic
50
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
+ out = _basic(df_lcres, df_mass, ocec_ratio, ocec_ratio_month, hr_lim, least_square_range, WISOC_OC_range)
53
54
 
54
55
  return self, out
55
56
 
56
- ## TEOM
57
+ # TEOM
57
58
  @run_process('Chemistry - TEOM basic', 'teom_basic')
58
59
  def TEOM_basic(self, df_teom, df_check=None):
59
60
  from ._teom import _basic
@@ -7,9 +7,6 @@ from pandas import concat, DataFrame, to_numeric, read_csv
7
7
  from ._calculate import _ug2umol
8
8
 
9
9
 
10
- # TODO: fix isoropia2.exe can not run
11
-
12
-
13
10
  def _basic(df_che, path_out, nam_lst):
14
11
  # parameter
15
12
  df_all = concat(df_che, axis=1)
@@ -18,8 +15,8 @@ def _basic(df_che, path_out, nam_lst):
18
15
 
19
16
  df_umol = _ug2umol(df_all)
20
17
 
21
- ## output
22
- ## Na, SO4, NH3, NO3, Cl, Ca, K, Mg, RH, TEMP
18
+ # output
19
+ # Na, SO4, NH3, NO3, Cl, Ca, K, Mg, RH, TEMP
23
20
  df_input = DataFrame(index=index)
24
21
  df_out = DataFrame(index=index)
25
22
 
@@ -29,25 +26,25 @@ def _basic(df_che, path_out, nam_lst):
29
26
  pth_input.unlink(missing_ok=True)
30
27
  pth_output.unlink(missing_ok=True)
31
28
 
32
- ## header
29
+ # header
33
30
  _header = 'Input units (0=umol/m3, 1=ug/m3)\n' + '0\n\n' + \
34
31
  'Problem type (0=forward, 1=reverse); Phase state (0=solid+liquid, 1=metastable)\n' + '0, 1\n\n' + \
35
32
  'NH4-SO4 system case\n'
36
33
 
37
- ## software
34
+ # software
38
35
  path_iso = Path(__file__).parent / 'isrpia2.exe'
39
36
 
40
37
  # make input file and output temp input (without index)
41
- ## NH3
38
+ # NH3
42
39
  df_input['NH3'] = df_umol['NH4+'].fillna(0).copy() + df_umol['NH3']
43
40
 
44
- ## NO3
41
+ # NO3
45
42
  df_input['NO3'] = df_umol['HNO3'].fillna(0).copy() + df_umol['NO3-']
46
43
 
47
- ## Cl
44
+ # Cl
48
45
  df_input['Cl'] = df_umol['HCl'].fillna(0).copy() + df_umol['Cl-']
49
46
 
50
- ## temp, RH
47
+ # temp, RH
51
48
  df_input['RH'] = df_all['RH'] / 100
52
49
  df_input['TEMP'] = df_all['temp'] + 273.15
53
50
 
@@ -55,7 +52,7 @@ def _basic(df_che, path_out, nam_lst):
55
52
 
56
53
  df_input = df_input[['Na', 'SO4', 'NH3', 'NO3', 'Cl', 'Ca', 'K', 'Mg', 'RH', 'TEMP']].fillna('-').copy()
57
54
 
58
- ## output the input data
55
+ # output the input data
59
56
  df_input.to_csv(pth_input, index=False)
60
57
  with (pth_input).open('r+', encoding='utf-8', errors='ignore') as _f:
61
58
  _cont = _f.read()
@@ -16,7 +16,7 @@ def _min_Rsq(_oc, _ec, _rng):
16
16
 
17
17
  _out_table = DataFrame(_oc_mesh - _val_mesh * _ec_mesh, index=_oc.index, columns=_rng)
18
18
 
19
- ## calculate R2
19
+ # calculate R2
20
20
  _r2_dic = {}
21
21
  _func = lambda _x, _sl, _inte: _sl * _x + _inte
22
22
  for _ocec, _out in _out_table.items():
@@ -30,28 +30,28 @@ def _min_Rsq(_oc, _ec, _rng):
30
30
 
31
31
  _r2_dic[round(_ocec, 3)] = 1. - _rss / _tss
32
32
 
33
- ## get the min R2
33
+ # get the min R2
34
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
- ## parameter
40
+ # parameter
41
41
  _out = DataFrame(index=_lcres_splt.index)
42
42
  (_, _oc), (_, _ec) = _lcres_splt.items()
43
43
  # _oc, _ec = _lcres_splt['Thermal_OC'], _lcres_splt['Thermal_EC']
44
44
 
45
- ## real data OC/EC
45
+ # real data OC/EC
46
46
  _ocec_ratio_real = (_oc / _ec).quantile(.5)
47
47
 
48
48
  _out[f'OC/EC_real_{_nam}'] = _ocec_ratio_real
49
49
  _out[f'POC_real_{_nam}'] = _ocec_ratio_real * _ec
50
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):
52
+ # the least R2 method
53
+ # estimated OC/EC
54
+ if len(_lcres_splt) <= _hr_lim:
55
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
56
  print('\t\tPlease Modify the Values of "hour_limit" or Input Sufficient Amount of Data !!')
57
57
 
@@ -60,13 +60,13 @@ def _ocec_ratio_cal(_nam, _lcres_splt, _hr_lim, _range_, _wisoc_range_):
60
60
 
61
61
  return _out
62
62
 
63
- if (len(_lcres_splt.dropna()) == 0):
63
+ if len(_lcres_splt.dropna()) == 0:
64
64
  _out[[f'OC/EC_{_nam}', f'POC_{_nam}', f'SOC_{_nam}', f'WISOC/OC_{_nam}', f'WSOC_{_nam}',
65
65
  f'WISOC_{_nam}']] = np.nan
66
66
 
67
67
  return _out
68
68
 
69
- ## OC/EC
69
+ # OC/EC
70
70
  _ocec_ratio = False
71
71
  _st, _ed, _stp = _range_
72
72
 
@@ -78,12 +78,12 @@ def _ocec_ratio_cal(_nam, _lcres_splt, _hr_lim, _range_, _wisoc_range_):
78
78
 
79
79
  _ocec_ratio, _soc = _min_Rsq(_oc, _ec, _ocec_rng)
80
80
 
81
- ## WISOC
81
+ # WISOC
82
82
  _st, _ed, _stp = _wisoc_range_
83
83
  _wisoc_rng = (np.arange(_st, _ed + _stp, _stp) * _ocec_ratio).round(5)
84
84
  _wisoc_ratio, _wsoc = _min_Rsq(_oc, _ec, _wisoc_rng)
85
85
 
86
- ## out
86
+ # out
87
87
  _out[f'OC/EC_{_nam}'] = _ocec_ratio
88
88
  _out[f'SOC_{_nam}'] = _soc
89
89
  _out[f'POC_{_nam}'] = _oc - _out[f'SOC_{_nam}']
@@ -95,15 +95,16 @@ def _ocec_ratio_cal(_nam, _lcres_splt, _hr_lim, _range_, _wisoc_range_):
95
95
  f'OC/EC_real_{_nam}', f'POC_real_{_nam}', f'SOC_real_{_nam}']]
96
96
 
97
97
 
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)
98
+ def _basic(_lcres, _mass, _ocec_ratio, _ocec_ratio_month, _hr_lim, _range, _wisoc_range):
99
+ _lcres, _mass = union_index(_lcres, _mass)
100
100
 
101
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 = _lcres[['OC1_raw', 'OC2_raw', 'OC3_raw', 'OC4_raw']] / _lcres['Sample_Volume'].to_frame().values.copy()
105
+ _df_bsc.rename(columns={'OC1_raw': 'OC1', 'OC2_raw': 'OC2', 'OC3_raw': 'OC3', 'OC4_raw': 'OC4'}, inplace=True)
105
106
 
106
- ## SOC, POC, OC/EC
107
+ # SOC, POC, OC/EC
107
108
  if _ocec_ratio is not None:
108
109
  try:
109
110
  iter(_ocec_ratio)
@@ -126,7 +127,7 @@ def _basic(_lcres, _res, _mass, _ocec_ratio, _ocec_ratio_month, _hr_lim, _range,
126
127
 
127
128
  _df_bsc = concat((_df_bsc.copy(), _prcs_df), axis=1)
128
129
 
129
- ## ratio
130
+ # ratio
130
131
  _df_ratio = DataFrame(index=_df_bsc.index)
131
132
 
132
133
  for _ky, _val in _df_bsc.items():
@@ -144,41 +145,15 @@ def _basic(_lcres, _res, _mass, _ocec_ratio, _ocec_ratio_month, _hr_lim, _range,
144
145
  _df_ratio[f'Optical_OC/PM'] = _lcres['Optical_OC'] / _mass
145
146
  _df_ratio[f'Optical_EC/PM'] = _lcres['Optical_EC'] / _mass
146
147
 
147
- ## ratio status
148
+ # ratio status
148
149
  _df_bsc = concat((_lcres, _df_bsc.copy()), axis=1)
149
150
 
150
151
  for _ky, _df in _df_ratio.items():
151
152
  _df_bsc[f'{_ky}_status'] = 'Normal'
152
153
  _df_bsc[f'{_ky}_status'] = _df_bsc[f'{_ky}_status'].mask(_df > 1, 'Warning')
153
154
 
154
- ## out
155
+ # out
155
156
  _out['ratio'] = _df_ratio
156
157
  _out['basic'] = _df_bsc
157
158
 
158
159
  return _out
159
-
160
-
161
- '''
162
- _ocec_mesh, _oc_mesh = n.meshgrid(_ocec_rng, _oc)
163
- _ocec_mesh, _ec_mesh = n.meshgrid(_ocec_rng, _ec)
164
-
165
- _soc_table = DataFrame(_oc_mesh-_ocec_mesh*_ec_mesh, index=_oc.index, columns=_ocec_rng)
166
-
167
- ## calculate R2
168
- _r2_dic = {}
169
- _func = lambda _x, _sl, _inte : _sl*_x+_inte
170
- for _ocec, _soc in _soc_table.items():
171
-
172
- _df = DataFrame([_soc.values, _ec.values]).T.dropna()
173
- _x, _y = _df[0], _df[1]
174
-
175
- _opt, _ = curve_fit(_func, _x, _y)
176
-
177
- _tss = n.sum((_y - _y.mean())**2.)
178
- _rss = n.sum((_y - _func(_x, *_opt))**2.)
179
-
180
- _r2_dic[round(_ocec,2)] = 1. - _rss / _tss
181
-
182
- ## get the min R2
183
- _ocec_ratio = DataFrame(_r2_dic, index=[0]).idxmin(axis=1).values[0]
184
- # '''
@@ -1,15 +1,10 @@
1
1
  from ..core import Writer, run_process
2
2
 
3
- __all__ = [
4
-
5
- 'VOC',
6
-
7
- ]
3
+ __all__ = ['VOC']
8
4
 
9
5
 
10
6
  class VOC(Writer):
11
7
 
12
- ## Reconstruction
13
8
  @run_process('VOC - basic', 'voc_basic')
14
9
  def VOC_basic(self, _df_voc):
15
10
  from ._potential_par import _basic
@@ -0,0 +1,108 @@
1
+ from pathlib import Path
2
+
3
+ from pandas import DataFrame, read_json, concat
4
+
5
+
6
+ def _basic(_df_voc):
7
+ with (Path(__file__).parent / 'support_voc.json').open('r', encoding='utf-8', errors='ignore') as f:
8
+ _par = read_json(f)
9
+
10
+ # parameter
11
+ _keys = _df_voc.keys()
12
+
13
+ invalid_keys = [key for key in _df_voc.keys() if key not in set(_par.keys())]
14
+
15
+ if invalid_keys:
16
+ raise KeyError(f'\n\t\t{invalid_keys} are not supported keys.'
17
+ f'\n\t\tPlease check the\033[91m support_voc.md\033[0m file to use the correct name.')
18
+
19
+ _MW, _MIR, _SOAP, _KOH = _par.loc['MW', :], _par.loc['MIR', :], _par.loc['SOAP', :], _par.loc['KOH', :]
20
+
21
+ _voc_classify = {
22
+ 'alkane_total': ['Ethane', 'Propane', 'Isobutane', 'n-Butane', 'Isopentane', 'n-Pentane', 'n-Hexane',
23
+ 'n-Heptane', 'n-Octane', 'n-Nonane', 'n-Decane', 'n-Undecane', 'n-Dodecane',
24
+
25
+ 'Cyclopentane', 'Methylcyclopentane', 'Cyclohexane', 'Methylcyclohexane',
26
+
27
+ '2,2-Dimethylbutane', '2,3-Dimethylbutane', '2-Methylpentane', '3-Methylpentane',
28
+ '2,4-Dimethylpentane', '2-Methylhexane', '3-Methylhexane',
29
+ '2,2,4-Trimethylpentane', '2,3,4-Trimethylpentane', '2-Methylheptane', '3-Methylheptane'],
30
+
31
+ 'alkene_total': ['Ethylene', 'Propylene', '1-Butene', 't-2-Butene', 'cis-2-Butene', '1-Pentene', 't-2-Pentene',
32
+ 'cis-2-Pentene', '1-Hexene', 'Isoprene', '1.3-Butadiene', '1-Octene'],
33
+
34
+ 'aromatic_total': ['Benzene', 'Toluene', 'Ethylbenzene', 'm/p-Xylene', 'o-Xylene', 'Styrene',
35
+ 'Isopropylbenzene',
36
+ 'n-Propylbenzene', 'm-Ethyltoluene', 'p-Ethyltoluene', 'o-Ethyltoluene', 'm-Diethylbenzene',
37
+ 'p-Diethylbenzene', '1,2,4-Trimethylbenzene', '1,2,3-Trimethylbenzene',
38
+ '1,3,5-Trimethylbenzene', ],
39
+
40
+ 'alkyne_total': ['Acetylene'],
41
+
42
+ 'OVOC': ['Acetaldehyde', 'Ethanol', 'Acetone', 'IPA', 'Ethyl Acetate', 'Butyl Acetate'],
43
+
44
+ 'ClVOC': ['VCM', 'TCE', 'PCE', '1.4-DCB', '1.2-DCB'],
45
+ }
46
+
47
+ _df_MW = (_df_voc * _MW).copy()
48
+ _df_dic = {
49
+ 'Conc': _df_voc.copy(),
50
+ 'OFP': _df_MW / 48 * _MIR,
51
+ 'SOAP': _df_MW / 24.5 * _SOAP / 100 * 0.054,
52
+ 'LOH': _df_MW / 24.5 / _MW * 0.602 * _KOH,
53
+ }
54
+
55
+ # calculate
56
+ _out = {}
57
+ for _nam, _df in _df_dic.items():
58
+
59
+ _df_out = DataFrame(index=_df_voc.index)
60
+
61
+ for _voc_nam, _voc_lst in _voc_classify.items():
62
+ _lst = list(set(_keys) & set(_voc_lst))
63
+ if len(_lst) == 0:
64
+ continue
65
+
66
+ _df_out = concat([_df[_lst], _df_out], axis=1)
67
+
68
+ _df_out[_voc_nam] = _df[_lst].sum(axis=1, min_count=1)
69
+
70
+ _df_out['Total'] = _df.sum(axis=1, min_count=1)
71
+
72
+ _out[_nam] = _df_out
73
+
74
+ return _out
75
+
76
+
77
+ def markdown_table_to_dataframe():
78
+ import pandas as pd
79
+ from pathlib import Path
80
+
81
+ # support_voc.md
82
+ with open(Path(__file__).parent / 'support_voc.md', 'r', encoding='utf-8') as file:
83
+ markdown_content = file.read()
84
+
85
+ # 將內容分割成行
86
+ lines = markdown_content.strip().split('\n')
87
+
88
+ # 提取表頭
89
+ headers = [col.strip() for col in lines[0].split('|')[1:-1]]
90
+
91
+ # 解析數據行
92
+ data = []
93
+ for line in lines[2:]: # 跳過表頭和分隔行
94
+ columns = [col.strip() for col in line.split('|')[1:-1]]
95
+ data.append(columns)
96
+
97
+ # 創建 DataFrame
98
+ df = pd.DataFrame(data, columns=headers)
99
+
100
+ # 轉換數據類型
101
+ numeric_columns = ['MIR', 'MW', 'SOAP', 'KOH']
102
+ for col in numeric_columns:
103
+ df[col] = pd.to_numeric(df[col], errors='coerce')
104
+ df = df.set_index('Species').T
105
+
106
+ df = df.iloc[:, :-7]
107
+
108
+ df.to_json(Path(__file__).parent / 'support_voc.json', indent=4)