matplotlib / matplotlib/basemap

drawlsmask not working for rotpole

Aperta
#156 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Lingua principale
Python
Stelle
817
Fork
395
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

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

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

Inizia in mpl_toolkits/basemap/init.py, in drawlsmask, e segui la sua chiamata a transform_scalar in mpl_toolkits/basemap/proj.py makegrid, dove il traceback mostra la divisione per nx-1. Riproduci m.drawlsmask(resolution='c') con una proiezione rotpole e determina la gestione specifica della proiezione necessaria. Il lavoro è completato quando drawlsmask termina senza ZeroDivisionError e visualizza la maschera terra-mare.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
python
Ambito
data-visualization
Tipo di issue
Bug
Difficoltà
4/5
Tempo stimato
3-5 giorni
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
35/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.