Support

Applying a color weighting function during optimization

Written by Admin | Aug 30, 2021 4:00:00 AM

Question

I notice in the Optimization Conditions dialog box (see the menu item "Optimize>>Optimization Conditions"), that I can apply field, pupil and color weighting functions. How can I do this?

Synopsis

Applying a color weighting function during optimization

Symptoms

You can apply a custom color/wavelength weighting function (written in CCL) that will be implemented when you choose the "Generate Wavelengths" option in the Wavelength Data Editor (this data may later be used in creating the optimization error function). This Knowledge Base item will address the specifics of how to apply and customize this color weighting function. Implementing field and pupil weighting functions will be the subject of separate Knowledge Base entries.

Solution

An example CCL routine for the color weighting function can be found inside the "asyst_tools1.ccl" file in your ".../public/ccl" folder. The command is called "color_wt" and can be found with a text search in the CCL file. This command already contains an equation defining a default weighting function. For demonstration purposes, we will use this default weighting function without altering the file. A brief description of how to alter the weighting function will be identified below. Demonstrating the Color weighting function: We will open a simple lens, and generate a set of wavelengths both with and without a color weighting function applied. We will inspect the wavelength weighting before and after.
  1. Load a typical lens such as the "TRIP.len" lens in your ".../private/len" folder.
  2. First, we need to generate a set of sampled wavelengths.
    • Select the "Wavelength" button from the opened "Surface Data Spreadsheet". This will open the "Wavelength Data Editor".
    • Click on the "Generate Wavelengths" button and answer the resulting questions with the default values. This will automatically generate a sequence of three wavelengths and weights sampled using Gaussian Quadrature over the wavelength range from 0.4 to 0.7 microns.
    • Note that the data in the Wavelength Data Editor has changed to: Wavelength Weight 0.505545 0.977595 0.418886 0.390364 0.644535 1.000000
    • Close the Wavelength Data Editor by clicking on the Green "Check" in the upper left corner of the editor window.
  3. Now we will apply the color weighting function.
    • Choose "Optimize>>Optimization Conditions" from the OSLO menu.
    • In the resulting dialog, enter "color_wt" (no quotes) in the cell next to "Command for color weighting:"
    • Click on the Green "check" in the upper left corner of the window to accept the changes you have made.
    • As an alternative to using the "Optimization Conditions" dialog, you can issue the following command on the command line: opcw color_wt;
  4. Now we will re-generate a sampling of wavelengths and inspect how the wavelength sampling has changed
    • Generate Wavelengths in the same way you did in step #2 above.
    • Note that the data in the Wavelength Data Editor has changed to: Wavelength Weight 0.518982 1.000000 0.434658 0.127632 0.614795 0.705439
    • The falloff in wavelength sensitivity is much more pronounced towards the ends of the wavelength range.
    • This wavelength sampling data may later be used in creating the optimization error function.
Changing the Color weighting function: If you want to change the calculation of the Color weighting function, it is recommended that you copy the "color_wt" function from the "asyst_tools1.ccl" file in your ".../public/ccl" folder, into a new CCL file in your ".../private/ccl/" folder (the files in your private folder will not be overwritten in a future release of OSLO).
  1. Copy the color_wt function: double color_wt(double lambda) // hlp: See Fig. 9 (approximate photopic response of the human eye). // kwd: human eye, color, weights // cat: general tools, math functions { treturn exp(-150.0*(lambda-0.550)*(lambda-0.550)); }...from the "asyst_tools1.ccl" file to your new CCL file in your ".../private/ccl" folder.
  2. Once you have created your new CCL file, save it and make sure that your private CCLs are compiled ("Tools>>Compile CCL" in the OSLO menu). The message: *CCL COMPILATION MESSAGES: No errors detected ...in the text window indicates that the new CCL file was created properly.
  3. Now you can edit the contents of your new CCL file.
    • Note that "lambda" is the wavelength value that is passed to the function.
    • The result of the equation: exp(-150.0*(lambda-0.550)*(lambda-0.550));...is the weighting factor that is passed back to OSLO and used.
    • Make sure that the new CCL file name ends with the *.CCL delimiter
    • You can name the new CCL file that same name if you like ("asyst_tools1.ccl"), or you can change it. It is the names of the commands inside the file that are important.
    • You can even change the name of the command from "color_wt". Just make sure that the name is changed in both the CCL file as well as the cell in the Optimization Conditions dialog.
    • You can place more than one CCL command in each CCL file. So you can combine multiple weighting functions in the same CCL file.
    The color weighting function is only available in OSLO Premium