.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "api/gallery/communications/propagation/plot_01_hertz_wavelength.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. .. rst-class:: sphx-glr-example-title .. _sphx_glr_api_gallery_communications_propagation_plot_01_hertz_wavelength.py: Hertz's electromagnetic waves and their wavelength ================================================== Maxwell's equations (1865) predicted electromagnetic waves travelling at the speed of light. Heinrich Hertz confirmed them in 1887-1888: a spark gap drove waves at a few hundred megahertz, a metal sheet reflected them into a standing wave, and the spacing of the nodes, half a wavelength, multiplied by the frequency gave the speed. :func:`~engineeringkit.communications.wavelength` computes :math:`\lambda = c/f`; the example reconstructs Hertz's standing-wave measurement and maps the radio spectrum. .. GENERATED FROM PYTHON SOURCE LINES 15-20 .. code-block:: Python import matplotlib.pyplot as plt import numpy as np from engineeringkit.communications import SPEED_OF_LIGHT, wavelength .. GENERATED FROM PYTHON SOURCE LINES 21-26 A standing wave in front of a reflector --------------------------------------- Incident and reflected waves add to :math:`2\sin(kx)\cos(\omega t)`; nodes are half a wavelength apart. .. GENERATED FROM PYTHON SOURCE LINES 26-37 .. code-block:: Python f = 450e6 lam = float(wavelength(f)) x = np.linspace(0, 3, 3001) envelope = np.abs(2 * np.sin(2 * np.pi * x / lam)) interior = (envelope[1:-1] < envelope[:-2]) & (envelope[1:-1] < envelope[2:]) nodes = x[1:-1][interior] spacing = np.mean(np.diff(nodes)) print(f"f = {f / 1e6:.0f} MHz: node spacing {spacing:.4f} m -> speed {2 * spacing * f:.4e} m/s (c = {SPEED_OF_LIGHT:.4e})") assert np.isclose(2 * spacing * f, SPEED_OF_LIGHT, rtol=2e-3) .. rst-class:: sphx-glr-script-out .. code-block:: none f = 450 MHz: node spacing 0.3331 m -> speed 2.9981e+08 m/s (c = 2.9979e+08) .. GENERATED FROM PYTHON SOURCE LINES 38-40 Wavelengths across the radio spectrum ------------------------------------- .. GENERATED FROM PYTHON SOURCE LINES 40-52 .. code-block:: Python bands = {"LF 100 kHz": 1e5, "AM 1 MHz": 1e6, "FM 100 MHz": 1e8, "Hertz 450 MHz": 4.5e8, "Wi-Fi 2.4 GHz": 2.4e9, "Ku 12 GHz": 1.2e10} fig, axes = plt.subplots(1, 2, figsize=(10, 3.5)) axes[0].plot(x, envelope) axes[0].plot(nodes, np.zeros_like(nodes), "kv") axes[0].set(xlabel="distance from reflector [m]", ylabel="field amplitude", title=f"Standing wave, λ = {lam:.3f} m") axes[1].barh(list(bands), wavelength(np.array(list(bands.values())))) axes[1].set_xscale("log") axes[1].set(xlabel="wavelength [m]") fig.tight_layout() plt.show() .. image-sg:: /api/gallery/communications/propagation/images/sphx_glr_plot_01_hertz_wavelength_001.png :alt: Standing wave, λ = 0.666 m :srcset: /api/gallery/communications/propagation/images/sphx_glr_plot_01_hertz_wavelength_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.272 seconds) .. _sphx_glr_download_api_gallery_communications_propagation_plot_01_hertz_wavelength.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: lite-badge .. image:: images/jupyterlite_badge_logo.svg :target: ../../../../lite/lab/index.html?path=api/gallery/communications/propagation/plot_01_hertz_wavelength.ipynb :alt: Launch JupyterLite :width: 150 px .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_01_hertz_wavelength.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_01_hertz_wavelength.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_01_hertz_wavelength.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_