utils

This module contains convenience functions for any purposes.

Timer([info, verbose])

Provide a simple time profiling utility

concat_each_time_coordinate(*datasets)

Concatenate xarray datasets along each time coordinate

date2num(dates, units[, calendar])

Convert an array of integer into datetime objects.

deprecated([func, new_name, message])

Decorator which can be used to mark functions as deprecated.

extract_block_diag(M, n)

Extract diagonal blocks from square Matrix.

get_time_coordinates(ds)

From a xarray dataset or dataarray, get coordinates with at least 1 time dimension

get_time_dimensions(ds)

From a xarray dataset or dataarray, get dimensions corresponding to time coordinates

get_xarray_groups(dataset[, only_names])

Get pseudo groups from xarray dataset object (only direct under root)

image2mpeg(glob, outfile[, framerate, ...])

Combine image files to a video using ffmpeg.

num2date(times, units[, calendar])

Convert an array of integers into datetime objects.

path_append(dirname[, path])

Append a directory to environment path variable.

path_prepend(dirname[, path])

Prepend a directory to environment path variable.

path_remove(dirname[, path])

Remove a directory from environment path variable.

reraise_with_stack(func)

Make functions include the whole stack in raised exceptions

safe_eval(expr)

Safely evaluate string that may contain basic arithmetic

set_time_resolution(datetime_obj, resolution)

Set the resolution of a python datetime object.

split_units(value)

Splits a string into float number and potential unit

stack_xarray_repdim(da, **dims)

Like xarrays stack, but with partial support for repeated dimensions

to_datetime(obj)

Convert an object to a python datetime object.

to_timedelta(obj[, numbers_as])

Convert an object to a python datetime object.

undo_xarray_floatification(ds[, fields])

convert floats back to ints in xarray dataset where appropriate

unique(seq)

Remove duplicates from list whilst keeping the original order

utils.cache

Utilities related to caching and memoisation

mutable_cache([maxsize])

In-memory cache like functools.lru_cache but for any object