Skip to content
Brewster Malevich edited this page May 7, 2014 · 6 revisions

Welcome to the embm wiki!

If you're just getting started, be sure to check README.md.

An quick demo

How do we run this thing? Lets fire up a Python3 script and give it a whirl.

We begin by creating a embm.Model instance and let it spin up by letting the model run for about 208 days ("model time" not 208 days IRL, each time step represents about 1/2 hour in the model, by default):

import numpy as np
import embm

m = embm.Model()
m.step(10000)

This takes within a minute to run on my old laptop.

That's fantastic, but lets get some data and see what's actually being simulated when the model spins up. First, we need to reset the model to its starting conditions:

m.reset()
t_hist, q_hist, p_hist = m.step(10000, trace = True)

Ha! With the trace argument set to True, we're asking the model to give us the global mean of its air temperature, specific humidity and precipitation for each of its 10000 time steps. If you have matplotlib and Basemap installed, we can get some basic plots. If you just have matplotlib and not Basemap, that's okay, you can do much of the same plotting with pylab.pcolor(), pylab.pcolormesh(), etc. You'll just be missing the nice map projections.

Anyways, lets import our modules and plot the data.

import pylab as plt
from mpl_toolkits.basemap import Basemap
import matplotlib.pyplot as plt

plt.figure()
plt.subplot(2, 1, 1)
plt.plot(p_hist)
plt.grid()
plt.ylabel("Global mean precipitation (m/yr)")
plt.xlabel("Model step")

plt.subplot(2, 1, 2)
plt.plot(t_hist)
plt.grid()
plt.ylabel("Global mean temperature (K)")
plt.xlabel("Model step")
plt.tight_layout()
plt.show()

This will give you a graphic with two subplots that look something like this. p_hist and t_hist plotted as time series

Clone this wiki locally