RawRead

class PyLTSpice.raw_read.RawRead(raw_filename: str, traces_to_read: Optional[Union[str, List[str], Tuple[str]]] = '*', **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.

Parameters:
  • raw_filename (str | pahtlib.Path) – The file containing the RAW data to be read

  • traces_to_read (str, list or tuple) – A string or a list containing the list of traces to be read. If None is provided, only the header is read and all trace data is discarded. If a ‘*’ wildcard is given or no parameter at all then all traces are read.

Key headeronly:

Used to only load the header information and skip the trace data entirely. Use headeronly=True.

ACCEPTED_PLOTNAMES = ('AC Analysis', 'DC transfer characteristic', 'Operating Point', 'Transient Analysis', 'Transfer Function', 'Noise Spectral Density', 'Frequency Response Analysis')
get_axis(step: int = 0)[source]

This function is equivalent to get_trace(0).get_wave(step) instruction. It also implements a workaround on a LTSpice issue when using 2nd Order compression, where some values on the time trace have a negative value. :param step: Step number :type step: int :returns: Array with the X axis :rtype: list[float] or numpy.array

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

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

get_raw_property(property_name=None)[source]

Get a property. By default it returns all properties defined in the RAW file.

Parameters:

property_name (str) – name of the property to retrieve.

Returns:

Property object

Return type:

str

Raises:

ValueError if the property doesn’t exist

get_steps(**kwargs)[source]

Returns the steps that correspond to the query set in the * * kwargs parameters. Example:

raw_read.get_steps(V5=1.2, TEMP=25)

This will return all steps in which the voltage source V5 was set to 1.2V and the TEMP parameter is 24 degrees. This feature is only possible if a .log file with the same name as the .raw file exists in the same directory. Note: the correspondence between step numbers and .STEP information is stored on the .log file.

Key kwargs:

key-value arguments in which the key correspond to a stepped parameter or source name, and the value is the stepped value.

Returns:

The steps that match the query

Return type:

list[int]

get_time_axis(step: int = 0)[source]

(Deprecated) Use get_axis method instead

This function is equivalent to get_trace(‘time’).get_time_axis(step) instruction. It’s workaround on a LTSpice issue when using 2nd Order compression, where some values on the time trace have a negative value.

get_trace(trace_ref: Union[str, int])[source]

Retrieves the trace with the requested name (trace_ref).

Parameters:

trace_ref (str or int) – Name of the trace or the index of the trace

Returns:

An object containing the requested trace

Return type:

DataSet subclass

Raises:

IndexError – When a trace is not found

get_trace_names()[source]

Returns a list of exiting trace names inside of the RAW file.

Returns:

trace names

Return type:

list[str]

get_wave(trace_ref: Union[str, int], step: int = 0)[source]

Retrieves the trace data with the requested name (trace_ref), optionally providing the step number.

Parameters:
  • trace_ref (str or int) – Name of the trace or the index of the trace

  • step (int) – Optional parameter specifying which step to retrieve.

Returns:

A numpy array containing the requested waveform.

Return type:

numpy.array

Raises:

IndexError – When a trace is not found

header_lines = ('Title', 'Date', 'Plotname', 'Output', 'Flags', 'No. Variables', 'No. Points', 'Offset', 'Command', 'Variables', 'Backannotation')