Solved

ZOS-API unexpectedly fails to open the Wavefront analysis window

  • 15 February 2022
  • 2 replies
  • 173 views

Hello! I am trying to retrieve data about wavefront via ZOS-API in Matlab. Since I need to iterate through different positions of mirror, I am using coordinate breaks and iterate through them using arrays and FOR cycle:

decenter = [-0.5:0.1:0.5];
tilt = [-0.2:0.04:0.2];
for i = 1:tilt_length
for j = 1:decenter_length
disp([i j]);
TheSystem.LDE.GetSurfaceAt(3).GetCellAt(13).DoubleValue = decenter(j); % I set decenter here in the coordinate break (surface 3)
TheSystem.LDE.GetSurfaceAt(3).GetCellAt(14).DoubleValue = tilt(i); % I set tilt here
newWin = TheSystem.Analyses.New_WavefrontMap(); % Requesting new window
newWin_Settings = newWin.GetSettings(); % Requesting settings
newWin_Settings.Wavelength.SetWavelengthNumber(1); % Setting wavelength number
newWin_Settings.Field.SetFieldNumber(1); % Setting field number
newWin_Settings.Sampling = ZOSAPI.Analysis.SampleSizes.S_1024x1024; % Setting sampling
newWin.ApplyAndWaitForCompletion(); % Applying the settings
newWin_Results = newWin.GetResults(); %
wavefrontmap = newWin_Results.DataGrids(1).Values.double; % Exporting the wavefront map with decenter and tilt
end
end

It iterates for some time, but then gets an error:

Dot indexing is not supported for variables of this type.

Error occurs when the code tries to set wavelength number. It reproduces every time (for this specific arrays of decenter and tilt it happens when (i,j) = (9, 11).). However, it executes smoothly if I use these values directly. While debugging, I found out, that newWin_Settings = newWin.GetSettings() for some reason returns empty array, so I can’t address any settings at all. Is there any way to avoid the error? Thank you.

icon

Best answer by David.Nguyen 15 February 2022, 12:42

View original

2 replies

Userlevel 7
Badge +2

Hi gkasoev,

 

I don’t have a MATLAB licence to check your code, but it seems you are not closing the wavefront map in the loop. I imagine that if you open too many wavefront map analyses, it might cause some memory issues. It seems you are doing only 10 iterations, which should be fine but if your application allow it, I’d recommend closing the analysis window once you’ve retrieved its results using the Close() method:

newWin.Close()

inside the loop. That way you are opening the window, taking the results, and closing the window, thus limiting the memory requirements.

Let me know if this helps, and take care,

 

David

Thank you, it worked! Have a nice day.

Reply