Post Go back to editing

Low resolution waveforms in exported waveform

Category: Datasheet/Specs
Product Number: 24.
Software Version: 24.0.9

I am using a PyLTSpice library to automate LTspice simulations. In LTspice, I can identify my desired points on the waveforms and calculate dv/dt off, dv/dt on, and other time-domain features. However, when I read the waveform data using the Python script, the data is compressed and has much lower resolution than the simulation file. I also tried exporting the data as text directly from LTspice, but the resolution remains low. Is there any know any workaround for this issue? 

  • Hi  ,

    You'll want to decrease or remove waveform compression using .options. From the help:

    plotreltol .0025 Relative error tolerance for waveform compression.
    plotvntol 10μV Absolute voltage error tolerance for waveform compression.
    plotabstol 1nA Absolute current error tolerance for waveform compression.
    plotwinsize 300 Number of data points to compress in one window. Set to zero to disable compression.

    mike

  •  thanks for your response! ".options plotwinsize 0" decompressed data points when I export data as a text file directly from LTspice. However, still number of data points does not match from what I am getting using the PyLTSpice. Here is how I am getting the waveforms using PyLTSpice:  

    raw, log = runner.run_now(net, run_filename='./results.net')

    raw = RawRead("./results.raw")
    t = raw.get_axis()
    v = raw.get_trace('V(mid)').get_wave()
    I = raw.get_trace('I(Rlow)').get_wave()

  • Hi  ,

    I can't speak to PyLTspice, since I don't use it, nor do we support it.

    Nevertheless, this may be the confusing thing: note that the raw file is not “raw”, like a photo. It's simply a file extension applied to all waveforms, compressed or not.

    You need to have a way for PyLTspice to produce an uncompressed waveform, as you would from LTspice proper using.options plotwinsize 0. Is there a way in PyLTspice to pass the .options to your simulation command?

    Or, if you go into LTspice > Settings > Compression, and turn off compression, this should change the .ini file, as this setting is persistent, and I believe this will affect your simulations as run by PyLTspice? (no guarantee there):

    mike

  • Hi  

    Yes, I added .options plotwinsize 0 to the Spice directive, which increased the resolution of the exported data by around 20%. However, as I mentioned in my previous comment, the number of exported data points still does not match what I am getting in the PyLTSpice simulation. I also unchecked the compression setting, but it had almost no effect on the compression.

  • Hi  ,

    Guess I was wrong about the persistent setting. I'll have to ask around. Sorry, never used PyLTspice, so no idea what compression options it might have in its raw read algorithm. Just to double-check: you have directly compared the results.raw output of LTspice directly to the results.raw file output of PyLTspice and the file sizes are different?

    thanks,

    mike

  • Hi  ,

    From PyLTspice site:

    sim_batch.py This is a script to launch Spice Simulations. This is useful because:

    • Can overcome the limitation of only stepping 3 parameters
    • Different types of simulations .TRAN .AC .NOISE can be run in a single batch
    • The RAW Files are smaller and easier to treat

    From Generative AI (Take with rock-alt sized grain of salt, make that a distill-pond-sized…)

    PyLTSpice's RAW files can be smaller than LTSpice's due to how PyLTSpice handles data and the compression techniques it employs. LTSpice uses a lossy compression algorithm that significantly reduces file size, sometimes by a factor of 50. This compression is controlled by settings within LTSpice, allowing users to adjust the level of compression. PyLTSpice, on the other hand, is designed to create smaller and more manageable RAW files, which are easier to process and handle, particularly in batch simulations and data analysis.
    Both LTSpice and PyLTSpice store simulation data in RAW files, which include a text preamble containing information about the traces and simulation setup, followed by the binary data of the simulation results. The difference in file size arises from how each tool manages this data. PyLTSpice is optimized for creating smaller files, which is beneficial when running multiple simulations or dealing with large datasets. This optimization, combined with efficient data handling, results in smaller RAW files compared to those generated by LTSpice, especially when LTSpice's compression is not maximized.
    It seems unlikely that you can do an apples-to-apples, meaningful comparison of the two types of raw files as they are structurally different despite the shared extension.
    mike
  • Hi  

    Thanks for your detailed response. We're running thousands of simulations using PyLTSpice, and this compression is affecting our waveforms, resulting in much lower resolution compared to LTspice. Unfortunately, it seems there is no workaround for this issue.

  • Hi  ,

    Hmmm, hmmm, hmmm. I feel like the "more efficient" file size of PyLTspice should not be a lossy compression, like LTspice's. So…

    We may be barking up the wrong tree looking at waveform compression. My fault; just read your original post again. Most derivative problems, like dv/dt, are best served by lowering the maximum time step in transient analysis. It is possible that you can do achieve you want in PyLTspice by simply forcing a small time step size in .tran. Just shooting in the dark here. To wit, dTmax:

    .TRAN <Tstep> <Tstop> [Tstart [dTmax]] [modifiers]

    I can also ask our resident command line expert if it is possible to simply build your own batch app in Powershell as opposed to PyLTspice, but it looks like PyLTspice has a useful command structure.

    mike