package scipy

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type
type tag = [
  1. | `LSQSphereBivariateSpline
]
type t = [ `LSQSphereBivariateSpline | `Object ] Obj.t
val of_pyobject : Py.Object.t -> t
val to_pyobject : [> tag ] Obj.t -> Py.Object.t
val create : ?w:[> `Ndarray ] Np.Obj.t -> ?eps:float -> theta:Py.Object.t -> phi:Py.Object.t -> r:Py.Object.t -> tt:Py.Object.t -> tp:Py.Object.t -> unit -> t

Weighted least-squares bivariate spline approximation in spherical coordinates.

Determines a smooth bicubic spline according to a given set of knots in the `theta` and `phi` directions.

.. versionadded:: 0.11.0

Parameters ---------- theta, phi, r : array_like 1-D sequences of data points (order is not important). Coordinates must be given in radians. Theta must lie within the interval ``0, pi``, and phi must lie within the interval ``0, 2pi``. tt, tp : array_like Strictly ordered 1-D sequences of knots coordinates. Coordinates must satisfy ``0 < tti < pi``, ``0 < tpi < 2*pi``. w : array_like, optional Positive 1-D sequence of weights, of the same length as `theta`, `phi` and `r`. eps : float, optional A threshold for determining the effective rank of an over-determined linear system of equations. `eps` should have a value within the open interval ``(0, 1)``, the default is 1e-16.

Notes ----- For more information, see the FITPACK_ site about this function.

.. _FITPACK: http://www.netlib.org/dierckx/sphere.f

Examples -------- Suppose we have global data on a coarse grid (the input data does not have to be on a grid):

>>> theta = np.linspace(0., np.pi, 7) >>> phi = np.linspace(0., 2*np.pi, 9) >>> data = np.empty((theta.shape0, phi.shape0)) >>> data:,0, data0,:, data-1,: = 0., 0., 0. >>> data1:-1,1, data1:-1,-1 = 1., 1. >>> data1,1:-1, data-2,1:-1 = 1., 1. >>> data2:-2,2, data2:-2,-2 = 2., 2. >>> data2,2:-2, data-3,2:-2 = 2., 2. >>> data3,3:-2 = 3. >>> data = np.roll(data, 4, 1)

We need to set up the interpolator object. Here, we must also specify the coordinates of the knots to use.

>>> lats, lons = np.meshgrid(theta, phi) >>> knotst, knotsp = theta.copy(), phi.copy() >>> knotst0 += .0001 >>> knotst-1 -= .0001 >>> knotsp0 += .0001 >>> knotsp-1 -= .0001 >>> from scipy.interpolate import LSQSphereBivariateSpline >>> lut = LSQSphereBivariateSpline(lats.ravel(), lons.ravel(), ... data.T.ravel(), knotst, knotsp)

As a first test, we'll see what the algorithm returns when run on the input coordinates

>>> data_orig = lut(theta, phi)

Finally we interpolate the data to a finer grid

>>> fine_lats = np.linspace(0., np.pi, 70) >>> fine_lons = np.linspace(0., 2*np.pi, 90)

>>> data_lsq = lut(fine_lats, fine_lons)

>>> import matplotlib.pyplot as plt >>> fig = plt.figure() >>> ax1 = fig.add_subplot(131) >>> ax1.imshow(data, interpolation='nearest') >>> ax2 = fig.add_subplot(132) >>> ax2.imshow(data_orig, interpolation='nearest') >>> ax3 = fig.add_subplot(133) >>> ax3.imshow(data_lsq, interpolation='nearest') >>> plt.show()

val ev : ?dtheta:int -> ?dphi:int -> theta:Py.Object.t -> phi:Py.Object.t -> [> tag ] Obj.t -> Py.Object.t

Evaluate the spline at points

Returns the interpolated value at ``(thetai, phii), i=0,...,len(theta)-1``.

Parameters ---------- theta, phi : array_like Input coordinates. Standard Numpy broadcasting is obeyed. dtheta : int, optional Order of theta-derivative

.. versionadded:: 0.14.0 dphi : int, optional Order of phi-derivative

.. versionadded:: 0.14.0

val get_coeffs : [> tag ] Obj.t -> Py.Object.t

Return spline coefficients.

val get_knots : [> tag ] Obj.t -> Py.Object.t

Return a tuple (tx,ty) where tx,ty contain knots positions of the spline with respect to x-, y-variable, respectively. The position of interior and additional knots are given as tk+1:-k-1 and t:k+1=b, t-k-1:=e, respectively.

val get_residual : [> tag ] Obj.t -> Py.Object.t

Return weighted sum of squared residuals of the spline approximation: sum ((wi*(zi-s(xi,yi)))**2,axis=0)

val to_string : t -> string

Print the object to a human-readable representation.

val show : t -> string

Print the object to a human-readable representation.

val pp : Format.formatter -> t -> unit

Pretty-print the object to a formatter.

OCaml

Innovation. Community. Security.