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

.. only:: html

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

        Click :ref:`here <sphx_glr_download_sample_data_checkerboard.py>`
        to download the full example code

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

.. _sphx_glr_sample_data_checkerboard.py:


Checkerboard function
=====================

The :class:`verde.synthetic.CheckerBoard` class generates synthetic data in a
checkerboard pattern. It has the same data generation methods that most
gridders have: predict, grid, scatter, and profile.

.. GENERATED FROM PYTHON SOURCE LINES 15-47



.. image-sg:: /sample_data/images/sphx_glr_checkerboard_001.png
   :alt: checkerboard
   :srcset: /sample_data/images/sphx_glr_checkerboard_001.png
   :class: sphx-glr-single-img


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

 Out:

 .. code-block:: none

    wavelengths (east, north): 2500.0 2500.0
    Checkerboard value at (easting=2000, northing=-2500): -951.0565162951536
    /usr/share/miniconda3/envs/test/lib/python3.9/site-packages/verde/base/base_classes.py:463: FutureWarning: The 'spacing', 'shape' and 'region' arguments will be removed in Verde v2.0.0. Please use the 'verde.grid_coordinates' function to define grid coordinates and pass them as the 'coordinates' argument.
      warnings.warn(

    Data grid:
     <xarray.Dataset>
    Dimensions:   (northing: 150, easting: 100)
    Coordinates:
      * easting   (easting) float64 0.0 50.51 101.0 ... 4.899e+03 4.949e+03 5e+03
      * northing  (northing) float64 -5e+03 -4.966e+03 -4.933e+03 ... -33.56 0.0
    Data variables:
        scalars   (northing, easting) float64 0.0 126.6 251.1 ... -126.6 -4.899e-13
    Attributes:
        metadata:  Generated by CheckerBoard()

    Table of scattered data:
           northing      easting     scalars
    0 -1610.917316  2744.067520 -354.631332
    1 -3649.960134  3575.946832 -410.305405
    2 -1324.029889  3013.816880 -944.622429
    3  -189.057274  2724.415915  475.366775
    4 -3756.234282  2118.273997  818.736516






|

.. code-block:: default

    import matplotlib.pyplot as plt

    import verde as vd

    # Instantiate the data generator class and fit it to set the data region.
    synth = vd.synthetic.CheckerBoard()

    # Default values are provided for the wavelengths of the function determined
    # from the region.
    print("wavelengths (east, north):", synth.w_east_, synth.w_north_)

    # The CheckerBoard class behaves like any gridder class
    print(
        "Checkerboard value at (easting=2000, northing=-2500):",
        synth.predict((2000, -2500)),
    )

    # Generating a grid results in a xarray.Dataset
    grid = synth.grid(shape=(150, 100))
    print("\nData grid:\n", grid)

    # while a random scatter generates a pandas.DataFrame
    table = synth.scatter(size=100)
    print("\nTable of scattered data:\n", table.head())

    fig = plt.figure(figsize=(5.5, 4))
    ax = plt.subplot(111)
    ax.set_title("CheckerBoard")
    ax.set_aspect("equal")
    grid.scalars.plot.pcolormesh(ax=ax)
    plt.tight_layout(pad=0)
    plt.show()


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

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


.. _sphx_glr_download_sample_data_checkerboard.py:


.. only :: html

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



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

     :download:`Download Python source code: checkerboard.py <checkerboard.py>`



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

     :download:`Download Jupyter notebook: checkerboard.ipynb <checkerboard.ipynb>`


.. only:: html

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

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