metasurface-py
Open-source Python package for design, analysis, and optimization of programmable electromagnetic metasurfaces for wireless communication and sensing.
Installation
pip install -e ".[dev]"
Quickstart
import numpy as np
from metasurface_py.geometry import RectangularLattice
from metasurface_py.elements import PhaseOnlyCell, DiscretePhaseSpace
from metasurface_py.surfaces import Metasurface
from metasurface_py.em import steering_phase, far_field_pattern
from metasurface_py.core.types import AngleGrid
from metasurface_py.plotting import plot_pattern_2d
lattice = RectangularLattice(nx=32, ny=32, dx=5.4e-3, dy=5.4e-3)
cell = PhaseOnlyCell(state_space=DiscretePhaseSpace(num_bits=2))
surface = Metasurface(lattice=lattice, cell=cell, mode="reflect")
freq = 28e9
phase = steering_phase(lattice, theta_steer=np.radians(30), phi_steer=0.0, freq=freq)
state = surface.set_state(phase).quantize(cell.state_space.codebook)
angles = AngleGrid.from_degrees(theta=np.arange(-90, 91, dtype=float), phi=np.array([0.0, 90.0]))
pattern = far_field_pattern(surface, state, freq=freq, angles=angles)
plot_pattern_2d(pattern, cut_phi=0.0)
Features
- Metasurface modeling — Rectangular/hexagonal lattices, phase-only and lookup-table unit cells, amplitude-phase coupled elements
- Far-field analysis — Array factor, directivity, sidelobe level, HPBW, beam steering, focusing, multi-beam synthesis
- Optimization — Continuous (L-BFGS-B, DE), discrete refinement, relax-then-quantize pipeline, multi-objective Pareto sweeps
- Hardware constraints — Phase quantization, grouped control lines, dead elements, manufacturing noise
- RIS channel models — Free-space path loss, narrowband SISO RIS-assisted links, optimal phase computation
- Sensing — Monostatic/bistatic RCS, detection SNR, Fisher information, CRLB for localization
- Mutual coupling — Canonical dipole coupling approximation
- Publication-quality plotting — 13+ plot functions, IEEE/Nature/poster presets, colorblind-safe palettes, PDF/PNG export
- Experiment management — TOML configs, parameter sweeps, reproducibility metadata
- Interoperability — CSV/HDF5/Touchstone import, scikit-rf adapter, xarray labeled outputs
Tutorials
Interactive Jupyter notebooks that run in Google Colab (no install required):
| Notebook | Description | Colab |
|---|---|---|
| 01 Getting Started | Create a metasurface, steer a beam, compare quantization | |
| 02 Optimization | Relax-then-quantize with hardware constraints | |
| 03 RIS Link | RIS-assisted communication link, N² scaling | |
| 04 Sensing & ISAC | Radar detection, localization CRLB, comms-sensing tradeoff |
Citation
If you use metasurface-py in your research, please cite:
@software{metasurface_py,
author = {Hodge, John},
title = {metasurface-py: Design, analysis, and optimization of programmable electromagnetic metasurfaces},
year = {2026},
url = {https://github.com/jman4162/metasurface-py},
version = {0.1.0},
license = {BSD-3-Clause},
}
License
BSD-3-Clause
Metadata
Release files for metasurface-py 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| metasurface_py-0.2.0.tar.gz | 84.5 kB | With provenance | Details for metasurface_py-0.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| metasurface_py-0.2.0-py3-none-any.whl | Python 3 | none | any | Details for metasurface_py-0.2.0-py3-none-any.whl |
Total release size: 157.9 kB
Release files / metasurface_py-0.2.0.tar.gz
| Download URL | metasurface_py-0.2.0.tar.gz |
|---|---|
| Size | 84.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
dd97e45c889ca12c6096b4e7b4fdca423255b026f1cb270ad0bb6afe4c224ed4
|
|
BLAKE2b-256 checksum How to use checksums |
3446960e015e6c81c70a1e82f3354dad94d8768c3708f5be8249e34a932402ae
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
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 Mar 24, 2026.
Transparency logRelease files / metasurface_py-0.2.0-py3-none-any.whl
| Download URL | metasurface_py-0.2.0-py3-none-any.whl |
|---|---|
| Size | 73.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
2975f1a7dcd564e9a765d82d554aaa00f0e2620439f4b3fa44755fa9f325e4d6
|
|
BLAKE2b-256 checksum How to use checksums |
99f4f5b82209afdae1c6433ec22b39e43e76d686e257e209a27d3dec2357234d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
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 Mar 24, 2026.
Transparency logSecurity for metasurface-py 0.2.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.
Attestation for metasurface_py-0.2.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 Mar 24, 2026.
Transparency logA 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.