Skip to content

Commit

Permalink
Merge branch 'Proj/NovDemo' into eQASM_data
Browse files Browse the repository at this point in the history
  • Loading branch information
gtaifu committed Mar 30, 2018
2 parents cd1b45e + ef8d86c commit c139d1b
Show file tree
Hide file tree
Showing 38 changed files with 1,585 additions and 745 deletions.
5 changes: 5 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ before_install:
- chmod +x miniconda.sh
- ./miniconda.sh -b -p /home/travis/mc
- export PATH=/home/travis/mc/bin:$PATH
- export PYTHONPATH=$PYTHONPATH:$(pwd)


# command to install dependencies
Expand All @@ -38,7 +39,11 @@ install:

- pip install --upgrade pip
- pip install -r requirements.txt
- pip install ply # a requirement for pygsti
- pip install plotly # a requirement for pygsti
- pip install networkx # a requirement for pygsti
- pip install git+git://github.com/DiCarloLab-Delft/Qcodes.git
- pip install git+git://github.com/AdriaanRol/AutoDepGraph.git@v02_networkx_rewrite -e .
- pip install coverage pytest-cov pytest --upgrade
- pip install coveralls
- pip install codacy-coverage
Expand Down
26 changes: 13 additions & 13 deletions examples/AWG8_examples/AWG8_staircase_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,15 @@
reload(QuTech_CCL)

CCL = QuTech_CCL.CCL('CCL', address='192.168.0.11', port=5025)
cs_filepath = os.path.join(pq.__path__[0], 'measurement','openql_experiments',
'output','cs.txt')
cs_filepath = os.path.join(pq.__path__[0], 'measurement', 'openql_experiments',
'output', 'cs.txt')

CCL.control_store(cs_filepath)

# AWG8 = ZI_HDAWG8.ZI_HDAWG8('AWG8_8003', device='dev8003')
AWG8 = ZI_HDAWG8.ZI_HDAWG8('AWG8_8004', device='dev8004')
# AWG8 = ZI_HDAWG8.ZI_HDAWG8('AWG8_8004', device='dev8004')
# AWG8 = ZI_HDAWG8.ZI_HDAWG8('AWG8_8005', device='dev8005')
# AWG8 = ZI_HDAWG8.ZI_HDAWG8('AWG8_8006', device='dev8006')
AWG8 = ZI_HDAWG8.ZI_HDAWG8('AWG8_8006', device='dev8006')
# AWG8 = ZI_HDAWG8.ZI_HDAWG8('AWG8_8008', d/evice='dev8008')


Expand All @@ -52,12 +52,12 @@

if AWG_type == 'microwave':
example_fp = os.path.abspath(
os.path.join(pq.__path__[0], '..','examples','CCLight_example',
'qisa_test_assembly','consecutive_cws_double.qisa'))
os.path.join(pq.__path__[0], '..', 'examples', 'CCLight_example',
'qisa_test_assembly', 'consecutive_cws_double.qisa'))
elif AWG_type == 'flux':
example_fp = os.path.abspath(os.path.join(pq.__path__[0], '..',
'examples','CCLight_example',
'qisa_test_assembly','consecutive_cws_flux.qisa'))
'examples', 'CCLight_example',
'qisa_test_assembly', 'consecutive_cws_flux.qisa'))

print(example_fp)
CCL.eqasm_program(example_fp)
Expand All @@ -74,14 +74,15 @@
waveform_type = 'square'
# waveform_type = 'cos'

if waveform_type =='square':
if waveform_type == 'square':
for ch in range(8):
for i in range(32):
AWG8.set('wave_ch{}_cw{:03}'.format(ch+1, i), (np.ones(48)*i/32))
elif waveform_type == 'cos':
for ch in range(8):
for i in range(32):
AWG8.set('wave_ch{}_cw{:03}'.format(ch+1, i), (np.cos(np.arange(48)/2)*i/32))
AWG8.set('wave_ch{}_cw{:03}'.format(ch+1, i),
(np.cos(np.arange(48)/2)*i/32))
else:
raise KeyError()

Expand All @@ -91,11 +92,10 @@
AWG8.upload_codeword_program()



##########################################
# 4. Configuring the DIO protocol #
##########################################
AWG8.cfg_codeword_protocol('microwave') # <- ensures all bits are uploaded
AWG8.cfg_codeword_protocol('microwave') # <- ensures all bits are uploaded
AWG8.configure_codeword_protocol()
AWG8.upload_codeword_program()
AWG8.calibrate_dio_protocol()
AWG8.calibrate_dio_protocol()
41 changes: 35 additions & 6 deletions examples/CCLight_example/UHFQC_staircase_rolutman.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,33 @@
import os
import pycqed as pq
import qcodes as qc
station = qc.station

station = qc.Station()


from pycqed.instrument_drivers.physical_instruments.ZurichInstruments import UHFQuantumController as ZI_UHFQC

UHFQC = ZI_UHFQC.UHFQC('UHFQC', device='dev2320', server_name=None)
station.add_component(UHFQC)
UHFQC.timeout(60)

from pycqed.instrument_drivers.physical_instruments import QuTech_CCL

CCL = QuTech_CCL.CCL('CCL', address='192.168.0.11', port=5025)
cs_filepath = os.path.join(pq.__path__[0], 'measurement', 'openql_experiments',
'output', 'cs.txt')
print("cs_file_path",cs_filepath)
opc_filepath = os.path.join(pq.__path__[0], 'measurement', 'openql_experiments',
'output', 'qisa_opcodes.qmap')
CCL.control_store(cs_filepath)
CCL.qisa_opcode(opc_filepath)
CCL.num_append_pts(2)
station.add_component(CCL)

from pycqed.instrument_drivers.meta_instrument.LutMans.ro_lutman import UHFQC_RO_LutMan
RO_lutman = UHFQC_RO_LutMan('RO_lutman', num_res=7)
RO_lutman.AWG(UHFQC.name)
station.add_component(RO_lutman)


# making full DIO triggered lookuptable
Expand All @@ -16,7 +42,7 @@
CCL.eqasm_program(example_fp)
CCL.start()

amps = [0.1, 0.2, 0.3, 0.4, 0.5]
amps = [0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7]
rolut.sampling_rate(1.8e9)
# testing single pulse sequence
for i in range(5):
Expand All @@ -34,13 +60,16 @@
rolut.set('M_modulation_R{}'.format(i), 0)

rolut.acquisition_delay(200e-9)


UHFQC.quex_rl_length(1)
UHFQC.quex_wint_length(int(600e-9*1.8e9))
UHFQC.awgs_0_enable(1)
rolut.AWG('UHFQC')
rolut.generate_standard_waveforms()
rolut.pulse_type('M_up_down_down')
rolut.resonator_combinations([[0], [1], [2], [3], [4]])
rolut.load_DIO_triggered_sequence_onto_UHFQC()
rolut.resonator_combinations([[0],[1],[2],[3],[4],[5],[6]])
UHFQC.awgs_0_userregs_0(1024)
UHFQC.awgs_0_enable(1)

UHFQC.awgs_0_enable(0)
rolut.load_DIO_triggered_sequence_onto_UHFQC()
UHFQC.awgs_0_enable(1)
83 changes: 62 additions & 21 deletions pycqed/analysis/measurement_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,17 @@
from pycqed.analysis.tools import data_manipulation as dm_tools
import imp
import math
import pygsti
try:
import pygsti
except ImportError as e:
if str(e).find('pygsti') >= 0:
logging.warning('Could not import pygsti')
else:
raise

from math import erfc
from scipy.signal import argrelmax, argrelmin
from scipy.constants import *
from copy import deepcopy
from pycqed.analysis.fit_toolbox import functions as func
from pprint import pprint
Expand Down Expand Up @@ -201,7 +209,8 @@ def save_fig(self, fig, figname=None, xlabel='x',
fig.savefig(
self.savename, dpi=self.dpi, format=plot_format,
bbox_inches='tight')
except:
except Exception as e:
print(e)
fail_counter = True
if fail_counter:
logging.warning('Figure "%s" has not been saved.' % self.savename)
Expand Down Expand Up @@ -3504,8 +3513,8 @@ def NormCdfdiffDouble(x, mu0_0=mu0_0,
# n1, bins1 = np.histogram(shots_I_1_rot, bins=int(min_len/50),
# normed=1)

edat, = pylab.plot(bins1[:-1]+0.5*(bins1[1]-bins1[0]), n1, 'bo')
gdat, = pylab.plot(bins0[:-1]+0.5*(bins0[1]-bins0[0]), n0, 'ro')
gdat, = pylab.plot(bins0[:-1]+0.5*(bins0[1]-bins0[0]), n0, 'C0o')
edat, = pylab.plot(bins1[:-1]+0.5*(bins1[1]-bins1[0]), n1, 'C3o')

# n, bins1, patches = np.hist(shots_I_1_rot, bins=int(min_len/50),
# label = '1 I',histtype='step',
Expand All @@ -3531,13 +3540,13 @@ def NormCdfdiffDouble(x, mu0_0=mu0_0,
y1_1 = norm1*frac1_1*pylab.normpdf(bins1, mu1_1, sigma1_1)
y0_1 = norm1*(1-frac1_1)*pylab.normpdf(bins1, mu0_1, sigma0_1)

pylab.semilogy(bins0, y0, 'r', linewidth=1.5)
pylab.semilogy(bins0, y1_0, 'r--', linewidth=3.5)
pylab.semilogy(bins0, y0_0, 'r--', linewidth=3.5)
pylab.semilogy(bins0, y0, 'C0', linewidth=1.5)
pylab.semilogy(bins0, y1_0, 'C0--', linewidth=3.5)
pylab.semilogy(bins0, y0_0, 'C0--', linewidth=3.5)

pylab.semilogy(bins1, y1, 'b', linewidth=1.5)
pylab.semilogy(bins1, y0_1, 'b--', linewidth=3.5)
pylab.semilogy(bins1, y1_1, 'b--', linewidth=3.5)
pylab.semilogy(bins1, y1, 'C3', linewidth=1.5)
pylab.semilogy(bins1, y0_1, 'C3--', linewidth=3.5)
pylab.semilogy(bins1, y1_1, 'C3--', linewidth=3.5)
pdf_max = (max(max(y0), max(y1)))
(pylab.gca()).set_ylim(pdf_max/1000, 2*pdf_max)

Expand Down Expand Up @@ -5389,9 +5398,13 @@ def get_naming_and_values(self):

class Homodyne_Analysis(MeasurementAnalysis):

def __init__(self, label='HM', **kw):
def __init__(self, label='HM', custom_power_message: dict=None, **kw):
# Custome power message is used to create a message in resonator measurements
# dict must be custom_power_message={'Power': -15, 'Atten': 86, 'res_len':3e-6}
# Power in dBm, Atten in dB and resonator length in m
kw['label'] = label
kw['h5mode'] = 'r+'
kw['custom_power_message']=custom_power_message
super().__init__(**kw)

def run_default_analysis(self, print_fit_results=False,
Expand Down Expand Up @@ -5485,6 +5498,7 @@ def run_default_analysis(self, print_fit_results=False,
Model.set_param_hint('theta', value=0, min=-np.pi/2,
max=np.pi/2)
Model.set_param_hint('slope', value=0, vary=True)

self.params = Model.make_params()

if fit_window == None:
Expand Down Expand Up @@ -5599,7 +5613,7 @@ def run_default_analysis(self, print_fit_results=False,
y_unit=self.value_units[0],
save=False)
# ensures that amplitude plot starts at zero
ax.set_ylim(ymin=0.0)
ax.set_ylim(ymin=-0.001)

elif 'complex' in fitting_model:
self.plot_complex_results(
Expand Down Expand Up @@ -5635,15 +5649,42 @@ def run_default_analysis(self, print_fit_results=False,
old_vals = ''

if ('hanger' in fitting_model) or ('complex' in fitting_model):
textstr = '$f_{\mathrm{center}}$ = %.5f GHz $\pm$ (%.3g) GHz' % (
fit_res.params['f0'].value,
fit_res.params['f0'].stderr) + '\n' \
'$Qc$ = %.1f $\pm$ (%.1f)' % (
fit_res.params['Qc'].value,
fit_res.params['Qc'].stderr) + '\n' \
'$Qi$ = %.1f $\pm$ (%.1f)' % (
fit_res.params['Qi'].value, fit_res.params['Qi'].stderr) + \
old_vals
if kw['custom_power_message'] is None:
textstr = '$f_{\mathrm{center}}$ = %.5f GHz $\pm$ (%.3g) GHz' % (
fit_res.params['f0'].value,
fit_res.params['f0'].stderr) + '\n' \
'$Qc$ = %.1f $\pm$ (%.1f)' % (
fit_res.params['Qc'].value,
fit_res.params['Qc'].stderr) + '\n' \
'$Qi$ = %.1f $\pm$ (%.1f)' % (
fit_res.params['Qi'].value, fit_res.params['Qi'].stderr) + \
old_vals
else:
###############################################################################
# Custom must be a dictionary #
# custom_power = {'Power':-15, 'Atten':30, 'res_len':3.6e-6} #
# Power is power at source in dBm #
# Atten is attenuation at sample, including sources attenuation in dB #
# res_len is the lenght of the resonator in m #
# All of this is needed to calculate mean photon number and phase velocity #
###############################################################################

custom_power = kw['custom_power_message']
power_in_w = 10**((custom_power['Power']-custom_power['Atten'])/10)*1e-3
mean_ph = (2*(fit_res.params['Q'].value**2)/(fit_res.params['Qc'].value*hbar*(2*pi*fit_res.params['f0'].value*1e9)**2))*power_in_w
phase_vel = 4*custom_power['res_len']*fit_res.params['f0'].value*1e9

textstr = '$f_{\mathrm{center}}$ = %.5f GHz $\pm$ (%.3g) GHz' % (
fit_res.params['f0'].value,
fit_res.params['f0'].stderr) + '\n' \
'$Qc$ = %.1f $\pm$ (%.1f)' % (
fit_res.params['Qc'].value,
fit_res.params['Qc'].stderr) + '\n' \
'$Qi$ = %.1f $\pm$ (%.1f)' % (
fit_res.params['Qi'].value, fit_res.params['Qi'].stderr) + \
old_vals + '\n' \
'$< n_{\mathrm{ph} }>$ = %.1f' %(mean_ph) + '\n' \
'$v_{\mathrm{phase}}$ = %.3e m/s' %(phase_vel)

elif fitting_model == 'lorentzian':
textstr = '$f_{{\mathrm{{center}}}}$ = %.5f GHz ' \
Expand Down
2 changes: 1 addition & 1 deletion pycqed/analysis_v2/base_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -1080,4 +1080,4 @@ def plot_matplot_ax_method(self, pdict, axs):
"""
pfunc = getattr(axs, pdict.get('func'))
pfunc(**pdict['plot_kws'])
pfunc(**pdict['plot_kws'])
Loading

0 comments on commit c139d1b

Please sign in to comment.