contourf on cylindrical projection with irregular latlon grid (tri=True) is calling shiftdata when it shouldn't
还没有人认领这个 Issue。
评估
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 新手友好度
- 45/100
- Issue 类型
- 缺陷
- 描述清晰度
- 基本清楚
- 活跃度
- 停滞
- 技术栈
- matplotlib, python
调研方向
从 lib/mpl_toolkits/basemap/init.py 开始,沿着 contourf 包装器跟踪到 shiftdata 以及 traceback 中显示的 itemindex 检查。使用圆柱投影、不规则 1D 数组、tri=True 和 latlon=True 重现该示例,然后与正射投影进行比较;完成的标准是圆柱投影情况下不再引发 ambiguous-array ValueError,同时规则网格的行为保持不变。
由索引模型根据 Issue 内容生成。
描述
I ran into this problem while trying to plot interpolated data NOT on a regular latlon grid. Orthographic projection works but cylindrical does not.
Relevant code:
fig = plt.figure()
ax = fig.add_subplot(111)
levels = 20
m = Basemap(projection="cyl") # causes ValueError
# m = Basemap(projection="ortho", lat_0=0., lon_0=0., resolution='l') # works, does not cause ValueError
MC = m.contourf(lons_deg, lats_deg, vals, levels, ax=ax, tri=True, latlon=True) # latlon=True interprets first two args as lon and lat respectively
Note that lats_deg, lons_deg, and vals are 1d np arrays with irregular point spacing (no meshgrid). I used tri=True to allow interpolation. This works fine on orthographic projection. But with cylindrical I get the following error:
Traceback (most recent call last):
File "IcosahedralGeodesicLattice.py", line 146, in <module>
test_lattice.plot_data(data)
File "/home/wesley/programming/Mapping/Lattice.py", line 86, in plot_data
MC = m.contourf(lons_deg, lats_deg, vals, levels, ax=ax, tri=True, latlon=True) # latlon=True interprets first two args as LON and LAT RESPECTIVELY
File "/home/wesley/.local/lib/python3.5/site-packages/mpl_toolkits/basemap/__init__.py", line 544, in with_transform
fix_wrap_around=plotfunc.__name__ not in ["scatter"])
File "/home/wesley/.local/lib/python3.5/site-packages/mpl_toolkits/basemap/__init__.py", line 4797, in shiftdata
if fix_wrap_around and itemindex:
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
Looking at the relevant file, the docstring for shiftdata says "Only valid for cylindrical/pseudo-cylindrical global projections and data on regular lat/lon grids. longitudes and data can be 1-d or 2-d, if 2-d it is assumed longitudes are 2nd (rightmost) dimension."
So should it not be being called with tri=True? Sorry if I have misunderstood something, let me know. Thanks!
- 主要语言
- Python
- 星标
- 817
- 派生
- 395
- PR 合并指标
- 30 天内没有已合并 PR
贡献指南
这个仓库没有索引到贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
matplotlib/basemap 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 68/100
matplotlib/basemap#368 ·
-
难度 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 ·
-
难度 2/5 1-3 小时 新手友好度 48/100
matplotlib/basemap#645 · 2 条评论 ·
查看 matplotlib/basemap 的全部 Issue
相似的 Issue
-
triage/confirmed
难度 2/5 1-3 小时 新手友好度 88/100
agentscope-ai/agentscope#2775 ·
-
comp/desktop P3 type/bug
难度 1/5 1 小时以内 新手友好度 92/100
NousResearch/hermes-agent#118866 ·
-
bug
难度 1/5 1 小时以内 新手友好度 90/100
apache/cloudstack#14222 ·
-
难度 2/5 1-3 小时 新手友好度 76/100
-
bug
难度 2/5 1-3 小时 新手友好度 82/100