-
Notifications
You must be signed in to change notification settings - Fork 0
/
grid_fill.ncl
executable file
·64 lines (43 loc) · 1.53 KB
/
grid_fill.ncl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
;**********************************
; load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
; load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
; load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
; load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/shea_util.ncl"
; load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/popRemap.ncl"
;************************************************
begin
; CHECK INPUT
if (.not. isvar("ifile") .or. .not. isvar("ofile") .or. .not. isvar("varname")) then
print("Please give ifile ofile and per command line argument like so:")
;print("ncl 'ifile=''ifile.nc''' 'ofile=''ofile.nc'' 'varname=''TEMP''' grid_fill.ncl")
end if
; from Jan Sedlacek
nscan = 200 ; usually *much* fewer
eps = 0.001 ; variable depended
gtype = False ; "gendat" does not generate cyclic fields
guess = 0 ; use zonal means
relc = 0.6 ; standard relaxation coef
opt = 0
; load in data
in = addfiles(ifile, "r")
var = in[:]->$varname$
if (isfilevar(in[:], "time_bnds")) then
time_bnds = in[:]->time_bnds
has_time_bnds = True
else
has_time_bnds = False
end if
; need to get rid of the z dimension
; this is not elegant
if (dimsizes(dimsizes(var)) .eq. 4) then
delete(var)
var = in[:]->$varname$(:, 0, :, :)
end if
; fill the continents with reasonably sensible data
poisson_grid_fill(var, gtype, guess, nscan, eps, relc, opt)
fout = addfile(ofile,"c")
fout->$varname$=var
if (has_time_bnds) then
fout->time_bnds=time_bnds
end if
end