Hello,
Still relatively new to scripting in Ignition and I can’t seem to find solid documentation on the best way to approach numerically filtering a dataset.
What I’m trying to do is setup the value of an LedDisplay component in a perspective view using an average of a selected tag history. Right now I have a tag that is recording data every few seconds or so to our historian. So I’m configuring a tag history binding for the value of the LedDisplay. I’m using a 1min periodic query in the tag history binding for a 60min period, basically a dataset of 60 rows and 2 columns. The original dataset itself looks something like this:
- 2.34
- 2.38
- 2.54
- 18.42
- 2.45
- 2.79
- 0.00
- 2.55
I want to do a transform to that dataset to filter out any values that are higher than 3.00 and lower than 2.00. Essentially giving me the following desired dataset:
- 2.34
- 2.38
- 2.54
- 2.45
- 2.79
- 2.55
Again, the main reason I want to do this is to average the useful range within the dataset. The first dataset would give me an average of 4.18, whereas the second dataset average would be 2.51. That second dataset is a much more representative dataset of the process. Not interested in changing the logging of historian data, as I still want my historian to keep logging the 0s and the higher values because they are useful for other visualizations. Not sure if I’m going about this the best way, open to most things. Also, I’m a complete noob when it comes to the query area so I’d prefer a solution involving script transform.
Thanks!