# Patrick

Seeq Team

28

12

1. ## Oil and Gas Use Case

Solution: To address your first question of creating the t>1 hr after shut-in capsule. One method to do this is below: 1. Create a condition for ~5 min before shut-in and shift it by ~5 min to make sure you have the Steady state DHP prior to shut-in. This is done using Formula. The Formula syntax is \$ShutinCondition.beforeStart(5min).move(-5min) The "beforeStart(5 min)" creates a new 5 minute long capsule directly preceding your shut-in capsule. The move(-5 min) function shifts this new "beforeStart" capsule backwards in time by 5 minutes. 2. Calculate a new signal that represents the average DHP over the condition created in Step 1. Use "Signal from Condition" with the following inputs: Signal or condition = DHP Summary Statistic = Average Bounding Condition = Condition from step 1 Where to place timestamp = Start Interpolation Method = Step 3. Calculate a new signal that is the signal created in Step 2 (Average DHP before Shut-in) + 10%. Use Formula and the following syntax: \$signalFromStep2*(1.1) 4. Calculate a new signal that is the delta between the DHP and this initial + 10% signal. Use Formula and the following syntax: \$DHPsignal-\$signalFromstep3 5. Create a condition for when this delta signal created in Step 4 drops below zero. Use Value Search and <0 as inputs. 6. Create a Composite Condition that joins the end of your existing Capsules t<1 hr after shut-in to the start of your condition created in Step 5. The inputs to this composite condition will be: Condition A = t<1 hour after shut in Condition B = Delta signal drops below zero Logic = join Not inclusive of A Not inclusive of B Max capsule duration = long enough to capture the time back down to initial DHP. For each of the two new signals you want to create, you can use formula and the following syntax, where \$ChooseCondition will be your t<1 hr and t>1 hr conditions in each formula. \$DHP.within(\$ChooseCondition).runningAggregate(average(),hours()) This will give you a new signal of the 1-hr rolling average of DHP only during the specified condition.
2. ## How can I beat this error? Samples must be ordered by their keys!

Thanks for checking Ivan. I'm not sure what is happening here. I've not been able to reproduce this issue on our server. I also checked our ticketing system and am unable to find known issues related to the calculation you are trying to perform (the previous bug you encountered was related to min/max formulas and is fixed in 62.0.7.) I suspect there might be an issue upstream of the calculation - are you performing any min/max or other operations on \$s?. It might be more expedient to sign up for an office hour session so we can work this 1:1. https://outlook.office365.com/owa/calendar/SeeqOfficeHours@seeq.com/bookings/
3. ## How can I beat this error? Samples must be ordered by their keys!

Hi Ivan - Have you tried clearing the cache on the source signal via Item Properties in the Details Pane ("Clear Cached Values" under the Advanced section)?
4. ## Clear all cache?

One suggestion from my colleague that you can try as well if you want Datasource caching on, is go to the Admin page for the datasource and enable/disable/enable the cache (or, if it is already enabled, disable and re-enable the cache.) This may achieve the same result without resorting to code.
5. ## Clear all cache?

Hi David - While I'm not aware of an "easy button" to clear the cache on all items in a Workbench/Environment, you can programmatically clear the cache using the items API endpoint. One way to do this in Seeq Data Lab, given a list of signal IDs, is loop through that list and call the API endpoint to clear the cache with something like this: signal_id_list=spy.search({'Path':'Path_to_AF_signals_that_need_to_be_cleared'},limit=max_number_of_expected_signals)['ID'].tolist() items_api = sdk.ItemsApi(spy.client) for signal_id in signal_id_list(): items_api.clear_cache(id=signal_id,clear_dependents=True) The above example will get all the signal IDs in the AF path of choice, then clear their cache and any dependent items that are used in Workbenches in your system. If you want to be more surgical, you could pull the item IDs from the Workbench (e.g., via spy.utils.get_analysis_worksheet_from_url(worksheet_url).display_items), but note you will want to get to the root of any calculations to make sure the cache clearing propagates through all dependencies. Would this work for your use case?
6. ## Strange step signal behavior

Gotcha. The good news is that coming in R63 will be a way to force string signal values to be upper, lower, or titlecase. The bad news is that R63 is not yet released, though it's right around the corner. IF your signal name is consistent, one way to tackle this would be to do a replace on the string to standardize the case: \$string_signal .replace('BLU','Blu') .replace('LB','lb') You can then create a condition using .toCondition() which will span the entire duration when the signal value doesn't change. \$replaced_string.toCondition() The result will be a single condition for that string state: As noted, this will be more simple/robust starting in R63 where step 1 can simply be replaced by \$string_signal.lower() which will force the Signal value to be all lower case (alternatively, .upper() and .toTitleCase() will also be available for your use.) Let me know if this helps.
7. ## Strange step signal behavior

Hi protonshake - To convert a step signal into capsules, you can use the .tocapsules() or .toCondition() formula. The former will create a capsule between each sample, regardless if the value has changed or not, whereas .toCondition() will create a continuous capsule if the value is not changing. Regarding your input signal and changing case, is the end goal for the above to have a single capsule for the duration shown (i.e., ignore the signal case), or do you want them separated out each time the source signal case changes?
8. ## Spy.Push() to SHARED folders

Hi Tayyab - One alternative would be to disable inheritance on a folder in the Corporate Drive and then removing the "Everyone" group. To do so, create a folder in the Corporate Drive, click the "three dots" on the right, and select "Manage Permissions". You will see that "Everyone" has access. Click on "Advanced" and "Disable permission inheritance". You can now remove the "Everyone" group from your folder access and add your collaborators and have a folder all your collaborators share (and not "Everyone").
9. ## Dashboard Content not auto-updating and not staying accurate.

Hi Alyssa - I'm trying to reproduce your issue on one of our Seeq servers but am unable to get the same behavior. Have you tried reducing the update frequency to see if that helps? If not, I'd suggest you to swing by one of our office hours so an Analytics Engineer can take a look with you 1:1. Alternatively, please submit a support ticket here so we can follow-up. Office Hour sign up: https://outlook.office365.com/owa/calendar/SeeqOfficeHours@seeq.com/bookings/ Support Portal: https://seeq.atlassian.net/servicedesk/customer/portal/3
10. ## Trend curve fill (under or between)

Hi Johannes - Thank you for the suggestion. As you note, this is currently possible via Scorecard Metrics and use of Thresholds (which can reference static values or signals), but it does involve creating another signal. I'd recommend submitting this suggestion to our Support Portal (https://seeq.atlassian.net/servicedesk/customer/portal/3). Feature requests like these can be submitted as an "Analytics Request", and we will then log it internally with our Product Team for follow-up.
11. ## Convert a a condition written with a tool to formula (so it can be improved)

To add what Kin How mentioned above, I would encourage you to submit a feature request for this capability as I could see this being very helpful when iterating analyses over time. To do so, go to support.seeq.com, click on "Support Portal" in the lower right, and submit an "Analytics Help" request referencing this post. A one-liner will be sufficient. We will make sure it gets linked to a developer feature request.
12. ## How to create spider chart in seeq dashboard

Here's a simple radar plot Add-on that I have written. You can use it as a starting point if helpful. Radar Plot Add-on.ipynb
13. ## Track step change in scatter plot

Hi Tranquil - While not specific to XY plot, Seeq does have formulas that help you detect step changes in signals. If you are looking for changes in the samples coming in, I would suggest you explore the runningDelta() formula, which compares sample-by-sample changes. For instance, if you want to generate a "Step Change Condition" whenever the change in signal is greater than 3, you could write it as: abs(\$signal.runningDelta())>3 Once the condition is generated, you can filter your XY plot by that condition. To count the number of changes for a time period, you can apply a Signal from Condition or Scorecard Metric to count up the number of step changes. Example of a Simple Metric:
14. ## version of the seeq module

As a follow-up to the above, you will also want to check the Seeq Datalab version currently installed on your server by looking at the lower left in the Seeq Datalab browser. If it matches the Seeq version shown in workbench, the pip uninstall -y seeq command should fix your issue. If the version does not match, contact your Seeq Admin to upgrade the SDL server to match. This is a more robust solution as the approach above can cause the error to reoccur post future upgrades.
15. ## version of the seeq module

Hi Mohamed - This error happens when the Seeq Datalab version doesn't match the version of Seeq. You can update the SDL version to match with the Seeq server (ex R54) by executing pip install -U seeq~=54.x where x is the point release on your Seeq server (found in lower left of the browser window.) By the way, to check the Datalab version currently installed, you can execute: pip show seeq Lastly, to see what Seeq PIPY versions are available and install instructions, visit the Seeq PYPI project at https://pypi.org/project/seeq/
16. ## Capsule averages, multiple per day

Hi David - For this you can use the periods Formula. You can also "anchor" it to a specific start time. Example below. periods(12 hours, 12 hours, '2023-01-01T12:00:00','US/Mountain')
17. ## Set signal to blank if condition is not present

Hi Brie - You can try using the remove formula, i.e., \$signal.remove(\$condition). This should remove the data inside that condition.

19. ## Push plot from DataLab to Organizer?

You can append to existing topics/documents (pages) by first pulling the Organizer topic, and then adding to the respective page: #Search for topic (I used the Topic ID, but there are other options as well): topic_search=spy.workbooks.search({'ID':'DFFC7BB8-9EE3-42DD-937A-2CE2FAAAB0E8'}) #Pull the topic associated with that ID. This creates an object of the Organizer that you can modify. topic=spy.workbooks.pull(topic_search) #Extract the "Tensile" page so you can modify it tensile = topic[0].document('Tensile') #Add image to the "Tensile" page tensile.document.add_image(filename='Awesome_Chart.png', placement='end'); #Push modified Organizer back to Seeq: spy.workbooks.push(topic) Let me know if this works!
20. ## Push plot from DataLab to Organizer?

Hi patjdixon - You do have the ability to push images directly into an Organizer Topic. To do this, first save the image using plt's savefig method: Lab_Pred_Fig.savefig('Awesome_Chart.png') Create an Organizer Topic Object: topic = spy.workbooks.Topic({'Name': "Charts"}) Add a page to the topic object: page = topic.document('Visualizations Using Data Lab') Add the image to the page. Note the semicolon on the end suppresses the output from the cell. page.document.add_image(filename='Awesome_Chart.png', placement='end'); Publish the Topic: spy.workbooks.push(topic) If you have an existing Topic, you can use spy.workbooks.pull() to pull in the object and follow the same methodology as above. Note I included a [0] index to reference the Topic document in the pull results. topic_search=spy.workbooks.search({'ID':'DFFC7BB8-9EE3-42DD-937A-2CE2FAAAB0E8'}) topic=spy.workbooks.pull(topic_search) page = topic[0].document('Visualizations Using Data Lab')
21. ## Improve workbook\datalabs naming conventions and navigation

Hi Eric - Thanks for the suggestions, all great ideas. If you haven't already, please submit these ideas to support@seeq.com, as we do track feature requests there and will feed that info to our dev team. You will then also be notified when those features are implemented. Note that version tracking for Seeq Datalab projects will be improving in R58 with Git integration, which should make it easier to manage and track the scripts you are creating. https://seeq.atlassian.net/wiki/spaces/KB/pages/2436104292/What+s+New+in+R58
22. ## Create Pareto Charts with CDF in Seeq

We've received reports from some users encountering errors when following the above guide. Below are solutions to two errors users have reported: 1) NameError NameError: name 'total_time_by_reason_code' is not defined To fix this, define the dataframes first by inserting the definitions towards the beginning of the script: total_time_by_reason_code=pd.DataFrame() percent_time_by_reason_code=pd.DataFrame() cum_percent_time_by_reason_code=pd.DataFrame() 2) Type Error when trying to plot the first bar chart TypeError: value should be a 'Timedelta', 'NaT', or array of those. Got 'int' instead. To fix this, the 'Total_Time_by_Reason_Code' series can be converted to hours by adding the following line of code: total_time_by_reason_code['Total_Time_by_Reason_Code'] = total_time_by_reason_code['Total_Time_by_Reason_Code'].dt.total_seconds()/(60*60) Note the original post performs this conversion at a later time in the script. That conversion is no longer needed and should be removed:
23. ## Adjusting Asset (Row/Column) position in condition table

Hi Jesse - Unfortunately moving property columns to the left/top of metric columns in tables is not yet supported. There is an open developer request for this functionality. If you would like to be notified when this functionality becomes available (and advocate for prioritization), please send us a ticket to support@seeq.com referencing developer request #27076 so we can log your ticket against that request. Thanks, Patrick