Skip to main content
Solved

Path Analysis Tools in ZOS-API

  • January 30, 2022
  • 6 replies
  • 317 views

joshdfreeman
Ultraviolet
Forum|alt.badge.img

Can anyone point me to the tools/commands to call the Non-sequential Path Analysis Tools in ZOS-API? From Matlab, in Interactive Extension mode on a non-sequential object set, I’d like to be able to execute the path analysis to create the .PAF file and then import that .PAF file into Matlab or at least the desired parts of the .PAF file. I could then do some analysis on the individual aspects of the .PAF file. 

I’ve been looking in the documentation and not having much luck.

Thanks!

Josh

Best answer by Jeff.Wilde

Hi Josh,

You can access the Path Analysis feature from the ZOS-API, then programmatically change its settings:

 

After running an update (assuming some of the settings have been modified), the results can be directly analyzed in Matlab:

 

For this simple example, let’s acquire the path sequence information:

% get path sequence results
np = PA.GetResults.PathAnalysisData.Paths.Length;  % number of paths
paths = cell(1,np);  % initialize paths cell array
for i = 1:np
    paths{i} = PA.GetResults.PathAnalysisData.Paths(i);
end

% load path sequence vectors into array
% initialize vector containing number of ojects hit along each path 
phits = zeros(1,np); 
% loop thru paths
for j = 1:np
    phits(j) = paths{j}.HitsInPath;
end
max_hits = max(phits);  % max hits = number of array columns
path_seq = NaN(np,max_hits);  % initialize array to NaN 
% acquire array of objects hit (each row = one path)
for j = 1:np
    for k = 1:phits(j)
        path_seq(j,k) = paths{j}.PathObjectList(k);
    end
end

then display the results,

 

Compare this to the Path Analysis window output:

 

Alternatively, the results can be saved to a file, which could then be loaded and parsed in Matlab (see Example 10: NSC ZRD Filter String):

Regards,

Jeff

View original
Did this topic help you find an answer to your question?

6 replies

joshdfreeman
Ultraviolet
Forum|alt.badge.img
  • Author
  • Ultraviolet
  • 34 replies
  • January 31, 2022

Studying into it further, it looks like the .PAF file needs to be saved as part of the ray trace operation. I’m already calling the ray trace from Matlab. 

The regular OpticStudio 22.1 documentation mentions that “Currently a PAF file can only be used in the Path Analysis tool.” The format of the PAF file is much, much preferred over the ZRD file, as all I really need is the sum total of the energy in the various paths. Are there computationally “light” ways to get this same information from processing a ZRD file? Is extended PAF file capability with ZOS-API perhaps in a Beta release? Thoughts? 

 


Jeff.Wilde
Luminary
Forum|alt.badge.img+3
  • Luminary
  • 491 replies
  • Answer
  • February 1, 2022

Hi Josh,

You can access the Path Analysis feature from the ZOS-API, then programmatically change its settings:

 

After running an update (assuming some of the settings have been modified), the results can be directly analyzed in Matlab:

 

For this simple example, let’s acquire the path sequence information:

% get path sequence results
np = PA.GetResults.PathAnalysisData.Paths.Length;  % number of paths
paths = cell(1,np);  % initialize paths cell array
for i = 1:np
    paths{i} = PA.GetResults.PathAnalysisData.Paths(i);
end

% load path sequence vectors into array
% initialize vector containing number of ojects hit along each path 
phits = zeros(1,np); 
% loop thru paths
for j = 1:np
    phits(j) = paths{j}.HitsInPath;
end
max_hits = max(phits);  % max hits = number of array columns
path_seq = NaN(np,max_hits);  % initialize array to NaN 
% acquire array of objects hit (each row = one path)
for j = 1:np
    for k = 1:phits(j)
        path_seq(j,k) = paths{j}.PathObjectList(k);
    end
end

then display the results,

 

Compare this to the Path Analysis window output:

 

Alternatively, the results can be saved to a file, which could then be loaded and parsed in Matlab (see Example 10: NSC ZRD Filter String):

Regards,

Jeff


joshdfreeman
Ultraviolet
Forum|alt.badge.img
  • Author
  • Ultraviolet
  • 34 replies
  • February 2, 2022

Thanks @Jeff.Wilde,

that’s exactly what I was after!

 


joshdfreeman
Ultraviolet
Forum|alt.badge.img
  • Author
  • Ultraviolet
  • 34 replies
  • February 11, 2022

@Jeff.Wilde,

I was finally able to find the other parameters for PA.GetResults.PathAnalysis.Paths(n), where n is the individual paths. This let me obtain the TotalPathFlux for each paths, which along with the path data, is what I really needed. 

Basically, I have an optical system defined in OpticStudio, for which desired tilts and positions for the objects are calculated and then updated from Matlab in Interactive Extension Mode. The Raytrace is then called from Matlab, and I’m trying to update and import the PathAnalysis data. The import part is working. However, I’m can’t seem to figure out yet how to update the PathAnalysis data from Matlab. I tried the same methods as for updating the NSC 3D layout, which OS did not like. 

OpticStudio has great functionality and features. The documentation could seriously use a couple orders of magnitude improvements in order to match the standards of industry leading engineering software.

Thanks again!


Jeff.Wilde
Luminary
Forum|alt.badge.img+3
  • Luminary
  • 491 replies
  • February 11, 2022

Did you look at the various Methods associated with the path analysis feature:

 

and try using  “ApplyAndWaitForCompletion” to update after making changes?

 

 

I just used a simple test model in which I tweaked the layout by changing configurations, re-ran a ray trace, and then updated the Path Analysis feature and see that indeed the results are different.

Sometimes, if an error occurs while you are writing/testing the code, some of the OpticStudio tools (e.g., the NSC Ray Trace) can stop working properly.  If you think your code is correct, but it’s not working, at least trying closing out OpticStudio and Matlab, and starting fresh before spending too much time debugging. 


joshdfreeman
Ultraviolet
Forum|alt.badge.img
  • Author
  • Ultraviolet
  • 34 replies
  • February 12, 2022

Thanks @Jeff.Wilde

I was not aware of the Methods and that looks very useful. I’ll try that.

Thanks again!


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings