Skip to main content

Is there a way to load preset tables for the Field Data Editor (.fld) and Wavelength Data (.wav) in the API?

 

I’m not seeing a way in the syntax help guide for any type of loading of files in the SystemData namespace.

Hi Alex,

Currently there is no way to load a WAV or FLD file via the ZOS-API. 

Adding and removing wavelengths is extremely fast via the ZOS-API, so I would simply read the WAV file as a text file and change the IWavelength interface manually.

If speed isn’t an issue, then you can use the same approach for a FLD file since this is also text based & human readable.

However, if speed is an issue, adding and removing fields, is extremely slow via the ZOS-API.  When Zemax extended from 12 to 50 (Professional) or 2025 (Premium/Enterprise) fields, they did not refactor the underlying source code for handling fields.  Each addition/removal of a field causes a full optical system update and with complex systems or systems with a lot of fields, this update can take seconds.  The 2 recommendations I have for dealing with a lot of fields are:

  1. Only use two fields were Field 1 is (0, 0) on-axis and Field 2 is your target field.  You can then loop through each field in your script and retrieve your data.  This approach also helps with Merit Function Operands that use normalized field coordinates since Field 2 will always be Hx/Hy = 1.
  2. Open the ZMX file before loading in your ZOS-API program, manually add your fields to the ZMX file and then use the LoadFile command to open the file.  The first 12 field points are defined with the XFLN, YFLN, FWGN, VDXN, VDYN, VCXN, VCYN, VANN commands.  Any fields higher than 12 are designated with the FENF command to let OpticStudio know the total number of fields.  Then, fields 13 and above are each defined on a single line using the FEFD command.  

Approach #2 will be faster since the core code only needs to update/load the fields one time, but will be more error prone.  


Hi Michael, 

Thanks for your response.  Yeah sadly speed is a bit of an issue as my simulation already takes a full work day.

I wonder then if it is any quicker just to load a completely new .zmx file?


Reply