Metadata-Version: 2.1
Name: mhi-psout
Version: 2.0.0
Summary: Manitoba Hydro International: PSOUT File Reader
Author-email: "Manitoba Hydro International Ltd." <pscad@mhi.ca>
License: BSD-3-Clause-Clear
Project-URL: Homepage, https://www.pscad.com/support/support-resources
Project-URL: Documentation, https://www.pscad.com/webhelp-v502-al/index.html
Classifier: Development Status :: 5 - Production/Stable
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Programming Language :: Python :: 3.15
Classifier: Operating System :: Microsoft :: Windows
Requires: wheel
Requires-Python: >=3.7
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: mhi.help>=1.0.5

# PSOut Reader & Writer

A reader/writer for the PSCAD *.psout file

## Examples

### Reading

```python
import mhi.psout
import matplotlib.pyplot as plt

with mhi.psout.File('Cigre.psout') as file:

    ac_voltage = file.call("Root/Main/AC Voltage/0")
    run = file.run(0)

    for call in ac_voltage.calls():
        trace = run.trace(call)
        time = trace.domain
        plt.plot(time.data, trace.data, label=trace['Description'])

    plt.xlabel(time['Unit'])
    plt.ylabel(trace['Unit'])
    plt.legend()
    plt.show()
```

### Writing

```python
from math import sin, cos, pi
from mhi.psout import File, OpenType, PageSize

with File('SinCos.psout', open_type=OpenType.CREATE_OVERWRITE,
          page_size=PageSize.PS_1024) as file:

    # Create Call Tree
    root = file.make_pscad_root()
    time_call = file.make_pscad_domain(1234567, 'PGB')
    module = root.add_module(200, "Trig Funcs")
    sin_call = module.add_pgb_call(201, "Sine")
    cos_call = module.add_pgb_call(202, "Cosine")

    # Create a "time" samples for all runs
    time = [0.001 * i for i in range(201)]

    for freq in (50, 60):
        run = file.add_run(Description=f"{freq} Hertz sin waves")
        w = 2 * pi * freq

        # Time domain
        time_trace = run.add_pscad_domain(time_call, unit='s', data=time)

        # Create "sin" and "cos" traces
        sine = [sin(w*t) for t in time]
        cosine = [cos(w*t) for t in time]

        run.add_pscad_trace(sin_call, 'Trig', domain=time_trace, data=sine)
        run.add_pscad_trace(cos_call, 'Trig', domain=time_trace, data=cosine)
```

## Documentation

See: ``py -m mhi.psout help``
