PlasmaCalcs.tools.xarray_tools.xarray_coords.xarray_get_dx_along
- PlasmaCalcs.tools.xarray_tools.xarray_coords.xarray_get_dx_along(array, coord, *, atol=0, rtol=1e-05, float_rounding=False)
- returns number equal to the diff along array.coords[coord], after checking that it is constant.result will be a single number, equal to array.coords[coord].diff(coord)[0].item().(Technically, also promotes coord to dim during calculations if coord was a non-dimension coordinate.)before returning result, ensure that np.allclose(array.diff(dim), atol=atol, rtol=rtol);if that fails, raise DimensionValueError.
- float_rounding: bool
- if True, re-create floating point result if it seems to be wrong by only a small amount,e.g. 0.20000000001 –> float(0.2); 0.39999999999 –> float(0.4); 0.123456781234 –> unchangedThis sometimes improves “exact” float comparisons, if float was input from a string.See tools.float_rounding for more details.