matplotlib / matplotlib/basemap

etopo does not work for rotpole projection?

Open
#168 1 comment 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

Hi I was trying to get etopo image for my domain in rotpole projection but getting ZeroDivisionError: float division by zero. I understand the problem but not sure how to fix it.

Consider this code from the Basemap.warpimage method:

                if self.projection != 'cyl':
                     dx = 2.*np.pi*self.rmajor/float(nlons)
                     nx = int((self.xmax-self.xmin)/dx)+1
                     ny = int((self.ymax-self.ymin)/dx)+1

Since dx is in meters here and xmin,xmax,ymin,ymax are in degrees when the porjection is rotpole, so dx is very big (in meters or km) and domain width is small (in degrees), so here we get nx=ny=1, and later when we try to divide by (nx-1) we get the ZeroDivisionError.

Is there a quick fix for that? I tried to use dx=360.0/float(nlons), exception is gone but the image is wrong...

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 in Basemap.warpimage and reproduce the ZeroDivisionError for an etopo image with a rotpole projection. Inspect how projection coordinates and the dx-based nx/ny calculation are used before the later division. Done means the rotpole case avoids the error and produces a correctly positioned etopo image.

Written by the indexing model from the issue text.

Assessment

Tech stack
matplotlib, 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.