I feel like one could rewrite a ZBFRESAMPLE function for the ZOS-API. It could be a nice addition to ZOSPy. Without knowing the exact implementation of ZBFRESAMPLE there might be small differences, but it’ll be more efficient than having ZOS-API call for a ZPL macro.
Zemax Beam File (ZBF) Binary Format
The ZBF binary file format is defined as follows. All integers are 4 bytes, all doubles are 8 bytes.
1 integer: The format version number, currently 1.1 integer: The number of x samples (nx).1 integer: The number of y samples (ny).1 integer: The "is polarized" flag; 0 for unpolarized, 1 for polarized.1 integer: Units, 0 for mm, 1 for cm, 2 for in, 3 for meters. 4 integers: Currently unused, may be any value.1 double: The x direction spacing between points.1 double: The y direction spacing between points.1 double: The z position relative to the pilot beam waist, x direction.1 double: The Rayleigh distance for the pilot beam, x direction.1 double: The waist in lens units of the pilot beam, x direction.1 double: The z position relative to the pilot beam waist, y direction.1 double: The Rayleigh distance for the pilot beam, y direction.1 double: The waist in lens units of the pilot beam, y direction.1 double: The wavelength in lens units of the beam in the current medium.1 double: The index of refraction in the current medium.1 double: The receiver efficiency. Zero if fiber coupling is not computed.1 double: The system efficiency. Zero if fiber coupling is not computed.8 doubles: Currently unused, may be any value.2*nx*ny double: Ex values.If polarized, 2*nx*ny Ey values follow the Ex values.
The Ex and Ey values are defined such that the Ex*Ex + Ey*Ey is in units of watts.
Zemax Beam File (ZBF) text format
The ZBF text file format is defined as follows. The first line must be the single character “A”, followed by the other data values specified.
A: indicates a text file.
version: The format version number, currently 1.
nx: The number of x samples.
ny: The number of y samples.
ispol: The "is polarized" flag; 0 for unpolarized, 1 for polarized.
units: 0 for mm, 1 for cm, 2 for in, 3 for meters.
unused 1: Currently unused, may be any value.
unused 2: Currently unused, may be any value.
unused 3: Currently unused, may be any value.
unused 4: Currently unused, may be any value.
dx: The x direction spacing between points.
dy: The y direction spacing between points.
zx: The z position relative to the pilot beam waist, x direction.
Rx: The Rayleigh distance for the pilot beam, x direction.
wx: The waist in lens units of the pilot beam, x direction.
zy: The z position relative to the pilot beam waist, y direction.
Ry: The Rayleigh distance for the pilot beam, y direction.
wy: The waist in lens units of the pilot beam, y direction.
lambda: The wavelength in lens units of the beam in the current medium.
index: The index of refraction in the current medium.
re: The receiver efficiency. Zero if fiber coupling is not computed.
se: The system efficiency. Zero if fiber coupling is not computed.
unused 1: Currently unused, may be any value.
unused 2: Currently unused, may be any value.
unused 3: Currently unused, may be any value.
unused 4: Currently unused, may be any value.
unused 5: Currently unused, may be any value.
unused 6: Currently unused, may be any value.
unused 7: Currently unused, may be any value.
unused 8: Currently unused, may be any value.
Ex real value for point 1
Ex imaginary value for point 1
Ex real value for point 2
Ex imaginary value for point 2
etc... for 2*nx*ny Ex values.
If polarized, followed by 2*nx*ny Ey values.
The Ex and Ey values are defined such that the Ex*Ex + Ey*Ey is in units of watts.
I don’t have the bandwidth to work on that now, but if I get a chance I’ll give it a go. Let me know if you try yourself in the meantime.