Skip to main content

This Matlab function imports a raw Zemax ray database stored in ZRD file, groups the rays into distinct paths based on i) the exact same sequence of objects hit and ii) ray events (such as reflection, splitting etc.), and outputs this information in a form of graphs, human-readable variables and, most importantly, a summary table storing each path in descending total power, object sequence, total ray events and so on. It can be further processed either using Matlab's native capabilities, or exported and processed using Excel or a simple text editor.

It DOES NOT need Zemax to be installed onto your system and does not use any API to connect to it. It is a totally independent function.

The need for this custom function came clear during one project at work as the native Zemax ray paths tool is simply too primitive. For instance, ray grouping criteria is not clearly specified, also, the explicit sequence of objects is lost (if a ray enters the lens, is backreflected and leaves the lens through the first surface, even though 3 interactions tool place, it will be reported as a single one).

I want to note the inspiration from Michael Cheng’s Python function which helped me to write the part where the binary ray database is loaded. The original post is ‘Python Reading Writing Binary Files (ZRD, ZBF, DAT, SDF)’, available on https://community.zemax.com/code-exchange-10/python-reading-writing-binary-files-zrd-zbf-dat-sdf-3116 as of 1st November, 2024.

Although this function is shared free for use and any modification as you might see fit, I would appreciate it if you would quote me in case you are going to use it for any non-personal tasks.
©️ Kristupas Tikuišis 2024.

Hi, Kris.  Nice work, and thanks for sharing it with everyone.

In case you missed it, we have added face support to our ray databases and path analyses, highlighted below.  And maybe we could contact you for some feedback on one of our new tools coming in the 25R1 release in January.!  We are always looking for customers who are willing to exercise our new features.
 

Regards,

 

Erin


Dear ​@Erin.Elliott, how could I upload an updated version of my code? Should I simply modify the original post to make sure the newest version stays at the top of page?


Yes, edit the post if the system will let you.  If not, you may need to attach it to a new comment, here.


Reply