[Thread Prev][Thread Next][Index]

Re: wind barbs



On Thu, 13 Jan 2005, Jonathan Callahan wrote:
> Has anyone out there written a nice Ferret script that can do
> meteorological style wind barbs.  I'm imagining something that takes
> U,V,speed(knots) and plots the barbs with appropriate feathering.

Hi Jonathan,
	I put a bit of thought into this (at the risk of reinventing
a wheel up and running by other users).  The problem has three parts:

1) the generation of three type of barbs - pennants representing 50
   knots of wind speed, regular barbs each representing 10 kts of
   wind speed, and "half-barbs" representing 5 kts. The pennant(s)
   barbs and half-barbs project from a shaft.
2) decoding the wind speed into the appropriate set of pennants etc
   and orienting them according to the wind direction (from)
3) rendering one, or a field of such met vectors on the screen

I've solved 1) and 2) and most of 3).  The niceties of 3) (plotting
a field of met vectors and perhaps correcting direction and amplitude
of the arrows to be appropriate for the map scale) I've not taken to
completion, but hopefully the current state of things will prove of
some use.

The polygon command, al la Ned Cokelet's arrows, seems likely to be
of use in this situation.  The appended script "metvec.jnl" defines
the vertices of pennants, barbs, and half-barbs to be drawn with
polygon/coord_ax=z commands.  The decoding step basically defines a
set of masks that determine which vertices are needed to get the
appropriate combination of penntant/barbs.  And coordinate rotation
commands orient the met vector based on wind direction.

Hope this stuff proves of use,
Mick

!---------------------------------------------------------------
DEMO 1:
Here is a demo to draw one met vector for a fixed wind direction
(from 60 degrees true) and a range of wind speeds (1:75 knots)
so as to illustrate the windspeed decoding.

Copy metvec.jnl to your area then run the following in a ferret
session:

go metvec  ! define the variables needed

let dirfrom=60 ! wind from 60 degrees true
ppl axlen,5,5  ! combined with the /hlim=/vlim= this sets the

repeat/i=1:75 (let speedkt=i ; \
  POLYGON/nolab/LINE/COLOR=black/THICK=2/pal=black \
  /hlim=-2:2/ylim=-2:2/coord_ax=z xxbtot,yybtot ; \
  label 0 -1 0 0 0.2 @sr`i` knots)

!-------------------------------------------------------------
DEMO 2:
Render a field of metvecs, defined here as random variables. I
didn't expect the "repeat"s would be necessary - just a single
polygon command. There must be something I'm not thinking of.

go metvec

def axis/x=2:8:2 xax ; def axis/y=2:6:2 yax ; def grid/x=xax/y=yax grd
let xpos=x[g=grd]+0*y[g=grd] ; let ypos=y[g=grd]+0*x[g=grd]
let speedkt=100*randu(xpos)
let dirfrom=360*randu(ypos)

! draw a box
ppl axlen,5,5
plot/vs/nolab/hlim=0:10/vlim=0:10 {0,10},{0,10}
! and overlay the metvecs
repeat/i=1:4 (repeat/j=1:3 POLYGON/nolab/LINE/COLOR=black/THICK=2 \
   /pal=black/coord_ax=z/o xpos+xxbtot,ypos+yybtot )

list/nohead speedkt ! to confirm that
list/nohead dirfrom !    the results are as expected


! metvec : Definitions for plotting met wind vectors as constant length
!          shafts with pennants, full, and half barbs to represent speed.
!          Written by 14-Jan-05 by Mick Spillane     

! Concept: A shaft of unit length represents each vector. one or more
!          pennants, full barbs, and half barbs extend from the shaft
!          to encode the wind speed in knots. The orientation of the
!          shaft and its various barbs indicates the direction from
!          which the wind blows.

! Implementation: Since a combination of pennants, full barbs, and half
!          barbs are needed to represent any wind speed, (and since
!          pennants are filled triangles) an approach using ferret's
!          polygon/line command seems promising. The first task is to
!          define the coordinates of sets of pennants along a shaft.
!          Individual pennants and barbs, can be suppressed with a mask
!          and then the next task is to decode the wind speed into
!          such masks. The coordinatates of the pennants and barbs are
!          then rotated as appropriate to the direction from which the
!          wind blows and are plotted as polygons.

! Assumed inputs are arrays speedkt and dirfrom representing the speed
! in knots and direction (degrees clockwise from north) representing
! the wind field.

! The final product of these definitions is a set of vertices xxbtot,yybtot
! that will produce the desired "met vec" when drawn using polygon/coord_ax=z 
 
let d2r=atan(1.)/45
let radfrom=d2r*dirfrom
let csf=cos(radfrom) ; let snf=sin(radfrom)

let xpenn=zsequence({0,0.2,0,0, 0,0.2,0,0, 0,0.2,0,0, 0,0.2,0,0, 0,0.2,0,0,\
           0,0.2,0,0, 0,0.2,0,0, 0,0.2,0,0, 0,0.2,0,0, 0,0.2,0,0})
let xfull=xpenn
let xhalf=0.5*xpenn

let ypenn=zsequence({1.0,1.0,0.9,1.0, 0.9,0.9,0.8,0.9,\
           0.8,0.8,0.7,0.8, 0.7,0.7,0.6,0.7, 0.6,0.6,0.5,0.6, 0.5,0.5,0.4,0.5,\
           0.4,0.4,0.3,0.4, 0.3,0.3,0.2,0.3, 0.2,0.2,0.1,0.2, 0.1,0.1,0.0,0.1})
let yfull=zsequence({1.0,1.1,1.0,0.9, 0.9,1.0,0.9,0.8,\
           0.8,0.9,0.8,0.7, 0.7,0.8,0.7,0.6, 0.6,0.7,0.6,0.5, 0.5,0.6,0.5,0.4,\
           0.4,0.5,0.4,0.3, 0.3,0.4,0.3,0.2, 0.2,0.3,0.2,0.1, 0.1,0.2,0.1,0.0})
let yhalf=yfull-0.05*zsequence({0,1,0,0, 0,1,0,0, 0,1,0,0, 0,1,0,0, 0,1,0,0,\
                     0,1,0,0, 0,1,0,0, 0,1,0,0, 0,1,0,0, 0,1,0,0})

! decoding of wind speed
let npenn=int(speedkt-mod(speedkt,50))/50                 ! number of pennants
let nfull=int(speedkt-npenn*50-mod(speedkt,10))/10        ! number of full barbs
let nhalf=int(speedkt-npenn*50-nfull*10-mod(speedkt,5))/5 ! number of half barbs

let npenn0=if(npenn gt 0)then 1 else 0
let nfull0=if(nfull gt 0)then 1 else 0

let mpenn=if(k[k=1:40] le 4*npenn)then 1 else 0
let mfull=if(k[k=1:40] gt 4*npenn and i[i=1:40] le 4*(npenn+nfull))then 1 else 0
let mhalf=if(k[k=1:40] gt 4*(npenn+nfull) \
          and k[k=1:40] le 4*(npenn+nfull+nhalf))then 1 else 0 
let mpenn=if(k[k=1:40] le 4*npenn)then 1 else 0
let mfull=if(k[k=1:40] gt 4*(npenn+npenn0) \
          and k[k=1:40] le 4*(npenn+npenn0+nfull))then 1 else 0
let mhalf=if(k[k=1:40] gt 4*(npenn+npenn0+nfull) \
          and k[k=1:40] le 4*(npenn+npenn0+nfull+nhalf))then 1 else 0

! the rotated vector components are
let xbtot=mpenn*xpenn+mfull*xfull+mhalf*xhalf
let ybtot=mpenn*ypenn+mfull*yfull+mhalf*yhalf
let xxbtot=xbtot*csf+ybtot*snf
let yybtot=ybtot*csf-xbtot*snf


[Thread Prev][Thread Next][Index]

Dept of Commerce / NOAA / OAR / PMEL / TMAP

Contact Us | Privacy Policy | Disclaimer | Accessibility Statement