-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathicon_plot_test.ncl
More file actions
115 lines (104 loc) · 4.15 KB
/
icon_plot_test.ncl
File metadata and controls
115 lines (104 loc) · 4.15 KB
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
;---------------------------------------------------------------
; This script makes contour/vector plots of general ICON data files
; For scalar variables the underlying grid can be used instead of automatic
; contour lines. Both modes are capable of masking the input files before
; plotting, see the command line options below for details.
;------- lib location from the command line ------------------------------------------------------------------
loadscript("icon_plot_lib.ncl")
;------------------------------------------------------------------------------
undef("assert")
function assert(tag,givenResult,expectedResult,errorMessage)
begin
retval = True
if (any(givenResult .ne. expectedResult)) then
print("ERROR found: ================================================")
print(""+tag)
print(errorMessage)
print("Expected Result:"+expectedResult)
print("Given Result:"+givenResult)
retval = False
else
print("No Error in "+tag)
retval = True
end if
return retval
end
;------------------------------------------------------------------------------
undef("setSimpleResourceAndWks")
function setSimpleWks(ofile)
begin
otype = "pdf"
otype@wkOrientation = "portrait"
wks = gsn_open_wks(otype,ofile)
return wks
end
;------------------------------------------------------------------------------
; check version
;;ret = assert("NCL version",getNclVersion(),(/6,1,1/),"wrong version found")
;
; plot cells
undef("plot_cells")
procedure plot_cells(cellList,oFile,iFile)
begin
File = addfile( iFile+".nc", "r" )
resource = setDefaultResource(True,True,False,"RasterFill")
resource@tiMainString = oFile
wks = setSimpleWks(oFile)
varname = "t"
var = selField(varname,File,0,0,"unstructured")
coords = getCoordinates(var,File)
setCoordinates(resource,coords(0,:),coords(1,:))
bounds = getBoundsOfCoordinates(var,File)
boundslon = bounds(0,:,:)
boundslat = bounds(1,:,:)
plot = gsn_csm_contour_map(wks,var,resource)
do i=0,dimsizes(cellList)-1
cell = cellList(i)
gsn_polygon(wks,plot,boundslon(cell,:),boundslat(cell,:),resource)
end do
end
;---------------------------------------------------------------------------------
;---------------------------------------------------------------------------------
undef("plot_verts")
procedure plot_verts(vertList,oFile,iFile)
begin
File = addfile( iFile+".nc", "r" )
resource = setDefaultResource(True,True,False,"RasterFill")
resource@tiMainString = oFile
wks = setSimpleWks(oFile)
varname = "vort"
var = selField(varname,File,0,0,"unstructured")
coords = getCoordinates(var,File)
setCoordinates(resource,coords(0,:),coords(1,:))
bounds = getBoundsOfCoordinates(var,File)
boundslon = bounds(0,:,:)
boundslat = bounds(1,:,:)
plot = gsn_csm_contour_map(wks,var,resource)
do i=0,dimsizes(vertList)-1
vert = vertList(i)-1
gsn_polygon(wks,plot,boundslon(vert,:),boundslat(vert,:),resource)
end do
end
;---------------------------------------------------------------------------------
;---------------------------------------------------------------------------------
undef("plot_edges")
procedure plot_edges(edgeList,oFile,iFile)
begin
File = addfile( iFile+".nc", "r" )
resource = setDefaultResource(True,True,False,"RasterFill")
resource@tiMainString = oFile
wks = setSimpleWks(oFile)
varname = "vn"
var = selField(varname,File,0,0,"unstructured")
coords = getCoordinates(var,File)
setCoordinates(resource,coords(0,:),coords(1,:))
bounds = getBoundsOfCoordinates(var,File)
boundslon = bounds(0,:,:)
boundslat = bounds(1,:,:)
plot = gsn_csm_contour_map(wks,var,resource)
do i=0,dimsizes(edgeList)-1
edge = edgeList(i)-1
gsn_polygon(wks,plot,boundslon(edge,:),boundslat(edge,:),resource)
end do
end
; vim:list