In [1]:
from resonator_tools import circuit
import numpy as np
import pandas as pd
from IPython.display import display
%matplotlib inline
Although we could use the resonator tools to load data, here we want to use the Pandas library, which is used for statistical data analysis. It can handle many different file types including hdf5.
In [2]:
df = pd.read_csv('S11.txt',sep='\t')
Pandas has a very nice way of displaying the data. Let's look at the first few entries:
In [3]:
display(df.head())
Next, we define a reflection port measurement and add the data.
In [4]:
port1 = circuit.reflection_port(f_data=df["freq"].values,
z_data_raw=10**(df["mag"].values/20.)*np.exp(1j*df["phase"].values/180.*np.pi))
Perform an automated fit.
In [5]:
port1.autofit()
Let's plot the data and the fit!
In [6]:
port1.plotall()
Next, let us have a look at the fit results. Here, we convert the dictionary of results into a dataframe to display it in a nicer way.
In [7]:
display(pd.DataFrame([port1.fitresults]).applymap(lambda x: "{0:.2e}".format(x)))
Finally, we can calculate the single photon limit, i.e., the input power necessary to maintain one photon on average in the resonator:
In [8]:
print 'Single photon limit: %.2f dBm' % port1.get_single_photon_limit()
Or, we can compute the photons in the resonator for a given power:
In [9]:
print 'At -100dBm, we have %.2e photons in the resonator' % port1.get_photons_in_resonator(-100)