matplotlib / matplotlib/basemap
Numerical precision issue in rotate_vector
- Dominant language
- Python
- Stars
- 817
- Forks
- 395
- PR merge metrics
- No merged PRs in 30d
Description
Hi,
I ran into a numerical precision issue when using the rotate_vector function with 32bit floats as input data. In this case, the lat/lon increments used to determine the relative rotation between map projection and the lat/lon grid is chosen too small. The result was a cristalline structure in the plotted wind barbs which patches of barbs pointing in the exact same direction.
https://github.com/matplotlib/basemap/blob/decfa95124dab76499734145d03b002b9db27477/lib/mpl_toolkits/basemap/__init__.py#L3118
Converting the input to 64bit floats solves the issue for me, as did an increase of the increment to 1.0e-4.
Best regards,
Clemens
Contributor guide
No contributing guide indexed for this repository
Research direction
Start at lib/mpl_toolkits/basemap/__init__.py around the rotate_vector implementation referenced in the issue. Reproduce the wind-barb artifact with 32-bit float inputs, compare it with 64-bit inputs and the larger increment mentioned, and verify that the crystalline pattern is eliminated without changing expected rotation behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- matplotlib, python
- Domain
- data-visualization
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100