matplotlib / matplotlib/basemap
drawlsmask not working for rotpole
Nadie ha tomado este issue todavía.
- Lenguaje dominante
- Python
- Estrellas
- 817
- Forks
- 395
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Descripción
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
Guía de contribución
No hay ninguna guía de contribución indexada para este repositorio
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Línea de trabajo
Comienza en mpl_toolkits/basemap/init.py, en drawlsmask, y sigue su llamada a transform_scalar en mpl_toolkits/basemap/proj.py makegrid, donde el traceback muestra la división por nx-1. Reproduce m.drawlsmask(resolution='c') con una proyección rotpole y determina el tratamiento específico de la proyección que se necesita. Se considera terminado cuando drawlsmask finaliza sin ZeroDivisionError y renderiza la máscara tierra-mar.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- python
- Área
- data-visualization
- Tipo de issue
- Error
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Estado de actividad
- Estancado
- Claridad
- Bastante claro
- Aptitud para principiantes
- 35/100