.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/a_coordinate_systems/plot_ellipsoidal_coordinates.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_a_coordinate_systems_plot_ellipsoidal_coordinates.py: ====================================================== Oblate Spheroidal Coordinates: Effect of Eccentricity ====================================================== Visualize how the radial coordinate lines (R-contours) in the OblateSpheroidalCoordinateSystem change as a function of eccentricity. .. GENERATED FROM PYTHON SOURCE LINES 10-12 .. code-block:: Python import matplotlib.pyplot as plt .. GENERATED FROM PYTHON SOURCE LINES 13-28 In this example, we'll showcase a more complex coordinate system: :class:`~coordinates.coordinate_systems.OblateSpheroidalCoordinateSystem`. The oblate spheroidal coordinate system is an orthogonal coordinate system with coordinate variables :math:`(\mu,\nu,\theta)` for which the :math:`\mu` coordinate contours form confocal ellipses. .. hint:: The big difference between :class:`~coordinates.coordinate_systems.OblateHomoeoidalCoordinateSystem` and :class:`~coordinates.coordinate_systems.OblateSpheroidalCoordinateSystem` is that spheroidal coordinates are **confocal** while homoeoidal coordinates are **concentric**. In this example, we'll show off how to make these coordinate systems and then display some of its properties. .. GENERATED FROM PYTHON SOURCE LINES 28-32 .. code-block:: Python import numpy as np from pymetric import OblateSpheroidalCoordinateSystem .. GENERATED FROM PYTHON SOURCE LINES 33-36 To visualize, we'll use an *x-z* grid and then convert it into the relevant coordinate systems with different eccentricities. We can then plot contours for the effective radius :math:`\xi`. .. GENERATED FROM PYTHON SOURCE LINES 36-42 .. code-block:: Python # Create the cartesian grid. x = np.linspace(-1.5, 1.5, 200) z = np.linspace(-1.5, 1.5, 200) X, Z = np.meshgrid(x, z) .. GENERATED FROM PYTHON SOURCE LINES 43-47 The class requires an eccentricity parameter when initialized, so we'll iterate through each of them, create a coordinate system class, and then perform the conversions. .. GENERATED FROM PYTHON SOURCE LINES 47-69 .. code-block:: Python _as = [0.1, 0.2, 0.3, 0.5, 1, 2] fig, axes = plt.subplots(int(np.ceil(len(_as) / 3)), 3, sharex=True, sharey=True) for i, a in enumerate(_as): ax = axes.ravel()[i] csys = OblateSpheroidalCoordinateSystem(a=a) # Convert Cartesian (x, z) to native coordinates (λ, μ, φ) Lambda, Mu, Phi = csys.from_cartesian(X, 0, Z) # Plot λ contours (these correspond to elliptical shells) contour = ax.contour(X, Z, Lambda, levels=15, cmap="viridis") ax.set_title(f"$a= {a}$") ax.set_aspect("equal") ax.set_xlabel("x") if i == 0: ax.set_ylabel("z") fig.suptitle(r"Oblate Spheroidal Coordinate Contours ($\lambda$-lines)", fontsize=14) plt.tight_layout() plt.show() .. image-sg:: /auto_examples/a_coordinate_systems/images/sphx_glr_plot_ellipsoidal_coordinates_001.png :alt: Oblate Spheroidal Coordinate Contours ($\lambda$-lines), $a= 0.1$, $a= 0.2$, $a= 0.3$, $a= 0.5$, $a= 1$, $a= 2$ :srcset: /auto_examples/a_coordinate_systems/images/sphx_glr_plot_ellipsoidal_coordinates_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 4.515 seconds) .. _sphx_glr_download_auto_examples_a_coordinate_systems_plot_ellipsoidal_coordinates.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_ellipsoidal_coordinates.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_ellipsoidal_coordinates.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_ellipsoidal_coordinates.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_