Giter VIP home page Giter VIP logo

spr's Introduction

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 [email protected]: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 [email protected]: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 [email protected]: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

spr's People

Contributors

goncalo-godwitlabs avatar

Watchers

Marcin avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.