addcyclic problem with grib2 data
還沒有人認領這個 Issue。
評估
- 難度
- 3/5
- 預估耗時
- 1-2 天
- 新手友好度
- 35/100
- Issue 類型
- 缺陷
- 描述清晰度
- 基本清楚
- 活躍度
- 停滯
- 技術堆疊
- matplotlib, numpy, python
研究方向
使用指定的 Basemap 版本執行提供的 Python 指令碼,並檢查 addcyclic 呼叫,接著檢查 Basemap.call 以及回報的 pyproj 轉換。比較 addcyclic 前後 temp、lons 和 lats 的形狀。完成的標準是 GRIB2 範例能夠執行結束,座標陣列彼此相符,並產生預期的等高線圖。
由索引模型根據 Issue 內容生成。
描述
I have some problems to use add cyclic with data from grib2 file.
This is my code:
# -*- coding: utf-8 -*-
import pygrib
import numpy as np
from matplotlib.backends.backend_agg import FigureCanvasAgg as FigureCanvas
from matplotlib.figure import Figure
from mpl_toolkits.basemap import Basemap, addcyclic
fig = Figure((4, 3))
canvas = FigureCanvas(fig)
ax = fig.add_axes([0.05, 0.05, 0.9, 0.9])
# File download from http://para.nomads.ncep.noaa.gov/pub/data/nccf/com/gfs/para/gfs.2016041918/gfs.t18z.pgrb2.0p25.f000
grbindx = pygrib.index('gfs.t18z.pgrb2.0p25.f000', 'shortName', 'typeOfLevel', 'level')
grb = grbindx.select(shortName='2t', typeOfLevel='heightAboveGround', level=2)[0]
lats, lons = grb.latlons()
temp = grb.values
temp, lons = addcyclic(temp, lons)
bm = Basemap(projection='mill', resolution='l', ax=ax,
llcrnrlat=32, urcrnrlat=70, llcrnrlon=-25,
urcrnrlon=40.5, lat_ts=20)
x, y = bm(lons, lats)
bm.contourf(x, y, temp)
bm.drawcoastlines()
canvas.print_figure('gfs_temperature_2m.png', dpi=100)
With python 2.7.11 and basemap 1.0.7 this is the result:
Traceback (most recent call last):
File "addcyclic.py", line 21, in <module>
temp, lons = addcyclic(temp, lons)
File "/usr/local/lib/python2.7/site-packages/mpl_toolkits/basemap/__init__.py", line 5062, in addcyclic
lonsout[0:nlons] = lonsin[:]
ValueError: could not broadcast input array from shape (721,1440) into shape (1440)
With python 2.7.11 and basemap 1.0.8 (from latest github commit) this is the result:
Traceback (most recent call last):
File "addcyclic.py", line 27, in <module>
x, y = bm(lons, lats)
File "/usr/local/lib/python2.7/site-packages/mpl_toolkits/basemap/__init__.py", line 1175, in __call__
xout,yout = self.projtran(x,y,inverse=inverse)
File "/usr/local/lib/python2.7/site-packages/mpl_toolkits/basemap/proj.py", line 286, in __call__
outx,outy = self._proj4(x, y, inverse=inverse)
File "/usr/local/lib/python2.7/site-packages/pyproj/__init__.py", line 399, in __call__
_proj.Proj._fwd(self, inx, iny, radians=radians, errcheck=errcheck)
File "_proj.pyx", line 128, in _proj.Proj._fwd (_proj.c:1678)
RuntimeError: Buffer lengths not the same
Where is the problem?
Some bug in basemap? Or in my code?
Without addcycle this is the result:

Thanks
Andrew
- 主要語言
- Python
- 星號
- 817
- 分支
- 394
- PR 合併指標
- 30 天內沒有已合併 PR
環境準備
這個專案沒有提供開發容器、Dockerfile 或貢獻指南,環境需要你自己搭建:先看它的 README,通用步驟見我們的新手貢獻指南。
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
matplotlib/basemap 的其他 Issue
-
small bug in drawmapscale可能已有人在做 @DavidVadnais 於 55 天前認領。 未關閉
難度 2/5 1-3 小時 新手友好度 68/100
matplotlib/basemap#368 ·
-
難度 4/5 3-5 天 新手友好度 48/100
matplotlib/basemap#655 · 2 則留言 ·
-
難度 4/5 3-5 天 新手友好度 48/100
matplotlib/basemap#652 · 2 則留言 · 5 個 reaction ·
-
難度 2/5 1-3 小時 新手友好度 45/100
matplotlib/basemap#649 · 2 個 reaction ·
-
難度 5/5 一週以上 新手友好度 35/100
matplotlib/basemap#646 ·
查看 matplotlib/basemap 的全部 Issue
相似的 Issue
-
The changelog workflow excludes otelbot but not dependabot, so every Dependabot pull request fails the changelog check可能已有人在做 @ocelotl 今天認領。 未關閉
難度 1/5 1 小時以內 新手友好度 82/100
open-telemetry/opentelemetry-python#5825 ·
維護者通常 2 天內回覆
-
難度 2/5 1-3 小時 新手友好度 72/100
cuga-project/cuga-agent#1020 ·
維護者通常 2 天內回覆
-
難度 1/5 1 小時以內 新手友好度 70/100
microsoft/playwright#43640 ·
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 84/100
stac-utils/stac-fastapi-elasticsearch-opensearch#965 ·
維護者通常 2 天內回覆
-
難度 2/5 1-3 小時 新手友好度 70/100
維護者通常 1 天內回覆