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

Home » Public Forums » archive » cgDrawVectors over map problem?
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
cgDrawVectors over map problem? [message #89620] Sat, 01 November 2014 17:54 Go to next message
Dave[4] is currently offline  Dave[4]
Messages: 38
Registered: December 2007
Member
Hi David:

I want to use cgDrawVectors to draw wind over map, like this:

mapNorth = Obj_New('cgMap', 'Polar Stereographic', Limit=[0, -180, 90, 180], /NoBorder)
mapNorth -> Draw

cgMap_Continents, Color='black', map_structure=mapNorth
cgMap_Grid, LatDel=15, LonDel=15, LineStyle=1, Color='charcoal', /label, lonlabel=2, map_structure=mapNorth

cgDrawVectors, 10, 0, 140, 40, vecColors='black', /Overplot, referencevector=10, /solid, thick=2, MapCoord=mapNorth

In this example, the wind (u=10,v=0) should blow towards east. But the plotted wind blow towards right.

That's to say, the wind direction does not fellow the map projection. So why. Very thanks!

Dave
Re: cgDrawVectors over map problem? [message #89625 is a reply to message #89620] Sun, 02 November 2014 09:23 Go to previous messageGo to next message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Dave writes:

>
> Hi David:
>
> I want to use cgDrawVectors to draw wind over map, like this:
>
> mapNorth = Obj_New('cgMap', 'Polar Stereographic', Limit=[0, -180, 90, 180], /NoBorder)
> mapNorth -> Draw
>
> cgMap_Continents, Color='black', map_structure=mapNorth
> cgMap_Grid, LatDel=15, LonDel=15, LineStyle=1, Color='charcoal', /label, lonlabel=2, map_structure=mapNorth
>
> cgDrawVectors, 10, 0, 140, 40, vecColors='black', /Overplot, referencevector=10, /solid, thick=2, MapCoord=mapNorth
>
> In this example, the wind (u=10,v=0) should blow towards east. But the plotted wind blow towards right.
>
> That's to say, the wind direction does not fellow the map projection. So why. Very thanks!

Yikes! Bit of a problem here! :-(

This took quite a lot of thinking on my part. I don't think I got much
sleep last night. :-)

I understood my original mistake. I calculated the angle of the wind
vectors after I set up the map projection space. What I needed to do was
find a second point in the direction of the wind vectors, then transform
those two points into the map projection space, before calculating the
angle between them.

But then I couldn't figure out how to scale this vector to the reference
vector in the map space! Sigh...

Anyway, a couple more hours playing with this after coffee (LOTS of
coffee!) and I managed to get it working to my satisfaction. You can
find an updated program here:

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

I also added a map example (well, your example!) in the documentation
header. I've tried it with several other (and as perverse as I could
make them) map projections, and they all seem to work correctly.

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.")
Re: cgDrawVectors over map problem? [message #89629 is a reply to message #89625] Sun, 02 November 2014 16:10 Go to previous messageGo to next message
Dave[4] is currently offline  Dave[4]
Messages: 38
Registered: December 2007
Member
在 2014年11月3日星期一UTC+8上午1时23分18秒,David Fanning写道:
> Dave writes:
>
>>
>> Hi David:
>>
>> I want to use cgDrawVectors to draw wind over map, like this:
>>
>> mapNorth = Obj_New('cgMap', 'Polar Stereographic', Limit=[0, -180, 90, 180], /NoBorder)
>> mapNorth -> Draw
>>
>> cgMap_Continents, Color='black', map_structure=mapNorth
>> cgMap_Grid, LatDel=15, LonDel=15, LineStyle=1, Color='charcoal', /label, lonlabel=2, map_structure=mapNorth
>>
>> cgDrawVectors, 10, 0, 140, 40, vecColors='black', /Overplot, referencevector=10, /solid, thick=2, MapCoord=mapNorth
>>
>> In this example, the wind (u=10,v=0) should blow towards east. But the plotted wind blow towards right.
>>
>> That's to say, the wind direction does not fellow the map projection. So why. Very thanks!
>
> Yikes! Bit of a problem here! :-(
>
> This took quite a lot of thinking on my part. I don't think I got much
> sleep last night. :-)
>
> I understood my original mistake. I calculated the angle of the wind
> vectors after I set up the map projection space. What I needed to do was
> find a second point in the direction of the wind vectors, then transform
> those two points into the map projection space, before calculating the
> angle between them.
>
> But then I couldn't figure out how to scale this vector to the reference
> vector in the map space! Sigh...
>
> Anyway, a couple more hours playing with this after coffee (LOTS of
> coffee!) and I managed to get it working to my satisfaction. You can
> find an updated program here:
>
> http://www.idlcoyote.com/programs/cgdrawvectors.pro
>
> I also added a map example (well, your example!) in the documentation
> header. I've tried it with several other (and as perverse as I could
> make them) map projections, and they all seem to work correctly.
>
> 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.")

Hi, David:
Now cgDrawVector works with map projection. Very thanks!
Dave
Re: cgDrawVectors over map problem? [message #89690 is a reply to message #89620] Sun, 16 November 2014 23:20 Go to previous messageGo to next message
Dave[4] is currently offline  Dave[4]
Messages: 38
Registered: December 2007
Member
在 2014年11月2日星期日UTC+8上午8时54分05秒,Dave写 道:
> Hi David:
>
> I want to use cgDrawVectors to draw wind over map, like this:
>
> mapNorth = Obj_New('cgMap', 'Polar Stereographic', Limit=[0, -180, 90, 180], /NoBorder)
> mapNorth -> Draw
>
> cgMap_Continents, Color='black', map_structure=mapNorth
> cgMap_Grid, LatDel=15, LonDel=15, LineStyle=1, Color='charcoal', /label, lonlabel=2, map_structure=mapNorth
>
> cgDrawVectors, 10, 0, 140, 40, vecColors='black', /Overplot, referencevector=10, /solid, thick=2, MapCoord=mapNorth
>
> In this example, the wind (u=10,v=0) should blow towards east. But the plotted wind blow towards right.
>
> That's to say, the wind direction does not fellow the map projection. So why. Very thanks!
>
> Dave

Hi david:
Another question. Now cgvector work fine with cgmap object, but not with cgmapset. Very thanks!
Dave
Re: cgDrawVectors over map problem? [message #89697 is a reply to message #89690] Mon, 17 November 2014 05:24 Go to previous messageGo to next message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Dave writes:

> Another question. Now cgvector work fine with cgmap object, but not with cgmapset. Very thanks!

In what way do you think it doesn't work?

This works:

posx = cgScaleVector(RandomU(seed,200), -160, 160)
posy = cgScaleVector(RandomU(seed,200), -35, 70)
velx = RandomU(seed,200)-0.5
vely = RandomU(seed,200)-0.5
cgMap_Set, /Cylindrical
cgDrawVectors, velx, vely, posx, posy, /Overplot, VecColor='red'
cgMap_Grid
cgMap_Continents

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.")
Re: cgDrawVectors over map problem? [message #89700 is a reply to message #89620] Mon, 17 November 2014 17:20 Go to previous messageGo to next message
Dave[4] is currently offline  Dave[4]
Messages: 38
Registered: December 2007
Member
like this:

cgMap_Set, 90, 45, /stereo
cgDrawVectors, 10, 0, 140, 40, vecColors='black', /Overplot, referencevector=10, /solid, thick=2
cgMap_Grid
cgMap_Continents

the vector' direction is not right. So only /Cylindrical is ok.
Re: cgDrawVectors over map problem? [message #89701 is a reply to message #89700] Mon, 17 November 2014 17:37 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Dave writes:

> like this:
>
> cgMap_Set, 90, 45, /stereo
> cgDrawVectors, 10, 0, 140, 40, vecColors='black', /Overplot, referencevector=10, /solid, thick=2
> cgMap_Grid
> cgMap_Continents
>
> the vector' direction is not right. So only /Cylindrical is ok.

Ah, but now you are asking for cgDrawVectors to have a priori knowledge
of a command that was executed sometime before cgDrawVectors came onto
the scene. I suppose there might be a way to parse that knowledge out of
the !Map system variable, but if there is, I'm not going to discover
what it is. :-)

If you want to use polar map projections, set them up with cgMap and
tell cgDrawVectors about it. This approach seems pretty straightforward
to me. If it were up to me, I would delete all the Map_Set projections
entirely from IDL. They are VERY old. Map_Proj_Init projections are old,
too, but at least they were once the creme-de-la-creme of map projection
software. I guess the only thing I would even consider using cgMap_Set
for would be a cylindrical projection. :-)

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.")
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: IDL 6.1: X11 forward display. Mouse click not responsive on remote session.
Next Topic: polar_contour with log coordinates

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

Current Time: Wed Oct 08 09:20:22 PDT 2025

Total time taken to generate the page: 0.00603 seconds