xarray_utils#

Provides basic xarray utils.

Functions#

climatology(data)

Calculate the climatology from an xarray DataArray.

crop_ds(ds, lon_min, lon_max, lat_min, lat_max)

Crop an xarray.Dataset to the given lon/lat bounds, handling coordinate order.

get_clim_from_ds(ds[, input_var, factor])

Calculate climatology from a Dataset or DataArray.

get_coord_key(ds[, lat, lon, time, ...])

Return the lat or lon coordinate name used in the xarray dataset.

get_ds_extend(ds[, var, recursive_search, ...])

Get the spatial extent of a dataset as (lon_min, lon_max, lat_min, lat_max) from its bounds.

get_dtype(ds)

Return a simple dtype string without forcing data into memory.

get_overlapping_time_slice(input_ds, ref_ds)

Return the inclusive overlapping time window of two time-indexed objects.

get_single_data_var(ds[, proposed_vars])

Get the data var name from a dataset that only contains one data variable.

induce_data_var_from_file_name(ds, file_path)

Check if one of the data_vars is part of the file name and select it as the most probable data_var.

normalize_lat_lon(ds[, lat_key, lon_key, ...])

Normalize latitude and longitude dimension and coordinate names to 'lat' and 'lon'.

snap_to_target(ds, lat_key, lon_key, ...[, ...])

Rename latitude/longitude dimensions and assign exact target coordinates.

spearman_correlation(data1, data2)

Calculate Spearman rank correlation between two xarray DataArrays.

timedelta_to_alias(ds)

Map a median timedelta to a pandas frequency alias.