Note
Go to the end to download the full example code.
Spectral Filter Example¶
This example demonstrates how spectral filtering is
applied to a state using
SpectralFilter
model, we also make use of
NumberStateSource
to generate the state.
from __future__ import annotations
from symop.devices.models import SpectralFilter, NumberStateSource
from symop.modes.labels import Path, Polarization
from symop.modes.envelopes import GaussianEnvelope
from symop.modes.transfer import GaussianLowpass
from symop.polynomial.state import KetPolyState
# Visualization Package
import symop.viz as VI
Setup
set up a mode labels and then the single photon source together with filter defined by a transfer function.
src_env = GaussianEnvelope(omega0=100.0, sigma=50.0, tau=0.0)
src_pol = Polarization.H()
src_dev = NumberStateSource(envelope=src_env, polarization=src_pol, n=1)
tf = GaussianLowpass(w0=100.0, sigma_w=0.01)
filt_dev = SpectralFilter(transfer=tf)
1) Generate the state
Generate the vacuum state for the source to populate
For populating the vacuum
__call__()can be used or.apply()
vac = KetPolyState.vacuum()
single_photon_state = src_dev(
vac,
ports={"out": Path("src_out")},
).with_label("in")
2) Use filtering device to filter
filtered_state = filt_dev(
single_photon_state,
ports={
"in": Path("src_out"), # Path leading from the source to filter
"out": Path("filt_out"),
},
).with_label("filt")
3) Inspect the state after filtering
VI.plot(single_photon_state)
VI.plot(filtered_state)
<Figure size 900x440 with 2 Axes>
3a) Display the input state
VI.display(single_photon_state)
3b) Display the filtered state
VI.display(filtered_state)
Total running time of the script: (0 minutes 0.527 seconds)
![$\hat{a}_{2[\mathrm{src\_out}]}^\dagger$, mode 2](../../_images/sphx_glr_example_002_spectral_filter_001.png)
![$0.42265\,|0\rangle\langle 0| + 0.57735\,\hat{a}_{5[\mathrm{filt\_out}]}^\dagger\,|0 \rangle\!\langle 0 |\,\hat{a}_{5[\mathrm{filt\_out}]}$, mode 5](../../_images/sphx_glr_example_002_spectral_filter_002.png)