Jump to content

Teddy

Administrators
  • Posts

    95
  • Joined

  • Last visited

  • Days Won

    24

Posts posted by Teddy

  1. When I have created valueless metrics in the past, I have taken advantage of the number format setting in the item properties tab.  You can do this with the following steps.
     

    1.       Remove the units from the signal you want to use as the basis for your metric.  See screenshot below for details.
    Capture1.PNG

    2.       Fill out the metric as you normally would with the desired thresholds.  See example below.
    Capture3.PNG
     

    3.       After creating the metric go into the item properties of that metric by clicking on the “I” icon in the details pane.  Once in the items properties tab for the metric click override number format and set the number format to “ “.  (note there is a space between the quotes)  See screenshot below for details.

    Capture4.PNG

    • Like 2
  2. Recently an interesting question came up about converting a number to binary within Seeq. The goal was to convert an integer (0-255) to an 8-bit binary number.  This can be done by dividing the integer by 2, 8 times and keeping track of the remainders.  More information about binary numbers can be found here. https://en.wikipedia.org/wiki/Binary_number

     

    Note: For this conversion to work the input signal needs to be an integer between 0 and 255, also it cannot have units.

    Below is the formula syntax that will do the conversion.

    $i=$signal.ceiling().setUnits('')
     

    $div1=($i/2).floor()

    $div2=($div1/2).floor()
    $div3=($div2/2).floor()
    $div4=($div3/2).floor()
    $div5=($div4/2).floor()
    $div6=($div5/2).floor()
    $div7=($div6/2).floor()
    $div8=($div7/2).floor()

     

    $rem1=($i/2-$div1).ceiling().toString()
    $rem2=($div1/2-$div2).ceiling().toString()
    $rem3=($div2/2-$div3).ceiling().toString()
    $rem4=($div3/2-$div4).ceiling().toString()
    $rem5=($div4/2-$div5).ceiling().toString()
    $rem6=($div5/2-$div6).ceiling().toString()
    $rem7=($div6/2-$div7).ceiling().toString()
    $rem8=($div7/2-$div8).ceiling().toString()

     

    $rem8+$rem7+$rem6+$rem5+$rem4+$rem3+$rem2+$rem1

     

    Below is a screenshot of the syntax in the formula tool.

    Capture1.PNG

    Result:

    Capture2.PNG

    • Like 1
    • Thanks 1
  3. The replace operator can be applied a signal without a transform.  Using the replace function without the transform will be less computationally expensive, resulting in better performance. Both ways will get to the same answer.

    Syntax for replace function without transform:

    $signal.replace('/(\\d+)_\\d+_\\w+/', '$1')

     

    • Like 2
    • Thanks 2
  4. Ali, 

    To combine them into one signal you can use the following syntax in the forecast formula from step 2. 

    $signal.forecastConstant(365d) + 0.toSignal().splice($IncreasingTemp,$IncreasingTemp.isValid())

    Screen shot for details:

    CaptureA.PNG

    Note: This will result in a completely uncertain(dashed) signal. This is because of it's dependence on now() in the first formula.

    Hope this helps,

    Teddy

  5. Hello Ali,

    If I understand your question correctly you want to splice a signal that increase 2°F per to the end of some temperature signal such that the newly spliced signal starts at the last known value of your temperature signal. 

    1. The following syntax in the formula tool will create a signal that increases 2°F per day starting at now.

    (timeSince(toTime(now()), 1d)*2).setUnits('F')

    Capture.PNG

    2. Then to splice them I suggest following syntax.

    $signal.forecastConstant(365d) + $IncreasingTemp

    Capture1.PNG

    The final result:

    Capture2.PNG

    Hope this helps,

    Teddy

  6. Ali,

    I will preface this with saying that calculating a yearly rolling average can be slow. It requires looking at a lot of data.

    You can create the condition you are looking for with the formula tool. The following syntax will generate a condition with a capsule everyday extending 1 year. 

    periods(1year,1day)

    See screen shot below for formula details.
    image.png

    Lastly you can calculate the rolling average with the signal from condition tool.  See screen shot below for how to set up a yearly rolling average.

    image.png


    Hope this helps,

    Teddy
     

     

    Content Verified FEB2024

    • Like 1
  7. To generate and display curves in Seeq, a formula representing the shape of the curve needs to be created and added to an XY Plot.  There are two methods to achieve this.

    Method #1 - Use the Plot Curve Add-on

    1. Create a .csv file with a tabular representation of the curve.  This can be done with a tool such as https://apps.automeris.io/wpd/

      image.png
       
    2. Install the Plot Curve Add-on - https://seeq12.github.io/seeq-plot-curve/
       
    3. Add "Flow" and "Head" signals in Workbench and navigate to an XY Plot View
      • If you don't have a "Head" or "Flow" signal tag, you can use Formula to calculate them and use the output of that calculation as the associated signal.

         
    4. Launch the Plot Curve Add-on via Tools->Add-ons

      image.png
       
    5. Load the csv containing the curve data by clicking the "Load" button in the Add-on and navigating to the location of the csv
       
    6. Identify the Independent variable (e.g., Flow) and Dependent Variable (e.g., Head) from the csv, as well as the Independent Signal (e.g., Flow Signal Tag) and Output Signal Name (e.g., 1800 RPM Curve)
      • image.png
         
    7. You can also specify the curve polynomial fit that best matches the shape of the curve in the "Plot Curve Variables" section
       
    8. Repeat step 6 and 7 for EACH curve
       
    9. Push the curves to Seeq by clicking "Push to Seeq".  The formula(s) for the curve(s) will be added to your Display Pane.
      • You will have the option to only push the active curve, or all the curves configured
         
    10. In Workbench XY Plot view, click the f(x) button to add trend line(s)s to the plot

      image.png
       
    11. Select the Trend Line(s) to add confirm the associated independent signal (e.g., Flow) is correctly associated.  Close the modal.

      image.png
       
    12. The curve(s) will be added to the XY Plot.  Adjust the colors as needed via the Details Pane.

      image.png

    Method #2 - Manually create the curve using Formula

    1. Determine the X&Y components of the curve. This can be done with a tool such as https://apps.automeris.io/wpd/
    2. Enter or paste the components in columns A and B in the CurveFitter excel sheet. See screenshot below for details.  The CurveFitter file can be found here:  CurveFitter.xlsx

      image.png
       
    3. Once the new Flow and Head data has been pasted into excel copy the contents in from D2 to E9 and paste them into the Seeq formula tool. See screenshots below for copy paste details

      Copy:
      image.png

      Paste:
      image.png
    4. Paste the following syntax in the same formula under the coefficients. Be sure that the flow signal has the variable name “$flow”.

      $f=$flow.remove($flow.isNotBetween($lower,$upper)).setunits('')

      $coeff4*$f^4+$coeff3*$f^3+$coeff2*$f^2+$coeff1*$f+$const

      Final formula view:
      image.png
       
    5. Add the line to the XY Plot by selecting the f(x) in the XY Plot tool bar and pick the correct item from the select item dropdown.

      image.png
       
    6. If adding more than one curve, then click on the item properties “i” of the first curve and click on duplicate. Once in the formula tool copy the new coefficients from excel replacing the old one and hit execute. Follow step 5 to add the curve to the plot.

      Final View:
      image.png

     

    Note that both methods yield curves expressed as formula which can be used for calculations like any other signal in Seeq (e.g., calculate curve head vs actual, etc).

    • Like 4
    • Thanks 1
  8. FAQ: Why does the derivative look funny?

    When taking a derivative and the result looks like the screenshot below, but a smoother signal is expected it is likely that the input signal is step interpolated.  To verify this, click on the item properties “I” on the input signal and check the interpolation method.

    Capture1.PNG

    Item Properties View

    Capture2.PNG

    The interpolation method can be corrected by simply adding toLinear() in front of the derivative. See screen shot below of the formula.

    Capture3.PNG

    Final Results

    Capture4.PNG

    • Like 3
  9. Here is the syntax for a polynomial regression based condition. 

    $condition.removeLongerThan(15h).transform($cap->{
    
            $model=$signaltomodel.regressionModelOLS(group($cap), false, $Time, $Time^2)
            $cap.setProperty('Coeff1',$model.get('coefficient1'))
                  .setProperty('Coeff2',$model.get('coefficient2'))
                  .setProperty('Intercept',$model.get('intercept'))})

    Below is a screenshot of it setup in the formula tool. 

    Capture9.PNG

    The result
    Capture10.PNG

    • Like 2
  10. The following steps will create a prediction model for every capsule in a condition.

    Step 1.  pick a condition with capsules that isolate the desired area of regression.  Any condition with non-overlapping capsules will work as long as there are enough sample points within its duration. For this example, an increasing temperature condition will be used.  However, periodic conditions and value search conditions will work as well.

    Step 2. Create a time counter for each capsule in the condition.  This can be done with the new timesince() function in the formula tool. The timesince() function will have samples spaced depending on the selected period so it is important to select a period that has enough points to build a model with.  See below for details on the timesince() formula setup.

    Capture1.PNG

    Step 3. In this step a condition with capsule properties that hold the regression constants will be made.  This will be done in the formula tool with one formula.  The concept behind the formula below is to split the condition from step one into individual capsules and use each of the capsules as the training window for a regression model. Once the regression model is done for one capsule the coefficients of the model are assigned as properties to the capsule used for the training window.  

    The formula syntax for a linear model-based condition can be seen below.  An example of a polynomial regression model can be found in the post below.

    $Condtition.removeLongerThan(24h).transform($cap->
                 {
                  $model=$SignalToModel.validValues().regressionModelOLS( group($cap),false,$Time)
                  $cap.setProperty('Slope',$model.get('coefficient1'))
                  .setProperty('Intercept',$model.get('intercept'))})
     

    Below is a screenshot of how the formula looks in Seeq.

    Capture2.PNG

    Note: The regression constants can be added to the capsule pane by clicking on the black stats button and selecting add column. Below is a screen shot of the results.

    Capture3.PNG

    Step 4. Once a condition with the regression coefficients has been created the information will need to be extracted to a signal form. The following formula syntax will extract the information. This will need to be repeated for every constant from your regression model. e.g.(So for a linear model this must be done for both the slope and for the intercept.)

    The formula syntax for extracting the regression coefficients can be seen below.

    $signal=$Condition.transformToSamples(
      $cap -> sample($cap.getmiddle(), 
                  $cap.getProperty('Intercept').toNumber()), 1min)
    
    $signal.aggregate(average(),$Condition,durationKey())

    Below is a screenshot of the formula in Seeq.

    Capture4.PNG

    Below is a screenshot of the display window of how the signals should look.

    Capture5.PNG

    Step 5. Use the formula tool to plot the equation. See screenshot below for details.

    Capture6.PNG

    Final Result
    Capture8.PNG

    • Like 3
  11. To create the same shift schedule without daylight savings or excluding the effect of daylight savings the following steps can be used.

    Step 1. Use the periods() function to create the 28 day cycle.  This time 12 hour capsules will be used since there is no need to use the shift() function to deal with daylight savings.  This will be the condition used to create all four shifts.  The same excel trick that was used above can be used here as well. See the formula syntax below for details.  

    //-----inputs-----
    $TimeAdj=12h   //This allows the alignment of shifts depending 
                   //on the start date
    
    //-----Calculations-------
    
    //Note: The syntax below was set up with excel and copied in
    $s1    =periods(12h,28d,'2018-01-01', 'GMT').move(0h)
    $s2    =periods(12h,28d,'2018-01-01', 'GMT').move(24h)
    $s3    =periods(12h,28d,'2018-01-01', 'GMT').move(108h)
    $s4    =periods(12h,28d,'2018-01-01', 'GMT').move(132h)
    $s5    =periods(12h,28d,'2018-01-01', 'GMT').move(156h)
    $s6    =periods(12h,28d,'2018-01-01', 'GMT').move(216h)
    $s7    =periods(12h,28d,'2018-01-01', 'GMT').move(240h)
    $s8    =periods(12h,28d,'2018-01-01', 'GMT').move(348h)
    $s9    =periods(12h,28d,'2018-01-01', 'GMT').move(372h)
    $s10    =periods(12h,28d,'2018-01-01', 'GMT').move(432h)
    $s11    =periods(12h,28d,'2018-01-01', 'GMT').move(456h)
    $s12    =periods(12h,28d,'2018-01-01', 'GMT').move(480h)
    $s13    =periods(12h,28d,'2018-01-01', 'GMT').move(564h)
    $s14    =periods(12h,28d,'2018-01-01', 'GMT').move(588h)
    
    // Now that all 14 of the shifts have been set for their 28day 
    // cylce they need to be combined
    
    combinewith($s1,$s2,$s3,$s4,$s5,$s6,$s7,$s8,$s9,$s10,$s11,$s12,$s13,$s14).move($TimeAdj)

    Note: The time zone specification ensures that you will exclude daylight savings.

    Formula as seen in Seeq:

    image.png

    Step 2. Use the move() function to align all of the shifts correctly.  See screen shots below for details.

    Shift #1 No offset:

    image.png

    Shift #2 21 day offset:

    image.png

    Shift #3 14 day offset:

    image.png

    Shift #4 7 day offset:

    image.png

    Final result:

    image.png

    • Like 1
  12. FAQ: How do I create a condition for operational shifts if they alternate days and hours? e.g. (The EOWeO schedule)

    The following solution will keep the start times the same regardless of daylight savings.  So, there will be an 11-hour shift in March and a 13-hour shift in November. For areas that don’t follow daylight savings a simpler solution can be found further below.

    Overview: To achieve the results described above the shift() function will need to be used in order to create the desired effects around daylight savings.  If there was no daylight savings the periods() function would provide a  simpler solution. 

    Step 1. Create a condition for all night and day shifts. This can be done with the periodic condition tool. Note: This step will set the shift change over times, so it is important to ensure they are correct. e.g. (6:00 am and 6:00 pm et).  See screenshots below for details of how to create the day and night conditions.

    Day setup:

    image.png

    Night setup:

    image.png

    Results of step 1.

    image.png

    Note: This can also be done with 8-hour shifts as well by using 3 conditions instead of 2

    Step 2.  Create a condition with short capsules that contains the pattern of the shift schedule.  This condition will be used to select the correct shifts from the conditions made in step 1. Only one of these conditions will need to be defined since the shift schedule for EOWeO follows a 24-day pattern and each shift group is off set 7 days from the last. This condition was created with the formula tool with some help from excel. The following was a table set up in excel that was copied into the formula tool.

    image.png

    Note: The number format in columns B and D should be set to text to avoid problems.

    The numbers in column C are the offset from the start of the 28-day cycle to that particular shift. Altering these numbers would allow you to have different schedules other than EOWeO.  It should be noted that more rows can be added by just dragging down the auto-fill in excel and setting the offset time in column C.  See the code snippet below for all of the formula details and the result of pasting from excel.
     

    //-----inputs-----
    
    $TimeAdj=3.5d //This allows the alignment of shifts depending 
                  //on the start date
    
    //-----Calculations-------
    
    //Note: The syntax below was set up with excel and copied in
    $s1    =periods(1sec,28d).move(0h)
    $s2    =periods(1sec,28d).move(24h)
    $s3    =periods(1sec,28d).move(108h)
    $s4    =periods(1sec,28d).move(132h)
    $s5    =periods(1sec,28d).move(156h)
    $s6    =periods(1sec,28d).move(216h)
    $s7    =periods(1sec,28d).move(240h)
    $s8    =periods(1sec,28d).move(348h)
    $s9    =periods(1sec,28d).move(372h)
    $s10    =periods(1sec,28d).move(432h)
    $s11    =periods(1sec,28d).move(456h)
    $s12    =periods(1sec,28d).move(480h)
    $s13    =periods(1sec,28d).move(564h)
    $s14    =periods(1sec,28d).move(588h)
    
    // Now that all 14 of the shifts have been set for their 28day 
    // cycle and they need to be combined now
    
    combinewith($s1,$s2,$s3,$s4,$s5,$s6,$s7,$s8,$s9,$s10,$s11,$s12,$s13,$s14).move($TimeAdj)

    As seen in Seeq:
    image.png

     

    Step 3.  Combine the Night and Day conditions with the composite condition tool to make one condition for all of the shifts. See screenshot below for details.

    image.png 

    Step 4.  Use the condition created in step 2 to select the appropriate capsules of the combined day and night condition.  This can be done with the composite condition tool.  This will be shift #1.  

    Note: The $TimeAdj variable in the long formula used to create the shift pattern may need to be adjusted to ensure correct alignment.

    image.png 

    Step 5.  Create the other shifts' selection conditions by using the move() function in the formula tool to move the condition created in step 2 for all the other shifts. In this case the condition will be moved three times by 7, 14, and 21 days to get the other three shift selection conditions.

    Formula for 7 days:

    image.png

    Formula for 14 days:

    image.png

    Formula for 21 days:

    image.png

    Step 6.  Repeat step 4 for the rest of the shifts. Note there will be no need to adjust the timeAdj variable this time.

    image.png

    Final result:

    image.png

     

    • Like 1
    • Thanks 1
×
×
  • Create New...