load "$NCARG_ROOT/lib/ncarg/nclex/gsun/gsn_code.ncl"
begin
;
; Create the input arrays.
;
xmin = -1.
xmax = 1.
ymin = -1.
ymax = 1.
nx = 29
ny = 25
ndata = 1000
xi = new(ndata,float)
yi = new(ndata,float)
zi = new(ndata,float)
;
; Generate input data using the function f(x,y) = y**2 - 0.5*y*x**2
;
do i=0,ndata-1
xi(i) = xmin + (xmax-xmin)*rand()/32767.
yi(i) = ymin + (ymax-ymin)*rand()/32767.
zi(i) = yi(i)*yi(i) - 0.5*xi(i)*xi(i)*yi(i)
end do
;
; Set up the output grid.
;
xo = fspan(xmin,xmax,nx)
yo = fspan(ymin,ymax,ny)
knots = (/4,4/)
;
; Calculate the approximated function values.
;
func = csa2s(xi,yi,zi,knots,xo,yo)
;
; Calculate the approximated second order mixed partial.
;
wts = (/-1./)
smth = 0.0
nderiv = (/1,1/)
funcd = csa2xs(xi,yi,zi,wts,knots,smth,nderiv,xo,yo)
;
; Create workstation object.
;
NCGM=1
X11=0
PS=0
if (NCGM .eq. 1) then
wid = gsn_open_wks("ncgm","nm16n")
end if
if (X11 .eq. 1) then
wid = gsn_open_wks("x11","nm16n")
end if
if (PS .eq. 1) then
wid = gsn_open_wks("ps","nm16n")
end if
;
; Draw plot of approximated function.
;
rho = 2.7
theta = 45.
phi = 78.
tdez2d(wid, xo, yo, func, rho, theta, phi, 6)
txres = True
txres@txFontHeightF = 0.04
gsn_text_ndc(wid, \
":F25:z = f(x,y) = y:S:2:E: - -:H-10::S:1:E::B::V-6:2:E: x:S:2:E:", \
0.5,0.85,txres)
frame(wid)
;
; Draw plot of second order mixed partial.
;
tdez2d(wid, xo, yo, funcd, rho, theta, phi, 6)
gsn_text_ndc(wid, \
":F25:z = :F34::S::H8:6:F25::S:2:E::E::F34:>:B::F34::H-35::V-6:6:F25:x:F34:6:F25:y:E: f(x,y) = - x", \
0.5,0.85,txres)
frame(wid)
end
home |
contents |
defs |
procedures |
examples |
errors