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

Function interp

xarray/core/missing.py:616–683  ·  view source on GitHub ↗

Make an interpolation of Variable Parameters ---------- var : Variable indexes_coords Mapping from dimension name to a pair of original and new coordinates. Original coordinates should be sorted in strictly ascending order. Note that all the coordinates shoul

(
    var: Variable,
    indexes_coords: SourceDest,
    method: InterpOptions,
    **kwargs,
)

Source from the content-addressed store, hash-verified

614
615
616def interp(
617 var: Variable,
618 indexes_coords: SourceDest,
619 method: InterpOptions,
620 **kwargs,
621) -> Variable:
622 """Make an interpolation of Variable
623
624 Parameters
625 ----------
626 var : Variable
627 indexes_coords
628 Mapping from dimension name to a pair of original and new coordinates.
629 Original coordinates should be sorted in strictly ascending order.
630 Note that all the coordinates should be Variable objects.
631 method : string
632 One of {'linear', 'nearest', 'zero', 'slinear', 'quadratic',
633 'cubic'}. For multidimensional interpolation, only
634 {'linear', 'nearest'} can be used.
635 **kwargs
636 keyword arguments to be passed to scipy.interpolate
637
638 Returns
639 -------
640 Interpolated Variable
641
642 See Also
643 --------
644 DataArray.interp
645 Dataset.interp
646 """
647 if not indexes_coords:
648 return var.copy()
649
650 result = var
651
652 if method in ["linear", "nearest", "slinear"]:
653 # decompose the interpolation into a succession of independent interpolation.
654 iter_indexes_coords = decompose_interp(indexes_coords)
655 else:
656 iter_indexes_coords = (_ for _ in [indexes_coords])
657
658 for indep_indexes_coords in iter_indexes_coords:
659 var = result
660
661 # target dimensions
662 dims = list(indep_indexes_coords)
663
664 # transpose to make the interpolated axis to the last position
665 broadcast_dims = [d for d in var.dims if d not in dims]
666 original_dims = broadcast_dims + dims
667 result = interpolate_variable(
668 var.transpose(*original_dims),
669 {k: indep_indexes_coords[k] for k in dims},
670 method=method,
671 kwargs=kwargs,
672 )
673

Callers

nothing calls this directly

Calls 7

updateMethod · 0.95
addMethod · 0.95
OrderedSetClass · 0.90
decompose_interpFunction · 0.85
interpolate_variableFunction · 0.85
copyMethod · 0.45
transposeMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…