stack_nan_array

HSTB.kluster.xarray_helpers.stack_nan_array(dataarray, stack_dims=('time', 'beam'))

To handle NaN values in our input arrays, we flatten and index only the valid values. This comes into play with beamwise arrays that have NaN where there were no beams.

See reform_nan_array to rebuild the original array

Parameters
  • dataarray (DataArray) – xarray DataArray, array that we need to flatten and index non-NaN values

  • stack_dims (tuple) – tuple, dims of our input data

Returns

  • np.array – indexes of the original data

  • xr.DataArray – xarray DataArray, multiindexed and flattened