Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

prtLab Python

prtLab is a polarization ray-tracing toolkit for optical systems containing isotropic and uniaxial materials. This directory contains the installable Python implementation. The MATLAB implementation in the repository root remains the reference and the python is a port of that implementation that preserves numerical parity.

Installation

From the pyprtLab directory, install the package into an activated Python environment:

python -m pip install .

To work on the package itself, use an editable installation with the development tools:

python -m pip install -e ".[dev]"
pytest

The package name and import name differ only in capitalization. Import it as:

import prtlab

Quick Start

This traces the quarter-wave plate used in Chipman Example 20.1 and coherently recombines its ordinary and extraordinary branches:

from prtlab import (
    coherent_final_jones,
    jones_retardance_waves,
    polarization_ray_trace,
    quarter_wave_plate_system,
)

system = quarter_wave_plate_system()
result = polarization_ray_trace(
    system,
    [0, 0, 1],
    [0, 0, 0],
    [0, 1],
    {"encodePropagationPhaseInP": True},
)
jones = coherent_final_jones(result)
print("Retardance [waves]:", jones_retardance_waves(jones))

Examples and Notebooks

The examples are the best entry point for learning the current API. Python scripts are stored in examples, and direct translations of the MATLAB notebooks are stored in docs/source:

For interactive notebook use, register the project environment once:

python -m ipykernel install --user \
    --name prtlab-python --display-name "prtLab Python"

Then select prtLab Python from Jupyter's kernel menu.

Solid Scene Example

import matplotlib.pyplot as plt
import numpy as np

from prtlab import (
    create_fresnel_rhomb_solid,
    plot_prt_system_3d,
    polarization_ray_trace_solid,
)

rhomb = create_fresnel_rhomb_solid(
    1.495,
    length=14,
    height=8,
    width=8,
    shear=11.02085,
    wavelength=0.589,
)
result = polarization_ray_trace_solid(
    rhomb,
    [0, np.sin(np.deg2rad(0.1)), np.cos(np.deg2rad(0.1))],
    [0, 5, -2],
    [1, 1] / np.sqrt(2),
    {"maxInteractions": 8, "minAmplitude": 1e-4},
)

plot_prt_system_3d(
    rhomb,
    result,
    {"PostExtend": 4, "ShowLegend": True},
)
plt.show()

The 3D renderer colors ordinary, extraordinary, and reflected branches separately. Red glyphs show the real time-domain locus of each complex electric field.

Validation

Run the Python tests and notebook checks with:

pytest
python tools/validate_notebooks.py
python tools/validate_notebooks.py --execute
python tools/smoke_test_wheel.py

See PORTING_STATUS.md for current MATLAB-to-Python coverage.

MATLAB Synchronization

Every MATLAB function in prtLab/ is classified in tools/matlab_port_manifest.json as parity-tested, internal, deferred, or legacy. Validate the inventory and show deferred APIs with:

python tools/audit_api_parity.py --list-deferred

After changing MATLAB code, report files changed since the last reviewed Python synchronization point with:

python tools/check_matlab_sync.py

After those changes have been reviewed, ported, and tested, record the current commit with:

python tools/check_matlab_sync.py --mark-current

The marker is a review checkpoint, not an automatic claim of numerical parity.

License

prtLab is distributed under the BSD 3-Clause License. See LICENSE.

Download files

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

Source Distribution

prtlab-0.1.0a2.tar.gz (48.4 kB view details)

Uploaded Source

Built Distribution

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

prtlab-0.1.0a2-py3-none-any.whl (45.8 kB view details)

Uploaded Python 3

File details

Details for the file prtlab-0.1.0a2.tar.gz.

File metadata

  • Download URL: prtlab-0.1.0a2.tar.gz
  • Upload date:
  • Size: 48.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for prtlab-0.1.0a2.tar.gz
Algorithm Hash digest
SHA256 07fd2197a0e0dd6c78102d188b24cc0334b24a26ab474549a077a33218497f9c
MD5 40d0fb18d7136606d0ec575a42a1e1b8
BLAKE2b-256 c8f0563efdab212a8e64e131c58d09ff3439e4b08671381605fb99b08bfee24d

See more details on using hashes here.

Provenance

The following attestation bundles were made for prtlab-0.1.0a2.tar.gz:

Publisher: publish-pypi.yml on jeremynesbitt/prtLab

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file prtlab-0.1.0a2-py3-none-any.whl.

File metadata

  • Download URL: prtlab-0.1.0a2-py3-none-any.whl
  • Upload date:
  • Size: 45.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for prtlab-0.1.0a2-py3-none-any.whl
Algorithm Hash digest
SHA256 119cead83992368560c1dff7c8cf40ce5f907d6d97be727ddd8fdeab12f704ca
MD5 847b71d2606e5738fceb2c6a213299bc
BLAKE2b-256 39dacd1004ddcfd1ccc0fb96296dd3bcedaf2b465a135a50d085aea1651d5832

See more details on using hashes here.

Provenance

The following attestation bundles were made for prtlab-0.1.0a2-py3-none-any.whl:

Publisher: publish-pypi.yml on jeremynesbitt/prtLab

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

0.1.0a2 This release

2 files

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