Checkerboard functionΒΆ

The verde.datasets.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.

../_images/sphx_glr_checkerboard_001.png

Out:

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

Data grid:
 <xarray.Dataset>
Dimensions:   (easting: 100, northing: 150)
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(amplitude=1000, region=(0, 5000, -50...

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.datasets.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.110 seconds)

Gallery generated by Sphinx-Gallery