This jupyter notebook can be found at: https://github.com/environmentalscience/essm/blob/master/docs/examples/importable_variables_equations.ipynb
Below, we will import some generic python packages that are used in this notebook:
In [1]:
# Checking for essm version installed
import pkg_resources
pkg_resources.get_distribution("essm").version
Out[1]:
In [14]:
from IPython.core.display import display, HTML
display(HTML("<style>.container { width:150% !important; }</style>"))
In [4]:
from IPython.display import display
from sympy import init_printing, latex
init_printing()
from sympy.printing import StrPrinter
StrPrinter._print_Quantity = lambda self, expr: str(expr.abbrev) # displays short units (m instead of meter)
In [5]:
import scipy as sc
# Import various functions from sympy
from sympy import Derivative, Eq, exp, log, solve, Symbol
In [6]:
from essm.variables.utils import generate_metadata_table, ListTable
In [7]:
import essm.variables.physics.thermodynamics as physics_vars
vars = ['physics_vars.' + name for name in physics_vars.__all__]
generate_metadata_table([eval(name) for name in vars])
Out[7]:
Each of the above can also be imported one-by-one, using its Name, e.g.:
from essm.variables.physics.thermodynamics import R_mol
In [8]:
import essm.equations.physics.thermodynamics as physics_eqs
modstr = 'physics_eqs.'
eqs = [name for name in physics_eqs.__all__]
table = ListTable()
#table.append(('Name', 'Description', 'Equation'))
for name in eqs:
table.append((name, eval(modstr+name).__doc__, latex('$'+latex(eval(modstr+name))+'$')))
table
Out[8]:
In [9]:
import essm.variables.leaf.energy_water as leaf_energy
vars = ['leaf_energy.' + name for name in leaf_energy.__all__]
generate_metadata_table([eval(name) for name in vars])
Out[9]:
In [10]:
import essm.equations.leaf.energy_water as leaf_energy
modstr = 'leaf_energy.'
eqs = [name for name in leaf_energy.__all__]
table = ListTable()
#table.append(('Name', 'Description', 'Equation'))
for name in eqs:
table.append((name, eval(modstr+name).__doc__, latex('$'+latex(eval(modstr+name))+'$')))
table
Out[10]:
In [11]:
import essm.variables.leaf.radiation as leaf_radiation
vars = ['leaf_radiation.' + name for name in leaf_radiation.__all__]
generate_metadata_table([eval(name) for name in vars])
Out[11]:
In [12]:
import essm.variables.chamber.insulation as chamber_ins
vars = ['chamber_ins.' + name for name in chamber_ins.__all__]
generate_metadata_table([eval(name) for name in vars])
Out[12]:
In [13]:
import essm.variables.chamber.mass as chamber_mass
vars = ['chamber_mass.' + name for name in chamber_mass.__all__]
generate_metadata_table([eval(name) for name in vars])
Out[13]:
See https://essm.readthedocs.io/en/latest/api.html#bibliography
In [ ]: