Skip to main content

Hello,

 

I saw a coupling topics on this but don’t see a real solution.

Using the MATLAB API I can load a file and create a universal 1 D plot and change config settings. When I open the zmx file after I can see that the settings were applied correctly and the plot looks good. But, I cannot figure out how the access the plot data from the MATLAB API.  I’m using:

 

UnivPlot = TheSystem.Analyses.New_Analysis(ZOSAPI.Analysis.AnalysisIDM.UniversalPlot1D);

UnivPlot_Settings = UnivPlot.GetSettings();

fprintf('Universal Plot has analysis specific settings? %i\n', UnivPlot.HasAnalysisSpecificSettings)

% Above is False; Universal Plot Settings must be changed via ModifySettings (changing a config (.cfg) file)

cfg = System.String.Concat(TheApplication.ZemaxDataDir, '\Configs\UNI.CFG');

UnivPlot_Settings.Save(); % Create new .cfg file, named "UNI.CFG" in \Configs\ folder

% Change universal plot settings

UnivPlot_Settings.ModifySettings(cfg, 'UN1_CATEGORY', num2str(0));

UnivPlot_Settings.ModifySettings(cfg, 'UN1_PARAMETER', num2str(9));

UnivPlot_Settings.ModifySettings(cfg, 'UN1_SURFACE', num2str(14));

UnivPlot_Settings.ModifySettings(cfg, 'UN1_STARTVAL', num2str(0));

UnivPlot_Settings.ModifySettings(cfg, 'UN1_STOPVAL', num2str(1.26));

UnivPlot_Settings.ModifySettings(cfg, 'UN1_STEPS', num2str(151));

UnivPlot_Settings.ModifySettings(cfg, 'UN1_PAR1', num2str(15));

UnivPlot_Settings.ModifySettings(cfg, 'UN1_OPERAND', 'RSCE');

 

UnivPlot_Settings.LoadFrom(cfg); % Load in the Universal Plot Settings

% Save and close

TheSystem.Save();

% Run Analysis (THIS IS THE PART THAT DOESN”T WORK)

% UnivPlot.ApplyAndWaitForCompletion();

% UnivPlot_Results = UnivPlot.GetResults();

 

I’d like to be able to plot as follow:

Read and plot data series

% dataSeries = UnivPlot_Results.DataSeries;

% cc=lines(double(UnivPlot_Results.NumberOfDataSeries));

% for gridN=1:UnivPlot_Results.NumberOfDataSeries

% data = dataSeries(gridN);

% y = data.YData.Data.double;

% x = data.XData.Data.double;

% plot(x,y(:,1),'-','color',cc(gridN,:));

% plot(x,y(:,2),':','color',cc(gridN,:));

% end

 

Does anyone know how to get the universal plot results from MATLAB? I can plot in any format I can get them in.

Any help is much appreciated.

Thanks,

islandoptics

 

 

Hi Islandoptics,

As a general rule of thumb, analysis in the ZOS-API are hooked up in setting/results pairs.  So, if you need to use ModifySettings() to change the settings, then the results will not be hooked up in a DataSeries/DataGrid.  If you need to use ModifySettings(), then you’ll most likely have to use GetTextResult() to save the text file and then manually parse the results.  

With that said, the ZOS-API more or less negates the need for the Universal Plot.  The Universal Plot allows you to only change the LDE/NCE, MCE, or System Explorer data and then report the results of either a single MFE operand or the entire Merit Function.  The ZOS-API gives you control over any system parameter you want to change for the independent axis and then you can use TheSystem.MFE.GetOperandValue() or TheSystem.MFE.CalculateMeritFunction() to get the dependent axis.  Depending on what you're plotting, this approach could be faster than the Universal Plot, especially if you start to multi-thread your calculation since there can only be 1 UNI.CFG file that multiple threads are trying to write to.


That helps a lot! Thanks Michael!

I’ll most likely just loop over a parameter in ZOS-API and pull from the MFE.

Your insight saved me a lot of time. I’m new to the ZOS-API and trying to ramp up quickly.

Cheers,

 


Reply