# reconstruct

`boulderopal.noise_reconstruction.reconstruct(filter_functions, infidelities, infidelity_uncertainties=None, method=None)`

Estimate the power spectral density (PSD) of noise processes affecting a quantum system.

Use this function to obtain noise PSDs from measurements performed on your quantum system. You must provide the measurements as filter functions, which describe the controls applied to the system, and operational infidelities.

### Parameters

**filter_functions**(*list**[**list**[**FilterFunction**]**]*) – The filter functions associated with each control and noise. Each filter function represents the sensitivity of a set of controls to a certain noise. The placement in the outer list corresponds to the noise, while the inner list is organized by control. Note that at least one filter function must be present, and that the filter functions for each noise channel have to be sampled at the same frequencies.**infidelities**(*np.ndarray*) – The infidelities associated with the application of each control. It must contain at least one element, and all its values must be greater than or equal to 0, and less than or equal to 1.**infidelity_uncertainties**(*np.ndarray**or**None**,**optional*) – The uncertainty associated with each infidelity. The array must have the same length as the infidelities, and all values must be greater than or equal to 0, and less than or equal to 1. Defaults to None, in which case no uncertainty is associated to the infidelities.**method**(*NoiseReconstructionMethod**or**None**,**optional*) – The method to be used in the noise reconstruction. Defaults to the singular value decomposition (SVD) method with entropy truncation at 0.5.

### Returns

A dictionary containing the noise reconstruction result, with the following keys:

`output`

: A list with the spectral distributions of the reconstructed noises.
Each list entry is a dictionary containing the power spectral densities of a noise
(and the frequencies at which they are defined),
presented in the same sequence as provided in the filter_functions argument.
It might contain the estimated uncertainties for the spectral densities,
if you provide infidelity uncertainties.

`metadata`

: Metadata associated with the calculation.
No guarantees are made about the contents of this metadata dictionary;
the contained information is intended purely to help interpret the results of the
calculation on a one-off basis.

### Return type

dict

## Notes

From the filter function theory ^{1}, the operational infidelity for a given control
sequence applied on a weak-noise-perturbed quantum system is the overlap between the
noise power spectral density (PSD) and the corresponding filter functions:

where $S_k(f)$ is the PSD for the noise channel $k$, $F_{jk}(f)$ is the filter function corresponding to the control sequence $j$ and the noise channel $k$, and ${\mathcal I}_j$ is the measured infidelity after the control $j$ is applied to the system. Discretizing the integrals for all $M$ measurements gives the following linear equation:

$F'{\mathbf S} = {\mathbf I} ,$where $F' = [F'_1, \dots, F'_j, \dots, F'_{N_{\mathrm{noise}}}]$ is a $M \times K$ matrix and each element $F'_j$ is a $M \times K_j$ matrix representing the sampled filter functions weighted by discretized frequency step for the noise channel $j$ and $K \equiv \sum_{j=1}^{N_\mathrm{noise}} K_j$; noise PSD ${\mathbf S} = [{\mathbf S}_1, \dots, {\mathbf S}_j \dots, {\mathbf S}_K]^\top$ is a $K \times 1$ vector and each element ${\mathbf S}_j$ is a $K_j \times 1$ vector for noise channel $j$; infidelity vector ${\mathbf I} = [{\mathcal I}_1, {\mathcal I}_2, \dots, {\mathcal I}_M]^\top$ is a $M \times 1$ vector. Given sampled filter functions and infidelities, this function gives an estimation of the noise PSD ${\mathbf S}_{\mathrm{est}}$. If uncertainties are provided with infidelities, this function also returns the uncertainties in estimation.

## References

[1] T. J. Green, J. Sastrawan, H. Uys, and M. J. Biercuk, New Journal of Physics 15, 095004 (2013).

## Examples

Perform a simple noise reconstruction of one noise affecting frequency 2, using two pulses perfectly sensitive to frequencies 1 and 2:

```
>>> filter_functions = [
... [
... bo.noise_reconstruction.FilterFunction(
... frequencies=np.array([1, 2]), inverse_powers=np.array([1, 0])
... ),
... bo.noise_reconstruction.FilterFunction(
... frequencies=np.array([1, 2]), inverse_powers=np.array([0, 1])
... )
... ]
... ]
>>> result = bo.noise_reconstruction.reconstruct(
... filter_functions=filter_functions, infidelities=np.array([0, 1])
... )
>>> result["output"]
[{'frequencies': array([1., 2.]), 'psd': array([0., 1.])}]
```

See also the How to perform noise spectroscopy on arbitrary noise channels user guide.