In [1]:
from Initialization import *


c:\libs\pycqed_py3\data
Data directory set to: c:\libs\pycqed_py3\data
c:\libs\pycqed_py3\data
Connected to: Agilent Technologies N5183B (serial:MY53271678, firmware:B.01.60) in 2.02s
Connected to: Rohde&Schwarz SGS100A (serial:1416.0505k02/101645, firmware:3.1.19.15-3.50.124.67) in 0.06s
Connected to: SONY/TEK AWG520 (serial:0, firmware:SCPI:95.0 OS:1.0 USR:1.3a) in 0.15s
C:\ProgramData\Anaconda3\lib\site-packages\pyvisa\resources\messagebased.py:568: FutureWarning:

ask is deprecated and will be removed in 1.10, use query instead.

c:\libs\qcodes\qcodes\instrument\parameter.py:247: UserWarning:

Wrapping get method, original get method will not be directly accessible. It is recommended to define get_raw in your subclass instead.

Snapshot: Could not update parameter: clock_source on ATS
Snapshot: Could not update parameter: sample_rate on ATS
Snapshot: Could not update parameter: clock_edge on ATS
Snapshot: Could not update parameter: decimation on ATS
Snapshot: Could not update parameter: coupling1 on ATS
Snapshot: Could not update parameter: channel_range1 on ATS
Snapshot: Could not update parameter: impedance1 on ATS
Snapshot: Could not update parameter: bwlimit1 on ATS
Snapshot: Could not update parameter: coupling2 on ATS
Snapshot: Could not update parameter: channel_range2 on ATS
Snapshot: Could not update parameter: impedance2 on ATS
Snapshot: Could not update parameter: bwlimit2 on ATS
Snapshot: Could not update parameter: trigger_operation on ATS
Snapshot: Could not update parameter: trigger_engine1 on ATS
Snapshot: Could not update parameter: trigger_source1 on ATS
Snapshot: Could not update parameter: trigger_slope1 on ATS
Snapshot: Could not update parameter: trigger_level1 on ATS
Snapshot: Could not update parameter: trigger_engine2 on ATS
Snapshot: Could not update parameter: trigger_source2 on ATS
Snapshot: Could not update parameter: trigger_slope2 on ATS
Snapshot: Could not update parameter: trigger_level2 on ATS
Snapshot: Could not update parameter: external_trigger_coupling on ATS
Snapshot: Could not update parameter: external_trigger_range on ATS
Snapshot: Could not update parameter: trigger_delay on ATS
Snapshot: Could not update parameter: timeout_ticks on ATS
Snapshot: Could not update parameter: mode on ATS
Snapshot: Could not update parameter: samples_per_record on ATS
Snapshot: Could not update parameter: records_per_buffer on ATS
Snapshot: Could not update parameter: buffers_per_acquisition on ATS
Snapshot: Could not update parameter: channel_selection on ATS
Snapshot: Could not update parameter: transfer_offset on ATS
Snapshot: Could not update parameter: external_startcapture on ATS
Snapshot: Could not update parameter: enable_record_headers on ATS
Snapshot: Could not update parameter: alloc_buffers on ATS
Snapshot: Could not update parameter: fifo_only_streaming on ATS
Snapshot: Could not update parameter: interleave_samples on ATS
Snapshot: Could not update parameter: get_processed_data on ATS
Snapshot: Could not update parameter: allocated_buffers on ATS
Snapshot: Could not update parameter: buffer_timeout on ATS
Snapshot: Could not update parameter: acquisition on ATS_controller
f_RO_mod between RF and LO is not set correctly
	f_RO_mod = 10000000.0, LO_freq = 4990000000.0, RF_freq = 4990000000.0
Heterodyne frequency does not match RF frequency
f_RO_mod between RF and LO is not set correctly
	f_RO_mod = 10000000.0, LO_freq = 4990000000.0, RF_freq = 4990000000.0
controller initialized

In [2]:
station.components


Out[2]:
{'RFLO': <N51x1: RFLO>,
 'SPEC': <RohdeSchwarz_SGS100A: SPEC>,
 'AWG': <Tektronix_AWG520: AWG>,
 'ATS': <AlazarTech_ATS9870: ATS>,
 'ATS_controller': <Demodulation_AcquisitionController: ATS_controller>,
 'HS': <HeterodyneInstrument: HS>,
 'MC': <MeasurementControl: MC>}

In [3]:
station.AWG


Out[3]:
<Tektronix_AWG520: AWG>

In [5]:
AWG.ch1_status()


Out[5]:
1.0

In [6]:
AWG.ch1_amp(1.0)
AWG.ch2_amp(1.0)

In [7]:
RFLO.on()

In [8]:
SPEC.power(-5)
SPEC.IQ_state('ON')  
SPEC.frequency(6.16e9-0.05e9)
SPEC.on()

In [9]:
RFLO.power(19.0)
RFLO.frequency(6.16e9)

In [10]:
ATS.config(clock_source='INTERNAL_CLOCK',
                sample_rate=1e9,
                clock_edge='CLOCK_EDGE_RISING',
                decimation=0,
                coupling=['DC','DC'],
                channel_range=[0.1,0.1],
                impedance=[50,50],
                bwlimit=['DISABLED','DISABLED'],
                trigger_operation='TRIG_ENGINE_OP_J',
                trigger_engine1='TRIG_ENGINE_J',
                trigger_source1='EXTERNAL',
                trigger_slope1='TRIG_SLOPE_POSITIVE',
                trigger_level1=128,
                trigger_engine2='TRIG_ENGINE_K',
                trigger_source2='DISABLE',
                trigger_slope2='TRIG_SLOPE_POSITIVE',
                trigger_level2=128,
                external_trigger_coupling='AC',
                external_trigger_range='ETR_5V',
                trigger_delay=0,
                timeout_ticks=0
)

In [11]:
# configure the ATS controller
ATS_controller.update_acquisitionkwargs(#mode='NPT',
                 samples_per_record=4096,
                 records_per_buffer=8000,#70, segmments
                 buffers_per_acquisition=1,
                 channel_selection='AB',
                 transfer_offset=0,
                 external_startcapture='ENABLED',
                 enable_record_headers='DISABLED',
                 alloc_buffers='DISABLED',
                 fifo_only_streaming='DISABLED',
                 interleave_samples='DISABLED',
                 get_processed_data='DISABLED',
                 allocated_buffers=1,  
                 buffer_timeout=500,
)

In [13]:
def ATS_homodyne_acquisition(integration_start, integration_time):
    
    integration_end = integration_start + integration_time
    ATS.external_trigger_coupling._set_updated()
    ATS.external_trigger_range._set_updated()
    
    ATS_controller.pre_acquire()
    blub = ATS_controller.do_acquisition()
    ATS_controller.post_acquire()

    buffer = ATS_controller.buffer
    reshaped_buffer = buffer.reshape(2, ATS.records_per_buffer(), ATS.samples_per_record())-128.

#     print(reshaped_buffer.flatten()[np.argsort(reshaped_buffer.flatten())[-50:]])
#     print(reshaped_buffer.flatten()[np.argsort(reshaped_buffer.flatten())[:50]])

    average_record_I = np.average(reshaped_buffer[0,:,:], axis = 0)
    average_record_Q = np.average(reshaped_buffer[1,:,:], axis = 0)
    
    offset_I = np.average(average_record_I[3000:4000])
    offset_Q = np.average(average_record_Q[3000:4000])
    
#     range_I = np.max(average_record_I[integration_start:integration_end]) \
#              -np.min(average_record_I[integration_start:integration_end])
   
#     range_Q = np.max(average_record_Q[integration_start:integration_end]) \
#              -np.min(average_record_Q[integration_start:integration_end])
    
    integrated_output_I = np.average(average_record_I[integration_start:integration_end]-offset_I)#/range_I
    integrated_output_Q = np.average(average_record_Q[integration_start:integration_end]-offset_Q)#/range_Q
    
    return [integrated_output_I, integrated_output_Q]

In [23]:
ATS_homodyne_acquisition(500,2000)


Out[23]:
[0.51592012500000051, -1.6390381249999999]

In [544]:
%matplotlib inline

In [24]:
AWG.set_sequence('pulsed_spec_sequence_FILE.seq')
AWG.start()

In [25]:
integration_start=674
integration_end=integration_start+1000

RFLO.frequency(6.157e9)
SPEC.frequency(6.157e9-0.05e9)
SPEC.power(-10)
SPEC.off()
ATS.external_trigger_coupling._set_updated()
ATS.external_trigger_range._set_updated()

ATS_controller.pre_acquire()
blub = ATS_controller.do_acquisition()
ATS_controller.post_acquire()

buffer = ATS_controller.buffer
reshaped_buffer = buffer.reshape(2, ATS.records_per_buffer(), ATS.samples_per_record())

# print(reshaped_buffer.flatten()[np.argsort(reshaped_buffer.flatten())[-50:]])
# print(reshaped_buffer.flatten()[np.argsort(reshaped_buffer.flatten())[:50]])


average_record_I = np.average(reshaped_buffer[0,:,:], axis = 0)
average_record_Q = np.average(reshaped_buffer[1,:,:], axis = 0)

integrated_output_power = np.average((average_record_I[integration_start:integration_end]
                                     +average_record_Q[integration_start:integration_end])**2)
# integrated_output_power = np.average(((average_record_I[integration_start:integration_end])**2
#                                      +(average_record_Q[integration_start:integration_end])**2))**0.5

plt.figure(figsize=(10,10))
plt.plot(average_record_I)
plt.plot(average_record_Q)
# plt.xlim(500, 700)


Out[25]:
[<matplotlib.lines.Line2D at 0x17528cc0>]

In [580]:
frequencies = np.linspace(6.157e9-0.01e9, 6.157e9+0.01e9, 101)
integrated_output = []
for i, frequency in enumerate(frequencies):
    RFLO.frequency.set(frequency)
    integrated_output.append(ATS_homodyne_acquisition(670,1100))
#     print(frequency)
    
integrated_output = np.array(integrated_output)
plt.figure()
plt.plot(frequencies, integrated_output[:,0])
plt.plot(frequencies, integrated_output[:,1])

plt.figure()
plt.plot(frequencies, np.sqrt(integrated_output[:,0]**2+integrated_output[:,1]**2))


Out[580]:
[<matplotlib.lines.Line2D at 0x467b59b0>]

In [489]:
%matplotlib inline
integrated_output = np.array(v  integrated_output)

In [490]:
integrated_output.shape


Out[490]:
(101, 2)

In [491]:
plt.plot(frequencies, integrated_output[:,0])
plt.plot(frequencies, integrated_output[:,1])


Out[491]:
[<matplotlib.lines.Line2D at 0x2f21a940>]

In [492]:
plt.plot(frequencies, np.sqrt(integrated_output[:,0]**2+integrated_output[:,1]**2))


Out[492]:
[<matplotlib.lines.Line2D at 0x400a38d0>]

In [20]:
spec_frequencies = np.linspace(6.58e9, 6.60e9, 201)
integrated_output = []
SPEC.power.set(-35)
SPEC.IQ_state.set('ON')
SPEC.on()
RFLO.frequency.set(6.1565e9)  
for i, frequency in enumerate(spec_frequencies):
    SPEC.frequency.set(frequency-0.05e9)
    integrated_output.append(ATS_homodyne_acquisition(670,1100))
#     print(frequency)
    
integrated_output = np.array(integrated_output)
plt.figure()
plt.plot(spec_frequencies, integrated_output[:,0])
plt.plot(spec_frequencies, integrated_output[:,1])
  
plt.figure()
plt.plot(spec_frequencies, np.sqrt(integrated_output[:,0]**2+integrated_output[:,1]**2))


Out[20]:
[<matplotlib.lines.Line2D at 0x17bfe438>]

In [ ]:
plt.figure()
plt.plot(spec_frequencies, np.sqrt(integrated_output[:,0]**2+integrated_output[:,1]**2))
plt.title('Pulse spectroscopy')
plt.xlabel('Frequency GHz')
plt.ylabel('Homodyne voltage (a.u.)')
plt.xticks(np.arange(6.58e9, 6.60e9, 5e+7))
plt.savefig('foo.png', dpi=300, bbox_inches='tight')


---------------------------------------------------------------------------
KeyboardInterrupt                         Traceback (most recent call last)
<ipython-input-23-7fc23a000dc8> in <module>()
      4 plt.xlabel('Frequency GHz')
      5 plt.ylabel('Homodyne voltage (a.u.)')
----> 6 plt.xticks(np.arange(6.58e9, 6.60e9, 5))
      7 plt.savefig('foo.png', dpi=300, bbox_inches='tight')

C:\ProgramData\Anaconda3\lib\site-packages\matplotlib\pyplot.py in xticks(*args, **kwargs)
   1722         labels = ax.get_xticklabels()
   1723     elif len(args)==1:
-> 1724         locs = ax.set_xticks(args[0])
   1725         labels = ax.get_xticklabels()
   1726     elif len(args)==2:

C:\ProgramData\Anaconda3\lib\site-packages\matplotlib\axes\_base.py in set_xticks(self, ticks, minor)
   3206             Default is ``False``.
   3207         """
-> 3208         ret = self.xaxis.set_ticks(ticks, minor=minor)
   3209         self.stale = True
   3210         return ret

C:\ProgramData\Anaconda3\lib\site-packages\matplotlib\axis.py in set_ticks(self, ticks, minor)
   1688         else:
   1689             self.set_major_locator(mticker.FixedLocator(ticks))
-> 1690             return self.get_major_ticks(len(ticks))
   1691 
   1692     def _get_tick_boxes_siblings(self, xdir, renderer):

C:\ProgramData\Anaconda3\lib\site-packages\matplotlib\axis.py in get_major_ticks(self, numticks)
   1402             if self._gridOnMajor:
   1403                 tick.gridOn = True
-> 1404             self._copy_tick_props(self.majorTicks[0], tick)
   1405 
   1406         return self.majorTicks[:numticks]

C:\ProgramData\Anaconda3\lib\site-packages\matplotlib\axis.py in _copy_tick_props(self, src, dest)
   1362         dest.label2.update_from(src.label2)
   1363 
-> 1364         dest.tick1line.update_from(src.tick1line)
   1365         dest.tick2line.update_from(src.tick2line)
   1366         dest.gridline.update_from(src.gridline)

C:\ProgramData\Anaconda3\lib\site-packages\matplotlib\lines.py in update_from(self, other)
   1253         self._linestyle = other._linestyle
   1254         self._marker = MarkerStyle(other._marker.get_marker(),
-> 1255                                    other._marker.get_fillstyle())
   1256         self._drawstyle = other._drawstyle
   1257 

C:\ProgramData\Anaconda3\lib\site-packages\matplotlib\markers.py in __init__(self, marker, fillstyle)
    187         self._marker_function = None
    188         self.set_fillstyle(fillstyle)
--> 189         self.set_marker(marker)
    190 
    191     def __getstate__(self):

C:\ProgramData\Anaconda3\lib\site-packages\matplotlib\markers.py in set_marker(self, marker)
    273 
    274         self._marker = marker
--> 275         self._recache()
    276 
    277     def get_path(self):

C:\ProgramData\Anaconda3\lib\site-packages\matplotlib\markers.py in _recache(self)
    209         self._capstyle = 'butt'
    210         self._filled = True
--> 211         self._marker_function()
    212 
    213     if six.PY3:

C:\ProgramData\Anaconda3\lib\site-packages\matplotlib\markers.py in _set_tickdown(self)
    721 
    722     def _set_tickdown(self):
--> 723         self._transform = Affine2D().scale(1.0, -1.0)
    724         self._snap_threshold = 1.0
    725         self._filled = False

C:\ProgramData\Anaconda3\lib\site-packages\matplotlib\transforms.py in scale(self, sx, sy)
   2089         scale_mtx = np.array(
   2090             [[sx, 0.0, 0.0], [0.0, sy, 0.0], [0.0, 0.0, 1.0]], float)
-> 2091         self._mtx = np.dot(scale_mtx, self._mtx)
   2092         self.invalidate()
   2093         return self

KeyboardInterrupt: 

In [ ]:
from lmfit import Model 
def lorentzian(x, x0, amp,gamma,offset):
    return amp*(0.5*gamma/((x-x0)**2+0.25*gamma**2)/np.pi)+offset

f=spec_frequencies
y=np.sqrt(integrated_output[:,0]**2+integrated_output[:,1]**2)

gmodel = Model(lorentzian)
result = gmodel.fit(y,x=f,amp=0.05,gamma=1e+6, x0=6.591e+9,offset=7.0)

print(result.fit_report())

plt.figure()
# plt.xlabel('time (s)')
# plt.ylabel('2 state population')           
plt.plot(f, y, 'bo')
plt.plot(f, result.init_fit, 'k--') 
plt.plot(f, result.best_fit, 'r-')
# plt.ylim(0.0, 0.9)
plt.xlim(6.59e+9,6.5925e+9)
plt.show()

In [265]:
ATS.records_per_buffer()*ATS.samples_per_record()*ATS.buffers_per_acquisition()


Out[265]:
32768000