24.12.2013 Views

wradlib Documentation - Bitbucket

wradlib Documentation - Bitbucket

wradlib Documentation - Bitbucket

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>wradlib</strong> <strong>Documentation</strong>, Release 0.1.1<br />

3.6.4 <strong>wradlib</strong>.ipol.interpolate<br />

<strong>wradlib</strong>.ipol.interpolate(src, trg, vals, Interpolator, *args, **kwargs)<br />

Convenience function to use the interpolation classes in an efficient way<br />

ATTENTION: Works only for one- and two-dimensional vals arrays, yet.<br />

The interpolation classes in <strong>wradlib</strong>.ipol are computationally very efficient if they are applied on large multidimensional<br />

arrays of which the first dimension must be the locations’ dimension (1d or 2d coordinates) and the<br />

following dimensions can be anything (e.g. time or ensembles). This way, the weights need to be computed only<br />

once. However, this can only be done with success if all source values for the interpolation are valid numbers.<br />

If the source values contain let’s say np.nan types, the result of the interpolation will be np.nan in the vicinity<br />

of the corresponding points, too. Imagine that you have a time series of observations at points and in each time<br />

step one observation is missing. You would still like to efficiently apply the interpolation classes, but you will<br />

need to account for the resulting np.nan values in the interpolation output.<br />

In order to still allow for the efficient application, you have to take care of the remaining np.nan in your interpolation<br />

result. This is done by this convenience function.<br />

Alternatively, you have to make sure that your vals argument does not contain any np.nan values OR you have<br />

to post-process missing values in your interpolation result in another way.<br />

Parameters src : ndarray of floats, shape (npoints, ndims)<br />

Data point coordinates of the source points.<br />

trg : ndarray of floats, shape (npoints, ndims)<br />

Data point coordinates of the target points.<br />

vals : ndarray of float, shape (numsourcepoints, ...)<br />

Values at the source points which to interpolate<br />

Interpolator : a class which inherits from IpolBase<br />

*args : arguments of Interpolator (see class documentation)<br />

**kwargs : keyword arguments of Interpolator (see class documentation)<br />

Examples<br />

>>> # test for 1 dimension in space and two value dimensions<br />

>>> src = np.arange(10)[:,None]<br />

>>> trg = np.linspace(0,20,40)[:,None]<br />

>>> vals = np.hstack((np.sin(src), 10.+np.sin(src)))<br />

>>> # here we introduce missing values only in the second dimension<br />

>>> vals[3:5,1] = np.nan<br />

>>> ipol_result = interpolate(src, trg, vals, Idw, nnearest=2)<br />

>>> # plot if you like<br />

>>> import pylab as pl<br />

>>> pl.plot(trg, ipol_result, ’b+’)<br />

>>> pl.plot(src, vals, ’ro’)<br />

>>> pl.show()<br />

3.6.5 <strong>wradlib</strong>.ipol.interpolate_polar<br />

<strong>wradlib</strong>.ipol.interpolate_polar(data, mask=None, Interpolator=)<br />

Convenience function to interpolate polar data<br />

50 Chapter 3. Library Reference

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!