disdrodb 0.3.0__py3-none-any.whl → 0.5.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 (198) hide show
  1. disdrodb/__init__.py +2 -0
  2. disdrodb/_config.py +1 -0
  3. disdrodb/_version.py +2 -2
  4. disdrodb/accessor/__init__.py +1 -0
  5. disdrodb/accessor/methods.py +1 -0
  6. disdrodb/api/checks.py +2 -4
  7. disdrodb/api/io.py +224 -24
  8. disdrodb/api/path.py +2 -4
  9. disdrodb/cli/disdrodb_check_metadata_archive.py +1 -0
  10. disdrodb/cli/disdrodb_check_products_options.py +1 -0
  11. disdrodb/cli/disdrodb_create_summary.py +6 -6
  12. disdrodb/cli/disdrodb_create_summary_station.py +2 -2
  13. disdrodb/cli/disdrodb_data_archive_directory.py +1 -0
  14. disdrodb/cli/disdrodb_download_archive.py +5 -6
  15. disdrodb/cli/disdrodb_download_metadata_archive.py +1 -0
  16. disdrodb/cli/disdrodb_download_station.py +2 -3
  17. disdrodb/cli/disdrodb_initialize_station.py +3 -3
  18. disdrodb/cli/disdrodb_metadata_archive_directory.py +1 -0
  19. disdrodb/cli/disdrodb_open_data_archive.py +1 -2
  20. disdrodb/cli/disdrodb_open_logs_directory.py +2 -3
  21. disdrodb/cli/disdrodb_open_metadata_archive.py +1 -2
  22. disdrodb/cli/disdrodb_open_metadata_directory.py +2 -3
  23. disdrodb/cli/disdrodb_open_product_directory.py +1 -2
  24. disdrodb/cli/disdrodb_open_readers_directory.py +1 -0
  25. disdrodb/cli/disdrodb_run.py +6 -6
  26. disdrodb/cli/disdrodb_run_l0.py +6 -6
  27. disdrodb/cli/disdrodb_run_l0_station.py +3 -3
  28. disdrodb/cli/disdrodb_run_l0a.py +6 -6
  29. disdrodb/cli/disdrodb_run_l0a_station.py +3 -3
  30. disdrodb/cli/disdrodb_run_l0b.py +6 -6
  31. disdrodb/cli/disdrodb_run_l0b_station.py +3 -3
  32. disdrodb/cli/disdrodb_run_l0c.py +6 -6
  33. disdrodb/cli/disdrodb_run_l0c_station.py +3 -3
  34. disdrodb/cli/disdrodb_run_l1.py +6 -6
  35. disdrodb/cli/disdrodb_run_l1_station.py +3 -3
  36. disdrodb/cli/disdrodb_run_l2e.py +6 -6
  37. disdrodb/cli/disdrodb_run_l2e_station.py +3 -3
  38. disdrodb/cli/disdrodb_run_l2m.py +6 -6
  39. disdrodb/cli/disdrodb_run_l2m_station.py +3 -3
  40. disdrodb/cli/disdrodb_run_station.py +3 -3
  41. disdrodb/cli/disdrodb_upload_archive.py +6 -7
  42. disdrodb/cli/disdrodb_upload_station.py +3 -4
  43. disdrodb/configs.py +7 -8
  44. disdrodb/constants.py +1 -0
  45. disdrodb/data_transfer/download_data.py +8 -8
  46. disdrodb/data_transfer/upload_data.py +6 -8
  47. disdrodb/data_transfer/zenodo.py +1 -1
  48. disdrodb/fall_velocity/__init__.py +1 -0
  49. disdrodb/fall_velocity/graupel.py +1 -0
  50. disdrodb/fall_velocity/hail.py +1 -0
  51. disdrodb/fall_velocity/rain.py +1 -0
  52. disdrodb/issue/checks.py +1 -0
  53. disdrodb/issue/reader.py +1 -0
  54. disdrodb/issue/writer.py +1 -2
  55. disdrodb/l0/__init__.py +1 -0
  56. disdrodb/l0/check_configs.py +21 -23
  57. disdrodb/l0/check_standards.py +0 -1
  58. disdrodb/l0/configs/LPM/l0a_encodings.yml +17 -17
  59. disdrodb/l0/configs/LPM/l0b_cf_attrs.yml +55 -55
  60. disdrodb/l0/configs/LPM/l0b_encodings.yml +17 -17
  61. disdrodb/l0/configs/LPM/raw_data_format.yml +17 -17
  62. disdrodb/l0/configs/LPM_V0/l0a_encodings.yml +2 -2
  63. disdrodb/l0/configs/LPM_V0/l0b_cf_attrs.yml +2 -2
  64. disdrodb/l0/configs/LPM_V0/l0b_encodings.yml +2 -2
  65. disdrodb/l0/configs/LPM_V0/raw_data_format.yml +2 -2
  66. disdrodb/l0/l0_reader.py +1 -0
  67. disdrodb/l0/l0a_processing.py +5 -5
  68. disdrodb/l0/l0b_nc_processing.py +1 -2
  69. disdrodb/l0/l0b_processing.py +1 -13
  70. disdrodb/l0/l0c_processing.py +2 -1
  71. disdrodb/l0/readers/LPM/ARM/ARM_LPM.py +1 -0
  72. disdrodb/l0/readers/LPM/AUSTRALIA/MELBOURNE_2007_LPM.py +17 -17
  73. disdrodb/l0/readers/LPM/BRAZIL/CHUVA_LPM.py +17 -17
  74. disdrodb/l0/readers/LPM/BRAZIL/GOAMAZON_LPM.py +17 -17
  75. disdrodb/l0/readers/LPM/GERMANY/DWD.py +55 -52
  76. disdrodb/l0/readers/LPM/ITALY/GID_LPM.py +18 -17
  77. disdrodb/l0/readers/LPM/ITALY/GID_LPM_AQ.py +277 -0
  78. disdrodb/l0/readers/LPM/ITALY/GID_LPM_PI.py +18 -17
  79. disdrodb/l0/readers/LPM/ITALY/GID_LPM_T.py +18 -17
  80. disdrodb/l0/readers/LPM/ITALY/GID_LPM_W.py +18 -18
  81. disdrodb/l0/readers/LPM/KIT/CHWALA.py +18 -17
  82. disdrodb/l0/readers/LPM/NETHERLANDS/DELFT_RWANDA_LPM_NC.py +17 -17
  83. disdrodb/l0/readers/LPM/NORWAY/HAUKELISETER_LPM.py +18 -17
  84. disdrodb/l0/readers/LPM/NORWAY/NMBU_LPM.py +18 -17
  85. disdrodb/l0/readers/LPM/SLOVENIA/ARSO.py +18 -17
  86. disdrodb/l0/readers/LPM/SLOVENIA/UL.py +18 -17
  87. disdrodb/l0/readers/LPM/SWITZERLAND/INNERERIZ_LPM.py +18 -17
  88. disdrodb/l0/readers/LPM/UK/WITHWORTH_LPM.py +18 -17
  89. disdrodb/l0/readers/LPM/USA/CHARLESTON.py +18 -17
  90. disdrodb/l0/readers/LPM/USA/DEVEX.py +255 -0
  91. disdrodb/l0/readers/LPM_V0/BELGIUM/ULIEGE.py +2 -2
  92. disdrodb/l0/readers/LPM_V0/ITALY/GID_LPM_V0.py +3 -2
  93. disdrodb/l0/readers/ODM470/OCEAN/OCEANRAIN.py +1 -0
  94. disdrodb/l0/readers/PARSIVEL/BASQUECOUNTRY/EUSKALMET_OTT.py +1 -0
  95. disdrodb/l0/readers/PARSIVEL/CHINA/CHONGQING.py +1 -0
  96. disdrodb/l0/readers/PARSIVEL/EPFL/ARCTIC_2021.py +1 -0
  97. disdrodb/l0/readers/PARSIVEL/EPFL/COMMON_2011.py +1 -0
  98. disdrodb/l0/readers/PARSIVEL/EPFL/DAVOS_2009_2011.py +1 -0
  99. disdrodb/l0/readers/PARSIVEL/EPFL/EPFL_2009.py +1 -0
  100. disdrodb/l0/readers/PARSIVEL/EPFL/EPFL_ROOF_2008.py +1 -0
  101. disdrodb/l0/readers/PARSIVEL/EPFL/EPFL_ROOF_2010.py +1 -0
  102. disdrodb/l0/readers/PARSIVEL/EPFL/EPFL_ROOF_2011.py +1 -0
  103. disdrodb/l0/readers/PARSIVEL/EPFL/EPFL_ROOF_2012.py +1 -0
  104. disdrodb/l0/readers/PARSIVEL/EPFL/GENEPI_2007.py +1 -0
  105. disdrodb/l0/readers/PARSIVEL/EPFL/GRAND_ST_BERNARD_2007.py +1 -0
  106. disdrodb/l0/readers/PARSIVEL/EPFL/GRAND_ST_BERNARD_2007_2.py +1 -0
  107. disdrodb/l0/readers/PARSIVEL/EPFL/HPICONET_2010.py +1 -0
  108. disdrodb/l0/readers/PARSIVEL/EPFL/HYMEX_LTE_SOP2.py +1 -0
  109. disdrodb/l0/readers/PARSIVEL/EPFL/HYMEX_LTE_SOP3.py +1 -0
  110. disdrodb/l0/readers/PARSIVEL/EPFL/HYMEX_LTE_SOP4.py +1 -0
  111. disdrodb/l0/readers/PARSIVEL/EPFL/PARADISO_2014.py +1 -0
  112. disdrodb/l0/readers/PARSIVEL/EPFL/PARSIVEL_2007.py +1 -0
  113. disdrodb/l0/readers/PARSIVEL/EPFL/RACLETS_2019.py +1 -0
  114. disdrodb/l0/readers/PARSIVEL/EPFL/RACLETS_2019_WJF.py +1 -0
  115. disdrodb/l0/readers/PARSIVEL/EPFL/RIETHOLZBACH_2011.py +1 -0
  116. disdrodb/l0/readers/PARSIVEL/EPFL/SAMOYLOV_2017.py +1 -0
  117. disdrodb/l0/readers/PARSIVEL/EPFL/SAMOYLOV_2019.py +1 -0
  118. disdrodb/l0/readers/PARSIVEL/EPFL/UNIL_2022.py +1 -0
  119. disdrodb/l0/readers/PARSIVEL/SLOVENIA/UL.py +1 -0
  120. disdrodb/l0/readers/PARSIVEL2/ARM/ARM_PARSIVEL2.py +1 -0
  121. disdrodb/l0/readers/PARSIVEL2/BASQUECOUNTRY/EUSKALMET_OTT2.py +1 -0
  122. disdrodb/l0/readers/PARSIVEL2/BELGIUM/ILVO.py +1 -0
  123. disdrodb/l0/readers/PARSIVEL2/DENMARK/EROSION_nc.py +1 -0
  124. disdrodb/l0/readers/PARSIVEL2/DENMARK/EROSION_raw.py +1 -0
  125. disdrodb/l0/readers/PARSIVEL2/FRANCE/ENPC_PARSIVEL2.py +1 -0
  126. disdrodb/l0/readers/PARSIVEL2/FRANCE/OSUG.py +1 -1
  127. disdrodb/l0/readers/PARSIVEL2/ITALY/HYDROX.py +1 -0
  128. disdrodb/l0/readers/PARSIVEL2/MEXICO/OH_IIUNAM_nc.py +1 -0
  129. disdrodb/l0/readers/PARSIVEL2/NCAR/FARM_PARSIVEL2.py +1 -0
  130. disdrodb/l0/readers/PARSIVEL2/NCAR/PERILS_MIPS.py +1 -0
  131. disdrodb/l0/readers/PARSIVEL2/NCAR/PERILS_PIPS.py +1 -0
  132. disdrodb/l0/readers/PARSIVEL2/NCAR/VORTEX_SE_2016_P1.py +1 -0
  133. disdrodb/l0/readers/PARSIVEL2/NCAR/VORTEX_SE_2016_PIPS.py +1 -0
  134. disdrodb/l0/readers/PARSIVEL2/PHILIPPINES/PAGASA.py +1 -0
  135. disdrodb/l0/readers/PARSIVEL2/SPAIN/GRANADA.py +1 -0
  136. disdrodb/l0/readers/PARSIVEL2/SWEDEN/SMHI.py +1 -0
  137. disdrodb/l0/readers/PARSIVEL2/USA/CW3E.py +1 -0
  138. disdrodb/l0/readers/PWS100/AUSTRIA/HOAL.py +1 -0
  139. disdrodb/l0/readers/PWS100/FRANCE/ENPC_PWS100.py +1 -0
  140. disdrodb/l0/readers/PWS100/FRANCE/ENPC_PWS100_SIRTA.py +1 -0
  141. disdrodb/l0/readers/RD80/NOAA/PSL_RD80.py +1 -0
  142. disdrodb/l0/readers/SWS250/BELGIUM/KMI.py +1 -0
  143. disdrodb/l0/readers/template_reader_raw_netcdf_data.py +1 -0
  144. disdrodb/l0/readers/template_reader_raw_text_data.py +1 -0
  145. disdrodb/l0/template_tools.py +6 -8
  146. disdrodb/l1/__init__.py +1 -0
  147. disdrodb/l1/classification.py +1 -0
  148. disdrodb/l1/resampling.py +5 -0
  149. disdrodb/l1_env/routines.py +1 -0
  150. disdrodb/l2/__init__.py +1 -0
  151. disdrodb/l2/empirical_dsd.py +1 -0
  152. disdrodb/l2/processing.py +1 -0
  153. disdrodb/metadata/checks.py +9 -10
  154. disdrodb/metadata/download.py +1 -0
  155. disdrodb/metadata/geolocation.py +2 -1
  156. disdrodb/metadata/info.py +2 -2
  157. disdrodb/metadata/search.py +0 -1
  158. disdrodb/physics/atmosphere.py +1 -0
  159. disdrodb/physics/water.py +1 -0
  160. disdrodb/physics/wrappers.py +1 -0
  161. disdrodb/psd/__init__.py +0 -1
  162. disdrodb/psd/fitting.py +1 -0
  163. disdrodb/psd/models.py +1 -0
  164. disdrodb/routines/__init__.py +1 -0
  165. disdrodb/routines/l0.py +13 -9
  166. disdrodb/routines/l1.py +17 -12
  167. disdrodb/routines/l2.py +4 -5
  168. disdrodb/routines/options.py +1 -0
  169. disdrodb/routines/options_validation.py +12 -12
  170. disdrodb/routines/wrappers.py +33 -33
  171. disdrodb/scattering/__init__.py +0 -1
  172. disdrodb/scattering/permittivity.py +1 -0
  173. disdrodb/scattering/routines.py +3 -3
  174. disdrodb/summary/routines.py +12 -5
  175. disdrodb/utils/archiving.py +2 -1
  176. disdrodb/utils/attrs.py +3 -2
  177. disdrodb/utils/compression.py +1 -2
  178. disdrodb/utils/coords.py +45 -0
  179. disdrodb/utils/dask.py +5 -2
  180. disdrodb/utils/dataframe.py +4 -3
  181. disdrodb/utils/decorators.py +2 -1
  182. disdrodb/utils/directories.py +2 -2
  183. disdrodb/utils/encoding.py +2 -1
  184. disdrodb/utils/manipulations.py +1 -0
  185. disdrodb/utils/pydantic.py +1 -0
  186. disdrodb/utils/routines.py +1 -0
  187. disdrodb/utils/time.py +3 -2
  188. disdrodb/utils/warnings.py +1 -0
  189. disdrodb/utils/writer.py +4 -0
  190. disdrodb/utils/xarray.py +1 -0
  191. disdrodb/viz/plots.py +1 -0
  192. {disdrodb-0.3.0.dist-info → disdrodb-0.5.0.dist-info}/METADATA +4 -3
  193. disdrodb-0.5.0.dist-info/RECORD +361 -0
  194. {disdrodb-0.3.0.dist-info → disdrodb-0.5.0.dist-info}/WHEEL +1 -1
  195. disdrodb-0.3.0.dist-info/RECORD +0 -358
  196. {disdrodb-0.3.0.dist-info → disdrodb-0.5.0.dist-info}/entry_points.txt +0 -0
  197. {disdrodb-0.3.0.dist-info → disdrodb-0.5.0.dist-info}/licenses/LICENSE +0 -0
  198. {disdrodb-0.3.0.dist-info → disdrodb-0.5.0.dist-info}/top_level.txt +0 -0
@@ -15,6 +15,7 @@
15
15
  # along with this program. If not, see <http://www.gnu.org/licenses/>.
16
16
  # -----------------------------------------------------------------------------.
17
17
  """DISDRODB atmospheric physics module."""
18
+
18
19
  import numpy as np
19
20
  import xarray as xr
20
21
 
disdrodb/physics/water.py CHANGED
@@ -15,6 +15,7 @@
15
15
  # along with this program. If not, see <http://www.gnu.org/licenses/>.
16
16
  # -----------------------------------------------------------------------------.
17
17
  """DISDRODB water physics module."""
18
+
18
19
  import numpy as np
19
20
  import xarray as xr
20
21
 
@@ -15,6 +15,7 @@
15
15
  # along with this program. If not, see <http://www.gnu.org/licenses/>.
16
16
  # -----------------------------------------------------------------------------.
17
17
  """DISDRODB physics wrapper functions."""
18
+
18
19
  from disdrodb.physics.atmosphere import (
19
20
  get_air_density,
20
21
  get_air_dynamic_viscosity,
disdrodb/psd/__init__.py CHANGED
@@ -16,7 +16,6 @@
16
16
  # -----------------------------------------------------------------------------.
17
17
  """Implement PSD model and fitting routines."""
18
18
 
19
-
20
19
  from disdrodb.psd.fitting import estimate_model_parameters
21
20
  from disdrodb.psd.models import (
22
21
  ExponentialPSD,
disdrodb/psd/fitting.py CHANGED
@@ -15,6 +15,7 @@
15
15
  # along with this program. If not, see <http://www.gnu.org/licenses/>.
16
16
  # -----------------------------------------------------------------------------.
17
17
  """Routines for PSD fitting."""
18
+
18
19
  import numpy as np
19
20
  import scipy.stats as ss
20
21
  import xarray as xr
disdrodb/psd/models.py CHANGED
@@ -24,6 +24,7 @@ Source code:
24
24
  - https://github.com/wolfidan/pyradsim/blob/master/pyradsim/psd.py
25
25
 
26
26
  """
27
+
27
28
  import importlib
28
29
 
29
30
  import dask.array
@@ -15,6 +15,7 @@
15
15
  # along with this program. If not, see <http://www.gnu.org/licenses/>.
16
16
  # -----------------------------------------------------------------------------.
17
17
  """DISDRODB L0 software."""
18
+
18
19
  from disdrodb.routines.wrappers import (
19
20
  create_summary,
20
21
  create_summary_station,
disdrodb/routines/l0.py CHANGED
@@ -20,7 +20,6 @@ import datetime
20
20
  import logging
21
21
  import os
22
22
  import time
23
- from typing import Optional
24
23
 
25
24
  from disdrodb.api.checks import check_measurement_intervals, check_sensor_name, check_station_inputs
26
25
  from disdrodb.api.create_directories import (
@@ -368,11 +367,16 @@ def _generate_l0c(
368
367
 
369
368
  # Write a dataset for each sample interval
370
369
  valid_datasets = []
371
- for ds in dict_ds.values(): # (sample_interval, ds)
370
+ for sample_interval, ds in dict_ds.items():
372
371
  # Write L0C netCDF4 dataset
373
372
  if ds["time"].size > 1:
374
373
  # Write L0C netCDF4 dataset
375
- filename = define_l0c_filename(ds, campaign_name=campaign_name, station_name=station_name)
374
+ filename = define_l0c_filename(
375
+ ds,
376
+ campaign_name=campaign_name,
377
+ station_name=station_name,
378
+ sample_interval=sample_interval,
379
+ )
376
380
  folder_path = define_file_folder_path(ds, dir_path=data_dir, folder_partitioning=folder_partitioning)
377
381
  filepath = os.path.join(folder_path, filename)
378
382
  write_product(ds, filepath=filepath, force=force)
@@ -426,8 +430,8 @@ def run_l0a_station(
426
430
  debugging_mode: bool = False,
427
431
  parallel: bool = True,
428
432
  # DISDRODB root directories
429
- data_archive_dir: Optional[str] = None,
430
- metadata_archive_dir: Optional[str] = None,
433
+ data_archive_dir: str | None = None,
434
+ metadata_archive_dir: str | None = None,
431
435
  ):
432
436
  """
433
437
  Run the L0A processing of a specific DISDRODB station when invoked from the terminal.
@@ -621,8 +625,8 @@ def run_l0b_station(
621
625
  parallel: bool = True,
622
626
  debugging_mode: bool = False,
623
627
  # DISDRODB root directories
624
- data_archive_dir: Optional[str] = None,
625
- metadata_archive_dir: Optional[str] = None,
628
+ data_archive_dir: str | None = None,
629
+ metadata_archive_dir: str | None = None,
626
630
  ):
627
631
  """
628
632
  Run the L0B processing of a specific DISDRODB station when invoked from the terminal.
@@ -802,8 +806,8 @@ def run_l0c_station(
802
806
  parallel: bool = True,
803
807
  debugging_mode: bool = False,
804
808
  # DISDRODB root directories
805
- data_archive_dir: Optional[str] = None,
806
- metadata_archive_dir: Optional[str] = None,
809
+ data_archive_dir: str | None = None,
810
+ metadata_archive_dir: str | None = None,
807
811
  ):
808
812
  """
809
813
  Run the L0C processing of a specific DISDRODB station when invoked from the terminal.
disdrodb/routines/l1.py CHANGED
@@ -20,7 +20,6 @@ import datetime
20
20
  import logging
21
21
  import os
22
22
  import time
23
- from typing import Optional
24
23
 
25
24
  import pandas as pd
26
25
 
@@ -144,18 +143,23 @@ def _generate_l1(
144
143
  folder_partitioning,
145
144
  ):
146
145
  """Define L1 product processing."""
147
- # Open the L0C netCDF files
146
+ import dask
147
+
148
+ # Define variables to load
148
149
  # - precip_flag used for OceanRain ODM470 data only
149
150
  # - Missing variables in dataset are simply not selected
150
151
  variables = ["raw_drop_number", "qc_time", "precip_flag", *TEMPERATURE_VARIABLES, *METEOROLOGICAL_VARIABLES]
151
- ds = open_netcdf_files(
152
- filepaths,
153
- start_time=start_time,
154
- end_time=end_time,
155
- variables=variables,
156
- parallel=False,
157
- compute=True,
158
- )
152
+
153
+ # Open the L0C netCDF files
154
+ with dask.config.set(scheduler="single-threaded"): # synchronous
155
+ ds = open_netcdf_files(
156
+ filepaths,
157
+ start_time=start_time,
158
+ end_time=end_time,
159
+ variables=variables,
160
+ parallel=False,
161
+ compute=True,
162
+ )
159
163
 
160
164
  # Define sample interval in seconds
161
165
  sample_interval = ensure_sample_interval_in_seconds(ds["sample_interval"]).to_numpy().item()
@@ -234,8 +238,8 @@ def run_l1_station(
234
238
  parallel: bool = True,
235
239
  debugging_mode: bool = False,
236
240
  # DISDRODB root directories
237
- data_archive_dir: Optional[str] = None,
238
- metadata_archive_dir: Optional[str] = None,
241
+ data_archive_dir: str | None = None,
242
+ metadata_archive_dir: str | None = None,
239
243
  ):
240
244
  """
241
245
  Run the L1 processing of a specific DISDRODB station when invoked from the terminal.
@@ -337,6 +341,7 @@ def run_l1_station(
337
341
  # Generate products for each temporal resolution
338
342
  # temporal_resolution = "1MIN"
339
343
  # temporal_resolution = "10MIN"
344
+ # temporal_resolution = "ROLL2MIN"
340
345
  for temporal_resolution in l1_processing_options.temporal_resolutions:
341
346
  # Print progress message
342
347
  msg = f"Production of {product} {temporal_resolution} has started."
disdrodb/routines/l2.py CHANGED
@@ -21,7 +21,6 @@ import datetime
21
21
  import logging
22
22
  import os
23
23
  import time
24
- from typing import Optional
25
24
 
26
25
  import pandas as pd
27
26
 
@@ -215,8 +214,8 @@ def run_l2e_station(
215
214
  parallel: bool = True,
216
215
  debugging_mode: bool = False,
217
216
  # DISDRODB root directories
218
- data_archive_dir: Optional[str] = None,
219
- metadata_archive_dir: Optional[str] = None,
217
+ data_archive_dir: str | None = None,
218
+ metadata_archive_dir: str | None = None,
220
219
  ):
221
220
  """
222
221
  Generate the L2E product of a specific DISDRODB station when invoked from the terminal.
@@ -623,8 +622,8 @@ def run_l2m_station(
623
622
  parallel: bool = True,
624
623
  debugging_mode: bool = False,
625
624
  # DISDRODB root directories
626
- data_archive_dir: Optional[str] = None,
627
- metadata_archive_dir: Optional[str] = None,
625
+ data_archive_dir: str | None = None,
626
+ metadata_archive_dir: str | None = None,
628
627
  ):
629
628
  """
630
629
  Run the L2M processing of a specific DISDRODB station when invoked from the terminal.
@@ -15,6 +15,7 @@
15
15
  # along with this program. If not, see <http://www.gnu.org/licenses/>.
16
16
  # -----------------------------------------------------------------------------.
17
17
  """Implements ProcessingOption class for DISDRODB routines."""
18
+
18
19
  import json
19
20
  import os
20
21
  from pathlib import Path
@@ -1,6 +1,6 @@
1
1
  import os
2
2
  from pathlib import Path
3
- from typing import Any, Literal, Union
3
+ from typing import Any, Literal
4
4
 
5
5
  from pydantic import Field, field_validator, model_validator
6
6
 
@@ -239,7 +239,7 @@ class ArchiveOptions(CustomBaseModel):
239
239
  """Archive options configuration."""
240
240
 
241
241
  strategy: Literal["time_block", "event"] = Field(..., description="Archiving strategy")
242
- strategy_options: Union[TimeBlockStrategyOptions, EventStrategyOptions] = Field(
242
+ strategy_options: TimeBlockStrategyOptions | EventStrategyOptions = Field(
243
243
  ...,
244
244
  description="Strategy-specific options",
245
245
  )
@@ -284,35 +284,35 @@ class ArchiveOptionsTimeBlock(ArchiveOptions):
284
284
  class RadarOptions(CustomBaseModel):
285
285
  """Radar simulation options."""
286
286
 
287
- frequency: Union[str, int, float, list[Union[str, int, float]]] = Field(
287
+ frequency: str | int | float | list[str | int | float] = Field(
288
288
  ...,
289
289
  description="Radar frequency bands or numeric frequency values (in GHz)",
290
290
  )
291
- num_points: Union[int, float, list[Union[int, float]]] = Field(
291
+ num_points: int | float | list[int | float] = Field(
292
292
  ...,
293
293
  description="Number of points for T-matrix simulation",
294
294
  )
295
- diameter_max: Union[int, float, list[Union[int, float]]] = Field(
295
+ diameter_max: int | float | list[int | float] = Field(
296
296
  ...,
297
297
  description="Maximum diameter for T-matrix simulation",
298
298
  )
299
- canting_angle_std: Union[int, float, list[Union[int, float]]] = Field(
299
+ canting_angle_std: int | float | list[int | float] = Field(
300
300
  ...,
301
301
  description="Canting angle standard deviation",
302
302
  )
303
- axis_ratio_model: Union[str, list[str]] = Field(
303
+ axis_ratio_model: str | list[str] = Field(
304
304
  ...,
305
305
  description="Axis ratio model",
306
306
  )
307
- permittivity_model: Union[str, list[str]] = Field(
307
+ permittivity_model: str | list[str] = Field(
308
308
  ...,
309
309
  description="Permittivity model",
310
310
  )
311
- water_temperature: Union[int, float, list[Union[int, float]]] = Field(
311
+ water_temperature: int | float | list[int | float] = Field(
312
312
  ...,
313
313
  description="Water temperature in Celsius",
314
314
  )
315
- elevation_angle: Union[int, float, list[Union[int, float]]] = Field(
315
+ elevation_angle: int | float | list[int | float] = Field(
316
316
  ...,
317
317
  description="Elevation angle in degrees",
318
318
  )
@@ -372,9 +372,9 @@ class L2EProductOptions(CustomBaseModel):
372
372
  minimum_velocity: float = Field(..., ge=0, description="Minimum velocity threshold")
373
373
  maximum_velocity: float = Field(..., gt=0, description="Maximum velocity threshold")
374
374
  keep_mixed_precipitation: bool = Field(..., description="Whether to keep mixed precipitation")
375
- above_velocity_fraction: Union[float, None] = Field(..., ge=0, le=1, description="Above velocity fraction")
375
+ above_velocity_fraction: float | None = Field(..., ge=0, le=1, description="Above velocity fraction")
376
376
  above_velocity_tolerance: float = Field(..., ge=0, description="Above velocity tolerance")
377
- below_velocity_fraction: Union[float, None] = Field(..., ge=0, le=1, description="Below velocity fraction")
377
+ below_velocity_fraction: float | None = Field(..., ge=0, le=1, description="Below velocity fraction")
378
378
  below_velocity_tolerance: float = Field(..., ge=0, description="Below velocity tolerance")
379
379
  maintain_drops_smaller_than: float = Field(..., ge=0, description="Maintain drops smaller than threshold")
380
380
  maintain_drops_slower_than: float = Field(..., ge=0, description="Maintain drops slower than threshold")
@@ -15,9 +15,9 @@
15
15
  # along with this program. If not, see <http://www.gnu.org/licenses/>.
16
16
  # -----------------------------------------------------------------------------.
17
17
  """DISDRODB CLI routine wrappers."""
18
+
18
19
  import datetime
19
20
  import time
20
- from typing import Optional
21
21
 
22
22
  from disdrodb.api.search import available_stations, get_required_product
23
23
  from disdrodb.utils.cli import execute_cmd
@@ -111,8 +111,8 @@ def run_l0_station(
111
111
  debugging_mode: bool = False,
112
112
  parallel: bool = True,
113
113
  # DISDRODB root directories
114
- data_archive_dir: Optional[str] = None,
115
- metadata_archive_dir: Optional[str] = None,
114
+ data_archive_dir: str | None = None,
115
+ metadata_archive_dir: str | None = None,
116
116
  ):
117
117
  """Run the L0 processing of a specific DISDRODB station from the terminal.
118
118
 
@@ -253,8 +253,8 @@ def run_l0a_station(
253
253
  debugging_mode: bool = False,
254
254
  parallel: bool = True,
255
255
  # DISDRODB root directories
256
- data_archive_dir: Optional[str] = None,
257
- metadata_archive_dir: Optional[str] = None,
256
+ data_archive_dir: str | None = None,
257
+ metadata_archive_dir: str | None = None,
258
258
  ):
259
259
  """
260
260
  Run the L0A processing of a station by invoking the disdrodb_run_l0a_station command in the terminal.
@@ -331,8 +331,8 @@ def run_l0b_station(
331
331
  debugging_mode: bool = False,
332
332
  parallel: bool = True,
333
333
  # DISDRODB root directories
334
- data_archive_dir: Optional[str] = None,
335
- metadata_archive_dir: Optional[str] = None,
334
+ data_archive_dir: str | None = None,
335
+ metadata_archive_dir: str | None = None,
336
336
  ):
337
337
  """
338
338
  Run the L0B processing of a station by invoking the disdrodb_run_l0b_station command in the terminal.
@@ -415,8 +415,8 @@ def run_l0c_station(
415
415
  debugging_mode: bool = False,
416
416
  parallel: bool = True,
417
417
  # DISDRODB root directories
418
- data_archive_dir: Optional[str] = None,
419
- metadata_archive_dir: Optional[str] = None,
418
+ data_archive_dir: str | None = None,
419
+ metadata_archive_dir: str | None = None,
420
420
  ):
421
421
  """
422
422
  Run the L0C processing of a station by invoking the disdrodb_run_l0c_station command in the terminal.
@@ -497,8 +497,8 @@ def run_l1_station(
497
497
  debugging_mode: bool = False,
498
498
  parallel: bool = True,
499
499
  # DISDRODB root directories
500
- data_archive_dir: Optional[str] = None,
501
- metadata_archive_dir: Optional[str] = None,
500
+ data_archive_dir: str | None = None,
501
+ metadata_archive_dir: str | None = None,
502
502
  ):
503
503
  """
504
504
  Run the L1 processing of a station by invoking the disdrodb_run_l1_station command in the terminal.
@@ -573,8 +573,8 @@ def run_l2e_station(
573
573
  debugging_mode: bool = False,
574
574
  parallel: bool = True,
575
575
  # DISDRODB root directories
576
- data_archive_dir: Optional[str] = None,
577
- metadata_archive_dir: Optional[str] = None,
576
+ data_archive_dir: str | None = None,
577
+ metadata_archive_dir: str | None = None,
578
578
  ):
579
579
  """
580
580
  Run the L2E processing of a station by invoking the disdrodb_run_l2e_station command in the terminal.
@@ -649,8 +649,8 @@ def run_l2m_station(
649
649
  debugging_mode: bool = False,
650
650
  parallel: bool = True,
651
651
  # DISDRODB root directories
652
- data_archive_dir: Optional[str] = None,
653
- metadata_archive_dir: Optional[str] = None,
652
+ data_archive_dir: str | None = None,
653
+ metadata_archive_dir: str | None = None,
654
654
  ):
655
655
  """
656
656
  Run the L2M processing of a station by invoking the disdrodb_run_l2m_station command in the terminal.
@@ -757,8 +757,8 @@ def run_l0a(
757
757
  debugging_mode: bool = False,
758
758
  parallel: bool = True,
759
759
  # DISDRODB root directories
760
- data_archive_dir: Optional[str] = None,
761
- metadata_archive_dir: Optional[str] = None,
760
+ data_archive_dir: str | None = None,
761
+ metadata_archive_dir: str | None = None,
762
762
  ):
763
763
  """Run the L0A processing of DISDRODB stations.
764
764
 
@@ -860,8 +860,8 @@ def run_l0b(
860
860
  debugging_mode: bool = False,
861
861
  parallel: bool = True,
862
862
  # DISDRODB root directories
863
- data_archive_dir: Optional[str] = None,
864
- metadata_archive_dir: Optional[str] = None,
863
+ data_archive_dir: str | None = None,
864
+ metadata_archive_dir: str | None = None,
865
865
  ):
866
866
  """Run the L0B processing of DISDRODB stations.
867
867
 
@@ -969,8 +969,8 @@ def run_l0c(
969
969
  debugging_mode: bool = False,
970
970
  parallel: bool = True,
971
971
  # DISDRODB root directories
972
- data_archive_dir: Optional[str] = None,
973
- metadata_archive_dir: Optional[str] = None,
972
+ data_archive_dir: str | None = None,
973
+ metadata_archive_dir: str | None = None,
974
974
  ):
975
975
  """Run the L0C processing of DISDRODB stations.
976
976
 
@@ -1084,8 +1084,8 @@ def run_l0(
1084
1084
  debugging_mode: bool = False,
1085
1085
  parallel: bool = True,
1086
1086
  # DISDRODB root directories
1087
- data_archive_dir: Optional[str] = None,
1088
- metadata_archive_dir: Optional[str] = None,
1087
+ data_archive_dir: str | None = None,
1088
+ metadata_archive_dir: str | None = None,
1089
1089
  ):
1090
1090
  """Run the L0 processing of DISDRODB stations.
1091
1091
 
@@ -1213,8 +1213,8 @@ def run_l1(
1213
1213
  debugging_mode: bool = False,
1214
1214
  parallel: bool = True,
1215
1215
  # DISDRODB root directories
1216
- data_archive_dir: Optional[str] = None,
1217
- metadata_archive_dir: Optional[str] = None,
1216
+ data_archive_dir: str | None = None,
1217
+ metadata_archive_dir: str | None = None,
1218
1218
  ):
1219
1219
  """Run the L1 processing of DISDRODB stations.
1220
1220
 
@@ -1317,8 +1317,8 @@ def run_l2e(
1317
1317
  debugging_mode: bool = False,
1318
1318
  parallel: bool = True,
1319
1319
  # DISDRODB root directories
1320
- data_archive_dir: Optional[str] = None,
1321
- metadata_archive_dir: Optional[str] = None,
1320
+ data_archive_dir: str | None = None,
1321
+ metadata_archive_dir: str | None = None,
1322
1322
  ):
1323
1323
  """Run the L2E processing of DISDRODB stations.
1324
1324
 
@@ -1420,8 +1420,8 @@ def run_l2m(
1420
1420
  debugging_mode: bool = False,
1421
1421
  parallel: bool = True,
1422
1422
  # DISDRODB root directories
1423
- data_archive_dir: Optional[str] = None,
1424
- metadata_archive_dir: Optional[str] = None,
1423
+ data_archive_dir: str | None = None,
1424
+ metadata_archive_dir: str | None = None,
1425
1425
  ):
1426
1426
  """Run the L2M processing of DISDRODB stations.
1427
1427
 
@@ -1535,8 +1535,8 @@ def run_station(
1535
1535
  debugging_mode: bool = False,
1536
1536
  parallel: bool = True,
1537
1537
  # DISDRODB root directories
1538
- data_archive_dir: Optional[str] = None,
1539
- metadata_archive_dir: Optional[str] = None,
1538
+ data_archive_dir: str | None = None,
1539
+ metadata_archive_dir: str | None = None,
1540
1540
  ):
1541
1541
  """Run the complete processing chain of a specific DISDRODB station from the terminal.
1542
1542
 
@@ -1722,8 +1722,8 @@ def run(
1722
1722
  debugging_mode: bool = False,
1723
1723
  parallel: bool = True,
1724
1724
  # DISDRODB root directories
1725
- data_archive_dir: Optional[str] = None,
1726
- metadata_archive_dir: Optional[str] = None,
1725
+ data_archive_dir: str | None = None,
1726
+ metadata_archive_dir: str | None = None,
1727
1727
  ):
1728
1728
  """Run the complete processing chain of DISDRODB stations.
1729
1729
 
@@ -16,7 +16,6 @@
16
16
  # -----------------------------------------------------------------------------.
17
17
  """Implement PSD scattering routines."""
18
18
 
19
-
20
19
  from disdrodb.scattering.axis_ratio import available_axis_ratio_models, get_axis_ratio_model
21
20
  from disdrodb.scattering.permittivity import available_permittivity_models, get_refractive_index
22
21
  from disdrodb.scattering.routines import (
@@ -15,6 +15,7 @@
15
15
  # along with this program. If not, see <http://www.gnu.org/licenses/>.
16
16
  # -----------------------------------------------------------------------------.
17
17
  """Implement particle permittivity models."""
18
+
18
19
  import numpy as np
19
20
  import xarray as xr
20
21
 
@@ -92,14 +92,14 @@ def _check_frequency(frequency):
92
92
  # Not numeric, assume radar band name
93
93
  frequency = check_radar_band(frequency)
94
94
  frequency = frequency_dict[frequency]
95
- if isinstance(frequency, (int, float)):
95
+ if isinstance(frequency, (int, float, np.integer, np.floating)):
96
96
  return _is_valid_numeric_frequency(frequency)
97
97
  raise TypeError(f"Frequency {frequency} must be a string or a number.")
98
98
 
99
99
 
100
100
  def ensure_numerical_frequency(frequency):
101
101
  """Ensure that the frequencies are numerical values in GHz."""
102
- if isinstance(frequency, (str, int, float)):
102
+ if isinstance(frequency, (str, int, float, np.integer, np.floating)):
103
103
  frequency = [frequency]
104
104
  frequency = np.array([_check_frequency(f) for f in frequency])
105
105
  return frequency.squeeze()
@@ -562,7 +562,7 @@ def _estimate_model_radar_parameters(
562
562
  scatterer,
563
563
  ):
564
564
  # Assign PSD model to the scatterer object
565
- parameters = dict(zip(psd_parameters_names, parameters))
565
+ parameters = dict(zip(psd_parameters_names, parameters, strict=True))
566
566
  scatterer.psd = create_psd(psd_model, parameters)
567
567
 
568
568
  # Get radar variables
@@ -15,6 +15,7 @@
15
15
  # along with this program. If not, see <http://www.gnu.org/licenses/>.
16
16
  # -----------------------------------------------------------------------------.
17
17
  """Utilities to create summary statistics."""
18
+
18
19
  import gc
19
20
  import importlib
20
21
  import os
@@ -627,7 +628,7 @@ def fit_powerlaw(x, y, xbins, quantile=0.5, min_counts=10, x_in_db=False, use_ra
627
628
  absolute_sigma=True,
628
629
  maxfev=10_000, # max n iterations
629
630
  )
630
- (a_std, b_std) = np.sqrt(np.diag(pcov))
631
+ a_std, b_std = np.sqrt(np.diag(pcov))
631
632
  a_std = float(a_std)
632
633
  b_std = float(b_std)
633
634
 
@@ -3749,7 +3750,7 @@ def define_filename(prefix, extension, data_source, campaign_name, station_name,
3749
3750
 
3750
3751
  def create_l2_dataframe(ds):
3751
3752
  """Create pandas Dataframe for L2 analysis."""
3752
- dims_to_drop = set(ds.dims).intersection({DIAMETER_DIMENSION, VELOCITY_DIMENSION})
3753
+ dims_to_drop = set(ds.dims).intersection({DIAMETER_DIMENSION, VELOCITY_DIMENSION, "crs"})
3753
3754
  # - Drop array variables and convert to pandas
3754
3755
  df = ds.drop_dims(dims_to_drop).to_pandas()
3755
3756
  # - Drop coordinates
@@ -3801,8 +3802,11 @@ def generate_station_summary(ds, summary_dir_path, data_source, campaign_name, s
3801
3802
  # Ensure all data are in memory
3802
3803
  ds = ds.compute()
3803
3804
 
3804
- # Keep only timesteps with at least 3 Nbins to remove noise
3805
- valid_idx = np.where(ds["Nbins"] >= 3)[0]
3805
+ # Filter dataset to remove noisy timesteps
3806
+ # - Keep only timesteps with at least 3 Nbins to remove noise
3807
+ # - Keep only timesteps with sigma_m >= 0.2
3808
+ mask = (ds["Nbins"] >= 3) & (ds["sigma_m"] >= 0.2) & (ds["Nbins_missing_fraction"] <= 0.3) & (ds["Dmin"] <= 1)
3809
+ valid_idx = np.where(mask)[0]
3806
3810
  ds = ds.isel(time=valid_idx)
3807
3811
 
3808
3812
  ####---------------------------------------------------------------------.
@@ -3813,7 +3817,10 @@ def generate_station_summary(ds, summary_dir_path, data_source, campaign_name, s
3813
3817
  drop_number = ds["drop_number"].sum(dim="time")
3814
3818
 
3815
3819
  # Define theoretical and measured average velocity
3816
- theoretical_average_velocity = ds["fall_velocity"].mean(dim="time")
3820
+ if "time" in ds["fall_velocity"].dims:
3821
+ theoretical_average_velocity = ds["fall_velocity"].mean(dim="time")
3822
+ else:
3823
+ theoretical_average_velocity = ds["fall_velocity"]
3817
3824
  measured_average_velocity = get_drop_average_velocity(drop_number)
3818
3825
 
3819
3826
  # Save raw and filtered spectrum over time & theoretical and measured average fall velocity
@@ -15,6 +15,7 @@
15
15
  # along with this program. If not, see <http://www.gnu.org/licenses/>.
16
16
  # -----------------------------------------------------------------------------.
17
17
  """Utility function for DISDRODB product archiving."""
18
+
18
19
  import datetime
19
20
 
20
21
  import numpy as np
@@ -324,7 +325,7 @@ def _map_files_to_blocks(files_start_time, files_end_time, filepaths, block_star
324
325
  # Create a list with the a dictionary for each block
325
326
  filepaths = np.array(filepaths)
326
327
  results = []
327
- for i, (start, end) in enumerate(zip(block_starts, block_ends)):
328
+ for i, (start, end) in enumerate(zip(block_starts, block_ends, strict=True)):
328
329
  indices = np.where(mask[:, i])[0]
329
330
  if indices.size > 0:
330
331
  results.append(
disdrodb/utils/attrs.py CHANGED
@@ -15,9 +15,10 @@
15
15
  # along with this program. If not, see <http://www.gnu.org/licenses/>.
16
16
  # -----------------------------------------------------------------------------.
17
17
  """DISDRODB netCDF4 attributes utilities."""
18
- import datetime
18
+
19
19
  import os
20
20
 
21
+ from disdrodb.api.checks import get_current_utc_time
21
22
  from disdrodb.constants import ARCHIVE_VERSION, CONVENTIONS, COORDINATES, SOFTWARE_VERSION
22
23
  from disdrodb.utils.yaml import read_yaml
23
24
 
@@ -104,7 +105,7 @@ def update_disdrodb_attrs(ds, product: str):
104
105
  # ----------------------------------------------
105
106
  # Set DISDRODDB attributes
106
107
  # - Add DISDRODB processing info
107
- now = datetime.datetime.utcnow()
108
+ now = get_current_utc_time()
108
109
  current_time = now.strftime("%Y-%m-%d %H:%M:%S")
109
110
  attrs["disdrodb_processing_date"] = current_time
110
111
  # - Add DISDRODB product and version
@@ -23,7 +23,6 @@ import shutil
23
23
  import subprocess
24
24
  import tempfile
25
25
  import zipfile
26
- from typing import Optional
27
26
 
28
27
  from disdrodb.api.checks import check_data_archive_dir
29
28
  from disdrodb.api.path import define_station_dir
@@ -239,7 +238,7 @@ def compress_file(filepath: str, method: str, skip: bool) -> str:
239
238
  return compressed_filepath
240
239
 
241
240
 
242
- def _check_file_compression(filepath: str) -> Optional[str]:
241
+ def _check_file_compression(filepath: str) -> str | None:
243
242
  """Check the method used to compress a raw text file.
244
243
 
245
244
  From https://stackoverflow.com/questions/13044562/python-mechanism-to-identify-compressed-file-type-and-uncompress