How to build a spectrometer – Stray Light Analysis

Spectroscopy is a non-invasive technique and one of the most powerful tools available to study tissues, plasmas and materials. In this article, stray light occurring in a lens-grating-lens (LGL) spectrometer built of commercially available optical elements is examined. The article covers the conversion of a spectrometer setup from sequential to non-sequential mode, the design of a simple casing and the quantitative analysis of light scattered to the casing and light contaminating the spectrometer’s line camera.

Authored By Lorenz Martin


Article Attachments


Even when a spectrometer has been optimized in terms of optical conception, its performance can be deteriorated by stray light. Stray light may be scattered away laterally from the optical path leading to a loss of power. Another unwanted effect is stray light contaminating pixels on the spectrometer’s line camera other than the one related to a dedicated wavelength.

Conversion of an LGL spectrometer from sequential to non-sequential mode

The spectrometer we analyze in terms of stray light effects has been set up and optimized as described in the Knowledgebase article ”How to build a spectrometer – implementation”. It is also in this article where the technical details and specifications of the spectrometer are explained. The spectrometer has the following shape:

Spectro set-up

The spectrometer is of the lens-grating-lens (LGL) type and made of off-the-shelf optical elements. The bandwidth ranges from 855 nm to 905 nm and has been chosen for application in Optical Coherence Tomography (OCT).

In OpticStudio, the stray light analysis is carried out in non-sequential mode. As opposed to sequential mode, OpticStudio launches a large number of rays and traces their way through the spectrometer including ray and power splitting. So, as a first step, we convert the spectrometer from sequential to non-sequential mode. This conversion procedure largely follows the Knowledgebase article ”Introduction to stray light analysis – Part 1”.

Automatic conversion

Open the file Spectrometer.ZAR (available in the Downloads section of this article) and navigate to File…NSC Group. In the appearing window click OK (we do not need to use the Design Lockdown and the Critical Rayset Generator in our case):


As a result, OpticStudio switches to non-sequential mode and displays the spectrometer in the Non-Sequential Component Editor.

Manual completion of the NSC model

The OpticStudio conversion algorithm is very powerful, but a manual completion is necessary to bring the spectrometer into good shape. Delete the lines marked with red boxes in the Non-Sequential Component Editor (they concern the source and the detector which we implement by hand in the next step):

Manual correctionThen change the lines 2, 7 and 15 as given below:

Manual correction

  • Object 2 corresponds to a point source emitting a gaussian shaped, diverging beam mimicking the light originating from a single mode fiber.
    • We use 100 Layout Rays and 100,000 Analysis Rays to ensure a speedy calculation and rendering of the rays.
    • The choice of 100 W as source power is arbitrary but convenient for the analysis, since all power will show as percentage relative to the source.
    • Do not forget to also set X- and Y-Divergence to 6.892 degrees and X- and Y-SuperGauss to 1, which are the parameters related to the characteristic of the fiber. These parameters are further to the right in the Non-Sequential Component Editor and not visible in the screenshot above.
  • Object 15 concerns the detector. We implement it as an absorbing bar of 2000 pixels with 20 µm height and 20 mm width.

Modelling the diffraction grating

The last and most extensive adaptation concerns the diffraction grating (Objects 7 and 8). These settings are related to the manufacturer’s specifications. In fact, the grating consists of two consecutive gratings each of them having 0.9 lines per µm (which is equal to one grating having 1.8 lines per µm). The parameters not visible in the screenshot above are for both gratings: Thickness of 1.49 mm, Lines/µm 0.9 and Diff Order -1. The Z position of Object 7 needs to be set to 1.49 mm, and the Z position of Object 8 to 1.51 mm. The Spectrometer-NONSEQ.zar file attached contains the system up until this point.

A single grating is diffracting 87 % of the light into the -1st diffraction order and 13 % into the 0th diffraction order, resulting in an efficiency of 75 % for both gratings combined. This behavior is set in the Coat/Scatter Properties of Objects 7 and 8:


Finally, we apply a coating to the front and back face of the grating. Note that the first grating is turned by 180 degrees, so its front face becomes the back face of the element. According to the manufacturer, the reflection is 0.5 %. This is implemented in OpticStudio with a simple ideal coating having a transmission of 0.995. So, update the Diffraction Properties of Objects 7 and 8 as below:


First results

Now is the moment to have a look at the NSC Shaded Model of our spectrometer (in the settings, Color Rays By is set to Wave #). As you may see, the spectrometer looks the same as in non-sequential mode shown in the first picture at the top of the article (the detector is not visible because of its small height of 20 µm):

ViewerWe are now also ready to perform the first ray tracing run. Go to the Analyze tab and click on Ray Trace, which will open the Ray Trace Control.
The settings for ray tracing will remain the same throughout this article:

  • Use Polarization and Split NSC Rays ensure the rays are split and their power is divided when they hit surfaces.
  • Ignore Errors is to continue ray tracing when a ray cannot be calculated, e.g. when it is hitting the edge of an object.

Once you press the Clear & Trace button, ray tracing starts and finishes after some seconds, with the calculation time depending on the available CPU power. It is always good to have a look at the lost energy values (they may vary in every ray trace run because of the stochastic nature of the calculation). In our case, the loss due to errors is negligible, and approx. 0.5 W (of the initial 100 W of the source) got lost due to thresholds. OpticStudio stops tracing rays falling under a power threshold as specified in the System Explorer where we used the default value of 0.1 %.


So, all values look good and we can open the Detector Viewer (button also in the Analyze tab):


We see three distinct peaks representing the three wavelengths set in the System Explorer (855 nm, 880 nm, 905 nm). This result is in good agreement with the spectrometer simulation performed in sequential mode (see Knowledgebase article ”How to build a spectrometer – implementation”).

The plot also shows the total power arriving on the detector in the text section of the graph. We get 59.5 W out of the 100 W coming from the source. This result is also reasonable, since 25 % of the power are lost at the diffraction grating. So, roughly 20 % loss must be due to the lenses and due to limited focusing of the beams on the detector. This result is also in agreement with the spectrometer simulation performed in sequential mode.

The next two sections of this article are addressing the question how to examine the stray light related to reflections on lenses and to limited focusing on the detector. For this purpose, we add a simple casing to the spectrometer.

Implementation of a simple casing

The casing we are going to add to the spectrometer has two purposes:

  1. It will block light being scattered laterally.
  2. It will serve as a detector to understand where the light is mostly scattered.

The design of our casing will be very rough, yet appropriate for measuring stray light and not being far from how it could look like in reality. Take the Non-Sequential Component Editor and add six lines at the end as follows, being two cylinders surrounding the lenses (mimicking barrels), two circular surfaces at the end of the barrels and two rectangular surfaces near the diffraction grating:

HousingIn addition, we enable coating and scattering on all of the detector’s surfaces (Objects 16 to 21). With these settings, 95 % of the incident light is absorbed, 1 % is specular reflection and 4 % is backscattered with a Lambertian distribution. These are typical values for light absorbing black-out materials:


Make Objects 16-21 detectors:

Object As DetectorThe NSC 3D Layout shows nicely that most of the light is now absorbed by the casing:

3D Layout

Using a Merit Function to calculate power values

The NSC 3D Layout is only a qualitative assessment of the stray light. We would also like to get quantitative values of the intensity distribution. An elegant way to calculate these values is a merit function. Open the Merit Function Editor in the Optimize Tab and key in the following lines or open the file Spectrometer_casing.zar file which has the power_measurement.MF included:


The lines 3 and 5 with the NSDD and NSTR operands are standard lines to initiate a ray trace run in non-sequential mode. The measurement of the incoherent intensity data is performed with line 7 being the spectrometer’s detector and with the lines 8 to 13 being the Objects of the casing. Line 14 is the sum of all measurements. As we can see, the value is close to the 100 W fed into the system by the source.

When we have a closer look at the numerical values of the detectors, we can conclude that stray light effects are low before the grating (Objects 16 to 18). But the values are high after the grating at Objects 19 and 20 where the light from the 0th diffraction order of the grating is absorbed. There is another substantial fraction of the light on Object 21 surrounding the spectrometer’s detector, which is due to limited focusing of the beams on the detector. So, in the setup of the spectrometer, care must be taken to control the light originating from the 0th order of the diffraction grating, eventually using a light trap instead of only an absorbing surface. The system up until this point is attached in the file entitled Spectrometer_casing.zar.

Analysis of stray light on the detector

We have seen in the previous section that approx. 60 % of the initial intensity is focused on the detector and 10 % is spread over Object 21 surrounding the detector. We will now examine this distribution in more detail and particularly investigate how much light of a single wavelength is contaminating the line camera, i.e. illuminating pixels not related to this wavelength.

To prepare for this analysis, we first disable the wavelength at 855 nm and at 905 nm in the System Explorer so that we only have the central wavelength at 880 nm. Then we delete the Ellipse (Object 21) and the Detector Rectangle (Object 15) in the Non-Sequential Component Editor. We will add new detectors in the next step. Finally, we increase the number of Analysis Rays of the source (Object 2) to 108.

Total power on detector

To get a meaningful picture of the power distribution in the detector plane we set up three detectors as follows (lines 20 to 22):

3 detectors

  1. The first detector corresponds to the single pixel measuring the irradiance at 880 nm.
  2. The second detector corresponds to the array of the remaining pixels of the line camera (note that the number of pixels has been set to 2001 instead of 2000 to respect symmetry).
  3. The third detector covers the rest of the surface around the detector.

With this adaptation in the Non-Sequential Component Editor done, we start again a Ray Trace run, this time with Scatter NSC Rays also enabled. This run may take more than an hour since we have so many analysis rays. The Detector Viewer will show a result similar to this:


The line camera (left panel in the image above) is catching significant irradiance close to the central pixel corresponding to 880 nm wavelength. This behavior is due to limited focusing of the spots on the pixel. However, this finding should be interpreted with care since we used geometric ray tracing without taking diffraction into account. There is only weak irradiance on the more distant pixels (note the logarithmic scale). When we take the whole surface behind the detector as shown in the right panel above, stray light is visible mostly distant to the line camera (black bar).


Optical spectrometer:

Previous Article: How to build a spectrometer – tolerancing


Was this article helpful?
1 out of 1 found this helpful



Article is closed for comments.