matplotlib / matplotlib/basemap
contourf on cylindrical projection with irregular latlon grid (tri=True) is calling shiftdata when it shouldn't
Chưa có ai nhận issue này.
- Ngôn ngữ chính
- Python
- Star
- 817
- Fork
- 395
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Mô tả
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
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](https://github.com/matplotlib/basemap/blob/master/lib/mpl_toolkits/basemap/__init__.py), 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!
Hướng dẫn đóng góp
Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Hướng nghiên cứu
Bắt đầu trong lib/mpl_toolkits/basemap/__init__.py, lần theo wrapper contourf đến shiftdata và kiểm tra itemindex được hiển thị trong traceback. Tái hiện ví dụ với phép chiếu hình trụ, các mảng 1D không đều, tri=True và latlon=True, sau đó so sánh với phép chiếu trực giao; hoàn thành khi trường hợp hình trụ không còn phát sinh ValueError do mảng không rõ ràng và hành vi trên lưới đều vẫn được giữ nguyên.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- matplotlib, python
- Lĩnh vực
- data-visualization
- Loại issue
- Lỗi
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Khá rõ ràng
- Mức phù hợp với người mới
- 45/100