What is the easiest way to convert ZRD file to SDF file?

  • 26 April 2021
  • 4 replies
  • 363 views

To Whom It May Concern:


I am working with a C++ code writer who will provide a light source file with ZRD format.


I only know Source File can use SDF format, however, I don't know how to use ZRD to create a light source.


Could you help me with that?


Thanks.


Zheng-Wu (Paul)


4 replies

Userlevel 4
Badge

The simplest way is to save directly the ray file instead of converting the ZRD to a ray file (using the system that you used to generate the ray file in the first place). In the 'Ray Trace Control window', you can save the rays hitting an object in a ray file instead of the full ZRD by:


- prefixing the filename by '#-' where # is the object number of the object where you record the rays (it may have to be a detector object, I'm not sure) and


- suffixing by the extension (.dat or .sdf).


For instance,


14-exportedrays.sdf


will save rays at object 14 in the file 'exportedrays.sdf'


The alternative with ZRD is more complex, it involves importing the ZRD, splitting the ray trees into individual segments, selecting the segments that hit the desired object (and/or face) and saving them as a ray file (that step is easy).

Hi, Ray:


However, the C++ code writer provided me all files in the format of .ZRD.


ZRD is not generated by Zemax non-sequential, it is converted from C++.


Could you let me know a simple way to convert ZRD to SDF?


Thanks.


Zheng-Wu (Paul)

Userlevel 4
Badge

2 solutions:


1- Matlab format


Zemax can convert ZRD to Matlab format, this may be a way to avoid working from the ZRD files (command is ZRD2MAT).


 


2- ZRD


The ZRD formats exists in 3 forms: uncompressed full data, uncompressed limited data and compressed. Only the first one is documented. Start from there.


You want to filter the segments that match the object you want to use as start from the rays. You may want to use the 'level' field to generate the source where the rays began in your ZRD, or any other object. Then, for these selected segments, you can use the x,y,z,l,m,n, and intensity fields. If the 'in_object' field is zero, you can use the nx field for the wavelength. If you cannot know the wavelength, use the dat format instead of the sdf format (sdf is dat + the wavelength)

Hi, Ray:


It is very educational to me from your reply.


I will be working on 2-ZRD, because it is exact what I need.


Could you send me some documents I can read and star to learn?


Thanks.


Zheng-Wu (Paul)


 


 

Reply