This article demonstrates how Sequence Selector in Ansys Zemax OpticStudio can simplify common ghost analysis workflows. It shows how generated sequences and sequence groups can be used to identify and isolate dominant ghost paths, investigate their contributions, trace ghost reflections back to optical surfaces, and support iterative ghost reduction. The article also shows how ZOS-API can be used to automate selected ghost analysis workflows, reducing the manual steps required to generate, investigate, and evaluate ghost sequences.
Note: The Sequence Selector feature is available in the Premium and Enterprise editions of Ansys Zemax OpticStudio.
Authored by Aubry Grossetete and Elham Sarbazi
Introduction
Ghost analysis in complex optical systems can involve a large number of possible ray paths, making it difficult to isolate and investigate the contributions of interest. This article presents practical examples for using the Sequence Selector to simplify common ghost-analysis tasks and manage complex ray-path information through sequences and groups. The examples demonstrate how these capabilities can be applied at different stages of a ghost analysis. For selected examples, ZOS-API scripts are also provided to show how the equivalent manual analysis steps can be automated.
Throughout this article, we consider a cellphone camera lens system for demonstrating the examples. The large number of optical surfaces in this system can generate many potential ghost paths, making it difficult to determine which reflections contribute to the ghost signal at the detector. Sequence Selector provides an efficient way to organize and investigate these paths, allowing the relevant contributions to be isolated and examined more easily.
For a general introduction to Sequence Selector and its functionality, refer to the Knowledgebase article How to Use Sequence Selector. The same camera lens system introduced in that article is also used here to demonstrate how Sequence Selector can be applied specifically to ghost analysis.
The Zemax model and supporting Python scripts used throughout the examples are provided as downloadable attachments to this article.
Note: Before running the attached Python scripts, review the path definitions at the beginning of each script. Modify azos_install_path, script_dir, and zemax_dir as needed to match the location of your OpticStudio installation, the script, and the accompanying Zemax files.
Example 1. Identifying dominant ghost paths
Begin by running a non-sequential ray trace with a modest number of rays per source, for example, a few hundred rays. Use the filter string H25 to retain rays that reach the detector and save the ray data to a ZRD file.
In Sequence Selector, select "Use ZRD or PAF File" and load the saved ZRD file. Next, select "Automatic Sequence Grouping" from the Sequence Selector toolbar. Sequence Selector analyses the generated sequences and organizes them into groups based on common characteristics. The resulting groups are displayed in the lower-left panel, as shown in the screenshot below:
The Ghosts group contains all sequences with at least one ghost event. The GhostsFromSource1-5 groups organize these sequences by their originating source. Automatic Sequence Grouping also creates additional groups based on characteristics such as ghost order, which are explored later in this article. Within each group, the sequences are sorted by total ending flux by default, making it straightforward to identify the dominant ghost contributors.
The generated group names can be used directly as filter strings in other analysis tools. For example, load the ZRD file in Detector Viewer and apply GhostsFromSource1 as the filter string to display the detector footprint produced by ghost paths originating from Source 1.
In this example, the first three sequences in the Ghosts group, SEQ6 to SEQ8, have the highest flux contributions at the detector. Once these paths have been identified, a second ray trace can be performed with a larger number of rays, for example, 104 rays per source, for a more accurate evaluation. Apply the filter Ghosts[1:3] so that only rays belonging to these three dominant ghost paths are saved to the new ZRD file. This reduces the size of the ray database while retaining the paths required for further analysis.
Load the resulting ZRD file in Detector Viewer and apply Ghosts[1:1], Ghosts[2:2], and Ghosts[3:3] to inspect the footprint of each dominant ghost path individually.
The analysis steps in this example can also be automated using ZOS-API. Refer to Example 1 in the attached Python scripts, which demonstrates how to automate sequence generation, automatic grouping, and identification of the dominant ghost paths.
Example 2. Identifying surfaces responsible for ghost reflections
Once the relevant ghost sequences have been identified and grouped in Sequence Selector, the surfaces associated with their ghost reflections can be identified in two ways. A quick visual indication can be obtained by selecting a sequence and inspecting the ray path in the embedded layout:
The embedded layout for SEQ6 shows the ray path reversing direction at Objects 19 and 16, providing a visual indication of the surfaces involved in the ghost reflections.
For a more detailed inspection, use the sequence filter SEQ6 in Ray Database Viewer to identify the exact object and face associated with each ghost event. The viewer lists the individual ray segments together with the object, face, and flags describing how each branch was generated.
In the DGEF column, G identifies a branch generated by a ghost event. The surface where the ghost event occurred can be identified from the preceding segment. In the screenshot shown below, segment 10 contains the G identifier. Segment 9 ends at Object 19, Face 1, identifying this as the surface associated with the ghost event.
For sequences containing multiple ghost events, repeat this inspection for each G identifier to identify the corresponding surfaces. The embedded layout provides a convenient visual overview of the ghost path, while Ray Database Viewer provides the segment-level information needed to determine the exact object and face.
This analysis can also be automated using ZOS-API. A Python script can inspect the ray-segment data for the selected ghost sequences, locate the ghost events, and report the corresponding object and face. Refer to Example 2 in the attached python scripts for an implementation of this analysis.
Example 3. Separating ghost contributions by order
In ghost analysis, it can be useful to separate the ghost contributions according to the number of ghost events in each ray path. Sequence Selector simplifies this comparison by automatically organizing the generated ghost sequences into GhostOrder1, GhostOrder2, GhostOrder3, and subsequent groups, avoiding the need to identify and group the individual sequences manually.
The flux values reported for the sequences in these groups provide an initial indication of their relative contributions. For the camera lens system, the sequences in GhostOrder2 show substantially larger contributions than those in the higher-order groups. To compare the second-order contribution with the higher orders collectively, create a user-defined group containing the higher-order sequences.
Select "Make New Group", rename the new group HigherOrders, and add all the sequences from GhostOrder3 through GhostOrder8 to this group. The resulting HigherOrders group represents the combined set of higher-order ghost paths.
The automatically generated GhostOrder2 group and the user-defined HigherOrders group can now be used directly as filter strings in Path Analysis. Applying GhostOrder2 and HigherOrders separately to the same ray database allows their total contributions to be compared directly.
For this system, the Path Analysis results confirm the initial observation from Sequence Selector: the combined higher-order ghost contribution is considerably smaller than the second-order contribution.
This example demonstrates how automatic and user-defined grouping can be used together to organize ghost sequences into meaningful subsets for further analysis. The resulting groups can be used directly as filter strings, avoiding the need to construct and maintain filters for the individual paths.
Example 4. Tracing ghosts from a detector region
Ghost analysis may start from a region of the detector where unwanted ghost light is observed rather than from a known optical path. In this example, an existing filter string is used to isolate rays reaching a selected detector region, while Sequence Selector is used to identify and investigate the ghost paths contributing to that region.
Consider a rectangular region on the detector (object 25) defined by -0.5 < x < 0.5 and 1.5 < y < 2, where x and y are the local coordinates on the detector. The region can be isolated during the non-sequential ray trace using the following filter string:
X_XGT(25,-0.5) & X_XLT(25,0.5) & X_YGT(25,1.5) & X_YLT(25,2)
where the individual conditions define the lower and upper x and y limits of the region.
Run a non-sequential ray trace with 500 rays per source, apply the coordinate filter, and save the filtered rays to a new ZRD file (for example raytrace_500_TargetRegion.ZRD). The resulting ZRD file contains only rays reaching the selected region, providing a targeted dataset for identifying the optical paths contributing there.
In Sequence Selector, select "Use ZRD or PAF File" and load the saved ZRD file. Then click "Generate sequences", followed by "Automatic Sequence Grouping". Because the ray trace has already been restricted to the region of interest, the generated sequence groups represent paths contributing specifically to this part of the detector.
The sequences in the Ghosts group are ranked by total ending flux, providing a direct way to identify the dominant ghost contributions within the selected region. The corresponding sequences can then be inspected to determine the optical paths and surfaces involved.
In this example, inspection of the three highest-flux ghost sequences shows that SEQ2 and SEQ3 both contain ghost events at Face 2 of Object 19. This identifies a surface common to two of the dominant ghost paths reaching the region of interest.
The initial ray trace with 500 rays per source is primarily intended to identify and rank the relevant ghost paths. For a more accurate evaluation of their footprint or power, the identified sequence filters can be used in a subsequent ray trace with a larger number of rays.
Example 5. Iterative ghost reduction by applying coatings
In some systems, reducing a single ghost contribution may not be sufficient to achieve the required reduction in total ghost power. In this example, Sequence Selector is used iteratively to identify the dominant ghost paths as coatings are applied, with the objective of reducing the total ghost power by 25%.
Start with the uncoated camera lens system and run a non-sequential ray trace with 500 rays per source, saving rays that reach the detector to a ZRD file. Load the ZRD file in Sequence Selector, generate the sequences, and apply "Automatic Sequence Grouping". The resulting Ghosts group provides a flux-ranked list of the ghost paths reaching the detector.
Use the complete Ghosts group in Detector Viewer to establish the initial total ghost power. For the uncoated system, the total ghost power is 1.0778× 10⁻¹ W. This value is used as the baseline for evaluating the reduction after each coating cycle.
Next, start with the highest-flux sequence, Ghosts[1:1], and identify the first uncoated surface associated with a ghost event in that path as discussed in Example 2 earlier in this article. Apply the selected AR coating to this surface and repeat the ray trace.
After applying the coating, load the new ZRD file in Sequence Selector, regenerate the sequences, and apply "Automatic Sequence Grouping" again. The coating changes the flux carried by the different ghost paths, so their relative ranking may also change. The updated Ghosts group therefore provides the ranking for the modified system.
Evaluate the total ghost power again and compare it with the original value. After the first coating cycle, the total ghost power is reduced to 9.0065 × 10⁻² W, corresponding to a reduction of 16.43%. Since the 25% target has not yet been reached, another coating cycle is required.
For each new cycle, start from the current highest-flux ghost path and identify an uncoated face associated with a ghost event. If no suitable uncoated face is available in that sequence, continue to the next dominant ghost path. After applying the coating, run a new ray trace, generate and regroup the sequences from the updated ZRD file, and evaluate the new total ghost power. Repeat these steps until the required 25% reduction is achieved or no suitable uncoated surface remains within the dominant ghost paths being considered.
Coating cycle |
Coated object |
Coated face |
Total ghost power (W) |
Reduction from baseline |
Baseline |
- |
- |
1.0778E-01 |
- |
1 |
19 |
1 |
9.0065E-02 |
16.43% |
2 |
16 |
2 |
8.7090E-02 |
19.19% |
3 |
22 |
1 |
8.2284E-02 |
23.65% |
4 |
13 |
2 |
7.5592E-02 |
29.86% |
As coatings are applied, the relative contributions of the ghost paths change. Regenerating and grouping the sequences after each coating cycle provides an updated view of the dominant ghost contributions for the modified system, which is then used for the next cycle.
Automating the workflow with ZOS-API
The complete iterative process can also be automated using ZOS-API. Refer to Example 5 in the attached Python scripts for an implementation that automates the ray trace, sequence generation and automatic grouping, identification of an uncoated ghost-producing face within the dominant ghost sequences, application of the AR coating, and evaluation of the resulting total ghost power.
This iterative coating workflow can be extended to include both optical and optomechanical contributors to stray light. In each cycle, an optical ghost contribution is identified in Zemax OpticStudio and an AR coating is applied to the corresponding optical surface. The updated system is then transferred to Speos, where an optomechanical stray-light contributor is identified and the corresponding surface is coated. The cycle is repeated to progressively reduce the overall system noise. For a complete implementation of this workflow, refer to Automating system-level stray light analysis and optical noise reduction with Ansys Optics – Ansys Optics.