! bench_gridding.jnl  
! *acm* 8/99

! Call scat2gridlaplace_xy  and scat2gridgauss_xy
! to put scattered data onto a regularly spaced grid.

! function definition from objective_analysis_demo.jnl

! 2/2005 changed number of arguments to the Gaussing gridding functions


define axis/x=0:10:0.05 x10
define axis/y=0:10:0.05 y10
define grid/x=x10/y=y10 g10x10
set grid g10x10

let WAVE = SIN(KX*XPTS + KY*YPTS - PHASE) / 3
let PHASE = 0
let KAPPA = 0.4
let KX = 0.4
let KY = 0.7
let FCN1 = SIN(R)/(R+1)
let R = ((XPTS-X0)^2+ 5*(YPTS-Y0)^2)^0.5
let X0 = 3
let Y0 = 8

LET sample_function = fcn1 + wave

let xpts = x; let ypts = y

list/x=4:5/y=1 sample_function

can mem /all

let xpts = 10*randu(i); let ypts = 10*randu(i+2)

set region/i=1:200
define axis/x=1:10:.5 xax5
define axis/y=1:10:.5 yax5

let sgrid = scat2gridlaplace_xy (xpts, ypts, sample_function, x[gx=xax5], y[gy=yax5], 5., 5)
! the following in now needed since the result grid axes are no longer extended
! load sgrid
! otherwise the following would use a 3-element X axis and 1-element Y axis
! list/x=4:5/y=1 sgrid
list /order=yx sgrid

let sgrid = scat2gridlaplace_xy (xpts, ypts, sample_function, x[gx=xax5], y[gy=yax5], 1.,1)
! the following in now needed since the result grid axes are no longer extended
! load sgrid
! otherwise the following would use a 3-element X axis and 1-element Y axis
! list/x=4:5/y=1 sgrid
list /order=yx sgrid

let sgrid = scat2gridgauss_xy (xpts, ypts, sample_function, x[gx=xax5], y[gy=yax5], 0.5, 0.5, 2, 2)
! list/x=4:5/y=1 sgrid
list /order=yx sgrid

let sgrid = scat2gridgauss_xy (xpts, ypts, sample_function, x[gx=xax5], y[gy=yax5], 1., 1., 6, 6)
! list/x=4:5/y=1 sgrid
list /order=yx sgrid

can mem /all
can var /all
can axis yax5
can axis xax5
set grid abstract
can grid g10x10
can axis y10
can axis x10

