### Setup and Experiment Initialization Source: https://github.com/microsoft/qcodes/blob/main/docs/examples/driver_examples/Qcodes example with Keysight Network Analyzer.ipynb Initializes logging and sets up a QCoDeS experiment. Loads an existing experiment if found, otherwise starts a new one. ```python %matplotlib inline ``` ```python # Import Dependencies import logging # qcodes imports from qcodes.dataset import ( Measurement, load_experiment_by_name, new_experiment, plot_by_id, ) from qcodes.instrument_drivers.Keysight import KeysightN5245A # setup logger = logging.getLogger() logger.setLevel(logging.DEBUG) # Start experiment exp_name = "PNA_Example" sample_name = "Thru_Coax" try: exp = load_experiment_by_name(exp_name, sample=sample_name) print("Experiment loaded. Last ID no:", exp.last_counter) except ValueError: exp = new_experiment(exp_name, sample_name) print("Starting new experiment.") ``` -------------------------------- ### Install Documentation Dependencies Source: https://github.com/microsoft/qcodes/blob/main/README.rst Use this command to install the necessary dependencies for building the QCoDeS documentation. ```bash pip install -r docs_requirements.txt ``` -------------------------------- ### Initialize Database and Experiment Source: https://github.com/microsoft/qcodes/blob/main/docs/examples/Parameters/Simple-Example-of-ParameterWithSetpoints.ipynb Sets up the database and experiment for the tutorial. This is a prerequisite for running the subsequent examples. ```python from qcodes.utils.db import initialise_or_create_database_at from qcodes.experiment.experiment_container import load_or_create_experiment from pathlib import Path tutorial_db_path = ( Path.cwd().parent / "example_output" / "tutorial_paramter_with_setpoints.db" ) initialise_or_create_database_at(tutorial_db_path) load_or_create_experiment( experiment_name="tutorial_ParameterWithSetpoints", sample_name="no sample" ) ``` -------------------------------- ### Install QCoDeS Source: https://context7.com/microsoft/qcodes/llms.txt Install QCoDeS using pip. Optional loop support can be installed with an extra. ```bash pip install qcodes # With optional loop support: pip install qcodes[loop] ``` -------------------------------- ### Start QCoDeS logging Source: https://github.com/microsoft/qcodes/blob/main/docs/examples/driver_examples/Qcodes example with Ithaco.ipynb Initializes QCoDeS logging to capture instrument interactions and experiment progress. This is a standard setup step for QCoDeS experiments to enable debugging and record-keeping. ```python from qcodes.logger import start_all_logging start_all_logging() ``` -------------------------------- ### Load Instrument Setup Source: https://github.com/microsoft/qcodes/blob/main/docs/examples/driver_examples/QCoDeS example with Keithley 3706A System Switch.ipynb Load a previously saved instrument setup. Use 0 to load factory defaults, 1 to load the setup from non-volatile memory, or a string path for a setup saved on a USB drive. ```python smatrix.load_setup(0) ``` ```python smatrix.load_setup(1) ``` -------------------------------- ### Import Matplotlib and QCoDeS Source: https://github.com/microsoft/qcodes/blob/main/docs/examples/driver_examples/Qcodes example with Rohde Schwarz ZNB.ipynb Initializes the matplotlib backend for plotting and imports the QCoDes library. This is a common setup for QCoDeS examples. ```python %matplotlib nbagg import qcodes as qc ``` -------------------------------- ### Install Package from Local Wheel Source: https://github.com/microsoft/qcodes/wiki/How-to-release Install the newly built QCoDes package from the local wheel file into the test environment. ```bash pip install dist/qcodes--py3-none-any.whl ``` -------------------------------- ### Install QCoDeS with test dependencies Source: https://github.com/microsoft/qcodes/blob/main/CONTRIBUTING.rst Install QCoDeS including testing dependencies. Use the -e flag for an editable install. ```bash pip install .[test] -c requirements.txt ``` -------------------------------- ### Log file output example Source: https://github.com/microsoft/qcodes/blob/main/docs/examples/logging/logfile_parsing.ipynb This is an example output from QCoDeS logging, showing the configuration and status of the logging system. ```text Output: Logging hadn't been started. Activating auto-logging. Current session state plus future input saved. Filename : C:\Users\jenielse\.qcodes\logs\command_history.log Mode : append Output logging : True Raw input log : False Timestamping : True State : active Qcodes Logfile : C:\Users\jenielse\.qcodes\logs\220603-13972-qcodes.log ``` -------------------------------- ### Install Additional Requirements Source: https://github.com/microsoft/qcodes/wiki/How-to-release Install the necessary project and testing requirements into the test environment. ```bash pip install -r requirements.txt -r test_requirements.txt ``` -------------------------------- ### Setup dummy instruments and station Source: https://github.com/microsoft/qcodes/blob/main/docs/examples/DataSet/Performing-measurements-using-qcodes-parameters-and-dataset.ipynb Configures mock instruments (DAC and DMM) to simulate a physical experimental setup. The DMM is set up to depend on the DAC's output, and both are added to a QCoDeS Station object. ```python # preparatory mocking of physical setup dac = DummyInstrument("dac", gates=["ch1", "ch2"]) dmm = DummyInstrumentWithMeasurement(name="dmm", setter_instr=dac) station = qc.Station(dmm, dac) ``` -------------------------------- ### Install QCoDeS from GitHub with Test Dependencies Source: https://github.com/microsoft/qcodes/blob/main/docs/start/index.md Performs an editable install of QCoDeS from a local git clone, including the necessary dependencies to run the package's tests. ```bash pip install -e [test] ``` -------------------------------- ### Create and Activate Conda Environment and Install QCoDeS with conda Source: https://github.com/microsoft/qcodes/blob/main/docs/start/index.md Creates a new conda environment, sets it up to use the conda-forge channel with strict channel priority, and then installs QCoDeS. This method is recommended for new users. ```bash conda create -n qcodes conda activate qcodes conda config --add channels conda-forge --env conda config --set channel_priority strict --env conda install qcodes ``` -------------------------------- ### Save and Load Instrument Setup Source: https://github.com/microsoft/qcodes/blob/main/docs/examples/driver_examples/QCoDeS example with Aim TTi PL601-P.ipynb Save the current instrument configuration to a specified slot and then load a previously saved configuration. This allows for easy recall of specific setups. ```python tti.ch1.save_setup(0) ``` ```python tti.ch1.load_setup(0) ``` -------------------------------- ### Get Installed Switch Cards Source: https://github.com/microsoft/qcodes/blob/main/docs/examples/driver_examples/QCoDeS example with Keithley 3706A System Switch.ipynb Retrieves a list of all installed switch cards in the system. This is useful for identifying the hardware configuration. ```python smatrix.get_switch_cards() ``` -------------------------------- ### Get DataSet GUID Source: https://github.com/microsoft/qcodes/blob/main/docs/examples/DataSet/DataSet-class-walkthrough.ipynb Retrieves the Globally Unique Identifier (GUID) of a QCoDeS DataSet. The GUID is a unique string used to identify a dataset across different databases and systems. ```python dataset.guid ``` -------------------------------- ### Initialize Database and Load Experiment Source: https://github.com/microsoft/qcodes/blob/main/docs/examples/DataSet/Datasaver_Builder.ipynb Sets up the database file path and initializes or creates the database at the specified location. It then loads or creates a qcodes experiment named 'Examples'. ```python db_path = Path.cwd().parent / "example_output" / "measurement_extensions.db" initialise_or_create_database_at(db_file_with_abs_path=db_path) experiment = load_or_create_experiment("Examples") ``` -------------------------------- ### Initialize Database and Experiment Source: https://github.com/microsoft/qcodes/blob/main/docs/examples/Parameters/Parameter-With-Setpoints-defined-on-a-different-instrument.ipynb Sets up the database and experiment for logging data. Ensure the tutorial_db_path is correctly configured for your environment. ```python tutorial_db_path = ( Path.cwd().parent / "example_output" / "tutorial_paramter_with_setpoints.db" ) initialise_or_create_database_at(tutorial_db_path) load_or_create_experiment( experiment_name="tutorial_ParameterWithSetpoints", sample_name="no sample" ) ``` -------------------------------- ### Get GUIDs by run specification Source: https://github.com/microsoft/qcodes/blob/main/docs/examples/DataSet/Extracting-runs-from-one-DB-file-to-another.ipynb Retrieve a list of GUIDs for runs matching specific criteria, such as `captured_run_id`. This is useful when `captured_run_id` is not unique and you need to find all runs associated with it. ```python from qcodes.dataset import get_guids_by_run_spec, load_by_guid, load_by_run_spec ``` ```python guids = get_guids_by_run_spec(conn=target_conn, captured_run_id=3) guids ``` -------------------------------- ### Install QCoDeS from Forked GitHub Repository with Test Dependencies Source: https://github.com/microsoft/qcodes/blob/main/docs/start/index.md Installs QCoDeS from a local clone of a forked repository, including test dependencies. This is done after fetching tags from the upstream repository. ```bash pip install -e [test] ``` -------------------------------- ### Get Switch State Source: https://github.com/microsoft/qcodes/blob/main/docs/examples/driver_examples/Qcodes example with Minicircuits Switch boxes (USB-XSPDT).ipynb Retrieve the current state of a specific switch. For example, 'dev.b()' returns the state of switch 'b'. ```python dev.b() ``` -------------------------------- ### Setup database and experiment Source: https://github.com/microsoft/qcodes/blob/main/docs/examples/DataSet/Measuring X as a function of time.ipynb Initializes or creates a QCoDeS database at a specified path and loads or creates an experiment with a given name and sample context. ```python initialise_or_create_database_at( Path.cwd().parent / "example_output" / "x_as_a_function_of_time.db" ) load_or_create_experiment("tutorial", "no_sample") ``` -------------------------------- ### Initialize database and experiment Source: https://github.com/microsoft/qcodes/blob/main/docs/examples/DataSet/Paramtypes explained.ipynb Sets up the QCoDeS database and loads or creates an experiment. Ensure the output directory exists. ```python initialise_or_create_database_at( Path.cwd().parent / "example_output" / "paramtypes_explained.db" ) exp = load_or_create_experiment("paramtypes", sample_name="not_available") ``` -------------------------------- ### Set up experiment and mock instrument Source: https://github.com/microsoft/qcodes/blob/main/docs/examples/DataSet/Extracting-runs-from-one-DB-file-to-another.ipynb Loads or creates an experiment in the source database and initializes a mock instrument and station. This prepares the environment for data acquisition. ```python exp = load_or_create_experiment( experiment_name="extract_runs_experiment", sample_name="no_sample", conn=source_conn ) my_inst = DummyInstrument("my_inst", gates=["voltage", "current"]) station = Station(my_inst) ``` -------------------------------- ### Get Switch Cards Information Source: https://github.com/microsoft/qcodes/blob/main/docs/examples/driver_examples/QCoDeS example with Keithley 3706A System Switch.ipynb Retrieves a list of installed switch cards on the Keithley 3706A System Switch. This is useful for verifying hardware configuration. ```python smatrix.get_switch_cards() ``` ```text Result: ({'slot_no': '1', 'model': '3730', 'mtype': '6x16 High Density Matrix', 'firmware': '01.40h', 'serial': '4447332'}, {'slot_no': '2', 'model': '3730', 'mtype': '6x16 High Density Matrix', 'firmware': '01.40h', 'serial': '4398982'}, {'slot_no': '3', 'model': '3730', 'mtype': '6x16 High Density Matrix', 'firmware': '01.40h', 'serial': '4447333'}) ``` -------------------------------- ### Import necessary libraries Source: https://github.com/microsoft/qcodes/blob/main/docs/examples/driver_examples/Qcodes example with AMI430.ipynb Imports the required QCoDeS drivers, time, matplotlib, and numpy for the example. ```python import time import matplotlib.pyplot as plt import numpy as np from qcodes.instrument_drivers.american_magnetics import AMIModel430, AMIModel4303D from qcodes.math_utils.field_vector import FieldVector ``` -------------------------------- ### Initialize or create database and experiment Source: https://github.com/microsoft/qcodes/blob/main/docs/examples/Parameters/Parameter-With-Setpoints-defined-on-a-different-instrument.ipynb Sets up the QCoDes database and experiment environment. ```python from qcodes.dataset import initialise_or_create_database_at, load_or_create_experiment ``` -------------------------------- ### Import QCoDeS and necessary modules Source: https://github.com/microsoft/qcodes/blob/main/docs/examples/DataSet/Performing-measurements-using-qcodes-parameters-and-dataset.ipynb Imports essential QCoDeS modules and other libraries for performing measurements and logging. This setup is required before defining instruments or starting measurements. ```python %matplotlib inline from pathlib import Path from time import monotonic, sleep import numpy as np import qcodes as qc from qcodes.dataset import ( Measurement, initialise_or_create_database_at, load_by_guid, load_by_run_spec, load_or_create_experiment, plot_dataset, ) from qcodes.dataset.descriptions.detect_shapes import detect_shape_of_measurement from qcodes.instrument_drivers.mock_instruments import ( DummyInstrument, DummyInstrumentWithMeasurement, ) from qcodes.logger import start_all_logging start_all_logging() ``` -------------------------------- ### Set up mock station Source: https://github.com/microsoft/qcodes/blob/main/docs/examples/plotting/How-to-use-Plottr-with-QCoDeS-for-live-plotting.ipynb Creates a mock QCoDeS station with a dummy DAC and a dummy instrument that measures voltage. This is used for demonstration purposes. ```python dac = DummyInstrument("dac", gates=["ch1", "ch2"]) dmm = DummyInstrumentWithMeasurement(name="dmm", setter_instr=dac) station = qc.Station(dmm, dac) ``` -------------------------------- ### Setup Spectrum Analyzer Limits Source: https://github.com/microsoft/qcodes/blob/main/docs/examples/Parameters/Simple-Example-of-ParameterWithSetpoints.ipynb Configures the start frequency, stop frequency, and number of points for the spectrum analyzer. These settings define the range and resolution of the frequency axis. ```python a.f_start(0) a.f_stop(500) a.n_points(501) ``` -------------------------------- ### Define a Parameter for Force Side Source: https://github.com/microsoft/qcodes/blob/main/docs/examples/DataSet/DataSet-class-walkthrough.ipynb Defines a Parameter object named 'force_side' with a label and initial value. This is a basic setup for a parameter that might not have direct set or get commands. ```python fs = Parameter( name="force_side", label="Side of the Force", initial_value="dark", set_cmd=None, get_cmd=None, ) ``` -------------------------------- ### Mock Instrument Setup Source: https://github.com/microsoft/qcodes/blob/main/docs/examples/logging/logging_example.ipynb Sets up mock AMI430 magnet controller instruments for demonstration purposes. This includes creating individual instrument instances for each axis and a combined 3D driver. ```python import numpy as np from qcodes.instrument_drivers.american_magnetics import AMIModel430, AMIModel4303D mag_x = AMIModel430( "x", address="GPIB::1::INSTR", pyvisa_sim_file="AMI430.yaml", terminator="\n" ) mag_y = AMIModel430( "y", address="GPIB::2::INSTR", pyvisa_sim_file="AMI430.yaml", terminator="\n" ) mag_z = AMIModel430( "z", address="GPIB::3::INSTR", pyvisa_sim_file="AMI430.yaml", terminator="\n" ) field_limit = [ lambda x, y, z: x == 0 and y == 0 and z < 3, lambda x, y, z: np.linalg.norm([x, y, z]) < 2, ] driver = AMIModel4303D("AMI430_3D", mag_x, mag_y, mag_z, field_limit) ``` -------------------------------- ### Setup Imports and Mock Instruments Source: https://github.com/microsoft/qcodes/blob/main/docs/examples/DataSet/Cache/write_for_caching.ipynb Imports necessary QCoDeS modules and sets up mock instruments for demonstration purposes. This includes initializing the database and loading or creating an experiment. ```python %matplotlib notebook import time import numpy as np import qcodes as qc from qcodes.dataset import Measurement, initialise_database, load_or_create_experiment from qcodes.instrument_drivers.mock_instruments import ( DummyInstrument, DummyInstrumentWithMeasurement, ) ``` ```python # preparatory mocking of physical setup dac = DummyInstrument("dac", gates=["ch1", "ch2"]) dmm = DummyInstrumentWithMeasurement("dmm", setter_instr=dac) station = qc.Station(dmm, dac) ``` ```python initialise_database() exp = load_or_create_experiment( experiment_name="dataset_cache_test", sample_name="no sample" ) ``` -------------------------------- ### Conditional Sweep with Measurement Context Manager Source: https://github.com/microsoft/qcodes/blob/main/docs/examples/DataSet/Performing-measurements-using-qcodes-parameters-and-dataset.ipynb Perform a 1D sweep and stop early if a condition is met. This example shows how to use the Measurement context manager to dynamically control the measurement loop. Requires prior setup of 'exp', 'dac', and 'dmm'. ```python meas = Measurement(exp=exp) meas.register_parameter(dac.ch1) # register the first independent parameter meas.register_parameter(dmm.v1, setpoints=(dac.ch1,)) # now register the dependent oone with meas.run() as datasaver: for set_v in np.linspace(0, 25, 25): dac.ch1.set(set_v) get_v = dmm.v1.get() datasaver.add_result((dac.ch1, set_v), (dmm.v1, get_v)) if get_v < 1: break dataset = datasaver.dataset ``` -------------------------------- ### Initialize and create a new database Source: https://github.com/microsoft/qcodes/blob/main/docs/examples/DataSet/Saving_data_in_the_background.ipynb Sets up a new QCoDeS database in a temporary directory and starts a new experiment. This is a prerequisite for saving data. ```python dbname = os.path.join(tempfile.gettempdir(), os.urandom(24).hex()) + ".db" initialise_or_create_database_at(dbname) new_experiment("saving_data_in_bg", "no_sample") ``` -------------------------------- ### Initialize or create database and load experiment Source: https://github.com/microsoft/qcodes/blob/main/docs/examples/DataSet/import-data-from-legacy-dat-files.ipynb Sets up the qcodes database at a specified location and loads or creates an experiment to store the imported data. This step is crucial for organizing your data. ```python # in case it was not there already initialise_or_create_database_at( Path.cwd().parent / "example_output" / "import_data.db" ) # put the old data in a new experiment exp = load_or_create_experiment("old_data_loading", sample_name="no_sample") ``` -------------------------------- ### Compare GUIDs of original and extracted runs Source: https://github.com/microsoft/qcodes/blob/main/docs/examples/DataSet/Extracting-runs-from-one-DB-file-to-another.ipynb Compares the GUID of a run in the source database with the GUID of its corresponding extracted run in the target database. The GUIDs should be identical, indicating a true copy. ```python exp.data_set(3).guid ``` ```python target_exp.data_set(1).guid ``` -------------------------------- ### Initialize Database and Experiment Source: https://github.com/microsoft/qcodes/blob/main/docs/examples/driver_examples/Qcodes example with Rigol DS1074Z.ipynb Sets up the QCoDeS database and loads or creates a new experiment. This is a prerequisite for logging measurement data. ```python initialise_database() exp = load_or_create_experiment( experiment_name="Oscilloscope trace", sample_name="no_name" ) ``` -------------------------------- ### Initialize database and experiment Source: https://github.com/microsoft/qcodes/blob/main/docs/examples/DataSet/Offline Plotting Tutorial.ipynb Sets up the QCoDeS database and creates an experiment to store measurement data. The database is created at a specified path. ```python initialise_or_create_database_at( Path.cwd().parent / "example_output" / "offline_plotting_example.db" ) exp = load_or_create_experiment("offline_plotting_experiment", "nosample") ``` -------------------------------- ### Access GUID of a dataset Source: https://github.com/microsoft/qcodes/blob/main/docs/examples/DataSet/Extracting-runs-from-one-DB-file-to-another.ipynb Retrieve the Globally Unique Identifier (GUID) for a specific dataset within an experiment. The GUID is a persistent identifier for the dataset. ```python exp.data_set(3).guid ``` -------------------------------- ### Mock instruments for QCoDeS setup Source: https://github.com/microsoft/qcodes/blob/main/docs/examples/DataSet/Exporting-data-to-other-file-formats.ipynb Sets up mock instruments (DAC and DMM) for demonstration purposes. These simulate real hardware for testing QCoDeS functionalities without physical equipment. ```python # preparatory mocking of physical setup dac = DummyInstrument("dac", gates=["ch1", "ch2"]) dmm = DummyInstrumentWithMeasurement("dmm", setter_instr=dac) station = qc.Station(dmm, dac) ``` -------------------------------- ### Preview Benchmarking Results Locally Source: https://github.com/microsoft/qcodes/blob/main/benchmarking/README.rst Start a local server to view the generated benchmarking website. The '-b' option automatically opens the site in your default browser. ```bash asv preview -b ``` -------------------------------- ### Print dataset GUID Source: https://github.com/microsoft/qcodes/blob/main/docs/examples/DataSet/Performing-measurements-using-qcodes-parameters-and-dataset.ipynb Display the Globally Unique Identifier (GUID) of a QCoDeS dataset. The GUID ensures unique identification across different database files. ```python print(f"Dataset GUID is: {dataset1D.guid}") ``` -------------------------------- ### Initialize Station with multiple YAML configs Source: https://github.com/microsoft/qcodes/blob/main/docs/examples/basic_examples/Station.ipynb Create a Station instance by providing a list of YAML configuration files. The order may matter for merging. ```python station = Station(config_file=['example_1.yaml', 'example_2.yaml']) ``` -------------------------------- ### Install JupyterLab Source: https://github.com/microsoft/qcodes/blob/main/docs/start/index.md Install JupyterLab as an alternative to the classic Jupyter notebook interface. ```bash pip install jupyterlab ``` -------------------------------- ### Initialize QCoDeS database and experiment Source: https://github.com/microsoft/qcodes/blob/main/docs/examples/DataSet/Linking to parent datasets.ipynb Sets up the QCoDeS database at a specified path and creates a new experiment. This is a prerequisite for logging any measurement data. ```python now = str(datetime.datetime.now()) tutorial_db_path = Path.cwd().parent / "example_output" / "linking_datasets_tutorial.db" initialise_or_create_database_at(tutorial_db_path) load_or_create_experiment("tutorial " + now, "no sample") ``` -------------------------------- ### Initialize QCoDeS database and experiment Source: https://github.com/microsoft/qcodes/blob/main/docs/examples/driver_examples/Qcodes example with keithley 2450.ipynb Sets up the QCoDeS database and creates a new experiment to store measurement data. ```python initialise_database() experiment = new_experiment(name="Keithley_2450_example", sample_name="no sample") ``` -------------------------------- ### Get Top-Level Parameters Source: https://github.com/microsoft/qcodes/blob/main/docs/examples/DataSet/Accessing-data-in-DataSet.ipynb Use the 'top_level_parameters' property to get a tuple of all parameters that are not dependencies of any other parameter. ```python interdeps.top_level_parameters ``` -------------------------------- ### Build HTML Documentation Source: https://github.com/microsoft/qcodes/blob/main/README.rst Navigate to the 'docs' directory and run this command to build the HTML documentation locally. The output will be in 'docs/_build/html'. ```bash make html ``` -------------------------------- ### Initialize or create the database Source: https://github.com/microsoft/qcodes/blob/main/docs/examples/DataSet/Using_doNd_functions_in_comparison_to_Measurement_context_manager_for_performing_measurements.ipynb Sets up the QCoDeS database at the specified path. This is necessary for storing measurement data. ```python tutorial_db_path = Path.cwd().parent / "example_output" / "tutorial_doNd.db" initialise_or_create_database_at(tutorial_db_path) ``` -------------------------------- ### Install QCoDeS via pip Source: https://github.com/microsoft/qcodes/blob/main/docs/examples/basic_examples/15_minutes_to_QCoDeS.ipynb Use this command to install QCoDeS using the pip package manager. ```bash pip install qcodes ``` -------------------------------- ### Initialize Database and Load Experiment Source: https://github.com/microsoft/qcodes/blob/main/docs/examples/DataSet/Working with snapshots.ipynb Initializes the QCoDeS database and loads or creates an experiment. Ensure the database path is correctly set. ```python from qcodes.utils.db import initialise_or_create_database_at from qcodes.experiment.experiment_container import load_or_create_experiment from pathlib import Path # Let's initialize a database to ensure that it exists initialise_or_create_database_at( Path.cwd().parent / "example_output" / "snapshot_example.db" ) # Let's create a new experiment experiment = load_or_create_experiment("snapshot_experiment", "no_sample_yet") ``` -------------------------------- ### Start Waveform Generation Source: https://github.com/microsoft/qcodes/blob/main/docs/examples/driver_examples/Qcodes example with Keysight 33500B.ipynb Enable the output for the synchronization signal and channel 1 to start the configured waveform generation. ```python # Start it ks.sync.output("ON") ks.ch1.output("ON") ``` -------------------------------- ### Build Station Programmatically Source: https://context7.com/microsoft/qcodes/llms.txt Demonstrates how to create a Station object and add parameters programmatically. Use this for setting up instruments and parameters when not loading from a configuration file. ```python from qcodes.station import Station from qcodes.parameters import ManualParameter from qcodes.validators import Numbers # Build programmatically station = Station() gate = ManualParameter("gate", unit="V", vals=Numbers(-3, 3), initial_value=0.0) bias = ManualParameter("bias", unit="mV", vals=Numbers(-100, 100), initial_value=0.0) station.add_component(gate, "gate") station.add_component(bias, "bias") # Access components print(station.gate()) # 0.0 station.gate(1.0) # Snapshot captures the full setup state snap = station.snapshot() print(snap["components"]["gate"]["value"]) # 1.0 # Load from YAML (recommended for real experiments) # station = Station(config_file="my_experiment.station.yaml") # station.load_instrument("dmm") # instantiates the instrument from YAML ``` -------------------------------- ### Install QCoDeS via conda Source: https://github.com/microsoft/qcodes/blob/main/docs/examples/basic_examples/15_minutes_to_QCoDeS.ipynb Use this command to install QCoDeS using the conda package manager with the conda-forge channel. ```bash conda -c conda-forge install qcodes ``` -------------------------------- ### Initialize or Load Experiment and Database Source: https://github.com/microsoft/qcodes/blob/main/docs/examples/DataSet/Dataset_Performance.ipynb Initializes a new database at a specified location or loads an existing one. It also loads or creates a QCoDeS experiment. ```python initialise_or_create_database_at( Path.cwd().parent / "example_output" / "dataset_performance.db" ) exp = load_or_create_experiment(experiment_name="tutorial_exp", sample_name="no sample") ``` -------------------------------- ### Create a QCoDeS experiment Source: https://github.com/microsoft/qcodes/blob/main/docs/examples/driver_examples/Qcodes example with Agilent 34400A.ipynb Loads an existing experiment named 'tutorial_experiment' or creates a new one if it doesn't exist. Sets the sample name to 'no_sample'. ```python tutorial_exp = load_or_create_experiment("tutorial_experiment", sample_name="no_sample") ``` -------------------------------- ### Set and Get Voltage Parameter Source: https://github.com/microsoft/qcodes/blob/main/docs/examples/writing_drivers/abstract_instruments.ipynb Demonstrates setting and getting the value of the 'voltage' parameter on a correctly implemented concrete instrument. ```python vs = VoltageSource("name") vs.voltage(1) vs.voltage() ``` -------------------------------- ### Initialize QCoDeS database and experiment Source: https://github.com/microsoft/qcodes/blob/main/docs/examples/writing_drivers/A-ParameterWithSetpoints-Example-with-Dual-Setpoints.ipynb Sets up the QCoDeS database at a specified path and loads or creates a new experiment. This is a prerequisite for saving measurement data. ```python tutorial_db_path = Path.cwd().parent / "example_output" / "tutorial_doND.db" initialise_or_create_database_at(tutorial_db_path) load_or_create_experiment(experiment_name="tutorial_exp", sample_name="no sample") ``` -------------------------------- ### Identify and Select Installed Modules Source: https://github.com/microsoft/qcodes/blob/main/docs/examples/driver_examples/Qcodes example with Keysight B1500 Parameter Analyzer.ipynb Lists and selects installed modules on the Keysight B1500. Use this to understand the instrument's configuration. ```python # Identify and select installed modules b1500.identify() b1500.select_module(slot=1, module='B1511A') ``` -------------------------------- ### Install Spyder and Jupyter Source: https://github.com/microsoft/qcodes/blob/main/docs/start/index.md Install the Spyder IDE and Jupyter notebook environment within your activated QCoDeS conda environment using pip. ```bash pip install spyder ``` ```bash pip install jupyter ``` -------------------------------- ### Set up dummy instruments Source: https://github.com/microsoft/qcodes/blob/main/docs/examples/DataSet/Using_doNd_functions_in_comparison_to_Measurement_context_manager_for_performing_measurements.ipynb Creates mock instruments for simulating a physical setup. `DummyInstrumentWithMeasurement` is configured to depend on `DummyInstrument`'s settings. ```python # preparatory mocking of physical setup dac = DummyInstrument("dac", gates=["ch1", "ch2"]) dmm = DummyInstrumentWithMeasurement("dmm", setter_instr=dac) ``` -------------------------------- ### Demonstrate custom Parameter get method Source: https://github.com/microsoft/qcodes/blob/main/docs/examples/Parameters/Parameters.ipynb Illustrates calling the get method of a custom Parameter subclass. The 'c()' syntax is a shorthand for 'c.get()'. ```python c = MyCounter("c") # c() is equivalent to c.get() print("Successive calls of c.get():", c(), c(), c(), c(), c()) ``` -------------------------------- ### Initialize Station and Add Components Source: https://github.com/microsoft/qcodes/blob/main/docs/examples/basic_examples/Station.ipynb Creates a new Station instance and adds previously defined parameters and instruments to it using the `add_component` method. ```python station = Station() station.add_component(p) station.add_component(instr) ``` -------------------------------- ### Example .pypirc Configuration Source: https://github.com/microsoft/qcodes/wiki/How-to-release Configuration file for distutils, used by twine for authentication and repository details. This example shows settings for both PyPI and TestPyPI. ```ini [distutils] index-servers = pypi pypitest [pypi] username=your-pypi-username password=your-pypi-password [pypitest] repository=https://test.pypi.org/legacy/ username=your-pypitest-username password=your-pypitest-password ``` -------------------------------- ### Create dummy instruments Source: https://github.com/microsoft/qcodes/blob/main/docs/examples/DataSet/Paramtypes explained.ipynb Initializes mock instruments for use in the experiment. These simulate real hardware. ```python dac = DummyInstrument("dac", gates=["ch1", "ch2"]) SA = DummyInstrument("SA") ``` -------------------------------- ### Install QCoDeS from Forked GitHub Repository Source: https://github.com/microsoft/qcodes/blob/main/docs/start/index.md Installs QCoDeS from a local clone of a forked repository. This command can be used after fetching tags from the upstream repository. ```bash pip install -e ``` -------------------------------- ### Initialize Station with a single YAML config Source: https://github.com/microsoft/qcodes/blob/main/docs/examples/basic_examples/Station.ipynb Create a Station instance by providing a single YAML configuration file. Ensure the file path is correct. ```python station = Station(config_file='qutech_station_25.yaml') ``` -------------------------------- ### Load run by GUID Source: https://github.com/microsoft/qcodes/blob/main/docs/examples/DataSet/Extracting-runs-from-one-DB-file-to-another.ipynb Load a specific run from the database using its GUID. This function is essential for accessing individual runs when their identifiers might not be unique. ```python load_by_guid(guids[0], conn=target_conn) ``` ```python load_by_guid(guids[1], conn=target_conn) ``` -------------------------------- ### Initialize database and experiment Source: https://github.com/microsoft/qcodes/blob/main/docs/examples/DataSet/Offline plotting with categorical data.ipynb Initializes or creates a QCoDeS database at a specified location and loads or creates an experiment. ```python initialise_or_create_database_at( Path.cwd().parent / "example_output" / "offline_plotting_example_categorical.db" ) exp = load_or_create_experiment("offline_plotting_experiment", "nosample") ``` -------------------------------- ### doNd with get_after_set=True Source: https://github.com/microsoft/qcodes/blob/main/docs/examples/DataSet/Using_doNd_functions_in_comparison_to_Measurement_context_manager_for_performing_measurements.ipynb Demonstrates using doNd with `get_after_set=True`. This performs a 'get' operation after each 'set' of the sweep parameter, and the value returned by 'get' is recorded as the setpoint. ```python with qcodes.logger.console_level("DEBUG"): with qcodes.logger.filter_instrument(dac): dond(set_and_get_sweep, dmm.v1, dmm.v2) ``` -------------------------------- ### Instantiate MiniCircuitsUsbSPDT Source: https://github.com/microsoft/qcodes/blob/main/docs/examples/driver_examples/Qcodes example with Minicircuits Switch boxes (USB-XSPDT).ipynb Instantiate the MiniCircuitsUsbSPDT driver. Provide a name, the serial number of the device, and the path to the downloaded DLL. The driver path should point to the directory containing the DLL. ```python dev = MiniCircuitsUsbSPDT( "test", serial_number="11703020018", driver_path=r"C:\Users\a-dovoge\Qcodes\qcodes\instrument_drivers\Minicircuits\mcl_RF_Switch_Controller_NET45", ) ``` -------------------------------- ### Get Interdependencies Keys from DataSet Description Source: https://github.com/microsoft/qcodes/blob/main/docs/examples/DataSet/Accessing-data-in-DataSet.ipynb Access the keys of the dependencies within the DataSet's description to get a tuple of ParamSpecBase objects representing interdependencies. ```python tuple(dataset.description.interdeps.dependencies.keys()) ``` -------------------------------- ### Import BaselSP983c and Keysight34465A Source: https://github.com/microsoft/qcodes/blob/main/docs/examples/driver_examples/Qcodes example with Basel SP983c Preamp.ipynb Import necessary QCoDeS instrument drivers for the Basel Preamp and a Keysight multimeter. ```python from qcodes.instrument_drivers.basel import BaselSP983c from qcodes.instrument_drivers.Keysight import Keysight34465A ``` -------------------------------- ### Read Data from Cache Example Source: https://github.com/microsoft/qcodes/blob/main/docs/examples/DataSet/Cache/read_data_from_cache.ipynb This snippet shows an example of data read from a cache, likely representing experimental results. It includes arrays for 'dmm_v1' and 'dac_ch1'. ```python Output: {'dmm_v1': {'dmm_v1': array([5.09018204, 4.63105405, 4.42728866, 4.38829264, 4.22625556, 3.82653766, 3.67129649, 3.34695112, 3.40300734, 3.21666924, 3.10543365, 2.83800252, 2.88099671, 2.6835489 , 2.46641422, 2.40653038, 2.26613887, 2.02905696, 1.88625026, 2.1919164 , 1.77698013, 1.74489802, 1.62200398, 1.60651668, 1.34105113, 1.34898369, 1.27445697, 1.36462193, 1.03507652, 1.24241502, 1.14786241, 0.70820501, 1.00223568, 1.03322718, 0.84584845, 0.75458588, 0.7183519 , 0.77026242, 0.87493324, 0.74312331, 0.70260914, 0.51703849, 0.63249996, 0.55123235, 0.54686047, 0.45702373, 0.34336841, 0.39462052, 0.42183136, 0.34064474, 0.19263888, 0.33376233, 0.40571299, 0.30248277, 0.38082725, 0.38076513, 0.36496263, 0.36835082, 0.23406347]), 'dac_ch1': array([ 0. , 0.25252525, 0.50505051, 0.75757576, 1.01010101, 1.26262626, 1.51515152, 1.76767677, 2.02020202, 2.27272727, 2.52525253, 2.77777778, 3.03030303, 3.28282828, 3.53535354, 3.78787879, 4.04040404, 4.29292929, 4.54545455, 4.7979798 , 5.05050505, 5.3030303 , 5.55555556, 5.80808081, 6.06060606, 6.31313131, 6.56565657, 6.81818182, 7.07070707, 7.32323232, 7.57575758, 7.82828283, 8.08080808, 8.33333333, 8.58585859, 8.83838384, 9.09090909, 9.34343434, 9.5959596 , 9.84848485, 10.1010101 , 10.35353535, 10.60606061, 10.85858586, 11.11111111, 11.36363636, 11.61616162, 11.86868687, 12.12121212, 12.37373737, 12.62626263, 12.87878788, 13.13131313, 13.38383838, 13.63636364, 13.88888889, 14.14141414, 14.39393939, 14.64646465])}} ``` ```python Output: {'dmm_v1': {'dmm_v1': array([5.09018204, 4.63105405, 4.42728866, 4.38829264, 4.22625556, 3.82653766, 3.67129649, 3.34695112, 3.40300734, 3.21666924, 3.10543365, 2.83800252, 2.88099671, 2.6835489 , 2.46641422, 2.40653038, 2.26613887, 2.02905696, 1.88625026, 2.1919164 , 1.77698013, 1.74489802, 1.62200398, 1.60651668, 1.34105113, 1.34898369, 1.27445697, 1.36462193, 1.03507652, 1.24241502, 1.14786241, 0.70820501, 1.00223568, 1.03322718, 0.84584845, 0.75458588, 0.7183519 , 0.77026242, 0.87493324, 0.74312331, 0.70260914, 0.51703849, 0.63249996, 0.55123235, 0.54686047, 0.45702373, 0.34336841, 0.39462052, 0.42183136, 0.34064474, 0.19263888, 0.33376233, 0.40571299, 0.30248277, 0.38082725, 0.38076513, 0.36496263, 0.36835082, 0.23406347, 0.1774725 , 0.20164293, 0.08147221, 0.19006361, 0.27811192]), 'dac_ch1': array([ 0. , 0.25252525, 0.50505051, 0.75757576, 1.01010101, 1.26262626, 1.51515152, 1.76767677, 2.02020202, 2.27272727, 2.52525253, 2.77777778, 3.03030303, 3.28282828, 3.53535354, 3.78787879, 4.04040404, 4.29292929, 4.54545455, 4.7979798 , 5.05050505, 5.3030303 , 5.55555556, 5.80808081, 6.06060606, 6.31313131, 6.56565657, 6.81818182, 7.07070707, 7.32323232, 7.57575758, 7.82828283, 8.08080808, 8.33333333, 8.58585859, 8.83838384, 9.09090909, 9.34343434, 9.5959596 , 9.84848485, 10.1010101 , 10.35353535, 10.60606061, 10.85858586, 11.11111111, 11.36363636, 11.61616162, 11.86868687, 12.12121212, 12.37373737, 12.62626263, 12.87878788, 13.13131313, 13.38383838, 13.63636364, 13.88888889, 14.14141414, 14.39393939, 14.64646465, 14.8989899 , 15.15151515, 15.4040404 , 15.65656566, 15.90909091])}} ``` ```python Output: {'dmm_v1': {'dmm_v1': array([5.09018204e+00, 4.63105405e+00, 4.42728866e+00, 4.38829264e+00, 4.22625556e+00, 3.82653766e+00, 3.67129649e+00, 3.34695112e+00, 3.40300734e+00, 3.21666924e+00, 3.10543365e+00, 2.83800252e+00, 2.88099671e+00, 2.68354890e+00, 2.46641422e+00, 2.40653038e+00, 2.26613887e+00, 2.02905696e+00, 1.88625026e+00, 2.19191640e+00, 1.77698013e+00, 1.74489802e+00, 1.62200398e+00, 1.60651668e+00, 1.34105113e+00, 1.34898369e+00, 1.27445697e+00, 1.36462193e+00, 1.03507652e+00, 1.24241502e+00, 1.14786241e+00, 7.08205010e-01, 1.00223568e+00, 1.03322718e+00, 8.45848450e-01, 7.54585880e-01, 7.18351900e-01, 7.70262420e-01, 8.74933240e-01, 7.43123310e-01, 7.02609140e-01, 5.17038490e-01, 6.32499960e-01, 5.51232350e-01, 5.46860470e-01, 4.57023730e-01, 3.43368410e-01, 3.94620520e-01, 4.21831360e-01, 3.40644740e-01, 1.92638880e-01, 3.33762330e-01, 4.05712990e-01, 3.02482770e-01, 3.80827250e-01, 3.80765130e-01, 3.64962630e-01, 3.68350820e-01, 2.34063470e-01]), 'dac_ch1': array([ 0. , 0.25252525, 0.50505051, 0.75757576, 1.01010101, 1.26262626, 1.51515152, 1.76767677, 2.02020202, 2.27272727, 2.52525253, 2.77777778, 3.03030303, 3.28282828, 3.53535354, 3.78787879, 4.04040404, 4.29292929, 4.54545455, 4.7979798 , 5.05050505, 5.3030303 , 5.55555556, 5.80808081, 6.06060606, 6.31313131, 6.56565657, 6.81818182, 7.07070707, 7.32323232, 7.57575758, 7.82828283, 8.08080808, 8.33333333, 8.58585859, 8.83838384, 9.09090909, 9.34343434, 9.5959596 , 9.84848485, 10.1010101 , 10.35353535, 10.60606061, 10.85858586, 11.11111111, 11.36363636, 11.61616162, 11.86868687, 12.12121212, 12.37373737, 12.62626263, 12.87878788, 13.13131313, 13.38383838])}} ``` -------------------------------- ### Initialize and Load Experiment Source: https://github.com/microsoft/qcodes/blob/main/docs/examples/DataSet/DataSet-class-walkthrough.ipynb Initializes a QCoDes database at a specified path and loads or creates an experiment with a given name and sample name. ```python db_path = os.path.join(tempfile.gettempdir(), "data_access_example.db") initialise_or_create_database_at(db_path) experiment = load_or_create_experiment(experiment_name="greco", sample_name="draco") ``` -------------------------------- ### Load dataset by GUID Source: https://github.com/microsoft/qcodes/blob/main/docs/examples/DataSet/Performing-measurements-using-qcodes-parameters-and-dataset.ipynb Load a QCoDeS dataset using its unique Globally Unique Identifier (GUID). This method guarantees identification even across multiple database files. ```python loaded_ds = load_by_guid(dataset1D.guid) ``` -------------------------------- ### Get and set instrument parameters Source: https://github.com/microsoft/qcodes/blob/main/docs/examples/driver_examples/Qcodes example with Tektronix AWG5014C.ipynb Demonstrates how to get and set parameters for the AWG instrument, including channel states and offsets. Parameters can be accessed at the top level or per channel. ```python print(awg1.ch3.state.get()) print(awg1.ch2.offset.get()) awg1.ch2.offset.set(0.1) print(awg1.ch2.offset.get()) ``` -------------------------------- ### Setting up a Measurement with the Measurement Context Manager Source: https://github.com/microsoft/qcodes/blob/main/docs/examples/DataSet/Using_doNd_functions_in_comparison_to_Measurement_context_manager_for_performing_measurements.ipynb Initialize a Measurement object, specifying a name and the experiment. Register parameters that will be measured, and optionally define their setpoints. This setup is part of using the Measurement context manager for performing measurements. ```python # Setting up Measurement meas = Measurement(name="1d_measurement of dmm from dac sweep", exp=tutorial_exp) meas.register_parameter(dac.ch1) meas.register_parameter(dmm.v1, setpoints=(dac.ch1,)) meas.register_parameter(dmm.v2, setpoints=(dac.ch1,)) ``` -------------------------------- ### Get Special Parameter Values (MIN) Source: https://github.com/microsoft/qcodes/blob/main/docs/examples/driver_examples/Qcodes example with Keysight 344xxA.ipynb Retrieves the minimum value for a parameter, such as `sample_timer`, by setting it to 'MIN'. The actual value is then obtained by calling the parameter's get method. ```python dmm.sample.timer("MIN") dmm.sample.timer() ``` -------------------------------- ### Get Special Parameter Values (DEF) Source: https://github.com/microsoft/qcodes/blob/main/docs/examples/driver_examples/Qcodes example with Keysight 344xxA.ipynb Retrieves the default value for a parameter, such as `sample_timer`, by setting it to 'DEF'. The actual value is then obtained by calling the parameter's get method. ```python dmm.sample.timer("DEF") dmm.sample.timer() ``` -------------------------------- ### Instantiate and Add Instruments to Station Source: https://github.com/microsoft/qcodes/blob/main/docs/examples/basic_examples/15_minutes_to_QCoDeS.ipynb Initialize a QCoDeS Station and add the previously created 'dac' and 'dmm' instruments to it for organized management. ```python station = qc.Station() ``` ```python station.add_component(dac) ``` ```python station.add_component(dmm) ``` -------------------------------- ### Get Special Parameter Values (MAX) Source: https://github.com/microsoft/qcodes/blob/main/docs/examples/driver_examples/Qcodes example with Keysight 344xxA.ipynb Retrieves the maximum value for a parameter, such as `sample_timer`, by setting it to 'MAX'. The actual value is then obtained by calling the parameter's get method. ```python dmm.sample.timer("MAX") dmm.sample.timer() ``` -------------------------------- ### Initialize mock instruments Source: https://github.com/microsoft/qcodes/blob/main/docs/examples/DataSet/Threaded data acquisition.ipynb Sets up two mock instruments: `dac` (a dummy instrument with two gates) and `dmm1`, `dmm2` (dummy instruments with measurement capabilities that use `dac` as their setter instrument). These are used to simulate real hardware. ```python dac = DummyInstrument("dac", gates=["ch1", "ch2"]) dmm1 = DummyInstrumentWithMeasurement(name="dmm1", setter_instr=dac) dmm2 = DummyInstrumentWithMeasurement(name="dmm2", setter_instr=dac) ``` -------------------------------- ### Create and Initialize a DataSet Source: https://github.com/microsoft/qcodes/blob/main/docs/examples/DataSet/Pedestrian example of subscribing to a DataSet.ipynb Initializes a new QCoDeS DataSet with specified parameters and marks it as started. This is the first step before adding any data. ```python dataSet = new_data_set( "test", exp_id=exp.exp_id, specs=[ ParamSpec("blip", "numeric", unit="bit"), ParamSpec("blop", "numeric", unit="bit"), ], ) dataSet.mark_started() ``` -------------------------------- ### Clone QCoDeS Repository and Install from GitHub Source: https://github.com/microsoft/qcodes/blob/main/docs/start/index.md Clones the QCoDeS repository including submodules and performs an editable install. Changes in the local git clone are automatically available without reinstallation. ```bash git clone --recurse-submodules https://github.com/QCoDeS/Qcodes pip install -e ```