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
@@ -0,0 +1,390 @@
1
+ {
2
+ "fRH": {
3
+ "1": 1.0,
4
+ "2": 1.0,
5
+ "3": 1.0,
6
+ "4": 1.0,
7
+ "5": 1.0,
8
+ "6": 1.0,
9
+ "7": 1.0,
10
+ "8": 1.0,
11
+ "9": 1.0,
12
+ "10": 1.0,
13
+ "11": 1.0,
14
+ "12": 1.0,
15
+ "13": 1.0,
16
+ "14": 1.0,
17
+ "15": 1.0,
18
+ "16": 1.0,
19
+ "17": 1.0,
20
+ "18": 1.0,
21
+ "19": 1.0,
22
+ "20": 1.0,
23
+ "21": 1.0,
24
+ "22": 1.0,
25
+ "23": 1.0,
26
+ "24": 1.0,
27
+ "25": 1.0,
28
+ "26": 1.0,
29
+ "27": 1.0,
30
+ "28": 1.0,
31
+ "29": 1.0,
32
+ "30": 1.0,
33
+ "31": 1.0,
34
+ "32": 1.0,
35
+ "33": 1.0,
36
+ "34": 1.0,
37
+ "35": 1.0,
38
+ "36": 1.0,
39
+ "37": 1.02,
40
+ "38": 1.04,
41
+ "39": 1.06,
42
+ "40": 1.08,
43
+ "41": 1.1,
44
+ "42": 1.13,
45
+ "43": 1.15,
46
+ "44": 1.18,
47
+ "45": 1.2,
48
+ "46": 1.23,
49
+ "47": 1.26,
50
+ "48": 1.28,
51
+ "49": 1.31,
52
+ "50": 1.34,
53
+ "51": 1.37,
54
+ "52": 1.41,
55
+ "53": 1.44,
56
+ "54": 1.47,
57
+ "55": 1.51,
58
+ "56": 1.54,
59
+ "57": 1.58,
60
+ "58": 1.62,
61
+ "59": 1.66,
62
+ "60": 1.7,
63
+ "61": 1.74,
64
+ "62": 1.79,
65
+ "63": 1.83,
66
+ "64": 1.88,
67
+ "65": 1.93,
68
+ "66": 1.98,
69
+ "67": 2.03,
70
+ "68": 2.08,
71
+ "69": 2.14,
72
+ "70": 2.19,
73
+ "71": 2.25,
74
+ "72": 2.31,
75
+ "73": 2.37,
76
+ "74": 2.43,
77
+ "75": 2.5,
78
+ "76": 2.56,
79
+ "77": 2.63,
80
+ "78": 2.7,
81
+ "79": 2.78,
82
+ "80": 2.86,
83
+ "81": 2.94,
84
+ "82": 3.03,
85
+ "83": 3.12,
86
+ "84": 3.22,
87
+ "85": 3.33,
88
+ "86": 3.45,
89
+ "87": 3.58,
90
+ "88": 3.74,
91
+ "89": 3.93,
92
+ "90": 4.16,
93
+ "91": 4.45,
94
+ "92": 4.84,
95
+ "93": 5.37,
96
+ "94": 6.16,
97
+ "95": 7.4
98
+ },
99
+ "fRHSS": {
100
+ "1": 1.0,
101
+ "2": 1.0,
102
+ "3": 1.0,
103
+ "4": 1.0,
104
+ "5": 1.0,
105
+ "6": 1.0,
106
+ "7": 1.0,
107
+ "8": 1.0,
108
+ "9": 1.0,
109
+ "10": 1.0,
110
+ "11": 1.0,
111
+ "12": 1.0,
112
+ "13": 1.0,
113
+ "14": 1.0,
114
+ "15": 1.0,
115
+ "16": 1.0,
116
+ "17": 1.0,
117
+ "18": 1.0,
118
+ "19": 1.0,
119
+ "20": 1.0,
120
+ "21": 1.0,
121
+ "22": 1.0,
122
+ "23": 1.0,
123
+ "24": 1.0,
124
+ "25": 1.0,
125
+ "26": 1.0,
126
+ "27": 1.0,
127
+ "28": 1.0,
128
+ "29": 1.0,
129
+ "30": 1.0,
130
+ "31": 1.0,
131
+ "32": 1.0,
132
+ "33": 1.0,
133
+ "34": 1.0,
134
+ "35": 1.0,
135
+ "36": 1.0,
136
+ "37": 1.0,
137
+ "38": 1.0,
138
+ "39": 1.0,
139
+ "40": 1.0,
140
+ "41": 1.0,
141
+ "42": 1.0,
142
+ "43": 1.0,
143
+ "44": 1.0,
144
+ "45": 1.0,
145
+ "46": 1.0,
146
+ "47": 2.3584,
147
+ "48": 2.3799,
148
+ "49": 2.4204,
149
+ "50": 2.4488,
150
+ "51": 2.4848,
151
+ "52": 2.5006,
152
+ "53": 2.5052,
153
+ "54": 2.5279,
154
+ "55": 2.5614,
155
+ "56": 2.5848,
156
+ "57": 2.5888,
157
+ "58": 2.616,
158
+ "59": 2.6581,
159
+ "60": 2.6866,
160
+ "61": 2.7341,
161
+ "62": 2.7834,
162
+ "63": 2.8272,
163
+ "64": 2.8287,
164
+ "65": 2.8594,
165
+ "66": 2.8943,
166
+ "67": 2.9105,
167
+ "68": 2.9451,
168
+ "69": 3.0105,
169
+ "70": 3.0485,
170
+ "71": 3.1269,
171
+ "72": 3.1729,
172
+ "73": 3.2055,
173
+ "74": 3.2459,
174
+ "75": 3.2673,
175
+ "76": 3.3478,
176
+ "77": 3.4174,
177
+ "78": 3.5202,
178
+ "79": 3.5744,
179
+ "80": 3.6329,
180
+ "81": 3.6905,
181
+ "82": 3.808,
182
+ "83": 3.9505,
183
+ "84": 4.0398,
184
+ "85": 4.1127,
185
+ "86": 4.2824,
186
+ "87": 4.494,
187
+ "88": 4.6078,
188
+ "89": 4.8573,
189
+ "90": 5.1165,
190
+ "91": 5.3844,
191
+ "92": 5.7457,
192
+ "93": 6.1704,
193
+ "94": 6.7178,
194
+ "95": 7.3492
195
+ },
196
+ "fRHs": {
197
+ "1": 1.0,
198
+ "2": 1.0,
199
+ "3": 1.0,
200
+ "4": 1.0,
201
+ "5": 1.0,
202
+ "6": 1.0,
203
+ "7": 1.0,
204
+ "8": 1.0,
205
+ "9": 1.0,
206
+ "10": 1.0,
207
+ "11": 1.0,
208
+ "12": 1.0,
209
+ "13": 1.0,
210
+ "14": 1.0,
211
+ "15": 1.0,
212
+ "16": 1.0,
213
+ "17": 1.0,
214
+ "18": 1.0,
215
+ "19": 1.0,
216
+ "20": 1.0,
217
+ "21": 1.0,
218
+ "22": 1.0,
219
+ "23": 1.0,
220
+ "24": 1.0,
221
+ "25": 1.0,
222
+ "26": 1.0,
223
+ "27": 1.0,
224
+ "28": 1.0,
225
+ "29": 1.0,
226
+ "30": 1.0,
227
+ "31": 1.0,
228
+ "32": 1.0,
229
+ "33": 1.0,
230
+ "34": 1.0,
231
+ "35": 1.0,
232
+ "36": 1.0,
233
+ "37": 1.38,
234
+ "38": 1.4,
235
+ "39": 1.42,
236
+ "40": 1.44,
237
+ "41": 1.46,
238
+ "42": 1.48,
239
+ "43": 1.49,
240
+ "44": 1.51,
241
+ "45": 1.53,
242
+ "46": 1.55,
243
+ "47": 1.57,
244
+ "48": 1.59,
245
+ "49": 1.62,
246
+ "50": 1.64,
247
+ "51": 1.66,
248
+ "52": 1.68,
249
+ "53": 1.71,
250
+ "54": 1.73,
251
+ "55": 1.76,
252
+ "56": 1.78,
253
+ "57": 1.81,
254
+ "58": 1.83,
255
+ "59": 1.86,
256
+ "60": 1.89,
257
+ "61": 1.92,
258
+ "62": 1.95,
259
+ "63": 1.99,
260
+ "64": 2.02,
261
+ "65": 2.06,
262
+ "66": 2.09,
263
+ "67": 2.13,
264
+ "68": 2.17,
265
+ "69": 2.22,
266
+ "70": 2.26,
267
+ "71": 2.31,
268
+ "72": 2.36,
269
+ "73": 2.41,
270
+ "74": 2.47,
271
+ "75": 2.54,
272
+ "76": 2.6,
273
+ "77": 2.67,
274
+ "78": 2.75,
275
+ "79": 2.84,
276
+ "80": 2.93,
277
+ "81": 3.03,
278
+ "82": 3.15,
279
+ "83": 3.27,
280
+ "84": 3.42,
281
+ "85": 3.58,
282
+ "86": 3.76,
283
+ "87": 3.98,
284
+ "88": 4.23,
285
+ "89": 4.53,
286
+ "90": 4.9,
287
+ "91": 5.35,
288
+ "92": 5.93,
289
+ "93": 6.71,
290
+ "94": 7.78,
291
+ "95": 9.34
292
+ },
293
+ "fRHl": {
294
+ "1": 1.0,
295
+ "2": 1.0,
296
+ "3": 1.0,
297
+ "4": 1.0,
298
+ "5": 1.0,
299
+ "6": 1.0,
300
+ "7": 1.0,
301
+ "8": 1.0,
302
+ "9": 1.0,
303
+ "10": 1.0,
304
+ "11": 1.0,
305
+ "12": 1.0,
306
+ "13": 1.0,
307
+ "14": 1.0,
308
+ "15": 1.0,
309
+ "16": 1.0,
310
+ "17": 1.0,
311
+ "18": 1.0,
312
+ "19": 1.0,
313
+ "20": 1.0,
314
+ "21": 1.0,
315
+ "22": 1.0,
316
+ "23": 1.0,
317
+ "24": 1.0,
318
+ "25": 1.0,
319
+ "26": 1.0,
320
+ "27": 1.0,
321
+ "28": 1.0,
322
+ "29": 1.0,
323
+ "30": 1.0,
324
+ "31": 1.0,
325
+ "32": 1.0,
326
+ "33": 1.0,
327
+ "34": 1.0,
328
+ "35": 1.0,
329
+ "36": 1.0,
330
+ "37": 1.31,
331
+ "38": 1.32,
332
+ "39": 1.34,
333
+ "40": 1.35,
334
+ "41": 1.36,
335
+ "42": 1.38,
336
+ "43": 1.39,
337
+ "44": 1.41,
338
+ "45": 1.42,
339
+ "46": 1.44,
340
+ "47": 1.45,
341
+ "48": 1.47,
342
+ "49": 1.49,
343
+ "50": 1.5,
344
+ "51": 1.52,
345
+ "52": 1.54,
346
+ "53": 1.55,
347
+ "54": 1.57,
348
+ "55": 1.59,
349
+ "56": 1.61,
350
+ "57": 1.63,
351
+ "58": 1.65,
352
+ "59": 1.67,
353
+ "60": 1.69,
354
+ "61": 1.71,
355
+ "62": 1.73,
356
+ "63": 1.75,
357
+ "64": 1.78,
358
+ "65": 1.8,
359
+ "66": 1.83,
360
+ "67": 1.86,
361
+ "68": 1.89,
362
+ "69": 1.92,
363
+ "70": 1.95,
364
+ "71": 1.98,
365
+ "72": 2.01,
366
+ "73": 2.05,
367
+ "74": 2.09,
368
+ "75": 2.13,
369
+ "76": 2.18,
370
+ "77": 2.22,
371
+ "78": 2.27,
372
+ "79": 2.33,
373
+ "80": 2.39,
374
+ "81": 2.45,
375
+ "82": 2.52,
376
+ "83": 2.6,
377
+ "84": 2.69,
378
+ "85": 2.79,
379
+ "86": 2.9,
380
+ "87": 3.02,
381
+ "88": 3.16,
382
+ "89": 3.33,
383
+ "90": 3.53,
384
+ "91": 3.77,
385
+ "92": 4.06,
386
+ "93": 4.43,
387
+ "94": 4.92,
388
+ "95": 5.57
389
+ }
390
+ }
@@ -0,0 +1,92 @@
1
+ from functools import wraps
2
+ from typing import Literal
3
+
4
+ import matplotlib.pyplot as plt
5
+ from matplotlib.pyplot import Axes
6
+
7
+ __all__ = ['set_figure', 'combine_legends', 'auto_label_pct']
8
+
9
+
10
+ def set_figure(func=None,
11
+ *,
12
+ figsize: tuple | None = None,
13
+ fs: int | None = None,
14
+ fw: str = None,
15
+ autolayout: bool = True):
16
+ # For more details please see https://matplotlib.org/stable/users/explain/customizing.html
17
+ def decorator(_func):
18
+ @wraps(_func)
19
+ def wrapper(*args, **kwargs):
20
+ print(f'\tPlot:\033[96m {_func.__name__}\033[0m')
21
+
22
+ plt.rcParams['mathtext.fontset'] = 'custom'
23
+ plt.rcParams['mathtext.rm'] = 'Times New Roman'
24
+ plt.rcParams['mathtext.it'] = 'Times New Roman: italic'
25
+ plt.rcParams['mathtext.bf'] = 'Times New Roman: bold'
26
+ plt.rcParams['mathtext.default'] = 'regular'
27
+
28
+ # The font properties used by `text.Text`.
29
+ # The text, annotate, label, title, ticks, are used to create text
30
+ plt.rcParams['font.family'] = 'Times New Roman'
31
+ plt.rcParams['font.weight'] = fw or 'normal'
32
+ plt.rcParams['font.size'] = fs or 8
33
+
34
+ plt.rcParams['axes.titlesize'] = 'large'
35
+ plt.rcParams['axes.titleweight'] = 'bold'
36
+ plt.rcParams['axes.labelweight'] = 'bold'
37
+
38
+ # color
39
+ plt.rcParams['axes.prop_cycle'] = plt.cycler(color=['b', 'g', 'r', 'c', 'm', 'y', 'k'])
40
+
41
+ plt.rcParams['xtick.labelsize'] = 'medium'
42
+ plt.rcParams['ytick.labelsize'] = 'medium'
43
+
44
+ # matplotlib.font_manager.FontProperties ---> matplotlib.rcParams
45
+ plt.rcParams['legend.loc'] = 'best'
46
+ plt.rcParams['legend.frameon'] = False
47
+ plt.rcParams['legend.fontsize'] = 'small'
48
+ plt.rcParams['legend.title_fontsize'] = 'medium'
49
+ plt.rcParams['legend.handlelength'] = 1.5
50
+ plt.rcParams['legend.labelspacing'] = 0.7
51
+
52
+ plt.rcParams['figure.figsize'] = figsize or (4, 4)
53
+ plt.rcParams['figure.dpi'] = 200
54
+ plt.rcParams['figure.autolayout'] = autolayout
55
+
56
+ if ~autolayout:
57
+ plt.rcParams['figure.subplot.left'] = 0.1
58
+ plt.rcParams['figure.subplot.right'] = 0.875
59
+ plt.rcParams['figure.subplot.top'] = 0.875
60
+ plt.rcParams['figure.subplot.bottom'] = 0.125
61
+
62
+ # plt.rcParams['figure.constrained_layout.use'] = True
63
+
64
+ plt.rcParams['savefig.transparent'] = True
65
+
66
+ return _func(*args, **kwargs)
67
+
68
+ return wrapper
69
+
70
+ if func is None:
71
+ return decorator
72
+
73
+ return decorator(func)
74
+
75
+
76
+ def combine_legends(axes_list: list[Axes]) -> tuple[list, list]:
77
+ return (
78
+ [legend for axes in axes_list for legend in axes.get_legend_handles_labels()[0]],
79
+ [label for axes in axes_list for label in axes.get_legend_handles_labels()[1]]
80
+ )
81
+
82
+
83
+ def auto_label_pct(pct,
84
+ symbol: bool = True,
85
+ include_pct: bool = False,
86
+ ignore: Literal["inner", "outer"] = 'inner',
87
+ value: float = 2):
88
+ if not symbol:
89
+ return ''
90
+ cond = pct <= value if ignore == 'inner' else pct > value
91
+ label = '' if cond else '{:.1f}'.format(pct)
92
+ return '' if label == '' else label + '%' if include_pct else label
@@ -0,0 +1,49 @@
1
+ import numpy as np
2
+ from sklearn.linear_model import LinearRegression
3
+ from tabulate import tabulate
4
+
5
+ __all__ = ['linear_regression_base']
6
+
7
+
8
+ def linear_regression_base(x_array: np.ndarray,
9
+ y_array: np.ndarray,
10
+ columns: str | list[str] | None = None,
11
+ positive: bool = True,
12
+ fit_intercept: bool = True):
13
+ if len(x_array.shape) > 1 and x_array.shape[1] >= 2:
14
+ model = LinearRegression(positive=positive, fit_intercept=fit_intercept).fit(x_array, y_array)
15
+
16
+ coefficients = model.coef_[0].round(3)
17
+ intercept = model.intercept_[0].round(3) if fit_intercept else 'None'
18
+ r_square = model.score(x_array, y_array).__round__(3)
19
+ y_predict = model.predict(x_array)
20
+
21
+ equation = ' + '.join([f'{coeff:.3f} * {col}' for coeff, col in zip(coefficients, columns)])
22
+ equation = equation.replace(' + 0.000 * Const', '') # Remove terms with coefficient 0
23
+
24
+ text = 'y = ' + str(equation) + '\n' + r'$\bf R^2 = $' + str(r_square)
25
+ tab = tabulate([[*coefficients, intercept, r_square]], headers=[*columns, 'intercept', 'R^2'], floatfmt=".3f",
26
+ tablefmt="fancy_grid")
27
+ print('\n' + tab)
28
+
29
+ return text, y_predict, coefficients
30
+
31
+ else:
32
+ x_array = x_array.reshape(-1, 1)
33
+ y_array = y_array.reshape(-1, 1)
34
+
35
+ model = LinearRegression(positive=positive, fit_intercept=fit_intercept).fit(x_array, y_array)
36
+
37
+ slope = model.coef_[0][0].round(3)
38
+ intercept = model.intercept_[0].round(3) if fit_intercept else 'None'
39
+ r_square = model.score(x_array, y_array).__round__(3)
40
+ y_predict = model.predict(x_array)
41
+
42
+ text = np.poly1d([slope, intercept])
43
+ text = 'y = ' + str(text).replace('\n', "") + '\n' + r'$\bf R^2 = $' + str(r_square)
44
+
45
+ tab = tabulate([[slope, intercept, r_square]], headers=['slope', 'intercept', 'R^2'], floatfmt=".3f",
46
+ tablefmt="fancy_grid")
47
+ print('\n' + tab)
48
+
49
+ return text, y_predict, slope
@@ -0,0 +1,84 @@
1
+ {
2
+ "ALWC": "ALWC (\u00b5g/m^3)",
3
+ "AN": "AN (\u00b5g/m^3)",
4
+ "AS": "AS (\u00b5g/m^3)",
5
+ "T_EC": "EC (\u00b5g/m^3)",
6
+ "T_OC": "OC (\u00b5g/m^3)",
7
+ "PM1": "PM_{1} (\u00b5g/m^3)",
8
+ "PM25": "PM_{2.5} (\u00b5g/m^3)",
9
+ "SIA": "SIA (\u00b5g/m^3)",
10
+ "POC": "POC (\u00b5g/m^3)",
11
+ "SOC": "SOC (\u00b5g/m^3)",
12
+ "total_mass": "Reconstructed PM_{2.5} (\u00b5g/m^3)",
13
+ "PM1/PM25": "PM_{1} / PM_{2.5}",
14
+ "OM_mass_ratio": "OM ratio (%)",
15
+ "EC_mass_ratio": "EC/PM_{2.5}",
16
+ "AS_mass_ratio": "AS ratio (%)",
17
+ "AN_mass_ratio": "AN ratio (%)",
18
+ "ALWC_mass_ratio": "ALWC/PM_{2.5}",
19
+ "SIA_mass_ratio": "SIA/PM_{2.5}",
20
+ "Babs": "Mie Amb Absorption (1/Mm)",
21
+ "Babs_dry": "Mie Dry Absorption (1/Mm)",
22
+ "Absorption": "Absorption (1/Mm)",
23
+ "Bext": "Mie Amb Extinction (1/Mm)",
24
+ "Bext_dry": "Mie Dry Extinction (1/Mm)",
25
+ "Extinction": "Extinction (1/Mm)",
26
+ "Bsca": "Mie Amb Scattering (1/Mm)",
27
+ "Bsca_dry": "Mie Dry Scattering (1/Mm)",
28
+ "Scattering": "Scattering (1/Mm)",
29
+ "Diurnal": "Hour",
30
+ "PBLH": "PBLH (m)",
31
+ "VC": "VC (m²/s)",
32
+ "MAC": "MAC (m²/g)",
33
+ "MAE": "MAE (m²/g)",
34
+ "MEE": "MEE (m²/g)",
35
+ "MSE": "MSE (m²/g)",
36
+ "SSA": "SSA",
37
+ "AAE": "AAE",
38
+ "Localized": "Reconstructed Extinction (1/Mm)",
39
+ "Modified": "Reconstructed Extinction (1/Mm)",
40
+ "Revised": "Reconstructed Extinction (1/Mm)",
41
+ "Measured": "Measured Extinction (1/Mm)",
42
+ "SOR": "SOR",
43
+ "NOR": "NOR",
44
+ "O3": "O_{3} (ppb)",
45
+ "NO2": "NO_{2} (ppb)",
46
+ "CO": "CO (ppm)",
47
+ "SO2": "SO_{2} (ppb)",
48
+ "kappa": "kappa",
49
+ "RH": "RH (\\%)",
50
+ "gRH": "g(RH)",
51
+ "fRH": "f(RH)",
52
+ "Factor": "Factor",
53
+ "Bext_internal": "Bext_{internal}",
54
+ "Bsca_internal": "Bsca_{internal}",
55
+ "Babs_internal": "Babs_{internal}",
56
+ "Bext_external": "Bext_{external}",
57
+ "Bsca_external": "Bsca_{external}",
58
+ "Babs_external": "Babs_{external}",
59
+ "Bext_dry_external": "Dry Bext_{external}",
60
+ "Bsca_dry_external": "Dry Bsca_{external}",
61
+ "Babs_dry_external": "Dry Babs_{external}",
62
+ "Bext_Fixed_PNSD": "Mie Amb Extinction (1/Mm)",
63
+ "Bext_Fixed_RI": "Mie Amb Extinction (1/Mm)",
64
+ "ABC": "ABC (%)",
65
+ "CPC_1": "CPC_1 ({\\#}/cm^{3})",
66
+ "CPC_2": "CPC_2 ({\\#}/cm^{3})",
67
+ "BC6": "BC6 (ng/cm^{3}) (880 nm)",
68
+ "IR BCc": "IR BCc (ng/cm^{3}) (880 nm)",
69
+ "AT": "Temp (^{\\circ}C)",
70
+ "WS": "WS (m/s)",
71
+ "WD": "WD ({\\circ})",
72
+ "y_actual": "y_{actual}",
73
+ "y_predict": "y_{predict}",
74
+ "PG": "Extinction (1/Mm)",
75
+ "Number_dist": "dN/dlogdp (nm^{-1}/cm^3)",
76
+ "Surface_dist": "dS/dlogdp (nm/cm^3)",
77
+ "Volume_dist": "dV/dlogdp (nm^2/cm^3)",
78
+ "Extinction_dist": "d{\\sigma}/dlogdp (1/Mm)",
79
+ "Vis_LPV": "Visibility (km)",
80
+ "Vis_LPV_1": "Visibility (km)",
81
+ "MA350_0171 IR BCc": "MA350-0171 IR BCc (ng/cm^{3}) (880 nm)",
82
+ "MA350_0176 IR BCc": "MA350-0176 IR BCc (ng/cm^{3}) (880 nm)",
83
+ "BC1054 IR BCc": "BC-1054 IR BCc (ng/cm^{3}) (880 nm)"
84
+ }
AeroViz/plot/violin.py ADDED
@@ -0,0 +1,79 @@
1
+ import matplotlib.pyplot as plt
2
+ import numpy as np
3
+ import pandas as pd
4
+ from matplotlib.pyplot import Figure, Axes
5
+ from pandas import DataFrame
6
+
7
+ from AeroViz.plot.utils import *
8
+
9
+ __all__ = ['violin']
10
+
11
+
12
+ @set_figure(fw='bold')
13
+ def violin(data_set: DataFrame | dict,
14
+ unit: str,
15
+ ax: Axes | None = None,
16
+ **kwargs
17
+ ) -> tuple[Figure, Axes]:
18
+ """
19
+ Generate a violin plot for multiple data sets.
20
+
21
+ Parameters
22
+ ----------
23
+ data_set : pd.DataFrame or dict
24
+ A mapping from category names to pandas DataFrames containing the data.
25
+ unit : str
26
+ The unit for the data being plotted.
27
+ ax : matplotlib.axes.Axes, optional
28
+ The Axes object to draw the plot onto. If not provided, a new figure will be created.
29
+ **kwargs : dict
30
+ Additional keyword arguments to be passed to the violinplot function.
31
+
32
+ Returns
33
+ -------
34
+ matplotlib.axes.Axes
35
+ The Axes object containing the violin plot.
36
+
37
+ """
38
+ fig, ax = plt.subplots(**kwargs.get('fig_kws', {})) if ax is None else (ax.get_figure(), ax)
39
+
40
+ data = data_set.to_numpy()
41
+
42
+ data = data[~np.isnan(data).any(axis=1)]
43
+
44
+ grps = data.shape[1]
45
+
46
+ width = 0.6
47
+ block = width / 2
48
+ x_position = np.arange(grps)
49
+
50
+ plt.boxplot(data, positions=x_position, widths=0.15,
51
+ showfliers=False, showmeans=True, meanline=False, patch_artist=True,
52
+ capprops=dict(linewidth=0),
53
+ whiskerprops=dict(linewidth=1.5, color='k', alpha=1),
54
+ boxprops=dict(linewidth=1.5, color='k', facecolor='#4778D3', alpha=1),
55
+ meanprops=dict(marker='o', markeredgecolor='black', markerfacecolor='white', markersize=6),
56
+ medianprops=dict(linewidth=1.5, ls='-', color='k', alpha=1))
57
+
58
+ sns.violinplot(data=data, density_norm='area', color='#4778D3', inner=None)
59
+
60
+ for violin, alpha in zip(ax.collections[:], [0.5] * len(ax.collections[:])):
61
+ violin.set_alpha(alpha)
62
+ violin.set_edgecolor(None)
63
+
64
+ plt.scatter(x_position, data.mean(), marker='o', facecolor='white', edgecolor='k', s=10)
65
+
66
+ xlim = kwargs.get('xlim') or (x_position[0] - (width / 2 + block), x_position[-1] + (width / 2 + block))
67
+ ylim = kwargs.get('ylim') or (0, None)
68
+ xlabel = kwargs.get('xlabel') or ''
69
+ ylabel = kwargs.get('ylabel') or Unit(unit)
70
+ xticks = kwargs.get('xticks') or [x.replace('-', '\n') for x in list(data_set.keys())]
71
+
72
+ ax.set(xlim=xlim, ylim=ylim, xlabel=xlabel, ylabel=ylabel, title=kwargs.get('title'))
73
+ ax.set_xticks(x_position, xticks, fontweight='bold', fontsize=12)
74
+
75
+ # fig.savefig(f'Violin_{unit}')
76
+
77
+ plt.show()
78
+
79
+ return fig, ax