disdrodb 0.0.20__py3-none-any.whl → 0.1.0__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.
Files changed (264) hide show
  1. disdrodb/__init__.py +132 -15
  2. disdrodb/_config.py +4 -2
  3. disdrodb/_version.py +9 -4
  4. disdrodb/api/checks.py +264 -237
  5. disdrodb/api/configs.py +4 -8
  6. disdrodb/api/create_directories.py +235 -290
  7. disdrodb/api/info.py +217 -26
  8. disdrodb/api/io.py +295 -269
  9. disdrodb/api/path.py +597 -173
  10. disdrodb/api/search.py +486 -0
  11. disdrodb/{metadata/scripts → cli}/disdrodb_check_metadata_archive.py +12 -7
  12. disdrodb/{utils/pandas.py → cli/disdrodb_data_archive_directory.py} +9 -18
  13. disdrodb/cli/disdrodb_download_archive.py +86 -0
  14. disdrodb/cli/disdrodb_download_metadata_archive.py +53 -0
  15. disdrodb/cli/disdrodb_download_station.py +84 -0
  16. disdrodb/{api/scripts → cli}/disdrodb_initialize_station.py +22 -10
  17. disdrodb/cli/disdrodb_metadata_archive_directory.py +32 -0
  18. disdrodb/{data_transfer/scripts/disdrodb_download_station.py → cli/disdrodb_open_data_archive.py} +22 -22
  19. disdrodb/cli/disdrodb_open_logs_directory.py +69 -0
  20. disdrodb/{data_transfer/scripts/disdrodb_upload_station.py → cli/disdrodb_open_metadata_archive.py} +22 -24
  21. disdrodb/cli/disdrodb_open_metadata_directory.py +71 -0
  22. disdrodb/cli/disdrodb_open_product_directory.py +74 -0
  23. disdrodb/cli/disdrodb_open_readers_directory.py +32 -0
  24. disdrodb/{l0/scripts → cli}/disdrodb_run_l0.py +38 -31
  25. disdrodb/{l0/scripts → cli}/disdrodb_run_l0_station.py +32 -30
  26. disdrodb/{l0/scripts → cli}/disdrodb_run_l0a.py +30 -21
  27. disdrodb/{l0/scripts → cli}/disdrodb_run_l0a_station.py +24 -33
  28. disdrodb/{l0/scripts → cli}/disdrodb_run_l0b.py +30 -21
  29. disdrodb/{l0/scripts → cli}/disdrodb_run_l0b_station.py +25 -34
  30. disdrodb/cli/disdrodb_run_l0c.py +130 -0
  31. disdrodb/cli/disdrodb_run_l0c_station.py +129 -0
  32. disdrodb/cli/disdrodb_run_l1.py +122 -0
  33. disdrodb/cli/disdrodb_run_l1_station.py +121 -0
  34. disdrodb/cli/disdrodb_run_l2e.py +122 -0
  35. disdrodb/cli/disdrodb_run_l2e_station.py +122 -0
  36. disdrodb/cli/disdrodb_run_l2m.py +122 -0
  37. disdrodb/cli/disdrodb_run_l2m_station.py +122 -0
  38. disdrodb/cli/disdrodb_upload_archive.py +105 -0
  39. disdrodb/cli/disdrodb_upload_station.py +98 -0
  40. disdrodb/configs.py +90 -25
  41. disdrodb/data_transfer/__init__.py +22 -0
  42. disdrodb/data_transfer/download_data.py +87 -90
  43. disdrodb/data_transfer/upload_data.py +64 -37
  44. disdrodb/data_transfer/zenodo.py +15 -18
  45. disdrodb/docs.py +1 -1
  46. disdrodb/issue/__init__.py +17 -4
  47. disdrodb/issue/checks.py +10 -23
  48. disdrodb/issue/reader.py +9 -12
  49. disdrodb/issue/writer.py +14 -17
  50. disdrodb/l0/__init__.py +17 -26
  51. disdrodb/l0/check_configs.py +35 -23
  52. disdrodb/l0/check_standards.py +32 -42
  53. disdrodb/l0/configs/{Thies_LPM → LPM}/bins_diameter.yml +44 -44
  54. disdrodb/l0/configs/{Thies_LPM → LPM}/bins_velocity.yml +40 -40
  55. disdrodb/l0/configs/LPM/l0a_encodings.yml +80 -0
  56. disdrodb/l0/configs/{Thies_LPM → LPM}/l0b_cf_attrs.yml +62 -59
  57. disdrodb/l0/configs/{Thies_LPM → LPM}/l0b_encodings.yml +9 -9
  58. disdrodb/l0/configs/{Thies_LPM → LPM}/raw_data_format.yml +245 -245
  59. disdrodb/l0/configs/{OTT_Parsivel → PARSIVEL}/bins_diameter.yml +66 -66
  60. disdrodb/l0/configs/{OTT_Parsivel → PARSIVEL}/bins_velocity.yml +64 -64
  61. disdrodb/l0/configs/PARSIVEL/l0a_encodings.yml +32 -0
  62. disdrodb/l0/configs/{OTT_Parsivel → PARSIVEL}/l0b_cf_attrs.yml +22 -20
  63. disdrodb/l0/configs/{OTT_Parsivel → PARSIVEL}/l0b_encodings.yml +17 -17
  64. disdrodb/l0/configs/{OTT_Parsivel → PARSIVEL}/raw_data_format.yml +77 -77
  65. disdrodb/l0/configs/{OTT_Parsivel2 → PARSIVEL2}/bins_diameter.yml +64 -64
  66. disdrodb/l0/configs/{OTT_Parsivel2 → PARSIVEL2}/bins_velocity.yml +64 -64
  67. disdrodb/l0/configs/PARSIVEL2/l0a_encodings.yml +39 -0
  68. disdrodb/l0/configs/{OTT_Parsivel2 → PARSIVEL2}/l0b_cf_attrs.yml +24 -22
  69. disdrodb/l0/configs/{OTT_Parsivel2 → PARSIVEL2}/l0b_encodings.yml +20 -20
  70. disdrodb/l0/configs/{OTT_Parsivel2 → PARSIVEL2}/raw_data_format.yml +98 -98
  71. disdrodb/l0/configs/{RD_80 → RD80}/bins_diameter.yml +40 -40
  72. disdrodb/l0/configs/RD80/l0a_encodings.yml +16 -0
  73. disdrodb/l0/configs/{RD_80 → RD80}/l0b_cf_attrs.yml +3 -3
  74. disdrodb/l0/configs/RD80/l0b_encodings.yml +135 -0
  75. disdrodb/l0/configs/{RD_80 → RD80}/raw_data_format.yml +48 -48
  76. disdrodb/l0/l0_reader.py +216 -340
  77. disdrodb/l0/l0a_processing.py +237 -208
  78. disdrodb/l0/l0b_nc_processing.py +227 -80
  79. disdrodb/l0/l0b_processing.py +93 -173
  80. disdrodb/l0/l0c_processing.py +627 -0
  81. disdrodb/l0/readers/{ARM → LPM/ARM}/ARM_LPM.py +36 -58
  82. disdrodb/l0/readers/LPM/AUSTRALIA/MELBOURNE_2007_LPM.py +226 -0
  83. disdrodb/l0/readers/LPM/BRAZIL/CHUVA_LPM.py +185 -0
  84. disdrodb/l0/readers/LPM/BRAZIL/GOAMAZON_LPM.py +183 -0
  85. disdrodb/l0/readers/LPM/ITALY/GID_LPM.py +179 -0
  86. disdrodb/l0/readers/{UK → LPM/UK}/DIVEN.py +14 -35
  87. disdrodb/l0/readers/PARSIVEL/AUSTRALIA/MELBOURNE_2007_PARSIVEL.py +157 -0
  88. disdrodb/l0/readers/PARSIVEL/CHINA/CHONGQING.py +113 -0
  89. disdrodb/l0/readers/{EPFL → PARSIVEL/EPFL}/ARCTIC_2021.py +40 -57
  90. disdrodb/l0/readers/{EPFL → PARSIVEL/EPFL}/COMMON_2011.py +37 -54
  91. disdrodb/l0/readers/{EPFL → PARSIVEL/EPFL}/DAVOS_2009_2011.py +34 -51
  92. disdrodb/l0/readers/{EPFL → PARSIVEL/EPFL}/EPFL_2009.py +34 -51
  93. disdrodb/l0/readers/{EPFL/PARADISO_2014.py → PARSIVEL/EPFL/EPFL_ROOF_2008.py} +38 -50
  94. disdrodb/l0/readers/PARSIVEL/EPFL/EPFL_ROOF_2010.py +105 -0
  95. disdrodb/l0/readers/{EPFL → PARSIVEL/EPFL}/EPFL_ROOF_2011.py +34 -51
  96. disdrodb/l0/readers/{EPFL → PARSIVEL/EPFL}/EPFL_ROOF_2012.py +33 -51
  97. disdrodb/l0/readers/{EPFL → PARSIVEL/EPFL}/GENEPI_2007.py +25 -44
  98. disdrodb/l0/readers/{EPFL → PARSIVEL/EPFL}/GRAND_ST_BERNARD_2007.py +25 -44
  99. disdrodb/l0/readers/{EPFL → PARSIVEL/EPFL}/GRAND_ST_BERNARD_2007_2.py +25 -44
  100. disdrodb/l0/readers/{EPFL → PARSIVEL/EPFL}/HPICONET_2010.py +34 -51
  101. disdrodb/l0/readers/{EPFL/EPFL_ROOF_2010.py → PARSIVEL/EPFL/HYMEX_LTE_SOP2.py} +37 -50
  102. disdrodb/l0/readers/PARSIVEL/EPFL/HYMEX_LTE_SOP3.py +111 -0
  103. disdrodb/l0/readers/{EPFL → PARSIVEL/EPFL}/HYMEX_LTE_SOP4.py +36 -54
  104. disdrodb/l0/readers/{EPFL → PARSIVEL/EPFL}/LOCARNO_2018.py +34 -52
  105. disdrodb/l0/readers/{EPFL → PARSIVEL/EPFL}/LOCARNO_2019.py +38 -56
  106. disdrodb/l0/readers/PARSIVEL/EPFL/PARADISO_2014.py +105 -0
  107. disdrodb/l0/readers/{EPFL → PARSIVEL/EPFL}/PARSIVEL_2007.py +27 -45
  108. disdrodb/l0/readers/{EPFL → PARSIVEL/EPFL}/PLATO_2019.py +24 -44
  109. disdrodb/l0/readers/PARSIVEL/EPFL/RACLETS_2019.py +140 -0
  110. disdrodb/l0/readers/{EPFL → PARSIVEL/EPFL}/RACLETS_2019_WJF.py +41 -59
  111. disdrodb/l0/readers/{EPFL → PARSIVEL/EPFL}/RIETHOLZBACH_2011.py +34 -51
  112. disdrodb/l0/readers/PARSIVEL/EPFL/SAMOYLOV_2017.py +117 -0
  113. disdrodb/l0/readers/PARSIVEL/EPFL/SAMOYLOV_2019.py +137 -0
  114. disdrodb/l0/readers/{EPFL → PARSIVEL/EPFL}/UNIL_2022.py +42 -55
  115. disdrodb/l0/readers/PARSIVEL/GPM/IFLOODS.py +104 -0
  116. disdrodb/l0/readers/{GPM → PARSIVEL/GPM}/LPVEX.py +29 -48
  117. disdrodb/l0/readers/PARSIVEL/GPM/MC3E.py +184 -0
  118. disdrodb/l0/readers/PARSIVEL/NCAR/CCOPE_2015.py +113 -0
  119. disdrodb/l0/readers/{NCAR/VORTEX_SE_2016_P1.py → PARSIVEL/NCAR/OWLES_MIPS.py} +46 -72
  120. disdrodb/l0/readers/PARSIVEL/NCAR/PECAN_MOBILE.py +125 -0
  121. disdrodb/l0/readers/{NCAR/OWLES_MIPS.py → PARSIVEL/NCAR/PLOWS_MIPS.py} +45 -64
  122. disdrodb/l0/readers/PARSIVEL/NCAR/VORTEX2_2009.py +114 -0
  123. disdrodb/l0/readers/PARSIVEL/NCAR/VORTEX2_2010.py +176 -0
  124. disdrodb/l0/readers/PARSIVEL/NCAR/VORTEX2_2010_UF.py +183 -0
  125. disdrodb/l0/readers/{ARM/ARM_LD.py → PARSIVEL2/ARM/ARM_PARSIVEL2.py} +27 -50
  126. disdrodb/l0/readers/PARSIVEL2/BRAZIL/CHUVA_PARSIVEL2.py +163 -0
  127. disdrodb/l0/readers/PARSIVEL2/BRAZIL/GOAMAZON_PARSIVEL2.py +163 -0
  128. disdrodb/l0/readers/{DENMARK → PARSIVEL2/DENMARK}/EROSION_nc.py +14 -35
  129. disdrodb/l0/readers/PARSIVEL2/FRANCE/SIRTA_PARSIVEL2.py +119 -0
  130. disdrodb/l0/readers/PARSIVEL2/GPM/GCPEX.py +104 -0
  131. disdrodb/l0/readers/PARSIVEL2/GPM/NSSTC.py +176 -0
  132. disdrodb/l0/readers/PARSIVEL2/ITALY/GID_PARSIVEL2.py +32 -0
  133. disdrodb/l0/readers/PARSIVEL2/MEXICO/OH_IIUNAM_nc.py +56 -0
  134. disdrodb/l0/readers/PARSIVEL2/NCAR/PECAN_FP3.py +120 -0
  135. disdrodb/l0/readers/{NCAR → PARSIVEL2/NCAR}/PECAN_MIPS.py +45 -64
  136. disdrodb/l0/readers/PARSIVEL2/NCAR/RELAMPAGO_PARSIVEL2.py +181 -0
  137. disdrodb/l0/readers/PARSIVEL2/NCAR/SNOWIE_PJ.py +160 -0
  138. disdrodb/l0/readers/PARSIVEL2/NCAR/SNOWIE_SB.py +160 -0
  139. disdrodb/l0/readers/{NCAR/PLOWS_MIPS.py → PARSIVEL2/NCAR/VORTEX_SE_2016_P1.py} +49 -66
  140. disdrodb/l0/readers/PARSIVEL2/NCAR/VORTEX_SE_2016_P2.py +118 -0
  141. disdrodb/l0/readers/PARSIVEL2/NCAR/VORTEX_SE_2016_PIPS.py +152 -0
  142. disdrodb/l0/readers/PARSIVEL2/NETHERLANDS/DELFT.py +166 -0
  143. disdrodb/l0/readers/{NCAR/RELAMPAGO_RD80.py → RD80/BRAZIL/CHUVA_RD80.py} +36 -60
  144. disdrodb/l0/readers/{BRAZIL → RD80/BRAZIL}/GOAMAZON_RD80.py +36 -55
  145. disdrodb/l0/readers/{NCAR → RD80/NCAR}/CINDY_2011_RD80.py +35 -54
  146. disdrodb/l0/readers/{BRAZIL/CHUVA_RD80.py → RD80/NCAR/RELAMPAGO_RD80.py} +40 -54
  147. disdrodb/l0/readers/template_reader_raw_netcdf_data.py +62 -0
  148. disdrodb/l0/readers/{reader_template.py → template_reader_raw_text_data.py} +20 -44
  149. disdrodb/l0/routines.py +885 -581
  150. disdrodb/l0/standards.py +72 -236
  151. disdrodb/l0/template_tools.py +104 -109
  152. disdrodb/l1/__init__.py +17 -0
  153. disdrodb/l1/beard_model.py +716 -0
  154. disdrodb/l1/encoding_attrs.py +620 -0
  155. disdrodb/l1/fall_velocity.py +260 -0
  156. disdrodb/l1/filters.py +192 -0
  157. disdrodb/l1/processing.py +200 -0
  158. disdrodb/l1/resampling.py +236 -0
  159. disdrodb/l1/routines.py +357 -0
  160. disdrodb/l1_env/__init__.py +17 -0
  161. disdrodb/l1_env/routines.py +38 -0
  162. disdrodb/l2/__init__.py +17 -0
  163. disdrodb/l2/empirical_dsd.py +1735 -0
  164. disdrodb/l2/event.py +388 -0
  165. disdrodb/l2/processing.py +519 -0
  166. disdrodb/l2/processing_options.py +213 -0
  167. disdrodb/l2/routines.py +868 -0
  168. disdrodb/metadata/__init__.py +9 -2
  169. disdrodb/metadata/checks.py +165 -118
  170. disdrodb/metadata/download.py +81 -0
  171. disdrodb/metadata/geolocation.py +146 -0
  172. disdrodb/metadata/info.py +20 -13
  173. disdrodb/metadata/manipulation.py +1 -1
  174. disdrodb/metadata/reader.py +59 -8
  175. disdrodb/metadata/search.py +77 -144
  176. disdrodb/metadata/standards.py +7 -8
  177. disdrodb/metadata/writer.py +8 -14
  178. disdrodb/psd/__init__.py +38 -0
  179. disdrodb/psd/fitting.py +2146 -0
  180. disdrodb/psd/models.py +774 -0
  181. disdrodb/routines.py +1176 -0
  182. disdrodb/scattering/__init__.py +28 -0
  183. disdrodb/scattering/axis_ratio.py +344 -0
  184. disdrodb/scattering/routines.py +456 -0
  185. disdrodb/utils/__init__.py +17 -0
  186. disdrodb/utils/attrs.py +208 -0
  187. disdrodb/utils/cli.py +269 -0
  188. disdrodb/utils/compression.py +60 -42
  189. disdrodb/utils/dask.py +62 -0
  190. disdrodb/utils/decorators.py +110 -0
  191. disdrodb/utils/directories.py +107 -46
  192. disdrodb/utils/encoding.py +127 -0
  193. disdrodb/utils/list.py +29 -0
  194. disdrodb/utils/logger.py +168 -46
  195. disdrodb/utils/time.py +657 -0
  196. disdrodb/utils/warnings.py +30 -0
  197. disdrodb/utils/writer.py +57 -0
  198. disdrodb/utils/xarray.py +138 -47
  199. disdrodb/utils/yaml.py +0 -1
  200. disdrodb/viz/__init__.py +17 -0
  201. disdrodb/viz/plots.py +17 -0
  202. disdrodb-0.1.0.dist-info/METADATA +321 -0
  203. disdrodb-0.1.0.dist-info/RECORD +216 -0
  204. {disdrodb-0.0.20.dist-info → disdrodb-0.1.0.dist-info}/WHEEL +1 -1
  205. disdrodb-0.1.0.dist-info/entry_points.txt +30 -0
  206. disdrodb/data_transfer/scripts/disdrodb_download_archive.py +0 -53
  207. disdrodb/data_transfer/scripts/disdrodb_upload_archive.py +0 -57
  208. disdrodb/l0/configs/OTT_Parsivel/l0a_encodings.yml +0 -32
  209. disdrodb/l0/configs/OTT_Parsivel2/l0a_encodings.yml +0 -39
  210. disdrodb/l0/configs/RD_80/l0a_encodings.yml +0 -16
  211. disdrodb/l0/configs/RD_80/l0b_encodings.yml +0 -135
  212. disdrodb/l0/configs/Thies_LPM/l0a_encodings.yml +0 -80
  213. disdrodb/l0/io.py +0 -257
  214. disdrodb/l0/l0_processing.py +0 -1091
  215. disdrodb/l0/readers/AUSTRALIA/MELBOURNE_2007_OTT.py +0 -178
  216. disdrodb/l0/readers/AUSTRALIA/MELBOURNE_2007_THIES.py +0 -247
  217. disdrodb/l0/readers/BRAZIL/CHUVA_LPM.py +0 -204
  218. disdrodb/l0/readers/BRAZIL/CHUVA_OTT.py +0 -183
  219. disdrodb/l0/readers/BRAZIL/GOAMAZON_LPM.py +0 -204
  220. disdrodb/l0/readers/BRAZIL/GOAMAZON_OTT.py +0 -183
  221. disdrodb/l0/readers/CHINA/CHONGQING.py +0 -131
  222. disdrodb/l0/readers/EPFL/EPFL_ROOF_2008.py +0 -128
  223. disdrodb/l0/readers/EPFL/HYMEX_LTE_SOP2.py +0 -127
  224. disdrodb/l0/readers/EPFL/HYMEX_LTE_SOP3.py +0 -129
  225. disdrodb/l0/readers/EPFL/RACLETS_2019.py +0 -158
  226. disdrodb/l0/readers/EPFL/SAMOYLOV_2017.py +0 -136
  227. disdrodb/l0/readers/EPFL/SAMOYLOV_2019.py +0 -158
  228. disdrodb/l0/readers/FRANCE/SIRTA_OTT2.py +0 -138
  229. disdrodb/l0/readers/GPM/GCPEX.py +0 -123
  230. disdrodb/l0/readers/GPM/IFLOODS.py +0 -123
  231. disdrodb/l0/readers/GPM/MC3E.py +0 -123
  232. disdrodb/l0/readers/GPM/NSSTC.py +0 -164
  233. disdrodb/l0/readers/ITALY/GID.py +0 -199
  234. disdrodb/l0/readers/MEXICO/OH_IIUNAM_nc.py +0 -92
  235. disdrodb/l0/readers/NCAR/CCOPE_2015.py +0 -133
  236. disdrodb/l0/readers/NCAR/PECAN_FP3.py +0 -137
  237. disdrodb/l0/readers/NCAR/PECAN_MOBILE.py +0 -144
  238. disdrodb/l0/readers/NCAR/RELAMPAGO_OTT.py +0 -195
  239. disdrodb/l0/readers/NCAR/SNOWIE_PJ.py +0 -172
  240. disdrodb/l0/readers/NCAR/SNOWIE_SB.py +0 -179
  241. disdrodb/l0/readers/NCAR/VORTEX2_2009.py +0 -133
  242. disdrodb/l0/readers/NCAR/VORTEX2_2010.py +0 -188
  243. disdrodb/l0/readers/NCAR/VORTEX2_2010_UF.py +0 -191
  244. disdrodb/l0/readers/NCAR/VORTEX_SE_2016_P2.py +0 -135
  245. disdrodb/l0/readers/NCAR/VORTEX_SE_2016_PIPS.py +0 -170
  246. disdrodb/l0/readers/NETHERLANDS/DELFT.py +0 -187
  247. disdrodb/l0/readers/SPAIN/SBEGUERIA.py +0 -179
  248. disdrodb/l0/scripts/disdrodb_run_l0b_concat.py +0 -93
  249. disdrodb/l0/scripts/disdrodb_run_l0b_concat_station.py +0 -85
  250. disdrodb/utils/netcdf.py +0 -452
  251. disdrodb/utils/scripts.py +0 -102
  252. disdrodb-0.0.20.dist-info/AUTHORS.md +0 -18
  253. disdrodb-0.0.20.dist-info/METADATA +0 -186
  254. disdrodb-0.0.20.dist-info/RECORD +0 -168
  255. disdrodb-0.0.20.dist-info/entry_points.txt +0 -15
  256. /disdrodb/l0/configs/{RD_80 → RD80}/bins_velocity.yml +0 -0
  257. /disdrodb/l0/manuals/{Thies_LPM.pdf → LPM.pdf} +0 -0
  258. /disdrodb/l0/manuals/{ODM_470.pdf → ODM470.pdf} +0 -0
  259. /disdrodb/l0/manuals/{OTT_Parsivel.pdf → PARSIVEL.pdf} +0 -0
  260. /disdrodb/l0/manuals/{OTT_Parsivel2.pdf → PARSIVEL2.pdf} +0 -0
  261. /disdrodb/l0/manuals/{PWS_100.pdf → PWS100.pdf} +0 -0
  262. /disdrodb/l0/manuals/{RD_80.pdf → RD80.pdf} +0 -0
  263. {disdrodb-0.0.20.dist-info → disdrodb-0.1.0.dist-info/licenses}/LICENSE +0 -0
  264. {disdrodb-0.0.20.dist-info → disdrodb-0.1.0.dist-info}/top_level.txt +0 -0
disdrodb/routines.py ADDED
@@ -0,0 +1,1176 @@
1
+ # -----------------------------------------------------------------------------.
2
+ # Copyright (c) 2021-2023 DISDRODB developers
3
+ #
4
+ # This program is free software: you can redistribute it and/or modify
5
+ # it under the terms of the GNU General Public License as published by
6
+ # the Free Software Foundation, either version 3 of the License, or
7
+ # (at your option) any later version.
8
+ #
9
+ # This program is distributed in the hope that it will be useful,
10
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+ # GNU General Public License for more details.
13
+ #
14
+ # You should have received a copy of the GNU General Public License
15
+ # along with this program. If not, see <http://www.gnu.org/licenses/>.
16
+ # -----------------------------------------------------------------------------.
17
+ """DISDRODB CLI routine wrappers."""
18
+ import datetime
19
+ import time
20
+ from typing import Optional
21
+
22
+ from disdrodb.api.search import available_stations, get_required_product
23
+ from disdrodb.utils.cli import _execute_cmd
24
+
25
+ ####--------------------------------------------------------------------------.
26
+ #### Run DISDRODB Station Processing
27
+
28
+
29
+ def run_l0_station(
30
+ data_source,
31
+ campaign_name,
32
+ station_name,
33
+ # L0 archive options
34
+ l0a_processing: bool = True,
35
+ l0b_processing: bool = True,
36
+ l0c_processing: bool = True,
37
+ remove_l0a: bool = False,
38
+ remove_l0b: bool = False,
39
+ # Processing options
40
+ force: bool = False,
41
+ verbose: bool = False,
42
+ debugging_mode: bool = False,
43
+ parallel: bool = True,
44
+ # DISDRODB root directories
45
+ data_archive_dir: Optional[str] = None,
46
+ metadata_archive_dir: Optional[str] = None,
47
+ ):
48
+ """Run the L0 processing of a specific DISDRODB station from the terminal.
49
+
50
+ Parameters
51
+ ----------
52
+ data_source : str
53
+ Institution name (when campaign data spans more than 1 country),
54
+ or country (when all campaigns (or sensor networks) are inside a given country).
55
+ Must be UPPER CASE.
56
+ campaign_name : str
57
+ Campaign name. Must be UPPER CASE.
58
+ station_name : str
59
+ Station name
60
+ l0a_processing : bool
61
+ Whether to launch processing to generate L0A Apache Parquet file(s) from raw data.
62
+ The default value is ``True``.
63
+ l0b_processing : bool
64
+ Whether to launch processing to generate L0B netCDF4 file(s) from L0A data.
65
+ The default value is ``True``.
66
+ l0b_processing : bool
67
+ Whether to launch processing to generate L0C netCDF4 file(s) from L0B data.
68
+ The default value is ``True``.
69
+ l0c_processing : bool
70
+ Whether to launch processing to generate L0C netCDF4 file(s) from L0C data.
71
+ The default is True.
72
+ remove_l0a : bool
73
+ Whether to keep the L0A files after having generated the L0B netCDF products.
74
+ The default value is ``False``.
75
+ remove_l0b : bool
76
+ Whether to remove the L0B files after having produced L0C netCDF files.
77
+ The default is False.
78
+ force : bool
79
+ If ``True``, overwrite existing data into destination directories.
80
+ If ``False``, raise an error if there are already data into destination directories.
81
+ The default value is ``False``.
82
+ verbose : bool
83
+ Whether to print detailed processing information into terminal.
84
+ The default value is ``True``.
85
+ parallel : bool
86
+ If ``True``, the files are processed simultaneously in multiple processes.
87
+ Each process will use a single thread to avoid issues with the HDF/netCDF library.
88
+ By default, the number of process is defined with ``os.cpu_count()``.
89
+ If ``False``, the files are processed sequentially in a single process.
90
+ If ``False``, multi-threading is automatically exploited to speed up I/0 tasks.
91
+ debugging_mode : bool
92
+ If ``True``, it reduces the amount of data to process.
93
+ For L0A, it processes just the first 3 raw data files for each station.
94
+ For L0B, it processes just the first 100 rows of 3 L0A files for each station.
95
+ The default value is ``False``.
96
+ data_archive_dir : str (optional)
97
+ The directory path where the DISDRODB Data Archive is located.
98
+ The directory path must end with ``<...>/DISDRODB``.
99
+ If ``None``, it uses the ``data_archive_dir`` path specified
100
+ in the DISDRODB active configuration.
101
+ """
102
+ # ---------------------------------------------------------------------.
103
+ t_i = time.time()
104
+ print(f"L0 processing of station {station_name} has started.")
105
+
106
+ # ------------------------------------------------------------------.
107
+ # L0A processing
108
+ if l0a_processing:
109
+ run_l0a_station(
110
+ # DISDRODB root directories
111
+ data_archive_dir=data_archive_dir,
112
+ metadata_archive_dir=metadata_archive_dir,
113
+ # Station arguments
114
+ data_source=data_source,
115
+ campaign_name=campaign_name,
116
+ station_name=station_name,
117
+ # Processing options
118
+ force=force,
119
+ verbose=verbose,
120
+ debugging_mode=debugging_mode,
121
+ parallel=parallel,
122
+ )
123
+ # ------------------------------------------------------------------.
124
+ # L0B processing
125
+ if l0b_processing:
126
+ run_l0b_station(
127
+ # DISDRODB root directories
128
+ data_archive_dir=data_archive_dir,
129
+ metadata_archive_dir=metadata_archive_dir,
130
+ # Station arguments
131
+ data_source=data_source,
132
+ campaign_name=campaign_name,
133
+ station_name=station_name,
134
+ # L0B processing options
135
+ remove_l0a=remove_l0a,
136
+ # Processing options
137
+ force=force,
138
+ verbose=verbose,
139
+ debugging_mode=debugging_mode,
140
+ parallel=parallel,
141
+ )
142
+
143
+ # ------------------------------------------------------------------.
144
+ # L0C processing
145
+ if l0c_processing:
146
+ run_l0c_station(
147
+ # DISDRODB root directories
148
+ data_archive_dir=data_archive_dir,
149
+ metadata_archive_dir=metadata_archive_dir,
150
+ # Station arguments
151
+ data_source=data_source,
152
+ campaign_name=campaign_name,
153
+ station_name=station_name,
154
+ # L0C processing options
155
+ remove_l0b=remove_l0b,
156
+ # Processing options
157
+ force=force,
158
+ verbose=verbose,
159
+ debugging_mode=debugging_mode,
160
+ parallel=parallel,
161
+ )
162
+
163
+ # -------------------------------------------------------------------------.
164
+ # End of L0 processing for all stations
165
+ timedelta_str = str(datetime.timedelta(seconds=round(time.time() - t_i)))
166
+ print(f"L0 processing of stations {station_name} completed in {timedelta_str}")
167
+
168
+
169
+ def run_l0a_station(
170
+ # Station arguments
171
+ data_source,
172
+ campaign_name,
173
+ station_name,
174
+ # Processing options
175
+ force: bool = False,
176
+ verbose: bool = False,
177
+ debugging_mode: bool = False,
178
+ parallel: bool = True,
179
+ # DISDRODB root directories
180
+ data_archive_dir: Optional[str] = None,
181
+ metadata_archive_dir: Optional[str] = None,
182
+ ):
183
+ """Run the L0A processing of a station calling the disdrodb_l0a_station in the terminal."""
184
+ # Define command
185
+ cmd = " ".join(
186
+ [
187
+ "disdrodb_run_l0a_station",
188
+ # Station arguments
189
+ data_source,
190
+ campaign_name,
191
+ station_name,
192
+ # DISDRODB root directories
193
+ "--data_archive_dir",
194
+ str(data_archive_dir),
195
+ "--metadata_archive_dir",
196
+ str(metadata_archive_dir),
197
+ # Processing options
198
+ "--force",
199
+ str(force),
200
+ "--verbose",
201
+ str(verbose),
202
+ "--debugging_mode",
203
+ str(debugging_mode),
204
+ "--parallel",
205
+ str(parallel),
206
+ ],
207
+ )
208
+ # Execute command
209
+ _execute_cmd(cmd)
210
+
211
+
212
+ def run_l0b_station(
213
+ # Station arguments
214
+ data_source,
215
+ campaign_name,
216
+ station_name,
217
+ # L0B processing options
218
+ remove_l0a: bool = False,
219
+ # Processing options
220
+ force: bool = False,
221
+ verbose: bool = False,
222
+ debugging_mode: bool = False,
223
+ parallel: bool = True,
224
+ # DISDRODB root directories
225
+ data_archive_dir: Optional[str] = None,
226
+ metadata_archive_dir: Optional[str] = None,
227
+ ):
228
+ """Run the L0B processing of a station calling disdrodb_run_l0b_station in the terminal."""
229
+ # Define command
230
+ cmd = " ".join(
231
+ [
232
+ "disdrodb_run_l0b_station",
233
+ # Station arguments
234
+ data_source,
235
+ campaign_name,
236
+ station_name,
237
+ # DISDRODB root directories
238
+ "--data_archive_dir",
239
+ str(data_archive_dir),
240
+ "--metadata_archive_dir",
241
+ str(metadata_archive_dir),
242
+ # L0B processing options
243
+ "--remove_l0a",
244
+ str(remove_l0a),
245
+ # Processing options
246
+ "--force",
247
+ str(force),
248
+ "--verbose",
249
+ str(verbose),
250
+ "--debugging_mode",
251
+ str(debugging_mode),
252
+ "--parallel",
253
+ str(parallel),
254
+ ],
255
+ )
256
+ # Execute command
257
+ _execute_cmd(cmd)
258
+
259
+
260
+ def run_l0c_station(
261
+ # Station arguments
262
+ data_source,
263
+ campaign_name,
264
+ station_name,
265
+ # L0C options
266
+ remove_l0b: bool = False,
267
+ # Processing options
268
+ force: bool = False,
269
+ verbose: bool = False,
270
+ debugging_mode: bool = False,
271
+ parallel: bool = True,
272
+ # DISDRODB root directories
273
+ data_archive_dir: Optional[str] = None,
274
+ metadata_archive_dir: Optional[str] = None,
275
+ ):
276
+ """Run the L0C processing of a station calling the disdrodb_l0c_station in the terminal."""
277
+ # TODO: implement remove_l0b!
278
+
279
+ # Define command
280
+ cmd = " ".join(
281
+ [
282
+ "disdrodb_run_l0c_station",
283
+ # Station arguments
284
+ data_source,
285
+ campaign_name,
286
+ station_name,
287
+ # DISDRODB root directories
288
+ "--data_archive_dir",
289
+ str(data_archive_dir),
290
+ "--metadata_archive_dir",
291
+ str(metadata_archive_dir),
292
+ # L0C processing options
293
+ "--remove_l0b",
294
+ str(remove_l0b),
295
+ # Processing options
296
+ "--force",
297
+ str(force),
298
+ "--verbose",
299
+ str(verbose),
300
+ "--debugging_mode",
301
+ str(debugging_mode),
302
+ "--parallel",
303
+ str(parallel),
304
+ ],
305
+ )
306
+ # Execute command
307
+ _execute_cmd(cmd)
308
+
309
+
310
+ def run_l1_station(
311
+ # Station arguments
312
+ data_source,
313
+ campaign_name,
314
+ station_name,
315
+ # Processing options
316
+ force: bool = False,
317
+ verbose: bool = False,
318
+ debugging_mode: bool = False,
319
+ parallel: bool = True,
320
+ # DISDRODB root directories
321
+ data_archive_dir: Optional[str] = None,
322
+ metadata_archive_dir: Optional[str] = None,
323
+ ):
324
+ """Run the L1 processing of a station calling the disdrodb_l1_station in the terminal."""
325
+ # Define command
326
+ cmd = " ".join(
327
+ [
328
+ "disdrodb_run_l1_station",
329
+ # Station arguments
330
+ data_source,
331
+ campaign_name,
332
+ station_name,
333
+ # DISDRODB root directories
334
+ "--data_archive_dir",
335
+ str(data_archive_dir),
336
+ "--metadata_archive_dir",
337
+ str(metadata_archive_dir),
338
+ # Processing options
339
+ "--force",
340
+ str(force),
341
+ "--verbose",
342
+ str(verbose),
343
+ "--debugging_mode",
344
+ str(debugging_mode),
345
+ "--parallel",
346
+ str(parallel),
347
+ ],
348
+ )
349
+ # Execute command
350
+ _execute_cmd(cmd)
351
+
352
+
353
+ def run_l2e_station(
354
+ # Station arguments
355
+ data_source,
356
+ campaign_name,
357
+ station_name,
358
+ # Processing options
359
+ force: bool = False,
360
+ verbose: bool = False,
361
+ debugging_mode: bool = False,
362
+ parallel: bool = True,
363
+ # DISDRODB root directories
364
+ data_archive_dir: Optional[str] = None,
365
+ metadata_archive_dir: Optional[str] = None,
366
+ ):
367
+ """Run the L2E processing of a station calling the disdrodb_l1_station in the terminal."""
368
+ # Define command
369
+ cmd = " ".join(
370
+ [
371
+ "disdrodb_run_l2e_station",
372
+ # Station arguments
373
+ data_source,
374
+ campaign_name,
375
+ station_name,
376
+ # DISDRODB root directories
377
+ "--data_archive_dir",
378
+ str(data_archive_dir),
379
+ "--metadata_archive_dir",
380
+ str(metadata_archive_dir),
381
+ # Processing options
382
+ "--force",
383
+ str(force),
384
+ "--verbose",
385
+ str(verbose),
386
+ "--debugging_mode",
387
+ str(debugging_mode),
388
+ "--parallel",
389
+ str(parallel),
390
+ ],
391
+ )
392
+ # Execute command
393
+ _execute_cmd(cmd)
394
+
395
+
396
+ def run_l2m_station(
397
+ # Station arguments
398
+ data_source,
399
+ campaign_name,
400
+ station_name,
401
+ # Processing options
402
+ force: bool = False,
403
+ verbose: bool = False,
404
+ debugging_mode: bool = False,
405
+ parallel: bool = True,
406
+ # DISDRODB root directories
407
+ data_archive_dir: Optional[str] = None,
408
+ metadata_archive_dir: Optional[str] = None,
409
+ ):
410
+ """Run the L2M processing of a station calling the disdrodb_l2m_station in the terminal."""
411
+ # Define command
412
+ cmd = " ".join(
413
+ [
414
+ "disdrodb_run_l2m_station",
415
+ # Station arguments
416
+ data_source,
417
+ campaign_name,
418
+ station_name,
419
+ # DISDRODB root directories
420
+ "--data_archive_dir",
421
+ str(data_archive_dir),
422
+ "--metadata_archive_dir",
423
+ str(metadata_archive_dir),
424
+ # Processing options
425
+ "--force",
426
+ str(force),
427
+ "--verbose",
428
+ str(verbose),
429
+ "--debugging_mode",
430
+ str(debugging_mode),
431
+ "--parallel",
432
+ str(parallel),
433
+ ],
434
+ )
435
+ # Execute command
436
+ _execute_cmd(cmd)
437
+
438
+
439
+ ####--------------------------------------------------------------------------.
440
+ #### Run DISDRODB Archive Processing
441
+
442
+
443
+ def run_l0a(
444
+ data_sources=None,
445
+ campaign_names=None,
446
+ station_names=None,
447
+ # Processing options
448
+ force: bool = False,
449
+ verbose: bool = False,
450
+ debugging_mode: bool = False,
451
+ parallel: bool = True,
452
+ # DISDRODB root directories
453
+ data_archive_dir: Optional[str] = None,
454
+ metadata_archive_dir: Optional[str] = None,
455
+ ):
456
+ """Run the L0A processing of DISDRODB stations.
457
+
458
+ This function allows to launch the processing of many DISDRODB stations with a single command.
459
+ From the list of all available DISDRODB stations, it runs the processing of the
460
+ stations matching the provided data_sources, campaign_names and station_names.
461
+
462
+ Parameters
463
+ ----------
464
+ data_sources : list
465
+ Name of data source(s) to process.
466
+ The name(s) must be UPPER CASE.
467
+ If campaign_names and station are not specified, process all stations.
468
+ The default value is ``None``.
469
+ campaign_names : list
470
+ Name of the campaign(s) to process.
471
+ The name(s) must be UPPER CASE.
472
+ The default value is ``None``.
473
+ station_names : list
474
+ Station names to process.
475
+ The default value is ``None``.
476
+ force : bool
477
+ If ``True``, overwrite existing data into destination directories.
478
+ If ``False``, raise an error if there are already data into destination directories.
479
+ The default value is ``False``.
480
+ verbose : bool
481
+ Whether to print detailed processing information into terminal.
482
+ The default value is ``True``.
483
+ parallel : bool
484
+ If ``True``, the files are processed simultaneously in multiple processes.
485
+ By default, the number of process is defined with ``os.cpu_count()``.
486
+ If ``False``, the files are processed sequentially in a single process.
487
+ debugging_mode : bool
488
+ If ``True``, it reduces the amount of data to process.
489
+ For L0A, it processes just the first 3 raw data files.
490
+ The default value is ``False``.
491
+ data_archive_dir : str (optional)
492
+ The directory path where the DISDRODB Data Archive is located.
493
+ The directory path must end with ``<...>/DISDRODB``.
494
+ If ``None``, it uses the ``data_archive_dir`` path specified
495
+ in the DISDRODB active configuration.
496
+ """
497
+ # Define products
498
+ product = "L0A"
499
+ required_product = get_required_product(product)
500
+
501
+ # Get list of available stations
502
+ list_info = available_stations(
503
+ # DISDRODB root directories
504
+ data_archive_dir=data_archive_dir,
505
+ metadata_archive_dir=metadata_archive_dir,
506
+ # Stations arguments
507
+ data_sources=data_sources,
508
+ campaign_names=campaign_names,
509
+ station_names=station_names,
510
+ # Search options
511
+ product=required_product,
512
+ raise_error_if_empty=True,
513
+ )
514
+
515
+ # Print message
516
+ n_stations = len(list_info)
517
+ print(f"{product} processing of {n_stations} stations started.")
518
+
519
+ # Loop over stations
520
+ for data_source, campaign_name, station_name in list_info:
521
+ print(f"{product} processing of {data_source} {campaign_name} {station_name} station started.")
522
+ # Run processing
523
+ run_l0a_station(
524
+ # DISDRODB root directories
525
+ data_archive_dir=data_archive_dir,
526
+ metadata_archive_dir=metadata_archive_dir,
527
+ # Station arguments
528
+ data_source=data_source,
529
+ campaign_name=campaign_name,
530
+ station_name=station_name,
531
+ # Process options
532
+ force=force,
533
+ verbose=verbose,
534
+ debugging_mode=debugging_mode,
535
+ parallel=parallel,
536
+ )
537
+ print(f"{product} processing of {data_source} {campaign_name} {station_name} station ended.")
538
+
539
+
540
+ def run_l0b(
541
+ data_sources=None,
542
+ campaign_names=None,
543
+ station_names=None,
544
+ # L0B processing options
545
+ remove_l0a: bool = False,
546
+ # Processing options
547
+ force: bool = False,
548
+ verbose: bool = False,
549
+ debugging_mode: bool = False,
550
+ parallel: bool = True,
551
+ # DISDRODB root directories
552
+ data_archive_dir: Optional[str] = None,
553
+ metadata_archive_dir: Optional[str] = None,
554
+ ):
555
+ """Run the L0B processing of DISDRODB stations.
556
+
557
+ This function allows to launch the processing of many DISDRODB stations with a single command.
558
+ From the list of all available DISDRODB L0A stations, it runs the processing of the
559
+ stations matching the provided data_sources, campaign_names and station_names.
560
+
561
+ Parameters
562
+ ----------
563
+ data_sources : list
564
+ Name of data source(s) to process.
565
+ The name(s) must be UPPER CASE.
566
+ If campaign_names and station are not specified, process all stations.
567
+ The default value is ``None``.
568
+ campaign_names : list
569
+ Name of the campaign(s) to process.
570
+ The name(s) must be UPPER CASE.
571
+ The default value is ``None``.
572
+ station_names : list
573
+ Station names to process.
574
+ The default value is ``None``.
575
+ remove_l0a : bool
576
+ Whether to keep the L0A files after having generated the L0B netCDF products.
577
+ The default value is ``False``.
578
+ force : bool
579
+ If ``True``, overwrite existing data into destination directories.
580
+ If ``False``, raise an error if there are already data into destination directories.
581
+ The default value is ``False``.
582
+ verbose : bool
583
+ Whether to print detailed processing information into terminal.
584
+ The default value is ``True``.
585
+ parallel : bool
586
+ If ``True``, the files are processed simultaneously in multiple processes.
587
+ By default, the number of process is defined with ``os.cpu_count()``.
588
+ If ``False``, the files are processed sequentially in a single process.
589
+ debugging_mode : bool
590
+ If ``True``, it reduces the amount of data to process.
591
+ For L0B, it processes just the first 100 rows of 3 L0A files.
592
+ The default value is ``False``.
593
+ data_archive_dir : str (optional)
594
+ The directory path where the DISDRODB Data Archive is located.
595
+ The directory path must end with ``<...>/DISDRODB``.
596
+ If ``None``, it uses the ``data_archive_dir`` path specified
597
+ in the DISDRODB active configuration.
598
+ """
599
+ # Define products
600
+ product = "L0B"
601
+ required_product = get_required_product(product)
602
+
603
+ # Get list of available stations
604
+ list_info = available_stations(
605
+ # DISDRODB root directories
606
+ data_archive_dir=data_archive_dir,
607
+ metadata_archive_dir=metadata_archive_dir,
608
+ # Stations arguments
609
+ data_sources=data_sources,
610
+ campaign_names=campaign_names,
611
+ station_names=station_names,
612
+ # Search options
613
+ product=required_product,
614
+ raise_error_if_empty=True,
615
+ )
616
+
617
+ # Print message
618
+ n_stations = len(list_info)
619
+ print(f"{product} processing of {n_stations} stations started.")
620
+
621
+ # Loop over stations
622
+ for data_source, campaign_name, station_name in list_info:
623
+ print(f"{product} processing of {data_source} {campaign_name} {station_name} station started.")
624
+ # Run processing
625
+ run_l0b_station(
626
+ # DISDRODB root directories
627
+ data_archive_dir=data_archive_dir,
628
+ metadata_archive_dir=metadata_archive_dir,
629
+ # Station arguments
630
+ data_source=data_source,
631
+ campaign_name=campaign_name,
632
+ station_name=station_name,
633
+ # L0B options
634
+ remove_l0a=remove_l0a,
635
+ # Process options
636
+ force=force,
637
+ verbose=verbose,
638
+ debugging_mode=debugging_mode,
639
+ parallel=parallel,
640
+ )
641
+ print(f"{product} processing of {data_source} {campaign_name} {station_name} station ended.")
642
+
643
+
644
+ def run_l0c(
645
+ data_sources=None,
646
+ campaign_names=None,
647
+ station_names=None,
648
+ # L0C options
649
+ remove_l0b: bool = False,
650
+ # Processing options
651
+ force: bool = False,
652
+ verbose: bool = False,
653
+ debugging_mode: bool = False,
654
+ parallel: bool = True,
655
+ # DISDRODB root directories
656
+ data_archive_dir: Optional[str] = None,
657
+ metadata_archive_dir: Optional[str] = None,
658
+ ):
659
+ """Run the L0C processing of DISDRODB stations.
660
+
661
+ This function allows to launch the processing of many DISDRODB stations with a single command.
662
+ From the list of all available DISDRODB stations, it runs the processing of the
663
+ stations matching the provided data_sources, campaign_names and station_names.
664
+
665
+ Parameters
666
+ ----------
667
+ data_sources : list
668
+ Name of data source(s) to process.
669
+ The name(s) must be UPPER CASE.
670
+ If campaign_names and station are not specified, process all stations.
671
+ The default value is ``None``.
672
+ campaign_names : list
673
+ Name of the campaign(s) to process.
674
+ The name(s) must be UPPER CASE.
675
+ The default value is ``None``.
676
+ station_names : list
677
+ Station names to process.
678
+ The default value is ``None``.
679
+ remove_l0b : bool
680
+ Whether to remove the L0B files after having produced L0C netCDF files.
681
+ The default is False.
682
+ force : bool
683
+ If ``True``, overwrite existing data into destination directories.
684
+ If ``False``, raise an error if there are already data into destination directories.
685
+ The default value is ``False``.
686
+ verbose : bool
687
+ Whether to print detailed processing information into terminal.
688
+ The default value is ``False``.
689
+ parallel : bool
690
+ If ``True``, the files are processed simultaneously in multiple processes.
691
+ Each process will use a single thread to avoid issues with the HDF/netCDF library.
692
+ By default, the number of process is defined with ``os.cpu_count()``.
693
+ If ``False``, the files are processed sequentially in a single process.
694
+ If ``False``, multi-threading is automatically exploited to speed up I/0 tasks.
695
+ debugging_mode : bool
696
+ If ``True``, it reduces the amount of data to process.
697
+ For L1B, it processes just 3 L0B files.
698
+ The default value is ``False``.
699
+ data_archive_dir : str (optional)
700
+ The directory path where the DISDRODB Data Archive is located.
701
+ The directory path must end with ``<...>/DISDRODB``.
702
+ If ``None``, it uses the ``data_archive_dir`` path specified
703
+ in the DISDRODB active configuration.
704
+ """
705
+ # Define products
706
+ product = "L0C"
707
+ required_product = get_required_product(product)
708
+
709
+ # Get list of available stations
710
+ list_info = available_stations(
711
+ # DISDRODB root directories
712
+ data_archive_dir=data_archive_dir,
713
+ metadata_archive_dir=metadata_archive_dir,
714
+ # Stations arguments
715
+ data_sources=data_sources,
716
+ campaign_names=campaign_names,
717
+ station_names=station_names,
718
+ # Search options
719
+ product=required_product,
720
+ raise_error_if_empty=True,
721
+ )
722
+
723
+ # Print message
724
+ n_stations = len(list_info)
725
+ print(f"{product} processing of {n_stations} stations started.")
726
+
727
+ # Loop over stations
728
+ for data_source, campaign_name, station_name in list_info:
729
+ print(f"{product} processing of {data_source} {campaign_name} {station_name} station started.")
730
+ # Run processing
731
+ run_l0c_station(
732
+ # DISDRODB root directories
733
+ data_archive_dir=data_archive_dir,
734
+ metadata_archive_dir=metadata_archive_dir,
735
+ # Station arguments
736
+ data_source=data_source,
737
+ campaign_name=campaign_name,
738
+ station_name=station_name,
739
+ # L0C options
740
+ remove_l0b=remove_l0b,
741
+ # Process options
742
+ force=force,
743
+ verbose=verbose,
744
+ debugging_mode=debugging_mode,
745
+ parallel=parallel,
746
+ )
747
+ print(f"{product} processing of {data_source} {campaign_name} {station_name} station ended.")
748
+
749
+
750
+ def run_l0(
751
+ data_sources=None,
752
+ campaign_names=None,
753
+ station_names=None,
754
+ # L0 archive options
755
+ l0a_processing: bool = True,
756
+ l0b_processing: bool = True,
757
+ l0c_processing: bool = True,
758
+ remove_l0a: bool = False,
759
+ remove_l0b: bool = False,
760
+ # Processing options
761
+ force: bool = False,
762
+ verbose: bool = False,
763
+ debugging_mode: bool = False,
764
+ parallel: bool = True,
765
+ # DISDRODB root directories
766
+ data_archive_dir: Optional[str] = None,
767
+ metadata_archive_dir: Optional[str] = None,
768
+ ):
769
+ """Run the L0 processing of DISDRODB stations.
770
+
771
+ This function allows to launch the processing of many DISDRODB stations with a single command.
772
+ From the list of all available DISDRODB stations, it runs the processing of the
773
+ stations matching the provided data_sources, campaign_names and station_names.
774
+
775
+ Parameters
776
+ ----------
777
+ data_sources : list
778
+ Name of data source(s) to process.
779
+ The name(s) must be UPPER CASE.
780
+ If campaign_names and station are not specified, process all stations.
781
+ The default value is ``None``.
782
+ campaign_names : list
783
+ Name of the campaign(s) to process.
784
+ The name(s) must be UPPER CASE.
785
+ The default value is ``None``.
786
+ station_names : list
787
+ Station names to process.
788
+ The default value is ``None``.
789
+ l0a_processing : bool
790
+ Whether to launch processing to generate L0A Apache Parquet file(s) from raw data.
791
+ The default value is ``True``.
792
+ l0b_processing : bool
793
+ Whether to launch processing to generate L0B netCDF4 file(s) from L0A data.
794
+ The default value is ``True``.
795
+ l0c_processing : bool
796
+ Whether to launch processing to generate L0C netCDF4 file(s) from L0B data.
797
+ The default value is ``True``.
798
+ remove_l0a : bool
799
+ Whether to keep the L0A files after having generated the L0B netCDF products.
800
+ The default value is ``False``.
801
+ remove_l0b : bool
802
+ Whether to remove the L0B files after having produced all L0C netCDF files.
803
+ The default value is ``False``.
804
+ force : bool
805
+ If ``True``, overwrite existing data into destination directories.
806
+ If ``False``, raise an error if there are already data into destination directories.
807
+ The default value is ``False``.
808
+ verbose : bool
809
+ Whether to print detailed processing information into terminal.
810
+ The default value is ``False``.
811
+ parallel : bool
812
+ If ``True``, the files are processed simultaneously in multiple processes.
813
+ Each process will use a single thread to avoid issues with the HDF/netCDF library.
814
+ By default, the number of process is defined with ``os.cpu_count()``.
815
+ If ``False``, the files are processed sequentially in a single process.
816
+ If ``False``, multi-threading is automatically exploited to speed up I/0 tasks.
817
+ debugging_mode : bool
818
+ If ``True``, it reduces the amount of data to process.
819
+ For L0A, it processes just the first 3 raw data files.
820
+ For L0B, it processes just the first 100 rows of 3 L0A files.
821
+ The default value is ``False``.
822
+ data_archive_dir : str (optional)
823
+ The directory path where the DISDRODB Data Archive is located.
824
+ The directory path must end with ``<...>/DISDRODB``.
825
+ If ``None``, it uses the ``data_archive_dir`` path specified
826
+ in the DISDRODB active configuration.
827
+ """
828
+ # Define starting product
829
+ if l0c_processing:
830
+ required_product = get_required_product("L0C")
831
+ if l0b_processing:
832
+ required_product = get_required_product("L0B")
833
+ if l0a_processing:
834
+ required_product = get_required_product("L0A")
835
+
836
+ # Get list of available stations
837
+ list_info = available_stations(
838
+ # DISDRODB root directories
839
+ data_archive_dir=data_archive_dir,
840
+ metadata_archive_dir=metadata_archive_dir,
841
+ # Stations arguments
842
+ data_sources=data_sources,
843
+ campaign_names=campaign_names,
844
+ station_names=station_names,
845
+ # Search options
846
+ product=required_product,
847
+ raise_error_if_empty=True,
848
+ )
849
+
850
+ # Print message
851
+ n_stations = len(list_info)
852
+ print(f"L0 processing of {n_stations} stations started.")
853
+
854
+ # Loop over stations
855
+ for data_source, campaign_name, station_name in list_info:
856
+ print(f"L0 processing of {data_source} {campaign_name} {station_name} station started.")
857
+ # Run processing
858
+ run_l0_station(
859
+ # DISDRODB root directories
860
+ data_archive_dir=data_archive_dir,
861
+ metadata_archive_dir=metadata_archive_dir,
862
+ # Station arguments
863
+ data_source=data_source,
864
+ campaign_name=campaign_name,
865
+ station_name=station_name,
866
+ # L0 archive options
867
+ l0a_processing=l0a_processing,
868
+ l0b_processing=l0b_processing,
869
+ l0c_processing=l0c_processing,
870
+ remove_l0a=remove_l0a,
871
+ remove_l0b=remove_l0b,
872
+ # Process options
873
+ force=force,
874
+ verbose=verbose,
875
+ debugging_mode=debugging_mode,
876
+ parallel=parallel,
877
+ )
878
+ print(f"L0 processing of {data_source} {campaign_name} {station_name} station ended.")
879
+
880
+
881
+ def run_l1(
882
+ data_sources=None,
883
+ campaign_names=None,
884
+ station_names=None,
885
+ # Processing options
886
+ force: bool = False,
887
+ verbose: bool = False,
888
+ debugging_mode: bool = False,
889
+ parallel: bool = True,
890
+ # DISDRODB root directories
891
+ data_archive_dir: Optional[str] = None,
892
+ metadata_archive_dir: Optional[str] = None,
893
+ ):
894
+ """Run the L1 processing of DISDRODB stations.
895
+
896
+ This function allows to launch the processing of many DISDRODB stations with a single command.
897
+ From the list of all available DISDRODB stations, it runs the processing of the
898
+ stations matching the provided data_sources, campaign_names and station_names.
899
+
900
+ Parameters
901
+ ----------
902
+ data_sources : list
903
+ Name of data source(s) to process.
904
+ The name(s) must be UPPER CASE.
905
+ If campaign_names and station are not specified, process all stations.
906
+ The default value is ``None``.
907
+ campaign_names : list
908
+ Name of the campaign(s) to process.
909
+ The name(s) must be UPPER CASE.
910
+ The default value is ``None``.
911
+ station_names : list
912
+ Station names to process.
913
+ The default value is ``None``.
914
+ force : bool
915
+ If ``True``, overwrite existing data into destination directories.
916
+ If ``False``, raise an error if there are already data into destination directories.
917
+ The default value is ``False``.
918
+ verbose : bool
919
+ Whether to print detailed processing information into terminal.
920
+ The default value is ``False``.
921
+ parallel : bool
922
+ If ``True``, the files are processed simultaneously in multiple processes.
923
+ Each process will use a single thread to avoid issues with the HDF/netCDF library.
924
+ By default, the number of process is defined with ``os.cpu_count()``.
925
+ If ``False``, the files are processed sequentially in a single process.
926
+ If ``False``, multi-threading is automatically exploited to speed up I/0 tasks.
927
+ debugging_mode : bool
928
+ If ``True``, it reduces the amount of data to process.
929
+ For L1B, it processes just 3 L0B files.
930
+ The default value is ``False``.
931
+ data_archive_dir : str (optional)
932
+ The directory path where the DISDRODB Data Archive is located.
933
+ The directory path must end with ``<...>/DISDRODB``.
934
+ If ``None``, it uses the ``data_archive_dir`` path specified
935
+ in the DISDRODB active configuration.
936
+ """
937
+ product = "L1"
938
+ required_product = get_required_product(product)
939
+
940
+ # Get list of available stations
941
+ list_info = available_stations(
942
+ # DISDRODB root directories
943
+ data_archive_dir=data_archive_dir,
944
+ metadata_archive_dir=metadata_archive_dir,
945
+ # Stations arguments
946
+ product=required_product,
947
+ data_sources=data_sources,
948
+ campaign_names=campaign_names,
949
+ station_names=station_names,
950
+ # Search options
951
+ available_data=False, # Check for station product directory is present only
952
+ raise_error_if_empty=True,
953
+ )
954
+
955
+ # Print message
956
+ n_stations = len(list_info)
957
+ print(f"{product} processing of {n_stations} stations started.")
958
+
959
+ # Loop over stations
960
+ for data_source, campaign_name, station_name in list_info:
961
+ print(f"{product} processing of {data_source} {campaign_name} {station_name} station started.")
962
+ # Run processing
963
+ run_l1_station(
964
+ # DISDRODB root directories
965
+ data_archive_dir=data_archive_dir,
966
+ metadata_archive_dir=metadata_archive_dir,
967
+ # Station arguments
968
+ data_source=data_source,
969
+ campaign_name=campaign_name,
970
+ station_name=station_name,
971
+ # Process options
972
+ force=force,
973
+ verbose=verbose,
974
+ debugging_mode=debugging_mode,
975
+ parallel=parallel,
976
+ )
977
+ print(f"{product} processing of {data_source} {campaign_name} {station_name} station ended.")
978
+
979
+
980
+ def run_l2e(
981
+ data_sources=None,
982
+ campaign_names=None,
983
+ station_names=None,
984
+ # Processing options
985
+ force: bool = False,
986
+ verbose: bool = False,
987
+ debugging_mode: bool = False,
988
+ parallel: bool = True,
989
+ # DISDRODB root directories
990
+ data_archive_dir: Optional[str] = None,
991
+ metadata_archive_dir: Optional[str] = None,
992
+ ):
993
+ """Run the L2E processing of DISDRODB stations.
994
+
995
+ This function allows to launch the processing of many DISDRODB stations with a single command.
996
+ From the list of all available DISDRODB stations, it runs the processing of the
997
+ stations matching the provided data_sources, campaign_names and station_names.
998
+
999
+ Parameters
1000
+ ----------
1001
+ data_sources : list
1002
+ Name of data source(s) to process.
1003
+ The name(s) must be UPPER CASE.
1004
+ If campaign_names and station are not specified, process all stations.
1005
+ The default value is ``None``.
1006
+ campaign_names : list
1007
+ Name of the campaign(s) to process.
1008
+ The name(s) must be UPPER CASE.
1009
+ The default value is ``None``.
1010
+ station_names : list
1011
+ Station names to process.
1012
+ The default value is ``None``.
1013
+ force : bool
1014
+ If ``True``, overwrite existing data into destination directories.
1015
+ If ``False``, raise an error if there are already data into destination directories.
1016
+ The default value is ``False``.
1017
+ verbose : bool
1018
+ Whether to print detailed processing information into terminal.
1019
+ The default value is ``False``.
1020
+ parallel : bool
1021
+ If ``True``, the files are processed simultaneously in multiple processes.
1022
+ Each process will use a single thread to avoid issues with the HDF/netCDF library.
1023
+ By default, the number of process is defined with ``os.cpu_count()``.
1024
+ If ``False``, the files are processed sequentially in a single process.
1025
+ If ``False``, multi-threading is automatically exploited to speed up I/0 tasks.
1026
+ debugging_mode : bool
1027
+ If ``True``, it reduces the amount of data to process.
1028
+ For L2E, it processes just 3 L1 files.
1029
+ The default value is ``False``.
1030
+ data_archive_dir : str (optional)
1031
+ The directory path where the DISDRODB Data Archive is located.
1032
+ The directory path must end with ``<...>/DISDRODB``.
1033
+ If ``None``, it uses the ``data_archive_dir`` path specified
1034
+ in the DISDRODB active configuration.
1035
+ """
1036
+ product = "L2E"
1037
+ required_product = get_required_product(product)
1038
+
1039
+ # Get list of available stations
1040
+ list_info = available_stations(
1041
+ # DISDRODB root directories
1042
+ data_archive_dir=data_archive_dir,
1043
+ metadata_archive_dir=metadata_archive_dir,
1044
+ # Stations arguments
1045
+ data_sources=data_sources,
1046
+ campaign_names=campaign_names,
1047
+ station_names=station_names,
1048
+ # Search options
1049
+ product=required_product,
1050
+ raise_error_if_empty=True,
1051
+ )
1052
+
1053
+ # Print message
1054
+ n_stations = len(list_info)
1055
+ print(f"{product} processing of {n_stations} stations started.")
1056
+
1057
+ # Loop over stations
1058
+ for data_source, campaign_name, station_name in list_info:
1059
+ print(f"{product} processing of {data_source} {campaign_name} {station_name} station started.")
1060
+ # Run processing
1061
+ run_l2e_station(
1062
+ # DISDRODB root directories
1063
+ data_archive_dir=data_archive_dir,
1064
+ metadata_archive_dir=metadata_archive_dir,
1065
+ # Station arguments
1066
+ data_source=data_source,
1067
+ campaign_name=campaign_name,
1068
+ station_name=station_name,
1069
+ # Process options
1070
+ force=force,
1071
+ verbose=verbose,
1072
+ debugging_mode=debugging_mode,
1073
+ parallel=parallel,
1074
+ )
1075
+ print(f"{product} processing of {data_source} {campaign_name} {station_name} station ended.")
1076
+
1077
+
1078
+ def run_l2m(
1079
+ data_sources=None,
1080
+ campaign_names=None,
1081
+ station_names=None,
1082
+ # Processing options
1083
+ force: bool = False,
1084
+ verbose: bool = False,
1085
+ debugging_mode: bool = False,
1086
+ parallel: bool = True,
1087
+ # DISDRODB root directories
1088
+ data_archive_dir: Optional[str] = None,
1089
+ metadata_archive_dir: Optional[str] = None,
1090
+ ):
1091
+ """Run the L2M processing of DISDRODB stations.
1092
+
1093
+ This function allows to launch the processing of many DISDRODB stations with a single command.
1094
+ From the list of all available DISDRODB stations, it runs the processing of the
1095
+ stations matching the provided data_sources, campaign_names and station_names.
1096
+
1097
+ Parameters
1098
+ ----------
1099
+ data_sources : list
1100
+ Name of data source(s) to process.
1101
+ The name(s) must be UPPER CASE.
1102
+ If campaign_names and station are not specified, process all stations.
1103
+ The default value is ``None``.
1104
+ campaign_names : list
1105
+ Name of the campaign(s) to process.
1106
+ The name(s) must be UPPER CASE.
1107
+ The default value is ``None``.
1108
+ station_names : list
1109
+ Station names to process.
1110
+ The default value is ``None``.
1111
+ force : bool
1112
+ If ``True``, overwrite existing data into destination directories.
1113
+ If ``False``, raise an error if there are already data into destination directories.
1114
+ The default value is ``False``.
1115
+ verbose : bool
1116
+ Whether to print detailed processing information into terminal.
1117
+ The default value is ``False``.
1118
+ parallel : bool
1119
+ If ``True``, the files are processed simultaneously in multiple processes.
1120
+ Each process will use a single thread to avoid issues with the HDF/netCDF library.
1121
+ By default, the number of process is defined with ``os.cpu_count()``.
1122
+ If ``False``, the files are processed sequentially in a single process.
1123
+ If ``False``, multi-threading is automatically exploited to speed up I/0 tasks.
1124
+ debugging_mode : bool
1125
+ If ``True``, it reduces the amount of data to process.
1126
+ For L2MB, it processes just 3 L0B files.
1127
+ The default value is ``False``.
1128
+ data_archive_dir : str (optional)
1129
+ The directory path where the DISDRODB Data Archive is located.
1130
+ The directory path must end with ``<...>/DISDRODB``.
1131
+ If ``None``, it uses the ``data_archive_dir`` path specified
1132
+ in the DISDRODB active configuration.
1133
+ """
1134
+ product = "L2M"
1135
+ required_product = get_required_product(product)
1136
+
1137
+ # Get list of available stations
1138
+ list_info = available_stations(
1139
+ # DISDRODB root directories
1140
+ data_archive_dir=data_archive_dir,
1141
+ metadata_archive_dir=metadata_archive_dir,
1142
+ # Stations arguments
1143
+ data_sources=data_sources,
1144
+ campaign_names=campaign_names,
1145
+ station_names=station_names,
1146
+ # Search options
1147
+ product=required_product,
1148
+ raise_error_if_empty=True,
1149
+ )
1150
+
1151
+ # Print message
1152
+ n_stations = len(list_info)
1153
+ print(f"{product} processing of {n_stations} stations started.")
1154
+
1155
+ # Loop over stations
1156
+ for data_source, campaign_name, station_name in list_info:
1157
+ print(f"{product} processing of {data_source} {campaign_name} {station_name} station started.")
1158
+ # Run processing
1159
+ run_l2m_station(
1160
+ # DISDRODB root directories
1161
+ data_archive_dir=data_archive_dir,
1162
+ metadata_archive_dir=metadata_archive_dir,
1163
+ # Station arguments
1164
+ data_source=data_source,
1165
+ campaign_name=campaign_name,
1166
+ station_name=station_name,
1167
+ # Process options
1168
+ force=force,
1169
+ verbose=verbose,
1170
+ debugging_mode=debugging_mode,
1171
+ parallel=parallel,
1172
+ )
1173
+ print(f"{product} processing of {data_source} {campaign_name} {station_name} station ended.")
1174
+
1175
+
1176
+ ####--------------------------------------------------------------------------.