I am trying to create a synthetic time series query that looks are two other time series and if those values meet a certain condition, is outputs a 1 or 0 as the synthetic time series but I keep getting a syntax error that I can’t solve. Below is a code sample.
for temperature in temp_id_list: temp_expression = f"TS{{id:{temperature}}} < 200" flow_expression = " + ".join([f"(TS{{id:{flowrate}}})" for flowrate in flow_id_list])
final_expression = f"if({temp_expression} and {flow_expression} > 0, 1, 0)"
Our current capabilities for synthetic time series do not support the use of if expressions. The supported functions include various mathematical operators, trigonometric functions, and specific functions like ln, pow, sqrt, exp, abs, and map. However, conditional statements like if are not listed among these supported functions. For more detailed information and to explore potential workarounds, you can refer to the Cognite synthetic time series documentation: Synthetic time series documentation.
In some cases the usage of functions like max and min can help you achieve the similar outcome as with an if expression, but we do understand that it’s not as flexible. If this is an important feature for you, I recommend making a feature request as a Product Idea here on the hub.
Our current capabilities for synthetic time series do not support the use of if expressions. The supported functions include various mathematical operators, trigonometric functions, and specific functions like ln, pow, sqrt, exp, abs, and map. However, conditional statements like if are not listed among these supported functions. For more detailed information and to explore potential workarounds, you can refer to the Cognite synthetic time series documentation: Synthetic time series documentation.
In some cases the usage of functions like max and min can help you achieve the similar outcome as with an if expression, but we do understand that it’s not as flexible. If this is an important feature for you, I recommend making a feature request as a Product Idea here on the hub.
I’ve used some workarounds before, using max, min, round, but also hack with the on_error method. For instance on_error(sqrt(200-TS{id:...}) this will throw an error if TS>200, due to sqrt of negative number
* 0 + (value if expression is true), value if no error
(value if expression is false)) value if error
You can also use ln, which fails on <= 0, not just <0
The syntax is not very nice, but it should get the work done
If the input is string time series, it is actually easier, using the map() function
We use 3 different kinds of cookies. You can choose which cookies you want to accept. We need basic cookies to make this site work, therefore these are the minimum you can select. Learn more about our cookies.