You might want to export simulation results in the form of images of plots, or script
Exported variables can then be loaded into another simulation file at a later time, or
they can be loaded into a third party tool for additional analysis.
Data can be exported in different formats and we'll cover export of figures, Lumerical
data files, exporting data to a text file or spreadsheet, and exporting data to MATLAB.
Some export methods can be carried out through the graphical user interface, and some require
use of script commands.
Additional options for data export are listed in the related links below this video.
Figures can be exported to image files from the visualizer window from the button in the
toolbar or the "Export to..." button in the plot options.
They can also be exported from figure windows using either the toolbar button for line or
vector plots, or from the "File" menu for surface plots.
Lumerical data files which have a .ldf file extension are used by Lumerical tools.
You can save data into the .ldf format and load it in another simulation file.
Any variables in the script workspace can be saved to a Lumerical data file, so this
could be monitor data that has been sent to the script workspace or user-defined variables
in the script workspace.
The data is saved by using the savedata script command, and it can be loaded using the loaddata
This is the simplest way to save script workspace data since once you close a simulation file,
the script workspace data is lost, since the script workspace doesn't get saved along
with the file.
For more information about the script commands mentioned in this video including details
about the syntax and example code, see the related links.
To export data to a text file, you can use the "Text" option of the "Export to..." button
in the visualizer to save the data directly to a text file, or you can use the "Clipboard"
option which will copy the data that's plotted in the visualizer to the clipboard so that
it can be pasted into a text file or spreadsheet.
It's also possible to write data to a text file from the script using the write script
command where the syntax is very similar to the savedata script command that we just saw
for saving variables to the Lumerical data format.
It's also possible to export figure data to MATLAB from the visualizer using the "Export to MATLAB"
button in the toolbar.
Two options are available.
The "MATLAB export" option opens a MATLAB instance and plots the equivalent figure as
the one that's currently plotted in the visualizer.
The "MATLAB export script" option plots the figure using MATLAB and also saves the data
to .mat file and the MATLAB script used to generate the plot to a .m file, so the
plot can be reproduced again later in MATLAB.
Note that you must have a compatible version of MATLAB installed on your computer in order
to use this feature.
You can find more details on the MATLAB requirements in the related links below.
A script command, matlabsave, can be used to save any data from the script workspace
to a .mat file which can be loaded in MATLAB.