Plotting global equal area maps with python, matplotlib/pylab and Basemap.
Sibiria 13,1 · 106 km² vs. china 9.7 · 106 km²
Maps thanks to Marble Desktop Globe [3] and Open Street Map [4], available under CC by-sa [5] and Open Data Commons Open Database License (ODbL) [6].
m = map.Basemap(projection='cea', lat_ts=37.5) outfile = "hobo-dyer.png" pl.title("Hobo Dyer: Cylindric Equal Area at $37.5^\\circ N$")
m = map.Basemap(projection='hammer', lon_0=0) outfile = "hammer.png" pl.title("Hammer") # latex-test: $\frac{1}{2}$
m = map.Basemap(projection='mbtfpq', lon_0=0) outfile = "flatpolarquartic.png" pl.title("Flat Polar Quartic: parallels at $33^\\circ 45' N/S$")
To show regional fluxes and longitudinally constrained regions: Easy to spot on rectangular grid.
To show a global overview: Helps the understanding of global data because it appears most similar to a real earth while including the whole earth surface.
For mainly latitudinally constrained regions: Straight latitudinal lines and high latitudinal resolution near the poles.
# basemap, pylab and numpy for plotting import mpl_toolkits.basemap as map import pylab as pl import numpy as np # netcdf for reading the emission files import netCDF4 as nc
<<addmapfeatures>> <<addindicatrix>> try: <<addemissions>> <<addcolorbar>> except RuntimeError: # recover from missing fluxfile m.fillcontinents(color='coral',lake_color='aqua') pl.savefig(outfile) return "./" + outfile + ""
# add map lines m.drawcoastlines() # only fill continents if we do not plot emissions # m.fillcontinents(color='coral',lake_color='aqua') m.drawparallels(np.arange(-90.,120.,30.), labels=[False,True,True,False]) m.drawmeridians(np.arange(0.,420.,60.), labels=[True,False,False,True]) m.drawmapboundary(fill_color='aqua')
# draw tissot's indicatrix to show distortion. for y in np.linspace(m.ymax/20,19*m.ymax/20,9): for x in np.linspace(m.xmax/20,19*m.xmax/20,12): lon, lat = m(x,y,inverse=True) poly = m.tissot(lon,lat,4.0,100, facecolor='green', zorder=10,alpha=0.5)
# d = nc.Dataset("/run/media/arne/3TiB/CTDAS-2013-03-07-2years-base-data/" # "analysis/data_flux1x1_weekly/flux_1x1.nc") d = nc.Dataset("UNPUBLISHED") biocovmean = np.mean( d.variables["bio_flux_prior_cov"][:,:,:], axis=0) # projection: matplotlib.org/basemap/users/examples.html lons, lats = pl.meshgrid(range(-180, 180), range(-90, 90)) x, y = m(lons, lats) # choose my standard color range: vmin = -0.5*vmax vmax = max(abs(np.max(biocovmean)), 2 * abs(np.min(biocovmean))) vmin = -0.5*vmax m.pcolor(x, y, biocovmean, shading='flat', vmin=vmin, vmax=vmax) # pcolormesh is faster
pl.rcParams.update({"text.usetex": True, "text.latex.unicode": True}) colorbar = pl.colorbar(orientation="horizontal", format="%.2g") # scientific colorbar.set_label("$CO_{2}$ fluxes [$\\frac{mol}{m^2 s}$]")
Emacs [12] 24.3.1 (Org [13] mode 8.0.2)
Validate XHTML 1.0 [14]
Anhang | Größe |
---|---|
flatpolarquartic.png [15] | 127.57 KB |
hobo-dyer.png [16] | 139.26 KB |
hammer.png [17] | 138.15 KB |
sibiria-china-flat.png [18] | 1.14 MB |
sibiria-china-globe.png [19] | 1.14 MB |
equal-area-map-projections.pdf [1] | 3.06 MB |
equal-area-map-projections.org [2] | 10.19 KB |
Links:
[1] https://www.draketo.de/files/equal-area-map-projections.pdf
[2] https://www.draketo.de/files/equal-area-map-projections.org
[3] http://kde.org/applications/education/marble/
[4] http://www.openstreetmap.org/
[5] http://creativecommons.org/licenses/by-sa/2.0/
[6] http://opendatacommons.org/licenses/odbl/
[7] http://onlinelibrary.wiley.com/doi/10.1029/JB078i011p01753/abstract
[8] http://matplotlib.org/basemap/
[9] http://www.scipy.org/PyLab
[10] http://www.numpy.org/
[11] http://code.google.com/p/netcdf4-python/
[12] http://www.gnu.org/software/emacs/
[13] http://orgmode.org
[14] http://validator.w3.org/check?uri=referer
[15] https://www.draketo.de/files/flatpolarquartic.png
[16] https://www.draketo.de/files/hobo-dyer.png
[17] https://www.draketo.de/files/hammer.png
[18] https://www.draketo.de/files/sibiria-china-flat.png
[19] https://www.draketo.de/files/sibiria-china-globe.png