disdrodb 0.1.5__py3-none-any.whl → 0.2.1__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 (125) hide show
  1. disdrodb/__init__.py +1 -5
  2. disdrodb/_version.py +2 -2
  3. disdrodb/accessor/methods.py +22 -4
  4. disdrodb/api/checks.py +10 -0
  5. disdrodb/api/io.py +20 -18
  6. disdrodb/api/path.py +42 -77
  7. disdrodb/api/search.py +89 -23
  8. disdrodb/cli/disdrodb_create_summary.py +1 -1
  9. disdrodb/cli/disdrodb_run_l0.py +1 -1
  10. disdrodb/cli/disdrodb_run_l0a.py +1 -1
  11. disdrodb/cli/disdrodb_run_l0b.py +1 -1
  12. disdrodb/cli/disdrodb_run_l0c.py +1 -1
  13. disdrodb/cli/disdrodb_run_l1.py +1 -1
  14. disdrodb/cli/disdrodb_run_l2e.py +1 -1
  15. disdrodb/cli/disdrodb_run_l2m.py +1 -1
  16. disdrodb/configs.py +30 -83
  17. disdrodb/constants.py +4 -3
  18. disdrodb/data_transfer/download_data.py +4 -2
  19. disdrodb/docs.py +2 -2
  20. disdrodb/etc/products/L1/1MIN.yaml +13 -0
  21. disdrodb/etc/products/L1/LPM/1MIN.yaml +13 -0
  22. disdrodb/etc/products/L1/LPM_V0/1MIN.yaml +13 -0
  23. disdrodb/etc/products/L1/PARSIVEL/1MIN.yaml +13 -0
  24. disdrodb/etc/products/L1/PARSIVEL2/1MIN.yaml +13 -0
  25. disdrodb/etc/products/L1/PWS100/1MIN.yaml +13 -0
  26. disdrodb/etc/products/L1/RD80/1MIN.yaml +13 -0
  27. disdrodb/etc/products/L1/SWS250/1MIN.yaml +13 -0
  28. disdrodb/etc/products/L1/global.yaml +6 -0
  29. disdrodb/etc/products/L2E/10MIN.yaml +1 -12
  30. disdrodb/etc/products/L2E/global.yaml +1 -1
  31. disdrodb/etc/products/L2M/MODELS/NGAMMA_GS_R_MAE.yaml +6 -0
  32. disdrodb/etc/products/L2M/global.yaml +1 -1
  33. disdrodb/issue/checks.py +2 -2
  34. disdrodb/l0/check_configs.py +1 -1
  35. disdrodb/l0/configs/LPM/l0a_encodings.yml +0 -1
  36. disdrodb/l0/configs/LPM/l0b_cf_attrs.yml +0 -4
  37. disdrodb/l0/configs/LPM/l0b_encodings.yml +9 -9
  38. disdrodb/l0/configs/LPM/raw_data_format.yml +11 -11
  39. disdrodb/l0/configs/LPM_V0/bins_diameter.yml +103 -0
  40. disdrodb/l0/configs/LPM_V0/bins_velocity.yml +103 -0
  41. disdrodb/l0/configs/LPM_V0/l0a_encodings.yml +45 -0
  42. disdrodb/l0/configs/LPM_V0/l0b_cf_attrs.yml +180 -0
  43. disdrodb/l0/configs/LPM_V0/l0b_encodings.yml +410 -0
  44. disdrodb/l0/configs/LPM_V0/raw_data_format.yml +474 -0
  45. disdrodb/l0/configs/PARSIVEL/l0b_encodings.yml +1 -1
  46. disdrodb/l0/configs/PARSIVEL/raw_data_format.yml +8 -8
  47. disdrodb/l0/configs/PARSIVEL2/raw_data_format.yml +9 -9
  48. disdrodb/l0/l0_reader.py +2 -2
  49. disdrodb/l0/l0a_processing.py +6 -2
  50. disdrodb/l0/l0b_processing.py +26 -19
  51. disdrodb/l0/l0c_processing.py +17 -3
  52. disdrodb/l0/manuals/LPM_V0.pdf +0 -0
  53. disdrodb/l0/readers/LPM/ITALY/GID_LPM.py +15 -7
  54. disdrodb/l0/readers/LPM/ITALY/GID_LPM_PI.py +279 -0
  55. disdrodb/l0/readers/LPM/ITALY/GID_LPM_T.py +276 -0
  56. disdrodb/l0/readers/LPM/ITALY/GID_LPM_W.py +2 -2
  57. disdrodb/l0/readers/LPM/NETHERLANDS/DELFT_RWANDA_LPM_NC.py +103 -0
  58. disdrodb/l0/readers/LPM/NORWAY/HAUKELISETER_LPM.py +216 -0
  59. disdrodb/l0/readers/LPM/NORWAY/NMBU_LPM.py +208 -0
  60. disdrodb/l0/readers/LPM/UK/WITHWORTH_LPM.py +219 -0
  61. disdrodb/l0/readers/LPM/USA/CHARLESTON.py +229 -0
  62. disdrodb/l0/readers/{LPM → LPM_V0}/BELGIUM/ULIEGE.py +33 -49
  63. disdrodb/l0/readers/LPM_V0/ITALY/GID_LPM_V0.py +240 -0
  64. disdrodb/l0/readers/PARSIVEL/BASQUECOUNTRY/EUSKALMET_OTT.py +227 -0
  65. disdrodb/l0/readers/{PARSIVEL2 → PARSIVEL}/NASA/LPVEX.py +16 -28
  66. disdrodb/l0/readers/PARSIVEL/{GPM → NASA}/MC3E.py +1 -1
  67. disdrodb/l0/readers/PARSIVEL/NCAR/VORTEX2_2010_UF.py +3 -3
  68. disdrodb/l0/readers/PARSIVEL2/BASQUECOUNTRY/EUSKALMET_OTT2.py +232 -0
  69. disdrodb/l0/readers/PARSIVEL2/DENMARK/EROSION_raw.py +1 -1
  70. disdrodb/l0/readers/PARSIVEL2/JAPAN/PRECIP.py +155 -0
  71. disdrodb/l0/readers/PARSIVEL2/MPI/BCO_PARSIVEL2.py +14 -7
  72. disdrodb/l0/readers/PARSIVEL2/MPI/BOWTIE.py +8 -3
  73. disdrodb/l0/readers/PARSIVEL2/NASA/APU.py +28 -5
  74. disdrodb/l0/readers/PARSIVEL2/NCAR/RELAMPAGO_PARSIVEL2.py +1 -1
  75. disdrodb/l0/readers/PARSIVEL2/{GPM/GCPEX.py → NORWAY/UIB.py} +54 -29
  76. disdrodb/l0/readers/PARSIVEL2/PHILIPPINES/{PANGASA.py → PAGASA.py} +6 -3
  77. disdrodb/l0/readers/PARSIVEL2/SPAIN/GRANADA.py +1 -1
  78. disdrodb/l0/readers/PARSIVEL2/SWEDEN/SMHI.py +189 -0
  79. disdrodb/l0/readers/{PARSIVEL/GPM/PIERS.py → PARSIVEL2/USA/CSU.py} +62 -29
  80. disdrodb/l0/readers/PARSIVEL2/USA/{C3WE.py → CW3E.py} +51 -24
  81. disdrodb/l0/readers/{PARSIVEL/GPM/IFLOODS.py → RD80/BRAZIL/ATTO_RD80.py} +50 -34
  82. disdrodb/l0/readers/{SW250 → SWS250}/BELGIUM/KMI.py +1 -1
  83. disdrodb/l1/beard_model.py +45 -1
  84. disdrodb/l1/fall_velocity.py +1 -6
  85. disdrodb/l1/filters.py +2 -0
  86. disdrodb/l1/processing.py +6 -5
  87. disdrodb/l1/resampling.py +101 -38
  88. disdrodb/l2/empirical_dsd.py +12 -8
  89. disdrodb/l2/processing.py +4 -3
  90. disdrodb/metadata/search.py +3 -4
  91. disdrodb/routines/l0.py +4 -4
  92. disdrodb/routines/l1.py +173 -60
  93. disdrodb/routines/l2.py +121 -269
  94. disdrodb/routines/options.py +347 -0
  95. disdrodb/routines/wrappers.py +9 -1
  96. disdrodb/scattering/axis_ratio.py +3 -0
  97. disdrodb/scattering/routines.py +1 -1
  98. disdrodb/summary/routines.py +765 -724
  99. disdrodb/utils/archiving.py +51 -44
  100. disdrodb/utils/attrs.py +1 -1
  101. disdrodb/utils/compression.py +4 -2
  102. disdrodb/utils/dask.py +35 -15
  103. disdrodb/utils/dict.py +33 -0
  104. disdrodb/utils/encoding.py +1 -1
  105. disdrodb/utils/manipulations.py +7 -1
  106. disdrodb/utils/routines.py +9 -8
  107. disdrodb/utils/time.py +9 -1
  108. disdrodb/viz/__init__.py +0 -13
  109. disdrodb/viz/plots.py +209 -0
  110. {disdrodb-0.1.5.dist-info → disdrodb-0.2.1.dist-info}/METADATA +1 -1
  111. {disdrodb-0.1.5.dist-info → disdrodb-0.2.1.dist-info}/RECORD +124 -95
  112. disdrodb/l0/readers/PARSIVEL/GPM/LPVEX.py +0 -85
  113. /disdrodb/etc/products/L2M/{GAMMA_GS_ND_MAE.yaml → MODELS/GAMMA_GS_ND_MAE.yaml} +0 -0
  114. /disdrodb/etc/products/L2M/{GAMMA_ML.yaml → MODELS/GAMMA_ML.yaml} +0 -0
  115. /disdrodb/etc/products/L2M/{LOGNORMAL_GS_LOG_ND_MAE.yaml → MODELS/LOGNORMAL_GS_LOG_ND_MAE.yaml} +0 -0
  116. /disdrodb/etc/products/L2M/{LOGNORMAL_GS_ND_MAE.yaml → MODELS/LOGNORMAL_GS_ND_MAE.yaml} +0 -0
  117. /disdrodb/etc/products/L2M/{LOGNORMAL_ML.yaml → MODELS/LOGNORMAL_ML.yaml} +0 -0
  118. /disdrodb/etc/products/L2M/{NGAMMA_GS_LOG_ND_MAE.yaml → MODELS/NGAMMA_GS_LOG_ND_MAE.yaml} +0 -0
  119. /disdrodb/etc/products/L2M/{NGAMMA_GS_ND_MAE.yaml → MODELS/NGAMMA_GS_ND_MAE.yaml} +0 -0
  120. /disdrodb/etc/products/L2M/{NGAMMA_GS_Z_MAE.yaml → MODELS/NGAMMA_GS_Z_MAE.yaml} +0 -0
  121. /disdrodb/l0/readers/PARSIVEL2/{GPM → NASA}/NSSTC.py +0 -0
  122. {disdrodb-0.1.5.dist-info → disdrodb-0.2.1.dist-info}/WHEEL +0 -0
  123. {disdrodb-0.1.5.dist-info → disdrodb-0.2.1.dist-info}/entry_points.txt +0 -0
  124. {disdrodb-0.1.5.dist-info → disdrodb-0.2.1.dist-info}/licenses/LICENSE +0 -0
  125. {disdrodb-0.1.5.dist-info → disdrodb-0.2.1.dist-info}/top_level.txt +0 -0
disdrodb/__init__.py CHANGED
@@ -39,8 +39,6 @@ from disdrodb.configs import (
39
39
  define_configs,
40
40
  get_data_archive_dir,
41
41
  get_metadata_archive_dir,
42
- get_model_options,
43
- get_product_options,
44
42
  get_scattering_table_dir,
45
43
  )
46
44
  from disdrodb.data_transfer.download_data import download_archive, download_station
@@ -145,8 +143,6 @@ __all__ = [
145
143
  "generate_l2m",
146
144
  "get_data_archive_dir",
147
145
  "get_metadata_archive_dir",
148
- "get_model_options",
149
- "get_product_options",
150
146
  "get_reader",
151
147
  "get_scattering_table_dir",
152
148
  "get_station_reader",
@@ -177,7 +173,7 @@ __all__ = [
177
173
  ]
178
174
 
179
175
 
180
- __root_path__ = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
176
+ package_dir = os.path.dirname(os.path.realpath(__file__))
181
177
 
182
178
 
183
179
  def is_pytmatrix_available():
disdrodb/_version.py CHANGED
@@ -28,7 +28,7 @@ version_tuple: VERSION_TUPLE
28
28
  commit_id: COMMIT_ID
29
29
  __commit_id__: COMMIT_ID
30
30
 
31
- __version__ = version = '0.1.5'
32
- __version_tuple__ = version_tuple = (0, 1, 5)
31
+ __version__ = version = '0.2.1'
32
+ __version_tuple__ = version_tuple = (0, 2, 1)
33
33
 
34
34
  __commit_id__ = commit_id = None
@@ -64,6 +64,13 @@ class DISDRODB_Base_Accessor:
64
64
 
65
65
  return get_diameter_bin_edges(self._obj)
66
66
 
67
+ @property
68
+ def velocity_bin_edges(self):
69
+ """Return velocity bin edges."""
70
+ from disdrodb.utils.manipulations import get_velocity_bin_edges
71
+
72
+ return get_velocity_bin_edges(self._obj)
73
+
67
74
  def regularize(self):
68
75
  """Regularize timesteps."""
69
76
  from disdrodb.utils.time import regularize_dataset
@@ -89,6 +96,12 @@ class DISDRODB_Base_Accessor:
89
96
 
90
97
  return align(self._obj, *args)
91
98
 
99
+ def plot_spectrum(self, **kwargs):
100
+ """Plot spectrum."""
101
+ from disdrodb.viz.plots import plot_spectrum
102
+
103
+ return plot_spectrum(self._obj, **kwargs)
104
+
92
105
 
93
106
  @xr.register_dataset_accessor("disdrodb")
94
107
  class DISDRODB_Dataset_Accessor(DISDRODB_Base_Accessor):
@@ -97,7 +110,7 @@ class DISDRODB_Dataset_Accessor(DISDRODB_Base_Accessor):
97
110
  def __init__(self, xarray_obj):
98
111
  super().__init__(xarray_obj)
99
112
 
100
- def resample(self, accumulation_interval, rolling=True):
113
+ def resample(self, temporal_resolution):
101
114
  """Resample a L1 or L2 DISDRODB Product."""
102
115
  from disdrodb.l1.resampling import resample_dataset
103
116
 
@@ -105,8 +118,7 @@ class DISDRODB_Dataset_Accessor(DISDRODB_Base_Accessor):
105
118
  ds = resample_dataset(
106
119
  self._obj,
107
120
  sample_interval=sample_interval,
108
- accumulation_interval=accumulation_interval,
109
- rolling=rolling,
121
+ temporal_resolution=temporal_resolution,
110
122
  )
111
123
  return ds
112
124
 
@@ -114,7 +126,13 @@ class DISDRODB_Dataset_Accessor(DISDRODB_Base_Accessor):
114
126
  """Plot drop number concentration N(D) timeseries."""
115
127
  from disdrodb.viz.plots import plot_nd
116
128
 
117
- plot_nd(self._obj, **kwargs)
129
+ return plot_nd(self._obj, **kwargs)
130
+
131
+ def plot_raw_and_filtered_spectra(self, **kwargs):
132
+ """Plot the raw and filtered spectra."""
133
+ from disdrodb.viz.plots import plot_raw_and_filtered_spectra
134
+
135
+ return plot_raw_and_filtered_spectra(self._obj, **kwargs)
118
136
 
119
137
 
120
138
  @xr.register_dataarray_accessor("disdrodb")
disdrodb/api/checks.py CHANGED
@@ -154,6 +154,16 @@ def check_rolling(rolling):
154
154
  raise TypeError("'rolling' must be a boolean.")
155
155
 
156
156
 
157
+ def check_temporal_resolution(temporal_resolution):
158
+ """Check temporal resolution validity."""
159
+ from disdrodb.utils.time import get_sampling_information
160
+
161
+ if not isinstance(temporal_resolution, str):
162
+ raise TypeError("'temporal_resolution' must be a string.")
163
+ # If correct, the follow should not raise error
164
+ _ = get_sampling_information(temporal_resolution)
165
+
166
+
157
167
  def check_folder_partitioning(folder_partitioning):
158
168
  """
159
169
  Check if the given folder partitioning scheme is valid.
disdrodb/api/io.py CHANGED
@@ -40,6 +40,7 @@ from disdrodb.api.path import (
40
40
  define_station_dir,
41
41
  )
42
42
  from disdrodb.l0.l0_reader import define_readers_directory
43
+ from disdrodb.utils.dict import extract_product_kwargs
43
44
  from disdrodb.utils.directories import list_files
44
45
  from disdrodb.utils.logger import (
45
46
  log_info,
@@ -117,7 +118,7 @@ def filter_by_time(filepaths, start_time=None, end_time=None):
117
118
  start_time, end_time = check_start_end_time(start_time, end_time)
118
119
 
119
120
  # -------------------------------------------------------------------------.
120
- # - Retrieve start_time and end_time of GPM granules
121
+ # - Retrieve files start_time and end_time
121
122
  l_start_time, l_end_time = get_start_end_time_from_filepaths(filepaths)
122
123
 
123
124
  # -------------------------------------------------------------------------.
@@ -165,12 +166,9 @@ def find_files(
165
166
 
166
167
  Other Parameters
167
168
  ----------------
168
- sample_interval : int, optional
169
- The sampling interval in seconds of the product.
170
- It must be specified only for product L2E and L2M !
171
- rolling : bool, optional
172
- Whether the dataset has been resampled by aggregating or rolling.
173
- It must be specified only for product L2E and L2M !
169
+ temporal_resolution : str, optional
170
+ The temporal resolution of the product (e.g., "1MIN", "10MIN", "1H").
171
+ It must be specified only for product L1, L2E and L2M !
174
172
  model_name : str
175
173
  The model name of the statistical distribution for the DSD.
176
174
  It must be specified only for product L2M !
@@ -349,6 +347,7 @@ def open_netcdf_files(
349
347
  ds = xr.open_mfdataset(
350
348
  filepaths,
351
349
  chunks=chunks,
350
+ data_vars="all",
352
351
  combine="nested",
353
352
  join="outer",
354
353
  concat_dim="time",
@@ -357,7 +356,7 @@ def open_netcdf_files(
357
356
  preprocess=preprocess,
358
357
  compat="no_conflicts",
359
358
  combine_attrs="override",
360
- coords="different", # maybe minimal?
359
+ coords="different", # maybe minimal? would remove lon/lat/alt?
361
360
  decode_timedelta=False,
362
361
  cache=False,
363
362
  autoclose=True,
@@ -411,21 +410,19 @@ def open_dataset(
411
410
  The name of the station.
412
411
  product : str
413
412
  The name DISDRODB product.
414
- sample_interval : int, optional
415
- The sampling interval in seconds of the product.
416
- It must be specified only for product L2E and L2M !
417
- rolling : bool, optional
418
- Whether the dataset has been resampled by aggregating or rolling.
419
- It must be specified only for product L2E and L2M !
420
- model_name : str
421
- The model name of the statistical distribution for the DSD.
422
- It must be specified only for product L2M !
423
413
  debugging_mode : bool, optional
424
414
  If ``True``, it select maximum 3 files for debugging purposes.
425
415
  The default value is ``False``.
426
416
  data_archive_dir : str, optional
427
417
  The base directory of DISDRODB, expected in the format ``<...>/DISDRODB``.
428
418
  If not specified, the path specified in the DISDRODB active configuration will be used.
419
+ **product_kwargs : optional
420
+ DISDRODB product options
421
+ It must be specified only for product L1, L2E and L2M products !
422
+ For L1, L2E and L2M products, temporal_resolution is required
423
+ FOr L2M product, model_name is required.
424
+ **open_kwargs : optional
425
+ Additional keyword arguments passed to ``xarray.open_mfdataset()``.
429
426
 
430
427
  Returns
431
428
  -------
@@ -434,7 +431,8 @@ def open_dataset(
434
431
  """
435
432
  from disdrodb.l0.l0a_processing import read_l0a_dataframe
436
433
 
437
- product_kwargs = product_kwargs if product_kwargs else {}
434
+ # Extract product kwargs from open_kwargs
435
+ product_kwargs = extract_product_kwargs(open_kwargs, product=product)
438
436
 
439
437
  # List product files
440
438
  filepaths = find_files(
@@ -478,6 +476,10 @@ def open_dataset(
478
476
  compute=compute,
479
477
  **open_kwargs,
480
478
  )
479
+
480
+ # Ensure coordinates in memory
481
+ # for coord in list(ds.coords):
482
+ # ds[coord] = ds[coord].compute()
481
483
  return ds
482
484
 
483
485
 
disdrodb/api/path.py CHANGED
@@ -336,13 +336,13 @@ def define_issue_filepath(
336
336
 
337
337
  def define_config_dir(product):
338
338
  """Define the config directory path of a given DISDRODB product."""
339
- from disdrodb import __root_path__
339
+ from disdrodb import package_dir
340
340
 
341
341
  if product.upper() in ["RAW", "L0A", "L0B"]:
342
342
  dir_name = "l0"
343
343
  else:
344
344
  raise NotImplementedError(f"Product {product} not implemented.")
345
- config_dir = os.path.join(__root_path__, "disdrodb", dir_name, "configs")
345
+ config_dir = os.path.join(package_dir, dir_name, "configs")
346
346
  return config_dir
347
347
 
348
348
 
@@ -448,12 +448,9 @@ def define_product_dir_tree(
448
448
  ----------
449
449
  product : str
450
450
  The DISDRODB product. See ``disdrodb.available_products()``.
451
- sample_interval : int, optional
452
- The sampling interval in seconds of the product.
453
- It must be specified only for product L2E and L2M !
454
- rolling : bool, optional
455
- Whether the dataset has been resampled by aggregating or rolling.
456
- It must be specified only for product L2E and L2M !
451
+ temporal_resolution : str, optional
452
+ The temporal resolution of the product.
453
+ It must be specified only for product L1, L2E and L2M !
457
454
  model_name : str
458
455
  The custom model name of the fitted statistical distribution.
459
456
  It must be specified only for product L2M !
@@ -463,28 +460,23 @@ def define_product_dir_tree(
463
460
  data_dir : str
464
461
  Station data directory path
465
462
  """
466
- from disdrodb.api.checks import check_product, check_product_kwargs, check_rolling, check_sample_interval
463
+ from disdrodb.api.checks import check_product, check_product_kwargs, check_temporal_resolution
467
464
 
468
465
  product = check_product(product)
469
466
  product_kwargs = check_product_kwargs(product, product_kwargs)
470
467
  if product.upper() == "RAW":
471
468
  return ""
472
- if product.upper() in ["L0A", "L0B", "L0C", "L1"]:
469
+ if product.upper() in ["L0A", "L0B", "L0C"]:
473
470
  return ""
474
- if product == "L2E":
475
- rolling = product_kwargs.get("rolling")
476
- sample_interval = product_kwargs.get("sample_interval")
477
- check_rolling(rolling)
478
- check_sample_interval(sample_interval)
479
- temporal_resolution = define_temporal_resolution(seconds=sample_interval, rolling=rolling)
480
- return os.path.join(temporal_resolution)
471
+ if product in ["L1", "L2E"]:
472
+ temporal_resolution = product_kwargs.get("temporal_resolution")
473
+ check_temporal_resolution(temporal_resolution)
474
+ return temporal_resolution
481
475
  # L2M if product == "L2M":
482
- rolling = product_kwargs.get("rolling")
483
- sample_interval = product_kwargs.get("sample_interval")
476
+ temporal_resolution = product_kwargs.get("temporal_resolution")
477
+ check_temporal_resolution(temporal_resolution)
484
478
  model_name = product_kwargs.get("model_name")
485
- check_rolling(rolling)
486
- check_sample_interval(sample_interval)
487
- temporal_resolution = define_temporal_resolution(seconds=sample_interval, rolling=rolling)
479
+
488
480
  return os.path.join(model_name, temporal_resolution)
489
481
 
490
482
 
@@ -611,12 +603,9 @@ def define_data_dir(
611
603
  If not specified, the path specified in the DISDRODB active configuration will be used.
612
604
  check_exists : bool, optional
613
605
  Whether to check if the directory exists. The default value is ``False``.
614
- sample_interval : int, optional
615
- The sampling interval in seconds of the product.
616
- It must be specified only for product L2E and L2M !
617
- rolling : bool, optional
618
- Whether the dataset has been resampled by aggregating or rolling.
619
- It must be specified only for product L2E and L2M !
606
+ temporal_resolution : str, optional
607
+ The temporal resolution of the product.
608
+ It must be specified only for product L1, L2E and L2M !
620
609
  model_name : str
621
610
  The name of the fitted statistical distribution for the DSD.
622
611
  It must be specified only for product L2M !
@@ -701,11 +690,8 @@ def define_filename(
701
690
  end_time : datetime.datatime, optional
702
691
  End time.
703
692
  Required if add_time_period = True.
704
- sample_interval : int, optional
705
- The sampling interval in seconds of the product.
706
- It must be specified only for product L0C, L1, L2E and L2M !
707
- rolling : bool, optional
708
- Whether the dataset has been resampled by aggregating or rolling.
693
+ temporal_resolution : str, optional
694
+ The temporal resolution of the product.
709
695
  It must be specified only for product L1, L2E and L2M !
710
696
  model_name : str
711
697
  The model name of the fitted statistical distribution for the DSD.
@@ -716,7 +702,7 @@ def define_filename(
716
702
  str
717
703
  L0B file name.
718
704
  """
719
- from disdrodb.api.checks import check_product, check_product_kwargs
705
+ from disdrodb.api.checks import check_product, check_product_kwargs, check_temporal_resolution
720
706
 
721
707
  product = check_product(product)
722
708
  product_kwargs = check_product_kwargs(product, product_kwargs)
@@ -729,16 +715,9 @@ def define_filename(
729
715
  product_name = f"{product}"
730
716
 
731
717
  # L0C ... sample interval known only per-file
732
- # L1 ... in future known a priori
733
- # if product in ["L1"]:
734
- # # TODO: HACK FOR CURRENT L0C and L1 log files in create_product_logs
735
- # sample_interval = product_kwargs.get("sample_interval", 0)
736
- # temporal_resolution = define_temporal_resolution(seconds=sample_interval, rolling=False)
737
- # product_name = f"{product}.{temporal_resolution}"
738
- if product in ["L2E", "L2M"]:
739
- rolling = product_kwargs.get("rolling")
740
- sample_interval = product_kwargs.get("sample_interval")
741
- temporal_resolution = define_temporal_resolution(seconds=sample_interval, rolling=rolling)
718
+ if product in ["L1", "L2E", "L2M"]:
719
+ temporal_resolution = product_kwargs.get("temporal_resolution")
720
+ check_temporal_resolution(temporal_resolution)
742
721
  product_name = f"{product}.{temporal_resolution}"
743
722
  if product in ["L2M"]:
744
723
  model_name = product_kwargs.get("model_name")
@@ -828,7 +807,7 @@ def define_l0b_filename(ds, campaign_name: str, station_name: str) -> str:
828
807
 
829
808
  def define_l0c_filename(ds, campaign_name: str, station_name: str) -> str:
830
809
  """Define L0C file name."""
831
- # TODO: add sample_interval as function argument s
810
+ # TODO: add sample_interval as function argument
832
811
  sample_interval = int(ensure_sample_interval_in_seconds(ds["sample_interval"]).data.item())
833
812
  temporal_resolution = define_temporal_resolution(sample_interval, rolling=False)
834
813
  starting_time, ending_time = get_file_start_end_time(ds)
@@ -839,37 +818,26 @@ def define_l0c_filename(ds, campaign_name: str, station_name: str) -> str:
839
818
  return filename
840
819
 
841
820
 
842
- def define_l1_filename(ds, campaign_name, station_name: str) -> str:
821
+ def define_l1_filename(ds, campaign_name, station_name: str, temporal_resolution: str) -> str:
843
822
  """Define L1 file name."""
844
- # TODO: add sample_interval and rolling as function argument
845
-
846
823
  starting_time, ending_time = get_file_start_end_time(ds)
847
- sample_interval = int(ensure_sample_interval_in_seconds(ds["sample_interval"]).data.item())
848
- temporal_resolution = define_temporal_resolution(sample_interval, rolling=False)
849
- starting_time, ending_time = get_file_start_end_time(ds)
850
- starting_time = starting_time.strftime("%Y%m%d%H%M%S")
851
- ending_time = ending_time.strftime("%Y%m%d%H%M%S")
852
- version = ARCHIVE_VERSION
853
- filename = f"L1.{temporal_resolution}.{campaign_name}.{station_name}.s{starting_time}.e{ending_time}.{version}.nc"
854
-
855
- # filename = define_filename(
856
- # product="L1",
857
- # campaign_name=campaign_name,
858
- # station_name=station_name,
859
- # # Filename options
860
- # start_time=starting_time,
861
- # end_time=ending_time,
862
- # add_version=True,
863
- # add_time_period=True,
864
- # add_extension=True,
865
- # # Product options
866
- # # sample_interval=sample_interval,
867
- # # rolling=rolling,
868
- # )
824
+ filename = define_filename(
825
+ product="L1",
826
+ campaign_name=campaign_name,
827
+ station_name=station_name,
828
+ # Filename options
829
+ start_time=starting_time,
830
+ end_time=ending_time,
831
+ add_version=True,
832
+ add_time_period=True,
833
+ add_extension=True,
834
+ # Product options
835
+ temporal_resolution=temporal_resolution,
836
+ )
869
837
  return filename
870
838
 
871
839
 
872
- def define_l2e_filename(ds, campaign_name: str, station_name: str, sample_interval: int, rolling: bool) -> str:
840
+ def define_l2e_filename(ds, campaign_name: str, station_name: str, temporal_resolution: str) -> str:
873
841
  """Define L2E file name."""
874
842
  starting_time, ending_time = get_file_start_end_time(ds)
875
843
  filename = define_filename(
@@ -883,8 +851,7 @@ def define_l2e_filename(ds, campaign_name: str, station_name: str, sample_interv
883
851
  add_time_period=True,
884
852
  add_extension=True,
885
853
  # Product options
886
- sample_interval=sample_interval,
887
- rolling=rolling,
854
+ temporal_resolution=temporal_resolution,
888
855
  )
889
856
  return filename
890
857
 
@@ -893,8 +860,7 @@ def define_l2m_filename(
893
860
  ds,
894
861
  campaign_name: str,
895
862
  station_name: str,
896
- sample_interval: int,
897
- rolling: bool,
863
+ temporal_resolution: str,
898
864
  model_name: str,
899
865
  ) -> str:
900
866
  """Define L2M file name."""
@@ -910,8 +876,7 @@ def define_l2m_filename(
910
876
  add_time_period=True,
911
877
  add_extension=True,
912
878
  # Product options
913
- sample_interval=sample_interval,
914
- rolling=rolling,
879
+ temporal_resolution=temporal_resolution,
915
880
  model_name=model_name,
916
881
  )
917
882
  return filename