core.interp.interpolator
GridR interpolators interface
- gridr.core.interp.interpolator.get_interpolator(interp, **kwargs)[source]
Get an instance of an interpolator either from its short name, from its enum type, or from an existing object.
If interp is either a str or a PyInterpolatorType, the corresponding interpolator object is instantiated with the provided keyword arguments. If an existing interpolator object is passed as an argument, the method returns it as is without any modification.
- Parameters:
interp (Union[str, PyInterpolatorType, InterpolatorClasses]) –
The interpolator identifier. It can be:
A string representing the interpolator name (e.g., “nearest”, “linear”, “cubic”, etc.).
A PyInterpolatorType enum value.
An instance of an interpolator class.
**kwargs (Any) – Additional keyword arguments to pass to the interpolator constructor if a new instance is created.
- Returns:
An instance of the specified interpolator.
- Return type:
InterpolatorClasses
- Raises:
Exception – If the interpolator name or type is not recognized.
Exception – If the type of the interp parameter is not supported.
Examples
>>> # Create a nearest interpolator >>> nearest_interp = get_interpolator("nearest") >>> # Use an existing interpolator >>> existing_interp = NearestInterpolator() >>> returned_interp = get_interpolator(existing_interp) >>> returned_interp is existing_interp # True
- gridr.core.interp.interpolator.is_bspline(interp)[source]
Check if an interpolator is a B-Spline.
- Parameters:
interp (Union[str, PyInterpolatorType, InterpolatorClasses]) –
The interpolator identifier. It can be:
A string representing the interpolator name (e.g., “nearest”, “linear”, “cubic”, etc.).
A PyInterpolatorType enum value.
An interpolator class
An instance of an interpolator class.
- Returns:
True if the interpolator is a B-Spline, False otherwise
- Return type:
bool