# Shamus C

Super Seeqer

46

14

1. ## Delaying or Shifting the Time of a Signal

Brett, There is not currently a direct equivalent function that would allow you to move a capsule using a variable amount. However, below is a formula that does the same thing in a couple of steps. It comes with a couple of caveats however If you have capsule properties on the first calculation they will not be transferred over to the delayed signal This formula will delay the start and end of the capsule the same amount as defined by the value of your delay signal at the capsule start. You could probably extend this to do more complex transformations if needed \$step1 = \$condition.aggregate(totalDuration("min"), \$condition, startKey(), 0s) \$step2 = \$step1.move(\$timeShiftSignal,2h) \$step2.toCapsules(\$sample -> capsule(\$sample.key(),\$sample.key()+\$sample.value()),30d) Let me know if this helps get you on the right track. Also I am curious to understand more about your use case so that we can help improve the built-in functions in the future. Shamus
2. ## Create your own formula v50

Eric, There is not currently a way to add stats to the capsule panel. What kind of statistics are you interested in adding?
3. ## The starting time of the average signal

The Scorecard tool does not have all of the timezone options in it and instead uses the default server time. The easy work around is to create a monthly condition using the Periodic Condition Tool with our desired timezone and then switch your Scorecard to a "Condition" type using that new monthly condition.
4. ## Set property for capsules

I am sure that there are probably a few ways to do this but here is a solution I came up with \$conditionToSamples = \$condition.aggregate(count(),\$condition,durationkey()) \$countingRange = condition(capsule('2020-01-01T00:00Z', '2023-01-01T00:00Z')) \$countSignal = \$ConditionToSamples.runningsum(\$countingRange) \$condition.setProperty('Capsule Count',\$countSignal,average()) Step by Step Outline \$conditiontoSamples - Take your input condition and turn it into a signal with a value of 1 whenever the condition exists \$countingRange - the range we are going to count these capsules over. In this example beginning of 2020 to beginning of 2023 \$countSignal - Create a signal that counts up those values for each condition starting at the start date Set the value of the \$countSignal as a property on your original condition
5. ## Removeoutliers function on signals with Gaps

Today in Office Hours I ran into an interesting problem when using the removeoutliers() function on a signal that also had gaps in the data. If you use the function directly on a signal of this type it will not detect the outlier point as you might expect. However there is a quick work around that I will detail below. The signal looks like the one above where the outlier was right after a data gap. In order to work around this problem we chained together a couple of functions in formula. \$gaps = \$signal.isValid() \$signal.validValues().removeOutliers().within(\$gaps) Step 1 - create a condition \$gaps that captures only the periods of time that contained valid data in the original signal Step 2 - use the validValue() function to ignore the gaps in the original signal, next run the removeoutliers() function finally add back in the gaps by using the within function
6. ## Exporting Organizer dashboard to Powerbi

There is not a mechanism to move the graphics directly to PowerBI but you can move the data that developed the graphs using the oData export https://support.seeq.com/space/KB/112868662/OData Export#Example-Importing-to-Microsoft-Power-BI-(Authenticate-Using-Seeq-Username-and-Password) This will require building the graphics again inside of PowerBI and I would recommend using the Signal export on a fixed grid in order to get datapoints that are at the exact same timestamp which will make life in PowerBI much easier Shamus
7. ## View User Information Information from Data Lab

As an Admin you can view additional user information not available through the Administration panel through Seeq Data Lab. The attached script will give you a dataframe containing the last login date for any given user. View All User Data (2).ipynb
8. ## Way to set user login credentials in the while building worksheet from URL and way to delete the worksheet/workbook from URL

I know that this is an old post but I wanted to give an update. Unfortunately there is not currently a way to pass user credentials or delete worksheets/workbooks using the URL builder functionality.
9. ## Filtering short capsules

There is an easy way to filter a condition to only keep capsules that are either longer or shorter than a specified duration. In formula just use one of the following function \$myCondition.removelongerthan(5h) or \$myCondition.removeshorterthan(5h)
10. ## Power BI and SEEQ compatibility

Kenny, There is not currently a way to delete oData exports for non-admins. However, the exports do not put any load on the Seeq system unless they are being used by an external system (PowerBI, Tableau, etc) To answer your second question we are creating a new export url endpoint every time someone runs the tool in workbench. These oData feeds are in active development and we have plans for making the creation and maintenance of them easier in upcoming releases.
11. ## Clear Cache on a Single Signal

I wanted to put together a quick guide on how to clear the cache for a particular signals inside of Seeq Workbench. Come common reasons for wanting to clear the cache on a signal Data source caching is turned on and you have changed a calculation in your source database You have added prior history to a tag and filled in a gap Steps to Clear the cache Open Item Properties Open Advanced Settings Click "Clear Cached Values"
12. ## Changing Workbench or Topic Ownership in R52+

In R52+ we have replaced the concept of document owner with folders for each individual users. There are two slightly different methods for changing ownership depending on if the document orignates from a User's folder or the Corporate Drive If you want to change the owner of a document that has not been published to the corporate drive you need to move that document from the existing user's folder to your target new users. The gif below gives a quick overview of the process. If the document is in the Corporate Drive admins can edit the document and directly transfer ownership to another user. The document owner for Topics is important as the document owner will act as the user permissions to render all of the charts and graphics. The document owner thus must have access to all the datasources in a topic in order for it to render properly.
13. ## Create a Table of a Signal's Timestamps and Values

We have had a couple of users ask for a method to create a table of timestamps and values for each of the samples in a signal. Below is a quick method to create such a table using the new features available in versions R53+ This method in general makes the most sense for finding the timestamps of discrete points but could be used for signal Step 1: Create a condition with a capsule for every sample point \$signal.toCapsules() Step 2: Move to the table view and select the "Condition" option The general settings you are going to want to pick are Condition mode Headers = Start Time Columns Capsule Property = Value Final Product:
14. ## Remove Similar/Repeated Data

There is a quick little trick to do this by combining two formulas together \$signal.tocondition().tosignal() What this formula does is create a condition .tocondition() where each capsule starts when the value in your ID signal changes (eliminating duplicate values) and then transforms those capsules back into a signal using .tosignal() Let me know if this example helps solve your question
15. ## Plotting Signal Metadata as Scalars

Currently there is not a way inside of Seeq formula to access a signal or condition's metadata for use in a formula. This comes up when users would like to do things like plot a special property that has been added to a signal from an external system such as OSIsoft Pi AF. There is a simple way to add these properties as scalars inside of Seeq DataLab however using the example notebook below. The key pieces are to make sure to include the all_properties=True flag in the spy.search() command and then to define your new signal names in your metadata dataframe Push Signal Metadata as Scalars.ipynb
16. ## Real-time Storage Emptying Time/Date Calculation

Can you see the forecast signal ever crossing your empty threshold. You can visually mark your lower limit on the trend by creating a Scalar value in formula
17. ## Importing Electric Time of Day Pricing

There is also a way to complete this inside of Seeq Formula. As a warning as rates change over the years these formulas could get longer and longer as you splice in new rate schedules against old rate schedules. Below is a formula for a rate schedule with a Winter Rate & Summer Off/Mid/High Rates. You could expand this to weekends and weekdays as well if needed \$Summer = periods(6months, 1year, "2020-05-01T00:00:00","US/Pacific") \$Winter = periods(6months, 1 year, "2020-11-01T00:00:00","US/Pacific").setProperty('Rate',0.10) \$SummerHighPeak = (shifts(16, 5, "US/Pacific") and \$Summer).setProperty('Rate',0.18) \$SummerMidPeak = (shifts(14, 2,"US/Pacific") and \$Summer).setProperty('Rate',0.16) \$SummerOffPeak = (\$Summer -(\$SummerHighPeak or \$SummerMidPeak)).setProperty('Rate',0.12) \$AllPeriods = CombineWith(\$Winter, \$SummerHighPeak, \$SummerMidPeak, \$SummerOffPeak) \$AllPeriods.toSignal('Rate').setUnits('\$')
18. ## Real-time Storage Emptying Time/Date Calculation

You can also re-create the same effect at the past() operator in offline situations or in older versions by modifying the formula to remove the period of time that there is data in the original source signal \$LowerLimit = 0% \$AboveLowerLimit = \$forecast > \$LowerLimit \$AboveLowerLimit - isvalid(\$original)
19. ## Re-creating a Prediction Model from Regression Coefficients

Another common question through the support portal this morning that is of general interest To help with this example I am going to create a quick polynomial prediction using Data from Area C in the example set. Our target is going to be to try to predict compressor power as a function of all of the input weather signals If you wanted to re-create this prediction model in excel or another tool you need the coefficients from block #1 in the screenshot above and the y-intercept from block #2 in the screenshot. Inside of the workbench tool you will see rounded values for each of the coefficients and intercepts but the full values are available when you copy them to the clipboard by clicking the little button highlighted in red. To fill out the example in excel the formula will look like the following \$temperature^2 * -0.000230 + \$temperature * 0.0607 + \$WB^2 * 0.000646 + \$WB * -0.101 + 6.5946 A final point to mention here is that for multi-variable regressions with many input signals it is important to take a minute and evaluate the p-values listed in the coefficient table. If the p-values for any coefficient are above 0.05 it is best practices to rethink if that signal needs to be included in the model at all or if you may need to perform data data cleansing or re-alignment to create a better performing model. Good blog post on P-values - https://medium.com/analytics-vidhya/understanding-the-p-value-in-regression-1fc2cd2568af Great reference post on how to optimize regression models using time shifting -
20. ## Real-time Storage Emptying Time/Date Calculation

Sam, You can pretty easily forecast the value from now till you empty setpoint and then display the result as a Capsule on the screen as well as a Time/Duration in a Scorecard/Table and have all the results update in real-time For my example I am going to use some example data but this should look very similar for your use case Step 1 - Create a Forecasted Value - This function may not work on exactly as you expect on historical data depending on your datasource \$signal.forecastLinear(1.5h,5d) //Train in the last 1.5 hours of data //Project 5 days into the future Step 2 - Create a condition that captures the time between now() and when you fall below your "empty" threshold. This step will only work for online data as it is using the past() operator \$LowerLimit = 0% \$AboveLowerLimit = \$fv > \$LowerLimit \$AboveLowerLimit - past() Step 3 - Create a Scorecard to Quantify the time between now and full and display it in a table. This uses the "Condition" mode in the Tables view and a Condition scorecard type
21. ## Best Practices for Scheduled Python Calculations

In Seeq version 52 and beyond we have introduced scheduled notebooks which opens up a new world of signals calculated using purely python and pushed into the seeq system on a schedule. These scheduled executions can be really powerful but also can place huge loads on the entire Seeq system if your notebooks are not designed with scheduled execution in mind. Attached is a notebook with some of our current thoughts on best practices to minimize the load on the system and not request and push the same sets of data over and over again with each notebook execution. General Calculation Plan Query our calculated signal name between now - Lookback length (1day) Find the last timestamp of our calculated signal Query the input signals to our calculation for the time range between that last timestamp and now Run our python script on our input signals to generate a new range of values for our calculated signal Push results back into Seeq for range between last timestamp and now Schedule next execution (15 min) Scenarios/methods you may want to avoid include pulling a month of data for all input signals, calculating values and then pushing results back on a 15 minute schedule. This will result in needlessly reading and writing the same data points over and over again. Example Scheduled Signal Calculation (1).ipynb
22. ## Importing Electric Time of Day Pricing

Great question today from the support channel that I wanted to share along with a helpful spreadsheet. As much as I spend my days getting people out of Excel, sometimes it comes in really handy for creating signals from lookup tables. Attached to this Post is an excel sheet I put together where you can input a rate schedule and pricing tiers for Summer/Winter and On/Mid/Off peak pricing. The last sheet in the excel file is setup to be exported to CSV which can then be quickly imported back into Seeq for use in analysis and integration anywhere it would be helpful. Step 1 - In the excel sheet fill out the Lookup Tables sheet to match your utility rate schedule Step 2 - Export the "Output Table - Save as CSV" to a new CSV file Step 3 - Import to Seeq using the Import CSV tool making sure to fill out your timezone, Step interpolation, unit of measure (\$) and under optional settings you may want to add the "Lenient daylight Savings" option to ignore those pesky clock changes. Electric Tier Pricing Worksheet.xlsx
23. ## Using a Scheduled Notebook to Upload Data from a Web API

Starting in Seeq Version R52 Data Lab notebooks can be run on a schedule which opens up a world of new interesting possibilities. One of those possibilities is to create a simple script that pulls data from a Web API source and pushes it into the Seeq data cache on a schedule. This can be a great way to prototype out a data connection prior to building a full featured connector using the Connector SDK This example notebook pulls from the USGS which has information on river levels, temperatures, turbidity etc and pushes those signals for multiple sites into the Seeq system. The next logical step would be to make a notebook to organize these signals into an asset tree. Curious to see what this inspires other to do and to connect to. If there are additional public resources of interest put them in the thread for ideas. USGS Upload Example.ipynb
24. ## Archiving/Removing an Asset Tree built from Spy.Assets()

Sometimes you want to clean up and remove an asset tree built using Seeq Data Lab from a Workbook so that you can restart or do something else. Below is the quickest way to remove an unwanted Tree Step 1 - In Workbench click in the info icon for the Asset Tree Step 2 - Copy the ID value to your clipboard. This may be located in a different place or under the advanced subsection in prior versions of Seeq Step 3 - Open the API Reference page from the Menu in the upper right corner Step 4 - Navigate down to the Trees/assets/{id} delete endpoint expand it, paste in the ID you copied in Step 2 and then click the Try it Out button You should receive a 200 confirmation response code and your Tree will no longer show up in your workbench analysis.
25. ## Create Individual Capsules for Batches that Match Prefix

Great question through the support portal today I am going to try to generalize for everyone. This requires joining two conditions and I am going to show how to do it in a using the simple tools and then how to combine it all together into one formula. Step 1 - Create a Value Search which matches you product code ABC. Once trick here is to search for "ABC*" that will return string results for anything starting with ABC and ending with any other series of characters. The * is part of Regex notation which you can use when searching strings inside the Value Search tool - https://support.seeq.com/space/KB/146637020/Regex%20Searches Step 2 - Create a Condition for each batch using formula and the toCondition() function. This will create a capsule every time the value of our string signal changes. \$mp.toCondition() Step 3 - Combine conditions together using the Composite Condition Tool and the intersection join Alternate Single Formula - Combine the steps in a multi-line formula \$AllBatches = \$mp.toCondition() \$ProductRuns = \$mp.contains("ABC") \$AllBatches and \$ProductRuns
×