dctools.utilities.misc_utils.to_float32

dctools.utilities.misc_utils.to_float32(obj)

Recursively converts all float64 data to float32 in xarray objects or dicts.

Copy-on-cast: only copies the Dataset/DataArray when at least one variable actually needs a dtype conversion. If every floating variable is already float32 the original object is returned unchanged — avoiding a full in-memory duplicate of potentially hundreds of MB of data. Works on both lazy (dask-backed) and already-computed (numpy) objects.

Parameters:

obj (Any)

Return type:

Any