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
)
| 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. |