disdrodb.utils package
Submodules
disdrodb.utils.compression module
- disdrodb.utils.compression.compress_station_files(disdrodb_dir: str, data_source: str, campaign_name: str, station_name: str, method: str) None[source]
Compress all files of a station.
- Parameters
disdrodb_dir (str) – Base directory of DISDRODB
data_source (str) – Name of data source of interest.
campaign_name (str) – Name of the campaign of interest.
station_name (str) – Station name of interest.
method (str) – Compression method. “zip”, “gzip” or “bzip2”.
disdrodb.utils.logger module
- disdrodb.utils.logger.close_logger(logger: <Logger asyncio (WARNING)>) None[source]
Close the logger
- Parameters
logger (logger) – Logger object.
- disdrodb.utils.logger.create_file_logger(processed_dir, product_level, station_name, filename, parallel)[source]
- disdrodb.utils.logger.create_l0_logger(processed_dir: str, campaign_name: str, verbose: bool = False) <Logger asyncio (WARNING)>[source]
Create L0 logger.
- Parameters
processed_dir (str) – Path of the processed directory.
campaign_name (str) – Campaign name.
verbose (bool, optional) – Whether to verbose the processing. The default is False.
- Returns
Logger object.
- Return type
logger
- disdrodb.utils.logger.define_summary_log(list_logs)[source]
Define station summary log file from list of file logs.
It select only logged lines with root, WARNING and ERROR keywords. It write the summary log in the parent directory.
- disdrodb.utils.logger.log_debug(logger: <Logger asyncio (WARNING)>, msg: str, verbose: bool = False) None[source]
Include debug entry into log.
- Parameters
logger (logger) – Log object.
msg (str) – Message.
verbose (bool, optional) – Whether to verbose the processing. The default is False.
- disdrodb.utils.logger.log_error(logger: <Logger asyncio (WARNING)>, msg: str, verbose: bool = False) None[source]
Include error entry into log.
- Parameters
logger (logger) – Log object.
msg (str) – Message.
verbose (bool, optional) – Whether to verbose the processing. The default is False.
disdrodb.utils.netcdf module
- disdrodb.utils.netcdf.ensure_monotonic_dimension(list_ds: list, fpaths: str, dim: str = 'time', verbose: bool = False) list[source]
Ensure that a list of xr.Dataset has a monotonic increasing (non duplicated) dimension values.
- Parameters
list_ds (list) – List of xarray Dataset.
fpaths (list) – List of netCDFs file paths.
dim (str, optional) – Dimension name. The default is “time”.
- Returns
list – List of xarray Dataset.
list – List of netCDFs file paths.
- disdrodb.utils.netcdf.ensure_unique_dimension_values(list_ds: list, fpaths: str, dim: str = 'time', verbose: bool = False) list[source]
Ensure that a list of xr.Dataset has non duplicated dimension values.
- Parameters
list_ds (list) – List of xarray Dataset.
fpaths (list) – List of netCDFs file paths.
dim (str, optional) – Dimension name. The default is “time”.
- Returns
list – List of xarray Dataset.
list – List of netCDFs file paths.
- disdrodb.utils.netcdf.get_list_ds(fpaths: str) list[source]
Get list of xarray datasets from file paths.
- Parameters
fpaths (list) – List of netCDFs file paths.
- Returns
List of xarray datasets.
- Return type
list
- disdrodb.utils.netcdf.xr_concat_datasets(fpaths: str, verbose=False) Dataset[source]
Concat xr.Dataset in a robust and parallel way.
It checks for time dimension monotonicity
- Parameters
fpaths (list) – List of netCDFs file paths.
- Returns
A single xarray dataset.
- Return type
xr.Dataset
- Raises
ValueError – Error if the merging/concatenation operations can not be achieved.