Skip to main content

maskmesh

PyPI Python License: MIT CI

maskmesh builds regular latitude/longitude mesh grids centered on an arbitrary point on the sphere.

Grid points are interpolated on the sphere (via 3D unit-vector arcs) instead of naive flat addition, so grids stay seamless when they cross the poles (latitude wrap beyond ±90°) or the ±180° antimeridian — handy for regional masks, meteorological/climate data extraction, and anywhere you need a local equidistant grid anywhere on the globe.

Features

  • Rectangular (lat, lon) grids centered on any (lat, lon), with a fixed angular step (degrees)
  • Seamless wrap-around across the poles and the antimeridian
  • Bidirectional coordinate helpers between (lat, lon) and unit-sphere (x, y, z)
  • Pure Python + NumPy, no compiled dependencies

Installation

pip install maskmesh

Or from source:

git clone https://github.com/WChao1988/maskmesh.git
cd maskmesh
pip install .

Quick start

from maskmesh import MaskMeshGrid

grid = MaskMeshGrid(lat=60, lon=160, step=1/60, target_size=(60, 60))

gis = grid.fetch_grid()          # ndarray of shape (60, 60, 2)
lats, lons = gis[..., 0], gis[..., 1]

A grid centered near the antimeridian wraps around instead of breaking:

grid = MaskMeshGrid(lat=0, lon=179.9, step=1/60, target_size=(40, 40))
lons = grid.fetch_grid()[..., 1]
# longitudes smoothly span ~179.6 ... 180 -> -180 ... -179.6

Parameters

Parameter Default Description
lat 60 Center latitude in degrees
lon 160 Center longitude in degrees
step 1/60 Grid step in degrees (1/60 = 1 arcminute)
target_size (41, 41) Nominal grid size (rows, cols)

Note: rows and columns are generated as symmetric ±half-step pairs around the center, so the returned array always has even side lengths: a target_size of (41, 41) yields a (40, 40, 2) array, (180, 180) yields (180, 180, 2).

Coordinate helpers

x, y, z = MaskMeshGrid.gis2xyz(lat, lon)   # (lat, lon) -> unit sphere (x, y, z)
lat, lon = MaskMeshGrid.xyz2gis(x, y, z)   # unit sphere (x, y, z) -> (lat, lon)

Development

pip install -e .[dev]
pytest

License

MIT

Metadata

Release files for maskmesh 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for maskmesh 0.1.0
File Size Uploaded Provenance Actions
maskmesh-0.1.0.tar.gz 4.8 kB With provenance Details for maskmesh-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for maskmesh 0.1.0
File Interpreter ABI Platform Actions
maskmesh-0.1.0-py3-none-any.whl Python 3 none any Details for maskmesh-0.1.0-py3-none-any.whl

Total release size: 9.3 kB

Release files / maskmesh-0.1.0.tar.gz

Download URL maskmesh-0.1.0.tar.gz
Size 4.8 kB
Tags Source
SHA-256 checksum
How to use checksums
ec486ffe389ba8cad644646b3575a44c9400e57916c3a804b7c935a4cbdec787
BLAKE2b-256 checksum
How to use checksums
f55b0036daa7b9b289328866c36028c8938c386f5d9c89b1c8c0291b81a9ba80
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 6, 2026.

Transparency log

Release files / maskmesh-0.1.0-py3-none-any.whl

Download URL maskmesh-0.1.0-py3-none-any.whl
Size 4.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
cc075df7cfc9b683052b82bc09e5b1fe2f306a8703dc7eeb0b60deea58d9f956
BLAKE2b-256 checksum
How to use checksums
e2a362bac025fbf816f42270f0d294b120705e486dc235d96b0127b593b2e876
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 6, 2026.

Transparency log

Security for maskmesh 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for maskmesh-0.1.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 6, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page