ltspice


Nameltspice JSON
Version 1.0.6 PyPI version JSON
download
home_pagehttps://github.com/DongHoonPark/ltspice_pytool
SummaryDESC
upload_time2022-10-04 07:38:53
maintainer
docs_urlNone
authorDonghoonPark
requires_python
licenseMIT
keywords ltspice circuit data analysis multi point simulation
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # LTSpice data parsing library for python

## Installation

```sh
$ pip install ltspice
```

## Supported Files
* encoding : UTF8 / UTF16-LE
* format : Binary / Ascii
* extenstion : .raw / .fft

## Usage

```python
import ltspice
filepath = 'Your ltspice output file (.raw)'
l = ltspice.Ltspice(filepath)
l.parse() # Data loading sequence. It may take few minutes for huge file.

time = l.get_time()
V1 = l.get_data('V(N1)')
```

## Examples

### 01 - RC Circuit

#### LTSpice file (.asc)

<img src="https://github.com/DongHoonPark/ltspice_pytool/blob/master/examples/01_RC/rc.jpg?raw=true" width="500">

#### Python code (.py)

```python
import ltspice
import matplotlib.pyplot as plt
import numpy as np
import os

l = ltspice.Ltspice(os.path.dirname(__file__)+'\\rc.raw') 
# Make sure that the .raw file is located in the correct path
l.parse() 

time = l.get_time()
V_source = l.get_data('V(source)')
V_cap = l.get_data('V(cap)')

plt.plot(time, V_source)
plt.plot(time, V_cap)
plt.show()
```

#### Output result
<img src="https://github.com/DongHoonPark/ltspice_pytool/blob/master/examples/01_RC/rc.png?raw=true" width="500">

### 02 - Multi point simulation

#### LTSpice file (.asc)
<img src="https://github.com/DongHoonPark/ltspice_pytool/blob/master/examples/02_Rectifier/rectifier.jpg?raw=true" width="500">

#### Python code (.py)

```python
import ltspice
import matplotlib.pyplot as plt
import numpy as np
import os

l = ltspice.Ltspice(os.path.dirname(__file__)+'\\rectifier.raw') 
# Make sure that the .raw file is located in the correct path
l.parse() 

time = l.get_time()
V_source = l.get_data('V(source)')
V_cap_max = []

plt.plot(time, V_source)
for i in range(l.case_count): # Iteration in simulation cases 
    time = l.get_time(i)
    # Case number starts from zero
    # Each case has different time point numbers
    V_cap = l.get_data('V(cap,pgnd)',i)
    V_cap_max.append(max(V_cap))
    plt.plot(time, V_cap)

print(V_cap_max)

plt.xlim((0, 1e-3))
plt.ylim((-15, 15))
plt.grid()
plt.show()

```

#### Output result

```sh
$ [8.299080580472946, 7.855469107627869, 7.391375303268433, 6.944645524024963, 6.529755532741547]

```

<img src="https://github.com/DongHoonPark/ltspice_pytool/blob/master/examples/02_Rectifier/rectifier.png?raw=true" width="500">

If you want to find more usage examples, please check examples folder. 

####
            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/DongHoonPark/ltspice_pytool",
    "name": "ltspice",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "ltspice,circuit data analysis,multi point simulation",
    "author": "DonghoonPark",
    "author_email": "donghun94@snu.ac.kr",
    "download_url": "https://files.pythonhosted.org/packages/6a/7b/80a1552d54ffd1854b9f5a762227aaddcee7a2ee1447be298e804f087019/ltspice-1.0.6.tar.gz",
    "platform": null,
    "description": "# LTSpice data parsing library for python\n\n## Installation\n\n```sh\n$ pip install ltspice\n```\n\n## Supported Files\n* encoding : UTF8 / UTF16-LE\n* format : Binary / Ascii\n* extenstion : .raw / .fft\n\n## Usage\n\n```python\nimport ltspice\nfilepath = 'Your ltspice output file (.raw)'\nl = ltspice.Ltspice(filepath)\nl.parse() # Data loading sequence. It may take few minutes for huge file.\n\ntime = l.get_time()\nV1 = l.get_data('V(N1)')\n```\n\n## Examples\n\n### 01 - RC Circuit\n\n#### LTSpice file (.asc)\n\n<img src=\"https://github.com/DongHoonPark/ltspice_pytool/blob/master/examples/01_RC/rc.jpg?raw=true\" width=\"500\">\n\n#### Python code (.py)\n\n```python\nimport ltspice\nimport matplotlib.pyplot as plt\nimport numpy as np\nimport os\n\nl = ltspice.Ltspice(os.path.dirname(__file__)+'\\\\rc.raw') \n# Make sure that the .raw file is located in the correct path\nl.parse() \n\ntime = l.get_time()\nV_source = l.get_data('V(source)')\nV_cap = l.get_data('V(cap)')\n\nplt.plot(time, V_source)\nplt.plot(time, V_cap)\nplt.show()\n```\n\n#### Output result\n<img src=\"https://github.com/DongHoonPark/ltspice_pytool/blob/master/examples/01_RC/rc.png?raw=true\" width=\"500\">\n\n### 02 - Multi point simulation\n\n#### LTSpice file (.asc)\n<img src=\"https://github.com/DongHoonPark/ltspice_pytool/blob/master/examples/02_Rectifier/rectifier.jpg?raw=true\" width=\"500\">\n\n#### Python code (.py)\n\n```python\nimport ltspice\nimport matplotlib.pyplot as plt\nimport numpy as np\nimport os\n\nl = ltspice.Ltspice(os.path.dirname(__file__)+'\\\\rectifier.raw') \n# Make sure that the .raw file is located in the correct path\nl.parse() \n\ntime = l.get_time()\nV_source = l.get_data('V(source)')\nV_cap_max = []\n\nplt.plot(time, V_source)\nfor i in range(l.case_count): # Iteration in simulation cases \n    time = l.get_time(i)\n    # Case number starts from zero\n    # Each case has different time point numbers\n    V_cap = l.get_data('V(cap,pgnd)',i)\n    V_cap_max.append(max(V_cap))\n    plt.plot(time, V_cap)\n\nprint(V_cap_max)\n\nplt.xlim((0, 1e-3))\nplt.ylim((-15, 15))\nplt.grid()\nplt.show()\n\n```\n\n#### Output result\n\n```sh\n$ [8.299080580472946, 7.855469107627869, 7.391375303268433, 6.944645524024963, 6.529755532741547]\n\n```\n\n<img src=\"https://github.com/DongHoonPark/ltspice_pytool/blob/master/examples/02_Rectifier/rectifier.png?raw=true\" width=\"500\">\n\nIf you want to find more usage examples, please check examples folder. \n\n####",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "DESC",
    "version": "1.0.6",
    "project_urls": {
        "Download": "https://pypi.org/project/ltspice",
        "Homepage": "https://github.com/DongHoonPark/ltspice_pytool"
    },
    "split_keywords": [
        "ltspice",
        "circuit data analysis",
        "multi point simulation"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "6a7b80a1552d54ffd1854b9f5a762227aaddcee7a2ee1447be298e804f087019",
                "md5": "f96786c25069df4a20dd36a5e4550441",
                "sha256": "b9ec773e35262f72379a44c70874c3967100593e34802ec0546af656adfa17a7"
            },
            "downloads": -1,
            "filename": "ltspice-1.0.6.tar.gz",
            "has_sig": false,
            "md5_digest": "f96786c25069df4a20dd36a5e4550441",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 6183,
            "upload_time": "2022-10-04T07:38:53",
            "upload_time_iso_8601": "2022-10-04T07:38:53.936839Z",
            "url": "https://files.pythonhosted.org/packages/6a/7b/80a1552d54ffd1854b9f5a762227aaddcee7a2ee1447be298e804f087019/ltspice-1.0.6.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2022-10-04 07:38:53",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "DongHoonPark",
    "github_project": "ltspice_pytool",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "requirements": [],
    "tox": true,
    "lcname": "ltspice"
}
        
Elapsed time: 0.18326s