matplotlib / matplotlib/basemap

contour not closed across 0 meridian in polar projection

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

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

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

説明

Hi all,
I'm trying to fetch contour line coordinates from a npaeqd projection plot and I noticed that the contour lines will be broken into 2 parts whenever it crosses the 0-degree longitude, even though they form a closed contour and after calling addcyclic(). Below is minimal working example:

import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.basemap import addcyclic
from mpl_toolkits.basemap import Basemap

lats=np.linspace(0,90,90)
lons=np.linspace(0,360,360)

# make some toy data
xx,yy=np.meshgrid(lons,lats)
z=np.cos(xx*np.pi/180)*np.sin(yy*np.pi/180)

# add cyclic
z,lons=addcyclic(z,lons)
xx,yy=np.meshgrid(lons,lats)

# get contours
bmap=Basemap(projection='npaeqd',boundinglat=0,lon_0=0,
        resolution='l')

fig=plt.figure(figsize=(12,6))
ax1=fig.add_subplot(1,2,1)

contours=bmap.contour(xx,yy,z,[-0.6,0.6],latlon=True,ax=ax1)
bmap.drawcoastlines(ax=ax1)

clines1=contours.collections[0].get_paths()
clines2=contours.collections[1].get_paths()

print 'len(clines1), num of contours across 180', len(clines1)
print 'len(clines2), num of contours across 0', len(clines2)

# plot contours
ax2=fig.add_subplot(1,2,2)

xs=clines1[0].vertices[:,0]
ys=clines1[0].vertices[:,1]
ax2.plot(xs,ys,'b-',label='Contour across 180')

xs=clines2[0].vertices[:,0]
ys=clines2[0].vertices[:,1]
ax2.plot(xs,ys,'r-',label='Half contour across 0')

xs=clines2[1].vertices[:,0]
ys=clines2[1].vertices[:,1]
ax2.plot(xs,ys,'g-',label='Half contour across 0')

ax2.legend()

plt.show(block=False)

Figure output here
The yellow contour on the left are made up by 2 lines (red+green) on the right. This makes it difficult when I try to detect and track some features that move across the 0-meridian.
Is it intended or a bug?

Some specs:
basemap 1.0.7
matplotlib 2.2.2, both installed via conda install

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

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

はじめの一歩

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

調査の方向性

npaeqd投影でaddcyclic()とBasemap.contour()を使用する最小限の例から始め、0度の子午線付近で輪郭パスがどのように返されるかを調べます。閉じた輪郭が2つの部分ではなく1つの連続したパスとして返され、例の180度をまたぐ輪郭が引き続き正しい状態になれば完了です。

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

評価

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

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

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