Writing Custom Python Scripts in OmniView Part II

Writing Custom Python Scripts in OmniView Part II

In part I of Writing Custom Python Scripts in OmniView, we discussed setting up a basic python script and determine the absorbance value at a specific wavelength. As shown in our training videos we recommend customers use Unscrambler Prediction Engine to implement PLSR or PCA calibrations. We also have a video demonstrating how to turn on additional statistics, such as Mahalanobis Distance.

When additional statistics are turned on, instead of returning a single floating point value, the Unscrambler Prediction Engine will return a python dictionary or array of answers (predicted properties). If you are operating near zero, the calibration may return a negative result. In many applications the answer, such as the concentration of water in a solvent, the real world value can never be less than zero. Therefore you may want to add some logic to your python method script to overwrite negative values and set them to zero.

The code below can be added to your custom python method script. Please note the tab indentation. Proper spacing is important in python syntax.

answer = unscramble(au)

for key in answer.keys():
    if answer[key] < 0:
        answer[key] = 0

Interested in learning more? Check out the training videos we have on our youtube channel.

Leave a Reply

Your email address will not be published. Required fields are marked *

Questions? We’re here to help.