<jupyter_start><jupyter_text>Xarray-simlab: execute individual processesXarray-simlab is a lightweight, non-invasive framework that let users run code (processes) without using the framework.We'll see here how to execute some processes individually without running any simulation, which is useful for exploring or testing the behavior of those processes, and certainly much easier than debugging it when being part of a whole model.<jupyter_code>import matplotlib.pyplot as plt
import numpy as np
import xsimlab as xs

%matplotlib inline<jupyter_output><empty_output><jupyter_text>Let's import a simple process from fastscape<jupyter_code>from fastscape.processes import Escarpment
xs.process_info(Escarpment)<jupyter_output><empty_output><jupyter_text>Like any other process, `Escarpment` is a regular Python class that can be used as usual.For example, we can create an instance of this class. All input variables (i.e., intent='in'), even foreign variables, are exposed as arguments of the constructor (i.e., `__init__` method). Unless a default value is defined for those variables, an input value is required. In the case of `Escarpment`, we need to provide values for the grid variables.<jupyter_code>Escarpment?
scarp = Escarpment(
    x_left=1e2,
    x_right=1e2,
    elevation_left=0.,
    elevation_right=5e2,
    shape=(200, 200),
    x = np.linspace(0., 2e2, 200)
)<jupyter_output><empty_output><jupyter_text>We can then mimic a simulation stage run, just by calling the corresponding method the instance created, e.g.,<jupyter_code>scarp.initialize()<jupyter_output><empty_output><jupyter_text>If the process compute a value during this simulation stage (for an output variable, i.e., intent='in' or intent='inout'), we can access that value simply by getting the corresponding attribute, e.g.,<jupyter_code>scarp.elevation
plt.imshow(scarp.elevation);<jupyter_output><empty_output><jupyter_text>Exercise: explore the orographic precipitation process<jupyter_code>from orographic_precipitation.fastscape_ext import OrographicPrecipitation<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.07544449783757809, 'fraction_numerical': 0.00913022585295531, 'mean_word_length': 6.543478260869565, 'pattern_counts': {'":': 0, '<': 25, '<?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': '15132', 'license': 'BSD-3-Clause', 'n_tokens_mistral': 635, 'n_tokens_neox': 609, 'n_words': 218, 'path': 'notebooks/03_run_processes.ipynb', 'repo_name': 'fastscape-lem/workshop-gfz-2021-01', 'size': '2081'}