<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 ECSimpleSnow component
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.
Details
Step1:  load example configuration and inputs
Step2:  initialize by using default example data
Step3:  Implement the simple snow model for the first year as an example
<ASSISTANT_TASK:>
Python Code:
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()
Explanation: ECSimpleSnow component
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.
Details:
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
Source code in Fortran:
URL: https://github.com/permamodel/Snow_BMI_Fortran
For this Notebook
Before you begin, install:
conda install -c conda-forge pymt pymt_ecsimplesnow numpy scipy
load module
End of explanation
#Call setup to get default config and data files.
defaults = ec.setup('.')
print(defaults)
cfg_filename = defaults[0]
%cat $cfg_filename
Explanation: load example configuration and inputs
End of explanation
# 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())
Explanation: initialize by using default example data
End of explanation
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()
Explanation: Implement the simple snow model for the first year as an example
End of explanation
<END_TASK>