Issue Using Grafana Functions for TimeSeries operations

Hello,

I’m trying to do basic math operations into my time series data with multiple measurements. These operations is to transform the KV line-neutral values to line-to-line and make present them in PU (using the Base KV and divider).

Checking on the documentation I saw there is a way in doing so using GSF Functions as described below.

However, whilst running the line:
FILTER TOP 10 ActiveMeasurements WHERE SignalType=‘VPHM’
ran sucesfully, adding the function Multiplier did not generate results, as per the code below:
Multiply(1000, FILTER TOP 10 ActiveMeasurements WHERE SignalType=‘VPHM’ )
could not be processed. Similar deferred funtions such as Divide, Add, Substract has the same issue.

However, other type of deferred funtions which does not requires an extra parameter (N variable) such as AbsoluteValue, Diffeerence run perfectly…

I suspect maybe is an issue with the pluging compatibility? Or maybe is my time series data faulty? For the record, I’m running openHIstorian pluging v1.0.3 with Grafana Server v9.5.15

Any help someone? Thanks!

In order to reduce confusion about how addition and multiplication were applied to a data set, one of the changes that was made to the new openHistorian Grafana data source was to replace Multiply and Divide with a Scale function, specifically:

/// <summary>
/// Returns a series of values that represent each of the values in the source series scaled by <c>N</c>.
/// <c>N</c> is a floating point value representing a scaling factor (multiplier or reciprocal) to be applied to each value the source series.
/// <c>N</c> can either be constant value or a named target available from the expression. The <c>asReciprocal</c> is a boolean parameter that,
/// when <c>true</c>, requests that <c>N</c> be treated as a reciprocal, i.e., 1 / <c>N</c>, thus resulting in a division operation instead of
/// multiplication - defaults to <c>false</c>.
/// </summary>
/// <remarks>
/// Signature: <c>Scale(N, [asReciprocal = false], expression)</c><br/>
/// Returns: Series of values.<br/>
/// Example 1: <c>Scale(1.5, FILTER ActiveMeasurements WHERE SignalType='CALC')</c><br/>
/// Example 2: <c>Scale(0.5, FILTER ActiveMeasurements WHERE SignalType='FREQ')</c><br/>
/// Example 3: <c>Scale(60, true, FILTER ActiveMeasurements WHERE SignalType='FREQ')</c><br/>
/// Variants: Scale<br/>
/// Execution: Deferred enumeration.
/// </remarks>

Additionally, Add and Subtract were replaced with Shift:

/// <summary>
/// Returns a series of values that represent each of the values in the source series shifted by <c>N</c>.
/// <c>N</c> is a floating point value representing an additive (positive or negative) offset to be applied to each value the source series.
/// <c>N</c> can either be constant value or a named target available from the expression.
/// </summary>
/// <remarks>
/// Signature: <c>Shift(N, expression)</c><br/>
/// Returns: Series of values.<br/>
/// Example 1: <c>Shift(2.2, FILTER ActiveMeasurements WHERE SignalType='CALC')</c><br/>
/// Example 2: <c>Shift(-60, FILTER ActiveMeasurements WHERE SignalType='FREQ')</c><br/>
/// Variants: Shift<br/>
/// Execution: Deferred enumeration.
/// </remarks>

There are other new functions added as well that did not exist in the original version.

Once we officially publish the openHistorian Grafana data source we will update the documentation page you are referring to, including notes about the changes above.

Thannks!
Ritchie

1 Like

In the meantime, you can look at our generated help docs here:
GrafanaAdapters.Functions.BuiltIn Namespace (gridprotectionalliance.org)

Note that most of the functions listted on this page have three definitions, one generic, one specific to the standard measurement value, and one speciifc to a phasor value tuple (a new data type supported by the openHistorian Grafana data source plugin).

Generally, you can just focus on the “generic” definition, as all the comments will be the same. Do note, however, there are few functions that are specific to either measurement or phasor values…

Thanks!
Ritchie

1 Like

Also, per your example, note that there is a new function called Reference that works with an OHPHASOR data source, i.e., phasor tuple values, that calculates phase angle differences.

Here is an example:

Label({PointTag}, Reference(0.0333, Unwrap(GPA_SEATTLE:LINE4_V1_500; 
GPA_CHATTANOOGA:500KV_LINEX_V1_500; GPA_BIRMINGHAM:115KV_LINE3_V1; 
GPA_DENVER:500KV_LINEG_V1_500; GPA_FORTKNOX:LINE3_V1_230; 
GPA_REYKJAVIK:BUS3_V1_500; GPA_HONULULU_APT:LINE1_V1_230; 
GPA_PHILADELPHIA:I1PM_V1_230; GPA_SANFRANCISCO:LINE3_V1_500;  
GPA_WESTPOINT_1:I1SPM_V1_230)))

Note that angles are in reference to the first angle specified, i.e., GPA_SEATTLE:LINE4_V1_500; .

You could also use a filter expression like the following:

Label({PointTag}, Reference(0.0333, Unwrap(GPA_SEATTLE:LINE4_V1_500; 
FILTER TOP 10 PhasorValues WHERE Phase='+' AND Type='V' AND 
PointTag <> 'GPA_SEATTLE:LINE4_V1_500')))

Note that the phasor value tuples include both angles and magnitude. If you want to hide the magnitudes from the trend you can use an override like the following:

image

Hope that helps!

Thanks,
Ritchie

1 Like

@ritchiecarroll : We are experiencing compatibility issues tu run the latest openHis plugin with Grafana, hence these new methods you describe above cannot be tested right now. Awaiting @clackner-gpa to look at it (bug fix likely). I understand that, in order to fulfill my mission as describe at the top, I need to wait for this fix. Please advice. Thanks!

Also thanks for the example above. I will give a try.