1

我正在使用方位角等距投影绘制火星北极附近一段的高程数据,这就是它的外观,如果北方向上,我会更喜欢它! 随着北下

这就是我的做法,我在 matplotlib.basemap 网站( http://matplotlib.org/basemap/users/index.html )上找不到任何建议解决方案的东西,所以任何想法都将不胜感激. 谢谢。

# 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]')
4

0 回答 0