Skip to content

Add data tools

Sebastian Müller requested to merge add_data_tools into main

Closes #35 (closed)

This merge request adds a data_tools.py submodule with:

  • to_xarray(data, info, time): create xarray from raw data, time can be None (check that info.meta is correctly set to xdata.attrs)
  • has_time(xdata): time in xdata.dims
  • get_time(xdata): get time from xdata if it has time else None
  • get_data(xdata): get data from an xarray (arr.data)
  • get_magnitude(xdata): get data from an xarray as numpy array (data.magnitude)
  • get_units(xdata): (pint.units)
  • get_dimensionality(xdata): (pint.dimensionality)
  • full_like(xdata, value): xarray with single value like given data
  • full(info, value, time): xarray with single value like to_xarray with np.full(info.grid.shape, value)
  • get_time(xdata): get list(datatime) or None (if no time dim)
  • to_units(xdata, units): (pint.to(units))
  • check(xdata, name, info, time): check if xarray matches info
Edited by Sebastian Müller

Merge request reports

Loading