get_regular_grid_spacing#
- rojak.core.indexing.get_regular_grid_spacing(array: NDArray[T]) None | T [source]#
Determines if array has a regular grid spacing
- Parameters:
array (NDArray[T]) – Array to be checked
- Returns:
Grid spacing if on a regular grid. If not, it returns None
- Return type:
None | T
>>> np.set_printoptions(legacy=False) >>> get_regular_grid_spacing(np.linspace(5, 10, 11)) np.float64(0.5) >>> get_regular_grid_spacing(np.arange(np.datetime64("1970-01-01"), np.datetime64("1970-01-02"), dtype="datetime64[h]")) np.timedelta64(1,'h')
None is returned if array does not have a regular grid spacing >>> get_regular_grid_spacing(np.asarray([9, 3, 7]))