Jump to content

Thorsten Vogt

Super Seeqer
  • Posts

    137
  • Joined

  • Last visited

  • Days Won

    45

Everything posted by Thorsten Vogt

  1. Hi Acerion12, I am not quite sure what you mean with getting a signal limited by date range. So I created a quick-and-dirty example to get a signal by its ID and also retrieve its samples over a specific date range. The query will only return 40 samples for each call. Seeq.Sdk.Client.ApiClient client = new Seeq.Sdk.Client.ApiClient("https://<YOUR SERVER>/api"); Seeq.Sdk.Api.AuthApi authApi = new Seeq.Sdk.Api.AuthApi(client); authApi.Login(new Seeq.Sdk.Model.AuthInputV1 { Username = "<YOUR ACCESSKEY>", Password = "<YOUR PASSWORD FOR THE ACCESSKEY>" }); string signalId = "14E630B3-E615-4B84-9EE3-4B685D5A3938"; Seeq.Sdk.Api.SignalsApi signalsApi = new Seeq.Sdk.Api.SignalsApi(client); Seeq.Sdk.Model.SignalOutputV1 signal = signalsApi.GetSignal(signalId); Console.WriteLine("Signal: {0}", signal.Name); string start = DateTime.Now.AddDays(-3).ToUniversalTime().ToString("o"); string end = DateTime.Now.AddDays(-2).ToUniversalTime().ToString("o"); int offset = 0; int numberOfItems = 40; Seeq.Sdk.Model.GetSamplesOutputV1 samples; do { samples = signalsApi.GetSamples(signalId, start, end, null, null, null, null, null, offset, numberOfItems); foreach (Seeq.Sdk.Model.SampleOutputV1 sample in samples.Samples) Console.WriteLine("{0} : {1}", sample.Key, sample.Value); offset += numberOfItems; } while (!string.IsNullOrEmpty(samples.Next)); client.Logout(); Does this answer your question? Regards, Thorsten
  2. Hi Martin, yes, this is possible with SDL. Here is an example: # Search for signals signals = spy.search({"Name":"cdt158*"}) Result: metadata = signals.copy() # Specify new Name by creating one based on the Original Name metadata["OriginalName"] = metadata["Name"] metadata["Name"] = "Derivative of " + metadata["Name"] # Attach column with Seeq Formula metadata["Formula"] = "$signal.derivative()" # Attach column with parameters for the Formula metadata["Formula Parameters"] = "$signal =" + metadata["ID"] # Remove ID Column, otherwise Seeq will try to update the original signal and not create a new one metadata = metadata.drop(columns=["ID", "OriginalName"]) The metadata DataFrame looks like this: # Push metadata to Seeq spy.push(metadata=metadata, worksheet="METADATA") When opening the link that spy.push generated, you can view the results within Workbench: Let me know it this works for you. Regards, Thorsten
  3. Hi Yassine, seems like you set the Max Interpolation to 5 days. The gaps in the screenshot seem to be bigger than that value. Can you check setting the value to a higher value?
  4. Can you post the formula you are using for summing the signals up?
  5. Hi Nate, that means that the values are uncertain and might be able to change (e.g. by using compression on the historian). Example: You may notice the sample at ~15:39 was removed by the historian: Now the datapoint was written to the achive. Notice the value from above (~15:46) was also removed: Hope this helps. Regards, Thorsten
  6. Hi Yassine, it would be helpful if you could provide some more details, like how the calculation is done or if there are warning or errors showing up in the Details Pane. In most cases gaps in the data appear if the maximum interpolation defined for the the signal is to small or invalid values exist in the data. So you might want to try setting the maximum interpolation to a higher value (using $signal.setMaxInterpolation()) or remove invalid values (using $signal.validValues). More information can also be found in this post: Regards, Thorsten
  7. Hi Jessica, there are some functions you can use to handle the validity of data: $signal.isNotValid() identifies periods where you have invalid data (like errorneous data from a sensor) resulting in a capsule $signal.isValid() identifies periods where you have valid data $signal.replaceNotValid(alternateValue) replaces periods with invalid data inside a signal with an alternate value Regards, Thorsten
  8. Hi Brian, you can filter Signal 2 using within() and use the resulting signal for further calculations: Regards, Thorsten
  9. Hi Micah, you can do this with a transform: $inputB.transform($capsule -> { $capsulesOfInputA = $inputA.removeLongerThan(1wk).toGroup($capsule) $start = $capsulesOfInputA.first().startKey() $end = $capsulesOfInputA.last().endKey() capsule(max($start, $capsule.startKey()), min($end, $capsule.endKey())) }) As the capsules for the output can only be as long as the capsules of Input B, I am using max() and min() to reduce the capsule length if capsules of Input A overlap with the beginning or end of a capsule of Input B (see first result). Regards, Thorsten
  10. Hi Christopher, regarding your points 2 and 3: You can specify a timezone in the hours() and days() function. As Seeq uses the timezone of the server the start of the day might differ from the timezone you selected for displaying the data. You can see the difference here: The spike at hour 23 is occuring because you created a signal that has the value of the hour at the beginning. Therefore it interpolates the values from 23 to 0 within that hour, so that the conditions you created apply and the calculated values are spliced into the original signal. A better approach would be using timesince(). This function calculates the amount of time that has passed since the beginning of the capsule: Changing your code in line 8 to $DayHours = timesince(days('<your timezone>'), 1h) should resolve the spike and the need to shift the signal by 5 hours. Regards, Thorsten
  11. One more comment on the post above: The within() function is creating additional samples at the beginning and the end of the capsule. These additional sample have an effect on the calculations performed in the histogram. To avoid this you can use the remove() and inverse() function to remove parts of the data when the condition is not met: In contrast to within() the remove() function will interpolate values if the distance between samples is less than the Maximum Interpolation setting of the signal. To avoid this when using remove you can combine the signal that the remove function creates with a signal that adds an "invalid" value at the beginning of each capsule so that the interpolation cannot be calculated: $invalidsAtCapsuleStart = $condition.removeLongerThan(1wk).tosamples($c -> sample($c.startkey(), SCALAR.INVALID), 1s) $signal.remove($condition.inverse()).combineWith($invalidsAtCapsuleStart) You can see the different behaviours of the three described methods in the screenshot:
  12. Hi SBC, applying the the within() function to your signal will result in a new signal that only keeps those parts of the signal where the condition is met. The filtered signal can then be used for the histogram. Regards, Thorsten
  13. Hello John, beginning in R57 you can adjust the number of characters to be displayed. https://seeq.atlassian.net/wiki/spaces/KB/pages/2344943627/What+s+New+in+R57#Customizable-formatting-for-string-labels-on-the-y-axis Regards, Thorsten
  14. Hi Victor, you can use within() for that: Regards, Thorsten
  15. Hi, you can use spy.login with the access_key parameter: spy.login(access_key="CagR-n4oQGqjlAb7e6fr3B", password="Ec9DaXnSXgaG969cjkv4d4iGdGiAah" ,url="https://myseeqserver") Regards, Thorsten
  16. Hello, you can change this by clicking on "Customize" in the Details pane and then switch the value of the dropdown in the "Samples" column: Regards, Thorsten
  17. Hi, the error means that you are referencing a variable that is not defined in your variable list. You should change your variable "$signal1" in the formula to a variable you have in your variables list: Also be aware that you cannot use a signal and a condition together on combineWith(). You can combine either signals only or conditions only. Regards, Thorsten
  18. Hello Kspring, I think you can do it that way: First create a condition based on the material signal by using toCondition(). The function creates a capsule everytime the value of the signal changes and stores the value in a defined property, in this case "Material": $signal.toCondition('Material') Next filter only for batches where the current material is produced using formula: //Create capsule of 1 day ending now $capsule = capsule(now()-1d, now()) //Get current material by selecting last value inside capsule created above $currentMaterial = $gradeCode.toScalars($capsule).last() //Only keep batches for current Material $batches.removeLongerThan(1mo).keep($c -> $c.property('Material') == $currentMaterial) Then create the condition the time range you want to aggregate over. Here I am using a monthly condition: Last step is calculating the value. The within() function is used to only keep that portions of the signal during the specified condition. $temperature.within($filteredBatches).aggregate(average(), $month, middleKey()).toDiscrete() Depending on your data you might need to do some adjustments on the timeranges I used in the formulas. Regards, Thorsten
  19. Hi Bellas, for creating the line at a certain y-value you can click on the "f(x)" button: Then click on "New Formula": Enter the formula for the trend line. In this case I am going to display the line at y=60: After executing click the "f(x)" button again and select the just created signal from the dropdown: The scatter plot now shows the line: Coloring an area above that line is not possible as far as I know. But you can color all points above that line. First you need to create a condition that identifies all points of the y-axis signal above the threshold: Next, click on the "Color" button: Select the condition from the conditions list: After closing the dialog all points identified by this condition are colored in the specific color of the condition: ? Regards, Thorsten
  20. Hi Robin, you can create a batch condition by using replace() to extract the batchnumber and toCondition() for creating the capsules for each batch: $subbatches.replace('/(\\d{1,7})NR\\d{3}/', '$1').toCondition() In the next step you can do the aggregation: $v1.aggregate(sum(), $batch.removeLongerThan(1wk), middleKey()) + $v2.aggregate(sum(), $batch.removeLongerThan(1wk), middleKey()) Regards, Thorsten
  21. Hello, you can use the merge() function for this. If a tolerance value is specified all capules beginning withing that tolerance after the end of a capsule are combined. Regards, Thorsten
  22. Hello, you can find deviations by using Value Search. The former Deviation Search Tool has been unified with Value Search in Version R50: https://support.seeq.com/space/KB/1075216533/What's+New+in+R50#Unify-Deviation-Search-and-Value-Search Regards, Thorsten
  23. Hi Javad, I got a solution based on this starting point: The following formula compares the durations of the first capsules for conditions B,C and D bounded by each capsule of condition A and sets a property on capsules of condition A indicating if these should be shown. The keep function on the end only displays capsules where the property is set to true $a.transform($a_capsule -> { $b_capsule = $b.toGroup($a_capsule).first() $c_capsule = $c.toGroup($a_capsule).first() $d_capsule = $d.toGroup($a_capsule).first() $show_a = ($b_capsule.duration() > $d_capsule.duration() and $d_capsule.duration() > $c_capsule.duration()) $a_capsule.setProperty('show', $show_a) }, 40h).keep('show', isequalTo(true) ) Changing capsule duration of B gets no capsule for result, which is expected: If you want to show another capsule for the last case, you can adjust the formula to generate another condition with the property show set to the inverse and select one of the conditions based on that value. Therefore you have to do the transform twice: $tempCondition1 = $a.transform($a_capsule -> { $b_capsule = $b.toGroup($a_capsule).first() $c_capsule = $c.toGroup($a_capsule).first() $d_capsule = $d.toGroup($a_capsule).first() $show_a = ($b_capsule.duration() > $d_capsule.duration() and $d_capsule.duration() > $c_capsule.duration()) $a_capsule.setProperty('show', $show_a) }, 40h) $tempCondition2 = $tempCondition1.transform($a_capsule -> { $d_capsule = $d.toGroup($a_capsule).first() $d_capsule.setProperty('show', not $a_capsule.property('show')) }, 40h) $tempCondition1.keep('show', isequalTo(true)) or $tempCondition2.keep('show', isequalTo(true)) As a result capsules for condition D are shown: Changing duration of capsule B to its original value show capsules of A as the result: Hope this helps. Regards, Thorsten
  24. Hi Matthias, you can try this: First, calculate the duration of each capsule using "Signal from Condition" tool: Then you can use timesince() to calculate the percentage value over the duration and also splice() to insert it into the base signal of 0% everytime the condition is met: 0%.splice(timesince($condition.removeLongerThan(40h), 1min)/$duration, $condition) Did I understand your question correctly? Regards, Thorsten
  25. Hi Yassine, maybe this post is helpful: Regards, Thorsten
×
×
  • Create New...