Documentation for PISM, the Parallel Ice Sheet Model

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
doc_misc [2014/01/13 23:06]
Ed Bueler try link to basemap_ex1.py at github/pism/pismdocs-template
doc_misc [2014/01/20 22:49]
Constantine Khroulev
Line 9: Line 9:
 Below is an example plotting csurf (the magnitude of the horizontal ice velocity at the ice surface) using a logarithmic color scale and marking the 100 <​sup>​m</​sup>/<​sub>​year</​sub>​ contour in black: Below is an example plotting csurf (the magnitude of the horizontal ice velocity at the ice surface) using a logarithmic color scale and marking the 100 <​sup>​m</​sup>/<​sub>​year</​sub>​ contour in black:
  
-[[https://​raw.github.com/​pism/​pismdocs-template/​master/​public_scripts/​basemap_ex1.py|basemap_ex1.py]] +++++ Click here to see the source of basemap_ex1.py | 
- +<code python basemap_ex1.py>​
-++++ Click here for source of basemap_ex1.py | +
- +
-<file python basemap_ex1.py>​+
 #​!/​usr/​bin/​env python #​!/​usr/​bin/​env python
 from mpl_toolkits.basemap import Basemap, NetCDFFile from mpl_toolkits.basemap import Basemap, NetCDFFile
Line 76: Line 73:
 plt.title(r"​Modeled ice surface velocity, m/​year"​) plt.title(r"​Modeled ice surface velocity, m/​year"​)
 plt.savefig('​g10km_0_csurf.png'​) plt.savefig('​g10km_0_csurf.png'​)
-</file> +</code>
 ++++ ++++
 +
  
 The following alternative python code does nearly the same thing but uses [[https://​code.google.com/​p/​netcdf4-python/​|netcdf4-python]] to read NetCDF: The following alternative python code does nearly the same thing but uses [[https://​code.google.com/​p/​netcdf4-python/​|netcdf4-python]] to read NetCDF:
  
-++++ Click here for source of basemap_ex2.py | +++++ Click here to see the source of basemap_ex2.py | 
- +<code python basemap_ex2.py>​
-<file python basemap_ex2.py>​+
 #​!/​usr/​bin/​env python #​!/​usr/​bin/​env python
 from mpl_toolkits.basemap import Basemap from mpl_toolkits.basemap import Basemap
  
-try: +from netCDF4 import Dataset as NC
-    ​from netCDF4 ​import Dataset as NC +
-except: +
-    from netCDF3 ​import Dataset as NC+
  
 import numpy as np import numpy as np
Line 160: Line 153:
 plt.title(r"​modeled surface velocity, m/​year"​) plt.title(r"​modeled surface velocity, m/​year"​)
 plt.savefig(rootname+'​_csurf.png'​) plt.savefig(rootname+'​_csurf.png'​)
-</file> +</code>
 ++++ ++++
 +
  
 This is the output of basemap_ex1.py:​ This is the output of basemap_ex1.py:​
 {{ g10km_0_csurf.png?​500 }} {{ g10km_0_csurf.png?​500 }}
doc_misc.txt · Last modified: 2014/01/20 22:49 by Constantine Khroulev
© 2020 by PISM | webmaster