Writes a dataset into a Zemax .zbf2 file in the specified directory.
| Syntax | Description |
|---|---|
| zbf2write("filename", zbf2_data_struct); | Writes a zbf2 file to a path specified by filename, with the data in zbf2_data_struct. The data to include in the struct is discussed below. This function does not return any data. |
| zbf2write("filename", zbf2_data_struct, rotation_option); |
Writes a zbf2 file to a path specified by filename, with the data in zbf2_data_struct. The data to include in the struct is discussed below. The rotation_option input is optional, it can be either ‘none’, ‘auto’, and ‘provided’. By default, the direction of propagation of the beam data is computed, and a rotation matrix is applied on the beam data so that it is rotated to the plane orthogonal to the propagation direction. This behavior can be controlled with the rotation input:
This function does not return any data. |
The data struct must contain the following fields
| Field | Description |
|---|---|
| beam | A dataset containing beam information. This dataset must contain E vs x,y, and wavelength/frequency information. |
| index | The refractive index for the beam. |
| attributeName | Optional, a string that specifies the name of the field information in the beam dataset. Defaults to using the first scalar or vector attribute in the dataset. |
| rotation_matrix |
Optional, except if ‘rotation_option’ is set to ‘provided’. A matrix that specifies the rotation matrix. |
| position | Optional, a vector that specifies the position of the beam. Defaults to [0,0,0]. |
| OPL | Optional, optical path length. Defaults to 0. |
Example
# Write beam information to the current working directory
E_monitor=getresult("monitor","E");
my_zbf2_struct={"beam": E_monitor, "index": 1};
# Default behavior with auto-rotation
zbf2write("my_beam.zbf2", my_zbf2_struct);
zbf2write("my_beam.zbf2", my_zbf2_struct,’auto’);
# Saving without rotation
zbf2write("my_beam.zbf2", my_zbf2_struct,’none’);
# Saving with a custom rotation matrix:
alpha=10*pi/180;
R_tilt = [[cos(alpha), 0, sin(alpha);0,1,0;-sin(alpha),0,cos(alpha)];
my_zbf2_struct_custom={"beam": E_monitor, "index": 1,”rotation_matrix”: R_tilt};
zbf2write("my_beam.zbf2", my_zbf2_struct_custom,’provided’);
See Also