Reference#
A *.psout file reader library.
The PSOUT file is a binary file that contains one or more collections of traces. Each trace is a 1-d vector of data. A trace may have an associated “domain” trace with the same length. Different traces are identified by a location in a “call tree”. All trace collections, known as “runs” share the same call tree, although a trace may not exist at every location of the call tree in different runs.
File#
- class mhi.psout.File#
A PSOUT file object
The PSOUT file contains a “Call Stack” and a list of “Runs”. The “Call Stack” describes a tree of calls into which traces are organized, and is shared by all runs. The traces themselves are stored in distinct “Runs”. A trace can only be retrieved given both a run and a call.
The file must be closed when no longer in use. To assist, File implements the context manager interface, so it may be used in a with statement so that it is automatically closed.
Example:
with mhi.psout.File("Cigre.psout") as file: ac_voltage_a_call = file.call("Root/Main/AC Voltage/Record/1") run = file.run(0) va = run.trace(ac_voltage_a_call) time = va.domain matplotlib.pyplot.plot(time.data, va.data, label="Phase A voltage")
General#
- File.path#
Path of the file
- File.created#
The ‘created on’ datetime
- File.modified#
The ‘modified on’ datetime
- File.variables() Dict[str, Any]#
Retrieve the key=value attributes stored with this object as a dictionary.
If only a single variable value is required,
item["VariableName"]may be used to fetch just that value.
- File.close()#
Closes the record file
Calls#
- File.root#
The root call for the file
- File.call(*path: int | str, sep='/') Call#
Retrive a call from the given path in the call stack / tree
- Parameters:
path – The call path, as names or ids
sep – A delimiter string, used when single string argument is given
Examples:
call = file.call("Root/Main/AC Voltage/Record/1", sep="/") call = file.call("Root", "Main", "AC Voltage", "Record", 1)
Note
A path segment composed entirely of digits is converted to an integer and used as a call id.
Runs#
- File.num_runs#
The number of runs in file
Call#
- class mhi.psout.Call#
A Call in the global call tree of the file.
All calls other than the root call node will have a parent. Every call may have child subcalls, which in turn can have grandchildren, great-grandchildern, and so on.
Identification#
- Call.id#
Returns call handle id
- Call.parent#
Return the parent call handle
Children#
- Call.num_calls#
Returns number of sub call handles
Run#
- class mhi.psout.Run(file: File)#
A handle to a run set in the file. A run set is a collection of traces that match the set structure defined by the call nodes
Identification#
- Run.id#
Returns run handle id
- Run.file#
File run is from
Traces#
- Run.num_traces#
Returns number of traces
- Run.trace(ident: int | Call) Trace#
Return a trace from this run identified by index or call.
- Parameters:
ident – the index or call of the trace
- Run.call(*args, sep='/') Trace#
Retrive a trace from this run for the given call path.
- Parameters:
path – The call path, as names or ids
sep – A delimiter string, used when single string argument is given
Examples:
trace = run.call("Root/Main/AC Voltage/Record/1", sep="/") trace = run.call("Root", "Main", "AC Voltage", "Record", 1)
Note
A path segment composed entirely of digits is converted to an integer and used as a call id.
Trace#
- class mhi.psout.Trace#
An individual trace stored in the file, identified by run and call.
Trace data is returned as an
array.array(), with an underlying type code specifying byte,intorfloatvalues of various precision.A trace may have an associated
domaintrace, such as time or frequency.Note
Neither
strnotcomplexdata types are supported byarray.array()at this time.
Identification#
- Trace.id#
Returns run handle id
- Trace.call#
Returns the associated call
- Trace.run#
Run trace is from
Data#
- Trace.domain#
The domain of the trace
- Trace.datatype#
Returns the trace datatype
- Trace.size#
Returns the size
- Trace.data#
Returns the sample values