Metadata-Version: 2.4
Name: envelopes-qc
Version: 0.1.3
Summary: Envelops impelemented by C++ and Python.
Author-email: Shibo Xu <sbxu@zju.edu.cn>
Classifier: Programming Language :: Python :: 3
Classifier: Operating System :: Microsoft :: Windows
Classifier: Operating System :: POSIX :: Linux
Requires-Python: >=3.11
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: numpy>=1.13.3
Requires-Dist: scipy>=1.0.0
Dynamic: license-file

# envelopes-qc

High performance tools for building and decoding envelopes used in superconducting qubit experiments.

## Build

Before building on Linux, install the `libcerf3` and `libcerf-dev` packages in the `src/libcerf` folder, or download and install them according to your Linux distribution.

```bash
python -m build -w -v
```

## Installation

```bash
pip install envelopes-qc
```

Or build from source:

1. Clone the repository to your machine.
2. Install the package locally with one of the following commands:

```bash
# Development build (compile in place)
python setup.py build_ext --inplace
```

```bash
# Install into the active Python environment
pip install .
```

## Usage

```python
from envelopes import evc
import numpy as np

# Create a GaussianDRAG envelope
center = 15
width = 10
pi_pulse = evc.GaussianDRAG(
    t0=center, w=width, amp=1.0, coef=0.5, df=0.1, phase=0.0
)

# Schedule multiple pulses
amp = np.array([1, 0.3, 0.7, 0.8])
dt = np.array([0, 50, 100, 200])
xy = evc.align(pi_pulse, dt, amp)  # align the envelope to the given dt and amplitude

# The following code has equivalent effect but is less efficient:
# xy = 0
# for _dt, _amp in zip(dt, amp):
#     xy += (pi_pulse >> _dt) * _amp

# Decode the envelope
resolution = 0.5
wc = evc.WaveCache(resolution)
# t, wave = evc.decode_envelope(xy, wc)  # default start and end from the envelope
t_start, wave = evc.decode_envelope(xy, wc, start=-50, end=250)
# wave is already a zero-copy numpy ndarray view of the internal buffer
t_list = np.arange(t_start, t_start + len(wave) * resolution, resolution)

import matplotlib.pyplot as plt

plt.figure()
plt.plot(t_list, wave.real, '.-', label='real')
plt.plot(t_list, wave.imag, '.-', label='imag')
plt.legend()
plt.xlabel('time')
plt.ylabel('amplitude')
plt.tight_layout()
plt.show()
```

## Supported Envelopes

See [tests/supported_envelopes.ipynb](./tests/supported_envelopes.ipynb) and the detailed envelope reference in [doc/envelope_reference.md](./doc/envelope_reference.md).

## Speed Test

See [tests/speed_test.ipynb](./tests/speed_test.ipynb).

## Documentation

Detailed usage documentation is available in the [doc/](./doc/) folder. Start from [doc/index.md](./doc/index.md):

- [doc/index.md](./doc/index.md) — documentation entry point
- [doc/quickstart.md](./doc/quickstart.md) — quick start guide
- [doc/concepts.md](./doc/concepts.md) — core concepts (WaveCache, operators, serialization)
- [doc/envelope_reference.md](./doc/envelope_reference.md) — parameter reference for every envelope class
- [doc/api_reference.md](./doc/api_reference.md) — module-level functions and operators
- [doc/examples.md](./doc/examples.md) — complete usage examples
