График потока Matplotlib на карте не может быть построен

Я столкнулся со странной проблемой, когда хотел построить линии тока с помощью matplotlib на карте с неравномерно распределенными данными модели (из WRF-NMM).

Вначале я определяю новую сетку карты:

    # Define grid and create map grid
    lat = ga.expr('lat') #Latitude from GRIB-File (WRF-NMM), irregularly spaced
    lon = ga.expr('lon') #Longitude from GRIB-File (WRF-NMM), irregularly spaced
    U10 = ga.expr('ugrd10m')
    V10 = ga.expr('vgrd10m')

    map = Basemap(projection='cass', lat_0 = 47, lon_0 = 8,
                  resolution = 'c', llcrnrlon=5.8, llcrnrlat=45.6, 
                  urcrnrlon=10.9, urcrnrlat=48.0,)

    longitudes = lon[1,:]
    latitudes = lat[:,1]
    mx,my = np.meshgrid(longitudes,latitudes)
    mapx,mapy = map(mx,my)

    # Plot streamlines
    stream = map.streamplot(mapx,mapy,U10,V10, density=[0.5, 1])

К сожалению, приведенный выше код не работает, и я не могу найти ошибку самостоятельно. Эта ошибка исходит от странной сетки?

Вот сообщения об ошибках:

/usr/local/lib/python2.7/dist-packages/matplotlib-1.3.1-py2.7-linux-x86_64.egg/matplotlib/contour.py:376: RuntimeWarning: invalid value encountered in true_divide
  dist = np.add.reduce(([(abs(s)[i] / L[i]) for i in range(xsize)]), -1)
Traceback (most recent call last):
  File "plot_map_v2.py", line 96, in <module>
    stream = map.streamplot(mapx,mapy,U10,V10, density=[0.5, 1])
  File "/usr/local/lib/python2.7/dist-packages/mpl_toolkits/basemap/__init__.py", line     551, in with_transform
    return plotfunc(self,x,y,u,v,*args,**kwargs)
  File "/usr/local/lib/python2.7/dist-packages/mpl_toolkits/basemap/__init__.py", line 3691, in streamplot
    ret =  ax.streamplot(x,y,u,v,*args,**kwargs)
  File "/usr/local/lib/python2.7/dist-packages/matplotlib-1.3.1-py2.7-linux-x86_64.egg/matplotlib/axes.py", line 6861, in streamplot
transform=transform)
  File "/usr/local/lib/python2.7/dist-packages/matplotlib-1.3.1-py2.7-linux-x86_64.egg/matplotlib/streamplot.py", line 67, in streamplot
grid = Grid(x, y)
  File "/usr/local/lib/python2.7/dist-packages/matplotlib-1.3.1-py2.7-linux-x86_64.egg/matplotlib/streamplot.py", line 256, in __init__
assert np.allclose(x_row, x)
AssertionError
Error in atexit._run_exitfuncs:
Traceback (most recent call last):
  File "/usr/lib/python2.7/atexit.py", line 24, in _run_exitfuncs
func(*targs, **kargs)
  File "/usr/local/lib/python2.7/dist-packages/matplotlib-1.3.1-py2.7-linux-x86_64.egg/matplotlib/_pylab_helpers.py", line 86, in destroy_all
manager.destroy()
  File "/usr/local/lib/python2.7/dist-packages/matplotlib-1.3.1-py2.7-linux-x86_64.egg/matplotlib/backends/backend_gtk3.py", line 427, in destroy
self.canvas.destroy()
AttributeError: FigureManagerGTK3Agg instance has no attribute 'canvas'
Error in sys.exitfunc:
Traceback (most recent call last):
  File "/usr/lib/python2.7/atexit.py", line 24, in _run_exitfuncs
func(*targs, **kargs)
  File "/usr/local/lib/python2.7/dist-packages/matplotlib-1.3.1-py2.7-linux-x86_64.egg/matplotlib/_pylab_helpers.py", line 86, in destroy_all
manager.destroy()
  File "/usr/local/lib/python2.7/dist-packages/matplotlib-1.3.1-py2.7-linux-x86_64.egg/matplotlib/backends/backend_gtk3.py", line 427, in destroy
self.canvas.destroy()
AttributeError: FigureManagerGTK3Agg instance has no attribute 'canvas'

Ваше здоровье,

Мартин


person GrauBernden    schedule 01.06.2014    source источник


Ответы (1)


взгляните на эту страницу, чтобы лучше понять, как отображать данные:

http://matplotlib.org/basemap/users/examples.html

person Naj    schedule 03.06.2014