• To Search the Seeq Knowledgebase:

# Search the Community

Showing results for tags 'formula'.

• ### Search By Tags

Type tags separated by commas.

### Forums

• Community Technical Forums
• Tips & Tricks
• General Seeq Discussions
• Seeq Data Lab
• Seeq Developer Club
• Feature Requests

### Calendars

• Community Calendar

### Categories

• Seeq FAQs
• Online Manual
• General Information

• Published
• Code
• Media

• 0 Replies

• 0 Reviews

• 0 Views

Found 51 results

1. ## How can I ignore incompatible units in Seeq Formula?

In some situations I do not want to enforce units of measure consistency in Seeq Formula calculations, or I simply want to do a series of unit conversions myself in a simplified way. How can I make my formula work as intended when units are not consistent and I still want to calculate the formula as is, because I've verified that it gives the results I need? For example, I want to calculate the Reynolds Number (=ρ*u*L/μ), a dimensionless quantity that helps predict fluid flow patterns, which is a function of 4 variables. I would prefer to check the units myself and leave them out of the formula: ρ = density (lbm /ft3 ) u = velocity based on the actual cross section area of the duct or pipe (ft/s) μ = dynamic viscosity (lbm /s ft) L = characteristic length (ft)
2. ## Automating Experimental Lookup Table Signal Generation

Is there a way to automate generating signals in Seeq using a experimental lookup table? As of now for a particular use case, we are able to generate signals from an experimental lookup table where the table was constructed in excel first and then copied/pasted into formula within a workbench where it is then executed to generate the signal. However, the data within the experimental lookup table is from a separate spreadsheet that gets updated per day so if a specific key has it's value changed, we would have to manually go into the lookup table and change that corresponding value for the specific key and then re-execute. I know in data lab, spy.pull() can have a calculation argument or you can specify a formula to be applied. Any help or suggestions would be much appreciated. Thanks!
3. ## video Calculating Rate of Change

This video demonstrates various formula functions in Seeq to calculate the rate of change or change in behavior in a process variable by leveraging the .derivative(), .runningDelta(), and .isDelta() formula functions.
4. ## video Batch Cycle Time Analysis

Batch Cycle Time Analysis is a core requirement for any batch process. In this example use case, we will explore how to identify various phases of the process, summarize the findings in tables and visualize data at scale using assets using Seeq.
5. ## tip Creating Periodic Conditions Relative to Now

For reporting purposes, I want to calculate statistics based on the most recent period(capsule) and display that along with the periods immediately preceding it. This can be done in Organizer using the custom date range by creating a Periodic Condition and selecting the capsule closest to or offset by one from the end. The same date ranges or capsules relative to now can be created in Seeq Workbench as well. Organizer: Workbench: We create the same condition as the above Organizer in Workbench by following the methods below. The first method defines how to create conditions for current and previous conditions for years, days, weeks, shifts. The second method includes an extra step that is necessary for current and previous months and quarters since the exact duration of these periods can vary based on the number of days each month. Method 1 - when the length of time in each period is definitive (e.g. year, week, day, shift). This example shows how to create conditions for "Current Week" and "Previous Week" 1. Create a Periodic Condition for "Weekly" using the Periodic Condition tool. 2. Create a Condition around the current time ("Now") using Formula --> condition(1min, capsule(now() - 1min, now())) 3. Use the Composite Condition tool to create a condition for "Current Week" when the Periodic Condition "Weekly" touches the tiny capsule at "Now". 4. Use Formula to create a condition for the "Previous Week" --> \$currentWeek.beforeStart(7d) Method 2 - when the length of time in each period is variable (e.g. month, quarter). This example creates a condition for "Current Month" and "Previous Month" 1. Create a Periodic Condition for "Monthly" using the Periodic Condition tool. 2. Create a Condition around the current time ("Now") using Formula --> condition(1min, capsule(now() - 1min, now())) 3. Use the Composite Condition tool to create a condition for "Current Month" when the Periodic Condition "Monthly" touches the tiny capsule at "Now". 4. Use Formula to create a Condition for the last day of the last period (in this case "Last Day of the Last Month") \$currentMonth.beforeStart(1d) 5. Use the Composite Condition tool to create a condition for the "Previous Month" when the Periodic Condition "Monthly" touches the "Last Day of Last Month". Content Verified DEC2023

7. ## Oil and Gas Use Case

Upstream O&G Customer Use Case Question: I have created a condition for when my well is shut-in based on a Value Search on the Down Hole Pressure (DHP). I've created another condition for the first hour after the well is shut-in. I would like to create another condition that runs from the end of my 1-hour after shut-in condition until the Down Hole Pressure returns to within 10% of it's Pre-shut-in value. Once I have isolated this period of time I would like to calculate an hourly rolling average over only that time period and do the same for my 1 hour after shut-in condition. ﻿
8. ## Comparing start and end values during an event

I want to identify the change in value of my signal after a change has occurred. My signal is generally constant (with typical noise) aside from when an event occurs during which there is a step change in the value of the signal.
9. ## Mean Kinetic Temperature (MKT) Calculation

How can i calculate the mean kinetic temperature (MKT)? In many industries (pharmaceuticals, food and beverage, etc.), mean kinetic temperature (MKT) is used to measure the temperature fluctuations of a material during storage and shipment. Mean Kinetic Temperature is a non-linear weighted average temperature that is set up to provide an impact on product stability. In general, product stability follows an exponential trend with temperature as it is inherently a decomposition reaction of the desired product. Therefore, the mean kinetic temperature takes into account the exponential reaction rate to determine the average temperature weighted by the kinetics of the reaction over time. The formula for mean kinetic temperature is: Where: is the mean kinetic temperature in Kelvin is the activation energy (in kJ mol−1) is the gas constant (in J mol−1 K−1) to are the temperatures at each of the sample points in kelvins to are time intervals at each of the sample points
10. ## How can I beat this error? Samples must be ordered by their keys!

When adding properties to capsules I sometimes get this error, it is fairly random across many different PI tags in different servers. I believe it may be related to seeq version R61.1.6 as I have only just started seeing it. It is consistent for the tag and time period that the error occurs for. This is the offending seeq formula. The signals in question trend just fine in Seeq. \$condition.setProperty('CO (minimum)', \$co, minValue()) .setProperty('CO (maximum)', \$co, maxValue()) .setProperty('O2 (minimum)', \$o2, minValue()) .setProperty('O2 (maximum)', \$o2, maxValue()) I am sure there is something that needs to be fixed here in Seeq or PI to resolve this correctly, but I am looking for a crafty workaround I can use in the short term while our IT support figures this out. Any ideas much appreciated!
11. ## Generating Formulas with DataLab as a form of Calculation Templatization

FYI, I'm very much self-taught in Python and don't use it more than a few times a month. I work as a technology licensor and our customers have provided datasets for us to work on. Most of our process units have enough similarities that we can templatize SEEQ formulas and then SEEQ workbooks. Thus once I've completed the following work for one customer, I'm 80% of the way done for the next 100+ customers. I'm struggling to get the formulas pushed back into SEEQ from the DataLab. I've imported CSVs of data into SEEQ until we get our PI-to-PI connect setup to pull directly from our customer to our PI Asset Framework and then pushed to our SEEQ instance. Since generating the template formulas is MUCH easier in Excel, I've created all the "Name", "Formula", "Formula Parameters" as strings in an Excel workbook and imported it as a Dataframe "calc_signals" into DataLab. Here's the relevant code: As you can see in Row 1, The Formula Parameter array is empty for the signal \$OFPOF. This is the formula generated for the row above, Row 0. This is because I haven't pushed it to SEEQ. You can see the error in the image below. Do I need to actually push each row to SEEQ and then search again to get this to work right? I don't have a huge set of calculations, but it seems there should be a better way. Once I sort through this error, I see that I will have troubles later since SEEQ automatically generates the signal variable name "\$OFPOF". Is there a way to override existing variable names and assign new calculations a variable name of my choice?
12. ## Formula results refresh

I write results of my simulation to historian and consequently I use them in Seeq as inputs for formulas. If I rewrite historian data (by running simulation again), then raw data in Seeq are reloaded, however results of formulas related to these inputs are not refreshed automatically. Only option I found is to change formula input to different variable and consequently configure correct input variable. How can I refresh formula outputs more efficiently?
13. ## Applying Seeq formula to part of the signals in my search dataframe when pulling the data

Hello, Does there exist a method to pull the data with some of them need to be applied with a formula? For example, I want to pull several signals all at once, including "SP", "MODE", "OUT", "PV". For SP and MODE, these attributes are categorical, so there are only four possibilities, for instance, for their values, which are 0, 1, 8, 9. However, with spy.pull() function, these attributes will be interpolated. So I have to pull first the data for "OUT", "PV", and again pull the data for "SP" and "MODE" with a parameter "calculation", as follows: # My current method is with 2 pull functions, but they took too much time for many signals my_pull_1 = spy.pull( my_search.query("Name not in ('MODE', 'SP')"), start=start, end=end, grid=grid, ) my_pull_2 = spy.pull( my_search.query("Name in ('MODE', 'SP')"), start=start, end=end, grid=grid, calculation="\$signal.toStep()" ) Since in my_search dataframe, there could be thousands of different "MODE" and "SP" signals, pulling the data twice will be very slow. Is there a way that I can pull only once the data, and apply the function to only part of the signals, like defining the formula parameter for the function? # what I would like to realize is something like this my_pull = spy.pull( my_search, start=start, end=end, grid=grid, formula="\$Mode.toStep()", formula_parameters={ "\$Mode": my_search[my_search['Name'] == 'MODE'] } ) Thanks in advance, Siqi
14. ## Representative capsules based on capsule duration / signal metrics or how to cast metrics to scalar

Dear community, I want to identify representative capsules based on the capsule duration. What I did so far is: 1. Identify capsules 2. Create a signal from condition that represents the capsule duration. 3. Calculate average capsule duration and percentiles of interest from this signal using metrics 4. Use these metrics to identify capsules that are within a certain range around the average or between two percentiles. What I would like to do next and could not accomplish so far is: By now step 4 works when entering the respective criterion to a value search by hand. Now I would like to do that dynamically, i.e., calculate the metrics for the displayed time range and directly get capsules that satisfy the criterion given above. After trying around for some time, this seems to be possible using formula: I tried to use the metrics directly, but the function I tried to use (InBetween) does not accept metrics as input. I also tried to calculate the metrics directly in formula to avoid wrong data types, but that was also not successful. It sems to get down to explicitly convert the signal metrics to scalar, but I also fail to do that. As I am quite new to seeq, I would appreciate if there were some hints on this: Is it possible? Did I choose the correct approach? Are there other, even simpler ways to accomplish that. Thanks in advance!
15. ## Create condition for past N batches

I am trying to create a condition that displays most recent 20 batches in the last month. Is there a good way to do this? I am currently using the below formula, but I get the error Uncertain Scalars cannot be used as thresholds for ScalarPredicates at 'isGreaterThanOrEqualTo', because it seems my \$earliest_start is always an uncertain value. \$capsule = capsule(now() - 1month, now()) \$selected = \$batch_condition.toGroup(\$capsule,CapsuleBoundary.EnclosedBy).pick(-20) \$earliest_start = \$selected.startKey() \$batch_condition.removeLongerThan(40h).keep('Start',isGreaterThanOrEqualTo(\$earliest_start)) Is there any way I can fix this issue or get the most recent 20 batches another way?
16. ## Replace missing data with zero

I have gaps in my signal with missing data and would like to replace the gaps with zero. Man with the yellow hat is not around and I could use some help.
17. ## Basic Formatting Tips for Workbench Formulas Pushed from Data Lab

When pushing Formulas to Workbench from Data Lab, you can use "\" and "\n" in a few different ways in the Data Lab code, to create a nicely formatted, multi-line Formula in Workbench: For the Formula pushed to Workbench, a \n can be used for a line return. This is valuable for creating multi-line Formulas with intermediate variable assignments, or for making lengthy, single lines of code more readable. For the Formula pushed to Workbench, a \ can be used just before a single quote, when you need to include a single quote in the Formula. This helps for example when working with string signals. On the Data Lab side, using a \ at the end of the line continues the code to the next line, helping with readability in Data Lab. These are illustrated in the Data Lab code below which pushes a condition Formula to Workbench: Editing the Formula in Workbench, the Formula appears as we desired:
18. ## Time Warping to Align Sample Points

This method demonstrates how to apply time warping to a signal which can shorten the time between sample points while retaining the signal’s characteristic shape. This is useful for batch processes where batches may have different durations or for aligning data from multi-step processes with different durations. Note that this method is distinct from the more complex Dynamic Time Warping. The following example is based upon the Area A Compressor Power signal available in the Example Data. A single condition was created to capture each compressor run, as shown in the following image. Step 1: Specify a Time Normalization Factor The user uses the Formula tool to specifiy a time duration (scalar value), set to 4 hours for this example. The compressor power signal for each compressor run will be normalized to this time duration. There is no single correct value; the value needs to be shorter than the minimum time duration for all signals to be normalized. // User specified time duration (scalar value). 4 hours Step 2: Create the Normalized Condition Use Formula to create the normalized Compressor Run condition based on the user-specified time normalization factor. This condition will be used later when the calculated signal delay is used for normalization. \$CompressorRuns.afterStart(\$nF) Step 3: Calculate the Run Duration Use the Signal from Condition tool to calculate the duration for each compressor run. This value will be used later for determining the calculated signal delay applied to each compressor run. Step 4: Calculate the Elapsed Time During Each Run Use the Formula tool to calculate the elapsed time during each compressor run. This value will be used later for determining the calculated signal delay applied to each compressor run. timeSince(\$CompressorRuns, 0.25min).convertUnits('h') Step 5: Calculate the Signal Delay Factor Needed for Time Warping Each sample (timestamp) for compressor power will be shifted to the left by a calculated amount to time warp the power signal from its original time period (Compressor Runs) to the normalized time period (Compressor Runs Normalized). The first sample point in each run will have no delay, and the last sample point will have the greatest delay. For example, if the original time period is 10 hours and we are normalizing to a time period of 4 hours, then the last sample point in the run will be shifted to the left by 6 hours (Delay Factor = -6 hrs). // This Formula first creates a signal with a value of 0 (default delay), then splice in the calculated delay during each compressor run. 0.toSignal(0.25min).convertUnits('hr').splice(\$ElapsedTime*(\$nF/\$RunDuration-1),\$CompressorRuns) At this point we zoom in to a single compressor run and use the Capsule Time view to better visualize the results of our intermediate calculations. For this compressor run lasting 10.9 hours, the Compressor Run Elapsed Time finishes at the correct value (10.9 hours) and the Delay Factor correctly decreases from 0 hours (beginning of run) to -6.9 hours (end of run). Step 6: Apply the Signal Delay to Time Warp the Signal Now that the appropriate delay factor is calculated for each sample point during the compressor runs, we apply it to the Area A Compressor Power signal using the delay() function in Formula. This generates the time warped signal called Compressor Power Normalized. \$CompressorPower.delay(\$delayFactor,24h).within(\$CompressorRunsN) When applying the signal delay, we are required to specify a maximum delay. This is important for the Seeq calculations going on in the background, so that the queries know how far back and forward to go when requesting input data. The maximum delay also provides a convenient way for the user to limit the applied delay, if they have some reason to do so. In our case, we just want the chosen value to be longer than the longest expected compressor run duration. Results Now that the compressor power signal has been normalized, Capsule Time view gives a nice comparison of the power signal behavior across the 3 runs contained in the Display Range:
19. ## IF - THEN formula building

Dear All, In python I have the following logic what I'd like to translate to Seeq formula. np.where((testdf['Signal_1']) < 0, testdf['Signal_2'], np.where((testdf['Signal_1']) < 30, testdf['Signal_2'], testdf['Signal_1'])) I know it would possible with capsules but it is only one leg of the whole solution and I think it's obscure to have 20-30 capsules for only one calculation what we use at others too.
20. ## Replace Gaps in Data with an Average Value from Previous Time Frame

FAQ: I have a signal with a gap in the data from a system outage. I want to replace the gap with a constant value, ideally the average of the time period immediately before the data. Solution: 1. Once you've identified your data gaps, extend the capsules backwards by the amount over which time you want to take the average. In this example, we want to fill in the gap with the average of the 10 minutes before the signal dropped, so we will extend the start of the data gap capsule 10 minutes in the past. This is done using the move function in Formula: \$conditionForDataGaps.move(-10min,0min) 2. Use Signal from Condition to calculate the average of the gappy signal during the condition created in step 1. Make sure to select "Duration" for the timestamp of the statistic. 3. Stitch the two signals together using the splice function. The validvalues() function at the end ensures a continuous output signal. \$gappysignal.splice(\$replacementsignal,\$gaps).validvalues()
21. ## guide Selecting Capsules within a Condition

In some cases you may want to do a calculation (such as an average) for a specific capsule within a condition. In Seeq Formula, the toGroup() function can be used to get a group of capsules from a condition (over a user-specified time period). The pick() function can then be used to select a specific capsule from the group. The Formula example below illustrates calculating an average temperature for a specific capsule in a high temperature condition. // Calculate the average temperature during a user selected capsule of a high temperature // condition. (The high temperature condition (\$HighT) was created using the Value Search tool.) // // To prevent an unbounded search for the capsules, must define the search start/end to use in toGroup(). // Here, \$capsule simply defines a search time period and does not refer to any specific capsules in the \$HighT condition. \$capsule = capsule('2019-06-19T09:00Z','2019-07-07T12:00Z') // Pick the 3rd capsule of the \$HighT condition during the \$capsule time period. // We must specify capsule boundary behavior (Intersect, EnclosedBy, etc.) to // define which \$HighTcapsules are used and what their boundaries are (see // CapsuleBoundary documentation within the Formula tool for more information). \$SelectedCapsule = \$HighT.toGroup(\$capsule,CapsuleBoundary.EnclosedBy).pick(3) // Calculate the temperature average during the selected capsule. \$Temperature.average(\$SelectedCapsule) The above example shows how to select and perform analysis on one specific capsule in a given time range. If instead you wanted to select a certain capsule of one condition within the capsule of a second condition, you can use the .transform() function. In this example, the user want to pick the first capsule from condition 2 within condition 1. Use formula tool: \$condition1 .removeLongerThan(1d) .transform(\$c -> \$condition2.removeLongerThan(1d).toGroup(\$c).pick(1)) The output: Content Verified DEC2023
22. ## Preventing Interpolation Across Batch/Capsule Boundaries

A question came up recently that I thought would be of wider interest: how can I prevent interpolation across batch/capsule boundaries? In batch processes, lab samples are often taken periodically throughout the course of a batch. When viewing these samples in Seeq, you may encounter times when samples are interpolating between batches rather than just within a batch. In the image below, the periods highlighted in yellow correspond to this unwanted interpolation. The following formula is one way of preventing this interpolation. \$signal corresponds to your signal of interest and \$condition corresponds to your batches you want to prevent interpolation across. combineWith( \$signal, Scalar.Invalid.toSignal().aggregate(startValue(), \$condition.removeLongerThan(40h), startKey()) ) This results in the following signal that has our desired behavior:
23. ## prediction Rolling Prediction

Seeq Version: R21.0.42+ Question: How can i create a signal that forcasts a value out into the future based on some rolling period of historical data? For this example say i want to predict the Area A Temperature 3 days in the future based on the previous week (7 days) of data.
24. ## tip Delaying or Shifting the Time of a Signal

Use Case Background In certain use cases, it can be advantageous to move data forward or back in time. You may move signals as part of a data cleansing step in a cause and effect analysis, prior to performing a regression, or simply as a more intuitive visualization. Here are some specific examples where this might be useful: Comparing a process variable to a process setpoint when the process variable lags the setpoint. Aligning inputs and outputs in unit operations where there is a known lag or residence time: In a plug flow reactor analysis, you may want to line up the outlet flow rate with the inlet flow rates after a known residence time. In a conveyor belt analysis, you may want to compare a widget created with an input variable upstream. Aligning lab data with process data. Moving a signal in time is easily accomplished in Seeq using the Formula tool and the function .move() Moving a signal forward in time 1. Search and select the relevant signal in the data tab and click to add it to the trend. 2. In the Tools tab, select the Formula tool. 3. Give the formula an appropriate name and enter the following formula. Make sure to match the variable name in the formula tool. Here, \$cp represents the Compressor Power signal I want to move. \$cp.move(3h) 4. Execute the formula. You will now have a new signal where the data is shifted forward in time. Moving a signal back (earlier) in time Follow steps 1-4 above, but in step 3, use a negative sign to indicate moving the signal earlier. \$cp.move(-3h) Moving a signal by the value of another signal Example use case: Oftentimes, lab data is associated with the time the lab technician completed the test and recorded the results instead of the time when the sample was obtained from the process, which could be hours or days earlier. In order to do a root cause analysis, it would be useful if the quality results lined up with when the sample was obtained. The data could be moved using a static value, like the examples above, but if there is relevant data that can be used to dynamically shift the time period based on when the sample was actually taken, that may be more accurate and useful. In this case, \$labData is the lab result with the original timestamp, and \$lagTime is the difference in time from when the sample is taken and when the sample result is recorded. By inputting this into the .move() function we can dynamically move the quality data to line up with the actual process conditions using the formula below. To do this, follow steps 1-4 above, but in step 3, use another signal as your first formula parameter and the second parameter representing the maximum you want to move any given sample. \$labData.move(\$lagTime, 5min) In the above example, \$labData will be moved by the value indicated in \$lagTime, up to 5 minutes, the maximum any sample will be moved. Content Verified DEC2023
25. ## Converting a number to a binary code

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. Result:
×
×
• Create New...