Precipitation in the Meteorology component

Goal: In this example, I give the Meteorology component a grid sequence of linearly increasing precipitation values and check whether it produces output when the model state is updated.

Define a helpful constant:


In [ ]:
mps_to_mmph = 1000 * 3600

Import the Babel-wrapped Meteorology component and create an instance:


In [ ]:
from cmt.components import Meteorology
met = Meteorology()

Initialize the model.


In [ ]:
%cd input
met.initialize('meteorology-P-linear.cfg')

The initial model precipitation volume flux is the first value from precip_rates.txt:


In [ ]:
bprecip = met.get_value('atmosphere_water__precipitation_leq-volume_flux')
print type(bprecip)
print bprecip.size
print bprecip.shape
bprecip * mps_to_mmph

Advance the model to the end, saving the model time and output P values (converted back to mm/hr for convenience) at each step:


In [ ]:
time = [met.get_current_time()]
flux = [bprecip.max() * mps_to_mmph]
count = 1
while met.get_current_time() < met.get_end_time():
    met.update(met.get_time_step()*count)
    time.append(met.get_current_time())
    flux.append(met.get_value('atmosphere_water__precipitation_leq-volume_flux').max() * mps_to_mmph)
    count += 1

Check the time and flux values (noting that I've included the time = 0.0 value here):


In [ ]:
time

In [ ]:
flux

Result: Input precipipation rates match output precipitation volume flux. Behaves as expected!