reform_nan_array¶
- HSTB.kluster.xarray_helpers.reform_nan_array(dataarray_stack, orig_idx, orig_shape, orig_coords, orig_dims)¶
To handle NaN values in our input arrays, we flatten and index only the valid values. Here we rebuild the original square shaped arrays we need using one of the original arrays as reference.
See stack_nan_array. Run this on the stacked output to get the original dimensions back.
- Parameters
dataarray_stack (
DataArray) – flattened array that we just interpolatedorig_idx (
tuple) – 2 elements, one for 1st dimension indexes and one for 2nd dimension indexes, see np.whereorig_shape (
tuple) – original shape of array before stack_nan_arrayorig_coords (
DataArray) – coordinates from array before stack_nan_arrayorig_dims (
tuple) – original dims of array before stack_nan_array
- Returns
values of arr, filled to be square with NaN values, coordinates of ref_array
- Return type
xr.DataArray