ibt_map_one_storm.ncl 7.04 KB
Newer Older
1
2
3
4
5
6
7
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; ibt_map_one_storm.ncl
; Carl Schreck (carl@cicsnc.org)
; October 2011
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


8
9
undef  ( "ibt_map_one_storm_preread" )
procedure ibt_map_one_storm_preread(   \
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
  io_wks        [1] : graphic, \
  io_plot       [1] : graphic, \
  i_thresh      [*] : numeric, \
  i_color       [*]          , \ ; should be 1 longer than thresh
  i_idString    [1] : string , \
  i_time        [*] : numeric, \
  i_lat         [*] : numeric, \
  i_lon         [*] : numeric, \
  i_wind        [*] : numeric, \
  i_tcRes       [1] : logical \ ; ibtStartName, ibtEndName, ibtGenesis,  \
                                ; ibtMinTime, ibtMaxTime
)
local None
begin ; ibt_map_one_storm
  offset = 0.002

26
27
28
29
30
  if( isatt( i_tcRes, "fontHeightF" ) ) then
    fontHeightF = i_tcRes@fontHeightF
  else
    fontHeightF = 0.02
  end if
31
32
33
34
35
36
37
38
39
40
41
  if( isatt( i_tcRes, "ibtMaxTime" ) ) then
    lastFixInd = max( ind( i_time.le.i_tcRes@ibtMaxTime ) )
  else
    lastFixInd = max( ind( .not.ismissing(i_time) ) )
  end if
  if( isatt( i_tcRes, "ibtMinTime" ) ) then
    firstFixInd = min( ind( i_time.ge.i_tcRes@ibtMinTime ) )
  else
    firstFixInd = min( ind( .not.ismissing(i_time) ) )
  end if

42
43
44
45
46
  if( ismissing(firstFixInd).or.ismissing(lastFixInd) ) then
    print( "WARNING: Time out of range" )
    return
  end if

47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
  txRes = True
  txRes@txFont = 2

  gsRes = True

  ; add date labels
  txRes@txJust = "TopRight"
  txRes@txFontHeightF = fontHeightF * 0.28
; do fixCounter = 0, lastFixInd
;   if( toint( cd_string( i_time(fixCounter), "%H" ) ).eq.0 ) then
;     io_plot@$unique_string("date")$ = gsn_add_text( io_wks, io_plot, \
;         cd_string( i_time(fixCounter), "%d" ), \
;         i_lon(fixCounter)-xOffset, i_lat(fixCounter)-yOffset, txRes )
;   end if 
; end do

  ; add id labels
  txRes@txFontHeightF = fontHeightF * 0.3
; txRes@txPerimOn = True
; txRes@txBackgroundFillColor = "white"
; txRes@txPerimColor = "black"

69
if( .not.ismissing(i_lat(firstFixInd)) ) then
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
  if( i_lat(firstFixInd).gt.0 ) then
    if( ( .not.isatt( i_tcRes, "ibtStartName" ) ).or.i_tcRes@ibtStartName ) then
      txRes@txJust = "TopLeft"
      xNdc = 0.
      yNdc = 0.
      xData = i_lon(firstFixInd)
      yData = i_lat(firstFixInd)
      datatondc( io_plot, xData, yData, xNdc, yNdc )
      xNdc = xNdc + offset
      yNdc = yNdc - offset
      ndctodata( io_plot, xNdc, yNdc, xData, yData )

      txRes@txFontThicknessF = 1
      txRes@txFontColor = "black"
      io_plot@$unique_string("id")$ = gsn_add_text( io_wks, io_plot, \
          i_idString, xData, yData, txRes )
      txRes@txFontThicknessF = 3
      txRes@txFontColor = "white"
      io_plot@$unique_string("id")$ = gsn_add_text( io_wks, io_plot, \
          i_idString, xData, yData, txRes )
    end if

    if( ( .not.isatt( i_tcRes, "ibtEndName" ) ).or.i_tcRes@ibtEndName ) then
      txRes@txJust = "BottomRight"
      xNdc = 0.
      yNdc = 0.
      xData = i_lon(lastFixInd)
      yData = i_lat(lastFixInd)
      datatondc( io_plot, xData, yData, xNdc, yNdc )
      xNdc = xNdc - offset
      yNdc = yNdc + offset
      ndctodata( io_plot, xNdc, yNdc, xData, yData )

      txRes@txFontThicknessF = 1
      txRes@txFontColor = "black"
      io_plot@$unique_string("id")$ = gsn_add_text( io_wks, io_plot, \
          i_idString, xData, yData, txRes )
      txRes@txFontThicknessF = 3
      txRes@txFontColor = "white"
      io_plot@$unique_string("id")$ = gsn_add_text( io_wks, io_plot, \
          i_idString, xData, yData, txRes )
    end if

  else
    if( ( .not.isatt( i_tcRes, "ibtStartName" ) ).or.i_tcRes@ibtStartName ) then
      txRes@txJust = "BottomLeft"
      xNdc = 0.
      yNdc = 0.
      xData = i_lon(firstFixInd)
      yData = i_lat(firstFixInd)
      datatondc( io_plot, xData, yData, xNdc, yNdc )
      xNdc = xNdc + offset
      yNdc = yNdc + offset
      ndctodata( io_plot, xNdc, yNdc, xData, yData )

      txRes@txFontThicknessF = 1
      txRes@txFontColor = "black"
      io_plot@$unique_string("id")$ = gsn_add_text( io_wks, io_plot, \
          i_idString, xData, yData, txRes )
      txRes@txFontThicknessF = 3
      txRes@txFontColor = "white"
      io_plot@$unique_string("id")$ = gsn_add_text( io_wks, io_plot, \
          i_idString, xData, yData, txRes )
    end if

    if( ( .not.isatt( i_tcRes, "ibtEndName" ) ).or.i_tcRes@ibtEndName ) then
      txRes@txJust = "TopRight"
      xNdc = 0.
      yNdc = 0.
      xData = i_lon(lastFixInd)
      yData = i_lat(lastFixInd)
      datatondc( io_plot, xData, yData, xNdc, yNdc )
      xNdc = xNdc - offset
      yNdc = yNdc - offset
      ndctodata( io_plot, xNdc, yNdc, xData, yData )

      txRes@txFontThicknessF = 1
      txRes@txFontColor = "black"
      io_plot@$unique_string("id")$ = gsn_add_text( io_wks, io_plot, \
          i_idString, xData, yData, txRes )
      txRes@txFontThicknessF = 3
      txRes@txFontColor = "white"
      io_plot@$unique_string("id")$ = gsn_add_text( io_wks, io_plot, \
          i_idString, xData, yData, txRes )

    end if
  end if
157
end if
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174

; txRes@txJust = "BottomRight"
; io_plot@$unique_string("id")$ = gsn_add_text( io_wks, io_plot, \
;     i_idString, i_lon(lastFixInd), i_lat(lastFixInd), txRes )

  ; add lines
  if( firstFixInd.lt.lastFixInd ) then
    do fixCounter = firstFixInd, lastFixInd-1
;     print( i_idString + "     " + cd_string( i_time(fixCounter), "" )  \
;         + "     " + i_wind(fixCounter) )
      colorInd = num( i_thresh.le.i_wind(fixCounter) )
      if( isatt( i_tcRes, "gsLineThicknessF" ) ) then
        gsRes@gsLineThicknessF = i_tcRes@gsLineThicknessF
      else
        gsRes@gsLineThicknessF = 1+colorInd*0.33333
      end if
      gsRes@gsLineColor = i_color(colorInd)
175

176
177
178
      glowRes = gsRes
      glowRes@gsLineColor = "white"
      glowRes@gsLineThicknessF = 1 + gsRes@gsLineThicknessF
179
      io_plot@$unique_string("line")$ = gsn_add_polyline( io_wks, io_plot, \
180
181
182
183
184
185
186
          i_lon(fixCounter:fixCounter+1), i_lat(fixCounter:fixCounter+1),  \
          glowRes )

      io_plot@$unique_string("line")$ = gsn_add_polyline( io_wks, io_plot, \
          i_lon(fixCounter:fixCounter+1), i_lat(fixCounter:fixCounter+1),  \
          gsRes )

187
188
189
    end do
  end if

190
end ; ibt_map_one_storm_preread
191
192


193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
undef  ( "ibt_map_one_storm" )
procedure ibt_map_one_storm(   \
  io_wks        [1] : graphic, \
  io_plot       [1] : graphic, \
  i_path      [1] : string , \
  i_targetSn  : string  ,  \ 
  i_tcRes       [1] : logical \ ; ibtStartName, ibtEndName, ibtGenesis,  \
                                ; ibtMinTime, ibtMaxTime
)
begin

  if( .not.isatt(i_tcRes,"timeUnits") ) then
    timeUnits = "days since 1800-01-01"
  else
    timeUnits = i_tcRes@timeUnits
  end if

  thresh = (/ 35, 64, 83, 96, 113, 137 /)
  colors = (/ "gray50", "gray25", "cyan", "blue", "orange", "red", "magenta" /)
  name = ibt_read_one_storm( i_path, timeUnits, i_targetSn )
  time = name@time
  time@units = timeUnits
  lat = name@lat
  lon = name@lon
  wind = name@wind

  ibt_map_one_storm_preread( io_wks, io_plot, thresh, colors, name, time,  \
      lat, lon, wind, i_tcRes )

end ; ibt_map_one_storm