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: 101, northing: 101)
Coordinates:
  * easting   (easting) float64 0.0 50.0 100.0 150.0 200.0 250.0 300.0 350.0 ...
  * northing  (northing) float64 -5e+03 -4.95e+03 -4.9e+03 -4.85e+03 ...
Data variables:
    scalars   (northing, easting) float64 0.0 125.3 248.7 368.1 481.8 587.8 ...
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()
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.122 seconds)

Gallery generated by Sphinx-Gallery