matplotlib / matplotlib/basemap

drawlsmask not working for rotpole

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

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

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

説明

Now that I played with 'rotpole' a bit... I also found that dralsmask fails with ZeroDivisionError. This is the full traceback:

---------------------------------------------------------------------------
ZeroDivisionError                         Traceback (most recent call last)
<ipython-input-79-0ba416c748fa> in <module>()
----> 1 m.drawlsmask(resolution='c')

/home/razvan/.local/lib/python3.4/site-packages/mpl_toolkits/basemap/__init__.py in drawlsmask(self, land_color, ocean_color, lsmask, lsmask_lons, lsmask_lats, lakes, resolution, grid, **kwargs)
   3934         # to a rectangular map projection grid.
   3935             mask,x,y = self.transform_scalar(lsmask,lsmask_lons,-> 3936                        lsmask_lats,nx,ny,returnxy=True,order=0,masked=255)
   3937             lsmask_lats.dtype
   3938             # for these projections, points outside the projection

/home/razvan/.local/lib/python3.4/site-packages/mpl_toolkits/basemap/__init__.py in transform_scalar(self, datin, lons, lats, nx, ny, returnxy, checkbounds, order, masked)
   2961                 raise ValueError('grid must be shifted so that lons are monotonically increasing and fit in range -180,+180 (see shiftgrid function)')
   2962         if returnxy:
-> 2963             lonsout, latsout, x, y = self.makegrid(nx,ny,returnxy=True)
   2964         else:
   2965             lonsout, latsout = self.makegrid(nx,ny)

/home/razvan/.local/lib/python3.4/site-packages/mpl_toolkits/basemap/__init__.py in makegrid(self, nx, ny, returnxy)
   1172         If ``returnxy = True``, the x,y values of the grid are returned also.
   1173         """
-> 1174         return self.projtran.makegrid(nx,ny,returnxy=returnxy)
   1175 
   1176     def _readboundarydata(self,name,as_polygons=False):

/home/razvan/.local/lib/python3.4/site-packages/mpl_toolkits/basemap/proj.py in makegrid(self, nx, ny, returnxy)
    332         if returnxy=True, the x,y values of the grid are returned also.
    333         """
--> 334         dx = (self.urcrnrx-self.llcrnrx)/(nx-1)
    335         dy = (self.urcrnry-self.llcrnry)/(ny-1)
    336         x = self.llcrnrx+dx*np.indices((ny,nx),np.float32)[1,:,:]

ZeroDivisionError: float division by zero

I figured it's because of this:

nx = int((self.xmax-self.xmin)/dx)+1; ny = int((self.ymax-self.ymin)/dx)+1

here self.xmax, self.xmin, ... are used incorrectly for 'rotpole' giving nx == ny == 1.

I tried changing line 3928:

if self.projection == 'cyl':

to

if self.projection == 'cyl' or self.projection == 'rotpole':

with the effect of producing a nice pattern :) but no land sea mask unfortunately... so the issue is a bit dipper, but I don't have time to investigate now...

Edit: on version 1.0.7

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

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

はじめの一歩

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

調査の方向性

mpl_toolkits/basemap/init.py の drawlsmask から開始し、トレースバックに nx-1 による除算が示されている mpl_toolkits/basemap/proj.py の makegrid への transform_scalar 呼び出しを追跡します。rotpole 投影で m.drawlsmask(resolution='c') を再現し、必要な投影固有の処理を特定します。drawlsmask が ZeroDivisionError なしで完了し、陸海マスクを描画できれば完了です。

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

評価

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

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

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