dctools.utilities.xarray_utils

Functions for processing xr.Datasets and DataArrays.

Functions

assign_coordinate(ds, coord_name, ...)

Assign a coordinate with values and attributes to a dataset.

create_empty_dataset(dimensions)

Create an empty xarray Dataset from a dictionary of dimensions.

filter_dataset_by_depth(ds, depth_vals[, ...])

Filter a dataset (Argo-like) by keeping only values close to depth_vals within depth_tol.

filter_spatial_area(ds, lat_min, lat_max, ...)

Filters an xarray Dataset to only include data within a specified spatial area.

filter_time_interval(ds, start_time, end_time)

Filters an xarray Dataset to only include data within a specified time range.

filter_variables(ds, keep_vars)

Filter an xarray Dataset by keeping only some variables/coordinates.

get_time_info(ds)

Analyze the main time axis of an xarray Dataset.

netcdf_to_zarr(ds, zarr_path[, overwrite, ...])

Convert NetCDF file to Zarr (fully written, no lazy graph left).

preview_display_dataset(ds[, variables, ...])

Display a summary of the dataset handling memory constraints.

rename_coordinates(ds, rename_dict)

Rename coordinates/dimensions of an xarray Dataset using swap_dims.

rename_coords_and_vars(ds[, ...])

Rename variables and coordinates according to given dictionaries.

rename_variables(ds[, rename_dict])

Rename variables according to a given dictionary.

reset_time_coordinates(dataset)

Reset time coordinates values to a sequence starting at 0.

sanitize_for_zarr(ds)

Prepare dataset for Zarr writing by cleaning encoding and converting data types.

subset_variables(ds, list_vars)

Extract a sub-dataset containing only listed variables, preserving attributes.