Simple example#
The example below shows how to create a custom eye model from clinical parameters, build it in OpticStudio, and interact with the model.
Import visisipy and other dependencies#
import matplotlib.pyplot as plt
import seaborn as sns
import visisipy
# Use the open-source Optiland backend for calculations; to use OpticStudio, replace
# "optiland" with "opticstudio"
visisipy.set_backend("optiland")
Define and build the eye model#
Yes, it’s only two lines of code!
# Initialize the default Navarro model
model = visisipy.EyeModel()
# Build the model in OpticStudio
model.build()
Perform a raytrace analysis#
# List of (x, y) coordinates
coordinates = [(0, 0), (0, 10), (0, 20), (0, 30), (0, 40)]
raytrace = visisipy.analysis.raytrace(coordinates=coordinates)
# Alternatively, the model can be built and analyzed in one go:
# raytrace = visisipy.analysis.raytrace(model, coordinates=zip([0] * 5, range(0, 60, 10)))
Visualize the eye model and the raytrace results#
fig, ax = plt.subplots()
visisipy.plots.plot_eye(ax, model.geometry, lens_edge_thickness=0.5)
ax.set_xlim((-7, 23))
ax.set_ylim((-15, 15))
ax.set_aspect("equal")
sns.lineplot(raytrace, x="z", y="y", hue="field", ax=ax)
sns.move_legend(ax, loc="lower right", title="Field")