Solved

More than 12 wavelengths in TraceNSCData

  • 13 August 2021
  • 1 reply
  • 65 views

I am gaining a lot of functionality from using direct NSC raytraces via the ZOSAPI from python. However, this method appears to be limited to only the 12 available system wavelengths.

The limiting interface seems to be ZOSAPI.Tools.RayTrace.IRayTraceNSCData, which takes a wavelength index (referring to a system wavelength) as an input. I can in principle define 12 system wavelengths, do a trace, clear the wavelengths, assing 12 new ones, do a trace, aso -- and append the results to a complete result for higher spectral sampling. However, this appears mightly clumsy.

Knowing that NSC source traces can cover non-system wavelengths (if the source is setup respectively): is there a way to do the equivalent in direct raytraces (i.e. detached from NSC source objects)? Or if not, could this capability be added? It would give a lot more freedom to custom spectral raytraces via the ZOSAPI.

--S

icon

Best answer by Allie 17 August 2021, 17:49

View original

1 reply

Userlevel 6
Badge +2

Hi @Stefan.Trotzky 

When running an NSC Ray Trace, the wavelengths will always be defined by the sources in use and their corresponding definitions within the NSCE. It is not possible to overwrite this from within the INSCRayTrace interface. We can confirm this by observing the available properties and public member functions for this interface (click the image for a higher resolution):

 

 

If you want to trace more than 12 pre-defined system wavelengths, you will need to update the Source settings under Object Properties...Sources. In your case, a spectrum file will serve you well. A spectrum file allows you to define anywhere between 3 and 200 wavelengths and their respective weights in a TXT file format specified within the Help System file “The Setup Tab > Editors Group (Setup Tab) > Non-sequential Component Editor > Object Properties (non-sequential component editor) > Sources > Defining a spectrum file

 

 

The file can be generated in Python, saved to the folder Zemax\Objects\Sources\Spectrum Files, then applied via the API with these commands:

 

    sourceObj = TheSystem.NCE.GetObjectAt(1)

    sourceObj.SourcesData.SourceColor = ZOSAPI.Editors.NCE.SourceColorMode.SpectrumFile

    sourceSettings = sourceObj.SourcesData.SourceColorSettings._S_SpectrumFile

    sourceSettings.SpectrumFile = “myFile_NameOnly_NoPath”

    sourceSettings.SpectrumCount = 50

    sourceSettings.WavelengthFrom = 0.40

    sourceSettings.WavelengthTo = 0.65

 

Once the spectrum file is applied, the ray trace will consider the full list of wavelengths instead of the system wavelengths, as shown below:

 

 

Would this setup work for you?

Reply