Question

How can I import Grid Sag in macro using buffer

  • 28 July 2023
  • 4 replies
  • 53 views

  • Monochrome
  • 3 replies

Hi all,

 

I am writing a ZPL macro which calculates phase patterns and imports the phase into Grid Phase Surface automatically. (There is a typo in title. I’m using a Grid Phase Surface)

 

I found a way to import the grid phase using IMPORTEXTRADATA keywords in a below question

Macro import of .dat file onto a Grid Phase surface | Zemax Community

But it requires “reading” .dat files; so, I should firstly generate .dat file for the calculated phase profiles, and after that I could read again the phase from those .dat files to import. It seems to be very inefficient method and takes too long time to write and read my phase profile. 

 

Is there any way to import phase data directly from another data types in ZPL (like array or vec) instead of writing and reading .dat files?

 

With best regards,

Jiwoon.


4 replies

Userlevel 7
Badge +3

I don’t think there is. If you are using the GRID surface types, their data is simply in the form of a grid of data, and there’s no way (I believe) to just write the pixel data into a GRID surface types without going out to a file.

That said, writing the data to, and reading it from, a data file should be virtually instantaneous. Since the data is only written and read once, and then has no effect on ray tracing speed I can’t see any meaningful speed increases from doing it another way. 

Hi Mark,

 

thanks you for your reply. Actually, at each loop of iteration, a newly updated GRID data is written to, and read from the .dat file. The probelm seems to occur when “reading” process of .dat file starts before finishing the “writing” process for the updated .dat file. For example, my GRID data is composed of 200x200 points, so 40,000+1 lines (including header) should be written as .dat file at every steps of the optimization. And the updated grid data is written to .dat file using “for-loop” of 40,000 iterations with OUTPUT “filename” keywords. So the reading process usually starts before my .dat file is completely written (sometimes writing the .dat file is done timely; then my code is working well in that moment...) By any chance, is there any way to write .dat file more quickly instead of the above approach using “for loop” of 40,000?

 

Thank you.

Userlevel 7
Badge +3

Oh brother, that sounds like a lot of work. SSD drive?

Have you looked at the TrueFreeForm surface? That is a built-in capability that might be more appropriate than GRID surfaces.

Alternatively, use ZOS-API rather than ZPL, as it has .UpdateAndWaitForCompletion methods, although even those might think that when the data is written to the disk’s buffer memory is when writing is complete. I can only suggest PAUSE statements for that case. I’d check out the TrueFreeForm though.

Good luck!

  • Mark

Hi Mark,

Thank you for your advice. I’ll try ZOS-API. BTW, it seems that I could replace GRID SAG surfaces with TrueFreeForm surfaces, but I have no idea if the TrueFreeFrom surface support changes of phase information on the surface (within constant/fixed sag profiles). Could the TrueFreeForm surfaces also replace GRID PHASE?

 

Thank you.

Reply