.. 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_homoeoidal_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_homoeoidal_coordinates.py: ====================================================== Oblate Homoeoidal Coordinates: Effect of Eccentricity ====================================================== Visualize how the radial coordinate lines (R-contours) in the OblateHomoeoidalCoordinateSystem change as a function of eccentricity. .. GENERATED FROM PYTHON SOURCE LINES 9-11 .. code-block:: Python import matplotlib.pyplot as plt .. GENERATED FROM PYTHON SOURCE LINES 12-21 In this example, we'll showcase a more complex coordinate system: :class:`~coordinates.coordinate_systems.OblateHomoeoidalCoordinateSystem`. The oblate homoeoidal coordinate system is a fully curvilinear coordinate system (non-diagonal metric) which inherits the angular coordinates of spherical coordinates but instead relies on a modified effective radius composed of con-centric ellipsoids. 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 21-25 .. code-block:: Python import numpy as np from pymetric import OblateHomoeoidalCoordinateSystem .. GENERATED FROM PYTHON SOURCE LINES 26-29 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 29-35 .. 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 36-40 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 40-64 .. code-block:: Python eccentricities = [0.0, 0.1, 0.3, 0.6, 0.9, 0.99] fig, axes = plt.subplots( int(np.ceil(len(eccentricities) / 3)), 3, sharex=True, sharey=True ) for i, ecc in enumerate(eccentricities): ax = axes.ravel()[i] csys = OblateHomoeoidalCoordinateSystem(ecc=ecc) # 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"$\\varepsilon = {ecc}$") ax.set_aspect("equal") ax.set_xlabel("x") if i == 0: ax.set_ylabel("z") fig.suptitle(r"Oblate Homoeoidal Coordinate Contours ($\lambda$-lines)", fontsize=14) plt.tight_layout() plt.show() .. image-sg:: /auto_examples/a_coordinate_systems/images/sphx_glr_plot_homoeoidal_coordinates_001.png :alt: Oblate Homoeoidal Coordinate Contours ($\lambda$-lines), $\varepsilon = 0.0$, $\varepsilon = 0.1$, $\varepsilon = 0.3$, $\varepsilon = 0.6$, $\varepsilon = 0.9$, $\varepsilon = 0.99$ :srcset: /auto_examples/a_coordinate_systems/images/sphx_glr_plot_homoeoidal_coordinates_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 11.626 seconds) .. _sphx_glr_download_auto_examples_a_coordinate_systems_plot_homoeoidal_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_homoeoidal_coordinates.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_homoeoidal_coordinates.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_homoeoidal_coordinates.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_