<jupyter_start><jupyter_text>![image](https://github.com/eWaterCycle/ewatercycle/raw/main/docs/examples/logo.png)  Running MARRMoT M01 model using eWaterCycle packageThis notebooks shows how to run [MARRMoT](https://github.com/wknoben/MARRMoT) M01 model using an example use-case. More information about data, configuration and installation instructions can be found in the [System setup](https://ewatercycle.readthedocs.io/en/latest/system_setup.html) in the eWaterCycle documentation.<jupyter_code>import warnings

warnings.filterwarnings("ignore", category=UserWarning)
import pandas as pd

import ewatercycle.forcing
import ewatercycle.models<jupyter_output><empty_output><jupyter_text>Load forcing data To download the example forcing file `BMI_testcase_m01_BuffaloRiver_TN_USA.mat`, see this [instruction](https://ewatercycle.readthedocs.io/en/latest/system_setup.htmldownload-example-forcing).<jupyter_code>forcing = ewatercycle.forcing.load_foreign(
    "marrmot",
    directory=".",
    start_time="1989-01-01T00:00:00Z",
    end_time="1992-12-31T00:00:00Z",
    forcing_info={"forcing_file": "BMI_testcase_m01_BuffaloRiver_TN_USA.mat"},
)
print(forcing)<jupyter_output>eWaterCycle forcing
-------------------
start_time=1989-01-01T00:00:00Z
end_time=1992-12-31T00:00:00Z
directory=/home/sarah/GitHub/ewatercycle/docs/examples
shape=None
forcing_file=BMI_testcase_m01_BuffaloRiver_TN_USA.mat<jupyter_text>Set up the model To create the model object, we need to select a version.<jupyter_code>ewatercycle.models.MarrmotM01.available_versions
model = ewatercycle.models.MarrmotM01(version="2020.11", forcing=forcing)
print(model)
model.parameters<jupyter_output><empty_output><jupyter_text>Setup model with maximum soil moisture storage of 12.0 instead of 10.0 and an earlier end time, making total model time just 1 month.<jupyter_code>cfg_file, cfg_dir = model.setup(
    maximum_soil_moisture_storage=12.0,
    end_time="1989-02-01T00:00:00Z",
)
print(cfg_file)
print(cfg_dir)
model.parameters<jupyter_output><empty_output><jupyter_text>Initialize the model with the config file:<jupyter_code>model.initialize(cfg_file)<jupyter_output><empty_output><jupyter_text>Get model variable names, only `flux_out_Q` is supported for now.<jupyter_code>model.output_var_names<jupyter_output><empty_output><jupyter_text>Run the model<jupyter_code>discharge = []
time_range = []
end_time = model.end_time

while model.time < end_time:
    model.update()
    discharge.append(model.get_value("flux_out_Q")[0])
    time_range.append(model.time_as_datetime.date())
    print(model.time_as_isostr)
model.finalize()<jupyter_output><empty_output><jupyter_text>Inspect the results<jupyter_code>simulated_discharge = pd.DataFrame(
    {"simulation": discharge}, index=pd.to_datetime(time_range)
)
simulated_discharge.plot(figsize=(12, 8))<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.11480574028701435, 'fraction_numerical': 0.03640182009100455, 'mean_word_length': 7.430678466076696, 'pattern_counts': {'":': 2, '<': 33, '<?xml version=': 0, '>': 32, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '8', 'dir': 'jupyter-structured-clean-dedup', 'id': '57111', 'license': 'Apache-2.0', 'n_tokens_mistral': 1087, 'n_tokens_neox': 995, 'n_words': 161, 'path': 'docs/examples/MarrmotM01.ipynb', 'repo_name': 'cffbots/ewatercycle', 'size': '2857'}