-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtsp-2.ncl
140 lines (87 loc) · 2.89 KB
/
tsp-2.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
;;; NCL script for creating contour plots of 2D time-varying NARCCAP RCM data
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"
;; Uncomment the following variables to hard-code them here, or pass
;; values in via command-line. Note that there are 3 output files,
;; named outfile.tt, outfile.tx, and outfile.ty. Example:
;; ncl varname=\"tas\" infile=\"tas_CRCM_1979010103.nc\" outfile=\"plots/tas_CRCM_1979010103\" title=\"tas_CRCM_1979010103.nc\ \" time-section-plot.ncl
; varname = "tas"
; infile = "tas_CRCM_1986010103.nc"
; outfile = "plot-test"
; title = systemfunc("basename "+infile)+" "
if (.not. isvar("title")) then
title = systemfunc("basename "+infile)+" "
end if
;; open file
fin = addfile(infile, "r")
;; read in coordinate variables first
lat = fin->lat
lon = fin->lon
time = fin->time
;;nt = dimsizes(fin->time)
;;nx = dimsizes(fin->xc)
;;ny = dimsizes(fin->yc)
dims = filevardimsizes(fin,varname)
ny = dims(1)
nx = dims(2)
norm = 1.0* max((/nx,ny/)) ;; for plot aspect ratios
if (.not. isvar("x0")) then
x0 = nx/2
end if
if (.not. isvar("y0")) then
y0 = ny/2
end if
;; read in data.
txdata = fin->$varname$(:,y0,:)
tydata = fin->$varname$(:,:,x0)
;; change coordinate variables to play nicely with plotting routines
if(dimsizes(dimsizes(lon)) .gt. 1) then
txdata!1 = "lon"
txdata&lon = lon(y0,:)
tydata!1 = "lat"
tydata&lat = lat(:,x0)
lat00 = lat(y0,x0)
lon00 = lon(y0,x0)
else
lat00 = lat(y0)
lon00 = lon(x0)
end if
res = True
res@cnFillOn = True
res@cnLinesOn = False
res@cnFillMode = "RasterFill"
res@lbLabelAutoStride = True
res@lbBoxLinesOn = False
res@lbOrientation = "Vertical"
res@gsnSpreadColors = True
res@gsnMaximize = True
res@gsnPaperOrientation = "landscape"
res@vpWidthF = 1.0
res@vpHeightF = 0.3
;; create the plots
wks = gsn_open_wks("ps", outfile+".tx")
gsn_define_colormap(wks,"nrl_sirkes") ;; 21 colors + fg/bg
res@tiMainString = title+"lat "+lat00
plot = gsn_csm_contour(wks, txdata(lon|:,time|:), res)
delete(wks)
wks = gsn_open_wks("ps", outfile+".ty")
gsn_define_colormap(wks,"nrl_sirkes") ;; 21 colors + fg/bg
res@tiMainString = title+"lon "+lon00
plot = gsn_csm_contour(wks, tydata(lat|:,time|:), res)
delete(wks)
wks = gsn_open_wks("ps", outfile+".tt")
gsn_define_colormap(wks,"nrl_sirkes") ;; 21 colors + fg/bg
tres = True
tres@gsnMaximize = True
tres@gsnPaperOrientation = "landscape"
tres@vpWidthF = 1.0
tres@vpHeightF = 0.3
tres@tiMainString = title+"lon "+lon00+", lat "+lat00
tres@xyMarkLineMode = "Markers"
tres@xyMarker = 1
;tres@xyMarkerSizeF = 0.05
tres@xyMarkerSizeF = 0.01
plot = gsn_csm_xy(wks, time, fin->$varname$(:,y0,x0), tres)
delete(wks)
exit