matplotlib / matplotlib/basemap

Shiftdata breaks pcolormesh wrapping

オープン
#183 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

主要言語
Python
スター
817
フォーク
395
PR マージ指標
30日以内にマージされた PR はありません

説明

I have a data grid which spans the whole globe from -180 -> 180. pcolormesh can plot this OK if I have lon_0=0 in which case Basemap doesn't have to do any wrapping
pcolormesh_ok

However if I do this for lon_0=180 (where Basemap has to shift some data), I get the following incorrect plot:
pcolormesh_bad

The code I have used for this is (using 1.0.7):

    import numpy as np
    from mpl_toolkits.basemap import Basemap
    import matplotlib.pyplot as plt
    x = np.arange(-180, 190, 10)
    y = np.array([40, 50, 60])
    data = np.arange(72).reshape((2, 36))
    xv, yv = np.meshgrid(x, y)
    # Add an empty row and column of data so that the data is the same shape as X,Y
    wider_data = np.ma.zeros(xv.shape)
    for index, v in np.ndenumerate(data):
        wider_data[index] = data[index]
    for lon in (0, 180):
        map = Basemap(lon_0=lon)
        map.drawparallels(np.arange(-90, 90, 20), labels=[1, 1, 0, 1])
        map.drawmeridians(np.arange(-180, 180, 30), labels=[1, 1, 0, 1])
        map.pcolormesh(xv, yv, wider_data, latlon=True)
        map.drawcoastlines()
        plt.show()

I suspect that this problem is related to https://github.com/matplotlib/basemap/issues/182 because to get around that issue, I have had to add an empty row and column to the data. This should still be OK though, since that extra data should just be ignored (from the pcolormesh docs).

However, what actually happens is that the empty row gets moved around because shiftdata doesn't know it should ignore and so the plot is wrong.

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

まず、提供された Basemap 1.0.7 の再現コードを pcolormesh で実行し、lon_0=0 と lon_0=180 のプロットを比較します。pcolormesh がラッピングに使用する shiftdata のパスを調査します。追加の行と列が引き続き無視され、シフトされたプロットが期待されるグローバルグリッドと一致すれば完了です。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
matplotlib, numpy, python
領域
data-visualization
issue の種類
バグ
難易度
3/5
見積もり時間
1〜2日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
45/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。