LTSpiceLogReader¶
- class PyLTSpice.LTSteps.LTSpiceLogReader(log_filename: str, read_measures=True, step_set={}, encoding=None)[source]¶
Bases:
object
Reads an LTSpice log file and retrieves the step information if it exists. The step information is then accessible by using the ‘stepset’ property of this class. This class is intended to be used together with the LTSpice_RawRead to retrieve the runs that are associated with a given parameter setting.
This class constructor only reads the step information of the log file. If the measures are needed, then the user should call the get_measures() method.
- Property stepset:
dictionary in which the keys are the variables that were STEP’ed during the simulation and the associated value is a list representing the sequence of assigned values during simulation.
- Property headers:
list containing the headers on the exported data. This is only populated when the read_measures optional parameter is set to False.
- Property dataset:
dictionary in which the keys are the the headers and the export file and the values are lists. This is information is only populated when the read_measures optional parameter is set to False.
- Parameters:
log_filename (str) – path to the Export file.
read_measures (boolean) – Optional parameter to skip measuring data reading.
step_set (dict) – Optional parameter to provide the steps from another file. This is used to process .mout files.
- export_data(export_file: str, append_with_line_prefix=None)[source]¶
Exports the measurement information to a tab separated value (.tsv) format. If step data is found, it is included in the exported file.
When using export data together with sim_batch.py classes, it may be helpful to append data to an existing file. For this purpose, the user can user the append_with_line_prefix argument to indicate that an append should be done. And in this case, the user must provide a string that will identify the LTSpice batch run.
- Parameters:
export_file (str) – path to the file containing the information
append_with_line_prefix (str) – user information to be written in the file in case an append is to be made.
- Returns:
Nothing
- get_measure_names() List[str] [source]¶
Returns the names of the measurements read from the log file. :return: List of measurement names. :rtype: list of str
- get_measure_value(measure: str, step: Optional[int] = None) Union[float, int, str, complex] [source]¶
Returns a measure value on a given step.
- Parameters:
measure (str) – name of the measurement to get
step (int) – optional step number if the simulation has no steps.
- get_measure_values_at_steps(measure: str, steps: Union[int, Iterable])[source]¶
Returns the measurements taken at a list of steps provided by the steps list.
- Parameters:
measure (str) – name of the measurement to get.
steps (int or list) – step number, or list of step numbers.
- Returns:
measurement or list of measurements
- Return type:
int or Iterable
- get_step_vars() List[str] [source]¶
Returns the stepped variable names of . :return: List of step variables. :rtype: list of str
- split_complex_values_on_datasets()[source]¶
Internal function to split the complex values into additional two columns TODO: Delete the old data and insert new ones the the right position
- steps_with_conditions(**conditions) List[int] [source]¶
Returns the steps that respect one more more equality conditions
- Key conditions:
parameters within the LTSpice simulation. Values are the matches to be found.
- Returns:
List of steps that repect all the given conditions
- Return type:
List[int]
- steps_with_parameter_equal_to(param: str, value: Union[str, int, float]) List[int] [source]¶
Returns the steps that contain a given condition.
- Parameters:
param (str) – parameter identifier on LTSpice simulation
value –
- Returns:
List of positions that respect the condition of equality with parameter value
- Return type:
List[int]