 ···

from mpl_toolkits.basemap import Basemap, shiftgrid, cm
import numpy as np
import matplotlib.pyplot as plt
from netCDF4 import Dataset

etopodata =
Dataset(‘http://ferret.pmel.noaa.gov/thredds/dodsC/data/PMEL/etopo5.nc’)
topoin = etopodata.variables[‘ROSE’][:]
lons = etopodata.variables[‘ETOPO05_X’][:]
lats = etopodata.variables[‘ETOPO05_Y’][:]

# shift data so lons go from -180 to 180 instead of 20 to 380.

topoin,lons = shiftgrid(180.,topoin,lons,start=False)

# create the figure and axes instances.

fig = plt.figure()

# use major and minor sphere radii from WGS84 ellipsoid.

m = Basemap(llcrnrlon=-145.5,llcrnrlat=1.,urcrnrlon=-2.566,urcrnrlat=46.352,
rsphere=(6378137.00,6356752.3142),
resolution=‘l’,area_thresh=1000.,projection=‘lcc’,
lat_1=50.,lon_0=-107.,ax=ax)

# transform to nx x ny regularly spaced 5km native projection grid

nx = int((m.xmax-m.xmin)/5000.)+1; ny = int((m.ymax-m.ymin)/5000.)+1
topodat = m.transform_scalar(topoin,lons,lats,nx,ny)

## …

Line (last but one):
nx = int((m.xmax-m.xmin)/5000.)+1; ny = int((m.ymax-m.ymin)/5000.)+1

(m.xmax-m.xmin) and (m.ymax-m.ymin) are very small compared to their divider 5000, so nx and ny are always 1

Provided link for “etopo5.nc” is desperately slow (~20 Kb/s) so I can’t test the code, but I tried with other dataset (ETOPO2) and I can’t get what “topodat” varable should be. It’s not clear to me from provided documentation.

Thanks in advance for any help

OK, soon I found out that m.xmax… are dependant on projection, and I wasn’t using Lambert projection
For default projection result are degrees and this way meters it sems

···

On Tue, Nov 8, 2011 at 9:13 PM, klo uo <klonuo@…287…> wrote:

from mpl_toolkits.basemap import Basemap, shiftgrid, cm
import numpy as np

import matplotlib.pyplot as plt
from netCDF4 import Dataset

etopodata =\

topoin = etopodata.variables[‘ROSE’][:]
lons = etopodata.variables[‘ETOPO05_X’][:]

lats = etopodata.variables[‘ETOPO05_Y’][:]

# shift data so lons go from -180 to 180 instead of 20 to 380.

topoin,lons = shiftgrid(180.,topoin,lons,start=False)

# create the figure and axes instances.

fig = plt.figure()

# use major and minor sphere radii from WGS84 ellipsoid.

m = Basemap(llcrnrlon=-145.5,llcrnrlat=1.,urcrnrlon=-2.566,urcrnrlat=46.352,\

``````        rsphere=(6378137.00,6356752.3142),\
resolution='l',area_thresh=1000.,projection='lcc',\

lat_1=50.,lon_0=-107.,ax=ax)
``````

# transform to nx x ny regularly spaced 5km native projection grid

nx = int((m.xmax-m.xmin)/5000.)+1; ny = int((m.ymax-m.ymin)/5000.)+1
topodat = m.transform_scalar(topoin,lons,lats,nx,ny)

## …

Line (last but one):
nx = int((m.xmax-m.xmin)/5000.)+1; ny = int((m.ymax-m.ymin)/5000.)+1

(m.xmax-m.xmin) and (m.ymax-m.ymin) are very small compared to their divider 5000, so nx and ny are always 1

Provided link for “etopo5.nc” is desperately slow (~20 Kb/s) so I can’t test the code, but I tried with other dataset (ETOPO2) and I can’t get what “topodat” varable should be. It’s not clear to me from provided documentation.

Thanks in advance for any help