-
Notifications
You must be signed in to change notification settings - Fork 2
/
remove-degenerate-level.ncl
60 lines (40 loc) · 1.34 KB
/
remove-degenerate-level.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
;;; Removed a degenerate height dimension.
;;; Needs revision - not generic enough
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"
;; Note: specify infile and outfile as command-line arguments:
;; ncl -x infile=\"$infile\" outfile=\"$outfile\" remove-degenerate-level.ncl
system("rm "+outfile)
fin = addfile(infile, "r")
fout = addfile(outfile, "c")
filedimdef(fout,"time",-1,True)
; copy global attributes
att_names = getvaratts(fin)
do i = 0,dimsizes(att_names)-1
fout@$att_names(i)$ = fin@$att_names(i)$
end do
; copy variables
var_names = getfilevarnames (fin) ;
do i = 0,dimsizes(var_names)-1
print(""+var_names(i))
badnames = (/ "cli", "clw", "hus", "ta", "ua", "va", "wa", "zg"/)
if (any(badnames .eq. var_names(i)) )then
fout->$var_names(i)$ = fin->$var_names(i)$(:,0,:,:)
fout->$var_names(i)$@coordinates = "lon lat level"
else
if (var_names(i) .eq. "level") then
level = fin->level(0)
level!0 = "ncl_scalar"
fout->level = level
else
fout->$var_names(i)$ = fin->$var_names(i)$
end if
end if
end do
delete(fin)
delete(fout)
delete(var_names)
delete(att_names)
;; Copyright 2009-2012 Univ. Corp. for Atmos. Research
;; Author: Seth McGinnis, [email protected]