-
Notifications
You must be signed in to change notification settings - Fork 41
/
plot_with_correct_Chinamap.ncl
179 lines (150 loc) · 6.85 KB
/
plot_with_correct_Chinamap.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
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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
;***********************************************************;
; ;
; This script is a example to plot contours on China map. ;
; Written by Huang Yongjie(IAP/CAS), 2016-05-22. ;
; ;
;***********************************************************;
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"
begin
f=addfile("pres.mon.ltm.nc","r")
pres= f->pres(0,:,:)
;---------------------------------------------------------------
wks = gsn_open_wks("x11","Correct_China_boundary")
gsn_define_colormap( wks ,"gui_default")
res = True
res@gsnMaximize = True
res@gsnDraw = False
res@gsnFrame = False
;---------------------------------------------------------------
; set for the map
res@mpMinLatF = 0.
res@mpMaxLatF = 55.
res@mpMinLonF = 72.
res@mpMaxLonF = 136.
res@mpFillOn = True
res@mpDataSetName = "./database/Earth..4"
res@mpDataBaseVersion = "MediumRes" ; or "Ncarg4_1"
res@mpAreaMaskingOn = True
res@mpMaskAreaSpecifiers = (/"China"/)
res@mpOutlineSpecifiers = (/"China","China:Provinces"/)
res@mpLandFillColor = "white"
res@mpInlandWaterFillColor = "white"
res@mpOceanFillColor = "white"
res@mpFillBoundarySets = "NoBoundaries"
res@mpOutlineBoundarySets = "NoBoundaries"
res@mpNationalLineColor = "black"
res@mpProvincialLineColor = "black"
res@mpGeophysicalLineColor = "black"
res@mpNationalLineThicknessF = 2
res@mpProvincialLineThicknessF = 1
;---------------------------------------------------------------
; set for the plot
res@cnFillOn = True
res@cnFillDrawOrder = "PreDraw"
res@cnLinesOn = False
res@cnLineLabelsOn = False
res@cnLevelSelectionMode = "ExplicitLevels"
res@cnLevels = ispan(520,1080,20)
res@cnFillPalette = "gui_default"
res@lbLabelAutoStride = True
res@pmTickMarkDisplayMode = "Always"
res@gsnRightString = "hPa"
;---------------------------------------------------------------
; plot the full China map
res@gsnLeftString = "Surface pressure over full China Map"
map = gsn_csm_contour_map(wks,pres,res)
draw(map)
frame(wks)
;---------------------------------------------------------------
; plot one part of China map with South China Sea subplot
res@mpMinLatF = 17.
res@gsnLeftString = "Surface pressure over part China Map with SCS"
map1 = gsn_csm_contour_map(wks,pres,res)
;--- add South China Sea ---
nhres = True
nhres@gsnFrame = False
nhres@gsnDraw = False
nhres@vpHeightF = 0.18
nhres@vpWidthF = 0.18
nhres@mpMinLatF = 2.0
nhres@mpMaxLatF = 23.0
nhres@mpMinLonF = 105.0
nhres@mpMaxLonF = 123.0
getvalues map1
"mpDataSetName" : nhres@mpDataSetName
"mpDataBaseVersion" : nhres@mpDataBaseVersion
"mpFillOn" : nhres@mpFillOn
"mpFillDrawOrder" : nhres@mpFillDrawOrder
"mpAreaMaskingOn" : nhres@mpAreaMaskingOn
"mpMaskAreaSpecifiers" : nhres@mpMaskAreaSpecifiers
"mpOutlineSpecifiers" : nhres@mpOutlineSpecifiers
"mpOutlineBoundarySets" : nhres@mpOutlineBoundarySets
"mpLandFillColor" : nhres@mpLandFillColor
"mpOceanFillColor" : nhres@mpOceanFillColor
"mpInlandWaterFillColor" : nhres@mpInlandWaterFillColor
"mpNationalLineColor" : nhres@mpNationalLineColor
"mpProvincialLineColor" : nhres@mpProvincialLineColor
end getvalues
getvalues map1@contour
"cnFillOn" : nhres@cnFillOn
"cnLevelSelectionMode" : nhres@cnLevelSelectionMode
"cnLevels" : nhres@cnLevels
"cnFillColors" : nhres@cnFillColors
"cnFillDrawOrder" : nhres@cnFillDrawOrder
"cnLinesOn" : nhres@cnLinesOn
"cnLineLabelsOn" : nhres@cnLineLabelsOn
end getvalues
nhres@lbLabelBarOn = False
nhres@tmXBOn = False
nhres@tmYLOn = False
nhres@tmYROn = False
nhres@tmXTOn = False
nhres@gsnLeftString = ""
nhres@gsnRightString = ""
map_nanhai = gsn_csm_contour_map(wks,pres,nhres)
adres = True
adres@amParallelPosF = 0.495 ; -0.5 is the left edge of the plot.
adres@amOrthogonalPosF = 0.49 ; -0.5 is the top edge of the plot.
adres@amJust = "BottomRight"
plotnh = gsn_add_annotation(map1,map_nanhai,adres)
draw(map1)
frame(wks)
;---------------------------------------------------------------
; Mask Xinjiang plot
res@mpMaskAreaSpecifiers = "Xinjiang Uygur"
res@gsnLeftString = "Surface pressure in Xinjiang with NCL Mask"
map2 = gsn_csm_contour_map(wks,pres,res)
;---------------------------------------------------------------
; Mask Xizang plot
res@mpMaskAreaSpecifiers = "Xizang"
res@gsnLeftString = "Surface pressure in Xizang with NCL Mask"
map3 = gsn_csm_contour_map(wks,pres,res)
;---------------------------------------------------------------
; Mask Beijing plot
res@mpOutlineSpecifiers := "Beijing Shi"
res@mpMaskAreaSpecifiers = "Beijing Shi"
res@mpMinLatF = 39.4
res@mpMaxLatF = 41.15
res@mpMinLonF = 115.25
res@mpMaxLonF = 117.6
res@mpShapeMode = "FreeAspect"
res@gsnLeftString = "Surface pressure in Beijing with NCL Mask and shp boundaries"
res@gsnRightString = ""
map4 = gsn_csm_contour_map(wks,pres,res)
;--- add shp file boundaries ---
ShpDir = "./cnmap/" ;"$NCARG_ROOT/lib/ncarg/nclscripts/cnmap/"
cnres = True
cnres@gsLineThicknessF = 2.0
cnres@gsLineColor = "red"
getvalues map4
"mpMinLatF" : cnres@minlat
"mpMaxLatF" : cnres@maxlat
"mpMinLonF" : cnres@minlon
"mpMaxLonF" : cnres@maxlon
end getvalues
plotshp = gsn_add_shapefile_polylines(wks,map4,ShpDir+"cnhimap.shp",cnres)
;---------------------------------------------------------------
gsn_panel(wks,(/map1,map2,map3,map4/),(/2,2/),True)
end