Python Class to open .ZBF file

  • 22 December 2023
  • 0 replies
  • 93 views

Userlevel 1

Hi all,

A while back I was on these forums looking for a way to open a .ZBF file using Python and there seemed to be some interest in that from others.  I’ve attached my file that handles opening a .ZBF file either by inputting a file name (with path) or leaving it blank to call a GUI with an explorer to select a file.  From there it will read the binary file and output all relevant information including the E field values, both real and imaginary for x and y (if polarized).  This started off using Michael Chen’s post Python Reading Writing Binary Files (ZRD, ZBF, DAT, SDF) and then using a chunk of code from the old PyZDDE module to see how to read the E-Field values.

 

I optimized reading the files down to a 2048x2048 image takes about 1.5 seconds to open.  Sadly I think the rest is a limitation of python. Within the class there are functions to get irradiance, power, total power, and peak irradiance.  I’ve also added a x,y decenter value to handle decentering the image (in lens units, not pixels).  I haven’t gotten to adding a phase calculation.  I tried a quick attempt at it using some formula’s I saw on this forum, but couldn’t get the plots to match and it’s currently not a priority for me.  But if someone has a the equation to calculate the phase based on the e-field, let me know and I can quickly add it.  If there are other functions people want to request, please feel free to reach out as I’m looking to add more.  The idea was to get as much from the beam file viewer into this class and add on to it.

 

No connection to zosapi is required and the only requirements are to have numpy and matplotlib installed.

 

But I hope people find this useful.  Please feel free to send suggestions.


0 replies

Be the first to reply!

Reply