matplotlib / matplotlib/basemap

llcrnrlon vs llcrnrx [-180, 180 vs 0, 360]

Offen
#155 8 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

Vorherrschende Sprache
Python
Sterne
817
Forks
395
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

I was playing with the projections and it took me a while to understand what's going on... I need the 'rotpole' projection to convert some locations and plot some graphs. I have all the information: lon_0 = 10, o_lon_p = 10, o_lat_p = 10, but I don't have the real lat/lon, I have the rotated one so I'm forced to use llcrnrx, llcrnry....

I have a climate model that gives me the output in this rotated pole projection with rotated left lon = -19.5, rotated right lon = 21, rotated bottom lat = -25, rotated top lat = 20.5.

First take:

import mpl_toolkits.basemap as mb
kwargs = {
    'projection': 'rotpole',
    'llcrnrx': -19.5,
    'llcrnry': -25,
    'urcrnrx': 21,
    'urcrnry': 20.5,
    'o_lon_p': 10,
    'o_lat_p': 32.5,
    'lat_0': 10
}
m = mb.Basemap(**kwargs)

Now m.drawcoastlines() will give me a huge map that goes backwards on X axis... After a full day of investigation... I saw that m.llcrnrx' takes the value of360-19.5 = 340.5andm.urcrnrx = 21` so this clearly dosn't work...

rotpole

Is this behaviour wanted? I mean, when building m = mb.Basemap(...) using llcrnrlon, llcrnrlat... you can safely pass negative values to llcrnrlon but when using llcrnrx you're forced to use (0, 360)...

Working version is:

import mpl_toolkits.basemap as mb
kwargs = {
    'projection': 'rotpole',
    'llcrnrx': 0,
    'llcrnry': -25,
    'urcrnrx': 21,
    'urcrnry': 40.5,
    'o_lon_p': 10,
    'o_lat_p': 32.5,
    'lat_0': -9.5
}
m = mb.Basemap(**kwargs)

So now I'm forced to do:

# x, y taken from climate model
xoffset = 19.5
lon, lat = m([x + xoffset], [y], inverse=True)

Even more confusing is the fact that you can use negative values in convert as in m(-1, 0, inverse=True) and you get the correct negative real longitude value...

Edit: using version 1.0.7; fixed 'urcrnry' misspell

Beitragsleitfaden

Für dieses Repository ist kein Beitragsleitfaden indexiert

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Rechercherichtung

Beginne damit, die bereitgestellten Beispiele für den Basemap-Konstruktor und die inverse Konvertierung mit den gemeldeten Koordinaten des gedrehten Pols zu reproduzieren. Untersuche, wie der Basemap-Einstiegspunkt die Bereiche llcrnrx und urcrnrx verarbeitet, ermittle dann das erwartete Koordinatenverhalten und füge eine Abdeckung für den Fall eines negativen gedrehten Längengrads hinzu. Die Aufgabe ist abgeschlossen, wenn der dokumentierte Koordinatenbereich und die resultierende Kartenausrichtung konsistent sind.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
python
Bereich
data-visualization
Issue-Typ
Bug
Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
35/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.