disdrodb 0.1.3__py3-none-any.whl → 0.1.5__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.
- disdrodb/__init__.py +4 -0
- disdrodb/_version.py +2 -2
- disdrodb/api/checks.py +70 -47
- disdrodb/api/configs.py +0 -2
- disdrodb/api/create_directories.py +0 -2
- disdrodb/api/info.py +3 -3
- disdrodb/api/io.py +48 -8
- disdrodb/api/path.py +116 -133
- disdrodb/api/search.py +12 -3
- disdrodb/cli/disdrodb_create_summary.py +113 -0
- disdrodb/cli/disdrodb_create_summary_station.py +11 -1
- disdrodb/cli/disdrodb_run_l0a_station.py +1 -1
- disdrodb/cli/disdrodb_run_l0b_station.py +2 -2
- disdrodb/cli/disdrodb_run_l0c_station.py +2 -2
- disdrodb/cli/disdrodb_run_l1_station.py +2 -2
- disdrodb/cli/disdrodb_run_l2e_station.py +2 -2
- disdrodb/cli/disdrodb_run_l2m_station.py +2 -2
- disdrodb/constants.py +1 -1
- disdrodb/data_transfer/download_data.py +123 -7
- disdrodb/etc/products/L1/global.yaml +1 -1
- disdrodb/etc/products/L2E/5MIN.yaml +1 -0
- disdrodb/etc/products/L2E/global.yaml +1 -1
- disdrodb/etc/products/L2M/GAMMA_GS_ND_MAE.yaml +6 -0
- disdrodb/etc/products/L2M/GAMMA_ML.yaml +1 -1
- disdrodb/etc/products/L2M/LOGNORMAL_GS_LOG_ND_MAE.yaml +6 -0
- disdrodb/etc/products/L2M/LOGNORMAL_GS_ND_MAE.yaml +6 -0
- disdrodb/etc/products/L2M/LOGNORMAL_ML.yaml +8 -0
- disdrodb/etc/products/L2M/global.yaml +11 -3
- disdrodb/issue/writer.py +2 -0
- disdrodb/l0/check_configs.py +49 -16
- disdrodb/l0/configs/LPM/l0a_encodings.yml +2 -2
- disdrodb/l0/configs/LPM/l0b_cf_attrs.yml +2 -2
- disdrodb/l0/configs/LPM/l0b_encodings.yml +2 -2
- disdrodb/l0/configs/LPM/raw_data_format.yml +2 -2
- disdrodb/l0/configs/PWS100/l0b_encodings.yml +1 -0
- disdrodb/l0/configs/SWS250/bins_diameter.yml +108 -0
- disdrodb/l0/configs/SWS250/bins_velocity.yml +83 -0
- disdrodb/l0/configs/SWS250/l0a_encodings.yml +18 -0
- disdrodb/l0/configs/SWS250/l0b_cf_attrs.yml +72 -0
- disdrodb/l0/configs/SWS250/l0b_encodings.yml +155 -0
- disdrodb/l0/configs/SWS250/raw_data_format.yml +148 -0
- disdrodb/l0/l0a_processing.py +10 -5
- disdrodb/l0/l0b_nc_processing.py +10 -6
- disdrodb/l0/l0b_processing.py +92 -72
- disdrodb/l0/l0c_processing.py +369 -251
- disdrodb/l0/readers/LPM/ARM/ARM_LPM.py +8 -1
- disdrodb/l0/readers/LPM/AUSTRALIA/MELBOURNE_2007_LPM.py +2 -2
- disdrodb/l0/readers/LPM/BELGIUM/ULIEGE.py +256 -0
- disdrodb/l0/readers/LPM/BRAZIL/CHUVA_LPM.py +2 -2
- disdrodb/l0/readers/LPM/BRAZIL/GOAMAZON_LPM.py +2 -2
- disdrodb/l0/readers/LPM/GERMANY/DWD.py +491 -0
- disdrodb/l0/readers/LPM/ITALY/GID_LPM.py +2 -2
- disdrodb/l0/readers/LPM/ITALY/GID_LPM_W.py +2 -2
- disdrodb/l0/readers/LPM/KIT/CHWALA.py +2 -2
- disdrodb/l0/readers/LPM/SLOVENIA/ARSO.py +107 -12
- disdrodb/l0/readers/LPM/SLOVENIA/UL.py +3 -3
- disdrodb/l0/readers/LPM/SWITZERLAND/INNERERIZ_LPM.py +2 -2
- disdrodb/l0/readers/PARSIVEL/NCAR/VORTEX2_2010.py +5 -14
- disdrodb/l0/readers/PARSIVEL/NCAR/VORTEX2_2010_UF.py +5 -14
- disdrodb/l0/readers/PARSIVEL/SLOVENIA/UL.py +117 -8
- disdrodb/l0/readers/PARSIVEL2/ARM/ARM_PARSIVEL2.py +4 -0
- disdrodb/l0/readers/PARSIVEL2/BRAZIL/CHUVA_PARSIVEL2.py +10 -14
- disdrodb/l0/readers/PARSIVEL2/BRAZIL/GOAMAZON_PARSIVEL2.py +10 -14
- disdrodb/l0/readers/PARSIVEL2/CANADA/UQAM_NC.py +69 -0
- disdrodb/l0/readers/PARSIVEL2/DENMARK/DTU.py +8 -14
- disdrodb/l0/readers/PARSIVEL2/DENMARK/EROSION_raw.py +382 -0
- disdrodb/l0/readers/PARSIVEL2/FINLAND/FMI_PARSIVEL2.py +4 -0
- disdrodb/l0/readers/PARSIVEL2/FRANCE/OSUG.py +1 -1
- disdrodb/l0/readers/PARSIVEL2/GREECE/NOA.py +127 -0
- disdrodb/l0/readers/PARSIVEL2/ITALY/HYDROX.py +239 -0
- disdrodb/l0/readers/PARSIVEL2/MPI/BCO_PARSIVEL2.py +136 -0
- disdrodb/l0/readers/PARSIVEL2/MPI/BOWTIE.py +220 -0
- disdrodb/l0/readers/PARSIVEL2/NASA/LPVEX.py +109 -0
- disdrodb/l0/readers/PARSIVEL2/NCAR/FARM_PARSIVEL2.py +5 -11
- disdrodb/l0/readers/PARSIVEL2/NCAR/PERILS_MIPS.py +4 -17
- disdrodb/l0/readers/PARSIVEL2/NCAR/RELAMPAGO_PARSIVEL2.py +5 -14
- disdrodb/l0/readers/PARSIVEL2/NCAR/SNOWIE_PJ.py +10 -13
- disdrodb/l0/readers/PARSIVEL2/NCAR/SNOWIE_SB.py +10 -13
- disdrodb/l0/readers/PARSIVEL2/NETHERLANDS/DELFT_NC.py +3 -0
- disdrodb/l0/readers/PARSIVEL2/PHILIPPINES/PANGASA.py +232 -0
- disdrodb/l0/readers/PARSIVEL2/SPAIN/CENER.py +6 -18
- disdrodb/l0/readers/PARSIVEL2/SPAIN/GRANADA.py +120 -0
- disdrodb/l0/readers/PARSIVEL2/USA/C3WE.py +7 -25
- disdrodb/l0/readers/PWS100/AUSTRIA/HOAL.py +321 -0
- disdrodb/l0/readers/SW250/BELGIUM/KMI.py +239 -0
- disdrodb/l1/beard_model.py +31 -129
- disdrodb/l1/fall_velocity.py +156 -57
- disdrodb/l1/filters.py +25 -28
- disdrodb/l1/processing.py +12 -14
- disdrodb/l1_env/routines.py +46 -17
- disdrodb/l2/empirical_dsd.py +6 -0
- disdrodb/l2/processing.py +3 -3
- disdrodb/metadata/checks.py +132 -125
- disdrodb/metadata/geolocation.py +0 -2
- disdrodb/psd/fitting.py +180 -210
- disdrodb/psd/models.py +1 -1
- disdrodb/routines/__init__.py +54 -0
- disdrodb/{l0/routines.py → routines/l0.py} +288 -418
- disdrodb/{l1/routines.py → routines/l1.py} +60 -92
- disdrodb/{l2/routines.py → routines/l2.py} +284 -485
- disdrodb/{routines.py → routines/wrappers.py} +100 -7
- disdrodb/scattering/axis_ratio.py +95 -85
- disdrodb/scattering/permittivity.py +24 -0
- disdrodb/scattering/routines.py +56 -36
- disdrodb/summary/routines.py +147 -45
- disdrodb/utils/archiving.py +434 -0
- disdrodb/utils/attrs.py +2 -0
- disdrodb/utils/cli.py +5 -5
- disdrodb/utils/dask.py +62 -1
- disdrodb/utils/decorators.py +31 -0
- disdrodb/utils/encoding.py +10 -1
- disdrodb/{l2 → utils}/event.py +1 -66
- disdrodb/utils/logger.py +1 -1
- disdrodb/utils/manipulations.py +22 -12
- disdrodb/utils/routines.py +166 -0
- disdrodb/utils/time.py +5 -293
- disdrodb/utils/xarray.py +3 -0
- disdrodb/viz/plots.py +109 -15
- {disdrodb-0.1.3.dist-info → disdrodb-0.1.5.dist-info}/METADATA +3 -2
- {disdrodb-0.1.3.dist-info → disdrodb-0.1.5.dist-info}/RECORD +124 -96
- {disdrodb-0.1.3.dist-info → disdrodb-0.1.5.dist-info}/entry_points.txt +1 -0
- {disdrodb-0.1.3.dist-info → disdrodb-0.1.5.dist-info}/WHEEL +0 -0
- {disdrodb-0.1.3.dist-info → disdrodb-0.1.5.dist-info}/licenses/LICENSE +0 -0
- {disdrodb-0.1.3.dist-info → disdrodb-0.1.5.dist-info}/top_level.txt +0 -0
|
@@ -21,11 +21,9 @@
|
|
|
21
21
|
import datetime
|
|
22
22
|
import logging
|
|
23
23
|
import os
|
|
24
|
-
import shutil
|
|
25
24
|
import time
|
|
26
25
|
from typing import Optional
|
|
27
26
|
|
|
28
|
-
import dask
|
|
29
27
|
import xarray as xr
|
|
30
28
|
|
|
31
29
|
from disdrodb.api.checks import check_station_inputs
|
|
@@ -33,7 +31,6 @@ from disdrodb.api.create_directories import (
|
|
|
33
31
|
create_logs_directory,
|
|
34
32
|
create_product_directory,
|
|
35
33
|
)
|
|
36
|
-
from disdrodb.api.io import find_files
|
|
37
34
|
from disdrodb.api.path import (
|
|
38
35
|
define_file_folder_path,
|
|
39
36
|
define_l1_filename,
|
|
@@ -46,16 +43,15 @@ from disdrodb.configs import (
|
|
|
46
43
|
get_product_options,
|
|
47
44
|
)
|
|
48
45
|
from disdrodb.l1.processing import generate_l1
|
|
46
|
+
from disdrodb.utils.dask import execute_tasks_safely
|
|
49
47
|
from disdrodb.utils.decorators import delayed_if_parallel, single_threaded_if_parallel
|
|
50
48
|
|
|
51
49
|
# Logger
|
|
52
50
|
from disdrodb.utils.logger import (
|
|
53
|
-
close_logger,
|
|
54
|
-
create_logger_file,
|
|
55
51
|
create_product_logs,
|
|
56
|
-
log_error,
|
|
57
52
|
log_info,
|
|
58
53
|
)
|
|
54
|
+
from disdrodb.utils.routines import run_product_generation, try_get_required_filepaths
|
|
59
55
|
from disdrodb.utils.writer import write_product
|
|
60
56
|
|
|
61
57
|
logger = logging.getLogger(__name__)
|
|
@@ -67,6 +63,7 @@ def _generate_l1(
|
|
|
67
63
|
filepath,
|
|
68
64
|
data_dir,
|
|
69
65
|
logs_dir,
|
|
66
|
+
logs_filename,
|
|
70
67
|
campaign_name,
|
|
71
68
|
station_name,
|
|
72
69
|
# Processing options
|
|
@@ -74,7 +71,7 @@ def _generate_l1(
|
|
|
74
71
|
verbose,
|
|
75
72
|
parallel, # this is used only to initialize the correct logger !
|
|
76
73
|
):
|
|
77
|
-
"""Generate the L1 product from the
|
|
74
|
+
"""Generate the L1 product from the DISDRODB L0C netCDF file.
|
|
78
75
|
|
|
79
76
|
Parameters
|
|
80
77
|
----------
|
|
@@ -103,34 +100,23 @@ def _generate_l1(
|
|
|
103
100
|
If an error occurs during processing, it is caught and logged,
|
|
104
101
|
but no error is raised to interrupt the execution.
|
|
105
102
|
"""
|
|
106
|
-
#
|
|
107
|
-
# Define product name
|
|
103
|
+
# Define product
|
|
108
104
|
product = "L1"
|
|
109
|
-
|
|
110
105
|
# Define folder partitioning
|
|
111
106
|
folder_partitioning = get_folder_partitioning()
|
|
112
107
|
|
|
113
|
-
#
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
)
|
|
108
|
+
# Define product processing function
|
|
109
|
+
def core(
|
|
110
|
+
filepath,
|
|
111
|
+
campaign_name,
|
|
112
|
+
station_name,
|
|
113
|
+
data_dir,
|
|
114
|
+
folder_partitioning,
|
|
115
|
+
):
|
|
116
|
+
"""Define L1 product processing."""
|
|
117
|
+
# Retrieve L1 configurations
|
|
118
|
+
l1_options = get_product_options("L1").get("product_options") # TODO: MOVE OUTSIDE
|
|
121
119
|
|
|
122
|
-
##------------------------------------------------------------------------.
|
|
123
|
-
# Log start processing
|
|
124
|
-
msg = f"{product} processing of {filename} has started."
|
|
125
|
-
log_info(logger=logger, msg=msg, verbose=verbose)
|
|
126
|
-
success_flag = False
|
|
127
|
-
##------------------------------------------------------------------------.
|
|
128
|
-
# Retrieve L1 configurations
|
|
129
|
-
l1_options = get_product_options("L1").get("product_options")
|
|
130
|
-
|
|
131
|
-
##------------------------------------------------------------------------.
|
|
132
|
-
### Core computation
|
|
133
|
-
try:
|
|
134
120
|
# Open the raw netCDF
|
|
135
121
|
with xr.open_dataset(filepath, chunks=-1, decode_timedelta=False, cache=False) as ds:
|
|
136
122
|
ds = ds[["raw_drop_number"]].load()
|
|
@@ -138,47 +124,40 @@ def _generate_l1(
|
|
|
138
124
|
# Produce L1 dataset
|
|
139
125
|
ds = generate_l1(ds=ds, **l1_options)
|
|
140
126
|
|
|
141
|
-
#
|
|
142
|
-
if ds["time"].size
|
|
143
|
-
|
|
144
|
-
filename = define_l1_filename(ds, campaign_name=campaign_name, station_name=station_name)
|
|
145
|
-
folder_path = define_file_folder_path(ds, data_dir=data_dir, folder_partitioning=folder_partitioning)
|
|
146
|
-
filepath = os.path.join(folder_path, filename)
|
|
147
|
-
# Write to disk
|
|
148
|
-
write_product(ds, filepath=filepath, force=force)
|
|
149
|
-
|
|
150
|
-
##--------------------------------------------------------------------.
|
|
151
|
-
#### - Define logger file final directory
|
|
152
|
-
if folder_partitioning != "":
|
|
153
|
-
log_dst_dir = define_file_folder_path(ds, data_dir=logs_dir, folder_partitioning=folder_partitioning)
|
|
154
|
-
os.makedirs(log_dst_dir, exist_ok=True)
|
|
155
|
-
|
|
156
|
-
##--------------------------------------------------------------------.
|
|
157
|
-
# Clean environment
|
|
158
|
-
del ds
|
|
159
|
-
|
|
160
|
-
# Log end processing
|
|
161
|
-
msg = f"{product} processing of {filename} has ended."
|
|
162
|
-
log_info(logger=logger, msg=msg, verbose=verbose)
|
|
163
|
-
success_flag = True
|
|
164
|
-
|
|
165
|
-
##--------------------------------------------------------------------.
|
|
166
|
-
# Otherwise log the error
|
|
167
|
-
except Exception as e:
|
|
168
|
-
error_type = str(type(e).__name__)
|
|
169
|
-
msg = f"{error_type}: {e}"
|
|
170
|
-
log_error(logger, msg, verbose=verbose)
|
|
127
|
+
# Ensure at least 1 timestep available
|
|
128
|
+
if ds["time"].size <= 1:
|
|
129
|
+
return None
|
|
171
130
|
|
|
172
|
-
|
|
173
|
-
|
|
131
|
+
# Write L1 netCDF4 dataset
|
|
132
|
+
filename = define_l1_filename(ds, campaign_name=campaign_name, station_name=station_name)
|
|
133
|
+
folder_path = define_file_folder_path(ds, dir_path=data_dir, folder_partitioning=folder_partitioning)
|
|
134
|
+
filepath = os.path.join(folder_path, filename)
|
|
135
|
+
write_product(ds, filepath=filepath, force=force)
|
|
174
136
|
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
# Move logger file to correct partitioning directory
|
|
178
|
-
dst_filepath = os.path.join(log_dst_dir, os.path.basename(logger_filepath))
|
|
179
|
-
shutil.move(logger_filepath, dst_filepath)
|
|
180
|
-
logger_filepath = dst_filepath
|
|
137
|
+
# Return L1 dataset
|
|
138
|
+
return ds
|
|
181
139
|
|
|
140
|
+
# Define product processing function kwargs
|
|
141
|
+
core_func_kwargs = dict( # noqa: C408
|
|
142
|
+
filepath=filepath,
|
|
143
|
+
campaign_name=campaign_name,
|
|
144
|
+
station_name=station_name,
|
|
145
|
+
# Archiving options
|
|
146
|
+
data_dir=data_dir,
|
|
147
|
+
folder_partitioning=folder_partitioning,
|
|
148
|
+
)
|
|
149
|
+
# Run product generation
|
|
150
|
+
logger_filepath = run_product_generation(
|
|
151
|
+
product=product,
|
|
152
|
+
logs_dir=logs_dir,
|
|
153
|
+
logs_filename=logs_filename,
|
|
154
|
+
parallel=parallel,
|
|
155
|
+
verbose=verbose,
|
|
156
|
+
folder_partitioning=folder_partitioning,
|
|
157
|
+
core_func=core,
|
|
158
|
+
core_func_kwargs=core_func_kwargs,
|
|
159
|
+
pass_logger=False,
|
|
160
|
+
)
|
|
182
161
|
# Return the logger file path
|
|
183
162
|
return logger_filepath
|
|
184
163
|
|
|
@@ -282,30 +261,18 @@ def run_l1_station(
|
|
|
282
261
|
|
|
283
262
|
# -------------------------------------------------------------------------.
|
|
284
263
|
# List files to process
|
|
264
|
+
# - If no data available, print error message and return None
|
|
285
265
|
required_product = get_required_product(product)
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
)
|
|
297
|
-
except Exception as e:
|
|
298
|
-
print(str(e)) # Case where no file paths available
|
|
299
|
-
flag_not_available_data = True
|
|
300
|
-
|
|
301
|
-
# -------------------------------------------------------------------------.
|
|
302
|
-
# If no data available, print error message and return None
|
|
303
|
-
if flag_not_available_data:
|
|
304
|
-
msg = (
|
|
305
|
-
f"{product} processing of {data_source} {campaign_name} {station_name} "
|
|
306
|
-
+ f"has not been launched because of missing {required_product} data."
|
|
307
|
-
)
|
|
308
|
-
print(msg)
|
|
266
|
+
filepaths = try_get_required_filepaths(
|
|
267
|
+
data_archive_dir=data_archive_dir,
|
|
268
|
+
data_source=data_source,
|
|
269
|
+
campaign_name=campaign_name,
|
|
270
|
+
station_name=station_name,
|
|
271
|
+
product=required_product,
|
|
272
|
+
# Processing options
|
|
273
|
+
debugging_mode=debugging_mode,
|
|
274
|
+
)
|
|
275
|
+
if filepaths is None:
|
|
309
276
|
return
|
|
310
277
|
|
|
311
278
|
# -----------------------------------------------------------------.
|
|
@@ -317,6 +284,7 @@ def run_l1_station(
|
|
|
317
284
|
filepath=filepath,
|
|
318
285
|
data_dir=data_dir,
|
|
319
286
|
logs_dir=logs_dir,
|
|
287
|
+
logs_filename=os.path.basename(filepath),
|
|
320
288
|
campaign_name=campaign_name,
|
|
321
289
|
station_name=station_name,
|
|
322
290
|
# Processing options
|
|
@@ -326,7 +294,7 @@ def run_l1_station(
|
|
|
326
294
|
)
|
|
327
295
|
for filepath in filepaths
|
|
328
296
|
]
|
|
329
|
-
list_logs =
|
|
297
|
+
list_logs = execute_tasks_safely(list_tasks=list_tasks, parallel=parallel, logs_dir=logs_dir)
|
|
330
298
|
|
|
331
299
|
# -----------------------------------------------------------------.
|
|
332
300
|
# Define L1 summary logs
|