Export of the Spot Diagram Image using ZOSAPI and MATLAB

  • 22 October 2020
  • 3 replies
  • 502 views

Hello Everyone,


I am new to Zemax. In my current Project I need to produce a couple (>60000 😉 ) Spot Diagrams for training of NNs. I have used the interactive connection with MATLAB and I can run the simulations in corresponding parameter space. The Problem that I am facing right now is that I cannot export the images from the Spot Diagram Window. I mean I can export the text file of the Spot Diagram (the one with Field Coordinates, Image coordinates, RMS Spot Radius, etc.) but I need the patterns which are visible in the plotted graph.


I have already tried to modify the routine in 'MATLABStandalone_22_seq_spot_diagram.m' , but the shape of the resulting graphs are different from the ones Zemax shows. 


Is there an easy way, like a Export method that I am missing? I would appreciate your help.


Bests,


Majid


3 replies

Userlevel 5
Badge +1

Hi Majid,


Thanks for your post here! At this time, there is no way to directly output the plot of the Spot Diagram with the API. You will essentially have to do what you are already performing, which is running the tool in the API and using GetResults() in conjunction with some plotting in MATLAB to get the same picture you're looking for. We also have a forum post here which goes into a bit more detail and provides another example for replicating the output image.


You might already know this, but we do have the EXPORTJPG and EXPORTBMP keywords in our Zemax Programming Language (ZPL). It would mean converting your code into a different language, though.


If you're still having issues with the plot output, would you be able to explain the shape differences? Perhaps we could provide some additional comments after your reply.


Thanks, and let us know how these thoughts work out for you!


~ Angel

Hello Angel,


 


Thank you for the answer. Then I guess I do this one using ZPL, because I need to do it asap. Later I will post the results from the MATLAB Routin and a Spot Diagram for a Singlet, and maybe you can help further.


 


All the best,


Majid 

Userlevel 5
Badge +2

Hello Majid,


Thanks for your feedback.

You may read more about the EXPORTBMP and EXPORTJPG macro keywords in the Help files at:

The Programming Tab > About the ZPL > KEYWORDS (about the zpl) > EXPORTBMP


Further application examples can be found in knowledgebase here:


How do I create presentation quality graphics and animations?


Automatically saving analysis windows


When you have some time, we are looking forward to see you Matlab code and results to investigate the differences.


If you have further questions, please let us know and we will be happy to help!


Best,


Csilla


 

Reply