Unable to extract CALC signals using openHistorian API

Hi Ricthie,
I am not being able to extract the measurements of Signal Type CALC using python openHistorian API although I am able to extract measurements of all other signal types. Kindly help in this regard.
Thanks and regards,
Datta

If it does not work can you please provide the calculation for active power that you have at your backend.

Reading CALC values from Python is working fine for me. What version of openHistorian are you using and what screen are you using to create the power calculations?

Are your calculated measurements associated with the PPA historian? You can check this by going to Metadata / Measurements from the openHistorian Manager main menu. From this screen, find the measurement you are attempting to read from Python and check the associated historian.

Older versions of openHistorian did not always associate the calculated power calculations with PPA when using the openHistorian Manager screen - but this has been fixed in more recent versions. If this is your issue, you can certainly manually associate the measurement with PPA historian such that you can read it from Python.

By the way, the easiest/best way to create power calculations is to use the web UI (typically from http://localhost:8180). From the web UI click on the Browse Devices button. When you are on the Devices screen, click on the desired device - this will pull up the screen labeled New Device Commissioning Wizard. On this screen select or verify associated voltages for for each current - the screen tries to guess at the correct associations when possible. Now select either Single Phase Power Calculations or Three Phase Power Calculations from the Tag Template drop-down. Now make sure PPA is selected for the Instance drop-down on the top right and click Save Device.

This will properly create power calculations for this device for the selected voltage / current pairs and associate the measurements with PPA such that the values can be read from Python.

If you want to replicate your own power calculations in Python, you can certainly calculate them yourself, our functions for this can be found here:

https://github.com/GridProtectionAlliance/gsf/blob/master/Source/Libraries/GSF.Core.Shared/Units/EE/Phasor.cs#L258

Thanks,
Ritchie

Hi Ritchie,
Thanks for the information. However I would like to inform that all the power measurements have been linked to PPA in my openHistorian. Regarding the code I have one small doubt does voltage.Value.Real and current.Value.Real correspond to Phase A voltage and current magnitude?

Per C# code: these power calculation functions work for any phase, i.e., A, B, C, +, -, or 0 - for example.

Per your Python value read issue: can you “trend” your power calculations using the Trend / Export Data screen in the web UI? If you cannot, maybe the values are not being calculated - we might need to check local clock time versus device time - we can check power calculation status in Status.txt file. If the web trending screen cannot pull the data, then the Python code will not be able to pull values either (as they will not exist). If you can trend the values in the web UI, there must be issue with your point selection in the Python code.

Thanks,
Ritchie

Yes Ritchie I am not being able to Trend the power calculations in Trend/Export Functionality however it can be trended in Grafana. Is there any fix for this?

That seems highly unusual. Perhaps we can join a webex and you can show me?

Sorry I was wrong. The trend is available on both Trend/Export and Grafana. I had given separate devices by mistake and out of that one device was inactive. However I still cant access the power calculations in python. I am using the following, is that right?

records_calc = metadata.GetMeasurementsBySignalType(SignalType.CALC, instance.Name)

Infact I am not getting any Calculation Signals.

That is exactly right. Can you query your openHistorian database table called SignalType and provide the contents? It should look something like this:

ID Name Acronym Suffix Abbreviation LongAcronym Source EngineeringUnits
1 Current Magnitude IPHM PM I CurrentMagnitude Phasor Amps
2 Current Phase Angle IPHA PA IH CurrentAngle Phasor Degrees
3 Voltage Magnitude VPHM PM V VoltageMagnitude Phasor Volts
4 Voltage Phase Angle VPHA PA VH VoltageAngle Phasor Degrees
5 Frequency FREQ FQ F Frequency PMU Hz
6 Frequency Delta (dF/dt) DFDT DF DF DfDt PMU NULL
7 Analog Value ALOG AV AV Analog PMU NULL
8 Status Flags FLAG SF S StatusFlags PMU NULL
9 Digital Value DIGI DV DV Digital PMU NULL
10 Calculated Value CALC CV CV Calculated PMU NULL
11 Statistic STAT ST ST Statistic Any NULL
12 Alarm ALRM AL AL Alarm Any NULL
13 Quality Flags QUAL QF QF QualityFlags Frame NULL

Also, you might try enumerating the measurementRecord.py values with Python in the metadata cache and checking the SignalTypeName properties - this should tell you if any CALC records are showing up the metadata.