Skip to content

relihanl/comtradehandlers

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Description

Its wikipedia entry describes COMTRADE (Common format for Transient Data Exchange for power systems) as "a file format for storing oscillography and status data related to transient power system disturbances".

This package supports file handlers for the COMTRADE format. It currently has the following limitations:

  • currently only has a writer. A COMTRADE reader will come later
  • Developed with reference to the "IEC 60255-24 Edition 2.0 2013-04, IEEE Std C37.111" standards document
  • the writer only supports ASCII format (1999 version) for the moment

Usage

Use the writer as follows:

from comtradehandlers import writer
import csv
import datetime
# lets use now as the start time
start_time = datetime.datetime.now()

# ...and 20 mills later as the trigger time
trigger_time = start_time + datetime.timedelta(milliseconds=20)

comtradeWriter = writer.ComtradeWriter("test3.cfg", start_time, trigger_time,rec_dev_id=250)

created_id = comtradeWriter.add_digital_channel("RELAY1", 0, 0, 0)
print("Created new digital channel " + str(created_id))

created_id = comtradeWriter.add_digital_channel("RELAY2", 0, 0, 0)
print("Created new digital channel " + str(created_id))



# A Current
created_id = comtradeWriter.add_analog_channel("IA", "A", "I", uu="A", skew=0, min=-500, max=500, primary=1,
                                               secondary=1)
print("Created new analog channel " + str(created_id))

# B Current
created_id = comtradeWriter.add_analog_channel("IB", "B", "I", uu="A", skew=0, min=-500, max=500, primary=1,
                                               secondary=1)
print("Created new analog channel " + str(created_id))

# C Current
created_id = comtradeWriter.add_analog_channel("IC", "C", "I", uu="A", skew=0, min=-500, max=500, primary=1,
                                               secondary=1)
print("Created new analog channel " + str(created_id))

# open a CSV file with raw data to insert. column 0 contains a microsecond offset from start_time
with open('outdata.csv', 'r') as csvfile:
    datareader = csv.reader(csvfile, delimiter=',', quotechar='|')
    next(datareader, None)  # skip the header
    for row in datareader:
        comtradeWriter.add_sample_record(row[0],
                                         [row[1], row[2], row[3]],
                                         [row[4], row[5]])

comtradeWriter.set_header_content("Data generated by comtradehandler from a CSV file. Enjoy!")

comtradeWriter.finalize()

See the example for more code.

Practically, to understand the various parameters ("uu", "primary", "secondary"), you will need to read the standard and be somewhat familiar with the problem domain.

Requirements

You need Python 3.4 or later to use this package.

Contact

This package was authored by Liam Relihan at www.resourcekraft.com. Contact him at liam.relihan@resourcekraft.com

License

This package is licensed under the terms of the MIT License (see the file LICENSE).

About

Python support for IEEE COMTRADE readers and writers

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages