LTSpice_RawRead module

From Nuno Brum’s PyLTSpice project: https://github.com/nunobrum/PyLTSpice
A pure python implementation of an LTSpice RAW file reader.
The reader returns a class containing all the traces read from the RAW File.
In case there there stepped data detected, it will try to open the simulation LOG file and read the stepping information.
Traces are accessible by the method <LTSpiceReader instance>.get_trace(trace_ref) where trace_ref is either the name of the net on the LTSPice Simulation. Normally trace references are stored with the format V(<node_name>) for voltages or I(device_reference). For example V(n001) or I(R1) or Ib(Q1).
For checking step, the method <LTSpiceReader instance>.get_steps() is used. In case there are no steps in the simulation, the class will return a single element list.
NOTE: This module tries to import the numpy if exists on the system.
If it finds numpy all data is later provided as an array. If not it will use a standard list of floats.

Classes:

Axis(name, datatype, datalen[, numerical_type])

This class is used to represent the horizontal axis like on a Transient or DC Sweep Simulation.

DataSet(name, datatype, datalen[, …])

Class for storing Traces.

DummyTrace(name, datatype)

Dummy Trace for bypassing traces while reading

LTSpiceRawRead(raw_filename[, traces_to_read])

Class for reading LTSpice wave Files.

Op(name, datatype, datalen, axis[, …])

Class used for storing operation points.

RawRead

This section is for testing your code

Trace(name, datatype, datalen, axis[, …])

Class used for storing generic traces that report to a given Axis.

Exceptions:

LTSPiceReadException

Custom class for exception handling

class LTSpice_RawRead.Axis(name, datatype, datalen, numerical_type='real')[source]

Bases: LTSpice_RawRead.DataSet

This class is used to represent the horizontal axis like on a Transient or DC Sweep Simulation.

Methods:

_set_steps(step_info)

get_time_axis([step])

get_wave([step])

step_offset(step)

_set_steps(step_info)[source]
get_time_axis(step=0)[source]
get_wave(step=0)[source]
step_offset(step)[source]
class LTSpice_RawRead.DataSet(name, datatype, datalen, numerical_type='real')[source]

Bases: object

Class for storing Traces.

Methods:

get_len()

get_point(n)

get_wave()

set_pointA(n, value)

function to be used on ASCII RAW Files.

set_pointB16(n, value)

set_pointB4(n, value)

Function that converts a normal trace into float on a Binary storage.

set_pointB8(n, value)

Function that converts the variable 0, normally associated with the plot X axis.

get_len()[source]
get_point(n)[source]
get_wave()[source]
set_pointA(n, value)[source]

function to be used on ASCII RAW Files.

Parameters
  • n – the point to set

  • value – the Value of the point being set.

set_pointB16(n, value)[source]
set_pointB4(n, value)[source]

Function that converts a normal trace into float on a Binary storage. This codification uses 4 bytes. The codification is done as follows:

.

7

6

5

4

3

2

1

0

Byte3

SGM

SGE

E6

E5

E4

E3

E2

E1

SGM - Signal of Mantissa: 0 - Positive 1 - Negative

Byte2

E0

M22

M21

M20

M19

M18

M17

M16

SGE - Signal of Exponent: 0 - Positive 1 - Negative

Byte1

M15

M14

M13

M12

M11

M10

M9

M8

E[6:0] - Exponent

Byte0

M7

M6

M5

M4

M3

M2

M1

M0

M[22:0] - Mantissa.

set_pointB8(n, value)[source]

Function that converts the variable 0, normally associated with the plot X axis. The codification is done as follows:

.

7

6

5

4

3

2

1

0

Byte7

SGM

SGE

E9

E8

E7

E6

E5

E4

SGM - Signal of Mantissa: 0 - Positive 1 - Negative

Byte6

E3

E2

E1

E0

M51

M50

M49

M48

SGE - Signal of Exponent: 0 - Positive 1 - Negative

Byte5

M47

M46

M45

M44

M43

M42

M41

M40

E[9:0] - Exponent

Byte4

M39

M38

M37

M36

M35

M34

M33

M32

M[51:0] - Mantissa.

Byte3

M31

M30

M29

M28

M27

M26

M25

M24

Byte2

M23

M22

M21

M20

M19

M18

M17

M16

Byte1

M15

M14

M13

M12

M11

M10

M9

M8

Byte0

M7

M6

M5

M4

M3

M2

M1

M0

class LTSpice_RawRead.DummyTrace(name, datatype)[source]

Bases: object

Dummy Trace for bypassing traces while reading

Methods:

set_pointA(n, value)

set_pointB16(n, value)

set_pointB4(n, value)

set_pointB8(n, value)

set_pointA(n, value)[source]
set_pointB16(n, value)[source]
set_pointB4(n, value)[source]
set_pointB8(n, value)[source]
exception LTSpice_RawRead.LTSPiceReadException[source]

Bases: Exception

Custom class for exception handling

class LTSpice_RawRead.LTSpiceRawRead(raw_filename, traces_to_read='*', **kwargs)[source]

Bases: object

Class for reading LTSpice wave Files. It can read all types of Files. If stepped data is detected, it will also try to read the corresponding LOG file so to retrieve the stepped data.

Methods:

_load_step_information(filename)

get_raw_property([property_name])

Get a property.

get_steps(**kwargs)

get_time_axis([step])

This funcion is to workaround on a LTSpice issue when using 2nd Order compression, where some values have a negative value

get_trace(trace_ref)

Retrieves the trace with the name given.

get_trace_names()

Attributes:

header_lines

_load_step_information(filename)[source]
get_raw_property(property_name=None)[source]

Get a property. By default it returns everything

get_steps(**kwargs)[source]
get_time_axis(step=0)[source]

This funcion is to workaround on a LTSpice issue when using 2nd Order compression, where some values have a negative value

get_trace(trace_ref)[source]

Retrieves the trace with the name given.

get_trace_names()[source]
header_lines = ['Title', 'Date', 'Plotname', 'Output', 'Flags', 'No. Variables', 'No. Points', 'Offset', 'Command', 'Variables', 'Backannotation']
class LTSpice_RawRead.Op(name, datatype, datalen, axis, numerical_type='real')[source]

Bases: LTSpice_RawRead.Trace

Class used for storing operation points.

LTSpice_RawRead.RawRead

This section is for testing your code

alias of LTSpice_RawRead.LTSpiceRawRead Methods:

_load_step_information(filename)

get_raw_property([property_name])

Get a property.

get_steps(**kwargs)

get_time_axis([step])

This funcion is to workaround on a LTSpice issue when using 2nd Order compression, where some values have a negative value

get_trace(trace_ref)

Retrieves the trace with the name given.

get_trace_names()

Attributes:

header_lines

class LTSpice_RawRead.Trace(name, datatype, datalen, axis, numerical_type='real')[source]

Bases: LTSpice_RawRead.DataSet

Class used for storing generic traces that report to a given Axis.

Methods:

get_point([n, step])

get_wave([step])

get_point(n=0, step=0)[source]
get_wave(step=0)[source]