pydeltasnow.utils.get_nonzero_chunk_idxs¶
- pydeltasnow.utils.get_nonzero_chunk_idxs(Hobs)[source]¶
Return start and stop indices of consecutive nonzero chunks in Hobs.
A nonzero chunk is a slice in Hobs of values not zero. Nans are treated as nonzeros. The slices which are retured from this function include one leading and one trailing zero since the main deltasnow loop wants an input HS array to start and end with zero. Exceptions are when Hobs does not start and/or end with zero (then the first start and/or last stop index is not pointing to a zero).
Note that when you slice Hobs with Hobs[start:stop] the stop value is non-inclusive (https://stackoverflow.com/a/509295).
- Parameters
Hobs (1D
numpy.ndarrayof floats) – input HS data- Returns
start_idxs (1D
numpy.ndarray) – Indices where a nonzero chunk begins.stop_idxs (1D
numpy.ndarray) – Indices where a nonzero chunk ends.