| Re: contour discontinuity [message #84235 is a reply to message #84234] |
Fri, 03 May 2013 06:20   |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
Sam writes:
> I have plotted a 2D latitude vs. Longitude contour. When I do it from -180 longitude to +180 longitude scale, it is coming perfect. Now I want the same plot to be shown in 0 to 360 latitude. But there is a white vertical band coming at 180 longitude (in the middle of the plot).
Before we start, I should tell you that the solution to this problem is
rarely satisfactory. You would be well advised to learn to live with
what you have now. :-)
In the Coyote Gallery, I have a plot named Contours on a Global Map. I'm
going to use that data, which is different from yours, but will have the
same problem. In my case, the longitude data vector goes from 0 to
357.5, and if I display the data with the center longitude at 180, all
is well. If I want to display the data with the center longitude at 0, I
find a gap in the center of the plot.
IDL> Restore, 'contours_on_global_map.sav' ; lat, lon, data
IDL> print, lon[0], lon[-1]
0.000000 357.500
To correct the problem, I have to "complete the circuit" by wrapping the
longitude vector back on itself. Since I am extending the longitude
vector, I will have to do the same thing with the data (which is a 2D
array with dimensions [lon,lat]).
IDL> lon = [lon, lon[0]]
IDL> print, lon[0], lon[-1]
0.000000 0.000000
IDL> help, data
DATA FLOAT = Array[144, 73]
IDL> data = [data, data[0,*]]
IDL> help, data
DATA FLOAT = Array[145, 73]
Next, I have to convert my longitude vector to run from -180 to 180. You
would do the opposite here. You can find the formulas for doing so in
this article:
http://www.idlcoyote.com/map_tips/lonconvert.html
IDL> t_lon = lon
IDL> lon = t_lon - (LONG(t_lon )/180)*360.0
Now, when I create the filled contour the gap is gone and the result has
me thinking that displaying the contours with 180 in center was probably
a good idea. :-)
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.")
|
|
|
|