Skip to main content

ZOSPy

Made by the MReye research group PyPI - Version Python Version from PEP 621 TOML Conda Version GitHub Actions Workflow Status Documentation Status JOSS Zenodo

About

Wrapper around the Ansys OpticStudio API that provides a more intuitive way to interact with the ZOS-API through Python using a .NET connection, as described in this Journal of Open Source Software paper. It thereby allows you to do more optics modelling with less coding.

In addition to full access to all the OpticStudio functions through the ZOS-API, ZOSPy provides the following features:

  • Wrapper functions for several OpticStudio analyses in zospy.analyses;
  • Easy access to solvers in zospy.solvers;
  • Easy access to all API constants in zospy.constants;
  • Autocomplete for all ZOS-API endpoints and constants;
  • Solves common problems related to Python.NET 3 and interaction with the ZOS-API.

Installing

ZOSPy is available on PyPi

pip install zospy

And through conda:

conda install conda-forge::zospy

Example

Create and draw a simple optical system consisting of a single lens:

import matplotlib.pyplot as plt
import zospy as zp

zos = zp.ZOS()
oss = zos.connect()

# Create a new, empty system
oss.new()

# Set aperture and wavelength
oss.SystemData.Aperture.ApertureType = zp.constants.SystemData.ZemaxApertureType.FloatByStopSize
oss.SystemData.Wavelengths.GetWavelength(1).Wavelength = 0.543  # in μm

# Set the object at infinity
surface_object = oss.LDE.GetSurfaceAt(0)
surface_object.Thickness = float("inf")

# Add a dummy surface for visualization purposes
input_beam = oss.LDE.InsertNewSurfaceAt(1)
input_beam.Comment = "input beam"
input_beam.Thickness = 10

# Use a stop diameter of 4 mm
surface_stop = oss.LDE.GetSurfaceAt(2)
surface_stop.SemiDiameter = 2

# Add a lens with n = 1.5
lens_front = oss.LDE.InsertNewSurfaceAt(3)
lens_front.Comment = "lens front"
lens_front.Radius = 20
lens_front.Thickness = 1
zp.solvers.material_model(lens_front.MaterialCell, refractive_index=1.5)

lens_back = oss.LDE.InsertNewSurfaceAt(4)
lens_back.Comment = "lens back"
lens_back.Radius = -20
lens_back.Thickness = 19.792  # System is in focus

# Show the system in the 3D viewer
draw_3d = zp.analyses.systemviewers.Viewer3D(surface_line_thickness="Thick", rays_line_thickness="Thick").run(oss)

plt.imshow(draw_3d.Data)
plt.axis("off")
plt.show()

Full example system

Please refer to the documentation for more information on how to use ZOSPy. More elaborate examples can be found in the example gallery.

Warranty and liability

The code is provided as is, without any warranty. It is solely intended for research purposes. No warranty is given and no rights can be derived from it, as is also stated in the MIT license.

Dependencies

ZOSPy officially supports Python 3.10 - 3.14. It may work with older Python versions, but support is not provided for these versions. Furthermore, a working installation of Ansys Zemax OpticStudio is required.

Compatibility

See the documentation for the most up-to-date compatibility information.

Referencing

When publishing results obtained with this package, please cite our paper in the Journal of Open Source Software:

Vught, L. van, Haasjes, C. & Beenakker, J.W.M. (2024). ZOSPy: Optical ray tracing in Python through OpticStudio. Journal of Open Source Software, 9(96), 5756. https://doi.org/10.21105/joss.05756

Contributing

Please read our contribution guidelines prior to opening a Pull Request.

Contact

Feel free to contact us via e-mail at zospy@mreye.nl for any inquiries, or visit mreye.nl to discover our research.

Metadata

Release files for zospy 2.2.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 zospy 2.2.0
File Size Uploaded
zospy-2.2.0.tar.gz 46.8 MB Details

Built distribution (wheel)

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

Total release size: 47.1 MB

Release files / zospy-2.2.0.tar.gz

Download URL zospy-2.2.0.tar.gz
Size 46.8 MB
Tags Source
SHA-256 checksum
How to use checksums
dc27e3b5c3a6467b9872566c4357445a46508081e1771dc60f3cd614533efb2c
BLAKE2b-256 checksum
How to use checksums
1d64a5c56a59058c4d81657424599485c95fff129fd7b310ed30e8b486748372
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 Sep 21, 2026.

Transparency log

Release files / zospy-2.2.0-py3-none-any.whl

Download URL zospy-2.2.0-py3-none-any.whl
Size 310.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2c75f13225e4481e3da98128dbd8d91e6e6eb6033c058d0b98ce0908c6ef5a76
BLAKE2b-256 checksum
How to use checksums
d97b34b65973733d69ee980d2aac6f9535215c90fc5b1c6dd0341e098cc0be09
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 Sep 21, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

2.2.0 This release

2 release files

2.1.5

2 release files

2.1.4

2 release files

2.1.3

2 release files

2.1.2

2 release files

2.1.1

2 release files

2.1.0

2 release files

2.0.2

2 release files

2.0.1

2 release files

2.0.0

2 release files

1.3.1

2 release files

1.3.0

2 release files

1.2.1

2 release files

1.2.0

2 release files

1.1.2

2 release files

1.1.1

2 release files

1.1.0

2 release files

1.0.0

2 release files

0.6.2

2 release files

0.6.1

2 release files

0.6.0

2 release files

0.5.1

2 release 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