[Python] Basemap nightshade() on Robinson Projection and lon_0=-180

Discussão em 'Python' iniciado por Stack, Novembro 21, 2024.

  1. Stack

    Stack Membro Participativo

    I'm attempting to plot day/night shading on a Robinson projection centered at -180 degrees with Basemap, and as you can see, the shading doesn't look right. I'm also getting a warning about a non-monotonically increasing x coordinate. Maybe there's some way of using shiftgrid to fix the nightshade? Any suggestions would be greatly appreciated!


    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).
    ​

    [​IMG]

    Here is some toy code to reproduce this plot:

    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')

    Continue reading...

Compartilhe esta Página