<jupyter_start><jupyter_text>Meteorology-SnowDegreeDay coupling **Goal:** Try to successfully run a coupled `Meteorology-SnowDegreeDay` simulation, with `Meteorology` as the driver. Each component runs to completion in stand-alone mode. Import the Babel-wrapped `Meteorology` and `SnowDegreeDay` components and create instances:<jupyter_code>from cmt.components import Meteorology, SnowDegreeDay
met, sno = Meteorology(), SnowDegreeDay()<jupyter_output><empty_output><jupyter_text>Initialize the components with cfg files that, for simplicity, use the same time step and run duration:<jupyter_code>%cd input
met.initialize('meteorology-2.cfg')
sno.initialize('snow_degree_day-1.cfg')<jupyter_output><empty_output><jupyter_text>Store initial values of time, snow depth, and air temperature:<jupyter_code>time = [met.get_current_time()]
snow_depth = [sno.get_value('snowpack__depth').max()]
air_temp = [met.get_value('atmosphere_bottom_air__temperature').max()]<jupyter_output><empty_output><jupyter_text>Run the coupled models to completion. In each time step, perform the following actions:1. Get variables from `Meteorology`; set into `SnowDegreeDay`1. Advance `SnowDegreeDay`1. Get variables from `SnowDegreeDay`; set into `Meteorology`1. Advance `Meteorology`<jupyter_code>count = 1
while met.get_current_time() < met.get_end_time():  
    T_air = met.get_value('atmosphere_bottom_air__temperature')
    P_snow = met.get_value('atmosphere_water__snowfall_leq-volume_flux')
    T_surf = met.get_value('land_surface__temperature')
    rho_H2O = met.get_value('water-liquid__mass-per-volume_density')
    sno.set_value('atmosphere_bottom_air__temperature', T_air)
    sno.set_value('atmosphere_water__snowfall_leq-volume_flux', P_snow)
    sno.set_value('land_surface__temperature', T_surf)
    sno.set_value('water-liquid__mass-per-volume_density', rho_H2O)
    
    sno.update(sno.get_time_step()*count)

    rho_snow = sno.get_value('snowpack__z_mean_of_mass-per-volume_density')
    h_snow = sno.get_value('snowpack__depth')
    h_swe = sno.get_value('snowpack__liquid-equivalent_depth')
    SM = sno.get_value('snowpack__melt_volume_flux')
    met.set_value('snowpack__z_mean_of_mass-per-volume_density', rho_snow)
    met.set_value('snowpack__depth', h_snow)
    met.set_value('snowpack__liquid-equivalent_depth', h_swe)
    met.set_value('snowpack__melt_volume_flux', SM)

    met.update(met.get_time_step()*count)
    
    time.append(met.get_current_time())
    snow_depth.append(sno.get_value('snowpack__depth').max())
    air_temp.append(met.get_value('atmosphere_bottom_air__temperature').max())
    
    count += 1
print time
print snow_depth
print air_temp<jupyter_output><empty_output><jupyter_text>Finalize the components:<jupyter_code>met.finalize(), sno.finalize()<jupyter_output><empty_output><jupyter_text>Plot snow depth versus time.<jupyter_code>%matplotlib inline
from matplotlib import pyplot as plt
plt.plot(time[1:], snow_depth[1:])
plt.title('Snow depth versus time')
plt.xlabel('Time [s]')
plt.ylabel('Snow depth [m]')<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.11443433029908973, 'fraction_numerical': 0.0039011703511053317, 'mean_word_length': 7.183510638297872, 'pattern_counts': {'":': 0, '<': 26, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '6', 'dir': 'jupyter-structured-clean-dedup', 'id': '50605', 'license': 'MIT', 'n_tokens_mistral': 1150, 'n_tokens_neox': 1095, 'n_words': 180, 'path': 'Meteorology-SnowDegreeDay.ipynb', 'repo_name': 'mdpiper/topoflow-notebooks', 'size': '3076'}