Jump to content

Thorsten Vogt

Super Seeqer
  • Posts

    171
  • Joined

  • Last visited

  • Days Won

    53

Posts posted by Thorsten Vogt

  1. Hello,

    you might want to check the following way:

    As you need to specify which is the first capsule you want to start with you need to define a bounding condition. In my example I use a monthly condition to do the calculation:

    image.png.b88139b6db53fbe65efebb0219697bc7.png

    Next I created a signal that puts the value 1 at the start of each capsule:

    $condition.removeLongerThan(40h).toSamples($c -> sample($c.startKey(), 1), 0s)

    image.png.8b32f693ac5b1f91d45de4bfdedd916e.png

    This signal is used to build the running sum of these values:

    image.png.1f67af7b1832a3733af001fa779e09ef.png

    The calculated value can be used to extend the original condition with a property containing the capsule number during each month:
     

    $condition.removeLongerThan(1d).setProperty('Capsule Number', $count, startValue())

    image.png.989acb1ce5d2f749c7bf9ca8740ecd26.png

    Then two new conditions can be created to include only capsules with odd and even capsule numbers:
     

    $conditionWithCount.keep($c -> ($c.property('Capsule Number')/2)-floor($c.property('Capsule Number')/2) > 0)
    $conditionWithCount.keep($c -> ($c.property('Capsule Number')/2)-floor($c.property('Capsule Number')/2) == 0)

    image.png.36f771890661b77763abc1f955cc9971.png

    A composite condition can be used to join the odd and even ones:

    image.png.5b7a3b1bc50b7ab7f968ea5db8eb65a5.png

    Hope this helps.

    Regards,

    Thorsten

  2. Hi, 

    you can do this by using splice(). The following example takes 10 as the default value and changes the part of the signal to 15 or 22 based on the value of the batch id.
     

    image.png.02263f0e29e20b39810bc826128d0fdf.png

    If the lot number you mentioned is a property of the capsule you imported you might need to convert it to a signal using toSignal() and the property name that is used to store the lot number:

    image.png.995594ebe3e2723319438053ea30fd36.png

    Or filter for capsules that contain the lot number using keep() on the condition:

    image.png.dc9a889894c94ff35cf1d7c07642e986.png

    You can check your capsules for existing properties by having a look at the Capsules Pane. When clicking the "Add Column" icon you are able to choose the properties from the dropdownlist of available properties. The name of the property can be used in the functions mentioned above.

    image.png.1130ba3b05b95ac47881b69ecc403a81.png

    Regards,

    Thorsten

  3. Hello Bill,

    if you do not have Data Lab than you can use the REST API of Seeq. I created an example using Powershell:

    $baseurl = "https://myseeqinstance"
    
    $headers = @{
        "accept" = "application/vnd.seeq.v1+json"
        "Content-Type" = "application/vnd.seeq.v1+json"
    }
    
    $body = @{
        "authProviderClass" = "Auth"
        "authProviderId" = "Seeq"
        "code" = $null
        "password" = "<password>"
        "state" = $null
        "username" = "<username>"
    } | ConvertTo-Json
    
    $url = $baseurl + "/api/auth/login"
    
    $response = Invoke-WebRequest -Method Post -Uri $url -Headers $headers -body $body
    
    
    $headers = @{
        "accept" = "application/vnd.seeq.v1+json"
        "x-sq-auth" = $response.Headers.'x-sq-auth'
    }
    
    $url = $baseurl + "/api/users?sortOrder=email%20asc&offset=0&limit=200"
    
    $response = Invoke-RestMethod -Method Get -Uri $url -Headers $headers
    
    $selectedAttributes = $response.users | Select-Object -Property firstname, lastname, email
    
    $selectedAttributes | Export-Csv -Path "userlist.csv" -NoTypeInformation
    

    The script uses the /auth/login endpoint to authenticate the user and retrieves the list of users (limited to 200) using the /users endpoint. You would need to replace the value in the first line with the URL of your Seeq system (eg. https://mycompany.seeq.site) and specify the credentials by replacing <password> and <username> inside the script. The list of users will be written to the file userlist.csv inside the directory from which the powershell script is run. 

    Let me know if this works for you.

    Regards,

    Thorsten

    • Like 1
  4. Hi Brian,

    you can use the timesince() function for this:

    years('CET').timesince(1h, $uptime.inverse())

    The example above creates a signal representing the running amount of hours for each year putting a sample every 1 hour. The last parameter specifies that periods where the uptime condition is not met are excluded from the calculation. In the follwowing screenshot you can see the signal is only increasing if a capsule for my uptime condition exists, otherwise the value does not change.

    image.png.40cf8c2cbcd8b35c6dcab0093a4ffa1f.png

     

    Furthermore the value will be reset to 0 at January 1st every year:

    image.png.c33ac5673db2c5eb28f36c416c458631.png

    Does this answer your question?

    Regards,

    Thorsten

  5. Hi Alex,

    maybe one workaround you could try is creating capsules for the discrete signal using $signal.tocapsules(). The capsules do not have duration, but will contain the value of the signal in a capsule property. Then export the Condition using OData and use the OData Capsule Summary Table Endpoint. I do not have Power BI, but when loading the data to Excel I can see the start of the capsule and the corresponding value. So this might be the information you can use.

    image.png.2f383e0cc29888eb95c53efc50c785f3.png

    Regards,

    Thorsten

  6. Hello Bill,

    one way I can think of is using a little python script inside Seeq Data Lab:

    import seeq.sdk as sdk
    import pandas as pd
    user_api = sdk.UsersApi(spy.client)
    userlist = user_api.get_users()
    users = list()
    for user in userlist.users:
        users.append({"Username": user.username, "First Name": user.first_name, "Last Name": user.last_name, "Directory": user.datasource_name})
    pd.DataFrame(users).to_excel("userlist.xlsx")

    You might need to run

    pip install openpyxl

     first and restart the kernel, if you get an error message that the package could not be found.

    The Excel file will appear in the rootfolder of your DataLab project and can be downloaded from there.

    I tested the script on R61, so I am not sure if you need to modify it a bit to get it working with R58.

    Regards,

    Thorsten

  7. Hi Swapnil, 

    you can calculate the average for these periods using the runningAggregate function. I created the 12 hour periods with the following formula:
     

    periods(12h, 12h, '2023-01-01T08:00:00', 'CET')

    This condition is then used inside the aggregation of the signal:

    $signal.runningAggregate(average(), $periods)

    The result will be the average value of the signal that resets at the beginning of each capsule:
    image.thumb.png.37160b4ff5d80b2b1615585224ac51e6.png

    I am not sure what you want to display in the table? Just the last value for the current period?

    Regards,

    Thorsten

  8. Hi Saha, 

    from your example it seems you want to filter your signal for a specific value to create a condition. In general it is easier to do this using a Value Search. The syntax you want to use only works on conditions, but you are using it on a signal. Therefore you get the syntax error.

    image.png.8d318638ac71f0b9fededa1227f11f65.png


    Can you provide some more details on what you are trying to achieve?

    Regards, 

    Thorsten

  9. Hi Pat,

    that is interesting. When writing the posts above I had tested changing the UIConfig property back and forth with a Value Search and ran into problems:

    image.png.612926f95940227a4aefbfa34bf7cd2a.png
    UIConfig is set to "value-search":
    image.thumb.png.828af7fd714d3a644169aa29082bf3a8.png

    After changing to "formula" Seeq displays the formula editor when editing the tool:

    image.png.2b3b70c000d7fc6b3f43aef4eebfc600.png

    When changing the property back to "value-search" the Value Search tool has no configuration:

    image.png.fbcfd5ff0dd5b60f3c37be824f632f36.png

    I just tested this with a daily periodic condition with specific days selected which gave the same results. A prediction that does not have the default values set behaves the same:

    image.thumb.png.5cc6dc521f86c4c22d087bb9221b570a.png

    After changing "UIConfig" to "formula" and back to "prediction" the regression method in the UI has changed to OLS instead of Ridge Regression. although in formula it still uses the regressionModelRidge() function:

    image.thumb.png.1549864f9567ce4c992469ec638c7b75.png

    Executing the tool changes the formula to use regressionModelOLS(). 

    My conclusion: I would not rely on converting a formula back to a tool as long as you do not know the exact parameters for the tool and therefore have the complete UIConfig string. Seeq seems not be able to extract these from the formula.

    Regards,

    Thorsten

     

     

  10. Hi Augustin,

    you can overwrite the UOM using the function setUnits(). However it expects a unit that is known to Seeq, so you might not be able to use "acfm". If it stands for "Actual cubic feet per minute" you might want to try "cf/min" instead.

    $t.setunits('cf/min')

    Does this work for you?

    Regards,

    Thorsten

  11. Hi Emre, 

    one way to achieve this would be counting the conditions and multiply them with you constant. This signal is then added to the other signal:

    $signal.setMaxInterpolation(20d).runningdelta().runningSum(months('CET')) +
    $conditionA.aggregate(count(), $conditionA, startKey(), 0s).runningCount(months('CET')).toStep(30d) * 3

    The second term of the formula will calculate the number of capsules during each capsule (which is 1) and put that as a discrete value to the start of the capsule. This value will be summed up during the month, transformed to a step signal and multiplied with the constant.
    The screenshot shows the previous calculation (red) together with the new calculation (blue). Condition A is represented by the green capsules.
    image.thumb.png.4d44ed3961f9f02f56b718e394b898f6.png

    Regards,

    Thorsten

  12. Hello,

    Seeq does not have a direct way to format strings. However you can use a regular expression to prefix values less then 10 with a leading "0". Just change the last line in the formula to this:
     

    $capsule.setProperty('Hours', $hours.toString().replace("/^(\\d{1})$/", "0$1") + ":" + $minutes.floor().toString().replace("/^(\\d{1})$/", "0$1") + ":" + $seconds.toString().replace("/^(\\d{1})$/", "0$1"))

    The RegEx in the replace function will search for one digit numbers and replace them with the original value prefixed with a leading 0. If the number contains more then one digit it will keep the original value:

    image.png.7de4ce494997a6cf23c8126afe60e7b0.png

    Regards,

    Thorsten

     

  13. Hello, 

    you could do this by creating a transform and calculating the values inside it. In my example I am using the duration() method to get the duration of the capsule. You might need to change this to get the value from your property.

    $condition.removeLongerThan(1mo).transform($capsule ->
    {
      //Calculate total hours
      $totalHours = $capsule.duration().convertUnits('h').setUnits('')
      
      $hoursFraction = $totalHours - $totalHours.floor()
      $hours = ($totalHours - $hoursFraction).floor()
      
      //Calculate minutes
      $minutes = $hoursFraction * 60
      $minutesFraction = $minutes - $minutes.floor()
      
      //Calculate seconds
      $seconds = ($minutesFraction * 60).round(0)
      
      //Set property by buildung a string
      $capsule.setProperty('Hours', $hours.toString() + ":" + $minutes.floor().toString() + ":" + $seconds.toString())
    })

    image.png.104fe9435cb7218f2095d95e9cc1064c.png

    Regards,

    Thorsten

  14. Hi Akos, 

    if I understood the code correctly it returns "Signal_2" everytime "Signal_1" is below 30, otherwise "Signal_1" will be returned. In Seeq you could use

    $signal1.splice($signal2, $signal1 < 30)

    for that.

    You may also have a look at this post:

    Regards,

    Thorsten

    • Like 1
×
×
  • Create New...