Question

I'm plotting elevation data for a segment near the north pole on Mars, using an Azimuthal Equidistant Projection, and this is how it looks, I would prefer it if North was up! With North Down

This is how I'm doing it, I can't find anything on the matplotlib.basemap website (http://matplotlib.org/basemap/users/index.html) to suggest a solution, so any ideas would be greatly appreciated. Thanks.

# FYI, 'array' is a 200x1000 numpy array containing the elevation values
# Latitude and Longitude are 200x1 and 1000x1 arrays respectively, 
#          containing the Latitude and Longitude
# minlat, minlon, maxlat, maxlon, midlat, midlon are the minimum,
#          middle and maximum values in Latitude and Longitude.
# C_Earth is 678.1e3m, Basemap doesn't know I'm looking at Mars.    

# Set up size of map
scope = maxlon-minlon
Circ = C_Earth*np.cos((180./np.pi)*minlat)
width = 1.8*Circ*(scope/360.)

# Prepare Map
m = Basemap(width=width, height=width, projection='aeqd', lat_0=midlat, lon_0=midlon)

# Automated thing to choose appropriate parallels & meridians
division_lon = [30, 10, 5, 2, 1, 0.5, 0.1]
parallels, i = [], 0
while len(parallels) < 4:
    minlatline = 80
    while minlatline > np.floor(minlat):
        minlatline -= division_lon[i]
    parallels = np.arange(minlatline, maxlat, division_lon[i])
    i += 1
meridians, i = [], 0
while len(meridians) < 4:
    minlonline = 360
    while minlonline > np.floor(minlon):
        minlonline -= division_lon[i]
    meridians = np.arange(minlonline, maxlon+division_lon[i], division_lon[i])
    i += 1
m.drawparallels(parallels, labels=[True,False,False,False])
m.drawmeridians(meridians, labels=[False,False,False,True])

# make up a regular lat/lon grid.
lons, lats = np.meshgrid(Longitude, Latitude)
# compute native map projection coordinates of lat/lon grid.
x, y = m(lons, lats)
# contour data over the map.
masked_array = np.ma.array(array, mask=np.isnan(array))
cs = m.pcolormesh(x,y,masked_array)
cb = plt.colorbar(orientation='horizontal', aspect=40)
cb.set_label('Elevation [m]')

No correct solution

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top