Tutorial 1c - Saving and Loading Optiland Files

This tutorial demonstrates how to save and load Optiland lens files in a human-readable json format.

[1]:
from optiland.fileio import load_optiland_file, save_optiland_file
from optiland.samples.microscopes import UVReflectingMicroscope

Load and draw a reflecting microscope system.

[2]:
system = UVReflectingMicroscope()
[3]:
_ = system.draw()
../_images/examples_Tutorial_1c_Save_and_Load_Files_6_0.png

Save the system as a json file. This file is human-readable and contains all data relevant for the system, such that the model can be easily shared or reloaded later. To save the system, use the save_optiland_file method:

[4]:
save_optiland_file(system, "uv_reflecting_microscope.json")

We can then load the system again using the load_optiland_file method:

[5]:
new_system = load_optiland_file("uv_reflecting_microscope.json")
[6]:
_ = new_system.draw()
../_images/examples_Tutorial_1c_Save_and_Load_Files_11_0.png