Python: Writing binary source files

  • 25 November 2020
  • 3 replies

Userlevel 7
Badge +2

Dear OpticStudio users,

I have created a GitHub repository with a template Python script to write binary source files:

I'm hoping this will make it easier for you to write binary sources for OpticStudio in the future. As a reminder from the help file, binary files are 30% as large as equivalent text files, read about 20x faster, and can be left on disk consuming only little RAM. The repository also includes an example script to generate stigmatic Gaussian beams as described by P. Colbourne in his webinar.

By generating a binary source file, one can visualize the propagation of a non-sequential stigmatic Gaussian beam given its waist parameters. Note that the beam needs to intercept the surfaces sequentially, this is a dummy example for visualizaiton only. An OpticStudio archive file is also included for demonstration. This archive contains the Gaussian beam shown in the layout below (x_waist = 1 um, and y_waist = 2 um).

Stigmatic Gaussian beam binary source example

Let me know if this is useful, and take care :)

3 replies


Dear David, 

Thank you so much for your contribution. It helped me to define the irradiance distribution of the laser source I have in the lab and perform beam shaping simulations. 




Userlevel 7
Badge +2

Dear Alejandro,

I'm happy to hear this little piece of code has helped you.

Let me know if it can be improved, and good luck with your research :)



Userlevel 6
Badge +2

I just saw this code and have moved it to the Code Exchange.