Re: overlaying wind vectors on a map [message #70177] |
Tue, 23 March 2010 12:03  |
R.G.Stockwell
Messages: 163 Registered: October 2004
|
Senior Member |
|
|
"slippy133" <slippy133@yahoo.com> wrote in message
news:c2833c42-8235-44fc-9110-528cd16ccd0c@h35g2000pri.google groups.com...
> Hi,
...
> I have also used ivector, but that doesn't seem to overlay on current
> maps either.
>
> Is there a simple way to do this in IDL that I am simply unaware of?
I wrote a routine to do this. Here is the relevant snippet,
; here, i have zonal wind in "zon" and meridional wind in "mer"
wgood = where(finite(zon) eq 1, wgoodcount)
if wgoodcount eq 0 then return
arrowtail_lat = zon*!values.f_nan ; same as zon but full of NANs
arrowtail_lon = arrowtail_lat
; lon is col
; lat is row
; Decimate arrow points ; arrow at each point may be too much
decimating_index = lindgen(wgoodcount/decfactor)*decfactor
wgood = wgood(decimating_index) ; arrow at every 'n'th data point
arrowtail_lat_index = wgood/nlon
arrowtail_lon_index = wgood mod nlon
arrowtail_lat(arrowtail_lon_index,arrowtail_lat_index) =
lats(arrowtail_lat_index)
arrowtail_lon(arrowtail_lon_index,arrowtail_lat_index)=
lons(arrowtail_lon_index)
arrowhead_lat = arrowtail_lat + mer*mps_to_latlong_copy
arrowhead_lon = arrowtail_lon + zon*mps_to_latlong_copy
if n_elements(mapStruct) gt 0 then begin
resulttail =
MAP_PROJ_FORWARD(arrowtail_lon,arrowtail_lat,map_structure = mapstruct)
resulthead =
MAP_PROJ_FORWARD(arrowhead_lon,arrowhead_lat,map_structure = mapstruct)
arrowtail_lon = resulttail[0,*]
arrowtail_lat = resulttail[1,*]
arrowhead_lon = resulthead[0,*]
arrowhead_lat = resulthead[1,*]
; different map struct used, so conver (in uv coords here)
wbadwrap = where( abs(arrowtail_lon - arrowhead_lon) gt
19848285L, wbadwrapcount,complement=badwrapcomp)
; remove these
arrowtail_lon = arrowtail_lon(badwrapcomp)
arrowtail_lat = arrowtail_lat(badwrapcomp)
arrowhead_lon = arrowhead_lon(badwrapcomp)
arrowhead_lat = arrowhead_lat(badwrapcomp)
for i = 0, n_elements(arrowtail_lon)-1 do begin
arrow,arrowtail_lon(i),arrowtail_lat(i),$
arrowhead_lon(i),arrowhead_lat(i),data=1,color=arrowcolor,hs ize=newhsize,solid=solid
endfor
endif else begin
; data in lat lon coords
arrow,arrowtail_lon(*),arrowtail_lat(*),$
arrowhead_lon(*),arrowhead_lat(*),data=1,color=arrowcolor,hs ize=newhsize,solid=solid
endelse
cheers,
bob
|
|
|
|