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

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.2.2.tar.gz (5.9 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.2.2-py3-none-any.whl (5.4 kB view details)

Uploaded Python 3

File details

Details for the file checkmatesample-0.2.2.tar.gz.

File metadata

  • Download URL: checkmatesample-0.2.2.tar.gz
  • Upload date:
  • Size: 5.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.9.19

File hashes

Hashes for checkmatesample-0.2.2.tar.gz
Algorithm Hash digest
SHA256 dd24a0b3ef71edb20226bb573068aa6816b999c5d4fcf69a95341d413e97c3bc
MD5 48e4c8eb8788541fa4f74a488dc4a3e4
BLAKE2b-256 514b2a3758f642a515116103ed237eee6141c76081a930567744bf3212f50673

See more details on using hashes here.

File details

Details for the file CheckmateSample-0.2.2-py3-none-any.whl.

File metadata

File hashes

Hashes for CheckmateSample-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 13b69e458169ea1406f57e399fcd1499b63f5a6fe2f10024b3b19a5bb9eda517
MD5 23ca4fe6c9d7feea98a5420f1cd4a1c3
BLAKE2b-256 c880ac638d5889f864463f1517b83bd7a951ee75ed72b66dc72952c42f9c2d5a

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