Basemap longitudes

Hi matplotlib users,

I'm trying to make some global plots with the basemap toolkit (version 0.4.2). I
would like the maps to be centered at arbitrary longitudes. For this I use the
shiftgrid method. When I make the plot and put on meridians some of them have
wrong W/E indicators. I was wondering whether that was due to a wrong longitude
array.

Let's say I want to make a map with the left and right margin at 150W with a
resolution of 60 degrees. How should the longitude array then look like? Is it
[-150, -90, -30, 30, 90, 150, -150], [210, 270, 330, 30, 90, 150, 210], [210,
270, 330, 390, 450, 510, 570], or something else?

Kind regards,
Jesper

jl@...656... wrote:

Hi matplotlib users,

I'm trying to make some global plots with the basemap toolkit (version 0.4.2). I
would like the maps to be centered at arbitrary longitudes. For this I use the
shiftgrid method. When I make the plot and put on meridians some of them have
wrong W/E indicators. I was wondering whether that was due to a wrong longitude
array.

Let's say I want to make a map with the left and right margin at 150W with a
resolution of 60 degrees. How should the longitude array then look like? Is it
[-150, -90, -30, 30, 90, 150, -150], [210, 270, 330, 30, 90, 150, 210], [210,
270, 330, 390, 450, 510, 570], or something else?

Kind regards,
Jesper

Jesper: I think the correct answer would be "any of the above" - assuming your data array actually is ordered the same way as your longitude array. It would help if you could post a small example.

-Jeff

···

--
Jeffrey S. Whitaker Phone : (303)497-6313
NOAA/OAR/CDC R/CDC1 FAX : (303)497-6449
325 Broadway Web : http://www.cdc.noaa.gov/~jsw
Boulder, CO, USA 80305-3328 Office: Skaggs Research Cntr 1D-124

Hi Jeff,

Here is an example which results in af plot with some of the longitudes
wrongly marked W on my computer:

#!/usr/bin/env /usr/bin/python
import pylab
import matplotlib.toolkits.basemap as basemap

def plot_test(filename):
  pylab.clf()

  lat = pylab.arange(-90.,91.,30.)
  lon = pylab.arange(100.,461.,60.)
  data = pylab.zeros((len(lat),len(lon)))

  # Create map with SW corner at 100E,90S and NW corner at 100E,90N
  m = basemap.Basemap(lon[0],lat[0],lon[-1],lat[-1],resolution='l')

  # Compute native map projection coordinates for lat/lon grid.
  xlon, ylat = m(*pylab.meshgrid(lon,lat))
  m.contourf(xlon,ylat,data)

  m.drawcoastlines()
  m.drawparallels(lat,labels=[1,0,0,0])
  m.drawmeridians(lon,labels=[0,0,0,1])

  pylab.savefig(filename)

if __name__ == '__main__':
  plot_test('1.png') # The longitude annotations for 40E and 100E are wrong

Kind regards,
Jesper

···

On Friday 24 June 2005 19:13, you wrote:

Jesper Larsen wrote:
>Hi matplotlib users,
>
>I'm trying to make some global plots with the basemap toolkit (version
> 0.4.2). I would like the maps to be centered at arbitrary longitudes. For
> this I use the shiftgrid method. When I make the plot and put on
> meridians some of them have wrong W/E indicators. I was wondering whether
> that was due to a wrong longitude array.
>
>Let's say I want to make a map with the left and right margin at 150W with
> a resolution of 60 degrees. How should the longitude array then look
> like? Is it [-150, -90, -30, 30, 90, 150, -150], [210, 270, 330, 30, 90,
> 150, 210], [210, 270, 330, 390, 450, 510, 570], or something else?
>
>Kind regards,
>Jesper

Jesper: I think the correct answer would be "any of the above" -
assuming your data array actually is ordered the same way as your
longitude array. It would help if you could post a small example.

-Jeff

Jesper Larsen wrote:

···

On Friday 24 June 2005 19:13, you wrote:

Jesper Larsen wrote:
   

Hi matplotlib users,

I'm trying to make some global plots with the basemap toolkit (version
0.4.2). I would like the maps to be centered at arbitrary longitudes. For
this I use the shiftgrid method. When I make the plot and put on
meridians some of them have wrong W/E indicators. I was wondering whether
that was due to a wrong longitude array.

Let's say I want to make a map with the left and right margin at 150W with
a resolution of 60 degrees. How should the longitude array then look
like? Is it [-150, -90, -30, 30, 90, 150, -150], [210, 270, 330, 30, 90,
150, 210], [210, 270, 330, 390, 450, 510, 570], or something else?

Kind regards,
Jesper
     
Jesper: I've now fixed this is CVS - there was indeed a bug in the labelling if lon > 360 or lon < -180. To check out a new version from CVS:

cvs -z3 -d:ext:anonymous@...54...:/cvsroot/matplotlib co toolkits

-Jeff

--
Jeffrey S. Whitaker Phone : (303)497-6313
Meteorologist FAX : (303)497-6449
NOAA/OAR/CDC R/CDC1 Email : Jeffrey.S.Whitaker@...259...
325 Broadway Office : Skaggs Research Cntr 1D-124
Boulder, CO, USA 80303-3328 Web : Jeffrey S. Whitaker: NOAA Physical Sciences Laboratory