Checkerboard function

Checkerboard function#

The verde.synthetic.CheckerBoard class generates synthetic data in a checkerboard pattern. It has different data generation methods, some of which are shared with most other gridders: predict, grid, profile, and scatter.

checkerboard
wavelengths (east, north): 2500.0 2500.0
Checkerboard value at (easting=2000, northing=-2500): -951.0565162951536

Data grid:
 <xarray.Dataset> Size: 122kB
Dimensions:   (northing: 150, easting: 100)
Coordinates:
  * easting   (easting) float64 800B 0.0 50.51 101.0 ... 4.949e+03 5e+03
  * northing  (northing) float64 1kB -5e+03 -4.966e+03 -4.933e+03 ... -33.56 0.0
Data variables:
    scalars   (northing, easting) float64 120kB 0.0 126.6 ... -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

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()

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

Gallery generated by Sphinx-Gallery