RawRead Trace

class PyLTSpice.raw.raw_classes.Axis(name: str, whattype: str, datalen: int, numerical_type: str = 'double')[source]

Bases: DataSet

This class is used to represent the horizontal axis like on a Transient or DC Sweep Simulation. It derives from the DataSet and defines additional methods that are specific for X axis. This class is constructed by the get_time_axis() method or by a get_trace(0) command. In RAW files the trace 0 is always the X Axis. Ex: time for .TRAN simulations and frequency for the .AC simulations.

To access data inside this class, the get_wave() should be used, which implements the support for the STEPed data. IF Numpy is available, get_wave() will return a numpy array.

In Transient Analysis and in DC transfer characteristic, LTSpice uses doubles to store the axis values.

get_len(step: int = 0) int[source]

Returns the length of the axis. :param step: Optional parameter the step index. :type step: int :return: The number of data points :rtype: int

get_point(n, step: int = 0) Union[float, complex][source]

Get a point from the dataset :param n: position on the vector :type n:int :param step: step index :type step: int :returns: Value of the data point :rtype: float or complex

get_position(t, step: int = 0) Union[int, float][source]

Returns the position of a point in the axis. If the point doesn’t exist, an interpolation is done between the two closest points. For example, if the point requested is 1.0001ms and the closest points that exist in the axis are t[100]=1ms and t[101]=1.001ms, then the return value will be 100 + (1.0001ms-1ms)/(1.001ms-1ms) = 100.1

Parameters:
  • t (float) – point in axis to search for

  • step (int) – step number

Returns:

The position of parameter /t/ in the axis

Return type:

int, float

get_time_axis(step: int = 0)[source]

Deprecated. Use get_wave() instead.

Returns the time axis raw data. Please note that the time axis may not have a constant time step. LTSpice will increase the time-step in simulation phases where there aren’t value changes, and decrease time step in the parts where more time accuracy is needed.

Parameters:

step (int) – Optional step number if reading a raw file with stepped data.

Returns:

time axis

Return type:

numpy.array

get_wave(step: int = 0) array[source]

Returns a vector containing the wave values. If numpy is installed, data is returned as a numpy array. If not, the wave is returned as a list of floats.

If stepped data is present in the array, the user should specify which step is to be returned. Failing to do so, will return all available steps concatenated together.

Parameters:

step (int) – Optional step in stepped data raw files.

Returns:

The trace values

Return type:

numpy.array

step_offset(step: int)[source]

In Stepped RAW files, several simulations runs are stored in the same RAW file. This function returns the offset within the binary stream where each step starts.

Parameters:

step (int) – Number of the step within the RAW file

Returns:

The offset within the RAW file

Return type:

int

class PyLTSpice.raw.raw_classes.TraceRead(name, whattype, datalen, axis, numerical_type='real')[source]

Bases: DataSet

This class is used to represent a trace. It derives from DataSet and implements the additional methods to support STEPed simulations. This class is constructed by the get_trace() command. Data can be accessed through the [] and len() operators, or by the get_wave() method. If numpy is available the get_wave() method will return a numpy array.

get_len(step: int = 0) int[source]

Returns the length of the axis. :param step: Optional parameter the step index. :type step: int :return: The number of data points :rtype: int

get_point(n: int, step: int = 0) Union[float, complex][source]

Implementation of the [] operator.

Parameters:
  • n (int) – item in the array

  • step (int) – Optional step number

Returns:

float value of the item

Return type:

float

get_point_at(t, step: int = 0) Union[float, complex][source]

Get a point from the trace at the point specified by the /t/ argument. If the point doesn’t exist on the axis, the data is interpolated using a linear regression between the two adjacent points. :param t: point in the axis where to find the point. :type t: float, float32(numpy) or float64(numpy) :param step: step index :type step: int

get_wave(step: int = 0) array[source]

Returns the data contained in this object. For stepped simulations an argument must be passed specifying the step number. If no steps exist, the argument must be left blank. To know whether stepped data exist, the user can use the get_raw_property(‘Flags’) method.

If numpy is available the get_wave() method will return a numpy array.

Parameters:

step (int) – To be used when stepped data exist on the RAW file.

Returns:

a List or numpy array (if installed) containing the data contained in this object.

Return type:

numpy.array