[SciPy-User] Question on spectral derivative

Geordie McBain gdmcbain at freeshell.org
Thu Apr 10 20:20:42 EDT 2014


2014-04-11 6:53 GMT+10:00 جاك الفضة <jacksilver045 at gmail.com>:
> I have data that form a scalar field on a 2D grid, evenly spaced. The grid
> has a finite size. There is no particular periodicity patern in my data.
>
> I want to calculate the value of the gradient at each grid point with a
> spectral method. Using simple FFT does not seem to work, especially near the
> borders (probably because the data are not periodic). I have ears about DCT,
> but I am not sure.
>
> I think that I could extend my grid with one row/column at each of the 4
> boundaries, duplicate the real boundary on these new boundary points to get
> a zero derivative boundary for the DCT algorithm. However, I am not sure how
> to get it working. Another possibility would be to extend my grid in some
> way that FFT will not create spurious oscillation near the boundaries, but
> again, I my attempts failed so far.
>
> I would appreciate advice on the best way to do this.

For a very nice introduction to spectral differentiation, see

Weideman, J. A. C., & S. C. Reddy (2000). A MATLAB differentiation
matrix suite. ACM Transactions on Mathematical Software 26 (4),
465-519.  http://dx.doi.org/10.1145/365723.365727

(The examples are in MATLAB, but the discussion is general and the
code simple enough to be read as pseudo-code.)

Basically, I fear you're like to encounter the problem that evenly
spaced grids aren't suited to spectral differentiation.  Ideally the
grid points should be the Gauss points, like the abscissæ of a
Gauss-type quadrature rule; these give us series-representations which
are independent of the boundary conditions.  If you can't change where
the grid points are, you're probably better off with lower order
differentiation, like high-order finite differences, using one-sided
rules near the edges.
   The discrete cosine transform that's used in JPEG gets around the
ultimate ill-conditioning of equidistant nodes by only applying it
after the image has been broken into (8, 8) tiles.
   If your grid wasn't of a finite size, you could use sinc functions,
but they have infinite support; again, this indicates the importance
of boundary conditions.



More information about the SciPy-User mailing list