In this section we will explore dealing with errors in our analytics, both from missing
tags and errors within the source data. There are several reasons to resolve errors in analytics.
The first is that the analytics service attempts to restart analytics in error
states every 15 minutes by default. Including analytics missing inputs.
This can cause performance problems if there are enough analytics in this state.
Another reason is that errors caused by bad source data within analytics can also hinder
performance and more importantly result in bad outputs in the calculation results.
It is important to build error checking into analytics for both of these reasons.
The first thing we'll take a look at is PI tags that may not be present for all
elements and we'll take a look at fixing this by excluding attributes that are not available
on certain assets. So first we'll launch PI System Explorer then we'll navigate to the elements view,
we'll expand Sirocco and then select Finisterre and we'll select turbine RB
006. Clicking over to the attributes tab we'll see that our wind turbines have a number of
elements in our example database, but one of these attributes:the local wind speed,
does not actually have a PI tag associated with it for this turbine. So if you look through the
database you'll notice that some of our turbines have local wind speed and some do not. This is
reflects that certain pieces of equipment and in the field may or may not have certain sensors.
In this case we'll select local wind speed and because it is not present on this turbine under
the properties window on the right, we'll click the drop-down and select excluded. You'll see
that the value of the attribute goes to excluded and that this attribute now looks like a static
attribute rather than a PI point data reference. Next we'll check in our changes. Then we'll click
over to the analyses tab for the RB 006 turbine. There you can see all of the analytics that are
running on this particular element, but in this case we're concerned with the local
wind speed vs site wind speed analytic. If you highlight it you'll notice that it has a pause
symbol instead of a check mark to indicate it's running like the others. So this this analytic
is in a pause state. If you hover over the pause button you can see that local wind speed vs site
wind speed is suspended for the following reasons: local wind speed is an excluded
attribute. So this calculation is not executing currently.. However this does prevent the analytic
service from trying to start this analytic every 15 minutes and improves performance.
Later on in this exercise we'll take a look at ways we could keep this analytic running
while excluding that attribute. Next we'll take a look at how to deal with bad data in
our input values by using the exit function when that input value does not contain good
data. So back in PI System Explorer, we'll click into the library view and we'll expand
our element templates and we'll go to our turbine element template. We'll click over to
the analyses templates tab and we'll look at our same local wind speed vs site wind speed analytic.
We're going to select turbine GE 001 as our example element if it's not selected already
and we'll right-click on our analytic and we'll say preview results. We're gonna start
our preview it today and end at the current time that should be fine and we'll generate results.
If you inspect the source data you'll notice that occasionally local speed even though it
is present on this turbine has a value of comm fail every once in a while. If you
scroll through the data you'll see that the comm fails are spread throughout the source
data without any regularity. So this indicates bad data in our source data. So if we have bad
data in our local wind speed variable there's no need to compare it to the site speed because the
result that we'll get will be an error value and will cause issues in the output variable.
So we're going to close out of our preview and then inside our analytic we'll add error
checking using the exit function. So in the local wind speed field we'll add if BadVal
of local wind speed then exit else local wind speed. So what this will do is if there's a bad
value in the local wind speed variable then we'll exit, otherwise we'll use the value of
the local wind speed. This BadVal function will return true if there's a problem with the input
including both a missing tag or a bad state and the tag value itself. The exit function will stop
processing of the analytic and save processing time if there is a bad value on this input.
We'll click evaluate to make sure we typed everything correctly and if we
get good results and we can right click and say preview analytic results again.
Now you'll see if there's a comm fail value in local wind speed, like this row here,
we don't get any variable for local speed or site speed because the analytic exits without
further processing. Next we'll check in our changes in PI System Explorer.
We can also take a look at the turret same turbine we looked at previously turbine RB 006. So we
click back to our elements view and take a look at turbine RB006 and click on his analyses tab.
We'll see that our local wind speed vs site wind speed analytic is no longer paused, it is now
running. This is because even if an attribute is excluded if it is wrapped in a BadVal check, like
our local wind speed is here, then the analytic service will allow the analytic to start and the
error handling inside the analytic will deal with the excluded attribute. So in the case of this
particular turbine, because there is no local wind speed, it's an excluded attribute, the value at
evaluation the BadVal triggered evaluates to true and the analytic exits without further process.
Another way to deal with tags that are missing on some elements is using a not applicable tag. In
this case we have created a not applicable tag on this test system and will assign it to an element
attribute. So back in PI System Explorer under the elements view will navigate to the RB 007
turbine and then to its attributes template. Once again notice that local wind speed does
not have a PI point for this turbine. So next we'll click on settings to change the PI point
data reference and we'll click search under tag name and we'll enter not applicable tag in the
search field. Click search and then select the not applicable tag. Next check in our changes.
Notice that local wind speed now has a value of NA. This is a system state inside a digital
tag so this will trigger the BadVal function to evaluate to true. So back over on our analyses
tab we'll select the local wind speed vs site wind speed analytic and if we click evaluate,
we notice that the value at evaluation comes out to a dash, meaning that this line here
exited the analytic. But we do notice that the analytic is running and is functional.
In summary, error checking both for bad data within the data sources and in terms of missing
inputs is critical to analytics performance at a large scale. The BadVal function is a key tool for
this. Both attribute exclusion and the default not applicable tag are valid ways to deal with
missing inputs but each has certain advantages. Attribute exclusion is cleaner in most cases;
but in cases where there are large numbers of elements it may be easier to use a default not
applicable tag and replace the tag where it actually exists for certain elements.