matplotlib / matplotlib/basemap

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

Open
#155 8 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
817
Forks
395
PR merge metrics
No merged PRs in 30d

Description

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:

``` python
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 of`360-19.5 = 340.5`and`m.urcrnrx = 21` so this clearly dosn't work...

![rotpole](https://cloud.githubusercontent.com/assets/1177508/3072050/deb6ba2c-e2c0-11e3-9bcf-221ed20debaf.png)

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:

``` python
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:

``` python
# 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

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the provided Basemap constructor and inverse-conversion examples with the reported rotated-pole coordinates. Inspect how the Basemap entry point handles llcrnrx and urcrnrx ranges, then determine the expected coordinate behavior and add coverage for the negative rotated-longitude case. Done means the documented coordinate range and resulting map orientation are consistent.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
data-visualization
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.