.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/01_quick-start/01_03_extension_modes.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code. or to run this example in your browser via JupyterLite or Binder .. rst-class:: sphx-glr-example-title .. _sphx_glr_auto_examples_01_quick-start_01_03_extension_modes.py: Extension modes =============== Plotting different extension modes of signals. .. GENERATED FROM PYTHON SOURCE LINES 13-18 Imports and Utilities --------------------- Visualize how the extension modes allow one to control the values that a signal is assumed to take outside of its original domain. Generate a signal that is mostly linear but includes a "bump." .. GENERATED FROM PYTHON SOURCE LINES 18-53 .. code-block:: Python import numpy as np import matplotlib.pyplot as plt from splineops.interpolate.tensorspline import TensorSpline x_values = np.linspace(0, 6, 101) def create_signal_with_bump(x_values, bump_location=3, bump_width=0.5, bump_height=5): linear_part = x_values bump = np.where( (x_values > (bump_location - bump_width / 2)) & (x_values < (bump_location + bump_width / 2)), bump_height, 0, ) return linear_part + bump def plot_extension_modes_for_bump_function(mode_name, x_values, title): plt.figure(figsize=(12, 6)) data = create_signal_with_bump(x_values) tensor_spline = TensorSpline( data=data, coordinates=(x_values,), bases="linear", modes=mode_name ) eval_x_values = np.linspace(-10, 10, 2000) extended_data = tensor_spline.eval(coordinates=(eval_x_values,)) plt.plot(eval_x_values, extended_data, label="Extended Signal") plt.axvline(x=x_values[0], color="red", linestyle="--", label="Original Start") plt.axvline(x=x_values[-1], color="blue", linestyle="--", label="Original End") plt.title(title) plt.xlabel("x") plt.ylabel("Interpolated Value") plt.grid(True) plt.legend() plt.show() .. GENERATED FROM PYTHON SOURCE LINES 54-56 Finite-Support Coefficients --------------------------- .. GENERATED FROM PYTHON SOURCE LINES 56-63 .. code-block:: Python plot_extension_modes_for_bump_function( mode_name="zero", x_values=x_values, title="Extension Mode: Finite Support Coefficients", ) .. image-sg:: /auto_examples/01_quick-start/images/sphx_glr_01_03_extension_modes_001.png :alt: Extension Mode: Finite Support Coefficients :srcset: /auto_examples/01_quick-start/images/sphx_glr_01_03_extension_modes_001.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 64-66 Narrow Mirroring ---------------- .. GENERATED FROM PYTHON SOURCE LINES 66-73 .. code-block:: Python plot_extension_modes_for_bump_function( mode_name="mirror", x_values=x_values, title="Extension Mode: Narrow Mirroring", ) .. image-sg:: /auto_examples/01_quick-start/images/sphx_glr_01_03_extension_modes_002.png :alt: Extension Mode: Narrow Mirroring :srcset: /auto_examples/01_quick-start/images/sphx_glr_01_03_extension_modes_002.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 74-76 Periodic Padding ---------------- .. GENERATED FROM PYTHON SOURCE LINES 76-81 .. code-block:: Python plot_extension_modes_for_bump_function( mode_name="periodic", x_values=x_values, title="Extension Mode: Periodic Padding", ) .. image-sg:: /auto_examples/01_quick-start/images/sphx_glr_01_03_extension_modes_003.png :alt: Extension Mode: Periodic Padding :srcset: /auto_examples/01_quick-start/images/sphx_glr_01_03_extension_modes_003.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.261 seconds) .. _sphx_glr_download_auto_examples_01_quick-start_01_03_extension_modes.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: binder-badge .. image:: images/binder_badge_logo.svg :target: https://mybinder.org/v2/gh/splineops/splineops.github.io/main?urlpath=lab/tree/notebooks_binder/auto_examples/01_quick-start/01_03_extension_modes.ipynb :alt: Launch binder :width: 150 px .. container:: lite-badge .. image:: images/jupyterlite_badge_logo.svg :target: ../../lite/lab/index.html?path=auto_examples/01_quick-start/01_03_extension_modes.ipynb :alt: Launch JupyterLite :width: 150 px .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: 01_03_extension_modes.ipynb <01_03_extension_modes.ipynb>` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: 01_03_extension_modes.py <01_03_extension_modes.py>` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: 01_03_extension_modes.zip <01_03_extension_modes.zip>` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_