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)
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)