[Thread Prev][Thread Next][Index]

[ferret_users] Re: wind barbs



Hi Jagadish,
The script metvec.jnl is basically a set of definitions that convert a users speed and direction data
into quantities that can be plotted using the POLYGON command. In order to work the user needs
to define SPEEDKT and DIRFROM based on their particular dataset. These names are meant to
represent "speed in knots" and "direction in degrees from which the wind or current comes". The
units of SPEEDKT are in fact arbitrary -- they could be miles per hour, centimeters per second, ...
-- but the logic of the definitions requires that the user provide the DIRFROM data in units of degrees.
The direction of the arrows drawn were made to be consistent with the meteorological convention of
"direction from" so that DIRFROM=45 is a wind coming from the northeast.

So to use metvec in practice you must

a) define SPEEDKT from your dataset. For example, if your data were read in as UU and VV
(eastward and northward components) you would use
let SPEEDKT=(UU^2+VV^2)^0.5
b) define DIRFROM for your available data. In the case described in a) above you would
use the ATAN2 function, with a factor to convert radians to degrees, plus a shift of 180
degrees to get the direction right -- in combination, something like
let D2R=atan(1.0)/45 ! the degree-to-radian factor
let DIRFROM=atan2((-1)*UU,(-1)*VV)/D2R
c) call the "metvec" definitions
go metvec
which include the coordinates XXBTOT and YYBTOT that, when you plot them with
polygon/coord_ax=z XXBTOT,YYBTOT
or maybe
polygon/coord_ax=z XPOS+XXBTOT, YPOS+YYBTOT
draws the vector with barbs and pennants. In the first case the vector is drawn with its origin
at (0,0). The second case positions the vector origin at (XPOS,YPOS) where these variables
are DEFINED BY THE USER, as for example where the user wants to draw a grid of
"metvec"s or maybe overlay them on an existing plot.
d) The last comment brings to mind another thought -- it is the USERS RESPONSIBILITY to
set up the axis scaling to make the aspect ratio of the vectors correct. For example they might
force the plot to be square with equal X and Y ranges, or they might
polygon/coord_ax=z SCALEX*XXBTOT,SCALEY*YYBTOT
where the scaling factors SCALEX,SCALEY are defined to "square up" the vector.

I hope these tips, together with the examples below, help you to use "metvec" in your work
Jagadish. Since I wrote it I have used it a few times but have not put in the extra work to make
it more "user friendly". If you improve on it, perhaps you might send the result to the user group.

Regards,
Mick

jagadish karmacharya wrote:

Dear Mick, Jonathan

I have tested the your demo. but i am not sure how to use the script to plot the actual data. Can you provide some hint.
Thanking in advance
Jagadish

*/Jonathan Callahan <Jonathan.S.Callahan@noaa.gov>/* wrote:

Mick,

Thanks for tackling this and doing such a good job! I think we're
well on the way to providing some real meteorological graphics for
our user community.

Anybody out there want to this this excellent start and test it on
their favorite datasets?


-- Jon



Mick.Spillane@noaa.gov wrote:

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 th
e 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 an
d 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 produc
t 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

*

* *
*
*

*
*

* *

------------------------------------------------------------------------
* Yahoo! Music Unlimited - Access over 1 million songs. Try it free. <http://pa.yahoo.com/*http://us.rd.yahoo.com/evt=36035/*http://music.yahoo.com/unlimited/> *


[Thread Prev][Thread Next][Index]

Dept of Commerce / NOAA / OAR / PMEL / TMAP

Contact Us | Privacy Policy | Disclaimer | Accessibility Statement