
.. DO NOT EDIT.
.. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY.
.. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE:
.. "gallery/bushveld-gravity.py"
.. LINE NUMBERS ARE GIVEN BELOW.

.. only:: html

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

        :ref:`Go to the end <sphx_glr_download_gallery_bushveld-gravity.py>`
        to download the full example code

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

.. _sphx_glr_gallery_bushveld-gravity.py:


Gravity ground-based data over the Bushveld Complex, Southern Africa
--------------------------------------------------------------------

This dataset contains ground gravity observations over the area that comprises
the Bushveld Igenous Complex in Southern Africa, including preprocessed gravity
fields such as the **gravity disturbance** and the **Bouguer gravity
disturbance** (topography-free gravity disturbance). In addition, the dataset
contains the heights of the observation points referenced on the WGS84
reference ellipsoid and over the mean sea-level (what can be considered to be
the geoid). This dataset was built upon a portion of the Southern Africa
gravity compilation available through NOAA NCEI.

**Original source:**

* Gravity: `NOAA NCEI <https://www.ngdc.noaa.gov/mgg/gravity/>`__
* Topography: `ETOPO1 <https://doi.org/10.7289/V5C8276M>`__

**Pre-processing:** `Source code for preparation of the original dataset for
redistribution in Ensaio <https://github.com/fatiando-data/bushveld-gravity>`__

.. GENERATED FROM PYTHON SOURCE LINES 29-36

.. code-block:: Python


    import numpy as np
    import pandas as pd
    import pygmt

    import ensaio








.. GENERATED FROM PYTHON SOURCE LINES 37-38

Download and cache the data and return the path to it on disk

.. GENERATED FROM PYTHON SOURCE LINES 38-41

.. code-block:: Python

    fname = ensaio.fetch_bushveld_gravity(version=1)
    print(fname)





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

 .. code-block:: none

    /home/runner/work/_temp/cache/ensaio/v1/bushveld-gravity.csv.xz




.. GENERATED FROM PYTHON SOURCE LINES 42-43

Load the CSV formatted data with pandas

.. GENERATED FROM PYTHON SOURCE LINES 43-46

.. code-block:: Python

    data = pd.read_csv(fname)
    data






.. raw:: html

    <div class="output_subarea output_html rendered_html output_result">
    <div>
    <style scoped>
        .dataframe tbody tr th:only-of-type {
            vertical-align: middle;
        }

        .dataframe tbody tr th {
            vertical-align: top;
        }

        .dataframe thead th {
            text-align: right;
        }
    </style>
    <table border="1" class="dataframe">
      <thead>
        <tr style="text-align: right;">
          <th></th>
          <th>longitude</th>
          <th>latitude</th>
          <th>height_sea_level_m</th>
          <th>height_geometric_m</th>
          <th>gravity_mgal</th>
          <th>gravity_disturbance_mgal</th>
          <th>gravity_bouguer_mgal</th>
        </tr>
      </thead>
      <tbody>
        <tr>
          <th>0</th>
          <td>25.01500</td>
          <td>-26.26334</td>
          <td>1230.2</td>
          <td>1257.474535</td>
          <td>978681.38</td>
          <td>25.081592</td>
          <td>-113.259165</td>
        </tr>
        <tr>
          <th>1</th>
          <td>25.01932</td>
          <td>-26.38713</td>
          <td>1297.0</td>
          <td>1324.574150</td>
          <td>978669.02</td>
          <td>24.538158</td>
          <td>-122.662101</td>
        </tr>
        <tr>
          <th>2</th>
          <td>25.02499</td>
          <td>-26.39667</td>
          <td>1304.8</td>
          <td>1332.401322</td>
          <td>978669.28</td>
          <td>26.526960</td>
          <td>-121.339321</td>
        </tr>
        <tr>
          <th>3</th>
          <td>25.04500</td>
          <td>-26.07668</td>
          <td>1165.2</td>
          <td>1192.107148</td>
          <td>978681.08</td>
          <td>17.954814</td>
          <td>-113.817543</td>
        </tr>
        <tr>
          <th>4</th>
          <td>25.07668</td>
          <td>-26.35001</td>
          <td>1262.5</td>
          <td>1289.971792</td>
          <td>978665.19</td>
          <td>12.700307</td>
          <td>-130.460126</td>
        </tr>
        <tr>
          <th>...</th>
          <td>...</td>
          <td>...</td>
          <td>...</td>
          <td>...</td>
          <td>...</td>
          <td>...</td>
          <td>...</td>
        </tr>
        <tr>
          <th>3872</th>
          <td>31.51500</td>
          <td>-23.86333</td>
          <td>300.5</td>
          <td>312.710241</td>
          <td>978776.85</td>
          <td>-4.783965</td>
          <td>-39.543608</td>
        </tr>
        <tr>
          <th>3873</th>
          <td>31.52499</td>
          <td>-23.30000</td>
          <td>280.7</td>
          <td>292.686630</td>
          <td>978798.55</td>
          <td>48.012766</td>
          <td>16.602026</td>
        </tr>
        <tr>
          <th>3874</th>
          <td>31.54832</td>
          <td>-23.19333</td>
          <td>245.7</td>
          <td>257.592670</td>
          <td>978803.55</td>
          <td>49.161771</td>
          <td>22.456674</td>
        </tr>
        <tr>
          <th>3875</th>
          <td>31.57333</td>
          <td>-23.84833</td>
          <td>226.8</td>
          <td>239.199065</td>
          <td>978808.44</td>
          <td>5.116904</td>
          <td>-20.419870</td>
        </tr>
        <tr>
          <th>3876</th>
          <td>31.37500</td>
          <td>-23.00000</td>
          <td>285.6</td>
          <td>297.165672</td>
          <td>978734.77</td>
          <td>5.186926</td>
          <td>-25.922627</td>
        </tr>
      </tbody>
    </table>
    <p>3877 rows × 7 columns</p>
    </div>
    </div>
    <br />
    <br />

.. GENERATED FROM PYTHON SOURCE LINES 47-48

Make a PyGMT map with the data points colored by the gravity data.

.. GENERATED FROM PYTHON SOURCE LINES 48-74

.. code-block:: Python

    fig = pygmt.Figure()
    fig.basemap(
        region=[
            data.longitude.min(),
            data.longitude.max(),
            data.latitude.min(),
            data.latitude.max(),
        ],
        projection="M15c",
        frame=True,
    )
    fig.coast(land="#444444")
    scale = np.max(np.abs(data.gravity_disturbance_mgal))
    pygmt.makecpt(
        cmap="polar",
        series=[-scale, scale],
    )
    fig.plot(
        x=data.longitude,
        y=data.latitude,
        fill=data.gravity_disturbance_mgal,
        cmap=True,
        style="c0.1c",
    )
    fig.colorbar(frame='af+l"gravity disturbance [mGal]"')
    fig.show()



.. image-sg:: /gallery/images/sphx_glr_bushveld-gravity_001.png
   :alt: bushveld gravity
   :srcset: /gallery/images/sphx_glr_bushveld-gravity_001.png
   :class: sphx-glr-single-img






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

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


.. _sphx_glr_download_gallery_bushveld-gravity.py:

.. only:: html

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

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

      :download:`Download Jupyter notebook: bushveld-gravity.ipynb <bushveld-gravity.ipynb>`

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

      :download:`Download Python source code: bushveld-gravity.py <bushveld-gravity.py>`


.. only:: html

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

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