
.. DO NOT EDIT.
.. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY.
.. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE:
.. "auto_examples/04-topography/4.2-plot_crater_profile.py"
.. LINE NUMBERS ARE GIVEN BELOW.

.. only:: html

    .. note::
        :class: sphx-glr-download-link-note

        :ref:`Go to the end <sphx_glr_download_auto_examples_04-topography_4.2-plot_crater_profile.py>`
        to download the full example code.

.. rst-class:: sphx-glr-example-title

.. _sphx_glr_auto_examples_04-topography_4.2-plot_crater_profile.py:


Create a crater and ejecta profile with the "basicmoon" morphology model
=========================================================================

.. rubric:: By David Minton

This example showcases how to create a crater and ejecta profile using the "basicmoon" morphology model from the CraterMaker package. The crater is created with a radius of 1 km, and the profiles are plotted in a 2D space normalized to the crater radius.

.. GENERATED FROM PYTHON SOURCE LINES 10-39



.. image-sg:: /auto_examples/04-topography/images/sphx_glr_4.2-plot_crater_profile_001.png
   :alt: 4.2 plot crater profile
   :srcset: /auto_examples/04-topography/images/sphx_glr_4.2-plot_crater_profile_001.png
   :class: sphx-glr-single-img


.. rst-class:: sphx-glr-script-out

 .. code-block:: none

    Creating a new grid
    Generating a mesh with icosphere level 4.






|

.. code-block:: Python


    import matplotlib.pyplot as plt
    import numpy as np

    from cratermaker import Crater, Morphology

    crater = Crater.maker(radius=1.0e3)
    # Because we are not explicitly passing a Surface object, the Morphology constructor will generate a default surface. We pass the "simdir" and "gridlevel" arguments to control the Surface generation, even though we don't make use of it directly here.
    morphology = Morphology.maker("basicmoon", simdir="simdata-4_2", gridlevel=4, ask_overwrite=False, reset=True)

    rc = crater.radius
    rvals = np.linspace(0, 3.0 * rc, 1000)
    hvals = morphology.crater_profile(crater, rvals)
    ejvals = morphology.ejecta_profile(crater, rvals)

    # Filter out the interior of the crater and add the ejecta to the crater profile to draw the combined profile
    rej = rvals[ejvals > 0]
    ejvals = hvals[ejvals > 0] + ejvals[ejvals > 0]

    fig, ax = plt.subplots(figsize=(8, 2))

    ax.set_xlabel("Distance ($r/r_c$)")
    ax.set_ylabel("Height ($h/r_c$)")

    ax.set_aspect("equal")
    ax.plot(rvals / rc, hvals / rc)
    ax.plot(rej / rc, ejvals / rc)

    plt.show()


.. rst-class:: sphx-glr-timing

   **Total running time of the script:** (0 minutes 1.684 seconds)


.. _sphx_glr_download_auto_examples_04-topography_4.2-plot_crater_profile.py:

.. only:: html

  .. container:: sphx-glr-footer sphx-glr-footer-example

    .. container:: sphx-glr-download sphx-glr-download-jupyter

      :download:`Download Jupyter notebook: 4.2-plot_crater_profile.ipynb <4.2-plot_crater_profile.ipynb>`

    .. container:: sphx-glr-download sphx-glr-download-python

      :download:`Download Python source code: 4.2-plot_crater_profile.py <4.2-plot_crater_profile.py>`

    .. container:: sphx-glr-download sphx-glr-download-zip

      :download:`Download zipped: 4.2-plot_crater_profile.zip <4.2-plot_crater_profile.zip>`


.. only:: html

 .. rst-class:: sphx-glr-signature

    `Gallery generated by Sphinx-Gallery <https://sphinx-gallery.github.io>`_
