Read/Write comtrade recording, commonly used algorithm for recording.
Project description
read/write comtrade recording files, commonly used algorithm
Installation
pip3 uninstall comtraderecord
pip3 install comtraderecord
Table of Contents
-
pyComtrade
- read comtrade file
-
pyRelayAlg
- commonly used algorithm for comtrade recording
-
ComtradeWriter
- generate comtrade file
Example
1、read comtrade recording
import matplotlib.pyplot as plt
from comtraderecord import pyComtrade, pyRelayAlg
recFile = pyComtrade.ComtradeFile(r"D:\CustomerCare\FRA00001.CFG")
# Use channel name/id to get the analog channel data
VA = recFile.getAnalogData("MPV3p1:V A")
IB = recFile.getAnalogData(2)
# Use channel name/id to get the digital channel data
pickup = recFile.getDigitalData(1)
operate = recFile.getDigitalData("VI3p1:Group indicat.:Operate:general")
# get timestamp of the record
timestamp = recFile.getTime()
plt.subplot(5,1,1)
plt.plot(timestamp,VA)
plt.title("sampling VA")
plt.subplot(5,1,2)
plt.plot(timestamp,IB)
plt.title("sampling IB")
plt.subplot(5,1,3)
mag_Va = abs(pyRelayAlg.fourier(VA,recFile.samplePoint))
plt.plot(timestamp,mag_Va)
plt.title("magnitude VA")
plt.subplot(5,1,4)
plt.plot(timestamp,pickup)
plt.title("pickup")
plt.subplot(5,1,5)
plt.plot(timestamp,operate)
plt.title("operate")
plt.show()
print("samplePoint:",recFile.samplePoint)
print("sampleRate:",recFile.sampleRate)
print("numberOfSamples:",recFile.numberOfSamples)
print("analog_id:",recFile.analog_id)
print("analog_An:",recFile.analog_An)
print("digital_id:",recFile.digital_id)
print("digital_Dn:",recFile.digital_Dn)
print("freq:",recFile.freq)
print("fileType:",recFile.fileType)
print("startTime:",recFile.startTime)
print("triggerTime:",recFile.triggerTime)
print("\n\nrecording cfg data:")
for k,v in recFile.cfg_data.items():
print(f"{k}:{v}")
2、pyRelayAlg
recFile = pyComtrade.ComtradeFile(r"D:\CustomerCare\FRA00001.CFG")
# Use channel name/id to get the analog channel data
VA = recFile.getAnalogData("MPV3p1:V A")
# calculate 5rd harmonic of the signal with 2 cycle window
Harm_5th = pyRelayAlg.fourier(VA,samplePoint,2,5)
# calculate TrueRMS of the signal
TrueRMS = pyRelayAlg.TrueRMS(VA,samplePoint)
3、ComtradeWriter
from comtraderecord import comtradeWriter
import numpy as np
import math
time_s = 0.2
sample = 1000
ratedFreq = 50.0
ts = np.arange(0,time_s,1/sample)
fi = 2*np.pi*ratedFreq
recData = [0]*3
recData[0] = 5.0*math.sqrt(2)*np.sin(fi*ts)
recData[1] = 2.0*math.sqrt(2)*np.sin(fi*ts+np.pi*4/3)
recData[2] = 5.0*math.sqrt(2)*np.sin(fi*ts+np.pi*2/3)
f = comtradeWriter("testRec",recData,sample,ratedFreq)
channelID = [
'Line VA',
'Line VB',
'Line VC'
]
f.setChannelID(channelID)
f.setUnit(['V','V','V'])
f.createFile()
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
No source distribution files available for this release.See tutorial on generating distribution archives.
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file comtraderecord-1.0.2-py3-none-any.whl.
File metadata
- Download URL: comtraderecord-1.0.2-py3-none-any.whl
- Upload date:
- Size: 10.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7a1bae4794256c687629058531731c516b50655fe6b6152268a7acbfdb657384
|
|
| MD5 |
54c21b94d5b82aa1a1df711989365530
|
|
| BLAKE2b-256 |
7e7f56c6f2b97af63a8316104fba2796c4df24b4fe3248206940533a1f8ccead
|