<jupyter_start><jupyter_text>Interface between numpy and ORTD systemsThis example demonstrates a 'quick' integration and execution of systems to perform computations on numpy arrays. The function decorator 'ORTDtoNumpy' converts a given function describing a system into a function that can be directly called with in- and output data. Internally, the system is automatically compiled and temporary instances are created to perform computations on the given data.<jupyter_code>z_inf = 0.9

# z_inf (being a parameter to the decorator) is a constant parameter that is compiled into
@ORTDtoNumpy(z_inf=z_inf)
def low_pass( u, z_inf ):
    
    y = dy.dtf_lowpass_1_order(u, z_inf)
    
    return y
# please note: the parameter z_inf is fixed
y1 = low_pass( np.ones(100) )
y2 = low_pass( np.concatenate( (np.ones(50), np.zeros(50)) )  )

plt.figure(figsize=(12,8), dpi=70)
plt.plot(y1)
plt.plot(y2)
plt.show()<jupyter_output>compiling system simulation (level 0)...<jupyter_text>2nd example<jupyter_code>@ORTDtoNumpy()
def low_pass_2( u, z_inf ):
    
    y = dy.dtf_lowpass_1_order(u, z_inf)
    
    return y
# please note: the parameter z_inf is *not* fixed
# in these function calls z_inf will be treated as a constant signal as a single value (instead of a np-array) is given.
y1 = low_pass_2( np.ones(100), 0.9 ) 
y2 = low_pass_2( np.ones(100), 0.8 )
y3 = low_pass_2( np.ones(100), 0.7 )

plt.figure(figsize=(12,8), dpi=70)
plt.plot(y1)
plt.plot(y2)
plt.plot(y3)
plt.legend(['z_inf = 0.9', 'z_inf = 0.8', 'z_inf = 0.7'])
plt.show()<jupyter_output>compiling system simulation (level 0)...
{'fraction_non_alphanumeric': 0.11125078566939033, 'fraction_numerical': 0.03708359522313011, 'mean_word_length': 4.625441696113074, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '476852', 'license': 'MIT', 'n_tokens_mistral': 612, 'n_tokens_neox': 574, 'n_words': 181, 'path': 'examples/numpy_interface.ipynb', 'repo_name': 'OpenRTDynamics/openrtdynamics2', 'size': '1591'}