Skip to main content

A tiny Python package to parse spice raw data files

Project description

Spice Raw Parser (spr)

A tiny Python package to parse spice raw data files.

Getting Started

These instructions will get you a copy of the package up and running on your local machine.

Note: at the moment only ascii raw spice format is supported!

Installation

From PyPI

pip install spr

From source code

pip install git+https://github.com/goncalo-godwitlabs/spr.git

or

git clone git@github.com:goncalo-godwitlabs/spr.git
cd spr/
make install

Usage

Just run:

from spr import load_raw
data = load_raw("/path/to/rawspice.raw")

Data structure

A properly parsed raw spice file by load_raw() returns a dictionary with the following structure:

{
    "title": <str>,
    "date:": <str>,
    "plotname:": <str>,
    "flags:": <str>,
    "no_vars:": <str>,
    "no_points:": <str>,
    "vars": [
        { "idx": <int>, "name": <str>, "type": <str> },
        { "idx": <int>, "name": <str>, "type": <str> }
        ...
        { "idx": <int>, "name": <str>, "type": <str> }
    ]
    "values": {
        "var1": <numpy.ndarray>,
        "var2": <numpy.ndarray>,
        ...
        "varN": <numpy.ndarray>
    }
}

Where values values is a numpy structured array with the actual data.

Examples

The following examples make use of ngspice to run the spice simulations, so please ensure it is installed. On ubuntu that would be:

sudo apt install ngspice

Inverting amplifier with an opamp LM741

Check the directory examples/amplifier/ for details on the cirtcuit and the simulation files.

The schematic:

Run the simulation with:

git clone git@github.com:goncalo-godwitlabs/spr.git
cd spr
make run-example-amplifier

which will fire ngspice generating output.log and rawspice.raw files and also plots the voltages vin and vout.

Second order low pass filter with an opamp LM741

Check the directory examples/lp_filter/ for details on the cirtcuit and the simulation files.

The schematic:

Run the simulation with:

git clone git@github.com:goncalo-godwitlabs/spr.git
cd spr
make run-example-lp_filter

which will fire ngspice generating output.log and rawspice.raw files and also plots the gain vout/vin in dB.

License

This project is licensed under the MIT License - see the LICENSE.md file for details

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

spr-0.2.1.tar.gz (3.5 kB view details)

Uploaded Source

Built Distribution

spr-0.2.1-py2-none-any.whl (3.8 kB view details)

Uploaded Python 2

File details

Details for the file spr-0.2.1.tar.gz.

File metadata

  • Download URL: spr-0.2.1.tar.gz
  • Upload date:
  • Size: 3.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for spr-0.2.1.tar.gz
Algorithm Hash digest
SHA256 9699478ab712c4c40a050824aecc642885e902d5f004131229d53906b21be44e
MD5 882a33c9b1b7b527ddb8bad241cd5dca
BLAKE2b-256 172d985d639ea5663e6bff8222f0f1c4d736df31d719e5f2b9681a03b11912ee

See more details on using hashes here.

File details

Details for the file spr-0.2.1-py2-none-any.whl.

File metadata

File hashes

Hashes for spr-0.2.1-py2-none-any.whl
Algorithm Hash digest
SHA256 ae44021c85638fd0b6b3447368e8f8ce38737b109db418bf902de581a7fcc4dc
MD5 2967eec1da3551d09a1f3f9335eba9be
BLAKE2b-256 73a0163d79c601883ed53da9d665318fcd5418ea48f68bfdc4885b817f6b1037

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page