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 =
SCAT2GRIDGAUSS_XY(a,b,val,x[gx=xax],y[gy=yax],0.8,0.8,0.8,0)
yes? shade/lev=($lev) gridded
yes? show function fill_xy
FILL_XY(DATA,MASK,N)
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.
Ansley
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
|