-
Notifications
You must be signed in to change notification settings - Fork 2
/
plot-tenvelope.ncl
118 lines (78 loc) · 2.6 KB
/
plot-tenvelope.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
;; Creates a temperature envelope plot: a scatter plot of temperatures
;; at particular times with the daily tmin & tmax overlaid for
;; comparison.
;; Inputs: temperature file, tmin file, and tmax file.
;; specify x and y coordinates for a point as array index values. If
;; not specified, the point nearest the center of the domain is used.
;; specify start time as a date. If unspecified, the middle of the
;; coverage period is used.
;; specify length of time plotted as number of days. Default is 60
;; days.
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
;****************************************************
fave = addfile(tavefile, "r")
fmin = addfile(tminfile, "r")
fmax = addfile(tmaxfile, "r")
if(.not. isvar("x")) then
d = getfilevardimsizes(fave,"tas")
x = d(2)/2
end if
if(.not. isvar("y")) then
d = getfilevardimsizes(fave,"tas")
y = d(1)/2
end if
if(.not. isvar("length")) then
length = 60
end if
time = fave->time
if(.not. isvar("start")) then
sdate=cd_calendar(time(dimsizes(time)/2),0)
start = ""+sdate(0,0)+"-"+sdate(0,1)+"-"+sdate(0,2)
end if
ds = stringtointeger(str_split(start,"-"))
cal=0
cal@calendar=time@calendar
t0 = cd_inv_calendar(ds(0),ds(1),ds(2),0,0,0,time@units,cal)
t1 = t0+length
tave = fave->tas({t0:t1},y,x)
tmin = fmin->tasmin({t0:t1},y,x)
tmax = fmax->tasmax({t0:t1},y,x)
tt = fave->time({t0:t1})
dummy = new((/dimsizes(tmin),2/),double)
dummy(:,0) = (/fmin->time_bnds({t0:t1},0)/)
dummy(:,1) = (/fmin->time_bnds({t0:t1},1)/)
tm = ndtooned(dummy)
dummy(:,0) = tmin
dummy(:,1) = tmin
pmin = ndtooned(dummy)
dummy(:,0) = tmax
dummy(:,1) = tmax
pmax = ndtooned(dummy)
colors = (/"black","blue","red"/)
wks = gsn_open_wks("ps",outfile)
res = True
res@gsnMaximize = True
res@gsnPaperOrientation = "portrait"
res@gsnDraw = False
res@gsnFrame = False
res@trYMinF = min(tmin) ; You could also just use
res@trYMaxF = max(tmax) ; min/max of u0,u1,u2.
res@xyMarkLineMode = "Markers"
res@xyMarkers = 1
res@xyMarkerColor = colors(0)
res@xyMarkerSizeF = 0.02
plot0 = gsn_csm_xy(wks,tt,tave,res)
res@xyMarkLineMode = "Lines"
res@xyLineThicknessF = 2.0
res@xyLineColor = colors(0)
res@xyLineColor = colors(1)
plot1 = gsn_csm_xy(wks,tm,pmin,res)
res@xyLineColor = colors(2)
plot2 = gsn_csm_xy(wks,tm,pmax,res)
overlay(plot0,plot1)
overlay(plot0,plot2)
draw(plot0)
frame(wks)
;; Copyright 2009-2012 Univ. Corp. for Atmos. Research
;; Author: Seth McGinnis, [email protected]