[Scilab-users] Padding and clipping a grid

Samuel Gougeon sgougeon at free.fr
Sun Jul 29 15:06:49 CEST 2018


Le 29/07/2018 à 14:53, arctica1963 a écrit :
> Hi all,
>
> I will have to look further into this. I can check the results against GMT
> (grdfft), I think they may use tapering but will have to look at the code
> (C++).
>
> Can I confirm that clipping is done via resize_matrix?
Not if it is symetric.

The f = fft() result put high frequencies (to be removed) at the center 
of the spectrum.
So, if you don't use fftshift() to put it on the spectrum's edges, you 
will have to do someting like:

pw = [pwr, pwc];  // predefined padding widths
s = size(f);
tf = f([1:s(1)/2-pwr s(1)/2+pwr:s(1)], [1:s(2)/2-pwc s(2)/2+pwc:s(2)];

But this expression is approximative, depending on the oddness of s 
components, etc.
It is easier to trimmed the shifted spectrum:

sf = fftshift(f);
tsf = sf(pwr+1:$-pwr, pwc+1:$-pwc);

and then backshift the trimmed spectrum:
sf = fftshift(tsf);

This is the idea.
Samuel




More information about the users mailing list