├── Project.toml ├── slab ├── experiments │ ├── __init__.py │ ├── untitled │ ├── Alex │ │ ├── __init__.py │ │ ├── ExpLib │ │ │ ├── __init__.py │ │ │ ├── PulseSequenceGroup.py │ │ │ └── SequentialExperiment.py │ │ ├── General │ │ │ ├── __init__.py │ │ │ └── PulseSequences │ │ │ │ └── __init__.py │ │ └── Multimode │ │ │ ├── __init__.py │ │ │ ├── PulseSequences │ │ │ └── __init__.py │ │ │ ├── sequentialEXPTest.py │ │ │ ├── mm_flux_sideband_rabi_freq_sweep_new_3.py │ │ │ └── run_multimode_seq_experiment.py │ ├── Hafnium │ │ ├── __init__.py │ │ ├── ExpLib │ │ │ ├── __init__.py │ │ │ ├── PulseSequenceGroup.py │ │ │ ├── seq_expt_new.py │ │ │ └── SequentialExperiment.py │ │ ├── General │ │ │ ├── __init__.py │ │ │ └── PulseSequences │ │ │ │ └── __init__.py │ │ └── Multimode │ │ │ ├── __init__.py │ │ │ ├── PulseSequences │ │ │ └── __init__.py │ │ │ ├── sequentialEXPTest.py │ │ │ ├── mm_flux_sideband_rabi_freq_sweep_new_3.py │ │ │ └── run_multimode_seq_experiment.py │ ├── Nitrogen │ │ ├── __init__.py │ │ ├── ExpLib │ │ │ ├── __init__.py │ │ │ ├── PulseSequenceGroup.py │ │ │ ├── SequentialExperiment.py │ │ │ └── awgpulses.py │ │ ├── General │ │ │ ├── __init__.py │ │ │ ├── PulseSequences │ │ │ │ └── __init__.py │ │ │ └── CWDriveExperiment.py │ │ └── Multimode │ │ │ ├── __init__.py │ │ │ ├── PulseSequences │ │ │ └── __init__.py │ │ │ ├── sequentialEXPTest.py │ │ │ └── mm_flux_sideband_rabi_freq_sweep_new_3.py │ ├── HVIExperiments │ │ ├── __init__.py │ │ ├── Test │ │ │ ├── TestExperimentHVI.HVI │ │ │ ├── TestExperimentHVI.HVI.bak │ │ │ ├── TestExperimentHVI.HVIprj │ │ │ ├── TestExperimentHVI.HVIprj.bak │ │ │ ├── default_hardware.keycfg.txt │ │ │ ├── test.py │ │ │ └── TestExperiment.py │ │ ├── Test2 │ │ │ ├── TestExperiment2.HVI │ │ │ ├── TestExperiment2.HVI.bak │ │ │ ├── TestExperiment2HVI.HVIprj │ │ │ ├── TestExperiment2HVI.HVIprj.bak │ │ │ ├── default_hardware.keycfg.txt │ │ │ └── TestExperiment2.py │ │ ├── default_hardware.keycfg │ │ └── DataHandlerHelper │ │ │ ├── build │ │ │ ├── temp.win-amd64-3.6 │ │ │ │ └── Release │ │ │ │ │ ├── DataHandlerHelper.obj │ │ │ │ │ ├── datahandlerhelper.cp36-win_amd64.exp │ │ │ │ │ └── datahandlerhelper.cp36-win_amd64.lib │ │ │ └── lib.win-amd64-3.6 │ │ │ │ └── datahandlerhelper.cp36-win_amd64.pyd │ │ │ ├── setup.py │ │ │ └── DataHandlerHelper.h │ ├── slab - Shortcut.lnk │ ├── .ipynb_checkpoints │ │ └── testkeysight-checkpoint.ipynb │ ├── Rodin Furnace │ │ ├── _testing_notebooks │ │ │ ├── 020721-Nb1 etch and heat treat logs │ │ │ │ ├── 00000_2021-02-11_RGA_log.png │ │ │ │ ├── 00001_2021-01-23_RGA_log.png │ │ │ │ ├── 00000_2021-02-11_Furnace_log.png │ │ │ │ └── furnace_config_N2.yml │ │ │ ├── 012521-Nb3 re-etch and N2 treatment │ │ │ │ ├── 00002_2021-01-31_RGA_log_O2_bake.png │ │ │ │ ├── 00001_2021-01-23_RGA_log_H2wN2_bake.png │ │ │ │ └── furnace_config.yml │ │ │ ├── 021721-Test strip etch and heat treat logs │ │ │ │ ├── 00000_2021-02-16_RGA_log.png │ │ │ │ └── furnace_config_N2.yml │ │ │ └── Temp scan tests.ipynb │ │ ├── instrument.cfg │ │ ├── furnace_config.yml │ │ ├── furnace_config_N2.yml │ │ ├── furnace_config_O2_bake.yml │ │ ├── heater_config.yml │ │ ├── system_config.yml │ │ └── Instruments │ │ │ ├── TempScanner.py │ │ │ └── __init__.py │ └── plottest.py ├── instruments │ ├── AD5780DAC │ │ ├── __init__.py │ │ └── AD5780DACServer │ │ │ └── AD5780.h │ ├── RedPitaya │ │ ├── __init__.py │ │ └── PyRedPitaya │ │ │ ├── __init__.py │ │ │ ├── enum │ │ │ └── __init__.py │ │ │ ├── pc.py │ │ │ ├── board.py │ │ │ ├── tests │ │ │ └── rp_test.py │ │ │ ├── service.py │ │ │ ├── client_memory.py │ │ │ ├── memory.py │ │ │ └── raw_memory.py │ ├── Seekat │ │ └── __init__.py │ ├── labbrick │ │ └── __init__.py │ ├── pulseblaster │ │ ├── __init__.py │ │ ├── pulseblaster_test.py │ │ └── pulseblaster_hafnium.py │ ├── spec_analyzer │ │ ├── __init__.py │ │ ├── socket_test.py │ │ ├── test_telnet_sa.py │ │ ├── sa_linear.py │ │ ├── sa_calibration.py │ │ ├── serial_com.py │ │ ├── precision.py │ │ ├── min_pwr.py │ │ └── spectrum_analyzer.py │ ├── Alazar │ │ ├── __init__.py │ │ ├── SweepDialog_ui.py │ │ └── Scope.py │ ├── relaybox │ │ ├── __init__.py │ │ └── RFSwitch.py │ ├── Furnace.py │ ├── qiskit │ │ ├── __init__.py │ │ ├── rfsoc │ │ │ └── __init__.py │ │ ├── json_util.py │ │ ├── job.py │ │ └── provider_interface.py │ ├── keysight │ │ ├── __init__.py │ │ └── KeysightPulseSequence.py │ ├── bk dummy.py │ ├── Furnace Cycle.py │ ├── PressureGauge.py │ ├── Omega16i.py │ ├── ArduinoADC.py │ ├── keysightM3xxxA.py │ ├── localinstruments.py │ ├── TestInstruments.py │ ├── awg │ │ ├── M8195A_test.py │ │ ├── M8195A_unittest.py │ │ ├── __init__.py │ │ ├── awgpulses2.py │ │ ├── TekPattern2.py │ │ └── chase │ │ │ ├── test_chase.py │ │ │ ├── test_chase_0.py │ │ │ ├── test_chase_3.py │ │ │ └── test_chase_4.py │ ├── HeaterSwitch.py │ ├── Temperature Logger.py │ ├── testscript.py │ ├── DigitalAttenuator.py │ ├── LakeshoreResistanceBridge.py │ ├── cryocon.py │ ├── geophone.py │ ├── dymo.py │ ├── DymoScale.py │ ├── TempScanner.py │ ├── KEPCOPowerSupply.py │ ├── RCA18.py │ ├── spectrum_analyzer.py │ └── __init__.py ├── widgets │ ├── __init__.py │ └── widgets.py ├── plotting │ ├── __init__.py │ ├── setup.py │ ├── run_hdfiview.py │ └── Server_ui.py ├── scripts │ ├── launcher │ │ ├── setup.py │ │ ├── build │ │ │ └── bdist.win32 │ │ │ │ └── winexe │ │ │ │ └── temp │ │ │ │ ├── _ssl.py │ │ │ │ ├── bz2.py │ │ │ │ ├── sip.py │ │ │ │ ├── _ctypes.py │ │ │ │ ├── _socket.py │ │ │ │ ├── select.py │ │ │ │ ├── PyQt4.Qt.py │ │ │ │ ├── _hashlib.py │ │ │ │ ├── win32api.py │ │ │ │ ├── PyQt4.QtCore.py │ │ │ │ ├── PyQt4.QtGui.py │ │ │ │ ├── unicodedata.py │ │ │ │ └── win32evtlog.py │ │ └── launcher.py │ ├── fileserverviewer.py │ └── eHe.py ├── __init__.py ├── datahandlerhelper.pyx ├── templates │ └── gui_template.py └── experiment.py ├── README.md ├── .gitignore ├── examples └── qiskit │ └── rfsoc │ ├── server.py │ ├── config.yaml │ └── user.py ├── setup.py ├── test ├── InstrumentManager test.py └── datamanagement unit test.py └── LICENSE /Project.toml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /slab/experiments/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /slab/experiments/untitled: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /slab/experiments/Alex/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /slab/experiments/Hafnium/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /slab/experiments/Nitrogen/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /slab/instruments/AD5780DAC/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /slab/instruments/RedPitaya/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /slab/instruments/Seekat/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /slab/instruments/labbrick/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /slab/experiments/Alex/ExpLib/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /slab/experiments/Alex/General/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /slab/experiments/Alex/Multimode/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /slab/experiments/HVIExperiments/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /slab/experiments/Hafnium/ExpLib/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /slab/instruments/pulseblaster/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /slab/instruments/spec_analyzer/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /slab/experiments/Hafnium/General/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /slab/experiments/Hafnium/Multimode/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /slab/experiments/Nitrogen/ExpLib/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /slab/experiments/Nitrogen/General/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /slab/experiments/Nitrogen/Multimode/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /slab/experiments/Alex/General/PulseSequences/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /slab/experiments/Alex/Multimode/PulseSequences/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /slab/instruments/Alazar/__init__.py: -------------------------------------------------------------------------------- 1 | from .dsalazar import * -------------------------------------------------------------------------------- /slab/experiments/Hafnium/General/PulseSequences/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /slab/experiments/Hafnium/Multimode/PulseSequences/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /slab/experiments/Nitrogen/General/PulseSequences/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /slab/experiments/Nitrogen/Multimode/PulseSequences/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /slab/instruments/relaybox/__init__.py: -------------------------------------------------------------------------------- 1 | from .relaybox import RelayBox -------------------------------------------------------------------------------- /slab/instruments/RedPitaya/PyRedPitaya/__init__.py: -------------------------------------------------------------------------------- 1 | __version__ = "1.0" 2 | 3 | -------------------------------------------------------------------------------- /slab/instruments/RedPitaya/PyRedPitaya/enum/__init__.py: -------------------------------------------------------------------------------- 1 | from .enum import * 2 | -------------------------------------------------------------------------------- /slab/instruments/Furnace.py: -------------------------------------------------------------------------------- 1 | ''' 2 | Author: Andrew Oriani 3 | 4 | Furnace object and cycle 5 | 6 | ''' -------------------------------------------------------------------------------- /slab/widgets/__init__.py: -------------------------------------------------------------------------------- 1 | from .widgets import * 2 | 3 | widget_dict = { "Alazar" : AlazarWidget } 4 | -------------------------------------------------------------------------------- /slab/experiments/slab - Shortcut.lnk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SchusterLab/slab/HEAD/slab/experiments/slab - Shortcut.lnk -------------------------------------------------------------------------------- /slab/instruments/qiskit/__init__.py: -------------------------------------------------------------------------------- 1 | """ 2 | slab.instruments.qiskit 3 | """ 4 | 5 | from .provider_interface import SLabProviderInterface 6 | -------------------------------------------------------------------------------- /slab/instruments/qiskit/rfsoc/__init__.py: -------------------------------------------------------------------------------- 1 | """ 2 | slab.instruments.qiskit.rfsoc 3 | """ 4 | 5 | from .rfsoc_backend import RFSoCBackend 6 | -------------------------------------------------------------------------------- /slab/instruments/keysight/__init__.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | Created on Thu Aug 30 14:44:20 2018 4 | 5 | @author: slab 6 | """ 7 | 8 | -------------------------------------------------------------------------------- /slab/plotting/__init__.py: -------------------------------------------------------------------------------- 1 | try: 2 | from .script_viewer import ScriptPlotter 3 | except: 4 | print("Warning could not import ScriptPlotter") 5 | -------------------------------------------------------------------------------- /slab/experiments/.ipynb_checkpoints/testkeysight-checkpoint.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [], 3 | "metadata": {}, 4 | "nbformat": 4, 5 | "nbformat_minor": 2 6 | } 7 | -------------------------------------------------------------------------------- /slab/experiments/HVIExperiments/Test/TestExperimentHVI.HVI: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SchusterLab/slab/HEAD/slab/experiments/HVIExperiments/Test/TestExperimentHVI.HVI -------------------------------------------------------------------------------- /slab/experiments/HVIExperiments/Test2/TestExperiment2.HVI: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SchusterLab/slab/HEAD/slab/experiments/HVIExperiments/Test2/TestExperiment2.HVI -------------------------------------------------------------------------------- /slab/experiments/HVIExperiments/Test/TestExperimentHVI.HVI.bak: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SchusterLab/slab/HEAD/slab/experiments/HVIExperiments/Test/TestExperimentHVI.HVI.bak -------------------------------------------------------------------------------- /slab/experiments/HVIExperiments/Test/TestExperimentHVI.HVIprj: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SchusterLab/slab/HEAD/slab/experiments/HVIExperiments/Test/TestExperimentHVI.HVIprj -------------------------------------------------------------------------------- /slab/experiments/HVIExperiments/Test2/TestExperiment2.HVI.bak: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SchusterLab/slab/HEAD/slab/experiments/HVIExperiments/Test2/TestExperiment2.HVI.bak -------------------------------------------------------------------------------- /slab/experiments/HVIExperiments/Test2/TestExperiment2HVI.HVIprj: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SchusterLab/slab/HEAD/slab/experiments/HVIExperiments/Test2/TestExperiment2HVI.HVIprj -------------------------------------------------------------------------------- /slab/experiments/HVIExperiments/Test/TestExperimentHVI.HVIprj.bak: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SchusterLab/slab/HEAD/slab/experiments/HVIExperiments/Test/TestExperimentHVI.HVIprj.bak -------------------------------------------------------------------------------- /slab/experiments/HVIExperiments/Test2/TestExperiment2HVI.HVIprj.bak: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SchusterLab/slab/HEAD/slab/experiments/HVIExperiments/Test2/TestExperiment2HVI.HVIprj.bak -------------------------------------------------------------------------------- /slab/instruments/RedPitaya/PyRedPitaya/pc.py: -------------------------------------------------------------------------------- 1 | from .instrument import RedPitaya 2 | from .client_memory import ClientMemory 3 | 4 | class RedPitaya(RedPitaya, ClientMemory): 5 | pass 6 | -------------------------------------------------------------------------------- /slab/instruments/RedPitaya/PyRedPitaya/board.py: -------------------------------------------------------------------------------- 1 | from .instrument import RedPitaya 2 | from .raw_memory import BoardRawMemory 3 | 4 | class RedPitaya(RedPitaya, BoardRawMemory): 5 | pass 6 | -------------------------------------------------------------------------------- /slab/plotting/setup.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | Created on Thu Nov 01 16:44:06 2012 4 | 5 | @author: slab 6 | """ 7 | 8 | from distutils.core import setup 9 | import py2exe 10 | setup(console=['run_hdfiview.py']) -------------------------------------------------------------------------------- /slab/experiments/HVIExperiments/default_hardware.keycfg: -------------------------------------------------------------------------------- 1 | #Hardware configuration file for our Keysight modules. Update as needed 2 | 3 | Chassis Number: 1 4 | 5 | #as lists 6 | Input Modules: [10] 7 | Output Modules: [6, 7, 8, 9] 8 | -------------------------------------------------------------------------------- /slab/experiments/HVIExperiments/Test/default_hardware.keycfg.txt: -------------------------------------------------------------------------------- 1 | #Hardware configuration file for our Keysight modules. Update as needed 2 | 3 | Chassis Number: 1 4 | 5 | #as lists 6 | Input Modules: [10] 7 | Output Modules: [6, 7, 8, 9] 8 | -------------------------------------------------------------------------------- /slab/experiments/HVIExperiments/Test/test.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | Created on Thu Sep 13 17:00:31 2018 4 | 5 | @author: slab 6 | """ 7 | 8 | #import datahandlerhelper 9 | import numpy as np 10 | import numpy.core.multiarray -------------------------------------------------------------------------------- /slab/experiments/HVIExperiments/Test2/default_hardware.keycfg.txt: -------------------------------------------------------------------------------- 1 | #Hardware configuration file for our Keysight modules. Update as needed 2 | 3 | Chassis Number: 1 4 | 5 | #as lists 6 | Input Modules: [10] 7 | Output Modules: [6, 7, 8, 9] 8 | -------------------------------------------------------------------------------- /slab/experiments/HVIExperiments/DataHandlerHelper/build/temp.win-amd64-3.6/Release/DataHandlerHelper.obj: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SchusterLab/slab/HEAD/slab/experiments/HVIExperiments/DataHandlerHelper/build/temp.win-amd64-3.6/Release/DataHandlerHelper.obj -------------------------------------------------------------------------------- /slab/experiments/HVIExperiments/DataHandlerHelper/build/lib.win-amd64-3.6/datahandlerhelper.cp36-win_amd64.pyd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SchusterLab/slab/HEAD/slab/experiments/HVIExperiments/DataHandlerHelper/build/lib.win-amd64-3.6/datahandlerhelper.cp36-win_amd64.pyd -------------------------------------------------------------------------------- /slab/experiments/Rodin Furnace/_testing_notebooks/020721-Nb1 etch and heat treat logs/00000_2021-02-11_RGA_log.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SchusterLab/slab/HEAD/slab/experiments/Rodin Furnace/_testing_notebooks/020721-Nb1 etch and heat treat logs/00000_2021-02-11_RGA_log.png -------------------------------------------------------------------------------- /slab/experiments/Rodin Furnace/_testing_notebooks/020721-Nb1 etch and heat treat logs/00001_2021-01-23_RGA_log.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SchusterLab/slab/HEAD/slab/experiments/Rodin Furnace/_testing_notebooks/020721-Nb1 etch and heat treat logs/00001_2021-01-23_RGA_log.png -------------------------------------------------------------------------------- /slab/experiments/Rodin Furnace/_testing_notebooks/020721-Nb1 etch and heat treat logs/00000_2021-02-11_Furnace_log.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SchusterLab/slab/HEAD/slab/experiments/Rodin Furnace/_testing_notebooks/020721-Nb1 etch and heat treat logs/00000_2021-02-11_Furnace_log.png -------------------------------------------------------------------------------- /slab/experiments/HVIExperiments/DataHandlerHelper/build/temp.win-amd64-3.6/Release/datahandlerhelper.cp36-win_amd64.exp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SchusterLab/slab/HEAD/slab/experiments/HVIExperiments/DataHandlerHelper/build/temp.win-amd64-3.6/Release/datahandlerhelper.cp36-win_amd64.exp -------------------------------------------------------------------------------- /slab/experiments/HVIExperiments/DataHandlerHelper/build/temp.win-amd64-3.6/Release/datahandlerhelper.cp36-win_amd64.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SchusterLab/slab/HEAD/slab/experiments/HVIExperiments/DataHandlerHelper/build/temp.win-amd64-3.6/Release/datahandlerhelper.cp36-win_amd64.lib -------------------------------------------------------------------------------- /slab/experiments/plottest.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | Created on Fri Sep 14 03:23:49 2018 4 | 5 | @author: slab 6 | """ 7 | 8 | import time 9 | import numpy as np 10 | 11 | def func(x, *args): 12 | print(args) 13 | 14 | list = [1, 2, 3] 15 | 16 | func(0, *list) -------------------------------------------------------------------------------- /slab/instruments/bk dummy.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | """ 4 | 5 | from slab.instruments import InstrumentManager 6 | from liveplot import LivePlotClient 7 | 8 | 9 | im = InstrumentManager() 10 | 11 | #nwa = im['PNAX2'] 12 | bk = im['bkp_bf2'] 13 | print(bk.get_id()) -------------------------------------------------------------------------------- /slab/experiments/Rodin Furnace/_testing_notebooks/012521-Nb3 re-etch and N2 treatment/00002_2021-01-31_RGA_log_O2_bake.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SchusterLab/slab/HEAD/slab/experiments/Rodin Furnace/_testing_notebooks/012521-Nb3 re-etch and N2 treatment/00002_2021-01-31_RGA_log_O2_bake.png -------------------------------------------------------------------------------- /slab/experiments/Rodin Furnace/_testing_notebooks/021721-Test strip etch and heat treat logs/00000_2021-02-16_RGA_log.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SchusterLab/slab/HEAD/slab/experiments/Rodin Furnace/_testing_notebooks/021721-Test strip etch and heat treat logs/00000_2021-02-16_RGA_log.png -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # SLab 2 | This repository houses experiment code for [Schuster Lab](http://schusterlab.uchicago.edu) at the University of Chicago. 3 | 4 | ## Contents 5 | - [Setup](#setup) 6 | 7 | ## Setup 8 | ``` 9 | pip install git+https://github.com/SchusterLab/slab 10 | ``` 11 | 12 | 13 | -------------------------------------------------------------------------------- /slab/experiments/Rodin Furnace/_testing_notebooks/012521-Nb3 re-etch and N2 treatment/00001_2021-01-23_RGA_log_H2wN2_bake.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SchusterLab/slab/HEAD/slab/experiments/Rodin Furnace/_testing_notebooks/012521-Nb3 re-etch and N2 treatment/00001_2021-01-23_RGA_log_H2wN2_bake.png -------------------------------------------------------------------------------- /slab/scripts/launcher/setup.py: -------------------------------------------------------------------------------- 1 | from distutils.core import setup 2 | import py2exe 3 | windows = [{'script':'launcher.py', 'icon_resources':[(0, 'launcher_icon.ico')]}] 4 | #setup(console=['launcher.py'], options={'py2exe':{'includes':['sip']}}) 5 | setup(windows=windows, options={'py2exe':{'includes':['sip']}}) -------------------------------------------------------------------------------- /slab/experiments/Rodin Furnace/instrument.cfg: -------------------------------------------------------------------------------- 1 | #Instrument Configuration file 2 | #comment lines out to disable instruments 3 | pressure_gauge Center_Three COM7 4 | PID TM4 COM15 5 | AG850 AG850 COM8 6 | TempScan HP34970A COM23 7 | PLC FurnacePLC COM20 8 | #xln XLN10014 COM3 9 | 10 | -------------------------------------------------------------------------------- /slab/instruments/Alazar/SweepDialog_ui.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | # Form implementation generated from reading ui file 'SweepDialog.ui' 4 | # 5 | # Created: Mon Apr 09 14:45:17 2012 6 | # by: PyQt4 UI code generator 4.8.5 7 | # 8 | # WARNING! All changes made in this file will be lost! 9 | 10 | -------------------------------------------------------------------------------- /slab/instruments/Furnace Cycle.py: -------------------------------------------------------------------------------- 1 | ''' 2 | Author: Andrew Oriani 3 | Furnace cycle automation script 4 | ''' 5 | 6 | import slab 7 | from slab import * 8 | import numpy as np 9 | import time 10 | 11 | 12 | 13 | #instrument manager initialization 14 | im-InstrumentManager() 15 | 16 | xln_id=im.xln.get_id()[1] 17 | rga_id=im.rga.get_id() 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /slab/plotting/run_hdfiview.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | Created on Thu Nov 01 16:51:01 2012 4 | 5 | @author: slab 6 | """ 7 | 8 | import subprocess 9 | import sys 10 | try: 11 | subprocess.call(["python", "C:\_Lib\python\slab\plotting\hdfiview.py", sys.argv[1]]) 12 | except IndexError: 13 | subprocess.call(["python", "C:\_Lib\python\slab\plotting\hdfiview.py"]) -------------------------------------------------------------------------------- /slab/scripts/launcher/build/bdist.win32/winexe/temp/_ssl.py: -------------------------------------------------------------------------------- 1 | 2 | def __load(): 3 | import imp, os, sys 4 | try: 5 | dirname = os.path.dirname(__loader__.archive) 6 | except NameError: 7 | dirname = sys.prefix 8 | path = os.path.join(dirname, '_ssl.pyd') 9 | #print "py2exe extension module", __name__, "->", path 10 | mod = imp.load_dynamic(__name__, path) 11 | ## mod.frozen = 1 12 | __load() 13 | del __load 14 | -------------------------------------------------------------------------------- /slab/scripts/launcher/build/bdist.win32/winexe/temp/bz2.py: -------------------------------------------------------------------------------- 1 | 2 | def __load(): 3 | import imp, os, sys 4 | try: 5 | dirname = os.path.dirname(__loader__.archive) 6 | except NameError: 7 | dirname = sys.prefix 8 | path = os.path.join(dirname, 'bz2.pyd') 9 | #print "py2exe extension module", __name__, "->", path 10 | mod = imp.load_dynamic(__name__, path) 11 | ## mod.frozen = 1 12 | __load() 13 | del __load 14 | -------------------------------------------------------------------------------- /slab/scripts/launcher/build/bdist.win32/winexe/temp/sip.py: -------------------------------------------------------------------------------- 1 | 2 | def __load(): 3 | import imp, os, sys 4 | try: 5 | dirname = os.path.dirname(__loader__.archive) 6 | except NameError: 7 | dirname = sys.prefix 8 | path = os.path.join(dirname, 'sip.pyd') 9 | #print "py2exe extension module", __name__, "->", path 10 | mod = imp.load_dynamic(__name__, path) 11 | ## mod.frozen = 1 12 | __load() 13 | del __load 14 | -------------------------------------------------------------------------------- /slab/scripts/launcher/build/bdist.win32/winexe/temp/_ctypes.py: -------------------------------------------------------------------------------- 1 | 2 | def __load(): 3 | import imp, os, sys 4 | try: 5 | dirname = os.path.dirname(__loader__.archive) 6 | except NameError: 7 | dirname = sys.prefix 8 | path = os.path.join(dirname, '_ctypes.pyd') 9 | #print "py2exe extension module", __name__, "->", path 10 | mod = imp.load_dynamic(__name__, path) 11 | ## mod.frozen = 1 12 | __load() 13 | del __load 14 | -------------------------------------------------------------------------------- /slab/scripts/launcher/build/bdist.win32/winexe/temp/_socket.py: -------------------------------------------------------------------------------- 1 | 2 | def __load(): 3 | import imp, os, sys 4 | try: 5 | dirname = os.path.dirname(__loader__.archive) 6 | except NameError: 7 | dirname = sys.prefix 8 | path = os.path.join(dirname, '_socket.pyd') 9 | #print "py2exe extension module", __name__, "->", path 10 | mod = imp.load_dynamic(__name__, path) 11 | ## mod.frozen = 1 12 | __load() 13 | del __load 14 | -------------------------------------------------------------------------------- /slab/scripts/launcher/build/bdist.win32/winexe/temp/select.py: -------------------------------------------------------------------------------- 1 | 2 | def __load(): 3 | import imp, os, sys 4 | try: 5 | dirname = os.path.dirname(__loader__.archive) 6 | except NameError: 7 | dirname = sys.prefix 8 | path = os.path.join(dirname, 'select.pyd') 9 | #print "py2exe extension module", __name__, "->", path 10 | mod = imp.load_dynamic(__name__, path) 11 | ## mod.frozen = 1 12 | __load() 13 | del __load 14 | -------------------------------------------------------------------------------- /slab/instruments/PressureGauge.py: -------------------------------------------------------------------------------- 1 | 2 | 3 | from slab.instruments import SerialInstrument 4 | 5 | class PressureGauge(SerialInstrument): 6 | 7 | def __init__(self, name="PressureGauge", address='COM5',enabled=True,timeout=1): 8 | SerialInstrument.__init__(self, name, address, enabled, timeout) 9 | 10 | def pressure_read(self): 11 | return float(self.query('R')) 12 | 13 | def get_pressure(self): 14 | return self.pressure_read() -------------------------------------------------------------------------------- /slab/scripts/launcher/build/bdist.win32/winexe/temp/PyQt4.Qt.py: -------------------------------------------------------------------------------- 1 | 2 | def __load(): 3 | import imp, os, sys 4 | try: 5 | dirname = os.path.dirname(__loader__.archive) 6 | except NameError: 7 | dirname = sys.prefix 8 | path = os.path.join(dirname, 'PyQt4.Qt.pyd') 9 | #print "py2exe extension module", __name__, "->", path 10 | mod = imp.load_dynamic(__name__, path) 11 | ## mod.frozen = 1 12 | __load() 13 | del __load 14 | -------------------------------------------------------------------------------- /slab/scripts/launcher/build/bdist.win32/winexe/temp/_hashlib.py: -------------------------------------------------------------------------------- 1 | 2 | def __load(): 3 | import imp, os, sys 4 | try: 5 | dirname = os.path.dirname(__loader__.archive) 6 | except NameError: 7 | dirname = sys.prefix 8 | path = os.path.join(dirname, '_hashlib.pyd') 9 | #print "py2exe extension module", __name__, "->", path 10 | mod = imp.load_dynamic(__name__, path) 11 | ## mod.frozen = 1 12 | __load() 13 | del __load 14 | -------------------------------------------------------------------------------- /slab/scripts/launcher/build/bdist.win32/winexe/temp/win32api.py: -------------------------------------------------------------------------------- 1 | 2 | def __load(): 3 | import imp, os, sys 4 | try: 5 | dirname = os.path.dirname(__loader__.archive) 6 | except NameError: 7 | dirname = sys.prefix 8 | path = os.path.join(dirname, 'win32api.pyd') 9 | #print "py2exe extension module", __name__, "->", path 10 | mod = imp.load_dynamic(__name__, path) 11 | ## mod.frozen = 1 12 | __load() 13 | del __load 14 | -------------------------------------------------------------------------------- /slab/scripts/launcher/build/bdist.win32/winexe/temp/PyQt4.QtCore.py: -------------------------------------------------------------------------------- 1 | 2 | def __load(): 3 | import imp, os, sys 4 | try: 5 | dirname = os.path.dirname(__loader__.archive) 6 | except NameError: 7 | dirname = sys.prefix 8 | path = os.path.join(dirname, 'PyQt4.QtCore.pyd') 9 | #print "py2exe extension module", __name__, "->", path 10 | mod = imp.load_dynamic(__name__, path) 11 | ## mod.frozen = 1 12 | __load() 13 | del __load 14 | -------------------------------------------------------------------------------- /slab/scripts/launcher/build/bdist.win32/winexe/temp/PyQt4.QtGui.py: -------------------------------------------------------------------------------- 1 | 2 | def __load(): 3 | import imp, os, sys 4 | try: 5 | dirname = os.path.dirname(__loader__.archive) 6 | except NameError: 7 | dirname = sys.prefix 8 | path = os.path.join(dirname, 'PyQt4.QtGui.pyd') 9 | #print "py2exe extension module", __name__, "->", path 10 | mod = imp.load_dynamic(__name__, path) 11 | ## mod.frozen = 1 12 | __load() 13 | del __load 14 | -------------------------------------------------------------------------------- /slab/scripts/launcher/build/bdist.win32/winexe/temp/unicodedata.py: -------------------------------------------------------------------------------- 1 | 2 | def __load(): 3 | import imp, os, sys 4 | try: 5 | dirname = os.path.dirname(__loader__.archive) 6 | except NameError: 7 | dirname = sys.prefix 8 | path = os.path.join(dirname, 'unicodedata.pyd') 9 | #print "py2exe extension module", __name__, "->", path 10 | mod = imp.load_dynamic(__name__, path) 11 | ## mod.frozen = 1 12 | __load() 13 | del __load 14 | -------------------------------------------------------------------------------- /slab/scripts/launcher/build/bdist.win32/winexe/temp/win32evtlog.py: -------------------------------------------------------------------------------- 1 | 2 | def __load(): 3 | import imp, os, sys 4 | try: 5 | dirname = os.path.dirname(__loader__.archive) 6 | except NameError: 7 | dirname = sys.prefix 8 | path = os.path.join(dirname, 'win32evtlog.pyd') 9 | #print "py2exe extension module", __name__, "->", path 10 | mod = imp.load_dynamic(__name__, path) 11 | ## mod.frozen = 1 12 | __load() 13 | del __load 14 | -------------------------------------------------------------------------------- /slab/__init__.py: -------------------------------------------------------------------------------- 1 | from .instruments import InstrumentManager, LocalInstruments, keysight 2 | from .datamanagement import SlabFile, h5File, AttrDict, generate_file_path 3 | from .dsfit import ( 4 | argselectdomain, selectdomain, zipsort, fitgeneral, fitexp, fitgauss, fithanger, 5 | fithangertilt, fitlor, fitdecaysin, fithanger_new, hangerfunc_new, fit_SNT 6 | ) 7 | from .dataanalysis import * 8 | from .matplotlib_text_wrapper import * 9 | from .experiment import Experiment 10 | from . import kfit 11 | -------------------------------------------------------------------------------- /slab/instruments/Omega16i.py: -------------------------------------------------------------------------------- 1 | __author__ = 'ge' 2 | 3 | from slab.instruments import SocketInstrument 4 | 5 | class Omega16i(SocketInstrument): 6 | default_port = 5000 7 | 8 | def __init__(self, name="Omega16i", address=None, enabled = True ): 9 | SocketInstrument.__init__(self, name, address, enabled=enabled, timeout=10, recv_length=2**20) 10 | self.query_sleep = 0.05 11 | 12 | def get_id(self): 13 | return "Omega 16i" 14 | 15 | def get_pressure(self, ch = '1'): 16 | return self.query("*X01") 17 | 18 | -------------------------------------------------------------------------------- /slab/instruments/spec_analyzer/socket_test.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | Created on Tue Aug 23 14:55:47 2011 4 | 5 | @author: Dai 6 | """ 7 | import socket 8 | import time 9 | 10 | s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) 11 | s.connect(('128.135.35.166', 23)) 12 | s.send('READ'); 13 | time.sleep(1); 14 | print(s.recv(1024)); 15 | s.send('READ_AVG'); 16 | time.sleep(.8); 17 | print(s.recv(1024)); 18 | s.send('invalid command'); 19 | time.sleep(1); 20 | print(s.recv(1024)); 21 | s.send('END'); 22 | time.sleep(1); 23 | print(s.recv(1024)); -------------------------------------------------------------------------------- /slab/datahandlerhelper.pyx: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | Created on Wed Aug 29 14:18:24 2018 4 | 5 | @author: slab 6 | """ 7 | 8 | cdef extern from "keysightSD1c.lib": 9 | short* SD_AIN_DAQbufferGet(int moduleID, int nDAQ, int &readPointsOut, 10 | int &errorOut) 11 | int SD_AIN_DAQbufferPoolConfig(int moduleID, int nDAQ, short* dataBuffer, 12 | int nPoints, int timeOut, 13 | callbackEventPtr callbackFunction, 14 | void *callbackUserObj) -------------------------------------------------------------------------------- /slab/instruments/ArduinoADC.py: -------------------------------------------------------------------------------- 1 | from slab.instruments import SerialInstrument 2 | import time 3 | 4 | class ArduinoADC(SerialInstrument): 5 | 6 | def __init__(self, name="ArduinoADC", address='COM4',enabled=True,timeout=.01): 7 | SerialInstrument.__init__(self, name, address, enabled, timeout,query_sleep=0.2) 8 | self.read() 9 | self.read() 10 | time.sleep(0.5) 11 | self.query('S') 12 | 13 | def get_voltages(self): 14 | s=self.query('S') 15 | s = self.query('S') 16 | return [float(n) for n in s.split(",") ] 17 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # editor files 2 | *.idea 3 | *.vscode 4 | *~ 5 | *\#* 6 | 7 | # python 8 | *.pyc 9 | __pycache__ 10 | *.egg-info 11 | 12 | # julia 13 | Manifest.toml 14 | 15 | # instruments 16 | instruments/instrument.cfg 17 | instruments/awg/test M8195A.ipynb 18 | instruments/awg/.ipynb_checkpoints/test M8195A-checkpoint.ipynb 19 | instruments/instruments.cfg 20 | *.dll 21 | 22 | # examples 23 | !examples/qiskit/rfsoc/config.yaml 24 | 25 | # binary 26 | *.DS_Store 27 | *.dat 28 | *.png 29 | *.pdf 30 | *.bit 31 | *.hwh 32 | 33 | # local 34 | out 35 | _test 36 | *.yaml 37 | *.log 38 | *.json -------------------------------------------------------------------------------- /examples/qiskit/rfsoc/server.py: -------------------------------------------------------------------------------- 1 | """ 2 | server.py 3 | """ 4 | 5 | import argparse 6 | 7 | from slab.instruments.qiskit.rfsoc import RFSoCBackend 8 | 9 | def main(): 10 | # parse CLI args 11 | parser = argparse.ArgumentParser() 12 | parser.add_argument("config-file-path", type=str) 13 | args = vars(parser.parse_args()) 14 | config_file_path = args["config-file-path"] 15 | 16 | # start backend and serve 17 | backend = RFSoCBackend.from_file(config_file_path) 18 | backend.serve() 19 | #ENDDEF 20 | 21 | if __name__ == "__main__": 22 | main() 23 | #ENDIF 24 | -------------------------------------------------------------------------------- /setup.py: -------------------------------------------------------------------------------- 1 | """ 2 | setup.py - a module to allow package installation 3 | """ 4 | 5 | from distutils.core import setup 6 | 7 | NAME = "slab" 8 | VERSION = "0.1" 9 | DEPENDENCIES = [ 10 | "numpy", 11 | "pyro4", 12 | "scipy", 13 | "tabulate", 14 | "visa" 15 | ] 16 | DESCRIPTION = "This package is used for Schuster Lab experiments" 17 | AUTHOR = "David Schuster" 18 | AUTHOR_EMAIL = "david.schuster@uchicago.edu" 19 | 20 | setup(author=AUTHOR, 21 | author_email=AUTHOR_EMAIL, 22 | description=DESCRIPTION, 23 | requires=DEPENDENCIES, 24 | name=NAME, 25 | version=VERSION, 26 | ) 27 | -------------------------------------------------------------------------------- /slab/instruments/keysightM3xxxA.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | Created on Thu Aug 16 15:33:58 2018 4 | 5 | @author: Josie Meyer (jcmeyer@stanford.edu) 6 | 7 | This file exists solely for integration between the Keysight code I wrote in 8 | the slab/instruments/keysight folder and the instrumentmanager class. It 9 | essentially aliases the KeysightChassis class. 10 | """ 11 | import keysight.KeysightLib as key 12 | 13 | class keysightM3xxxA(key.KeysightChassis): 14 | 15 | def __init__(self, name, address): 16 | self._name = name 17 | self._address = address 18 | 19 | self. -------------------------------------------------------------------------------- /slab/instruments/qiskit/json_util.py: -------------------------------------------------------------------------------- 1 | """ 2 | json_util.py 3 | """ 4 | 5 | import enum 6 | import json 7 | 8 | import numpy as np 9 | 10 | class PulseEncoder(json.JSONEncoder): 11 | def default(self, obj): 12 | if isinstance(obj, np.ndarray): 13 | ret = obj.tolist() 14 | elif isinstance(obj, complex): 15 | ret = (obj.real, obj.imag) 16 | elif isinstance(obj, enum.Enum): 17 | ret = obj.value 18 | else: 19 | ret = json.JSONEncoder.default(self, obj) 20 | #ENDELSE 21 | 22 | return ret 23 | #ENDDEF 24 | #ENDCLASS 25 | -------------------------------------------------------------------------------- /slab/instruments/RedPitaya/PyRedPitaya/tests/rp_test.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | from PyRedPitaya.instrument import RedPitaya 3 | 4 | 5 | def check_conv_buffer_readwrite(rp): 6 | ans = True 7 | for offset in [0x30000, 0x40000, 0x50000, 0x60000]: 8 | data = [rp.scope.from_pyint(v) for v in np.random.randint(0, 2 ** 13, 2 ** 12)] 9 | rp.scope.writes(offset, data) 10 | rdata = np.array([rp.scope.to_pyint(v) for v in rp.scope.reads(offset, len(data))]) 11 | ans = ans and np.array_equal(rdata, data) 12 | return ans 13 | 14 | if __name__ == "__main__": 15 | rp = RedPitaya() 16 | 17 | check_conv_buffer_readwrite(rp) 18 | 19 | -------------------------------------------------------------------------------- /slab/experiments/Alex/ExpLib/PulseSequenceGroup.py: -------------------------------------------------------------------------------- 1 | __author__ = 'Nitrogen' 2 | 3 | def cphase(psb,control_id ,minus_Z_id): 4 | psb.append('q,mm'+str(control_id),'pi_ge') 5 | psb.append('q,mm'+str(minus_Z_id),'2pi_ef') 6 | psb.append('q,mm'+str(control_id),'pi_ge') 7 | 8 | 9 | 10 | # def cnot(psb,control_id ,minus_Z_id): 11 | # psb.append('q,mm'+str(control_id),'pi_ge') 12 | # psb.append('q,mm'+str(minus_Z_id),'pi_ef') 13 | # # self.psb.append('q','general', self.ef_pulse_type, amp=1, length=self.expt_cfg['pi_ef_length'],freq=self.ef_sideband_freq) 14 | # psb.append('q,mm'+str(control_id),'pi_ef',phase=180) 15 | # psb.append('q,mm'+str(control_id),'pi_ge',phase=180) -------------------------------------------------------------------------------- /slab/experiments/Hafnium/ExpLib/PulseSequenceGroup.py: -------------------------------------------------------------------------------- 1 | __author__ = 'Nitrogen' 2 | 3 | def cphase(psb,control_id ,minus_Z_id): 4 | psb.append('q,mm'+str(control_id),'pi_ge') 5 | psb.append('q,mm'+str(minus_Z_id),'2pi_ef') 6 | psb.append('q,mm'+str(control_id),'pi_ge') 7 | 8 | 9 | 10 | # def cnot(psb,control_id ,minus_Z_id): 11 | # psb.append('q,mm'+str(control_id),'pi_ge') 12 | # psb.append('q,mm'+str(minus_Z_id),'pi_ef') 13 | # # self.psb.append('q','general', self.ef_pulse_type, amp=1, length=self.expt_cfg['pi_ef_length'],freq=self.ef_sideband_freq) 14 | # psb.append('q,mm'+str(control_id),'pi_ef',phase=180) 15 | # psb.append('q,mm'+str(control_id),'pi_ge',phase=180) -------------------------------------------------------------------------------- /slab/instruments/spec_analyzer/test_telnet_sa.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | Created on Tue Aug 23 16:38:16 2011 4 | 5 | @author: Dai 6 | """ 7 | from numpy import * 8 | from guiqwt.pyplot import * 9 | from time import * 10 | import matplotlib.pyplot as plt 11 | 12 | from .spectrum_analyzer import * 13 | 14 | pwr = [] 15 | ts = [] 16 | sa = SpectrumAnalyzer(address='128.135.35.166', query_sleep=0.2) 17 | t0 = time.time(); 18 | for i in range(1000): 19 | pwr.append(sa.get_power()) 20 | ts.append(time.time()-t0) 21 | print(i) 22 | 23 | figure(0) 24 | xlabel('time (s)') 25 | ylabel('output') 26 | title('Output Stability Test') 27 | plot(ts, array(pwr), 'r+') 28 | show() 29 | 30 | plt.hist(pwr, 7) 31 | plt.show() -------------------------------------------------------------------------------- /test/InstrumentManager test.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | Created on Sat Oct 13 10:41:58 2012 4 | 5 | @author: Dave 6 | """ 7 | 8 | """ 9 | To do this test you have to first start the nameserver 10 | and an InstrumentManager server 11 | 12 | #To start a nameserver (if one isn't already present) 13 | python -m Pyro4.naming -n hostname 14 | 15 | #To start InstrumentManager Server 16 | im = InstrumentManager(r'c:\_Lib\python\slab\instruments\instrument.cfg') 17 | im.serve_instruments() 18 | 19 | """ 20 | 21 | from slab.instruments import InstrumentManager 22 | 23 | im=InstrumentManager() 24 | print(list(im.keys())) 25 | print(im['echo'].echo('This is a test')) 26 | print(im['random'].random()) 27 | #print im['FRIDGE'].get_status() -------------------------------------------------------------------------------- /slab/instruments/localinstruments.py: -------------------------------------------------------------------------------- 1 | from slab.instruments.awg.PXDAC4800 import PXDAC4800 2 | 3 | class LocalInstruments(): 4 | 5 | # need a classmethod to generate these class variables inside init? 6 | 7 | inst_dict = {} 8 | inst_dict['pxdac4800_1'] = PXDAC4800(1) 9 | inst_dict['pxdac4800_2'] = PXDAC4800(2) 10 | #inst_dict['pxdac4800_3'] = PXDAC4800(3) 11 | 12 | def __init__(self): 13 | #self.test() 14 | pass 15 | 16 | # @classmethod 17 | # def test(cls): 18 | # cls.inst_dict['pxdac4800_2'] = PXDAC4800(2) 19 | # cls.inst_dict['pxdac4800_3'] = PXDAC4800(3) 20 | 21 | # note: 22 | # class method works for initialization, but errors out in 23 | # prep_function when start/stopping pxdacs 24 | 25 | -------------------------------------------------------------------------------- /slab/experiments/Alex/Multimode/sequentialEXPTest.py: -------------------------------------------------------------------------------- 1 | __author__ = 'Nitrogen' 2 | 3 | from slab.experiments.Multimode.MultimodePulseSequenceExperiment import * 4 | from slab.experiments.General.SingleQubitPulseSequenceExperiment import * 5 | 6 | def foo(**kwargs): 7 | for key, value in kwargs.items(): 8 | print(key) 9 | print(value) 10 | 11 | class SequentialExperiment(): 12 | def __init__(self,exp_list,kwargs_list=None,adc=None): 13 | for ii in arange(len(exp_list)): 14 | print(exp_list[ii]) 15 | foo(**kwargs_list[ii]) 16 | 17 | 18 | exp_l = [] 19 | kwargs_l = [] 20 | 21 | exp_l.append('1') 22 | exp_l.append('2') 23 | exp_l.append('3') 24 | 25 | kwargs_l.append({ 'foo' : 123, 'bar' : 456 }) 26 | kwargs_l.append({}) 27 | kwargs_l.append({ 'foo2' : 222, 'bar2' : 333 }) 28 | 29 | 30 | seq_exp = SequentialExperiment(exp_l,kwargs_l) 31 | -------------------------------------------------------------------------------- /slab/experiments/Hafnium/Multimode/sequentialEXPTest.py: -------------------------------------------------------------------------------- 1 | __author__ = 'Nitrogen' 2 | 3 | from slab.experiments.Multimode.MultimodePulseSequenceExperiment import * 4 | from slab.experiments.General.SingleQubitPulseSequenceExperiment import * 5 | 6 | def foo(**kwargs): 7 | for key, value in kwargs.items(): 8 | print(key) 9 | print(value) 10 | 11 | class SequentialExperiment(): 12 | def __init__(self,exp_list,kwargs_list=None,adc=None): 13 | for ii in arange(len(exp_list)): 14 | print(exp_list[ii]) 15 | foo(**kwargs_list[ii]) 16 | 17 | 18 | exp_l = [] 19 | kwargs_l = [] 20 | 21 | exp_l.append('1') 22 | exp_l.append('2') 23 | exp_l.append('3') 24 | 25 | kwargs_l.append({ 'foo' : 123, 'bar' : 456 }) 26 | kwargs_l.append({}) 27 | kwargs_l.append({ 'foo2' : 222, 'bar2' : 333 }) 28 | 29 | 30 | seq_exp = SequentialExperiment(exp_l,kwargs_l) 31 | -------------------------------------------------------------------------------- /slab/experiments/Nitrogen/Multimode/sequentialEXPTest.py: -------------------------------------------------------------------------------- 1 | __author__ = 'Nitrogen' 2 | 3 | from slab.experiments.Multimode.MultimodePulseSequenceExperiment import * 4 | from slab.experiments.General.SingleQubitPulseSequenceExperiment import * 5 | 6 | def foo(**kwargs): 7 | for key, value in kwargs.items(): 8 | print(key) 9 | print(value) 10 | 11 | class SequentialExperiment(): 12 | def __init__(self,exp_list,kwargs_list=None,adc=None): 13 | for ii in arange(len(exp_list)): 14 | print(exp_list[ii]) 15 | foo(**kwargs_list[ii]) 16 | 17 | 18 | exp_l = [] 19 | kwargs_l = [] 20 | 21 | exp_l.append('1') 22 | exp_l.append('2') 23 | exp_l.append('3') 24 | 25 | kwargs_l.append({ 'foo' : 123, 'bar' : 456 }) 26 | kwargs_l.append({}) 27 | kwargs_l.append({ 'foo2' : 222, 'bar2' : 333 }) 28 | 29 | 30 | seq_exp = SequentialExperiment(exp_l,kwargs_l) 31 | -------------------------------------------------------------------------------- /slab/experiments/Rodin Furnace/furnace_config.yml: -------------------------------------------------------------------------------- 1 | RGA: 2 | scan_masses: 3 | He: 4 4 | N2: 28 5 | H2: 2 6 | O2: 32 7 | H2O: 18 8 | Ar: 40 9 | CO2: 44 10 | scan_rate: 4 11 | fil_current: 1 12 | e_energy: 70 13 | ion_energy: 'high' 14 | foc_volts: 90 15 | units: 'mbar' 16 | interval: 5.0 17 | port: 'COM9' 18 | data_path: 19 | 20 | Furnace: 21 | Ramp_up_rate: .002 #rate is in volts a second 22 | Ramp_down_rate: .01 23 | Pre_heat_time: 3600 #seconds 24 | P_hold: 3.0E-5 25 | P_start: 6.0E-6 26 | Hold_v: 44.5 27 | Hold_time: 14400 28 | logging_interval: 5 29 | 30 | Nitrogen_Doping: 31 | nitrogen_step: True 32 | nitrogen_delay_time: 13920 #time in seconds till start of nitrogen sequence start 33 | nitrogen_hold_time: 120 #should be in whole multiples of 60 seconds, otherwise it rounds down to nearest whole minute 34 | 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /slab/experiments/Rodin Furnace/furnace_config_N2.yml: -------------------------------------------------------------------------------- 1 | RGA: 2 | scan_masses: 3 | He: 4 4 | N2: 28 5 | H2: 2 6 | O2: 32 7 | H2O: 18 8 | Ar: 40 9 | CO2: 44 10 | scan_rate: 4 11 | fil_current: 1 12 | e_energy: 70 13 | ion_energy: 'high' 14 | foc_volts: 90 15 | units: 'mbar' 16 | interval: 5.0 17 | port: 'COM9' 18 | data_path: 19 | 20 | Furnace: 21 | Ramp_up_rate: .002 #rate is in volts a second 22 | Ramp_down_rate: .01 23 | Pre_heat_time: 3600 #seconds 24 | P_hold: 3.0E-5 25 | P_start: 6.0E-6 26 | Hold_v: 45.5 27 | Hold_time: 14400 28 | logging_interval: 5 29 | 30 | Nitrogen_Doping: 31 | nitrogen_step: True 32 | nitrogen_delay_time: 13920 #time in seconds till start of nitrogen sequence start 33 | nitrogen_hold_time: 120 #should be in whole multiples of 60 seconds, otherwise it rounds down to nearest whole minute 34 | 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /slab/instruments/RedPitaya/PyRedPitaya/service.py: -------------------------------------------------------------------------------- 1 | import rpyc 2 | 3 | from .raw_memory import BoardRawMemory 4 | 5 | class MyService(rpyc.Service): 6 | def on_connect(self): 7 | print("CONNECTION") 8 | self._mem = BoardRawMemory() 9 | self._conn._config.update(dict( 10 | allow_all_attrs = True, 11 | allow_pickle = False, 12 | allow_getattr = True, 13 | allow_setattr = True, 14 | allow_delattr = True, 15 | import_custom_exceptions = True, 16 | instantiate_custom_exceptions = True, 17 | instantiate_oldstyle_exceptions = True, 18 | )) 19 | 20 | 21 | def exposed_mem(self): 22 | return self._mem 23 | 24 | if __name__=="__main__": 25 | from rpyc.utils.server import ThreadedServer 26 | print('START SERVER') 27 | t = ThreadedServer(MyService, port = 18861) 28 | t.start() 29 | -------------------------------------------------------------------------------- /slab/instruments/TestInstruments.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | Created on Thu Nov 17 15:44:47 2011 4 | 5 | @author: Nitrogen 6 | """ 7 | 8 | from slab.instruments import Instrument 9 | import random 10 | 11 | class EchoInstrument(Instrument): 12 | 13 | def __init__(self,name,address='',enabled=True): 14 | Instrument.__init__(self,name,address='',enabled=True) 15 | self.s='' 16 | 17 | def write(self,s): 18 | self.s+=s 19 | 20 | def read(self): 21 | s=self.s 22 | self.s='' 23 | return s 24 | 25 | def echo(self,s): 26 | return s 27 | 28 | class RandomInstrument(Instrument): 29 | def __init__(self,name,address='',enabled=True): 30 | Instrument.__init__(self,name,address='',enabled=True) 31 | 32 | def read(self): 33 | return random.random() 34 | 35 | def random(self): 36 | return self.read() -------------------------------------------------------------------------------- /slab/experiments/Rodin Furnace/_testing_notebooks/012521-Nb3 re-etch and N2 treatment/furnace_config.yml: -------------------------------------------------------------------------------- 1 | RGA: 2 | scan_masses: 3 | He: 4 4 | N2: 28 5 | H2: 2 6 | O2: 32 7 | H2O: 18 8 | Ar: 40 9 | CO2: 44 10 | scan_rate: 4 11 | fil_current: 1 12 | e_energy: 70 13 | ion_energy: 'high' 14 | foc_volts: 90 15 | units: 'mbar' 16 | interval: 5.0 17 | port: 'COM9' 18 | data_path: 19 | 20 | Furnace: 21 | Ramp_up_rate: .002 #rate is in volts a second 22 | Ramp_down_rate: .01 23 | Pre_heat_time: 3600 #seconds 24 | P_hold: 3.0E-5 25 | P_start: 6.0E-6 26 | Hold_v: 44.5 27 | Hold_time: 14400 28 | logging_interval: 5 29 | 30 | Nitrogen_Doping: 31 | nitrogen_step: True 32 | nitrogen_delay_time: 13920 #time in seconds till start of nitrogen sequence start 33 | nitrogen_hold_time: 120 #should be in whole multiples of 60 seconds, otherwise it rounds down to nearest whole minute 34 | 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /slab/instruments/awg/M8195A_test.py: -------------------------------------------------------------------------------- 1 | from .M8195A import * 2 | 3 | m8195A = M8195A(address ='192.168.14.234:5025') 4 | 5 | print("Testing set enabled:") 6 | m8195A.set_enabled(1,True) 7 | m8195A.set_enabled(2,False) 8 | print(m8195A.get_enabled(1)) 9 | print(m8195A.get_enabled(2)) 10 | 11 | print("Testing set amplitude:") 12 | m8195A.set_amplitude(1,0.2) 13 | print(m8195A.get_amplitude(1)) 14 | 15 | print("Testing set analogHigh:") 16 | m8195A.set_analog_high(3,0.5) 17 | print(m8195A.get_analog_high(3)) 18 | 19 | print("Testing set analoLow:") 20 | m8195A.set_analog_low(3,-0.5) 21 | print(m8195A.get_analog_low(3)) 22 | 23 | print("Testing set offset:") 24 | m8195A.set_offset(1,0.05) 25 | print(m8195A.get_offset(1)) 26 | 27 | print(m8195A.get_id()) 28 | 29 | print(m8195A.get_dac_mode()) 30 | 31 | m8195A.set_dac_sample_rate_divider(4) 32 | print(m8195A.get_sample_clock_divider()) 33 | 34 | print(m8195A.get_waveform_sample_source(1)) 35 | 36 | print("Done!") -------------------------------------------------------------------------------- /slab/experiments/Rodin Furnace/_testing_notebooks/020721-Nb1 etch and heat treat logs/furnace_config_N2.yml: -------------------------------------------------------------------------------- 1 | RGA: 2 | scan_masses: 3 | He: 4 4 | N2: 28 5 | H2: 2 6 | O2: 32 7 | H2O: 18 8 | Ar: 40 9 | CO2: 44 10 | scan_rate: 4 11 | fil_current: 1 12 | e_energy: 70 13 | ion_energy: 'high' 14 | foc_volts: 90 15 | units: 'mbar' 16 | interval: 5.0 17 | port: 'COM9' 18 | data_path: 19 | 20 | Furnace: 21 | Ramp_up_rate: .002 #rate is in volts a second 22 | Ramp_down_rate: .01 23 | Pre_heat_time: 3600 #seconds 24 | P_hold: 3.0E-5 25 | P_start: 6.0E-6 26 | Hold_v: 45.5 27 | Hold_time: 14400 28 | logging_interval: 5 29 | 30 | Nitrogen_Doping: 31 | nitrogen_step: True 32 | nitrogen_delay_time: 13920 #time in seconds till start of nitrogen sequence start 33 | nitrogen_hold_time: 120 #should be in whole multiples of 60 seconds, otherwise it rounds down to nearest whole minute 34 | 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /slab/experiments/Rodin Furnace/_testing_notebooks/021721-Test strip etch and heat treat logs/furnace_config_N2.yml: -------------------------------------------------------------------------------- 1 | RGA: 2 | scan_masses: 3 | He: 4 4 | N2: 28 5 | H2: 2 6 | O2: 32 7 | H2O: 18 8 | Ar: 40 9 | CO2: 44 10 | scan_rate: 4 11 | fil_current: 1 12 | e_energy: 70 13 | ion_energy: 'high' 14 | foc_volts: 90 15 | units: 'mbar' 16 | interval: 5.0 17 | port: 'COM9' 18 | data_path: 19 | 20 | Furnace: 21 | Ramp_up_rate: .002 #rate is in volts a second 22 | Ramp_down_rate: .01 23 | Pre_heat_time: 3600 #seconds 24 | P_hold: 3.0E-5 25 | P_start: 6.0E-6 26 | Hold_v: 45.5 27 | Hold_time: 14400 28 | logging_interval: 5 29 | 30 | Nitrogen_Doping: 31 | nitrogen_step: True 32 | nitrogen_delay_time: 13920 #time in seconds till start of nitrogen sequence start 33 | nitrogen_hold_time: 120 #should be in whole multiples of 60 seconds, otherwise it rounds down to nearest whole minute 34 | 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /slab/instruments/RedPitaya/PyRedPitaya/client_memory.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | 3 | class ClientMemory(object): 4 | def __init__(self, remote_connection): 5 | self.remote_connection = remote_connection 6 | self.remote_interface = remote_connection.root.mem() 7 | 8 | def read(self, addr): 9 | return self.remote_interface.read(addr) 10 | 11 | def reads(self, addr, length, return_buffer=False): 12 | out = self.remote_interface.reads(addr, length, return_buffer=True) 13 | if return_buffer: 14 | return out 15 | else: 16 | return np.frombuffer(out, dtype='uint32') 17 | 18 | def write(self, addr, value): 19 | self.remote_interface.write(addr, value) 20 | 21 | def writes(self, addr, values): 22 | if not isinstance(values, str): 23 | values = np.array(values, dtype='uint32') 24 | values = str(values.data) 25 | self.remote_interface.writes(addr, values) 26 | 27 | -------------------------------------------------------------------------------- /slab/instruments/awg/M8195A_unittest.py: -------------------------------------------------------------------------------- 1 | __author__ = 'Nelson Leung' 2 | 3 | import unittest 4 | from .M8195A import * 5 | 6 | class M8195ATest(unittest.TestCase): 7 | def test(self): 8 | print("Testing connection") 9 | m8195A = M8195A(address ='192.168.14.234:5025') 10 | 11 | self.assertEqual(m8195A.get_id()[:8],'Keysight') 12 | 13 | print("Testing set enabled") 14 | m8195A.set_enabled(1,True) 15 | m8195A.set_enabled(2,False) 16 | self.assertEqual(m8195A.get_enabled(1),'1\n') 17 | self.assertEqual(m8195A.get_enabled(2),'0\n') 18 | 19 | print("Testing set analogHigh") 20 | m8195A.set_analog_high(3,0.5) 21 | self.assertEqual(m8195A.get_analog_high(3),0.5) 22 | 23 | print("Testing set analoLow") 24 | m8195A.set_analog_low(3,-0.5) 25 | self.assertEqual(m8195A.get_analog_low(3),-0.5) 26 | 27 | print("Testing set offset") 28 | m8195A.set_offset(1,0.05) 29 | self.assertEqual(float(m8195A.get_offset(1)),0.05) 30 | -------------------------------------------------------------------------------- /slab/experiments/Rodin Furnace/furnace_config_O2_bake.yml: -------------------------------------------------------------------------------- 1 | RGA: 2 | scan_masses: #all masses in rounded AMU 3 | He: 4 4 | N2: 28 5 | H2: 2 6 | O2: 32 7 | H2O: 18 8 | Ar: 40 9 | CO2: 44 10 | scan_rate: 4 11 | fil_current: 1 #ma 12 | e_energy: 70 #eV 13 | ion_energy: 'high' 14 | foc_volts: 90 15 | units: 'mbar' 16 | interval: 5.0 #seconds 17 | port: 'COM9' 18 | data_path: 19 | 20 | Furnace: 21 | Ramp_up_rate: .002 #rate is in volts a second 22 | Ramp_down_rate: .01 23 | Pre_heat_time: 3600 #seconds 24 | P_hold: 3.0E-5 #hold and wait pressure in mbar 25 | P_start: 6.0E-6 #starts cycle at this pressure 26 | Hold_v: 18.5 27 | Hold_time: 10800 #seconds 28 | logging_interval: 5 #seconds 29 | 30 | Nitrogen_Doping: 31 | nitrogen_step: False #turns on nitrogen thread 32 | nitrogen_delay_time: 13920 #time in seconds till start of nitrogen sequence start 33 | nitrogen_hold_time: 120 #should be in whole multiples of 60 seconds, otherwise it rounds down to nearest whole minute 34 | 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /slab/instruments/awg/__init__.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | # try: 4 | # from .AWG81180 import AWG81180A 5 | # except: 6 | # print("Warning failed to import AWG81180A") 7 | # try: 8 | # from .Tek5014 import Tek5014, Tek5014Sequence, write_Tek5014_file 9 | # except: 10 | # print("Warning failed to import Tek5014") 11 | # try: 12 | # from .Tek70001 import Tek70001, write_Tek70001_waveform_file, write_Tek70001_sequence 13 | # except: 14 | # print("Warning failed to import Tek70001") 15 | # try: 16 | # from .M8195A import M8195A, upload_M8195A_sequence 17 | # except: 18 | # print("Warning failed to import M8195A") 19 | # try: 20 | # from .chase import DAx22000,DAx22000Segment 21 | # except: 22 | # print("Warning failed to import Chase DAx22000") 23 | 24 | # try: 25 | # from .PXDAC4800 import write_PXDAC4800_file 26 | # except: 27 | # print("Warning failed to import PXDAC4800") 28 | 29 | # from . import awgpulses, awgpulses2 30 | 31 | #from PulseSequence import PulseSequence, PulseSequenceArray 32 | 33 | #import StandardPulseSequences -------------------------------------------------------------------------------- /slab/experiments/HVIExperiments/DataHandlerHelper/setup.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | Created on Wed Sep 12 15:30:31 2018 4 | 5 | @author: Josie Meyer 6 | """ 7 | 8 | from distutils.core import setup, Extension 9 | 10 | module_name = "datahandlerhelper" 11 | 12 | module = Extension(module_name, 13 | sources = ['DataHandlerHelper.c'], 14 | include_dirs = [r"C:\_Lib\SD1\Libraries\include\c", 15 | r"C:\_Lib\C\pthreads-win32_2", 16 | r"C:\Users\slab\Anaconda3\pkgs\numpy-base-1.14.3-py36h555522e_1\Lib\site-packages\numpy\core\include\numpy"], 17 | libraries = ["keysightSD1", "pthreadVC2"], 18 | library_dirs = [r"C:\_Lib\SD1\Libraries\libx64\c", 19 | r"C:\_Lib\C\pthreads-win32_2", 20 | r"C::\_Lib\SD1\shared"]) 21 | 22 | setup(name = module_name, 23 | author = "Josephine Meyer", 24 | author_email = "jcmeyer@stanford.edu", 25 | version = "1.0", 26 | ext_modules = [module]) -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022 SchusterLab 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /slab/instruments/spec_analyzer/sa_linear.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | Created on Wed Aug 24 15:58:02 2011 4 | 5 | @author: Dai 6 | """ 7 | from instruments import * 8 | from rfgenerators import * 9 | from .spectrum_analyzer import * 10 | import matplotlib.pyplot as plt 11 | import time 12 | from numpy import * 13 | 14 | sa = SpectrumAnalyzer(address='128.135.35.166') 15 | #sa = SpectrumAnalyzer(protocol='serial', port=2) 16 | 17 | rf = E8257D(address='rfgen1.circuitqed.com') 18 | lo = E8257D(address='rfgen2.circuitqed.com') 19 | 20 | rf.set_output(False) 21 | lo.set_output(False) 22 | 23 | freq = 5e9 24 | rf.set_frequency(freq) 25 | lo.set_power(7) 26 | lo.set_frequency(freq+sa.lo_offset) 27 | lo.set_output(True) 28 | 29 | p = [] 30 | 31 | pwrs = arange(-10.0, 10.0, 1) 32 | for pwr in pwrs: 33 | rf.set_power(pwr) 34 | rf.set_output(True) 35 | time.sleep(0.2) 36 | p.append(sa.get_power()) 37 | rf.set_output(False) 38 | """ 39 | rf.set_power(-10) 40 | rf.set_output(True) 41 | pwrs = [] 42 | t0 = time.time() 43 | for i in range(50): 44 | pwrs.append(time.time()-t0) 45 | p.append(sa.get_avg_power()) 46 | time.sleep(0.1) 47 | """ 48 | lo.set_output(False) 49 | plt.scatter(pwrs, array(p)) 50 | plt.show() -------------------------------------------------------------------------------- /slab/templates/gui_template.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | Template for writing gui programs 4 | 5 | To use: 6 | - fill in UI_PREFIX with the name of your ui file which should be in the 7 | same directory as this file. E.g. if "test.ui" exists in this directory, 8 | write UI_PREFIX = "test" 9 | - Import from the compiled ui file, e.g. from test_ui import Ui_MainWindow 10 | - Rename MyDataThread and MyWindow to something more descriptive 11 | - 12 | """ 13 | from slab import gui 14 | 15 | COMPILE_UI = False 16 | UI_PREFIX = "myWindow" 17 | if COMPILE_UI: 18 | gui.compile_ui(UI_PREFIX) 19 | 20 | from myWindow_ui import Ui_MainWindow 21 | 22 | 23 | 24 | class MyDataThread(gui.DataThread): 25 | def my_script(self): 26 | # parameters in self.params["param_name"] 27 | # plots in self.plots["plot_name"] 28 | pass 29 | 30 | class MyWindow(gui.SlabWindow, Ui_MainWindow): 31 | def __init__(self): 32 | gui.SlabWindow.__init__(self, MyDataThread) 33 | self.setupSlabWindow(autoparam=True) 34 | self.register_script("my_script", self.start_button, self.abort_button) 35 | self.start_thread() 36 | 37 | if __name__ == "__main__": 38 | gui.runWin(MyWindow) -------------------------------------------------------------------------------- /slab/experiments/Alex/Multimode/mm_flux_sideband_rabi_freq_sweep_new_3.py: -------------------------------------------------------------------------------- 1 | __author__ = 'Nelson' 2 | 3 | from .MultimodeFluxSideBandFreqSweepExperiment3 import * 4 | import gc 5 | import json 6 | from slab.instruments.Alazar import Alazar 7 | 8 | flux_freq_pts = arange(2.515,3.0,0.001) 9 | 10 | path = r"S:\_Data\150716 - 2D multimode (Chip 1)\data" 11 | prefix = 'MM_Flux_Sideband_Rabi_Freq_Sweep_3_' 12 | data_file = os.path.join(path, get_next_filename(path, prefix, suffix='.h5')) 13 | config_file = os.path.join(path, "..\\config" + ".json") 14 | with open(config_file, 'r') as fid: 15 | cfg_str = fid.read() 16 | 17 | cfg = AttrDict(json.loads(cfg_str)) 18 | 19 | print("Prep Card") 20 | adc = Alazar(cfg['alazar']) 21 | 22 | for ii, flux_freq in enumerate(flux_freq_pts): 23 | 24 | mm_flux_sideband_rabi_freq_sweep=MultimodeFluxSideBandFreqSweepExperiment3(path=path,prefix=prefix,config_file='..\\config.json',flux_freq=flux_freq, data_file=data_file) 25 | # if ii == 0: 26 | # mm_flux_sideband_rabi_freq_sweep.plotter.clear() 27 | if mm_flux_sideband_rabi_freq_sweep.ready_to_go: 28 | mm_flux_sideband_rabi_freq_sweep.go(adc=adc) 29 | 30 | mm_flux_sideband_rabi_freq_sweep = None 31 | del mm_flux_sideband_rabi_freq_sweep 32 | 33 | gc.collect() 34 | 35 | -------------------------------------------------------------------------------- /slab/experiments/Alex/ExpLib/SequentialExperiment.py: -------------------------------------------------------------------------------- 1 | __author__ = 'Nelson' 2 | 3 | from slab.experiments.Alex.General.run_experiment import * 4 | from slab.experiments.Alex.Multimode.run_multimode_experiment import * 5 | 6 | import gc 7 | 8 | class SequentialExperiment(): 9 | def __init__(self, lp_enable = True): 10 | self.expt = None 11 | self.lp_enable = lp_enable 12 | 13 | 14 | def run(self,exp): 15 | 16 | if self.expt is not None: 17 | del self.expt 18 | gc.collect() 19 | 20 | expt_name = exp[0] 21 | expt_kwargs = exp[1] 22 | 23 | if 'seq_pre_run' in expt_kwargs: 24 | expt_kwargs['seq_pre_run'](self) 25 | 26 | self.expt = run_experiment(expt_name,self.lp_enable,**expt_kwargs) 27 | if self.expt is None: 28 | self.expt = run_multimode_experiment(expt_name,self.lp_enable,**expt_kwargs) 29 | 30 | if 'seq_post_run' in expt_kwargs: 31 | expt_kwargs['seq_post_run'](self) 32 | 33 | if 'update_config' in expt_kwargs: 34 | if expt_kwargs['update_config']: 35 | self.save_config() 36 | 37 | def save_config(self): 38 | self.expt.save_config() 39 | print("config saved!") 40 | 41 | 42 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /slab/experiments/Hafnium/Multimode/mm_flux_sideband_rabi_freq_sweep_new_3.py: -------------------------------------------------------------------------------- 1 | __author__ = 'Nelson' 2 | 3 | from .MultimodeFluxSideBandFreqSweepExperiment3 import * 4 | import gc 5 | import json 6 | from slab.instruments.Alazar import Alazar 7 | 8 | flux_freq_pts = arange(2.515,3.0,0.001) 9 | 10 | path = r"S:\_Data\150716 - 2D multimode (Chip 1)\data" 11 | prefix = 'MM_Flux_Sideband_Rabi_Freq_Sweep_3_' 12 | data_file = os.path.join(path, get_next_filename(path, prefix, suffix='.h5')) 13 | config_file = os.path.join(path, "..\\config" + ".json") 14 | with open(config_file, 'r') as fid: 15 | cfg_str = fid.read() 16 | 17 | cfg = AttrDict(json.loads(cfg_str)) 18 | 19 | print("Prep Card") 20 | adc = Alazar(cfg['alazar']) 21 | 22 | for ii, flux_freq in enumerate(flux_freq_pts): 23 | 24 | mm_flux_sideband_rabi_freq_sweep=MultimodeFluxSideBandFreqSweepExperiment3(path=path,prefix=prefix,config_file='..\\config.json',flux_freq=flux_freq, data_file=data_file) 25 | # if ii == 0: 26 | # mm_flux_sideband_rabi_freq_sweep.plotter.clear() 27 | if mm_flux_sideband_rabi_freq_sweep.ready_to_go: 28 | mm_flux_sideband_rabi_freq_sweep.go(adc=adc) 29 | 30 | mm_flux_sideband_rabi_freq_sweep = None 31 | del mm_flux_sideband_rabi_freq_sweep 32 | 33 | gc.collect() 34 | 35 | -------------------------------------------------------------------------------- /slab/experiments/Nitrogen/Multimode/mm_flux_sideband_rabi_freq_sweep_new_3.py: -------------------------------------------------------------------------------- 1 | __author__ = 'Nelson' 2 | 3 | from .MultimodeFluxSideBandFreqSweepExperiment3 import * 4 | import gc 5 | import json 6 | from slab.instruments.Alazar import Alazar 7 | 8 | flux_freq_pts = arange(2.515,3.0,0.001) 9 | 10 | path = r"S:\_Data\150716 - 2D multimode (Chip 1)\data" 11 | prefix = 'MM_Flux_Sideband_Rabi_Freq_Sweep_3_' 12 | data_file = os.path.join(path, get_next_filename(path, prefix, suffix='.h5')) 13 | config_file = os.path.join(path, "..\\config" + ".json") 14 | with open(config_file, 'r') as fid: 15 | cfg_str = fid.read() 16 | 17 | cfg = AttrDict(json.loads(cfg_str)) 18 | 19 | print("Prep Card") 20 | adc = Alazar(cfg['alazar']) 21 | 22 | for ii, flux_freq in enumerate(flux_freq_pts): 23 | 24 | mm_flux_sideband_rabi_freq_sweep=MultimodeFluxSideBandFreqSweepExperiment3(path=path,prefix=prefix,config_file='..\\config.json',flux_freq=flux_freq, data_file=data_file) 25 | # if ii == 0: 26 | # mm_flux_sideband_rabi_freq_sweep.plotter.clear() 27 | if mm_flux_sideband_rabi_freq_sweep.ready_to_go: 28 | mm_flux_sideband_rabi_freq_sweep.go(adc=adc) 29 | 30 | mm_flux_sideband_rabi_freq_sweep = None 31 | del mm_flux_sideband_rabi_freq_sweep 32 | 33 | gc.collect() 34 | 35 | -------------------------------------------------------------------------------- /slab/instruments/HeaterSwitch.py: -------------------------------------------------------------------------------- 1 | __author__ = 'ge' 2 | 3 | from slab.instruments import WebInstrument 4 | from urllib.request import urlopen 5 | 6 | 7 | class HeaterSwitch(WebInstrument): 8 | def __init__(self, name="HeaterSwitch", address='', enabled=True): 9 | WebInstrument.__init__(self, name, address, enabled) 10 | 11 | def get_switch(self, num): 12 | if num in (0, 1, 2, 3, 4): 13 | return urlopen(self.address + '/Q' + str(num)).read().split('\r\n')[1] 14 | else: 15 | print("ERROR: Invalid switch number") 16 | 17 | def get_switches(self): 18 | return [self.get_switch(ii) for ii in range(1, 5)] 19 | 20 | def set_switch(self, num, state): 21 | if num in (1, 2, 3, 4): 22 | if state.lower() == 'on': 23 | return urlopen(self.address + '/S' + str(num) + '0').read().split('\r\n')[1] 24 | elif state.lower() == 'off': 25 | return urlopen(self.address + '/S' + str(num) + '1').read().split('\r\n')[1] 26 | else: 27 | print("ERROR: Invalid command (ON\OFF) only") 28 | else: 29 | print("ERROR: Invalid switch number") 30 | 31 | def reset_switch(self): 32 | return urlopen(self.address + '/R').read().split('\r\n')[1] 33 | -------------------------------------------------------------------------------- /slab/instruments/spec_analyzer/sa_calibration.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | Created on Tue Aug 23 17:50:07 2011 4 | 5 | @author: Dai 6 | """ 7 | from .spectrum_analyzer import * 8 | from rfgenerators import * 9 | import pickle 10 | import time 11 | import matplotlib.pyplot as plt 12 | import numpy as np 13 | 14 | rf = E8257D(address='rfgen1.circuitqed.com') 15 | lo = E8257D(address='rfgen2.circuitqed.com') 16 | sa = SpectrumAnalyzer(address='128.135.35.167') 17 | 18 | min_power = pickle.load(open('10dBm_min_pwr.data', 'r')) 19 | cali = [] 20 | step = 10 21 | 22 | lo.set_output(False) 23 | rf.set_output(False) 24 | 25 | lo.set_power(10) 26 | 27 | for freq, mp in min_power: 28 | rf.set_frequency(freq) 29 | lo.set_frequency(freq + sa.lo_offset) 30 | lo.set_output(True) 31 | for pwr in range(mp, 10, step): 32 | rf.set_power(pwr) 33 | rf.set_output(True) 34 | time.sleep(0.2) 35 | #the calibration data is stored in a 2D array 36 | nd = [freq, sa.get_power(), pwr] 37 | cali.append(nd) 38 | print(nd) 39 | rf.set_output(False) 40 | lo.set_output(False) 41 | 42 | print(cali) 43 | pickle.dump(cali, open('10dBm_'+str(step)+'_cali.data', 'w')) 44 | 45 | c = np.array(cali) 46 | c = c.transpose() 47 | plt.scatter(c[0], c[1]) 48 | plt.show() -------------------------------------------------------------------------------- /slab/instruments/Temperature Logger.py: -------------------------------------------------------------------------------- 1 | import slab 2 | from slab import * 3 | import time 4 | import numpy as np 5 | 6 | # make sure fridge server is running prior to running script 7 | im=InstrumentManager() 8 | fridge=im['whistler'] 9 | expt= Experiment(expt_path='S:\_SchusterFridge\Whistler_Data', prefix='cryolog', liveplot_enabled=False) 10 | 11 | interval = 2. 12 | start_time=time.time() 13 | 14 | with expt.datafile() as f: 15 | f.attrs['start_time']=start_time 16 | f.attrs['interval']=interval 17 | # generic cryocon channels 18 | cryocon_channels = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H'] 19 | thermometer_labels=fridge.get_thermometers 20 | channels=[] 21 | 22 | #sets channels based on the channels present in the config 23 | for i in range(0, len(thermometer_labels)): 24 | channels[i]=cryocon_channels[i] 25 | 26 | print("Monitering temperature in"+expt.fname) 27 | while True: 28 | 29 | try: 30 | temps=[fridge.get_temp(ch) for ch in channels] 31 | t=time.time()-start_time 32 | print(temps, t) 33 | time.sleep(interval) 34 | with expt.datafile() as f: 35 | f.append_pt('tpts', t) 36 | for ch, temp in zip(channels, temps): 37 | f.append_pt(ch, temp) 38 | 39 | except: 40 | print('Exception occured...trying to continue....') 41 | -------------------------------------------------------------------------------- /slab/instruments/spec_analyzer/serial_com.py: -------------------------------------------------------------------------------- 1 | """ 2 | 3 | 4 | Author: Falcon Dai 5 | Date: 08/17/2011 6 | """ 7 | #using pySerial library 8 | import serial 9 | 10 | import time 11 | 12 | 13 | #scan for devices connected through serial ports 14 | #returns a list of tuples of the port number and the name of the device 15 | def scan(): 16 | 17 | port = [] 18 | for i in range(256): 19 | try: 20 | s = serial.Serial(i) 21 | port.append( (i, s.name) ) 22 | s.close() 23 | except serial.SerialException: 24 | pass 25 | return port 26 | 27 | 28 | if __name__ == '__main__': 29 | print(scan()) 30 | numPort = int(input('Enter the port number: ')) 31 | try: 32 | ser = serial.Serial(numPort) 33 | except serial.SerialException: 34 | print('Serial object cannot be created on port '+str(numPort)+'.\n') 35 | exit() 36 | 37 | time.sleep(0.1) 38 | print(ser.readline()) 39 | 40 | #create data files to record data 41 | fout = open('data/data.txt', 'w') 42 | fout.write('LO freq=6GHz, Amp=1dBm\n') 43 | 44 | for i in range(100): 45 | ser.write('READ') 46 | time.sleep(0.1) 47 | fout.write(ser.readline()) 48 | 49 | ser.close() 50 | fout.close() 51 | print('END') -------------------------------------------------------------------------------- /slab/scripts/fileserverviewer.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | Created on Tue Jan 29 13:54:11 2013 4 | 5 | @author: slab 6 | """ 7 | 8 | import PyQt4.Qt as qt 9 | import slab.datamanagement as dm 10 | 11 | if __name__ == "__main__": 12 | app = qt.QApplication([]) 13 | win = qt.QMainWindow() 14 | server = dm.FileServer(gui=app) 15 | widget = qt.QWidget() 16 | layout = qt.QVBoxLayout(widget) 17 | class FileList(qt.QListWidget): 18 | def __init__(self): 19 | qt.QListWidget.__init__(self) 20 | self.file_position = {} 21 | def add_file(self, fname): 22 | row = self.count() 23 | self.insertItem(row, fname) 24 | self.file_position[fname] = row 25 | def remove_file(self, fname): 26 | self.takeItem(self.file_position[fname]) 27 | filelist = FileList() 28 | app.connect(app, server.fileAddedSignal, filelist.add_file) 29 | app.connect(app, server.fileRemovedSignal, filelist.remove_file) 30 | app.connect(app, server.resetSignal, filelist.clear) 31 | 32 | reset_button = qt.QPushButton('Reset Server') 33 | reset_button.clicked.connect(server.restart) 34 | layout.addWidget(filelist) 35 | layout.addWidget(reset_button) 36 | win.setCentralWidget(widget) 37 | app.connect(app, qt.SIGNAL("lastWindowClosed()"), server.close) 38 | win.show() 39 | app.exec_() -------------------------------------------------------------------------------- /slab/experiments/Rodin Furnace/heater_config.yml: -------------------------------------------------------------------------------- 1 | PID: 2 | Port: 'COM15' 3 | UNITS: 'C' 4 | Con_Interval: 2.0 5 | Con_Type: 'PID' 6 | Ramp_Up_Rate: 5.0 #in deg (units) per unit time 7 | Ramp_Down_Rate: 5.0 8 | Ramp_Time_Unit: 'MIN' #must be SEC, MIN, HOUR 9 | CHANNELS: 10 | 1: 11 | Set_Point: 100.00 12 | P: 100.00 13 | I: 10.0 14 | D: 0 15 | RUN: True 16 | Con_Mode: 'AUTO' 17 | 2: 18 | Set_Point: 100.00 19 | P: 100.00 20 | I: 10.0 21 | D: 0 22 | RUN: True 23 | Con_Mode: 'AUTO' 24 | 3: 25 | Set_Point: 100.00 26 | P: 100.00 27 | I: 10.0 28 | D: 0 29 | RUN: True 30 | Con_Mode: 'AUTO' 31 | 4: 32 | Set_Point: 100.00 33 | P: 100.00 34 | I: 5.0 35 | D: 0 36 | RUN: True 37 | Con_Mode: 'AUTO' 38 | 5: 39 | Set_Point: 100.00 40 | P: 50.0 41 | I: 20 42 | D: 0 43 | RUN: True 44 | Con_Mode: 'AUTO' 45 | 6: 46 | Set_Point: 100.00 47 | P: 100.00 48 | I: 10.0 49 | D: 0 50 | RUN: False 51 | Con_Mode: 'AUTO' 52 | 7: 53 | Set_Point: 100.00 54 | P: 100.00 55 | I: 10.0 56 | D: 0 57 | RUN: False 58 | Con_Mode: 'AUTO' 59 | 8: 60 | Set_Point: 40 61 | P: 100.00 62 | I: 10.0 63 | D: 0 64 | RUN: False 65 | Con_Mode: 'AUTO' -------------------------------------------------------------------------------- /slab/instruments/spec_analyzer/precision.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | Created on Thu Aug 25 15:56:42 2011 4 | 5 | @author: Dai 6 | """ 7 | from rfgenerators import * 8 | from .spectrum_analyzer import * 9 | 10 | sa = SpectrumAnalyzer(address='128.135.35.167') 11 | rf = E8257D(address='rfgen1.circuitqed.com') 12 | lo = E8257D(address='rfgen2.circuitqed.com') 13 | rf.set_output(False) 14 | lo.set_output(False) 15 | 16 | lo.set_power(10) 17 | 18 | freq = 6e9 19 | rf.set_frequency(freq) 20 | lo.set_frequency(freq+sa.lo_offset) 21 | lo.set_output() 22 | 23 | for pwr in range(-200, 0, 1): 24 | rf.set_power(pwr/10.0) 25 | rf.set_output() 26 | time.sleep(0.2) 27 | op = sa.get_power() 28 | print('SA output: '+str(op)) 29 | print() 30 | rf.set_output(False) 31 | 32 | """ 33 | for f0 in range(500, 510, 1): 34 | f = f0*1e7 35 | rf.set_frequency(f) 36 | lo.set_frequency(f+sa.lo_offset) 37 | lo.set_output() 38 | for pwr in range(-10, 0, 2): 39 | rf.set_power(pwr) 40 | rf.set_output() 41 | time.sleep(0.2) 42 | op = sa.get_power() 43 | ppwr = get_rf_power(f, op) 44 | print 'RF frequency: '+str(f)+', SA output: '+str(op) 45 | print 'Measured: '+str(pwr)+', Predicted: '+str(ppwr) 46 | print 'Difference: '+str(ppwr-pwr) 47 | print 48 | rf.set_output(False) 49 | lo.set_output(False) 50 | """ -------------------------------------------------------------------------------- /slab/instruments/testscript.py: -------------------------------------------------------------------------------- 1 | __author__ = 'Nate' 2 | 3 | 4 | from slab import * 5 | from slab.datamanagement import SlabFile 6 | from numpy import * 7 | import os 8 | from instruments.PNAX import N5242A 9 | 10 | from slab.instruments import InstrumentManager 11 | from slab.instruments import Alazar, AlazarConfig 12 | from slab.instruments import InstrumentManager 13 | from liveplot import LivePlotClient 14 | #from slab.instruments import N5242A 15 | from slab.dsfit import fithanger_new_withQc 16 | 17 | 18 | 19 | im = InstrumentManager() 20 | #plotter = LivePlotClient() 21 | dcflux = im['YOKO2'] 22 | nwa = im['PNAX'] 23 | # nwa = N5242A("N5242A", address="192.168.14.249", timeout=10.) 24 | #drive = im['RF3'] 25 | print('Deviced Connected') 26 | expt_path = os.getcwd() + '\data' 27 | 28 | 29 | 30 | # initial NWA configuration values 31 | ifbw = 20 32 | read_power = -65.0 33 | probe_power = -20.0 34 | center = 4.35e9 35 | span = 400e6 36 | sweep_pts = 701 37 | avgs = 5 38 | delay = 0 39 | print("Configuring the NWA") 40 | nwa.set_timeout(10) 41 | nwa.set_ifbw(ifbw) 42 | nwa.set_center_frequency(center) 43 | nwa.set_span(span) 44 | nwa.write(":SOURCE:POWER1 %f" %(read_power)) 45 | nwa.write(":SOURCE:POWER3 %f" %(probe_power)) 46 | nwa.set_sweep_points(sweep_pts) 47 | nwa.clear_traces() 48 | nwa.setup_measurement("S21") 49 | nwa.setup_take(averages_state=True) 50 | nwa.set_averages_and_group_count(avgs, True) 51 | 52 | 53 | nwa.set_power(-60, channel=1, port=3,state=0) 54 | 55 | print("Done") -------------------------------------------------------------------------------- /slab/instruments/awg/awgpulses2.py: -------------------------------------------------------------------------------- 1 | __author__ = 'dave' 2 | 3 | import numpy as np 4 | 5 | 6 | def sideband(t, i, q, freq=0, phase=0): 7 | return ( np.cos(2 * np.pi * (freq/1.0e9 * t )) * i - np.cos(2 * np.pi * (freq/1.0e9 * t)) * q, 8 | np.cos(2 * np.pi * (freq/1.0e9 * t )+ phase*np.pi/180.0) * i + np.cos(2 * np.pi * (freq/1.0e9 * t ) + phase*np.pi/180.0) * q) 9 | 10 | 11 | def gauss(t, a, t0, sigma): 12 | if sigma >0: 13 | return a * np.exp(-1.0 * (t - t0) ** 2 / (2 * sigma ** 2)) 14 | else: 15 | return 0*(t-t0) 16 | 17 | 18 | def dgauss(t, a, t0, sigma): 19 | return a * np.exp(-1.0 * (t - t0) ** 2 / (2 * sigma ** 2)) * (t - t0) / sigma ** 2 20 | 21 | 22 | def ramp(t, a, t0, w): 23 | return a * (t - t0) * (t >= t0) * (t < t0 + w) 24 | 25 | 26 | def square(t, a, t0, w, sigma=0): 27 | if sigma>0: 28 | return a * ( 29 | (t >= t0) * (t < t0 + w) + # Normal square pulse 30 | (t < t0) * np.exp(-(t - t0) ** 2 / (2 * sigma ** 2)) + # leading gaussian edge 31 | (t >= t0 + w) * np.exp(-(t - (t0 + w)) ** 2 / (2 * sigma ** 2)) # trailing edge 32 | ) 33 | else: 34 | return a * (t >= t0) * (t < t0 + w) 35 | 36 | 37 | def trapezoid(t, a, t0, w, edge_time=0): 38 | return a * ( 39 | (t - t0) * (t >= t0) * (t < t0 + edge_time) + (t >= t0 + edge_time) * (t < t0 + edge_time + w) + ( 40 | t0 - t) * ( 41 | t >= t0 + w + edge_time) * ( 42 | t >= t0 + w + 2 * edge_time) ) 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /slab/instruments/DigitalAttenuator.py: -------------------------------------------------------------------------------- 1 | __author__ = 'dave' 2 | 3 | from slab.instruments import SerialInstrument 4 | from math import floor 5 | import time 6 | 7 | 8 | class DigitalAttenuator(SerialInstrument): 9 | 10 | 11 | """This is a driver for the Arduino Uno based digital attenuator 12 | It is based on a HITITE HMC424 digital attenuator. It also uses a custom board to invert the 13 | arduino logic. 14 | """ 15 | 16 | 17 | def __init__(self, name="", address='COM6', enabled=True, timeout=0): 18 | """Note when initialized the attenuator board will reset to -31.5dB""" 19 | SerialInstrument.__init__(self, name, address, enabled, timeout, query_sleep=0.1) 20 | self.term_char = '\n' 21 | 22 | 23 | def get_id(self): 24 | """Gets the id string of the instrument""" 25 | self.ser.flushInput() 26 | self.id = self.query('I') 27 | self.id = self.query('I') 28 | return self.id 29 | 30 | 31 | def set_attenuator(self, atten): 32 | """Sets the attenuation from -31.5 to 0dB 33 | can be set in 0.5 dB increments, if not multiple of 0.5 it rounds up 34 | ignores the sign of the attenuation""" 35 | val = floor(abs(atten) / 0.5) 36 | self.write('S%d' % val) 37 | 38 | 39 | def get_attenuator(self): 40 | """Returns current attenuation setting of the digital attenuator in dB""" 41 | self.ser.flushInput() 42 | val = float(self.query('G')) 43 | return -val * 0.5 44 | 45 | -------------------------------------------------------------------------------- /slab/instruments/LakeshoreResistanceBridge.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | Lakeshore 370 AC Resistance Bridge LakeshoreResistanceBridge 4 | ==================================== 5 | :Author: David Schuster 6 | """ 7 | from slab.instruments import SerialInstrument,VisaInstrument 8 | import re 9 | import time 10 | 11 | class LakeshoreResistanceBridge(SerialInstrument,VisaInstrument): 12 | 13 | def __init__(self,name="Lakeshore",address='COM4',enabled=True,timeout=1): 14 | #if ':' not in address: address+=':22518' 15 | if address[:3].upper()=='COM': 16 | SerialInstrument.__init__(self,name,address,enabled,timeout) 17 | else: 18 | VisaInstrument.__init__(self,name,address,enabled, term_chars='\r') 19 | self.query_sleep=0.05 20 | self.recv_length=65536 21 | self.term_char='\r' 22 | 23 | def read(self): 24 | if self.protocol == 'serial': 25 | return SerialInstrument.read(self) 26 | if self.protocol == 'VISA': 27 | return VisaInstrument.read(self) 28 | 29 | def write(self, s): 30 | if self.protocol == 'serial': 31 | SerialInstrument.write(self, s) 32 | if self.protocol == 'VISA': 33 | VisaInstrument.write(self, s) 34 | 35 | def __del__(self): 36 | return 37 | if self.protocol == 'serial': 38 | SerialInstrument.__del__(self) 39 | if self.protocol == 'VISA': 40 | VisaInstrument.__del__(self) 41 | 42 | def get_id(self): 43 | return self.query('V') -------------------------------------------------------------------------------- /slab/plotting/Server_ui.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | # Form implementation generated from reading ui file 'Server.ui' 4 | # 5 | # Created: Wed Sep 28 16:53:52 2011 6 | # by: PyQt4 UI code generator 4.5.4 7 | # 8 | # WARNING! All changes made in this file will be lost! 9 | 10 | from PyQt4 import QtCore, QtGui 11 | 12 | class Ui_ServerWindow(object): 13 | def setupUi(self, ServerWindow): 14 | ServerWindow.setObjectName("ServerWindow") 15 | ServerWindow.resize(443, 371) 16 | self.centralwidget = QtGui.QWidget(ServerWindow) 17 | self.centralwidget.setObjectName("centralwidget") 18 | self.curvewidget = CurveWidget(self.centralwidget) 19 | self.curvewidget.setGeometry(QtCore.QRect(30, 10, 400, 300)) 20 | self.curvewidget.setOrientation(QtCore.Qt.Horizontal) 21 | self.curvewidget.setObjectName("curvewidget") 22 | ServerWindow.setCentralWidget(self.centralwidget) 23 | self.menubar = QtGui.QMenuBar(ServerWindow) 24 | self.menubar.setGeometry(QtCore.QRect(0, 0, 443, 22)) 25 | self.menubar.setObjectName("menubar") 26 | ServerWindow.setMenuBar(self.menubar) 27 | self.statusbar = QtGui.QStatusBar(ServerWindow) 28 | self.statusbar.setObjectName("statusbar") 29 | ServerWindow.setStatusBar(self.statusbar) 30 | 31 | self.retranslateUi(ServerWindow) 32 | QtCore.QMetaObject.connectSlotsByName(ServerWindow) 33 | 34 | def retranslateUi(self, ServerWindow): 35 | ServerWindow.setWindowTitle(QtGui.QApplication.translate("ServerWindow", "MainWindow", None, QtGui.QApplication.UnicodeUTF8)) 36 | 37 | from guiqwt.plot import CurveWidget 38 | -------------------------------------------------------------------------------- /slab/instruments/qiskit/job.py: -------------------------------------------------------------------------------- 1 | """ 2 | job.py 3 | """ 4 | 5 | import json 6 | import requests 7 | import time 8 | 9 | from qiskit.providers.job import JobV1 as Job 10 | from qiskit.providers.jobstatus import JobStatus, JOB_FINAL_STATES 11 | from qiskit.result import Result 12 | 13 | from .json_util import PulseEncoder 14 | 15 | class SLabJob(Job): 16 | def __init__(self, backend, job_id, qobj_id, **kwargs): 17 | super().__init__(backend, job_id, **kwargs) 18 | bc = self._backend.configuration() 19 | self._backend_name = bc.backend_name 20 | self._backend_version = bc.backend_version 21 | self._status = JobStatus.INITIALIZING 22 | self._qobj_id = qobj_id 23 | self._results = list() 24 | #ENDDEF 25 | 26 | def submit(self): 27 | raise NotImplementedError("job.submit() is not supported. Please use " 28 | "SLabBackendInterface.run() to submit a job.") 29 | #ENDDEF 30 | 31 | def result(self): 32 | # post to /job-retrieve 33 | out_dict = { 34 | "job_id": self._job_id 35 | } 36 | out_payload = json.dumps(out_dict, cls=PulseEncoder) 37 | headers = {"Content-Type": "application/json"} 38 | res = requests.post(self._backend.job_retrieve_url, headers=headers, data=out_payload) 39 | 40 | # get result 41 | res.raise_for_status() 42 | in_dict = res.json() 43 | result_ = Result.from_dict(in_dict) 44 | self._status = JobStatus(result_.status) 45 | 46 | return result_ 47 | #ENDDEF 48 | 49 | def status(self): 50 | self.result() 51 | return self._status 52 | #ENDDEF 53 | #ENDCLASS 54 | -------------------------------------------------------------------------------- /slab/scripts/launcher/launcher.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | Created on Mon Jan 28 17:33:23 2013 4 | 5 | @author: slab 6 | """ 7 | 8 | from PyQt4 import QtGui, QtCore 9 | from subprocess import Popen 10 | import os 11 | 12 | slab_dir = r'C:\_Lib\slab' 13 | 14 | 15 | def python_cmd(relpath): 16 | return ['pythonw', os.path.join(slab_dir, relpath)] 17 | 18 | 19 | def select_dir(): 20 | dir = str(QtGui.QFileDialog().getExistingDirectory()) 21 | os.chdir(dir) 22 | return [] 23 | 24 | scripts = { 25 | 'HDF Viewer' : python_cmd(r'plotting\hdfiview.py'), 26 | 'Script Plotter' : python_cmd(r'plotting\script_viewer.py'), 27 | 'LivePlot' : python_cmd(r'..\liveplot\window.py'), 28 | 'NWA Viewer' : python_cmd(r'scripts\NWAWindow.pyw'), 29 | 'Instrument Manager' : python_cmd(r'instruments\instrumentmanager.py') + ['-g'], 30 | 'File Server' : python_cmd('datamanagement.py'), 31 | 'IPython Notebook' : lambda: select_dir() + ['ipython', 'notebook', '--pylab', 'inline', '--ip=*'] 32 | } 33 | 34 | 35 | def create_popen_fn(args): 36 | env = os.environ 37 | env.update({'PYTHONPATH':r'C:\_Lib'}) 38 | fn_type = type(lambda: 1) 39 | if isinstance(args, fn_type): 40 | return lambda: Popen(args(), env=env) 41 | return lambda: Popen(args, env=env) 42 | 43 | if __name__ == "__main__": 44 | app = QtGui.QApplication([]) 45 | win = QtGui.QMainWindow() 46 | widget = QtGui.QWidget() 47 | layout = QtGui.QVBoxLayout(widget) 48 | for name, args in list(scripts.items()): 49 | button = QtGui.QPushButton(name) 50 | button.clicked.connect(create_popen_fn(args)) 51 | layout.addWidget(button) 52 | win.setCentralWidget(widget) 53 | win.show() 54 | app.exec_() -------------------------------------------------------------------------------- /slab/instruments/cryocon.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | Created on Wed Sep 03 02:46:30 2014 4 | 5 | @author: Phil 6 | """ 7 | 8 | from slab.instruments import SocketInstrument 9 | 10 | class Cryocon(SocketInstrument): 11 | default_port = 5000 12 | 13 | def __init__(self, name="Cryocon", address=None, enabled=True): 14 | SocketInstrument.__init__(self, name, address, enabled=enabled, timeout=1, recv_length=2 ** 20) 15 | self.query_sleep = 0.05 16 | self.socket.setblocking(1) 17 | 18 | def get_id(self): 19 | return "Cryocon 18I" 20 | 21 | def get_temp(self,ch='A'): 22 | try: 23 | return float(self.query('INPUT? '+ch.upper())) 24 | except: 25 | return 0 26 | 27 | def set_sensor_type(self,ch,sensor_type=0): 28 | self.write("INPUT %s:SENSOR %d" %(ch,sensor_type) ) 29 | 30 | 31 | ##### Manage internal data logging features 32 | def reset_log(self): 33 | self.write('DLOG:RESET') 34 | 35 | def clear_log(self): 36 | self.write('DLOG:CLEAR') 37 | 38 | def set_logging(self,state): 39 | if state: 40 | self.write('DLOG:RUN ON') 41 | else: 42 | self.write('DLOG:RUN OFF') 43 | 44 | def get_log(self): 45 | s = self.query("DLOG:READ?") 46 | 47 | dates=[] 48 | times=[] 49 | temps=[] 50 | for line in s: 51 | sl = line.split(',') 52 | dates.append(sl[0]) 53 | times.append(sl[1]) 54 | temps.append(sl[2:]) 55 | return (dates,times,temps) 56 | 57 | if __name__=="__main__": 58 | c=Cryocon(address='192.168.14.165:5000') 59 | print(c.get_id()) 60 | print(c.get_temp('A')) 61 | 62 | -------------------------------------------------------------------------------- /slab/instruments/RedPitaya/PyRedPitaya/memory.py: -------------------------------------------------------------------------------- 1 | import sys 2 | import ctypes 3 | from ctypes import * 4 | import numpy as np 5 | 6 | class MemoryInterface(object): 7 | def __init__(self, addr_base=0x00000000, parent_memory=None): 8 | self.addr_base = addr_base 9 | self._parent = parent_memory 10 | 11 | def read(self, addr): 12 | """Read one register """ 13 | return self._parent.read(self.addr_base+addr) 14 | 15 | def reads(self, addr, length): 16 | return self._parent.reads(self.addr_base+addr, length) 17 | 18 | def write(self, addr, value): 19 | """Write one register """ 20 | self._parent.write(self.addr_base+addr, value) 21 | 22 | def writes(self, addr, value): 23 | self._parent.writes(self.addr_base+addr, value) 24 | 25 | def setbit(self,addr,bitnumber): 26 | v = self.read(addr)|(0x00000001<> (bitlength-1): 47 | v = v - 2**bitlength 48 | return int(v) 49 | 50 | def from_pyint(self,v,bitlength=14): 51 | if v < 0: 52 | v = v + 2**bitlength 53 | v= (v & (2**bitlength-1)) 54 | return int(v) 55 | 56 | 57 | 58 | -------------------------------------------------------------------------------- /slab/instruments/AD5780DAC/AD5780DACServer/AD5780.h: -------------------------------------------------------------------------------- 1 | /* AD5780.h 2 | * Created by Larry Chen 3 | */ 4 | 5 | #ifndef AD5780_h 6 | #define AD5780_h 7 | 8 | #include 9 | #include 10 | 11 | /* Read and write bits */ 12 | #define READ 0x8 13 | #define WRITE 0x0 14 | 15 | /* Register codes */ 16 | #define DAC 0x1 17 | #define CTRL 0x2 18 | #define CLR 0x3 19 | #define SCTRL 0x4 20 | 21 | #define INIT_CODE0 BITCODE(((WRITE|CTRL)<<4),0x0,0x16) //Clamps output to GND 22 | #define INIT_CODE BITCODE(((WRITE|CTRL)<<4),0x0,0x12) 23 | /* Given a value to write to the DAC register (0-262143), constructs the 24 bit code to send to the device */ 24 | #define DAC_CODE(val) ((((long)(WRITE|DAC)<<20)&0xF00000)|DAC_TO_BITCODE(val)) 25 | 26 | 27 | /* These macros return the first, second, and third bytes of a 24 bit code */ 28 | #define BYTE1(b) (byte)((b>>16)&0xFF) 29 | #define BYTE2(b) (byte)((b>>8)&0xFF) 30 | #define BYTE3(b) (byte)((b&0xFF)) 31 | 32 | 33 | /* Concatenates three bytes into one 24 bit code*/ 34 | #define BITCODE(b1, b2, b3) ((((long)b1<<16)|((long)b2<<8)|(long)b3)&0xFFFFFF) 35 | /* Given a 24 bit code, returns the value read from or written to the DAC register (0-262143)*/ 36 | #define BITCODE_TO_DAC(b) ((b>>2)&0x3FFFF) 37 | #define DAC_TO_BITCODE(d) ((long)(d<<2)&0xFFFFC) 38 | 39 | 40 | class AD5780 41 | { 42 | public: 43 | AD5780(int sync); 44 | void initialize_DAC(); 45 | 46 | long set_value(long bitcode); 47 | void set_gcurrval(long input); 48 | void ramp(long bitcode, long step_size, int delta_t); 49 | long read_CTRL_register(); 50 | long read_DAC_register(); 51 | long read_CLR_register(); 52 | long read_SCTRL_register(); 53 | private: 54 | int _sync; 55 | long _dac_reg; 56 | long currval; 57 | long gcurrval = 131072; 58 | 59 | }; 60 | 61 | #endif 62 | -------------------------------------------------------------------------------- /slab/instruments/RedPitaya/PyRedPitaya/raw_memory.py: -------------------------------------------------------------------------------- 1 | import sys 2 | import ctypes 3 | from ctypes import * 4 | import numpy as np 5 | from time import time 6 | 7 | if 'PyRedPitayaTest' in list(sys.modules.keys()): 8 | from PyRedPitayaTest import libmonitor_file 9 | else: 10 | libmonitor_file = 'libmonitor.so' 11 | 12 | libmonitor = ctypes.cdll.LoadLibrary(libmonitor_file) 13 | libmonitor.read_value.restype = c_uint32 14 | 15 | #TODO 16 | #Specify output types of read_value to uint32 17 | 18 | class BoardRawMemory(object): 19 | """ Classes uses to interface de RedPitaya memory 20 | 21 | This is a one to one match to the libmonitor.so library""" 22 | a = libmonitor 23 | 24 | def read(self, addr): 25 | """ Read one word in the memory """ 26 | return self.a.read_value(addr) 27 | 28 | def reads(self, addr, length, return_buffer=False): 29 | """ Read length words in the memory 30 | 31 | output : either an array on uint32 or a string buffer""" 32 | # t0 = time() 33 | buf = create_string_buffer(sizeof(ctypes.c_uint32)*length) 34 | self.a.read_values(addr,cast(buf, POINTER(ctypes.c_uint32)),length) 35 | # print "Time :",time()-t0 36 | if return_buffer: 37 | return buf.raw 38 | else: 39 | return np.frombuffer(buf.raw, dtype='uint32') 40 | 41 | def write(self, addr, value): 42 | """ Write one word in the memory """ 43 | self.a.write_value(addr, value) 44 | 45 | def writes(self, addr, values): 46 | """Write length words in memory 47 | 48 | input : values should be a list, np.array of numbers or a str (interpreted as a string buffer)""" 49 | if not isinstance(values, str): 50 | values = np.array(values, dtype='uint32') 51 | values = str(values.data) 52 | buf = create_string_buffer(values) 53 | self.a.write_values(addr, cast(buf, POINTER(ctypes.c_uint32)), len(values)//4) 54 | -------------------------------------------------------------------------------- /slab/experiments/Alex/Multimode/run_multimode_seq_experiment.py: -------------------------------------------------------------------------------- 1 | __author__ = 'Nelson' 2 | 3 | from slab.experiments.ExpLib.SequentialExperiment import * 4 | from slab.experiments.General.run_seq_experiment import * 5 | from slab import * 6 | import os 7 | import json 8 | 9 | 10 | datapath = os.getcwd() + '\data' 11 | config_file = os.path.join(datapath, "..\\config" + ".json") 12 | with open(config_file, 'r') as fid: 13 | cfg_str = fid.read() 14 | 15 | cfg = AttrDict(json.loads(cfg_str)) 16 | 17 | def get_data_filename(prefix): 18 | return os.path.join(datapath, get_next_filename(datapath, prefix, suffix='.h5')) 19 | 20 | 21 | def multimode_pulse_calibration(seq_exp, mode): 22 | pulse_calibration(seq_exp) 23 | seq_exp.run(('multimode_calibrate_offset',{'exp':'multimode_rabi','dc_offset_guess':0,'mode':mode,'update_config':True})) 24 | 25 | def multimode_pi_pi_phase_calibration(seq_exp,mode): 26 | seq_exp.run(('multimode_pi_pi_experiment',{'mode':mode,'update_config':True})) 27 | 28 | 29 | 30 | def run_multimode_seq_experiment(expt_name,lp_enable=True,**kwargs): 31 | seq_exp = SequentialExperiment(lp_enable) 32 | 33 | if expt_name.lower() == 'multimode_pulse_calibration': 34 | multimode_pulse_calibration(seq_exp,kwargs['mode']) 35 | 36 | if expt_name.lower() == 'multimode_pi_pi_phase_calibration': 37 | multimode_pi_pi_phase_calibration(seq_exp,kwargs['mode']) 38 | 39 | if expt_name.lower() == 'sequential_single_mode_rb': 40 | prefix = expt_name.lower() 41 | data_file = get_data_filename(prefix) 42 | 43 | with SlabFile(data_file) as f: 44 | f.append_pt('mode', kwargs['mode']) 45 | f.close() 46 | for i in arange(32): 47 | multimode_pulse_calibration(seq_exp,kwargs['mode']) 48 | multimode_pi_pi_phase_calibration(seq_exp,kwargs['mode']) 49 | seq_exp.run(('single_mode_rb',{'mode':kwargs['mode'],"data_file":data_file})) 50 | 51 | 52 | 53 | -------------------------------------------------------------------------------- /slab/experiments/Hafnium/Multimode/run_multimode_seq_experiment.py: -------------------------------------------------------------------------------- 1 | __author__ = 'Nelson' 2 | 3 | from slab.experiments.ExpLib.SequentialExperiment import * 4 | from slab.experiments.General.run_seq_experiment import * 5 | from slab import * 6 | import os 7 | import json 8 | 9 | 10 | datapath = os.getcwd() + '\data' 11 | config_file = os.path.join(datapath, "..\\config" + ".json") 12 | with open(config_file, 'r') as fid: 13 | cfg_str = fid.read() 14 | 15 | cfg = AttrDict(json.loads(cfg_str)) 16 | 17 | def get_data_filename(prefix): 18 | return os.path.join(datapath, get_next_filename(datapath, prefix, suffix='.h5')) 19 | 20 | 21 | def multimode_pulse_calibration(seq_exp, mode): 22 | pulse_calibration(seq_exp) 23 | seq_exp.run(('multimode_calibrate_offset',{'exp':'multimode_rabi','dc_offset_guess':0,'mode':mode,'update_config':True})) 24 | 25 | def multimode_pi_pi_phase_calibration(seq_exp,mode): 26 | seq_exp.run(('multimode_pi_pi_experiment',{'mode':mode,'update_config':True})) 27 | 28 | 29 | 30 | def run_multimode_seq_experiment(expt_name,lp_enable=True,**kwargs): 31 | seq_exp = SequentialExperiment(lp_enable) 32 | 33 | if expt_name.lower() == 'multimode_pulse_calibration': 34 | multimode_pulse_calibration(seq_exp,kwargs['mode']) 35 | 36 | if expt_name.lower() == 'multimode_pi_pi_phase_calibration': 37 | multimode_pi_pi_phase_calibration(seq_exp,kwargs['mode']) 38 | 39 | if expt_name.lower() == 'sequential_single_mode_rb': 40 | prefix = expt_name.lower() 41 | data_file = get_data_filename(prefix) 42 | 43 | with SlabFile(data_file) as f: 44 | f.append_pt('mode', kwargs['mode']) 45 | f.close() 46 | for i in arange(32): 47 | multimode_pulse_calibration(seq_exp,kwargs['mode']) 48 | multimode_pi_pi_phase_calibration(seq_exp,kwargs['mode']) 49 | seq_exp.run(('single_mode_rb',{'mode':kwargs['mode'],"data_file":data_file})) 50 | 51 | 52 | 53 | -------------------------------------------------------------------------------- /slab/instruments/geophone.py: -------------------------------------------------------------------------------- 1 | from scipy.interpolate import interp1d 2 | import numpy as np 3 | 4 | # Geophone calibration curve data 5 | 6 | def volts_to_velocity(frequency, volts): 7 | """ 8 | :param frequency: Frequency in Hz 9 | :param volts: Voltage at that particular frequency 10 | :return: Velocity in m/s estimated from data. 11 | """ 12 | 13 | # Data from the website. 1st column: Freq (Hz); 2nd column V/(in/s) 14 | data = np.array([[1.6, 0.11], 15 | [2.0, 0.19], 16 | [2.5, 0.30], 17 | [3.0, 0.50], 18 | [3.5, 0.72], 19 | [4.0, 1.00], 20 | [4.5, 1.20], 21 | [5.2, 1.32], 22 | [6.0, 1.20], 23 | [8.0, 1.04], 24 | [10.0, 0.95], 25 | [12.0, 0.91], 26 | [16.0, 0.87], 27 | [20.0, 0.85], 28 | [40.0, 0.82], 29 | [100, 0.81]]) 30 | 31 | interpolated_data = interp1d(data[:,0], data[:,1], kind='cubic') 32 | 33 | if len(frequency)>1 and len(frequency)==len(volts): 34 | velocity=[] 35 | for idx,F in enumerate(frequency): 36 | velocity.append(volts/interpolated_data(F)*25.4E-3) 37 | velocity = np.array(velocity) 38 | elif len(frequency)==len(volts): 39 | velocity = volts/interpolated_data(frequency)*25.4E-3 40 | 41 | return velocity 42 | 43 | 44 | def velocity_to_displacement(frequency, velocity): 45 | """ 46 | :param frequency: Frequency in Hz 47 | :param velocity: Velocity in m/s 48 | :return: Displacement in m 49 | """ 50 | displacement = velocity/(2*np.pi*frequency) 51 | return displacement 52 | 53 | def get_displacement(fpoints, volts): 54 | 55 | velocity = volts_to_velocity(fpoints, volts) 56 | displacement = velocity_to_displacement(fpoints, velocity) 57 | return displacement -------------------------------------------------------------------------------- /slab/instruments/qiskit/provider_interface.py: -------------------------------------------------------------------------------- 1 | """ 2 | provider_interface.py 3 | """ 4 | 5 | import requests 6 | 7 | from qiskit.providers import ProviderV1 as ProviderInterface 8 | 9 | from .backend_interface import SLabBackendInterface 10 | 11 | class SLabProviderInterface(ProviderInterface): 12 | """ 13 | Fetch a backend interface through this class. 14 | 15 | References: 16 | [0] https://github.com/Qiskit/qiskit-ibmq-provider/blob/master/ 17 | qiskit/providers/ibmq/accountprovider.py#L43 18 | """ 19 | backends_url_dict = { 20 | "RFSoC2": "http://192.168.14.184:8555", 21 | } 22 | 23 | def __init__(self, timeout=20): 24 | """ 25 | Args: 26 | timeout :: int - wait time in seconds for establishing 27 | contact with a potential backend 28 | """ 29 | super().__init__() 30 | self._backends = self._discover_backends(timeout) 31 | #ENDDEF 32 | 33 | def _discover_backends(self, timeout): 34 | """ 35 | Discover remote backends. 36 | """ 37 | backends = {} 38 | for key in self.backends_url_dict.keys(): 39 | url = self.backends_url_dict[key] 40 | # attempt HEAD request to backend 41 | try: 42 | res = requests.head(url) 43 | res.raise_for_status() 44 | success = True 45 | except Exception as e: 46 | print("Could not establish contact with backend {} at {}.\n{}" 47 | "".format(key, url, e)) 48 | success = False 49 | #ENDTRY 50 | # if HEAD succeeded, expose the backend 51 | if success: 52 | backend = SLabBackendInterface(self, url) 53 | backends[backend.name()] = backend 54 | #ENDIF 55 | #ENDFOR 56 | return backends 57 | #ENDDEF 58 | 59 | def backends(self, **kwargs): 60 | return self._backends 61 | #ENDDEF 62 | 63 | def get_backend(self, name): 64 | backend = self._backends.get(name, None) 65 | return backend 66 | #ENDDEF 67 | #ENDCLASS 68 | -------------------------------------------------------------------------------- /slab/scripts/eHe.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | Created on Sun Dec 02 22:58:15 2012 4 | 5 | @author: Dave 6 | """ 7 | 8 | from slab import * 9 | from slab.instruments import InstrumentManager 10 | from numpy import * 11 | import time,datetime 12 | from matplotlib.pyplot import show,plot 13 | 14 | class eHe: 15 | 16 | biasCh=1 17 | trapCh=2 18 | 19 | def __init__(self,expt_path=None,instrument_manager=None): 20 | if instrument_manager is None: 21 | instrument_manager=InstrumentManager() 22 | self.im=instrument_manager 23 | self.expt_path=expt_path 24 | 25 | self.filament=self.im['filament'] 26 | self.srs=self.im['SRS'] 27 | self.na=self.im['NWA'] 28 | self.fridge=self.im['FRIDGE'] 29 | 30 | def dump_electrons(self, biasDumpV,trapDumpV,wait_time=0): 31 | self.srs.set_volt(biasCh,biasDumpV) 32 | self.srs.set_volt(trapCh,trapDumpV) 33 | time.sleep(wait_time) 34 | 35 | def load_electrons(self,biasV,trapV,amplitude,offset,frequency,pulse_length): 36 | self.srs.set_volt(biasCh,biasV) 37 | self.srs.set_volt(trapCh,trapV) 38 | self.filament.setup_driver(amplitude,offset,frequency,pulse_length) 39 | 40 | def save_system_state(self,state): 41 | na.clear_averages() 42 | na.trigger_single() 43 | temperature=fridge.get_mc_temperature() 44 | 45 | # #tic() 46 | # biasV=srs.get_volt(channel=BiasCh) 47 | # trapV=srs.get_volt(channel=TrapCh) 48 | # #print "SRS: ", toc() 49 | # 50 | # #tic() 51 | # temperature=fridge.get_mc_temperature() 52 | # #print "Fridge: ", toc() 53 | 54 | state={'tpts':t,'biasV':biasV,'trapV':trapV,'temperature':temperature} 55 | fname= "%04d_%.3f_%s_%4f_%4f_%4f.csv" % (count,t,prefix, 56 | biasV,trapV,temperature) 57 | 58 | na.averaging_complete() 59 | #na.set_format('slog') 60 | if fname is not None: 61 | na.save_file(os.path.join(datapath,fname)) 62 | data=na.read_data() 63 | 64 | #data=take_one(na,os.path.join(datapath,fname)) 65 | addpt(datapath,prefix,data,state) 66 | time.sleep(delay) -------------------------------------------------------------------------------- /slab/instruments/pulseblaster/pulseblaster_test.py: -------------------------------------------------------------------------------- 1 | __author__ = 'Nelson' 2 | 3 | from .spinapi import * 4 | 5 | # Enable the log file 6 | pb_set_debug(1) 7 | 8 | print(("Using SpinAPI Library version %s" % pb_get_version())) 9 | print(("Found %d boards in the system.\n" % pb_count_boards())) 10 | 11 | pb_select_board(0) 12 | 13 | if pb_init() != 0: 14 | print(("Error initializing board: %s" % pb_get_error())) 15 | exit() 16 | 17 | # time settings 18 | unit_inst_time = 10 # ns 19 | exp_period = 200*1000 # 100us 20 | 21 | awg_trig_time = 0 22 | awg_trig_len = 100 23 | 24 | card_trig_time = 2000 25 | card_trig_len = 100 26 | 27 | readout_trig_time = card_trig_time 28 | readout_trig_len = 1000 # has to be longer than card_trig_len 29 | 30 | 31 | # calculated time value 32 | awg_trig_delay_loop = awg_trig_len/unit_inst_time 33 | card_and_readout_trig_delay_loop = card_trig_len/unit_inst_time 34 | readout_trig_delay_loop = (readout_trig_len-card_trig_len)/unit_inst_time 35 | 36 | awg_card_idle_time = card_trig_time - (awg_trig_time + awg_trig_len) 37 | awg_card_idle_delay_loop = awg_card_idle_time/unit_inst_time 38 | 39 | total_time = readout_trig_time + readout_trig_len 40 | period_idle_time = exp_period - total_time 41 | 42 | # delay loop 43 | delay_loop = 20 44 | 45 | # ports hex value 46 | idle = 0x0 47 | awg_trig = 0x1 48 | card_trig = 0x2 49 | readout_trig = 0x4 50 | drive_trig = 0x8 51 | 52 | # Configure the core clock 53 | pb_core_clock(500.0) 54 | 55 | 56 | 57 | # Program the pulse program 58 | pb_start_programming(PULSE_PROGRAM) 59 | 60 | # awg trigger 61 | start = pb_inst_pbonly64(awg_trig, Inst.LONG_DELAY,awg_trig_delay_loop,unit_inst_time) 62 | 63 | # idle between end of awg trig and card trig 64 | pb_inst_pbonly64(idle, Inst.LONG_DELAY, awg_card_idle_delay_loop, unit_inst_time) 65 | 66 | # card and readout trig starts at the same time 67 | pb_inst_pbonly64(card_trig+readout_trig, Inst.LONG_DELAY,card_and_readout_trig_delay_loop,unit_inst_time) 68 | 69 | # readout trig after card trig (assume readout trig is longer) 70 | pb_inst_pbonly64(readout_trig, Inst.LONG_DELAY,readout_trig_delay_loop,unit_inst_time) 71 | 72 | # branch to start; Outputs are off 73 | pb_inst_pbonly64(idle, Inst.BRANCH, start, period_idle_time) 74 | 75 | pb_stop_programming() 76 | 77 | # Trigger the board 78 | pb_reset() 79 | pb_start() 80 | 81 | pb_close() -------------------------------------------------------------------------------- /slab/experiments/HVIExperiments/DataHandlerHelper/DataHandlerHelper.h: -------------------------------------------------------------------------------- 1 | /* DataHandlerHelper.h. 2 | Created by Josie Meyer, 9/2018 */ 3 | 4 | #ifndef DataHandlerHelper_h 5 | #define DataHandlerHelper_h 6 | 7 | #include "Python.h" 8 | 9 | #include 10 | #include "SD_AIN.h" 11 | #include 12 | #include 13 | #include 14 | #include 15 | 16 | 17 | /* Used to build a fast, thread-safe and reentrant-safe queue */ 18 | typedef struct queue_struct { 19 | volatile short** data; /*Holds the actual data */ 20 | int num_trials; /* Number of trials */ 21 | int points_per_trial; /* Number of data points per trial */ 22 | volatile int last_claimed; /* The last slot claimed. Should be initialized to -1. */ 23 | volatile bool* ready_to_read; /* Indicates which data can be read */ 24 | 25 | volatile int* queue_positions; 26 | /* Index is the number of the queue in question. Value is the position of reader. */ 27 | 28 | int module_ID; /* The module_ID of the module associated with the queue */ 29 | int channel_number; /* The channel number */ 30 | } Queue; 31 | 32 | typedef struct HashBucket_struct { /* Used to make hash table */ 33 | Queue** entries; 34 | int num_filled; 35 | int capacity; 36 | } HashBucket; 37 | 38 | //Function prototypes 39 | static PyObject* DataHandlerHelper_configureBufferPool(PyObject * self, PyObject * args); 40 | static int put(short* new_data, Queue* queue); 41 | static int get(Queue* queue, int identifier, int num_tries, volatile short* data); 42 | static int addBuffer(int module_ID, int channel_number, int num_points); 43 | static unsigned int hashCode(int module_ID, int channel_number); 44 | static int initialSetup(); 45 | static int createQueue(int num_trials, int points_per_trial, int module_ID, int channel_number, Queue* queue); 46 | static int addToHashTable(Queue* queue); 47 | static int getFromHashTable(int module_ID, int channel_number, Queue* queue); 48 | static PyObject* DataHandlerHelper_getData(PyObject* self, PyObject* args); 49 | static PyObject* DataHandlerHelper_cleanup(PyObject* self, PyObject* args); 50 | static int freeQueue(Queue* queue); 51 | void callback(void* SDobject, int eventNumber, void* buffer, int numData, void* buffer2, int numData2, void *userObject, 52 | int status); 53 | 54 | #endif /* DataHandlerHelper_h */ 55 | 56 | -------------------------------------------------------------------------------- /slab/instruments/spec_analyzer/min_pwr.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | Created on Thu Aug 18 14:53:45 2011 4 | 5 | @author: Dai 6 | """ 7 | from numpy import * 8 | from guiqwt.pyplot import * 9 | 10 | from .spectrum_analyzer import * 11 | from rfgenerators import * 12 | import pickle 13 | import time 14 | 15 | rf=E8257D(address='rfgen1.circuitqed.com') 16 | lo=E8257D(address='rfgen2.circuitqed.com') 17 | 18 | sa = SpectrumAnalyzer(address='128.135.35.167') 19 | 20 | frequencies = [x*1e8 for x in range(50, 100, 1)] 21 | #additional frequencies to sample 22 | #frequencies.append(6.65e9) 23 | #frequencies.append(6.75e9) 24 | #frequencies.append(7.65e9) 25 | 26 | minPower = [] 27 | 28 | lo.set_power(sa.lo_power+3) 29 | 30 | for frequency in frequencies: 31 | measured_powers=[] 32 | lo.set_output(False) 33 | rf.set_output(False) 34 | 35 | rf.set_frequency(frequency) 36 | 37 | lo.set_frequency(frequency+sa.lo_offset) 38 | lo.set_power(10) 39 | lo.set_output(True) 40 | 41 | print("RF Frequency: "+str(frequency)) 42 | 43 | lp = -80 44 | rp = 10 45 | while (rp - lp > 1): 46 | rf.set_power((lp+rp)/2) 47 | rf.set_output(True) 48 | time.sleep(0.2) 49 | m = sa.get_power() 50 | rf.set_output(False) 51 | if (m > 50.0): 52 | rp = (lp + rp) / 2 53 | else: 54 | lp = (lp + rp) / 2 55 | minPower.append([frequency, (lp+rp)/2]) 56 | print((frequency, (lp+rp)/2)) 57 | 58 | lo.set_output(False) 59 | rf.set_output(False) 60 | 61 | pickle.dump(minPower, open(str(int(lo.get_power()))+'dBm_min_pwr.data', 'w')) 62 | 63 | figure(0) 64 | mpp = [] 65 | for mp in minPower: 66 | mpp.append(mp[1]) 67 | mpp = array(mpp) 68 | plot(frequencies, array(mpp), 'b+') 69 | title('Minimal Detectable Power v. RF Frequency') 70 | xlabel('RF Frequency (Hz)') 71 | ylabel('Minimal Detectable Power (dBm)') 72 | show() 73 | 74 | """ 75 | for power in powers: 76 | rf.set_power(power) 77 | rf.set_output(True) 78 | mpow=sa.get_avg_power() 79 | print "Power: %f, measured: %f " % (power,mpow) 80 | measured_powers.append(mpow) 81 | if (mpow > 50.0) and not found: 82 | minPower.append((frequency, power)) 83 | found = True 84 | 85 | measured_powers=array(measured_powers) 86 | figure(i) 87 | plot(powers,measured_powers) 88 | title('RF Frequency %f' % frequency) 89 | xlabel("RF Power") 90 | ylabel("Spec Analyzer Output") 91 | """ -------------------------------------------------------------------------------- /slab/experiments/Hafnium/ExpLib/seq_expt_new.py: -------------------------------------------------------------------------------- 1 | __author__ = 'Nelson' 2 | 3 | from slab.experiments.General.run_experiment import * 4 | from slab.experiments.Multimode.run_multimode_experiment import * 5 | import numbers 6 | from slab import * 7 | import json 8 | 9 | import gc 10 | 11 | def update_dict(d, u): 12 | for k, v in u.items(): 13 | if isinstance(v, collections.Mapping): 14 | r = update_dict(d.get(k, {}), v) 15 | d[k] = r 16 | else: 17 | d[k] = u[k] 18 | return d 19 | 20 | class SequentialExperiment(): 21 | def __init__(self, lp_enable = True): 22 | self.expt = None 23 | self.lp_enable = lp_enable 24 | # config_file = 'config.json' 25 | # datapath = os.getcwd() 26 | 27 | def run(self,expt_name,vary_dict={}, expt_kwargs = {}): 28 | 29 | 30 | 31 | if self.expt is not None: 32 | del self.expt 33 | gc.collect() 34 | 35 | datapath = os.getcwd() + '\data' 36 | config_file = os.path.join(datapath, "..\\config" + ".json") 37 | with open(config_file, 'r') as fid: 38 | cfg_str = fid.read() 39 | cfg_dict = json.loads(cfg_str) 40 | 41 | cfg_dict_temp = update_dict(cfg_dict, vary_dict) 42 | with open('config_temp.json', 'w') as fp: 43 | json.dump(cfg_dict_temp, fp) 44 | 45 | ## automatically save kwargs to data_file 46 | if 'data_file' in expt_kwargs: 47 | data_file = expt_kwargs['data_file'] 48 | for key in expt_kwargs: 49 | if isinstance(expt_kwargs[key],numbers.Number) and not key == 'update_config': 50 | with SlabFile(data_file) as f: 51 | f.append_pt(key, float(expt_kwargs[key])) 52 | f.close() 53 | 54 | if 'seq_pre_run' in expt_kwargs: 55 | expt_kwargs['seq_pre_run'](self) 56 | 57 | self.expt = run_experiment(expt_name,self.lp_enable,config_file = '..\\config_temp.json',**expt_kwargs) 58 | if self.expt is None: 59 | self.expt = run_multimode_experiment(expt_name,self.lp_enable,**expt_kwargs) 60 | 61 | if 'seq_post_run' in expt_kwargs: 62 | expt_kwargs['seq_post_run'](self) 63 | 64 | if 'update_config' in expt_kwargs: 65 | if expt_kwargs['update_config']: 66 | self.save_config() 67 | 68 | 69 | 70 | def save_config(self): 71 | self.expt.save_config() 72 | print("config saved!") 73 | 74 | 75 | 76 | 77 | 78 | -------------------------------------------------------------------------------- /slab/experiments/Nitrogen/ExpLib/PulseSequenceGroup.py: -------------------------------------------------------------------------------- 1 | __author__ = 'Nitrogen' 2 | 3 | def cphase(psb,control_id ,minus_Z_id): 4 | psb.append('q,mm'+str(control_id),'pi_ge') 5 | psb.append('q,mm'+str(minus_Z_id),'2pi_ef') 6 | psb.append('q,mm'+str(control_id),'pi_ge') 7 | 8 | 9 | def cphase_v1(psb,control_id ,minus_Z_id,cz_phase=0): 10 | if not control_id == "q": 11 | psb.append('q,mm'+str(control_id),'pi_ge') 12 | psb.append('q,mm'+str(minus_Z_id),'pi_ef') 13 | psb.append('q,mm'+str(minus_Z_id),'pi_ef', phase=cz_phase) 14 | 15 | if not control_id == "q": 16 | psb.append('q,mm'+str(control_id),'pi_ge') 17 | 18 | 19 | def cphase_v2(psb,control_id ,minus_Z_id,cz_phase1=0,cz_phase2=0): 20 | if not control_id == "q": 21 | psb.append('q,mm'+str(control_id),'pi_ge') 22 | psb.append('q,mm'+str(minus_Z_id),'pi_ef') 23 | psb.append('q,mm'+str(minus_Z_id),'pi_ef', phase=cz_phase1) 24 | 25 | if not control_id == "q": 26 | psb.append('q,mm'+str(control_id),'pi_ge') 27 | 28 | 29 | #### Final CZ gate 30 | def cphase_v3(psb,control_id ,minus_Z_id, efsbphase_0=0,efsbphase_1=0,gesbphase1=0,add_freq=0,efsbphase_2=0): 31 | # pass 32 | if not control_id == "q": 33 | psb.append('q,mm'+str(control_id),'pi_ge', phase = -gesbphase1,add_freq=add_freq) 34 | psb.append('q,mm'+str(minus_Z_id),'pi_ef',phase= efsbphase_0 ) 35 | psb.append('q,mm'+str(minus_Z_id),'pi_ef',phase = efsbphase_2) 36 | if not control_id == "q": 37 | psb.append('q,mm'+str(control_id),'pi_ge',phase=efsbphase_1 + gesbphase1,add_freq=add_freq) 38 | 39 | 40 | 41 | def cnot_v1(psb,control_id ,minus_Z_id, cnot_phase=0,cnot_dc_phase=0): 42 | if not control_id == "q": 43 | psb.append('q,mm'+str(control_id),'pi_ge') 44 | psb.append('q,mm'+str(minus_Z_id),'pi_ef') 45 | psb.append('q','pi_q_ef', phase=cnot_phase) 46 | psb.append('q,mm'+str(minus_Z_id),'pi_ef') 47 | 48 | if not control_id == "q": 49 | psb.append('q,mm'+str(control_id),'pi_ge',phase=cnot_dc_phase) 50 | 51 | 52 | #### Final CNOT gate 53 | def cnot_v2(psb,control_id ,minus_Z_id, cnot_phase=0,efsbphase_0=0,efsbphase_1=0,gesbphase1=0,efsbphase_2=0): 54 | if not control_id == "q": 55 | psb.append('q,mm'+str(control_id),'pi_ge', phase = -gesbphase1) 56 | psb.append('q,mm'+str(minus_Z_id),'pi_ef',phase= efsbphase_0 ) 57 | psb.append('q','pi_q_ef', phase=cnot_phase) 58 | psb.append('q,mm'+str(minus_Z_id),'pi_ef',phase=efsbphase_2) 59 | 60 | if not control_id == "q": 61 | psb.append('q,mm'+str(control_id),'pi_ge',phase=efsbphase_1 + gesbphase1) 62 | 63 | -------------------------------------------------------------------------------- /slab/instruments/dymo.py: -------------------------------------------------------------------------------- 1 | import usb.core 2 | import usb.util 3 | 4 | from slab.instruments import Instrument 5 | 6 | VENDOR_ID = 0x0922 7 | PRODUCT_ID = 0x8009 8 | 9 | class Dymo(Instrument): 10 | 11 | def __init__(self,name='Dymo', address='', enabled=True ): 12 | Instrument.__init__(self,name,address,enabled) 13 | dev = usb.core.find(idVendor=VENDOR_ID, idProduct=PRODUCT_ID) 14 | 15 | 16 | interface = 0 17 | if dev.is_kernel_driver_active(interface) is True: 18 | #print "but we need to detach kernel driver" 19 | dev.detach_kernel_driver(interface) 20 | 21 | # use the first/default configuration 22 | dev.set_configuration() 23 | #print "claiming device" 24 | usb.util.claim_interface(dev, interface) 25 | self.dev=dev 26 | 27 | def get_id(self): 28 | devmanufacturer = usb.util.get_string(self.dev, 256, 1) 29 | devname = usb.util.get_string(self.dev, 256, 2) 30 | return devmanufacturer + " " + devname 31 | 32 | def twos_comp(self,val, bits): 33 | """compute the 2's compliment of int value val""" 34 | if (val & (1 << (bits - 1))) != 0: # if sign bit is set e.g., 8bit: 128-255 35 | val = val - (1 << bits) # compute negative value 36 | return val 37 | 38 | def get_weight(self): 39 | 40 | try: 41 | # first endpoint 42 | endpoint = self.dev[0][(0,0)][0] 43 | 44 | # read a data packet 45 | attempts = 10 46 | data = None 47 | while data is None and attempts > 0: 48 | try: 49 | data = self.dev.read(endpoint.bEndpointAddress,endpoint.wMaxPacketSize) 50 | except usb.core.USBError as e: 51 | data = None 52 | if e.args == ('Operation timed out',): 53 | attempts -= 1 54 | print("timed out... trying again") 55 | continue 56 | scaling_factor=10.0**self.twos_comp(data[3],8) 57 | if data[2] == 12: 58 | lbs_factor = 0.453592 59 | else: 60 | lbs_factor = 1 61 | raw_weight=(data[4] + data[5] * 256)*scaling_factor 62 | return raw_weight*lbs_factor 63 | except usb.core.USBError as e: 64 | print("USBError: " + str(e.args)) 65 | except IndexError as e: 66 | print("IndexError: " + str(e.args)) 67 | 68 | 69 | if __name__ =="__main__": 70 | d=Dymo() 71 | print(d.get_id()) 72 | print(d.get_weight()) 73 | 74 | -------------------------------------------------------------------------------- /slab/instruments/DymoScale.py: -------------------------------------------------------------------------------- 1 | __author__ = 'Dave' 2 | 3 | import usb.core 4 | import usb.util 5 | from liveplot import LivePlotClient 6 | import time 7 | import math 8 | 9 | def grab(): 10 | try: 11 | # first endpoint 12 | endpoint = dev[0][(0,0)][0] 13 | 14 | # read a data packet 15 | attempts = 10 16 | data = None 17 | while data is None and attempts > 0: 18 | try: 19 | data = dev.read(endpoint.bEndpointAddress, 20 | endpoint.wMaxPacketSize) 21 | except usb.core.USBError as e: 22 | data = None 23 | if e.args == ('Operation timed out',): 24 | attempts -= 1 25 | print("timed out... trying again") 26 | continue 27 | 28 | return data 29 | except usb.core.USBError as e: 30 | print("USBError: " + str(e.args)) 31 | except IndexError as e: 32 | print("IndexError: " + str(e.args)) 33 | 34 | 35 | 36 | 37 | def listen(): 38 | DATA_MODE_GRAMS = 2 39 | DATA_MODE_OUNCES = 11 40 | 41 | last_raw_weight = 0 42 | last_raw_weight_stable = 4 43 | 44 | print("listening for weight...") 45 | 46 | while True: 47 | time.sleep(.5) 48 | 49 | weight = 0 50 | print_weight = "" 51 | 52 | data = grab() 53 | if data != None: 54 | raw_weight = data[4] + data[5] * 256 55 | 56 | # +/- 2g 57 | if raw_weight > 0 and abs(raw_weight-last_raw_weight) > 0 and raw_weight != last_raw_weight: 58 | last_raw_weight_stable = 4 59 | last_raw_weight = raw_weight 60 | 61 | if raw_weight > 0 and last_raw_weight_stable >= 0: 62 | last_raw_weight_stable -= 1 63 | 64 | if raw_weight > 0 and last_raw_weight_stable == 0: 65 | if data[2] == DATA_MODE_OUNCES: 66 | ounces = raw_weight * 0.1 67 | weight = math.ceil(ounces) 68 | print_weight = "%s oz" % ounces 69 | elif data[2] == DATA_MODE_GRAMS: 70 | grams = raw_weight 71 | weight = math.ceil(grams) 72 | print_weight = "%s g" % grams 73 | 74 | #print "stable weight: " + print_weight 75 | lp.append_y("scale",raw_weight) 76 | 77 | 78 | lp=LivePlotClient() 79 | 80 | VENDOR_ID = 0x0922 81 | PRODUCT_ID = 0x8009 82 | 83 | #print usb.core.find() 84 | # find the USB device 85 | dev = usb.core.find(idVendor=VENDOR_ID, 86 | idProduct=PRODUCT_ID) 87 | 88 | # use the first/default configuration 89 | dev.set_configuration() 90 | # first endpoint 91 | 92 | listen() 93 | 94 | -------------------------------------------------------------------------------- /slab/experiments/Nitrogen/General/CWDriveExperiment.py: -------------------------------------------------------------------------------- 1 | __author__ = 'Nelson' 2 | 3 | from slab import * 4 | from slab.instruments.Alazar import Alazar 5 | from numpy import mean, arange 6 | 7 | 8 | class CWDriveExperiment(Experiment): 9 | def __init__(self, path='', prefix='CW_Drive', config_file='..\\config.json', use_cal=False, **kwargs): 10 | Experiment.__init__(self, path=path, prefix=prefix, config_file=config_file, **kwargs) 11 | 12 | self.expt_cfg_name = prefix.lower() 13 | 14 | self.cfg['alazar']['samplesPerRecord'] = 2 ** (self.cfg['readout']['width'] - 1).bit_length() 15 | self.cfg['alazar']['recordsPerBuffer'] = 100 16 | self.cfg['alazar']['recordsPerAcquisition'] = 10000 17 | 18 | self.expt_pts = arange(self.cfg[self.expt_cfg_name]['start'], self.cfg[self.expt_cfg_name]['stop'], self.cfg[self.expt_cfg_name]['step']) 19 | 20 | return 21 | 22 | def go(self): 23 | self.plotter.clear() 24 | 25 | print("Prep Instruments") 26 | self.readout.set_output(True) 27 | self.readout.set_power(self.cfg['readout']['power']) 28 | self.readout.set_ext_pulse(mod=False) 29 | self.readout_atten.set_attenuator(self.cfg['readout']['dig_atten']) 30 | self.readout.set_frequency(self.cfg['readout']['frequency']) 31 | self.readout_shifter.set_phase((self.cfg['readout']['start_phase'])%360, self.cfg['readout']['frequency']) 32 | 33 | self.drive.set_output(True) 34 | self.drive.set_power(self.cfg['drive']['power']) 35 | self.drive.set_ext_pulse(mod=False) 36 | 37 | self.awg.set_amps_offsets(self.cfg['cal']['iq_amps'],self.cfg[self.expt_cfg_name]['iq_offsets']) 38 | 39 | print("Prep Card") 40 | adc = Alazar(self.cfg['alazar']) 41 | 42 | for freq in self.expt_pts: 43 | self.drive.set_frequency(freq) 44 | 45 | tpts, ch1_pts, ch2_pts = adc.acquire_avg_data() 46 | 47 | mag = sqrt(ch1_pts**2+ch2_pts**2) 48 | 49 | self.plotter.append_xy('avg_cw_drive_freq_scan1', freq, mean(ch1_pts[0:])) 50 | self.plotter.append_xy('avg_cw_drive_freq_scan2', freq, mean(ch2_pts[0:])) 51 | self.plotter.append_xy('avg_cw_drive_freq_scan_mag', freq, mean(mag[0:])) 52 | self.plotter.append_z('scope1',ch1_pts) 53 | self.plotter.append_z('scope2',ch2_pts) 54 | self.plotter.append_z('scope_mag',mag) 55 | 56 | with self.datafile() as f: 57 | f.append_pt('freq', freq) 58 | f.append_pt('ch1_mean', mean(ch1_pts[0:])) 59 | f.append_pt('ch2_mean', mean(ch2_pts[0:])) 60 | f.append_pt('mag_mean', mean(mag[0:])) 61 | 62 | 63 | -------------------------------------------------------------------------------- /slab/experiments/Rodin Furnace/system_config.yml: -------------------------------------------------------------------------------- 1 | PID: 2 | UNITS: 'C' 3 | Con_Interval: 2.0 4 | Con_Type: 'PID' 5 | Ramp_Up_Rate: 5.0 #in deg (units) per unit time 6 | Ramp_Down_Rate: 5.0 7 | Ramp_Time_Unit: 'MIN' #must be SEC, MIN, HOUR 8 | CHANNELS: 9 | 1: 10 | Set_Point: 100.00 11 | P: 100.00 12 | I: 10.0 13 | D: 0 14 | RUN: True 15 | Con_Mode: 'AUTO' 16 | 2: 17 | Set_Point: 100.00 18 | P: 100.00 19 | I: 10.0 20 | D: 0 21 | RUN: True 22 | Con_Mode: 'AUTO' 23 | 3: 24 | Set_Point: 100.00 25 | P: 100.00 26 | I: 10.0 27 | D: 0 28 | RUN: True 29 | Con_Mode: 'AUTO' 30 | 4: 31 | Set_Point: 100.00 32 | P: 100.00 33 | I: 5.0 34 | D: 0 35 | RUN: True 36 | Con_Mode: 'AUTO' 37 | 5: 38 | Set_Point: 100.00 39 | P: 50.0 40 | I: 20 41 | D: 0 42 | RUN: True 43 | Con_Mode: 'AUTO' 44 | 6: 45 | Set_Point: 100.00 46 | P: 100.00 47 | I: 10.0 48 | D: 0 49 | RUN: False 50 | Con_Mode: 'AUTO' 51 | 7: 52 | Set_Point: 100.00 53 | P: 100.00 54 | I: 10.0 55 | D: 0 56 | RUN: False 57 | Con_Mode: 'AUTO' 58 | 8: 59 | Set_Point: 40 60 | P: 100.00 61 | I: 10.0 62 | D: 0 63 | RUN: False 64 | Con_Mode: 'AUTO' 65 | 66 | Pressure_Monitor: 67 | UNITS: 'mbar' 68 | SET_POINTS: 69 | 1: 70 | CHANNEL: 1 71 | SP_H: 1.0E-4 72 | SP_L: 9.0E-5 73 | 2: 74 | CHANNEL: 1 75 | SP_H: 1.0E-4 76 | SP_L: 1.0E-3 77 | 3: 78 | CHANNEL: 2 79 | SP_H: 5.0E2 80 | SP_L: 1.0E-2 81 | 4: 82 | CHANNEL: 2 83 | SP_H: 3.3E-2 84 | SP_L: 3.2E-2 85 | 5: 86 | CHANNEL: 1 87 | SP_H: 8.5E-2 88 | SP_L: 8.0E-2 89 | 6: 90 | CHANNEL: 1 91 | SP_H: 8.5E-3 92 | SP_L: 8.0E-3 93 | 94 | PLC: 95 | VALVES: 96 | BACKING: 97 | CHANNEL: 1 98 | ROUGHING: 99 | CHANNEL: 2 100 | GATE: 101 | CHANNEL: 3 102 | PULSE: 103 | CHANNEL: 4 104 | RGA: 105 | CHANNEL: 5 106 | 107 | TURBO: 108 | SP_TYPE: 'freq' #or 'power' 109 | SP_VAL: 350 #unit Hz 110 | SP_HYST: 2 #percent of SP_val hysteresis 111 | LOW_SPEED: False 112 | SOFT_START: False 113 | COOLING: 'water' 114 | HIGH_SPEED_VAL: 825 #825 maximum, unit Hz 115 | LOW_SPEED_VAL: 400 #350 minimum, unit Hz 116 | GAS_TYPE: 'N2' 117 | 118 | SUPPLY: 119 | max_current: 14.00 120 | max_volts: 46.00 121 | min_volts: 12.00 122 | port: 'COM3' 123 | 124 | TEMPSCAN: 125 | CHANNELS: 126 | 101: 127 | SENS: 'TC' 128 | TYPE: 'K' 129 | UNIT: 'C' 130 | TRIG: 'IMM' 131 | 132 | 133 | 134 | 135 | -------------------------------------------------------------------------------- /slab/instruments/relaybox/RFSwitch.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | RF Switch Controller (relaybox.RFSwitch.py) 4 | =========================================== 5 | :Author: Thomas 6 | 7 | Relay Numbers(Ports) are always 1-8 unless activating multiple relays at a time. 8 | Ports 1-6 can be activated/deactivated 9 | If using USB cable, set address to appropriate COM. 10 | If using web access, set address to appropriate URL. 11 | """ 12 | 13 | from slab.instruments.relaybox import RelayBox 14 | import time 15 | 16 | class RFSwitch(RelayBox): 17 | 18 | def __init__(self,name="",address="",enabled=True, RF_Status=[False,False,False,False,False,False]): 19 | print("Switch", name, "at address", address, " is initiated!") 20 | RelayBox.__init__(self,name,address,enabled) 21 | self.RF_Status=RF_Status 22 | 23 | def set_switch (self, switch=0,state=True): 24 | """activates or deactivates RF Switch according to state, 25 | if switch=0 does for all switches, if switch=1..6 does individual port""" 26 | if state: self.activate(switch) 27 | else: self.deactivate(switch) 28 | 29 | def get_switch (self,switch=0): 30 | """Get switch (cached) state of _switch_ if _switch_ = 0 return array of switch states """ 31 | if switch == 0: return self.RF_Status 32 | else: return self.RF_Status[switch-1] 33 | 34 | def activate(self, switch=0,pulse_time=1): 35 | """Activate _switch_ if _switch_=0 activate all switches""" 36 | if switch>0: 37 | self.set_relay(switch, True) 38 | self.pulse_relay(7,pulse_time) 39 | self.set_relay(switch, False) 40 | self.RF_Status[switch-1]= True 41 | elif switch == 0: 42 | for i in range(1,7): 43 | self.activate(i) 44 | 45 | def deactivate(self, switch=0,pulse_time=1): 46 | """Activate _switch_ if _switch_=0 activate all switches""" 47 | if switch>0: 48 | self.set_relay(switch, True) 49 | self.pulse_relay(8,pulse_time) 50 | self.set_relay(switch, False) 51 | self.RF_Status[switch-1]= False 52 | elif switch == 0: 53 | for i in range(1,7): 54 | self.deactivate(i) 55 | 56 | if __name__=="__main__": 57 | RF_1= 'http://192.168.14.20' 58 | RF_2='http://192.168.14.21' 59 | RF_3='http://192.168.14.22' 60 | 61 | rfs_1=RFSwitch(name="Switch1", address=RF_1) 62 | rfs_2=RFSwitch(name="Switch2", address=RF_2) 63 | rfs_3=RFSwitch(name="Switch3", address=RF_3) 64 | 65 | for i in range(6): 66 | rfs_3.activate(i+1) 67 | print(rfs_3.RF_Status) 68 | 69 | for i in range(6): 70 | rfs_3.deactivate(i+1) 71 | print(rfs_3.RF_Status) 72 | 73 | 74 | 75 | 76 | -------------------------------------------------------------------------------- /slab/experiments/Hafnium/ExpLib/SequentialExperiment.py: -------------------------------------------------------------------------------- 1 | __author__ = 'Nelson' 2 | 3 | from slab.experiments.Hafnium.General.run_experiment import * 4 | from slab.experiments.Hafnium.Multimode.run_multimode_experiment import * 5 | import numbers 6 | from slab import * 7 | import json 8 | import collections 9 | 10 | import gc 11 | 12 | 13 | def update_dict(d, u): 14 | for k, v in u.items(): 15 | if isinstance(v, collections.Mapping): 16 | r = update_dict(d.get(k, {}), v) 17 | d[k] = r 18 | else: 19 | d[k] = u[k] 20 | return d 21 | 22 | 23 | class SequentialExperiment(): 24 | def __init__(self, lp_enable=True): 25 | self.expt = None 26 | self.lp_enable = lp_enable 27 | # config_file = 'config.json' 28 | # datapath = os.getcwd() 29 | 30 | def run(self, expt_name, vary_dict={}, expt_kwargs={}): 31 | 32 | if self.expt is not None: 33 | del self.expt 34 | gc.collect() 35 | 36 | datapath = os.getcwd() + '\data' 37 | config_file = os.path.join(datapath, "..\\config" + ".json") 38 | with open(config_file, 'r') as fid: 39 | cfg_str = fid.read() 40 | cfg_dict = json.loads(cfg_str) 41 | 42 | cfg_dict_temp = update_dict(cfg_dict, vary_dict) 43 | with open('config.json', 'w') as fp: 44 | json.dump(cfg_dict_temp, fp) 45 | 46 | print("--------Parameters varied in config file ---------") 47 | print(vary_dict) 48 | print("--------------------------------------------------") 49 | print("--------Parameters changed through extra_args---------") 50 | print(expt_kwargs) 51 | print("--------------------------------------------------") 52 | 53 | ## automatically save kwargs to data_file 54 | if 'data_file' in expt_kwargs: 55 | data_file = expt_kwargs['data_file'] 56 | for key in expt_kwargs: 57 | if isinstance(expt_kwargs[key], numbers.Number) and not key == 'update_config': 58 | with SlabFile(data_file) as f: 59 | f.append_pt(key, float(expt_kwargs[key])) 60 | f.close() 61 | 62 | if 'seq_pre_run' in expt_kwargs: 63 | expt_kwargs['seq_pre_run'](self) 64 | 65 | self.expt = run_experiment(expt_name, self.lp_enable, config_file='..\\config.json', **expt_kwargs) 66 | if self.expt is None: 67 | self.expt = run_multimode_experiment(expt_name, self.lp_enable, **expt_kwargs) 68 | 69 | if 'seq_post_run' in expt_kwargs: 70 | expt_kwargs['seq_post_run'](self) 71 | 72 | if 'update_config' in expt_kwargs: 73 | if expt_kwargs['update_config']: 74 | self.save_config() 75 | 76 | def save_config(self): 77 | self.expt.save_config() 78 | print("config saved!") 79 | 80 | 81 | 82 | 83 | 84 | -------------------------------------------------------------------------------- /slab/experiments/Nitrogen/ExpLib/SequentialExperiment.py: -------------------------------------------------------------------------------- 1 | __author__ = 'Nelson' 2 | 3 | from slab.experiments.Nitrogen.General.run_experiment import * 4 | from slab.experiments.Nitrogen.Multimode.run_multimode_experiment import run_multimode_experiment 5 | import numbers 6 | from slab import * 7 | import json 8 | import collections 9 | 10 | import gc 11 | 12 | 13 | def update_dict(d, u): 14 | for k, v in u.items(): 15 | if isinstance(v, collections.Mapping): 16 | r = update_dict(d.get(k, {}), v) 17 | d[k] = r 18 | else: 19 | d[k] = u[k] 20 | return d 21 | 22 | 23 | class SequentialExperiment(): 24 | def __init__(self, lp_enable=True): 25 | self.expt = None 26 | self.lp_enable = lp_enable 27 | # config_file = 'config.json' 28 | # datapath = os.getcwd() 29 | 30 | def run(self, expt_name, vary_dict={}, expt_kwargs={}): 31 | 32 | if self.expt is not None: 33 | del self.expt 34 | gc.collect() 35 | 36 | datapath = os.getcwd() + '\data' 37 | config_file = os.path.join(datapath, "..\\config" + ".json") 38 | with open(config_file, 'r') as fid: 39 | cfg_str = fid.read() 40 | cfg_dict = json.loads(cfg_str) 41 | 42 | cfg_dict_temp = update_dict(cfg_dict, vary_dict) 43 | with open('config.json', 'w') as fp: 44 | json.dump(cfg_dict_temp, fp) 45 | 46 | print("--------Parameters varied in config file ---------") 47 | print(vary_dict) 48 | print("--------------------------------------------------") 49 | print("--------Parameters changed through extra_args---------") 50 | print(expt_kwargs) 51 | print("--------------------------------------------------") 52 | 53 | ## automatically save kwargs to data_file 54 | if 'data_file' in expt_kwargs: 55 | data_file = expt_kwargs['data_file'] 56 | for key in expt_kwargs: 57 | if isinstance(expt_kwargs[key], numbers.Number) and not key == 'update_config': 58 | with SlabFile(data_file) as f: 59 | f.append_pt(key, float(expt_kwargs[key])) 60 | f.close() 61 | 62 | if 'seq_pre_run' in expt_kwargs: 63 | expt_kwargs['seq_pre_run'](self) 64 | 65 | self.expt = run_experiment(expt_name, self.lp_enable, config_file='..\\config.json', **expt_kwargs) 66 | if self.expt is None: 67 | self.expt = run_multimode_experiment(expt_name, self.lp_enable, **expt_kwargs) 68 | 69 | if 'seq_post_run' in expt_kwargs: 70 | expt_kwargs['seq_post_run'](self) 71 | 72 | if 'update_config' in expt_kwargs: 73 | if expt_kwargs['update_config']: 74 | self.save_config() 75 | 76 | def save_config(self): 77 | self.expt.save_config() 78 | print("config saved!") 79 | 80 | 81 | 82 | 83 | 84 | -------------------------------------------------------------------------------- /test/datamanagement unit test.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | Created on Sun Sep 23 12:14:08 2012 4 | 5 | @author: Dave 6 | """ 7 | 8 | from slab import * 9 | from os import * 10 | from numpy import * 11 | import matplotlib.pyplot as plt 12 | import time 13 | 14 | def test_slabfile(): 15 | fname='slabfile_test.h5' 16 | try: os.remove(fname) 17 | except: pass 18 | 19 | #print "Test save and load settings" 20 | f=SlabFile(fname,'w') 21 | d={'a':1,'b':2.1,'c':'This is a string!'} 22 | f.save_settings(d) 23 | f.close() 24 | 25 | f=SlabFile(fname) 26 | d2=f.load_settings() 27 | f.close() 28 | error=False 29 | for k in d: 30 | if d2[k]!=d[k]: 31 | print("Error! loaded item != to original: ", str(d2[k])," != ", str(d[k])) 32 | if not error: print("Passed: Save/load settings.") 33 | else: print("Failed: Rewrite settings.") 34 | 35 | #print "Test rewriting settings" 36 | d3={'a':2,'b':2.1,'c':'This is a string!','d':'Extra string'} 37 | f=SlabFile(fname) 38 | f.save_settings(d3) 39 | f.close() 40 | 41 | f=SlabFile(fname,'r') 42 | d4=f.load_settings() 43 | f.close() 44 | error=False 45 | for k in d: 46 | if d4[k]!=d3[k]: 47 | print("Error! loaded item != to original: ", str(d4[k])," != ", str(d3[k])) 48 | if not error: print("Passed: Rewrite settings.") 49 | else: print("Failed: Rewrite settings.") 50 | os.remove(fname) 51 | 52 | def test_append_data(): 53 | t0=time.time() 54 | fname='append_data_test.h5' 55 | try: os.remove(fname) 56 | except: pass 57 | 58 | error=False 59 | 60 | num_fpts=400 61 | num_tpts=1000 62 | freqs=linspace(1.,10.,num_fpts) 63 | 64 | tpts=linspace(0.,1.,num_tpts) 65 | data=array([exp(-tpts/0.5)*sin(2*pi*freq *tpts) for freq in freqs]) 66 | # plt.figure(1) 67 | # plt.imshow(data) 68 | # plt.show() 69 | 70 | 71 | 72 | f=SlabFile(fname) 73 | f.create_dataset('Rabi',shape=(0,num_tpts),maxshape=(None,num_tpts),dtype=float64) 74 | f.create_dataset('fpts', shape=(0,),maxshape=(None,),dtype=float64) 75 | f.close() 76 | for ii,d in enumerate(data): 77 | f=SlabFile(fname) 78 | #ds=f['Rabi'] 79 | #ds.resize((ii+1,num_tpts)) 80 | #ds[ii,:]=d 81 | f.append_line(f['Rabi'],d) 82 | f.append_pt(f['fpts'],freqs[ii]) 83 | f.close() 84 | 85 | print("Append test: %f" %(time.time()-t0)) 86 | f2=SlabFile(fname) 87 | data2=array(f['Rabi']) 88 | f2.close() 89 | plt.figure(1) 90 | plt.imshow(data2) 91 | plt.show() 92 | 93 | if not error: print("Passed: Append data.") 94 | else: print("Failed: Append data.") 95 | 96 | 97 | 98 | #os.remove(fname) 99 | 100 | 101 | 102 | 103 | if __name__=="__main__": 104 | test_slabfile() 105 | test_append_data() -------------------------------------------------------------------------------- /slab/instruments/awg/TekPattern2.py: -------------------------------------------------------------------------------- 1 | """ 2 | TekPattern2 for creating Tek70001 AWG files. 3 | 4 | Created on April 10, 2014 5 | 6 | Dave M 7 | """ 8 | 9 | import struct 10 | import io 11 | import h5py 12 | import numpy as np 13 | import io 14 | 15 | 16 | #This creates a waveform file that can be loaded into the awg 17 | def create_waveform_file(filename,data): 18 | 19 | 20 | data = data.astype(np.float32) 21 | 22 | #works if you specify single, floating and then each point is specified by a floating # 23 | #from -1 --> 1 24 | 25 | #datafile offset is where the data starts 26 | #first write to a string to determine the data offset! 27 | for i in range(2): 28 | if i==0: 29 | FID = io.StringIO() 30 | else: 31 | str_length = len(FID.getvalue()) 32 | FID = io.open(filename, 'wb') 33 | 34 | if i==0: 35 | FID.write("") 36 | else: 37 | FID.write("") 38 | FID.write("") 39 | FID.write("") 40 | FID.write("") 41 | FID.write("" + str(len(data)) + "") 42 | FID.write("AWGWaveformSample") 43 | FID.write("false") 44 | 45 | #number formats: Single, UInt16, Int32, Double 46 | FID.write("Single") 47 | FID.write("Big") 48 | FID.write("2014-04-01T16:29:23.8235574-07:00") 49 | FID.write("") 50 | FID.write("") 51 | FID.write("50000000000") 52 | FID.write("1.0") 53 | FID.write("0") 54 | FID.write("") 55 | FID.write("2.0.0211") 56 | FID.write("") 57 | 58 | #Floating, EightBit, NineBit, TenBit (What do these mean?) 59 | FID.write("Floating") 60 | FID.write("") 61 | FID.write("") 62 | FID.write(" ") 63 | FID.write("") 64 | FID.write("") 65 | FID.write("") 66 | FID.write("") 67 | 68 | 69 | FID.write(data.tostring()) 70 | 71 | FID.close() 72 | 73 | 74 | if __name__ == '__main__': 75 | 76 | pass 77 | 78 | 79 | -------------------------------------------------------------------------------- /slab/instruments/awg/chase/test_chase.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | from slab.instruments import DAx22000, DAx22000Segment,Alazar 3 | from slab.instruments import InstrumentManager 4 | from slab import Experiment 5 | import matplotlib.pyplot as plt 6 | 7 | expt=Experiment(path=r'C:\_Lib\python\slab\instruments\awg\chase',config_file='config.json') 8 | 9 | expt.plotter.clear('dac1') 10 | expt.plotter.clear('dac2') 11 | 12 | dac = DAx22000('dac', '1') 13 | 14 | im=InstrumentManager() 15 | trig = im['trig'] 16 | 17 | print(dac.initialize(ext_clk_ref=False)) 18 | print(dac.set_clk_freq(freq=0.5e9)) 19 | 20 | xpts = np.arange(6400) 21 | ypts = np.ceil(2047.5 + 2047.5 * np.sin(2.0 * np.pi * xpts / (32))) 22 | print(ypts) 23 | print(dac.create_single_segment(1, 0, 2047, 2047, ypts, 1)) 24 | print(dac.place_mrkr2(1)) 25 | print(dac.set_ext_trig(ext_trig=True)) 26 | 27 | numsegs = 200 28 | segs = [] 29 | waveforms = [] 30 | 31 | def waveform_compressor(waveform): 32 | print("compressing") 33 | 34 | 35 | for ii in range(numsegs): 36 | ii = numsegs - ii 37 | gauss1=np.exp(-1.0 * (xpts - 1000) ** 2 / (2 * (2*ii+1) ** 2)) 38 | cutoff1_1=0.5 * (np.sign(xpts-(1000 - 3*(2*ii+1))) + 1) 39 | cutoff1_2=0.5 * (np.sign((1000 + 3*(2*ii+1)) - xpts) + 1) 40 | cutoff_gauss1=np.array([a*b*c for a,b,c in zip(gauss1,cutoff1_1,cutoff1_2)]) 41 | gauss2=np.exp(-1.0 * (xpts - 2500) ** 2 / (2 * (ii+1) ** 2)) 42 | cutoff2_1=0.5 * (np.sign(xpts-(2500 - 3*(ii+1))) + 1) 43 | cutoff2_2=0.5 * (np.sign((2500 + 3*(ii+1)) - xpts) + 1) 44 | cutoff_gauss2=np.array([a*b*c for a,b,c in zip(gauss2,cutoff2_1,cutoff2_2)]) 45 | waveform = 2047 + 2047*cutoff_gauss1#*np.exp(-1.0 * (xpts - 2000) ** 2 / (2 * (5*ii+1) ** 2)) #* 0.5 * (np.sign(xpts-2000 - 3*(5*ii+1)) + 1)#*0.5 * (np.sign(xpts-4000 - 3*(10*ii+1)) + 1) * 0.5 * (np.sign(4000 + 3*(10*ii+1) - xpts) + 1) 46 | waveform += 2047*cutoff_gauss2 47 | waveforms.append(waveform) 48 | segs.append(DAx22000Segment(waveform, loops=0, triggered=True)) 49 | #segs.append(DAx22000Segment(xpts * 4095.0 / max(xpts) * ii / numsegs, loops=0, triggered=True)) 50 | 51 | 52 | dac.create_segments(chan=1, segments=segs, loops=0) 53 | dac.create_segments(chan=2, segments=segs, loops=0) 54 | 55 | print(dac.set_ext_trig(ext_trig=True)) 56 | #print dac.run(trigger_now=False) 57 | 58 | expt.cfg['alazar']["samplesPerRecord"]=8192 59 | expt.cfg['alazar']["recordsPerBuffer"]=numsegs 60 | expt.cfg['alazar']["recordsPerAcquisition"]=numsegs 61 | adc = Alazar(expt.cfg['alazar']) 62 | 63 | #expt.awg.stop() 64 | trig.set_output(False) 65 | 66 | def trig_stop(): 67 | trig.set_output(False) 68 | dac.stop() 69 | print("trig stop") 70 | 71 | def trig_start(): 72 | trig.set_output(True) 73 | dac.run(trigger_now=False) 74 | print("trig start") 75 | 76 | tpts, ch1_pts, ch2_pts = adc.acquire_avg_data_by_record(prep_function=trig_stop, start_function=trig_start) 77 | 78 | trig.set_output(False) 79 | 80 | 81 | dac.stop() 82 | dac.close() 83 | 84 | expt.plotter.plot_z('dac1',ch1_pts) 85 | expt.plotter.plot_z('dac2',ch2_pts) 86 | expt.plotter.plot_z('waveforms',waveforms) 87 | 88 | 89 | 90 | 91 | 92 | 93 | -------------------------------------------------------------------------------- /slab/instruments/pulseblaster/pulseblaster_hafnium.py: -------------------------------------------------------------------------------- 1 | __author__ = 'Nelson' 2 | 3 | from .spinapi import * 4 | 5 | 6 | def start_pulseblaster(exp_period_ns,awg_trig_len,card_trig_time,card_trig_len,readout_trig_len): 7 | 8 | 9 | # Enable the log file 10 | pb_set_debug(1) 11 | 12 | print(("Using SpinAPI Library version %s" % pb_get_version())) 13 | print(("Found %d boards in the system.\n" % pb_count_boards())) 14 | 15 | pb_select_board(0) 16 | 17 | 18 | # TODO: Make this error checking better 19 | if pb_init() != 0: 20 | print(("Error initializing board: %s" % pb_get_error())) 21 | # exit() 22 | 23 | # time settings 24 | unit_inst_time = 10 # ns 25 | idle_unit_inst_time = 10000 # ns 26 | exp_period = exp_period_ns 27 | #exp_period = 200*1000 # 100us 28 | 29 | awg_trig_time = 0 30 | #awg_trig_len = 100 31 | 32 | #card_trig_time = 2000 33 | #card_trig_len = 100 34 | 35 | readout_trig_time = card_trig_time 36 | #readout_trig_len = 1000 # has to be longer than card_trig_len 37 | 38 | 39 | # calculated time value 40 | awg_trig_delay_loop = awg_trig_len/unit_inst_time 41 | card_and_readout_trig_delay_loop = card_trig_len/unit_inst_time 42 | readout_trig_delay_loop = (readout_trig_len-card_trig_len)/unit_inst_time 43 | 44 | awg_card_idle_time = card_trig_time - (awg_trig_time + awg_trig_len) 45 | awg_card_idle_delay_loop = awg_card_idle_time/unit_inst_time 46 | 47 | total_time = readout_trig_time + readout_trig_len 48 | period_idle_time = exp_period - total_time 49 | period_idle_delay_loop = int(period_idle_time / idle_unit_inst_time - 1) 50 | 51 | 52 | 53 | # delay loop 54 | delay_loop = 20 55 | 56 | # ports hex value 57 | idle = 0x0 58 | awg_trig = 0x1 59 | card_trig = 0x2 60 | readout_trig = 0x4 61 | #drive_trig = 0x8 62 | 63 | # Configure the core clock 64 | pb_core_clock(500.0) 65 | 66 | # Program the pulse program 67 | pb_start_programming(PULSE_PROGRAM) 68 | 69 | # awg trigger 70 | start = pb_inst_pbonly64(awg_trig, Inst.LONG_DELAY,awg_trig_delay_loop,unit_inst_time) 71 | 72 | # idle between end of awg trig and card trig 73 | pb_inst_pbonly64(idle, Inst.LONG_DELAY, awg_card_idle_delay_loop, unit_inst_time) 74 | 75 | # card and readout trig starts at the same time 76 | pb_inst_pbonly64(card_trig+readout_trig, Inst.LONG_DELAY,card_and_readout_trig_delay_loop,unit_inst_time) 77 | 78 | # readout trig after card trig (assume readout trig is longer) 79 | pb_inst_pbonly64(readout_trig, Inst.LONG_DELAY,readout_trig_delay_loop,unit_inst_time) 80 | 81 | # idle for next experiment 82 | pb_inst_pbonly64(idle, Inst.LONG_DELAY, period_idle_delay_loop, idle_unit_inst_time) 83 | 84 | # branch to start; Outputs are off 85 | pb_inst_pbonly64(idle, Inst.BRANCH, start, idle_unit_inst_time) 86 | 87 | pb_stop_programming() 88 | 89 | # Trigger the board 90 | pb_reset() 91 | # run_pulseblaster() 92 | 93 | #pb_close() 94 | 95 | def run_pulseblaster(): 96 | pb_start() 97 | 98 | def stop_pulseblaster(): 99 | pb_stop() -------------------------------------------------------------------------------- /slab/instruments/awg/chase/test_chase_0.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | from slab.instruments import DAx22000, DAx22000Segment,Alazar 3 | from slab.instruments import InstrumentManager 4 | from slab import Experiment 5 | import matplotlib.pyplot as plt 6 | 7 | expt=Experiment(path=r'C:\_Lib\python\slab\instruments\awg\chase',config_file='config.json') 8 | 9 | expt.plotter.clear('dac1') 10 | expt.plotter.clear('dac2') 11 | 12 | dac = DAx22000('dac', '1') 13 | 14 | im=InstrumentManager() 15 | trig = im['trig'] 16 | 17 | print(dac.initialize(ext_clk_ref=True)) 18 | print(dac.set_clk_freq(freq=0.5e9)) 19 | 20 | xpts = np.arange(6400) 21 | ypts = np.ceil(2047.5 + 2047.5 * np.sin(2.0 * np.pi * xpts / (32))) 22 | print(ypts) 23 | print(dac.create_single_segment(1, 0, 2047, 2047, ypts, 1)) 24 | print(dac.place_mrkr2(1)) 25 | print(dac.set_ext_trig(ext_trig=True)) 26 | 27 | numsegs = 65 28 | segs = [] 29 | waveforms = [] 30 | 31 | def waveform_compressor(waveform): 32 | print("compressing") 33 | 34 | 35 | for ii in range(numsegs): 36 | # ii = numsegs - ii 37 | # gauss1=np.exp(-1.0 * (xpts - 1000) ** 2 / (2 * (2*ii+1) ** 2)) 38 | # cutoff1_1=0.5 * (np.sign(xpts-(1000 - 3*(2*ii+1))) + 1) 39 | # cutoff1_2=0.5 * (np.sign((1000 + 3*(2*ii+1)) - xpts) + 1) 40 | # cutoff_gauss1=np.array([a*b*c for a,b,c in zip(gauss1,cutoff1_1,cutoff1_2)]) 41 | # gauss2=np.exp(-1.0 * (xpts - 2500) ** 2 / (2 * (ii+1) ** 2)) 42 | # cutoff2_1=0.5 * (np.sign(xpts-(2500 - 3*(ii+1))) + 1) 43 | # cutoff2_2=0.5 * (np.sign((2500 + 3*(ii+1)) - xpts) + 1) 44 | # cutoff_gauss2=np.array([a*b*c for a,b,c in zip(gauss2,cutoff2_1,cutoff2_2)]) 45 | # waveform = 2047 + 2047*cutoff_gauss1#*np.exp(-1.0 * (xpts - 2000) ** 2 / (2 * (5*ii+1) ** 2)) #* 0.5 * (np.sign(xpts-2000 - 3*(5*ii+1)) + 1)#*0.5 * (np.sign(xpts-4000 - 3*(10*ii+1)) + 1) * 0.5 * (np.sign(4000 + 3*(10*ii+1) - xpts) + 1) 46 | # waveform += 2047*cutoff_gauss2 47 | # waveforms.append(waveform) 48 | # segs.append(DAx22000Segment(waveform, loops=0, triggered=True)) 49 | segs.append(DAx22000Segment(xpts * 4095.0 / max(xpts) * ii / numsegs, loops=1, triggered=True)) 50 | 51 | 52 | dac.create_segments(chan=1, segments=segs, loops=0) 53 | dac.create_segments(chan=2, segments=segs, loops=0) 54 | 55 | print(dac.set_ext_trig(ext_trig=True)) 56 | print(dac.run(trigger_now=False)) 57 | 58 | expt.cfg['alazar']["samplesPerRecord"]=8192 59 | expt.cfg['alazar']["recordsPerBuffer"]=numsegs 60 | expt.cfg['alazar']["recordsPerAcquisition"]=numsegs 61 | adc = Alazar(expt.cfg['alazar']) 62 | 63 | #expt.awg.stop() 64 | trig.set_output(True) 65 | 66 | def trig_stop(): 67 | trig.set_output(False) 68 | dac.stop() 69 | print("trig stop") 70 | 71 | def trig_start(): 72 | trig.set_output(True) 73 | dac.run(trigger_now=False) 74 | print("trig start") 75 | 76 | tpts, ch1_pts, ch2_pts = adc.acquire_avg_data_by_record(prep_function=None, start_function=None) 77 | 78 | #trig.set_output(False) 79 | 80 | 81 | dac.stop() 82 | dac.close() 83 | 84 | expt.plotter.plot_z('dac1',ch1_pts) 85 | expt.plotter.plot_z('dac2',ch2_pts) 86 | expt.plotter.plot_z('waveforms',waveforms) 87 | 88 | 89 | 90 | 91 | 92 | 93 | -------------------------------------------------------------------------------- /slab/instruments/keysight/KeysightPulseSequence.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | Created on Mon Aug 6 16:01:14 2018 4 | 5 | @author: Josie Meyer (jcmeyer@stanford.edu) 6 | 7 | Allows existing pulse sequence code to be played out on the Keysight M32xxA 8 | modules. This is the 'dumb' implementation that does not take advantage of the 9 | full capability of the HVI and only uses it for synching. Moreover, individual 10 | channels are all activated simultaneously; they may be manually muted if 11 | necessary. 12 | 13 | """ 14 | 15 | import KeysightLib as key 16 | import keysightSD1 as SD1 17 | import json 18 | 19 | class KeysightPulseSequence(): 20 | '''Class representing a pulse sequence as customized for a Keysight M32xxA 21 | module.''' 22 | 23 | def __init__(self): 24 | '''Initializes the pulse sequence object.''' 25 | self._dict = {} 26 | 27 | def addWaveform(self, chassis_number, slot_number, channel_number, 28 | waveform_array): 29 | '''Adds one channel's waveform to the pulse sequence. 30 | Params: 31 | chassis_number: The number of the chassis where the desired channel 32 | is housed. 33 | slot_number: The number of the slot where the desired channel is 34 | housed. 35 | channel_number: The channel number of the desired channel 36 | waveform: The array representing the waveform''' 37 | self._dict[key.Tools.serializeChannel(chassis_number, 38 | slot_number, channel_number)] = waveform_array 39 | 40 | def writeToFile(self, filename): 41 | '''Writes the pulse sequence to a file that can be opened.''' 42 | with open(filename, 'w') as f: 43 | json.dump(self._dict, f) 44 | 45 | @staticmethod 46 | def loadFromFile(chassis, filename): 47 | '''Loads the pulse sequence from a file into the AWG's. 48 | Params: 49 | chassis: The chassis object where the waveforms are to be loaded and 50 | queued. 51 | filename: The filename (and path) where the json file containing the 52 | experiment is stored. 53 | ''' 54 | pulse_sequence = KeysightPulseSequence() 55 | with open(filename) as f: 56 | pulse_sequence._dict = json.load(f) 57 | pulse_sequence.loadToExperiment(chassis) 58 | 59 | def loadToExperiment(self, chassis): 60 | '''Loads a pulse sequence object directly into the AWG's. 61 | Params: 62 | chassis: The chassis object where the waveforms are to be loaded and 63 | queued.''' 64 | for serialized_channel in self._dict: 65 | (chassis_number, slot_number, 66 | channel_number) = key.Tools.deserializeChannel(serialized_channel) 67 | channel = chassis.getChannel(slot_number, channel_number) 68 | waveform = key.Waveform(self._dict[serialized_channel]) 69 | waveform.loadToModule(channel.getModule()) 70 | waveform.queue(channel, trigger_mode = SD1.SD_TriggerModes.SWHVITRIG) 71 | -------------------------------------------------------------------------------- /slab/experiments/HVIExperiments/Test2/TestExperiment2.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | Created on Wed Aug 29 16:39:57 2018 4 | 5 | @author: slab 6 | """ 7 | import numpy as np 8 | import slab.experiments.HVIExperiments.HVIExpLib as exp 9 | from slab.instruments.keysight import KeysightLib as key 10 | import os 11 | 12 | 13 | class TestExperiment2(exp.HVIEnabledQubitExperiment): 14 | 15 | def __init__(self): 16 | exp.HVIEnabledQubitExperiment.__init__(self, liveplot_enabled = False, 17 | save_in_register = True) 18 | #data_channel = self.getChannel(10, 1) 19 | #self.addChannelToListen(data_channel) 20 | #self.addWorkers(exp.Saver(data_channel, r"C:\Users\slab\keysight_test_data", "testdata", 21 | #name = "SAVER")) 22 | 23 | def buildHVIPulseSequence(self): 24 | return TestPulseSequence2() 25 | 26 | 27 | def pre_run(self): 28 | #configure AWG; defaults OK 29 | self.getChannel(6, 1).configure() 30 | #configure digitizer 31 | self.getChannel(10, 1).configure( 32 | points_per_cycle = 5000, 33 | cycles = 100000, 34 | use_buffering = False, 35 | cycles_per_return = 10) 36 | 37 | 38 | class TestPulseSequence2(exp.HVIPulseSequence): 39 | 40 | def __init__(self): 41 | '''Initializes the pulse sequence''' 42 | path = r"C:\_Lib\python\slab\experiments\HVIExperiments" 43 | exp.HVIPulseSequence.__init__(self, 44 | HVI_file = os.path.join(path, r"Test2\TestExperiment2.HVI"), 45 | module_config_file = os.path.join(path, r"default_hardware.keycfg")) 46 | 47 | '''for i in range(1000): 48 | pass 49 | 50 | 51 | self.addWaveform(key.Waveform(arr = np.ones(1000), 52 | waveform_number = 1, 53 | append_zero = True), 54 | modules = [6]) 55 | self.addWaveform(key.Waveform(arr = np.arange(0, 1, .001), 56 | waveform_number = 2, 57 | append_zero = True), 58 | modules = [6])''' 59 | 60 | for i, elem in enumerate(make_pulses()): 61 | self.addWaveform(key.Waveform(arr = elem, waveform_number = i, 62 | append_zero = True), modules = [6]) 63 | 64 | def gaussian(amplitude, mu, sigma, x): 65 | return amplitude*np.exp(-(x-mu)**2 / (2*sigma**2)) 66 | 67 | def make_pulses(): 68 | x=np.arange(0,600,1) 69 | 70 | return [gaussian(ii/100.,300,100,x) for ii in range(100)] 71 | 72 | 73 | #print(gaussian(1,50,10,x)) 74 | 75 | 76 | if __name__ == "__main__": 77 | exp = TestExperiment2() 78 | exp.go() 79 | 80 | 81 | 82 | #def gaussian_wave(amplitude=1, mu, sigma, num_points=600): 83 | # return np.array(list(map(gaussian, x))) 84 | 85 | -------------------------------------------------------------------------------- /slab/experiments/HVIExperiments/Test/TestExperiment.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | Created on Wed Aug 29 16:39:57 2018 4 | 5 | @author: Josie Meyer 6 | 7 | Test experiment that extends HVIEnabledQubitExperiment. Mainly to test functionality, 8 | does not do anything scientificalyl interesting. However, it shows how to build an 9 | HVIEnabledQubitExperiment subclass, so I have kept it. 10 | 11 | DEBUG: Currently the digitizers do not work. Need to figure out why. 12 | """ 13 | import numpy as np 14 | import slab.experiments.HVIExperiments.HVIExpLib as exp 15 | from slab.instruments.keysight import KeysightLib as key 16 | import os 17 | 18 | 19 | class TestExperiment(exp.HVIEnabledQubitExperiment): 20 | '''A test extension of HVIEnabledQubitExperiment. Shows largely how to 21 | extend the class and what can be modified. (Note: can also extend post_run() 22 | analogous to pre_run())).''' 23 | 24 | def __init__(self): 25 | '''Add any data channels, workers, channels to listen''' 26 | exp.HVIEnabledQubitExperiment.__init__(self, liveplot_enabled = False, 27 | save_in_register = True) 28 | data_channel = self.getChannel(10, 1) 29 | self.addChannelToListen(data_channel) 30 | self.addWorkers(exp.Saver(data_channel, r"C:\Users\slab\keysight_test_data", "testdata", 31 | name = "SAVER")) 32 | 33 | def buildHVIPulseSequence(self): 34 | '''Specify the pulse sequence''' 35 | return TestPulseSequence() 36 | 37 | 38 | def pre_run(self): 39 | '''Example pre_run code. Mostly for configuration.''' 40 | #configure AWG; defaults OK for now 41 | self.getChannel(6, 1).configure() 42 | #configure digitizer 43 | self.getChannel(10, 1).configure( 44 | points_per_cycle = 5000, 45 | cycles = 100000, 46 | use_buffering = False, #must be false 47 | cycles_per_return = 10) 48 | 49 | 50 | class TestPulseSequence(exp.HVIPulseSequence): 51 | 52 | def __init__(self): 53 | '''Initializes the pulse sequence. Here we only add two waveforms. 54 | Note that we have specified an HVI file and a .keycfg hardware file.''' 55 | path = r"C:\_Lib\python\slab\experiments\HVIExperiments" 56 | exp.HVIPulseSequence.__init__(self, 57 | HVI_file = os.path.join(path, r"Test\TestExperimentHVI.HVI"), 58 | module_config_file = os.path.join(path, r"default_hardware.keycfg")) 59 | self.addWaveform(key.Waveform(arr = np.ones(1000), 60 | waveform_number = 1, 61 | append_zero = True), 62 | modules = [6]) 63 | self.addWaveform(key.Waveform(arr = np.arange(0, 1, .001), 64 | waveform_number = 2, 65 | append_zero = True), 66 | modules = [6]) 67 | 68 | 69 | if __name__ == "__main__": 70 | exp = TestExperiment() 71 | exp.go() #will run experiment, just like the Experiment class 72 | -------------------------------------------------------------------------------- /slab/instruments/TempScanner.py: -------------------------------------------------------------------------------- 1 | """ 2 | This is a driver for the AG/HP 34970 Scanner. This scanner mainframe is designed for three independant and configurable 3 | cards. The driver is written with base functionality using a 16 channel temperature/voltage measurement card. 4 | 5 | Author: Andrew Oriani 6 | 7 | """ 8 | 9 | import slab 10 | from slab import * 11 | import numpy as np 12 | import time 13 | from slab.instruments import SerialInstrument 14 | 15 | 16 | class HP34970A(SerialInstrument): 17 | def __init__(self, name="", address='COM23', enabled=True, timeout=.5): 18 | self.query_sleep=.01 19 | self.timeout=timeout 20 | self.recv_length=1024 21 | self.term_char='\r\n' 22 | self.therm_type=['TC', 'K'] 23 | SerialInstrument.__init__(self, name, address, enabled, timeout, baudrate=115200, query_sleep=self.query_sleep) 24 | 25 | def c_query(self, cmd, bit_len=1024): 26 | self.ser.write(str(cmd+self.term_char).encode()) 27 | time.sleep(self.query_sleep) 28 | mes=self.ser.read(bit_len) 29 | return mes.decode().split('\r\n')[0] 30 | 31 | def get_id(self): 32 | return self.c_query('*IDN?', bit_len=33) 33 | 34 | def ch_list(self, ch, card=1): 35 | if type(ch)==list: 36 | ch_list="@" 37 | for chs in ch: 38 | ch_val=str(card)+'{:>02d}'.format(chs)[0::]+',' 39 | ch_list+=ch_val 40 | return ch_list[0:-1] 41 | elif type(ch)==int: 42 | ch_list="@%s"%(str(card)+'{:>02d}'.format(ch)[0::]) 43 | return ch_list 44 | 45 | def val_unpack(self, val): 46 | return list(map(float, val.split(','))) 47 | 48 | def get_temp(self, ch, sens="TC", t_type='K', card=1): 49 | if type(ch)!=list: 50 | ch=[ch] 51 | else: 52 | pass 53 | val=self.c_query("MEAS:TEMP? %s, %s, (%s)"%(sens, t_type, self.ch_list(ch, card)), bit_len=len(ch)*16+1) 54 | return self.val_unpack(val) 55 | 56 | def conf_temp_tcouple(self, ch, t_type='K', card=1): 57 | type_list=['B', 'E', 'K', 'J', 'N', 'R', 'S', 'T'] 58 | if type(ch)!=list: 59 | ch=[ch] 60 | else: 61 | pass 62 | if t_type in type_list: 63 | self.write('CONF:TEMP TC,%s, (%s)'%(t_type, self.ch_list(ch, card))) 64 | else: 65 | raise Exception('Invalid thermocouple type') 66 | 67 | def read_chs(self, trig=None): 68 | if trig==None: 69 | trig='IMM' 70 | self.write('TRIG:SOUR %s'%trig) 71 | val=self.c_query('READ?') 72 | return self.val_unpack(val) 73 | 74 | def get_ch_config(self, ch, card=1): 75 | return self.c_query("CONF? (%s)"%(self.ch_list(ch, card))).split("\"")[1::2] 76 | 77 | def conf_temp_unit(self, ch, unit='C', card=1): 78 | unit_type=['C', 'F', 'K'] 79 | if unit in unit_type: 80 | self.write("UNIT:TEMP %s, (%s)"%(unit, self.ch_list(ch, card))) 81 | else: 82 | raise Exception("Invalid temperature unit, must be C (default), F, or K") 83 | 84 | def get_temp_unit(self, ch, card=1): 85 | return self.c_query("UNIT:TEMP? (%s)"%(self.ch_list(ch)), bit_len=3).split(',') 86 | 87 | def abort(self): 88 | self.write('ABOR') 89 | 90 | 91 | -------------------------------------------------------------------------------- /examples/qiskit/rfsoc/config.yaml: -------------------------------------------------------------------------------- 1 | %YAML 1.2 2 | --- 3 | ### PULSE BACKEND CONFIGURAITON ### 4 | # https://github.com/Qiskit/qiskit-terra/blob/main/ 5 | # qiskit/providers/models/backendconfiguration.py#L493 6 | backend_name: "RFSoC2" 7 | backend_version: "0.1" 8 | n_qubits: 2 9 | basis_gates: [] 10 | gates: [] 11 | local: true 12 | simulator: false 13 | conditional: true 14 | open_pulse: true 15 | memory: true 16 | # `max_shots` is unlimited in principle 17 | max_shots: 100000 18 | coupling_map: [[1], [0]] 19 | n_uchannels: 0 20 | u_channel_lo: [] 21 | meas_levels: [1] 22 | # `lo_range` is really the intermediate frequency output by the DDS of the RFSoC, which 23 | # is limited to 6.144 GHz 24 | qubit_lo_range: [[0, 6.144], [0, 6.144]] 25 | meas_lo_range: [[0, 6.144]] 26 | # 1 / 6.144 27 | dt: 0.162760416666667 28 | dtm: 0.162760416666667 29 | rep_times: [] 30 | meas_kernels: [] 31 | discriminators: [] 32 | dynamic_reprate_enabled: true 33 | # RFSoC master clock is 48-bit, so maximum delay in DAC (dt) units is 16 * (2^48) 34 | # 16 * (2^48) * dt * 1e-9 = 733 008 us 35 | # where dt is as in this config file, see above 36 | rep_delay_range: [0., 733008.] 37 | default_rep_delay: 0. 38 | # https://github.com/Qiskit/qiskit-terra/issues/6469 39 | parametric_pulses: ["constant", "gaussian", "gaussian_square"] 40 | processor_type: {} 41 | 42 | ### PULSE DEFAULTS ### 43 | # https://github.com/Qiskit/qiskit-terra/blob/main/ 44 | # qiskit/providers/models/pulsedefaults.py#L164 45 | # we use qubit_freq_est slightly differntly than was intended 46 | qubit_freq_est: [5., 6.] 47 | meas_freq_est: [8.] 48 | buffer: 0 49 | pulse_library: [] 50 | cmd_def: [] 51 | 52 | ### SLAB BACKEND ### 53 | # `shots_per_set` is limited by how many IQ points we can store in the 54 | # "AVG" portion of the average buffer, which is 2^14 = 16384 55 | default_shots_per_set: 1000 56 | log_level: 10 57 | log_path: "log" 58 | result_timeout: 86400 # 1 day in seconds 59 | result_timeout_sleep: 10 # 3600 # 1 hour in seconds 60 | 61 | ### RFSoC BACKEND ### 62 | ch_name_idx: { 63 | "d0": 4, # qubit 64 | "d1": 2, # cavity 65 | "m0": 3, # readout 66 | "a0": 0, # acquire readout 67 | "r0": 5, # readout dds 68 | } 69 | # TODO: this will be deprecated in a new firmware version 70 | ch_idx_rdds: { 71 | 3: 5, 72 | } 73 | ch_idx_page: { 74 | 0: 0, 75 | 1: 0, 76 | 2: 1, 77 | 3: 1, 78 | 4: 2, 79 | 5: 2 80 | } 81 | ch_idx_reg: [ 82 | # ch0 - page0 83 | {"out": 16}, 84 | # ch1 - page0 85 | {"freq": 24, "phase": 25, "addr": 26, "gain": 27, "mode": 28, "t": 29, "adc_freq": 30}, 86 | # ch2 - page1 87 | {"freq": 16, "phase": 17, "addr": 18, "gain": 19, "mode": 20, "t": 21, "adc_freq": 22}, 88 | # ch3 - page1 89 | {"freq": 24, "phase": 25, "addr": 26, "gain": 27, "mode": 28, "t": 29, "adc_freq": 30}, 90 | # ch4 - page2 91 | {"freq": 16, "phase": 17, "addr": 18, "gain": 19, "mode": 20, "t": 21, "adc_freq": 22}, 92 | # ch5 - page2 93 | {"freq": 24}, 94 | ] 95 | # miscellaneous tproc registers, access these lists with the same index 96 | misc_page: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] 97 | misc_reg: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15] 98 | tproc_initial_cycle_offset: 1000 99 | adc_trig_offset: 256 100 | acquire_pad: 10 101 | rfsoc_binary_file_path: "qsystem_0.bit" 102 | -------------------------------------------------------------------------------- /slab/instruments/awg/chase/test_chase_3.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | from slab.instruments import DAx22000, DAx22000Segment,Alazar 3 | from slab.instruments import InstrumentManager 4 | from slab import Experiment 5 | import matplotlib.pyplot as plt 6 | 7 | expt=Experiment(path=r'C:\_Lib\python\slab\instruments\awg\chase',config_file='config.json') 8 | 9 | expt.plotter.clear('dac1') 10 | expt.plotter.clear('dac2') 11 | 12 | dac = DAx22000('dac', '1') 13 | 14 | im=InstrumentManager() 15 | trig = im['trig'] 16 | 17 | print(dac.initialize(ext_clk_ref=False)) 18 | print(dac.set_clk_freq(freq=0.5e9)) 19 | 20 | xpts = np.arange(4096) 21 | ypts = np.ceil(2047.5 + 2047.5 * np.sin(2.0 * np.pi * xpts / (32))) 22 | print(ypts) 23 | print(dac.create_single_segment(1, 0, 2047, 2047, ypts, 1)) 24 | print(dac.place_mrkr2(1)) 25 | print(dac.set_ext_trig(ext_trig=True)) 26 | 27 | numsegs = 128 28 | segs = [] 29 | waveforms = [] 30 | segment_size = 1280 31 | 32 | def waveform_compressor(waveform): 33 | print("compressing") 34 | 35 | 36 | for ii in range(numsegs): 37 | # ii = numsegs - ii 38 | # gauss1=np.exp(-1.0 * (xpts - 1000) ** 2 / (2 * (2*ii+1) ** 2)) 39 | # cutoff1_1=0.5 * (np.sign(xpts-(1000 - 3*(2*ii+1))) + 1) 40 | # cutoff1_2=0.5 * (np.sign((1000 + 3*(2*ii+1)) - xpts) + 1) 41 | # cutoff_gauss1=np.array([a*b*c for a,b,c in zip(gauss1,cutoff1_1,cutoff1_2)]) 42 | # gauss2=np.exp(-1.0 * (xpts - 2500) ** 2 / (2 * (ii+1) ** 2)) 43 | # cutoff2_1=0.5 * (np.sign(xpts-(2500 - 3*(ii+1))) + 1) 44 | # cutoff2_2=0.5 * (np.sign((2500 + 3*(ii+1)) - xpts) + 1) 45 | # cutoff_gauss2=np.array([a*b*c for a,b,c in zip(gauss2,cutoff2_1,cutoff2_2)]) 46 | # waveform = 2047 + 2047*cutoff_gauss1#*np.exp(-1.0 * (xpts - 2000) ** 2 / (2 * (5*ii+1) ** 2)) #* 0.5 * (np.sign(xpts-2000 - 3*(5*ii+1)) + 1)#*0.5 * (np.sign(xpts-4000 - 3*(10*ii+1)) + 1) * 0.5 * (np.sign(4000 + 3*(10*ii+1) - xpts) + 1) 47 | # waveform += 2047*cutoff_gauss2 48 | # waveforms.append(waveform) 49 | # segs.append(DAx22000Segment(waveform, loops=0, triggered=True)) 50 | for jj in range(len(xpts)/segment_size): 51 | if jj==0: 52 | triggered = True 53 | else: 54 | triggered = True 55 | segs.append(DAx22000Segment(xpts[jj*segment_size:(jj+1)*segment_size] * 4095.0 / max(xpts) * ii / numsegs, loops=0, triggered=triggered)) 56 | 57 | print(len(segs)) 58 | dac.create_segments(chan=1, segments=segs, loops=0) 59 | dac.create_segments(chan=2, segments=segs, loops=0) 60 | 61 | print(dac.set_ext_trig(ext_trig=True)) 62 | print(dac.run(trigger_now=False)) 63 | 64 | expt.cfg['alazar']["samplesPerRecord"]=8192 65 | expt.cfg['alazar']["recordsPerBuffer"]=numsegs 66 | expt.cfg['alazar']["recordsPerAcquisition"]=numsegs 67 | adc = Alazar(expt.cfg['alazar']) 68 | 69 | #expt.awg.stop() 70 | trig.set_output(True) 71 | 72 | def trig_stop(): 73 | trig.set_output(False) 74 | dac.stop() 75 | print("trig stop") 76 | 77 | def trig_start(): 78 | trig.set_output(True) 79 | dac.run(trigger_now=False) 80 | print("trig start") 81 | 82 | tpts, ch1_pts, ch2_pts = adc.acquire_avg_data_by_record(prep_function=None, start_function=None) 83 | 84 | #trig.set_output(False) 85 | 86 | 87 | dac.stop() 88 | dac.close() 89 | 90 | expt.plotter.plot_z('dac1',ch1_pts) 91 | expt.plotter.plot_z('dac2',ch2_pts) 92 | expt.plotter.plot_z('waveforms',waveforms) 93 | 94 | 95 | 96 | 97 | 98 | 99 | -------------------------------------------------------------------------------- /slab/experiments/Rodin Furnace/Instruments/TempScanner.py: -------------------------------------------------------------------------------- 1 | """ 2 | This is a driver for the AG/HP 34970 Scanner. This scanner mainframe is designed for three independant and configurable 3 | cards. The driver is written with base functionality using a 16 channel temperature/voltage measurement card. 4 | 5 | Author: Andrew Oriani 6 | 7 | """ 8 | 9 | import slab 10 | from slab import * 11 | import numpy as np 12 | import time 13 | from slab.instruments import SerialInstrument 14 | 15 | 16 | class HP34970A(SerialInstrument): 17 | def __init__(self, name="", address='COM23', enabled=True, timeout=.5): 18 | self.query_sleep=.01 19 | self.timeout=timeout 20 | self.recv_length=1024 21 | self.term_char='\r\n' 22 | self.therm_type=['TC', 'K'] 23 | SerialInstrument.__init__(self, name, address, enabled, timeout, baudrate=115200, query_sleep=self.query_sleep) 24 | 25 | def c_query(self, cmd, bit_len=1024): 26 | self.ser.write(str(cmd+self.term_char).encode()) 27 | time.sleep(self.query_sleep) 28 | mes=self.ser.read(bit_len) 29 | return mes.decode().split('\r\n')[0] 30 | 31 | def get_id(self): 32 | return self.c_query('*IDN?', bit_len=33) 33 | 34 | def ch_list(self, ch, card=1): 35 | if type(ch)==list: 36 | ch_list="@" 37 | for chs in ch: 38 | ch_val=str(card)+'{:>02d}'.format(chs)[0::]+',' 39 | ch_list+=ch_val 40 | return ch_list[0:-1] 41 | elif type(ch)==int: 42 | ch_list="@%s"%(str(card)+'{:>02d}'.format(ch)[0::]) 43 | return ch_list 44 | 45 | def val_unpack(self, val): 46 | return list(map(float, val.split(','))) 47 | 48 | def get_temp(self, ch, sens="TC", t_type='K', card=1): 49 | if type(ch)!=list: 50 | ch=[ch] 51 | else: 52 | pass 53 | val=self.c_query("MEAS:TEMP? %s, %s, (%s)"%(sens, t_type, self.ch_list(ch, card)), bit_len=len(ch)*16+1) 54 | return self.val_unpack(val) 55 | 56 | def conf_temp_tcouple(self, ch, t_type='K', card=1): 57 | type_list=['B', 'E', 'K', 'J', 'N', 'R', 'S', 'T'] 58 | if type(ch)!=list: 59 | ch=[ch] 60 | else: 61 | pass 62 | if t_type in type_list: 63 | self.write('CONF:TEMP TC,%s, (%s)'%(t_type, self.ch_list(ch, card))) 64 | else: 65 | raise Exception('Invalid thermocouple type') 66 | 67 | def read_chs(self, trig=None): 68 | if trig==None: 69 | trig='IMM' 70 | self.write('TRIG:SOUR %s'%trig) 71 | val=self.c_query('READ?') 72 | return self.val_unpack(val) 73 | 74 | def get_ch_config(self, ch, card=1): 75 | return self.c_query("CONF? (%s)"%(self.ch_list(ch, card))).split("\"")[1::2] 76 | 77 | def conf_temp_unit(self, ch, unit='C', card=1): 78 | unit_type=['C', 'F', 'K'] 79 | if unit in unit_type: 80 | self.write("UNIT:TEMP %s, (%s)"%(unit, self.ch_list(ch, card))) 81 | else: 82 | raise Exception("Invalid temperature unit, must be C (default), F, or K") 83 | 84 | def get_temp_unit(self, ch, card=1): 85 | return self.c_query("UNIT:TEMP? (%s)"%(self.ch_list(ch)), bit_len=3).split(',') 86 | 87 | def abort(self): 88 | self.write('ABOR') 89 | 90 | 91 | -------------------------------------------------------------------------------- /slab/instruments/awg/chase/test_chase_4.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | from slab.instruments import DAx22000, DAx22000Segment,Alazar 3 | from slab.instruments import InstrumentManager 4 | from slab import Experiment 5 | import matplotlib.pyplot as plt 6 | 7 | expt=Experiment(path=r'C:\_Lib\python\slab\instruments\awg\chase',config_file='config.json') 8 | 9 | expt.plotter.clear('dac1') 10 | expt.plotter.clear('dac2') 11 | 12 | #dac = DAx22000('dac', '1') 13 | 14 | im=InstrumentManager() 15 | trig = im['trig'] 16 | 17 | # print dac.initialize(ext_clk_ref=False) 18 | # print dac.set_clk_freq(freq=0.5e9) 19 | 20 | # xpts = np.arange(6400) 21 | # ypts = np.ceil(2047.5 + 2047.5 * np.sin(2.0 * np.pi * xpts / (32))) 22 | # print ypts 23 | # print dac.create_single_segment(1, 0, 2047, 2047, ypts, 1) 24 | # print dac.place_mrkr2(1) 25 | # print dac.set_ext_trig(ext_trig=True) 26 | # 27 | numsegs = 200 28 | # segs = [] 29 | # waveforms = [] 30 | # segment_size = 640 31 | # 32 | # def waveform_compressor(waveform): 33 | # print "compressing" 34 | # 35 | # 36 | # for ii in range(numsegs): 37 | # # ii = numsegs - ii 38 | # # gauss1=np.exp(-1.0 * (xpts - 1000) ** 2 / (2 * (2*ii+1) ** 2)) 39 | # # cutoff1_1=0.5 * (np.sign(xpts-(1000 - 3*(2*ii+1))) + 1) 40 | # # cutoff1_2=0.5 * (np.sign((1000 + 3*(2*ii+1)) - xpts) + 1) 41 | # # cutoff_gauss1=np.array([a*b*c for a,b,c in zip(gauss1,cutoff1_1,cutoff1_2)]) 42 | # # gauss2=np.exp(-1.0 * (xpts - 2500) ** 2 / (2 * (ii+1) ** 2)) 43 | # # cutoff2_1=0.5 * (np.sign(xpts-(2500 - 3*(ii+1))) + 1) 44 | # # cutoff2_2=0.5 * (np.sign((2500 + 3*(ii+1)) - xpts) + 1) 45 | # # cutoff_gauss2=np.array([a*b*c for a,b,c in zip(gauss2,cutoff2_1,cutoff2_2)]) 46 | # # waveform = 2047 + 2047*cutoff_gauss1#*np.exp(-1.0 * (xpts - 2000) ** 2 / (2 * (5*ii+1) ** 2)) #* 0.5 * (np.sign(xpts-2000 - 3*(5*ii+1)) + 1)#*0.5 * (np.sign(xpts-4000 - 3*(10*ii+1)) + 1) * 0.5 * (np.sign(4000 + 3*(10*ii+1) - xpts) + 1) 47 | # # waveform += 2047*cutoff_gauss2 48 | # # waveforms.append(waveform) 49 | # # segs.append(DAx22000Segment(waveform, loops=0, triggered=True)) 50 | # for jj in range(len(xpts)/segment_size): 51 | # if jj==0: 52 | # triggered = True 53 | # else: 54 | # triggered = True 55 | # segs.append(DAx22000Segment(xpts[jj*segment_size:(jj+1)*segment_size] * 4095.0 / max(xpts) * ii / numsegs, loops=0, triggered=triggered)) 56 | # 57 | # 58 | # dac.create_segments(chan=1, segments=segs, loops=0) 59 | # dac.create_segments(chan=2, segments=segs, loops=0) 60 | # 61 | # print dac.set_ext_trig(ext_trig=True) 62 | # print dac.run(trigger_now=False) 63 | 64 | expt.cfg['alazar']["samplesPerRecord"]=8192 65 | expt.cfg['alazar']["recordsPerBuffer"]=numsegs 66 | expt.cfg['alazar']["recordsPerAcquisition"]=numsegs 67 | adc = Alazar(expt.cfg['alazar']) 68 | 69 | #expt.awg.stop() 70 | trig.set_output(True) 71 | 72 | def trig_stop(): 73 | trig.set_output(False) 74 | dac.stop() 75 | print("trig stop") 76 | 77 | def trig_start(): 78 | trig.set_output(True) 79 | dac.run(trigger_now=False) 80 | print("trig start") 81 | 82 | tpts, ch1_pts, ch2_pts = adc.acquire_avg_data_by_record(prep_function=None, start_function=None) 83 | 84 | #trig.set_output(False) 85 | 86 | 87 | # dac.stop() 88 | # dac.close() 89 | 90 | expt.plotter.plot_z('dac1',ch1_pts) 91 | expt.plotter.plot_z('dac2',ch2_pts) 92 | expt.plotter.plot_z('waveforms',waveforms) 93 | 94 | 95 | 96 | 97 | 98 | 99 | -------------------------------------------------------------------------------- /slab/instruments/KEPCOPowerSupply.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | KEPCO Power Supply (KEPCOPowerSupply.py) 4 | ======================================== 5 | :Author: David Schuster 6 | """ 7 | from slab.instruments import SerialInstrument 8 | import time 9 | from numpy import linspace 10 | 11 | class KEPCOPowerSupply(SerialInstrument): 12 | 13 | def __init__(self,name="Kepco",address='COM4',enabled=True,timeout=1): 14 | #if ':' not in address: address+=':22518' 15 | if address[:3].upper()=='COM': 16 | SerialInstrument.__init__(self,name,address,enabled,timeout) 17 | self.query_sleep=0.05 18 | self.recv_length=65536 19 | self.Remote() 20 | 21 | def get_id(self): 22 | return self.query('*IDN?') 23 | 24 | def Remote(self): 25 | self.write('SYST:REM 1') 26 | 27 | def Local(self): 28 | self.write('SYST:REM 0') 29 | 30 | def set_output(self,output=True): 31 | if output: 32 | self.write('OUTP 1') 33 | else: 34 | self.write('OUTP 0') 35 | 36 | def set_voltage(self,v): 37 | if self.protocol == 'serial': 38 | self.write('VOLT %f'%v) 39 | 40 | def get_voltage(self): 41 | return float(self.query('VOLT?').strip("\x13\r\n\x11")) 42 | 43 | def set_current(self,c): 44 | self.write('CURR %f'%c) 45 | 46 | def ramp_to_current(self,c,sweeprate=None): 47 | if sweeprate is None: 48 | sweeprate=self.sweeprate 49 | 50 | start=self.get_current() 51 | stop=c 52 | start_t=time.time() 53 | self.set_current(start) 54 | time.sleep(self.query_sleep) 55 | step_t=time.time()-start_t 56 | total_t=abs(stop-start)/sweeprate 57 | steps=total_t/step_t 58 | 59 | for ii in linspace(start,stop,steps): 60 | self.set_current(ii) 61 | time.sleep(self.query_sleep) 62 | 63 | def get_current(self): 64 | count = 0 65 | 66 | while (count<20): 67 | try: 68 | current_value = self.query('CURR?').strip("\x13\r\n\x11") 69 | if type(current_value)==float: 70 | return float(current_value) 71 | elif type(current_value)==str: 72 | "Converting from String to Float." 73 | current_value = float(current_value) 74 | return current_value 75 | else: 76 | print("The Machine didn't return a float") 77 | print(current_value) 78 | print(type(current_value)) 79 | except: 80 | print("Getting the current again...") 81 | count+=1 82 | time.sleep(1) 83 | raise Exception("The Machine wouldn't return a floating number. Try smacking it.") 84 | 85 | return float(current_value) 86 | 87 | def set_current_mode(self): 88 | self.write('FUNC:MODE CURR') 89 | 90 | def set_voltage_mode(self): 91 | self.write('FUNC:MODE VOLT') 92 | 93 | 94 | if __name__ == '__main__': 95 | p=KEPCOPowerSupply(address="COM6") 96 | 97 | #magnet.set_local() 98 | #print fridge.get_status() 99 | #d=fridge.get_temperatures() 100 | #print fridge.get_temperatures() 101 | #print fridge.get_settings() 102 | 103 | -------------------------------------------------------------------------------- /slab/experiment.py: -------------------------------------------------------------------------------- 1 | __author__ = 'Nitrogen' 2 | 3 | # from liveplot import LivePlotClient 4 | # from dataserver import dataserver_client 5 | import os.path 6 | import json 7 | 8 | from slab import SlabFile, InstrumentManager, get_next_filename, AttrDict, LocalInstruments 9 | 10 | 11 | class Experiment: 12 | """Base class for all experiments""" 13 | 14 | def __init__(self, path='', prefix='data', config_file=None, liveplot_enabled=True, **kwargs): 15 | """ Initializes experiment class 16 | @param path - directory where data will be stored 17 | @param prefix - prefix to use when creating data files 18 | @param config_file - parameters for config file specified are loaded into the class dict 19 | (name relative to expt_directory if no leading /) 20 | Default = None looks for path/prefix.json 21 | 22 | @param **kwargs - by default kwargs are updated to class dict 23 | 24 | also loads InstrumentManager, LivePlotter, and other helpers 25 | """ 26 | self.__dict__.update(kwargs) 27 | self.path = path 28 | self.prefix = prefix 29 | self.cfg = None 30 | if config_file is not None: 31 | self.config_file = os.path.join(path, config_file) 32 | else: 33 | self.config_file = None 34 | self.im = InstrumentManager() 35 | # if liveplot_enabled: 36 | # self.plotter = LivePlotClient() 37 | # self.dataserver= dataserver_client() 38 | self.fname = os.path.join(path, get_next_filename(path, prefix, suffix='.h5')) 39 | 40 | self.load_config() 41 | 42 | def load_config(self): 43 | if self.config_file is None: 44 | self.config_file = os.path.join(self.path, self.prefix + ".json") 45 | try: 46 | if self.config_file[:-3] == '.h5': 47 | with SlabFile(self.config_file) as f: 48 | cfg_str = f['config'] 49 | else: 50 | with open(self.config_file, 'r') as fid: 51 | cfg_str = fid.read() 52 | 53 | self.cfg = AttrDict(json.loads(cfg_str)) 54 | except: 55 | pass 56 | if self.cfg is not None: 57 | for alias, inst in self.cfg['aliases'].items(): 58 | setattr(self, alias, self.im[inst]) 59 | 60 | def save_config(self): 61 | if self.config_file[:-3] != '.h5': 62 | with open(self.config_file, 'w') as fid: 63 | json.dump(self.cfg, fid) 64 | self.datafile().attrs['config'] = json.dumps(self.cfg) 65 | 66 | def datafile(self, group=None, remote=False, data_file = None, swmr=False): 67 | """returns a SlabFile instance 68 | proxy functionality not implemented yet""" 69 | if data_file ==None: 70 | data_file = self.fname 71 | if swmr==True: 72 | f = SlabFile(data_file, 'w', libver='latest') 73 | elif swmr==False: 74 | f = SlabFile(data_file) 75 | else: 76 | raise Exception('ERROR: swmr must be type boolean') 77 | 78 | if group is not None: 79 | f = f.require_group(group) 80 | if 'config' not in f.attrs: 81 | try: 82 | f.attrs['config'] = json.dumps(self.cfg) 83 | except TypeError as err: 84 | print(('Error in saving cfg into datafile (experiment.py):', err)) 85 | 86 | return f 87 | 88 | def go(self): 89 | pass 90 | 91 | 92 | -------------------------------------------------------------------------------- /examples/qiskit/rfsoc/user.py: -------------------------------------------------------------------------------- 1 | """ 2 | user.py 3 | """ 4 | 5 | import time 6 | 7 | import h5py 8 | import numpy as np 9 | import matplotlib as mpl 10 | mpl.use("Agg") 11 | import matplotlib.pyplot as plt 12 | from slab import generate_file_path 13 | from slab.instruments.qiskit import SLabProviderInterface 14 | from qiskit import pulse 15 | from qiskit.providers.jobstatus import JOB_FINAL_STATES 16 | from qiskit.qobj.utils import MeasLevel, MeasReturnType 17 | 18 | DPI = 300 19 | 20 | # unit conversion factors -> all backend properties returned in SI (Hz, sec, etc) 21 | GHz = 1.0e9 #Hz 22 | MHz = 1.0e6 #Hz 23 | us = 1.0e-6 #s 24 | ns = 1.0e-9 #s 25 | 26 | def get_closest_multiple_of_16(num): 27 | return int(num + 8 ) - (int(num + 8 ) % 16) 28 | #ENDDEF 29 | 30 | def rs(plot=True): 31 | provider = SLabProviderInterface() 32 | backend = provider.get_backend("RFSoC2") 33 | backend_config = backend.configuration() 34 | backend_defaults = backend.defaults() 35 | dt = backend_config.dt #s 36 | 37 | qubit_chan = pulse.DriveChannel(0) 38 | cavity_chan = pulse.DriveChannel(1) 39 | meas_chan = pulse.MeasureChannel(0) 40 | acq_chan = pulse.AcquireChannel(0) 41 | 42 | meas_amp = 0.125 43 | meas_duration = get_closest_multiple_of_16(32000) #dts 44 | meas_pulse = pulse.library.Constant(meas_duration, meas_amp) 45 | 46 | meas_freq_count = 100 47 | meas_freq_start = 90 * MHz #Hz 48 | meas_freq_stop = 110 * MHz #Hz 49 | meas_freqs = np.linspace(meas_freq_start, meas_freq_stop, meas_freq_count) 50 | 51 | schedule = pulse.Schedule(name="Frequency sweep") 52 | schedule += pulse.Play(meas_pulse, meas_chan) 53 | schedule += pulse.Acquire(meas_duration, acq_chan, pulse.MemorySlot(0)) 54 | 55 | # fig = schedule.draw() 56 | # plot_file_path = generate_file_path(".", "rs_sched", "png") 57 | # plt.savefig(plot_file_path) 58 | # print(f"plotted schedule to {plot_file_path}") 59 | 60 | num_shots = 1000 61 | rep_delay = 10 * us #s 62 | schedule_los = list() 63 | for meas_freq in meas_freqs: 64 | schedule_los.append({ 65 | meas_chan: meas_freq, 66 | }) 67 | #ENDFOR 68 | 69 | job = backend.run( 70 | schedule, meas_level=MeasLevel.KERNELED, 71 | meas_return=MeasReturnType.AVERAGE, shots=num_shots, 72 | schedule_los=schedule_los, 73 | rep_delay=rep_delay, 74 | shots_per_set=10, 75 | ) 76 | 77 | job.wait_for_final_state() 78 | result = job.result() 79 | 80 | # parse data 81 | data = np.zeros(meas_freq_count, dtype=np.complex128) 82 | amp_data = np.zeros(meas_freq_count, dtype=np.complex128) 83 | for i in range(meas_freq_count): 84 | data[i] = result.get_memory(i)[0] 85 | amp_data[i] = abs(data) 86 | #ENDFOR 87 | 88 | if plot: 89 | meas_freqs_Hz = meas_freqs / MHz 90 | fig = plt.figure() 91 | # plt.plot(meas_freqs_Hz, data.real, label="I") 92 | # plt.plot(meas_freqs_Hz, data.imag, label="Q") 93 | plt.plot(meas_freqs_Hz, amp_data) 94 | plt.scatter(meas_freqs_Hz, amp_data, label="A") 95 | plt.xlabel("DDS Frequency (MHz)") 96 | plt.ylabel("V (a.u.)") 97 | plt.legend() 98 | plot_file_path = generate_file_path(".", "t1_rs", "png") 99 | plt.savefig(plot_file_path, dpi=DPI) 100 | plt.close() 101 | print("plotted to {}".format(plot_file_path)) 102 | #ENDIF 103 | 104 | return result 105 | #ENDDEF 106 | 107 | def main(): 108 | rs() 109 | #ENDDEF 110 | 111 | if __name__ == "__main__": 112 | main() 113 | #ENDIF 114 | -------------------------------------------------------------------------------- /slab/instruments/RCA18.py: -------------------------------------------------------------------------------- 1 | __author__ = 'Aman LaChapelle' 2 | 3 | from urllib.request import urlopen 4 | from math import * 5 | from slab import * 6 | from slab.instruments import SocketInstrument 7 | 8 | class MCRCA18(SocketInstrument): 9 | 10 | def __init__(self, name = "MCRCA18", address = "192.168.14.138:80"): 11 | SocketInstrument.__init__(self, name = name, address = '192.168.14.138:80') 12 | self.tcp_ip = address.split(":")[0] 13 | self.tcp_port = int(address.split(":")[1]) 14 | 15 | def send_command(self, command = None, show = True): 16 | response = urlopen('http://%s:%d/%s' % (self.tcp_ip, self.port, command)) 17 | if show == True: 18 | print(response.read()) 19 | 20 | def get_largest(self): 21 | counter = [] 22 | for i in range(7, 0, -1): 23 | try: 24 | ports_open = int(log(self.ports_copy, 2)) 25 | counter.append(ports_open) 26 | except ValueError: 27 | pass 28 | return counter[0] 29 | 30 | def ports_one(self): 31 | response = urlopen('http://%s:%d/SWPORT?' % (self.tcp_ip, self.port)) 32 | ports = int(response.read()) 33 | if ports == 0: 34 | return "None" # edit this for the new array 35 | if ports != 0: 36 | ports_open = [] 37 | possible = {0:'A', 1:'B', 2:'C', 3:'D', 4:'E', 5:'F', 6:'G', 7:'H'} 38 | open_ports = [] 39 | self.ports_copy = ports 40 | while self.ports_copy != 0: 41 | largest = self.get_largest() 42 | open_ports.append(largest) 43 | self.ports_copy -= 2**largest 44 | for i in range(0, len(open_ports)): 45 | ports_open.append(possible[open_ports[i]]) 46 | return ports_open 47 | 48 | def switch_port(self, ports): 49 | ports_open = self.ports_one() 50 | for port in ports: 51 | if port in ports_open: 52 | self.send_command("SET%s=0" % port, show = False) 53 | else: 54 | self.send_command("SET%s=1" % port, show = False) 55 | return 0 56 | 57 | def all_to_zero(self): 58 | tmp = self.ports_one() 59 | if tmp == "None": 60 | return 0 61 | else: 62 | self.switch_port(tmp) 63 | return 0 64 | 65 | # Will need to change these as the diagram changes to make sure the switching still works. 66 | # As in lab notebook, cavities indexed 0-7 not 1-8 67 | def measure_cavity(self, number): 68 | binary_rep = "{0:03b}".format(number) 69 | 70 | possible = {'000':"", '001':"E", '010':"F", '011':["B", "F"], '100':"A", '101':["A", "D"],\ 71 | '110':["A", "C"], '111':["A", "C", "G"]} 72 | 73 | self.all_to_zero() 74 | self.switch_port(possible[binary_rep]) 75 | 76 | 77 | 78 | 79 | 80 | if __name__ == "__main__": 81 | print("Usage:\n>>> = rf_switch()\n>>> " \ 82 | ".ports_one()\n>>> .switch_port()" \ 83 | "\n>>> .send_command('')") 84 | print("Commands are here:\n" \ 85 | "http://www.minicircuits.com/softwaredownload/Prog_Manual-2-Switch.pdf\n" \ 86 | "Section 4.4") 87 | temp = MCRCA18() 88 | print(temp.ports_one()) 89 | temp.measure_cavity(3) 90 | print(temp.ports_one()) 91 | temp.all_to_zero() 92 | #command = raw_input("Enter a command: ") 93 | #temp.send_command(command, show = False) 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | -------------------------------------------------------------------------------- /slab/experiments/Nitrogen/ExpLib/awgpulses.py: -------------------------------------------------------------------------------- 1 | __author__ = 'dave' 2 | 3 | import numpy as np 4 | 5 | 6 | def sideband(t, plus, minus, freq=0, phase=0, offset=False, offset_fit_lin=0,offset_fit_quad=0,t0=0): 7 | if offset: 8 | if (not max(plus) == 0): 9 | time_step = t[1]-t[0] 10 | freq_calibrated = getFreq(plus,freq,offset_fit_lin,offset_fit_quad); 11 | freq_integ_array = np.cumsum(freq_calibrated)*time_step 12 | # np.savetxt('time.out', t, delimiter=',') 13 | return ( np.cos(2 * np.pi * (freq_integ_array/1.0e9) + phase*np.pi/180.0) * plus - np.cos(2 * np.pi * (freq_integ_array/1.0e9) + phase*np.pi/180.0) * minus, 14 | +np.sin(2 * np.pi * (freq_integ_array/1.0e9)+ phase*np.pi/180.0) * plus + np.sin(2 * np.pi * (freq_integ_array/1.0e9) + phase*np.pi/180.0) * minus) 15 | else: 16 | # For ML0218 Mixer 17 | return ( np.cos(2 * np.pi * (freq/1.0e9 * (t-t0))+ phase*np.pi/180.0) * plus - np.cos(2 * np.pi * (freq/1.0e9 * (t-t0)) + phase*np.pi/180.0) * minus, 18 | +np.sin(2 * np.pi * (freq/1.0e9 * (t-t0))+ phase*np.pi/180.0) * plus +np.sin(2 * np.pi * (freq/1.0e9 * (t-t0)) + phase*np.pi/180.0) * minus) 19 | # 20 | # For IQ0317 Mixer 21 | # return ( np.cos(2 * np.pi * (freq/1.0e9 * t)+ phase*np.pi/180.0) * plus - np.cos(2 * np.pi * (freq/1.0e9 * t) + phase*np.pi/180.0) * minus, 22 | # -np.sin(2 * np.pi * (freq/1.0e9 * t)+ phase*np.pi/180.0) * plus - np.sin(2 * np.pi * (freq/1.0e9 * t) + phase*np.pi/180.0) * minus) 23 | 24 | 25 | 26 | def getFreq(pulse,freq,offset_fit_lin=0,offset_fit_quad=0): 27 | #time is a point 28 | #pulse is an array 29 | 30 | abs_pulse = abs(pulse) 31 | max_a = max(abs_pulse) 32 | 33 | freq_list = freq + (offset_fit_lin*abs_pulse+offset_fit_quad*abs_pulse**2) - (offset_fit_lin*max_a+offset_fit_quad*max_a**2) 34 | freq_array = np.array(freq_list) 35 | 36 | ## This saves the freq and pulse data for the churpped pulse for analysis 37 | # if (not max_a == 0): 38 | # np.savetxt('freq.out', freq_array, delimiter=',') 39 | # np.savetxt('pulse.out', pulse, delimiter=',') 40 | # print "done" 41 | return freq_array 42 | 43 | 44 | def gauss(t, a, t0, sigma): 45 | if sigma >0: 46 | return (t >= t0-2*sigma) * (t <= t0+2*sigma)*a * np.exp(-1.0 * (t - t0) ** 2 / (2 * sigma ** 2)) 47 | else: 48 | return 0*(t-t0) 49 | 50 | 51 | def dgauss(t, a, t0, sigma): 52 | return a * np.exp(-1.0 * (t - t0) ** 2 / (2 * sigma ** 2)) * (t - t0) / sigma ** 2 53 | 54 | 55 | def ramp(t, a, t0, w): 56 | return a * (t - t0) * (t >= t0) * (t < t0 + w) 57 | 58 | 59 | def square(t, a, t0, w, sigma=0): 60 | if sigma>0: 61 | return a * ( 62 | (t >= t0) * (t < t0 + w) + # Normal square pulse 63 | (t >= t0-2*sigma) * (t < t0) * np.exp(-(t - t0) ** 2 / (2 * sigma ** 2)) + # leading gaussian edge 64 | (t >= t0 + w)* (t <= t0+w+2*sigma) * np.exp(-(t - (t0 + w)) ** 2 / (2 * sigma ** 2)) # trailing edge 65 | ) 66 | else: 67 | return a * (t >= t0) * (t < t0 + w) 68 | 69 | 70 | def trapezoid(t, a, t0, w, edge_time=0): 71 | return a * ( 72 | (t - t0) * (t >= t0) * (t < t0 + edge_time) + (t >= t0 + edge_time) * (t < t0 + edge_time + w) + ( 73 | t0 - t) * ( 74 | t >= t0 + w + edge_time) * ( 75 | t >= t0 + w + 2 * edge_time) ) 76 | 77 | 78 | def get_pulse_span_length(cfg, type, length, ramp_sigma = None): 79 | if type == "gauss": 80 | return length * 4 +cfg['spacing'] ## 4 sigma 81 | if type == "square": 82 | if ramp_sigma == None: 83 | return length + 4 * cfg[type]['ramp_sigma'] +cfg['spacing'] 84 | else: 85 | return length + 4 * ramp_sigma +cfg['spacing'] -------------------------------------------------------------------------------- /slab/widgets/widgets.py: -------------------------------------------------------------------------------- 1 | """ 2 | widgets -- Customized PyQt widgets 3 | 4 | A note on Qt Designer usage: In order to use these custom widgets in 5 | Qt Designer, first put a place holder widget (if applicable, a member 6 | of the base class of the widget being used), into your designed 7 | gui. Right click on the element, and select 'Promote to...', If the 8 | widget has not been previously promoted, write the widget name in the 9 | promoted class name field (e.g. SlabSpinBox), 'slab.h' in the header 10 | field (this will be appropriately translated by pyuic), and click 11 | 'add', then 'Promote'. 12 | """ 13 | 14 | from PyQt4.Qt import * 15 | import guiqwt.plot 16 | import math 17 | import re 18 | 19 | DEBUG = False 20 | if DEBUG: 21 | from PyQt4 import uic 22 | uifile = open("SweepDialog_ui.py", 'w') 23 | uic.compileUi("SweepDialog.ui", uifile) 24 | uifile.close() 25 | from .SweepDialog_ui import Ui_SweepDialog 26 | from .AlazarWidget_ui import Ui_AlazarForm 27 | import PyQt4.Qt as Qt 28 | import guiqwt.plot 29 | import guiqwt.builder 30 | 31 | class AlazarWidget(QWidget, Ui_AlazarForm): 32 | def __init__(self): 33 | QWidget.__init__(self) 34 | self.setupUi(self) 35 | 36 | class SweepDialog(QDialog, Ui_SweepDialog): 37 | def __init__(self): 38 | QDialog.__init__(self) 39 | self.setupUi(self) 40 | 41 | class SlabLinePlot(guiqwt.plot.CurvePlot): 42 | def __init__(self, ncurves=1): 43 | guiqwt.plot.CurvePlot.__init__(self) 44 | self.curves = [] 45 | for i in range(ncurves): 46 | c = guiqwt.builder.make([],[]) 47 | self.curves.append(c) 48 | self.add_item(c) 49 | def update_curve(x, y, curve_n=0): 50 | self.curves[curve_n].set_data(x,y) 51 | 52 | class SlabSpinBox(QDoubleSpinBox): 53 | def __init__(self, *args, **kwargs): 54 | self.precision = kwargs.pop('precision') if 'precision' in kwargs else 4 55 | QDoubleSpinBox.__init__(self, *args, **kwargs) 56 | self.maxv = 10 ** 3 57 | self.minv = 10 ** -2 58 | self.prefixes = { "n|nano" : 10 ** -9, 59 | "u|micro" : 10 ** -6, 60 | "milli" : 10 ** -3, 61 | "k|kilo" : 10 ** 3, 62 | "m|mega" : 10 ** 6, 63 | "g|giga" : 10 ** 9, 64 | "t|tera" : 10 ** 12, 65 | } 66 | pfkeys = "".join([ key for key in self.prefixes ]) 67 | self.RE = QRegExp( 68 | "^[\+-]?[0-9]+(\.[0-9]*)?(e[\+-]?[0-9]+|(" + "|".join(pfkeys) + "))?$", 69 | cs=Qt.CaseInsensitive) 70 | self.REValidator = QRegExpValidator(self.RE, self) 71 | 72 | def validate(self, text_, pos): 73 | return self.REValidator.validate(text_, pos) 74 | 75 | def valueFromText(self, text_): 76 | # Convert to python string for predictability 77 | text = str(text_).lower().replace(" ","") 78 | if QRegExp("^[\+-]?[0-9]+(\.[0-9]*)?$").exactMatch(text): 79 | return float(text) 80 | if QRegExp("^[\+-]?[0-9]+(\.[0-9]*)?e[\+-]?[0-9]+$").exactMatch(text): 81 | base, exp = text.split('e') 82 | return float(base) * (10 ** int(exp)) 83 | for p in self.prefixes: 84 | if QRegExp("^[\+-]?[0-9]+(\.[0-9]*)?(" + p + ")$").exactMatch(text): 85 | base = float("".join([ c for c in text if c.isdigit() or c == '.'])) 86 | return base * self.prefixes[p] 87 | return 0. 88 | 89 | 90 | def textFromValue(self, value): 91 | if value > self.maxv or value < self.minv: 92 | return QString(("%." + str(self.precision) + "e") % value) 93 | else: 94 | return QString(("%." + str(self.precision) + "f") % value) 95 | -------------------------------------------------------------------------------- /slab/instruments/spectrum_analyzer.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | Created on Thu Aug 18 14:32:54 2011 4 | 5 | @author: Dai 6 | """ 7 | from slab.instruments import SerialInstrument, SocketInstrument 8 | import time 9 | 10 | class SpectrumAnalyzer(SerialInstrument, SocketInstrument): 11 | #general design parameters 12 | #LO offset is 10.55MHz 13 | #LO power is 10dBm 14 | lo_power = 10 15 | #bandwidth is 180kHz 16 | bandwidth=180e3 17 | #calibration information 18 | #calibration_data = None 19 | #min_power = None 20 | #step = 10 21 | 22 | def __init__(self, name='spec_analyzer', protocol='socket', 23 | address='', port=23, enabled=True, timeout=.1, recv_length=1024, 24 | query_sleep=0.005, lo_power=10, lo_offset=10.55e6, baudrate=115200): 25 | 26 | self.lo_offset = lo_offset 27 | self.lo_power = lo_power 28 | 29 | if (address.count('.') == 3): 30 | #the address is in an IP address format 31 | self.protocol = 'socket' 32 | else: 33 | #otherwise we treat the address as port 34 | self.protocol = 'serial' 35 | if address != '': 36 | port = int(address) 37 | 38 | if self.protocol == 'serial': 39 | SerialInstrument.__init__(self, name, port, enabled, 40 | timeout, recv_length, baudrate=baudrate, querysleep=query_sleep) 41 | self.term_char = '' 42 | time.sleep(2) 43 | print(self.read()) 44 | elif self.protocol == 'socket': 45 | if ':' in address: 46 | SocketInstrument.__init__(self, name, address, enabled, 47 | timeout, recv_length) 48 | else: 49 | SocketInstrument.__init__(self, name, address+':'+str(port), enabled, 50 | timeout, recv_length) 51 | self.recv_length = recv_length 52 | self.term_char = '' 53 | self.query_sleep = query_sleep 54 | else: 55 | print('The protocol requested is not valid.') 56 | 57 | def read(self): 58 | if self.protocol == 'serial': 59 | return SerialInstrument.read(self) 60 | if self.protocol == 'socket': 61 | return SocketInstrument.read(self) 62 | 63 | def write(self, s): 64 | if self.protocol == 'serial': 65 | SerialInstrument.write(self, s) 66 | if self.protocol == 'socket': 67 | SocketInstrument.write(self, s) 68 | 69 | def __del__(self): 70 | if self.protocol == 'serial': 71 | SerialInstrument.__del__(self) 72 | if self.protocol == 'socket': 73 | self.write('END') 74 | SocketInstrument.__del__(self) 75 | 76 | def get_power(self): 77 | return float(self.query('READ')) 78 | 79 | def get_avg_power(self): 80 | self.write('READ_AVG') 81 | #leaves extra time for average power reading 82 | time.sleep(0.15) 83 | 84 | return float(self.read()) 85 | 86 | 87 | if __name__ == '__main__': 88 | #from instruments import E8257D 89 | 90 | sa = SpectrumAnalyzer(protocol='serial', port=2) 91 | #rf = E8257D(address='rfgen1.circuitqed.com') 92 | #lo = E8257D(address='rfgen2.circuitqed.com') 93 | #rf.set_output(False) 94 | #lo.set_output(False) 95 | #rf.set_frequency(6e9) 96 | #lo.set_frequency(6e9+sa.lo_offset) 97 | #lo.set_power(10) 98 | #rf.set_power(-10) 99 | #lo.set_output() 100 | #rf.set_output() 101 | 102 | print(sa.get_power()) 103 | print(sa.get_avg_power()) -------------------------------------------------------------------------------- /slab/instruments/spec_analyzer/spectrum_analyzer.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | Created on Thu Aug 18 14:32:54 2011 4 | 5 | @author: Dai 6 | """ 7 | from slab.instruments import SerialInstrument, SocketInstrument 8 | import time 9 | 10 | class SpectrumAnalyzer(SerialInstrument, SocketInstrument): 11 | #general design parameters 12 | #LO offset is 10.55MHz 13 | #LO power is 10dBm 14 | lo_power = 10 15 | #bandwidth is 180kHz 16 | bandwidth=180e3 17 | #calibration information 18 | #calibration_data = None 19 | #min_power = None 20 | #step = 10 21 | 22 | def __init__(self, name='spec_analyzer', protocol='socket', 23 | address='', port=23, enabled=True, timeout=.1, recv_length=1024, 24 | query_sleep=0.005, lo_power=10, lo_offset=10.55e6, baudrate=115200): 25 | 26 | self.lo_offset = lo_offset 27 | self.lo_power = lo_power 28 | 29 | if (address.count('.') == 3): 30 | #the address is in an IP address format 31 | self.protocol = 'socket' 32 | else: 33 | #otherwise we treat the address as port 34 | self.protocol = 'serial' 35 | if address != '': 36 | port = int(address) 37 | 38 | if self.protocol == 'serial': 39 | SerialInstrument.__init__(self, name, port, enabled, 40 | timeout, recv_length, baudrate=baudrate, querysleep=query_sleep) 41 | self.term_char = '' 42 | time.sleep(2) 43 | print(self.read()) 44 | elif self.protocol == 'socket': 45 | if ':' in address: 46 | SocketInstrument.__init__(self, name, address, enabled, 47 | timeout, recv_length) 48 | else: 49 | SocketInstrument.__init__(self, name, address+':'+str(port), enabled, 50 | timeout, recv_length) 51 | self.recv_length = recv_length 52 | self.term_char = '' 53 | self.query_sleep = query_sleep 54 | else: 55 | print('The protocol requested is not valid.') 56 | 57 | def read(self): 58 | if self.protocol == 'serial': 59 | return SerialInstrument.read(self) 60 | if self.protocol == 'socket': 61 | return SocketInstrument.read(self) 62 | 63 | def write(self, s): 64 | if self.protocol == 'serial': 65 | SerialInstrument.write(self, s) 66 | if self.protocol == 'socket': 67 | SocketInstrument.write(self, s) 68 | 69 | def __del__(self): 70 | if self.protocol == 'serial': 71 | SerialInstrument.__del__(self) 72 | if self.protocol == 'socket': 73 | self.write('END') 74 | SocketInstrument.__del__(self) 75 | 76 | def get_power(self): 77 | return float(self.query('READ')) 78 | 79 | def get_avg_power(self): 80 | self.write('READ_AVG') 81 | #leaves extra time for average power reading 82 | time.sleep(0.15) 83 | 84 | return float(self.read()) 85 | 86 | 87 | if __name__ == '__main__': 88 | #from instruments import E8257D 89 | 90 | sa = SpectrumAnalyzer(protocol='serial', port=2) 91 | #rf = E8257D(address='rfgen1.circuitqed.com') 92 | #lo = E8257D(address='rfgen2.circuitqed.com') 93 | #rf.set_output(False) 94 | #lo.set_output(False) 95 | #rf.set_frequency(6e9) 96 | #lo.set_frequency(6e9+sa.lo_offset) 97 | #lo.set_power(10) 98 | #rf.set_power(-10) 99 | #lo.set_output() 100 | #rf.set_output() 101 | 102 | print(sa.get_power()) 103 | print(sa.get_avg_power()) -------------------------------------------------------------------------------- /slab/experiments/Rodin Furnace/_testing_notebooks/Temp scan tests.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "metadata": { 3 | "language_info": { 4 | "codemirror_mode": { 5 | "name": "ipython", 6 | "version": 3 7 | }, 8 | "file_extension": ".py", 9 | "mimetype": "text/x-python", 10 | "name": "python", 11 | "nbconvert_exporter": "python", 12 | "pygments_lexer": "ipython3", 13 | "version": "3.7.3-final" 14 | }, 15 | "orig_nbformat": 2, 16 | "kernelspec": { 17 | "name": "python3", 18 | "display_name": "Python 3", 19 | "language": "python" 20 | } 21 | }, 22 | "nbformat": 4, 23 | "nbformat_minor": 2, 24 | "cells": [ 25 | { 26 | "cell_type": "code", 27 | "execution_count": 1, 28 | "metadata": {}, 29 | "outputs": [], 30 | "source": [ 31 | "import slab\n", 32 | "from slab import InstrumentManager\n", 33 | "from slab.instruments import TempScanner\n", 34 | "import time\n" 35 | ] 36 | }, 37 | { 38 | "cell_type": "code", 39 | "execution_count": 2, 40 | "metadata": {}, 41 | "outputs": [], 42 | "source": [ 43 | "im=InstrumentManager()" 44 | ] 45 | }, 46 | { 47 | "cell_type": "code", 48 | "execution_count": 4, 49 | "metadata": {}, 50 | "outputs": [], 51 | "source": [ 52 | "t_scan=im.TempScan" 53 | ] 54 | }, 55 | { 56 | "cell_type": "code", 57 | "execution_count": 4, 58 | "metadata": {}, 59 | "outputs": [], 60 | "source": [ 61 | "t_scan.write('CONF:TEMP TC,K, (@101)\\r\\n')\n", 62 | "t_scan.write('TRIG:SOUR IMM\\r\\n')\n" 63 | ] 64 | }, 65 | { 66 | "cell_type": "code", 67 | "execution_count": 15, 68 | "metadata": {}, 69 | "outputs": [], 70 | "source": [ 71 | "t_scan.write('ABOR')" 72 | ] 73 | }, 74 | { 75 | "cell_type": "code", 76 | "execution_count": 8, 77 | "metadata": {}, 78 | "outputs": [ 79 | { 80 | "output_type": "stream", 81 | "name": "stdout", 82 | "text": [ 83 | "['TEMP TC,K,+1.000000E+00,+3.000000E-06']\n" 84 | ] 85 | } 86 | ], 87 | "source": [ 88 | "print(t_scan.get_ch_config(1))" 89 | ] 90 | }, 91 | { 92 | "cell_type": "code", 93 | "execution_count": 5, 94 | "metadata": {}, 95 | "outputs": [ 96 | { 97 | "output_type": "execute_result", 98 | "data": { 99 | "text/plain": [ 100 | "[13.187]" 101 | ] 102 | }, 103 | "metadata": {}, 104 | "execution_count": 5 105 | } 106 | ], 107 | "source": [ 108 | "t_scan.get_temp(1, sens='TC', t_type='K')" 109 | ] 110 | }, 111 | { 112 | "cell_type": "code", 113 | "execution_count": 6, 114 | "metadata": {}, 115 | "outputs": [], 116 | "source": [ 117 | "\n", 118 | "t_scan.conf_temp_tcouple(1, t_type='K')" 119 | ] 120 | }, 121 | { 122 | "cell_type": "code", 123 | "execution_count": 7, 124 | "metadata": {}, 125 | "outputs": [ 126 | { 127 | "output_type": "execute_result", 128 | "data": { 129 | "text/plain": [ 130 | "[13.161]" 131 | ] 132 | }, 133 | "metadata": {}, 134 | "execution_count": 7 135 | } 136 | ], 137 | "source": [ 138 | "t_scan.read_chs()" 139 | ] 140 | }, 141 | { 142 | "cell_type": "code", 143 | "execution_count": 7, 144 | "metadata": {}, 145 | "outputs": [ 146 | { 147 | "output_type": "execute_result", 148 | "data": { 149 | "text/plain": [ 150 | "'HEWLETT-PACKARD,34970A,0,13-2-2'" 151 | ] 152 | }, 153 | "metadata": {}, 154 | "execution_count": 7 155 | } 156 | ], 157 | "source": [ 158 | "t_scan.c_query('*IDN?')" 159 | ] 160 | }, 161 | { 162 | "cell_type": "code", 163 | "execution_count": null, 164 | "metadata": {}, 165 | "outputs": [], 166 | "source": [] 167 | } 168 | ] 169 | } -------------------------------------------------------------------------------- /slab/instruments/__init__.py: -------------------------------------------------------------------------------- 1 | 2 | from .instrumentmanager import InstrumentManager 3 | from .instrumenttypes import Instrument, VisaInstrument, TelnetInstrument, SocketInstrument, SerialInstrument, \ 4 | WebInstrument 5 | from .localinstruments import LocalInstruments 6 | 7 | # try: from .InstrumentManagerWindow import InstrumentManagerWindow 8 | # except: print("Could not load InstrumentManagerWindow") 9 | 10 | # from .spectrumanalyzer import E4440 11 | from .nwa import E5071 12 | from .PNAX import N5242A 13 | # from .rfgenerators import N5183B,E8257D,BNC845 14 | # from .cryostat import Triton 15 | # from .awg import * 16 | # from .spec_analyzer.spectrum_analyzer import * 17 | # from .ipsmagnet import * 18 | from .TestInstruments import EchoInstrument,RandomInstrument 19 | # from .TDS7104 import TekTDS7104 20 | # from .RCA18 import MCRCA18 21 | # from .multimeter import Keithley199 22 | 23 | # try: from .AD5780DAC.AD5780 import AD5780 24 | # except: print("Could not load AD5780 dac") 25 | # try: from .ArduinoADC import ArduinoADC 26 | # except: print("Could not load ArduinoADC") 27 | # try: from .labbrick.labbrick import LMS_get_device_info,LMS103,LPS802,LDA602 28 | # except: print("Could not load labbrick") 29 | # try: from .relaybox.relaybox import RelayBox 30 | # except: print("Could not load relaybox") 31 | # try: from .relaybox.heliummanifold import HeliumManifold 32 | # except: print("Could not load heliummanifold") 33 | # try: from .relaybox.RFSwitch import RFSwitch 34 | # except: print("Could not load heliummanifold") 35 | # try: from .bkpowersupply import BKPowerSupply 36 | # except: print("Could not load BKPowerSupply") 37 | # try: from .bkpowersupply import BKPowerSupplynew 38 | # except: print("Could not load BKPowerSupply") 39 | # try: from .bkpowersupply import BKPowerSupply2 40 | # except: print("Could not load BKPowerSupply") 41 | try: from .XLN10014 import XLN10014 42 | except: print("Could not load XLN10014") 43 | # try: from .KEPCOPowerSupply import KEPCOPowerSupply 44 | # except: print("Could not load KEPCOPowerSupply") 45 | # try: from .voltsource import SRS900 46 | # except: print("Could not load SRS900") 47 | # try: from .voltsource import YokogawaGS200 48 | # except: print("Could not load YokogawaGS200") 49 | # from .Alazar import Alazar, AlazarConfig, AlazarConstants 50 | # try: from .Alazar import Alazar, AlazarConfig, AlazarConstants 51 | # except: print("Could not load Alazar card") 52 | # try: from .function_generator import BiasDriver,FilamentDriver,BNCAWG 53 | # except: print("Could not load BNC AWG classes") 54 | # try: from .multimeter import Keithley199, HP34401A 55 | # except: print("Could not load Keithley199/HP34401A multimeter classes") 56 | # try: from .spectrumanalyzer import E4440 57 | # except: print("Could not load E4440 Spectrum Analyzer") 58 | # try: from .cryocon import Cryocon 59 | # except: print("Could not load Cryocon instrument driver") 60 | # try: from .DigitalAttenuator import DigitalAttenuator 61 | # except: print("Could not load Digital Attenuator driver") 62 | # try: from .HeaterSwitch import HeaterSwitch 63 | # except: print("Could not load Heater Switch Driver") 64 | # try: from .Omega16i import Omega16i 65 | # except: print("Could not load Omega 16i driver") 66 | # try: from .lockin import SR844 67 | # except: print("Could not load SR844 driver") 68 | try: from .PressureGauge import PressureGauge 69 | except: print("Could not load PressureGauge driver") 70 | try: from .RGA100 import RGA100 71 | except: print('Could not load SRS RGA100 driver') 72 | try: from .AG850 import AG850 73 | except: print("Could not load AG850 Driver") 74 | try: from .Autonics import TM4 75 | except: print("Could not load Autonics TM4 Driver") 76 | try: from .Oerlikon import Center_Three 77 | except: print("Could not load Oerlikon Center Three Driver") 78 | try: from .TempScanner import HP34970A 79 | except: print("Could not load HP34970A Driver") 80 | try: from .PLC import FurnacePLC 81 | except: print("Could not load Furnace PLC") 82 | 83 | 84 | -------------------------------------------------------------------------------- /slab/instruments/Alazar/Scope.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | Created on Mon May 16 18:29:46 2011 4 | 5 | @author: Phil 6 | """ 7 | from gui import * 8 | from instruments.Alazar.TestAlazarApi import * 9 | 10 | class ScopeDataSet(DataSet): 11 | bgm1=BeginGroup("Acquisition Properties") 12 | samples= IntItem("Samples",default = 8192, min=0) 13 | records= IntItem("Records per buffer",default=4,min=0).set_pos(col=1) 14 | buffers= IntItem("Buffers per acquisition",default=1000,min=0)#.set_pos(col=2) 15 | averages= IntItem("Averages",default=1,min=1) 16 | egm1 = EndGroup("Acquisition Properties") 17 | 18 | bgm2 = BeginGroup("Horizontal Properties") 19 | clock_type=ChoiceItem("Clock Type",[(0,'Fast AC'),(1,'Slow'),(3,'10 MHz PLL'),(4,'Internal')]) 20 | clock_decimation=IntItem("Decimation",default=1,min=1).set_pos(col=1) 21 | egm2 = EndGroup("Horizontal Properties") 22 | 23 | bgm3 = BeginGroup("Vertical Properties") 24 | scale= ChoiceItem('Scale',[(0,'2 mV'),(1,'5 mV'),(2,'10 mV'),(3,'20 mV'),(4,'50 mV'),(5,'100 mV'),(5,'200 mV'),(6,'500 mV'),(7,'1 V'),(8,'2 V'),(9,'5 V'),(10,'10 V'),(11,'20 V')]) 25 | coupling = ChoiceItem('Input Coupling', [(0,'DC'),('1','AC')]).set_pos(col=1) 26 | egm3 = EndGroup("Vertical Properties") 27 | 28 | bgm4 = BeginGroup("Trigger Properties") 29 | source= ChoiceItem('Source',[(0,"CH 1"),(1,'CH 2'),(2,'External'),(3,'Disabled')]) 30 | level = IntItem('Level (%)',default=50).set_pos(col=1) 31 | egm4 = EndGroup("Trigger Properties") 32 | 33 | bgm5 = BeginGroup("File Properties") 34 | fileprefix = FileSaveItem("File Prefix") 35 | filenumber= IntItem("File #",default=1,min=0).set_pos(col=1) 36 | egm5 = EndGroup("File Properties") 37 | 38 | class ScopeWindow(SlabWindow): 39 | 40 | def setupWidgets(self): 41 | self.guidata=DataSetEditGroupBox("Properties", ScopeDataSet,button_text='Go') 42 | #self.guidata.setSizePolicy(QSizePolicy.Preferred,QSizePolicy.Preferred) 43 | self.connect(self.guidata, SIGNAL("apply_button_clicked()"), 44 | self.go) 45 | self.paramswidget.addWidget(self.guidata) 46 | 47 | #Oscilloscope widget 48 | self.curvewidget = CurveWidget(self,title='Oscilloscope',xlabel='Time (ns)',ylabel='Voltage (V)') 49 | self.plot = self.curvewidget.plot 50 | x=np.linspace(-5,5,1000) 51 | y1=np.cos(x) 52 | y2=np.sin(x) 53 | self.ch1_plot = make.mcurve(x, y1, label="Ch1") 54 | self.plot.add_item(self.ch1_plot) 55 | self.ch2_plot = make.mcurve(x, y2, label="Ch2") 56 | self.plot.add_item(self.ch2_plot) 57 | self.plot.add_item(make.legend('TR')) 58 | 59 | self.add_plot_updater("Ch1","line_plot",self.plot,self.ch1_plot) 60 | self.add_plot_updater("Ch2","line_plot",self.plot,self.ch2_plot) 61 | 62 | self.curvewidget.register_all_image_tools() 63 | self.plotswidget.addWidget(self.curvewidget) 64 | 65 | 66 | def go(self): 67 | print("GO!") 68 | p = Process(target=acquire_data, args=(self.guidata.dataset,self.pipes,)) 69 | p.start() 70 | print("Process started") 71 | self.statusBar().showMessage("Acquiring Data", 5000) 72 | p.join() 73 | 74 | 75 | def acquire_data(params,pipes=None): 76 | print("Acquiring data") 77 | if pipes!=None: 78 | ch1_pipe=pipes['Ch1'] 79 | ch2_pipe=pipes['Ch2'] 80 | card = Card() 81 | x = linspace(-5, 5, card.samples) 82 | card.configure() 83 | for ii in range(4): 84 | card.acquire() 85 | y1 = card.cur_result[0] 86 | if pipes!=None: 87 | ch1_pipe.send((x,y1)) 88 | #ch2_pipe.send((x,y2)) 89 | 90 | if __name__ == "__main__": 91 | app=guidata.qapplication() 92 | window=ScopeWindow(title="Test Scope",size=(1000,600)) 93 | window.show() 94 | app.exec_() -------------------------------------------------------------------------------- /slab/experiments/Rodin Furnace/Instruments/__init__.py: -------------------------------------------------------------------------------- 1 | 2 | from .instrumentmanager import InstrumentManager 3 | from .instrumenttypes import Instrument, VisaInstrument, TelnetInstrument, SocketInstrument, SerialInstrument, \ 4 | WebInstrument 5 | from .localinstruments import LocalInstruments 6 | 7 | # try: from .InstrumentManagerWindow import InstrumentManagerWindow 8 | # except: print("Could not load InstrumentManagerWindow") 9 | 10 | # from .spectrumanalyzer import E4440 11 | # from .nwa import E5071 12 | # from .PNAX import N5242A 13 | # from .rfgenerators import N5183B,E8257D,BNC845 14 | # from .cryostat import Triton 15 | # from .awg import * 16 | # from .spec_analyzer.spectrum_analyzer import * 17 | # from .ipsmagnet import * 18 | from .TestInstruments import EchoInstrument,RandomInstrument 19 | # from .TDS7104 import TekTDS7104 20 | # from .RCA18 import MCRCA18 21 | # from .multimeter import Keithley199 22 | 23 | # try: from .AD5780DAC.AD5780 import AD5780 24 | # except: print("Could not load AD5780 dac") 25 | # try: from .ArduinoADC import ArduinoADC 26 | # except: print("Could not load ArduinoADC") 27 | # try: from .labbrick.labbrick import LMS_get_device_info,LMS103,LPS802,LDA602 28 | # except: print("Could not load labbrick") 29 | # try: from .relaybox.relaybox import RelayBox 30 | # except: print("Could not load relaybox") 31 | # try: from .relaybox.heliummanifold import HeliumManifold 32 | # except: print("Could not load heliummanifold") 33 | # try: from .relaybox.RFSwitch import RFSwitch 34 | # except: print("Could not load heliummanifold") 35 | # try: from .bkpowersupply import BKPowerSupply 36 | # except: print("Could not load BKPowerSupply") 37 | # try: from .bkpowersupply import BKPowerSupplynew 38 | # except: print("Could not load BKPowerSupply") 39 | # try: from .bkpowersupply import BKPowerSupply2 40 | # except: print("Could not load BKPowerSupply") 41 | try: from .XLN10014 import XLN10014 42 | except: print("Could not load XLN10014") 43 | # try: from .KEPCOPowerSupply import KEPCOPowerSupply 44 | # except: print("Could not load KEPCOPowerSupply") 45 | # try: from .voltsource import SRS900 46 | # except: print("Could not load SRS900") 47 | # try: from .voltsource import YokogawaGS200 48 | # except: print("Could not load YokogawaGS200") 49 | # from .Alazar import Alazar, AlazarConfig, AlazarConstants 50 | # try: from .Alazar import Alazar, AlazarConfig, AlazarConstants 51 | # except: print("Could not load Alazar card") 52 | # try: from .function_generator import BiasDriver,FilamentDriver,BNCAWG 53 | # except: print("Could not load BNC AWG classes") 54 | # try: from .multimeter import Keithley199, HP34401A 55 | # except: print("Could not load Keithley199/HP34401A multimeter classes") 56 | # try: from .spectrumanalyzer import E4440 57 | # except: print("Could not load E4440 Spectrum Analyzer") 58 | # try: from .cryocon import Cryocon 59 | # except: print("Could not load Cryocon instrument driver") 60 | # try: from .DigitalAttenuator import DigitalAttenuator 61 | # except: print("Could not load Digital Attenuator driver") 62 | # try: from .HeaterSwitch import HeaterSwitch 63 | # except: print("Could not load Heater Switch Driver") 64 | # try: from .Omega16i import Omega16i 65 | # except: print("Could not load Omega 16i driver") 66 | # try: from .lockin import SR844 67 | # except: print("Could not load SR844 driver") 68 | try: from .PressureGauge import PressureGauge 69 | except: print("Could not load PressureGauge driver") 70 | try: from .RGA100 import RGA100 71 | except: print('Could not load SRS RGA100 driver') 72 | try: from .AG850 import AG850 73 | except: print("Could not load AG850 Driver") 74 | try: from .Autonics import TM4 75 | except: print("Could not load Autonics TM4 Driver") 76 | try: from .Oerlikon import Center_Three 77 | except: print("Could not load Oerlikon Center Three Driver") 78 | try: from .TempScanner import HP34970A 79 | except: print("Could not load HP34970A Driver") 80 | try: from .PLC import FurnacePLC 81 | except: print("Could not load Furnace PLC") 82 | 83 | 84 | --------------------------------------------------------------------------------