matplotlib / matplotlib/basemap

Shiftdata breaks pcolormesh wrapping

Ouverte
#183 0 commentaires 0 réactions 0 personnes assignées Voir sur GitHub

Personne n'a encore pris cette issue.

Langage dominant
Python
Étoiles
817
Forks
395
Métriques de merge des PR
Aucune PR mergée en 30 j

Description

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](https://cloud.githubusercontent.com/assets/7656534/6391456/4383d52a-bdae-11e4-804a-718626b54441.png)

However if I do this for lon_0=180 (where Basemap has to shift some data), I get the following incorrect plot:
![pcolormesh_bad](https://cloud.githubusercontent.com/assets/7656534/6391457/43853fa0-bdae-11e4-857f-de3bcebc4300.png)

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.

Guide de contribution

Aucun guide de contribution indexé pour ce dépôt

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Piste de recherche

Commencez par exécuter la reproduction fournie de Basemap 1.0.7 avec pcolormesh et comparez les graphiques lon_0=0 et lon_0=180. Inspectez le chemin shiftdata utilisé par pcolormesh pour le wrapping ; le travail est terminé lorsque la ligne et la colonne supplémentaires restent ignorées et que le graphique décalé correspond à la grille globale attendue.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Évaluation

Stack technique
matplotlib, numpy, python
Domaine
data-visualization
Type d'issue
Bug
Difficulté
3/5
Temps estimé
1-2 jours
Activité
À l'abandon
Clarté
Plutôt claire
Accessibilité débutants
45/100

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.