[Thread Prev][Thread Next][Index]

Re: [ferret_users] @FNR in 2D fills up x dimension first

Hi Ansley,

I had looked into fill_xy before trying @FNR, but it is "leaking" interpolation, see attached figure fill_xy_6iter_interpolation_leak.png.

shows that already at iteration = 1 (iter), fill_xy does not correspond to filling up with nearest-neighbor values. See for instance x=2 y=1: should be filled with 1.

Same happens when x and y axes span from -2 to 10 to be sure not to cut any area of the created grid object, not shown.

The mask was '1' everywhere on the grid for all examples.

def ax/x=-2:10:1 xax
def ax/y=-2:10:1 yax
def sym lev = (0.5,10.5,1)
let a   = {3,3,3,5,5,5}
let b   = {1,2,3,1,2,3}
let val = {1,2,3,4,5,6}
let gridded=SCAT2GRIDGAUSS_XY(a,b,val,x[gx=xax],y[gy=yax],0.8,0.8,0.8,0)
let mask = IF gridded THEN 1 ELSE 1
let iter = 1
let filled = FILL_XY (gridded, mask, iter)
shade/lev=($lev) filled
go polymark poly/lev=($lev)/key/ov/line/fill a b val circle 2

Best regards,
Hella Riede

P.S. Regarding figure fill_xy_6iter_interpolation_leak.png: I had made a mistake in my previous handmade "expected" figure at position x=3 y=2, which is corrected in the attached version.

Am 29.06.2018 um 20:10 schrieb Ansley C. Manke:
Hi Hella,

The function fill_xy does  fill in two dimensions together, but with one caveat. Here is your script, with the xax and yax axis definitions changed so that the points are not in the corners of the domain

    yes? let a   = {1,1,8,8,2}
    yes? let b   = {1,8,8,1,4}
    yes? let val = {2,4,6,8,10}

    yes? def ax/x=-2:10:1 xax
    yes? def ax/y=-2:10:1 yax

    yes? def sym lev = (1.5,10.5,1)

    yes? !! assign values from dots to grid cells
    yes? set win 1
    yes? let gridded =
    yes? shade/lev=($lev) gridded

    yes? show function fill_xy
         fills missing values with average nearest neighbour values
         DATA: this arg is filled
         MASK: mask (1 -> fill, missing -> do not fill)
         N: the maximum number of fill-passes

    yes? ! define a mask that's 1 everywhere
    yes? let mask = 0*missing(gridded,1)+1
    yes? set window/new
    yes? shade/lev=($lev) fill_xy(gridded, mask, 1)

    ! also look at fill_xy(gridded, mask, 2), fill_xy(gridded, mask, 3) ...

The function avoids filling singleton points that lie in a corner of the domain. We'll have to look into why that happens, but otherwise this function does what you need.


On 6/28/2018 7:37 AM, Hella Riede wrote:
Hello ferret community,

I am using @FNR in two dimensions and got an unexpected result (see ferret script at end of this mail):

In the attached ferret_before_FNR.png, the original 2D grid cells are shown (values inherited from dots by scat2grid, see below).

ferret_after_FNR.png shows the result after applying @FNR (fill with nearest neighbor) in 2 dimensions.

As an example for the unexpected result, lets take the grid cell at (x=8,y=5). Its value before @FNR was undefined. The nearest neighbor is (x=8,y=8). Yet, the value is inherited from (x=2,y=4).

Is @FNR not supposed to be applied in 2D or is the logic behind different from what I expected? It seems the missing points are always filled up in x dimension first, and only remaining missing values are then filled up in y direction ...

I attached a manual version of what I would have expected as ferret_FNR_expected.png.

Thank you very much in advance for helping to clarify this.

Best regards,
Hella Riede

can var/all
can sym/all

let a   = {1,1,8,8,2}
let b   = {1,8,8,1,4}
let val = {2,4,6,8,10}

def ax/x=1:8:1 xax
def ax/y=1:8:1 yax

def sym lev = (1.5,10.5,1)

!! assign values from dots to grid cells
set win 1
let gridded = SCAT2GRIDGAUSS_XY(a,b,val,x[gx=xax],y[gy=yax],0.8,0.8,0.8,0)
shade/lev=($lev) gridded
!! plot original scattered values for comparison
go polymark poly/lev=($lev)/key/ov/line/fill a b val circle 2

!! fill up undefined values with nearest neighbor
set win 2
let nn = gridded[x=@FNR,y=@FNR]
shade/lev=($lev) nn
go polymark poly/lev=($lev)/key/ov/line/fill a b val circle 2


Hella Riede

Deutscher Wetterdienst
Forschung und Entwicklung - Verfahrensentwicklung Fernerkundung (FE23)
Projekt Flottenwetterkarte (FloWKar)
Frankfurter Str. 135, 63067 Offenbach / Main
Tel. +49-69-8062-2414


Attachment: fill_xy_6iter_interpolation_leak.png
Description: PNG image

Attachment: fill_xy_iter1.png
Description: PNG image

Attachment: fill_xy_iter1_longaxes.png
Description: PNG image

[Thread Prev][Thread Next][Index]
Contact Us
Dept of Commerce / NOAA / OAR / PMEL / Ferret

Privacy Policy | Disclaimer | Accessibility Statement