MCPcopy Index your code
hub / github.com/pydata/xarray / nearest

Method nearest

xarray/core/resample.py:184–208  ·  view source on GitHub ↗

Take new values from nearest original coordinate to up-sampled frequency coordinates. Parameters ---------- tolerance : float | Iterable[float] | str | None, default: None Maximum distance between original and new labels to limit the up-sampli

(
        self, tolerance: float | Iterable[float] | str | None = None
    )

Source from the content-addressed store, hash-verified

182 bfill = backfill
183
184 def nearest(
185 self, tolerance: float | Iterable[float] | str | None = None
186 ) -> T_Xarray:
187 """Take new values from nearest original coordinate to up-sampled
188 frequency coordinates.
189
190 Parameters
191 ----------
192 tolerance : float | Iterable[float] | str | None, default: None
193 Maximum distance between original and new labels to limit
194 the up-sampling method.
195 Up-sampled data with indices that satisfy the equation
196 ``abs(index[indexer] - target) <= tolerance`` are filled by
197 new values. Data with indices that are outside the given
198 tolerance are filled with ``NaN`` s.
199
200 Returns
201 -------
202 upsampled : DataArray or Dataset
203 """
204 obj = self._drop_coords()
205 (grouper,) = self.groupers
206 return obj.reindex(
207 {self._dim: grouper.full_index}, method="nearest", tolerance=tolerance
208 )
209
210 def interpolate(self, kind: InterpOptions = "linear", **kwargs) -> T_Xarray:
211 """Interpolate up-sampled data using the original data as knots.

Callers 2

test_upsampleMethod · 0.80

Calls 2

_drop_coordsMethod · 0.95
reindexMethod · 0.45

Tested by 2

test_upsampleMethod · 0.64