ECSimpleSnow is an empirical algorithm to melt snow according to the surface temperature and increase snow depth according to the precipitation that has fallen since the last time step.
Brown, R. D., Brasnett, B., & Robinson, D. (2003). Gridded North American monthly snow depth and snow water equivalent for GCM evaluation. Atmosphere-Ocean, 41(1), 1-14.
URL: https://www.tandfonline.com/doi/abs/10.3137/ao.410101
URL: https://github.com/permamodel/Snow_BMI_Fortran
Before you begin, install:
conda install -c conda-forge pymt pymt_ecsimplesnow numpy scipy
In [1]:
import numpy as np
import matplotlib.pyplot as plt
from scipy.optimize import curve_fit
# Load PyMT model(s)
import pymt.models
ec = pymt.models.ECSimpleSnow()
In [2]:
#Call setup to get default config and data files.
defaults = ec.setup('.')
print(defaults)
cfg_filename = defaults[0]
%cat $cfg_filename
In [10]:
# Initialize the model with the defaults.
ec.initialize('snow_model.cfg')
ec.set_value('snow_class',2)
ec.set_value('open_area_or_not', 1)
# List input and output variable names.
print(ec.get_output_var_names())
print(ec.get_input_var_names())
In [12]:
plt.figure(figsize=[4,9])
h0 = plt.subplot(3,1,1)
h1 = plt.subplot(3,1,2)
h2 = plt.subplot(3,1,3)
h0.title.set_text('Snow Depth')
h1.title.set_text('Snow Density')
h2.title.set_text('Air Temperature')
print('Air Temperature Unit:', ec.get_var_units('land_surface_air__temperature'))
print('Snow Depth Unit:' , ec.get_var_units('snowpack__depth'))
print('Snow Density Unit:' , ec.get_var_units('snowpack__mass-per-volume_density'))
for i in np.arange(365):
ec.update()
tair = ec.get_value('land_surface_air__temperature')
snd = ec.get_value('snowpack__depth', units='m')
rsn = ec.get_value('snowpack__mass-per-volume_density')
units = ec.get_var_units('snowpack__depth')
h0.scatter(ec.time, snd, c='k')
h1.scatter(ec.time, rsn, c='k')
h2.scatter(ec.time,tair, c='k')
# ec.finalize()
In [ ]: