Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nightshade() on Robinson Projection and lon_0=-180 #610

Open
domdabomb opened this issue Nov 22, 2024 · 2 comments
Open

nightshade() on Robinson Projection and lon_0=-180 #610

domdabomb opened this issue Nov 22, 2024 · 2 comments

Comments

@domdabomb
Copy link

Hello! I'm plotting day/night shading on a Robinson projection centered at -180 degrees with nightshade(), and as you can see, the shading doesn't look right. I'm also getting a warning about a non-monotonically increasing x coordinate. Presumably, nightshade() is plotting a transparent contour under the hood, but I couldn't see a way to change the starting longitude in the documentation. I'm not familiar enough with Basemap to know if this is a bug or if I'm missing something. Any suggestions would be greatly appreciated!

Plot
test

Warning

WARNING: x coordinate not montonically increasing - contour plot may not be what you expect. If it looks odd, your can either adjust the map projection region to be consistent with your data, or (if your data is on a global lat/lon grid) use the shiftgrid function to adjust the data to be consistent with the map projection region (see examples/contour_demo.py).

Code for reproduction

from mpl_toolkits.basemap import Basemap
import numpy as np
import matplotlib.pyplot as plt
from datetime import datetime
# lon_0 is central longitude of projection.
# resolution = 'c' means use crude resolution coastlines.
m = Basemap(projection='robin',lon_0=-180,resolution='c')
m.drawcoastlines()
m.fillcontinents(color='coral',lake_color='aqua')
# draw parallels and meridians.
m.drawparallels(np.arange(-90.,120.,30.))
m.drawmeridians(np.arange(0.,360.,60.))
m.drawmapboundary(fill_color='aqua')
date = datetime(2024,10,10,6)
m.nightshade(date,alpha=0.2)
plt.title("Robinson Projection")
plt.savefig('test.png')

Environment
Ubuntu and RHEL
Python 3.8.13

Please let me know if I should be providing more details

@molinav
Copy link
Member

molinav commented Nov 22, 2024

Hi, @domdabomb! Which basemap version are you using to reproduce the issue? Can you provide a list of the packages in your environment? Is basemap installed from the system repositories, from PyPI, from miniforge, or directly built from the source code?

@domdabomb
Copy link
Author

Hi @molinav. I think I installed Basemap from PyPI. Here's what conda list | grep basemap returns:

basemap 1.3.8 pypi_0 pypi
basemap-data 1.3.2 pypi_0 pypi

I'm attaching the output of conda env export > conda_env.txt here:
conda_env.txt

Is this the info you need? Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants