.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/2_multiscaling/plot_signal_multiscale.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 .. rst-class:: sphx-glr-example-title .. _sphx_glr_auto_examples_2_multiscaling_plot_signal_multiscale.py: Multiscaling and signal propagation =================================== This example shows how a signal a signal can be propagated across scales on a multiscale representation. The rules for signal propagation are defined by the `FineToCoarsePolicy <../../api/skshapes.html#skshapes.types.FineToCoarsePolicy>`_ and `CoarseToFinePolicy <../../api/skshapes.html#skshapes.types.FineToCoarsePolicy>`_ classes. .. GENERATED FROM PYTHON SOURCE LINES 11-22 .. code-block:: Python import pyvista as pv import pyvista.examples import skshapes as sks bunny = sks.PolyData(pyvista.examples.download_bunny()) multiscale_bunny = sks.Multiscale(shape=bunny, ratios=[0.1, 0.01, 0.005]) .. GENERATED FROM PYTHON SOURCE LINES 23-24 Define a signal on the high resolution mesh .. GENERATED FROM PYTHON SOURCE LINES 24-29 .. code-block:: Python signal = multiscale_bunny.at(ratio=1).points[:, 1] multiscale_bunny.at(ratio=1).point_data["height"] = signal .. GENERATED FROM PYTHON SOURCE LINES 30-31 Propagate the signal from fine to coarse resolutions .. GENERATED FROM PYTHON SOURCE LINES 31-44 .. code-block:: Python # define a fine_to_coarse propagation scheme fine_to_coarse_policy = sks.FineToCoarsePolicy( reduce="mean", ) # propagate the signal from the high resolution to the lower resolutions multiscale_bunny.propagate( signal_name="height", from_ratio=1, fine_to_coarse_policy=fine_to_coarse_policy, ) .. GENERATED FROM PYTHON SOURCE LINES 45-46 Propagate a signal from the lower resolutions to the higher resolution .. GENERATED FROM PYTHON SOURCE LINES 46-75 .. code-block:: Python signal_low = multiscale_bunny.at(ratio=0.005).points[:, 1] multiscale_bunny.at(ratio=0.005).point_data["height_low_constant"] = signal_low multiscale_bunny.at(ratio=0.005).point_data["height_low_smoothing"] = signal_low # define a coarse_to_fine propagation scheme coarse_to_fine_policy = sks.CoarseToFinePolicy( smoothing="constant", ) # propagate the signal from the lower resolutions to the higher resolution multiscale_bunny.propagate( signal_name="height_low_constant", from_ratio=0.005, coarse_to_fine_policy=coarse_to_fine_policy, ) # define a coarse_to_fine propagation scheme coarse_to_fine_policy = sks.CoarseToFinePolicy(smoothing="mesh_convolution") # propagate the signal from the lower resolutions to the higher resolution multiscale_bunny.propagate( signal_name="height_low_smoothing", from_ratio=0.005, coarse_to_fine_policy=coarse_to_fine_policy, ) .. GENERATED FROM PYTHON SOURCE LINES 76-77 Visualize the multiscale representation .. GENERATED FROM PYTHON SOURCE LINES 77-142 .. code-block:: Python plotter = pv.Plotter(shape=(3, 4)) row = 0 plotter.subplot(row, 0) plotter.add_mesh(multiscale_bunny.at(ratio=1).to_pyvista(), scalars="height") plotter.view_xy() plotter.subplot(row, 1) plotter.add_mesh(multiscale_bunny.at(ratio=0.1).to_pyvista(), scalars="height") plotter.view_xy() plotter.subplot(row, 2) plotter.add_mesh( multiscale_bunny.at(ratio=0.01).to_pyvista(), scalars="height" ) plotter.view_xy() plotter.subplot(row, 3) plotter.add_mesh( multiscale_bunny.at(ratio=0.005).to_pyvista(), scalars="height" ) plotter.view_xy() row = 1 plotter.subplot(row, 0) plotter.add_mesh( multiscale_bunny.at(ratio=1).to_pyvista(), scalars="height_low_constant" ) plotter.view_xy() plotter.subplot(row, 1) plotter.add_mesh( multiscale_bunny.at(ratio=0.1).to_pyvista(), scalars="height_low_constant" ) plotter.view_xy() plotter.subplot(row, 2) plotter.add_mesh( multiscale_bunny.at(ratio=0.01).to_pyvista(), scalars="height_low_constant" ) plotter.view_xy() plotter.subplot(row, 3) plotter.add_mesh( multiscale_bunny.at(ratio=0.005).to_pyvista(), scalars="height_low_constant", ) plotter.view_xy() row = 2 plotter.subplot(row, 0) plotter.add_mesh( multiscale_bunny.at(ratio=1).to_pyvista(), scalars="height_low_smoothing" ) plotter.view_xy() plotter.subplot(row, 1) plotter.add_mesh( multiscale_bunny.at(ratio=0.1).to_pyvista(), scalars="height_low_smoothing" ) plotter.view_xy() plotter.subplot(row, 2) plotter.add_mesh( multiscale_bunny.at(ratio=0.01).to_pyvista(), scalars="height_low_smoothing", ) plotter.view_xy() plotter.subplot(row, 3) plotter.add_mesh( multiscale_bunny.at(ratio=0.005).to_pyvista(), scalars="height_low_smoothing", ) plotter.view_xy() plotter.show() .. tab-set:: .. tab-item:: Static Scene .. image-sg:: /auto_examples/2_multiscaling/images/sphx_glr_plot_signal_multiscale_001.png :alt: plot signal multiscale :srcset: /auto_examples/2_multiscaling/images/sphx_glr_plot_signal_multiscale_001.png :class: sphx-glr-single-img .. tab-item:: Interactive Scene .. offlineviewer:: /home/runner/work/scikit-shapes/scikit-shapes/doc/source/auto_examples/2_multiscaling/images/sphx_glr_plot_signal_multiscale_001.vtksz .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 1.546 seconds) .. _sphx_glr_download_auto_examples_2_multiscaling_plot_signal_multiscale.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_signal_multiscale.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_signal_multiscale.py ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_