fill_dataarray_with_nearest#
- mhm_tools.pre.fill_nearest.fill_dataarray_with_nearest(array, along_time=None, missing_value=None, mask=None, fill_value=-9999.0, default_value=None, source_file=None)[source]#
Fill missing values in a data array with nearest valid neighbours.
- Parameters:
array (xarray.DataArray) – Data array modified in place.
along_time (bool, optional) – Whether to treat all non-time dimensions as the fill domain and copy the selected source-cell time series to each target cell. Defaults to true when
arrayhas atimedimension.missing_value (float, optional) – Missing-value marker to fill. NaNs are always treated as missing.
mask (numpy.ndarray, optional) – Boolean spatial mask where true cells are excluded from filling and set to
fill_value.fill_value (float, default -9999.0) – Value written to masked cells and to target cells when no valid source cells exist.
source_file (str or pathlib.Path, optional) – File path used only for diagnostic log messages.
- Returns:
Number of unmasked cells selected for nearest-neighbour filling.
- Return type: