Skip to main content

Overview

To better understand User-Defined Functions, let’s create one using the LEO dataset from Tutorial 1. This function will use the camera_1.temperature Channel to convert the temperature from Celsius to Fahrenheit, allowing it to be reused consistently across a Calculated Channel and a Rule.

Create a User-Defined Function

  1. In Sift’s homepage, click the User-Defined Functions tab.
  2. Click New Function.
  3. In the User-Defined Function name box, enter:
        fl_tutorial_7_user_defined_function
    
    • User-Defined Function names must meet the following requirements:
      • No spaces
      • Must be 1 to 253 characters long
      • Must start with a letter
      • Use only letters, numbers, and underscores
  4. Replace fl (in fl_tutorial_7_user_defined_function) with your initials.
  5. In the Enter an expression box, enter the following:
        ($1 * 9/5) + 32
    
    • In this expression, $1 is a placeholder that refers to the first input Channel assigned to the function, in this case camera_1.temperature. Each input Channel can be assigned a data type, including
      • Number,
      • String,
      • Boolean, or
      • their constant equivalents (Constant Number, Constant String, Constant Boolean).
    • Constant types use fixed values defined in the function that do not change between evaluations, while non-constant types receive their values from Channels at the time the function is called.
      • For this function, $1 is defined as a Number since camera_1.temperature is a numeric Channel.
    • When a function needs to operate on more than one Channel, you can add additional inputs and reference them as $2, $3, and so on.
      • For example, if you wanted to calculate the temperature difference between two cameras in the LEO dataset, you could add camera_1.temperature as $1 and camera_2.temperature as $2, and write the expression as
        • $1 - $2.
  6. In the Preview section, click Select Run to preview.
  7. In the Run name or description box, enter the name of the created Run in Tutorial 1.
  8. Click Next.
  9. In the Channel name list, select camera_1.temperature.
  10. Click Preview.
  11. Click Save.