how to write ZPL macro to save detector data from ZRD file to .DAT or .SDF file?

  • 28 December 2022
  • 2 replies


I want to save data from 100 detectors (ZRD file) to .DAT or .SDF files using ZPL macro or something similar.  Can anyone help with a code?  It is tedious to manually save one by one.  

Thank you very much!


Best answer by Ethan 30 January 2023, 20:29

View original

2 replies

I am able to write a loop to save Detector data to .DAT file using  ZRDSAVERAYS.  However, the .DAT file seems not “flux only” and I cannot use “System wavelength” when the .DAT files are used as source file.  However, .DAT file that is manually saved through “Ray Data Viewer” is ok, “flux only” type and “System wavelength” can be used.

Userlevel 2
Badge +2

Hi @Ntran,

Apologies for the delayed response to your question. I’m glad you were able to use the ZRDSAVERAYS function to approach the problem. However, this is a limitation of ZPL, and you have limited control over some of the analysis and export features. To overcome this challenge, you could consider using the ZPL to manually edit the wavelength in the output files. The DAT format is pretty straightforward (see the Help File, The Setup Tab > Editors Group (Setup Tab) > Non-sequential Component Editor > Non-sequential Sources > Source File). You will find that each ray follows this format (per line):

x   y   z   l   m   n   intensity   wavelength


Let me know if this might work for you.