Skip to main content

A sample project with checkerboard functionality

Project description

CheckmateSample

This Python module provides a function to generate a checkerboard pattern using NumPy. The function make_checkerboard creates a 2D NumPy array representing a checkerboard with customizable board size and square (and rectangle) sizes. Can be used for geospatial ML problems to try and combat autocorrelation. The functions can export two (testing/training) and three (testing/training/validation) checkerboard patterns

Parameters

board_size (tuple[int, int]): Size of the board in (rows, columns).

square_size (tuple[int, int]): Size of each square in (rows, columns).

separation_size (int): Size of separation distance in pixels between squares.

validation (bool): If True, use a ternary (0, 1, 2) pattern; if False, use a binary (0, 1) pattern

xarray only:

dim_names (dict): Dictionary specifying the names of x and y dimensions da (xr.DataArray): Input DataArray to apply the checkerboard pattern to

Dependencies

numpy and xarray

Useage

Create a NumPy checkerboard

checkerboard = make_checkerboard((10, 10), (2, 2))

Create an xarray DataArray

da = xr.DataArray(np.random.rand(100, 100), dims=['lat', 'lon'])

Apply checkerboard pattern to DataArray

result = make_checkerboard_xr(da, (10, 10), keep_pattern=1)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

checkmatesample-0.3.1.post0.tar.gz (468.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

CheckmateSample-0.3.1.post0-py3-none-any.whl (6.0 kB view details)

Uploaded Python 3

File details

Details for the file checkmatesample-0.3.1.post0.tar.gz.

File metadata

  • Download URL: checkmatesample-0.3.1.post0.tar.gz
  • Upload date:
  • Size: 468.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.9.20

File hashes

Hashes for checkmatesample-0.3.1.post0.tar.gz
Algorithm Hash digest
SHA256 a602bc3f1c84c7d1926197cdd84e0de1338fc68021b9a1fab23527beea2c1d6c
MD5 7ce1d1444b81130edb485dc3299f7be6
BLAKE2b-256 981789a3b3d1327a5f408248e3b1cf2d75b3401e5362a981758bb05d9096b7f0

See more details on using hashes here.

File details

Details for the file CheckmateSample-0.3.1.post0-py3-none-any.whl.

File metadata

File hashes

Hashes for CheckmateSample-0.3.1.post0-py3-none-any.whl
Algorithm Hash digest
SHA256 22dfbc832b1b413d124384ad35b0dcb3178f58a16d8c3c8cc9b11fd1c3708de5
MD5 8fe9b27431afef179a5d5360b01acecd
BLAKE2b-256 f06261a78e5024bb3f5a3c897b2d1b1f5b203b2af126b7dd71faf91189cf316b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page