comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Direction of Wind Vectors: A bug?
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Direction of Wind Vectors: A bug? [message #90287] Wed, 18 February 2015 10:32 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Folks,

Someone was harassing my retirement reveries this morning by claiming
that cgDrawVectors was drawing vectors incorrectly, in the wrong
directions. He cited as evidence the output of the lovely NASA program,
PartVelVec.

Upon looking into this, I discovered that the two programs produce
vectors in exactly the same direction if the the plot they are being
output on has the same scale in the X and Y direction. (Other things,
such as vector length and whether the location specifies the end of the
vector or the middle, etc, are different, but irrelevant here.)

If the scale is different on the output plot, the two programs calculate
the end-point of the vector differently. As it happens (maybe you saw
this coming), I believe cgDrawVectors is doing things right and
PartVelVec is doing things wrong.

You will need a recent version of cgDrawVectors to test this. You can
download the latest here:

http://www.idlcoyote.com/programs/cgdrawvectors.pro

Unfortunately, I am only about 75% convinced cgDrawVectors is right. I
need reassurance from some IDL experts. God only knows how many papers
have been written using output from PartVelVec as supporting evidence!

Here is my thinking. Suppose you tell me at some spot on the Earth, the
wind is blowing 10 mph in the X direction and 10 mph in the Y direction.
Clearly, if I place, say, an arrow at that location, I will have to
point it at a 45 degree angle to the location I am standing on to
indicate the wind vector direction at that location.

OK, see, my confidence has already eroded to less than 50%, just by
writing what I have so far! :-(

As you can see from the test program below, cgDrawVectors preserves this
instantaneous vector angle (45 degrees) no matter what the plot scale,
while PartVelVec does not. But, I can also see someone explaining
PartVelVec by saying, "Look, forget the angle of the vector for a
moment. Walk from the starting point of this vector to the end of this
vector, and note the coordinates of the two points. Calculate the angle
from that. It is 45 degrees, even though it doesn't look like it on the
plot because the scale is screwed up."

So, here is my question. Are both of these programs "right"? If not, why
not? And, which would convey the "true wind direction" more convincingly
on a plot?

Here is the test program.

;*********************************************************** *****
Pro Vector_Bug
cgdisplay, wid=1, aspect=1.0, Title='Scale Same in XY'
cgplot, [-180, 180], [-180, 180], /NoData
partvelvec, [10,10], [10,10], [-45, -45], [50,-50], $
/over, veccolor='red', length=.5
cgdrawvectors, [10,10], [10,10], [-45, -45], [50,-50], $
/over, veccolor='blue', length=0.1

cgdisplay, wid=0, aspect=1.0, Title='Scale Different in XY'
cgplot, [-180, 180], [-90, 90], /NoData
partvelvec, [10,10], [10,10], [-45, -45], [50,-50], $
/over, veccolor='red', length=.5
cgdrawvectors, [10,10], [10,10], [-45, -45], [50,-50], $
/over, veccolor='blue', length=0.2
END
;*********************************************************** *****

Cheers,

David

--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
Sepore ma de ni thue. ("Perhaps thou speakest truth.")
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Interpolation
Next Topic: Errors when compiling routines with main-level programs

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 16:00:00 PDT 2025

Total time taken to generate the page: 0.00236 seconds