ibt_map_one_storm.ncl 5.98 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; ibt_map_one_storm.ncl
; Carl Schreck (carl@cicsnc.org)
; October 2011
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


undef  ( "ibt_map_one_storm" )
procedure ibt_map_one_storm(   \
  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, \
18
19
20
  i_wind        [*] : numeric, \
  i_tcRes       [1] : logical \ ; ibtStartName, ibtEndName, ibtGenesis,  \
                                ; ibtMinTime, ibtMaxTime
21
22
23
24
25
)
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
  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
41
42

  txRes = True
43
  txRes@txFont = 2
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58

  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
59
  txRes@txFontHeightF = fontHeightF * 0.3
60
61
62
63
; txRes@txPerimOn = True
; txRes@txBackgroundFillColor = "white"
; txRes@txPerimColor = "black"

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
  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

107
  else
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
    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
150
151
152
153
154
155
156
  end if

; 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
157
158
  if( firstFixInd.lt.lastFixInd ) then
    do fixCounter = firstFixInd, lastFixInd-1
159
160
161
;     print( i_idString + "     " + cd_string( i_time(fixCounter), "" )  \
;         + "     " + i_wind(fixCounter) )
      colorInd = num( i_thresh.le.i_wind(fixCounter) )
162
163
164
165
166
      if( isatt( i_tcRes, "gsLineThicknessF" ) ) then
        gsRes@gsLineThicknessF = i_tcRes@gsLineThicknessF
      else
        gsRes@gsLineThicknessF = 1+colorInd*0.33333
      end if
167
      gsRes@gsLineColor = i_color(colorInd)
168
169
170
171
172
173
174
175

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

176
      io_plot@$unique_string("line")$ = gsn_add_polyline( io_wks, io_plot, \
177
178
          i_lon(fixCounter:fixCounter+1), i_lat(fixCounter:fixCounter+1),  \
          gsRes )
179
180
    end do
  end if
181
182
183
184

end ; ibt_map_one_storm