Re: problem plotting a trajectory across the International Dateline (180 deg)

From: Jonathan Vigh <vigh_at_nyahnyahspammersnyahnyah>
Date: Wed, 20 Sep 2006 13:25:19 -0600

Aha! There is an easy solution to problem #1 (wrapping of trajectories
at the domain edge). It involves a very handy (and apparently
oft-overlooked) resource called mpGreatCircleLinesOn which controls how
the primitive transformations are mapped for the primitive functions
like gsn_add_polyline, gsn_add_polygon, and gsn_add_polymarker. The
default (res_at_mpGreatCircleLineOn = False) treats the lat-lon grid as a
cartesian system, which explains why the wrapping occurs. Setting it
instead to True calculates the great circle route (the shortest distance
on the surface of the globe) between each set of points. So the dots get
connected 'nicely' along the shortest possible path on the sphere.

Now on to problem #2 . . .

Jonathan

On Wed, 2006-09-20 at 13:00 -0600, Jonathan Vigh wrote:
> Greetings NCL Wizards,
>
> This might be an advanced problem, or maybe there's an easy solution
> - I'm not sure at this point.
>
> I am trying to plot trajectories on the globe which may or may not
> cross the International Dateline or the Prime Meridian. My longitude
> convention is -180 to 180 (Eastern Hemisphere positive, Western
> Hemisphere negative). There are two issues which arise. The first
> problem occurs when a trajectory (plotted using gsn_add_polyline)
> crosses the International Dateline. For a trajectory going from the
> Western Hemisphere to the Eastern Hemisphere (e.g. westward), the
> trajectory longitudes may go like this in time:
>
> -170.
> -174.
> -178.
> 177.
> 173.
>
> I am using mpLimitMode = "latlon" and and am also setting mpCenterLon in
> the correct way, so my domain is centered correctly. However, the
> trajectory comes up to the last point in the WHem before the Dateline
> then wraps all the way around the globe to get to the next point in the
> EHem. I know that I should expect this because gsn_add_polyline is just
> doing what it's being told - connecting the dots - so it's not its
> fault. One solution would be to just transform my input data so that
> longitude keeps going more negative in the Ehem, but I'd rather not do
> this as I'd like the script to be smart enough to plot the trajectory
> without regard to where it starts and where or how far it goes (in the
> more general case, it would be nice to plot the trajectory correctly
> without regard to how many times it circles the globe and in which
> direction it is going). I think changing the longitude convention to 0
> to 360 just moves the problem over to the Prime Meridian. It would be
> really nice if there was a general solution to this problem.
>
> So is there any way to tell gsn_add_polyline not to 'wrap' the polyline
> all the way around the globe if it crosses the Dateline? Is there some
> sort of resource to indicate that if the distance between points is less
> than halfway around the globe, don't wrap it all the way around, but
> just connect it across the Dateline?
>
> The second issue is that the domain is not limited in the desired manner
> if it spans the Dateline (I'm using mpLimitMode = "latlon", and setting
> mpMaxLonF and mpMinLonF). If I'm using a -180 to +180 longitude
> convention and it happens to include the Dateline, I'd like the domain
> to span from my smallest positive longitude (leftmost point in the E
> Hemisphere) to my largest negative longitude (rightmost point in the W
> Hemisphere) - so this is like the inverse of what the current behavior
> of is. Simply swapping the values doesn't work because it generates a
> warning that the min can't be greater than the max. The only workaround
> I've found so far is to make longitude go beyond -180 or 180 and then
> swap the values, but then my data do not get plotted unless they are
> similarly transformed and I'd rather not have to transform this data.
>
> I've attached my script and an example plot if anyone is interested in
> these two problems. Any comments or suggestions are appreciated.
>
> Thanks!
> Jonathan
>
>
>
> _______________________________________________
> ncl-talk mailing list
> ncl-talk_at_ucar.edu
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
_______________________________________________
ncl-talk mailing list
ncl-talk_at_ucar.edu
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Wed Sep 20 2006 - 13:25:19 MDT

This archive was generated by hypermail 2.2.0 : Mon Sep 25 2006 - 11:45:07 MDT