These examples cover the basic FRED scripting commands involving diffraction gratings: "Get" - retrieve diffraction grating attributes, "Is" - query surface, "Set" - set diffraction grating attributes.
The following structures are required for diffraction gratings:
FRED supports two types of gratings, linear gratings and Holographic Optical Elements (HOE).
"Get" grating data
The "Get" commands retrieve data from diffraction gratings. In this example, the grating information from "grating plate" is retrieved. This grating has its lines oriented at angle with respect to the local x-axis, freq lp/mm. Efficiencies for each order at each wavelength is loaded into an array. Note that the (0,0) element of the array is nothing more than a placeholder and hold no meaningful information:
Dim angle#, freq#
"Is" query In searching for a specific surface type, it is common practice to loop over all entities. The IsDiffractingSurface command can be used to identify a grating. In this example, all linear gratings in the system are set to 257 lp/mm.
For i=0 To GetEntityCount()-1 If IsDiffractingSurface( i ) Then If GetDiffractType ( i ) = "Linear" Then SetDiffractLinear i, 0, 257 End If End If Next i
"Set" grating data As should be common practice, use "Set" commands in concert with "Get" commands to insure only the specified changes are made. This example changes the specification of Source 2 to "Position" and sets its xyz location on an HOE surface:
Dim HO As T_HOE Dim pType$ Dim Hcoefs()
hid=FindName("Mirror HOE") GetDiffractHOE hid, HO, pType, Hcoefs HO.x2=-1: HO.y2=-1: HO.z2=-10: HO.isSrc2Position=True SetDiffractHOE hid, HO, pType, Hcoefs
See Also….
|