This page was generated from docs/examples/legacy/Datasaving examples.ipynb. Interactive online version: Binder badge.

Datasaving Examples

[1]:
%matplotlib nbagg
import numpy as np
from importlib import reload
import qcodes as qc

from qcodes.loops import Loop
[2]:
import sys
import logging
# Create logger
logger = logging.getLogger()
logger.setLevel(logging.DEBUG)

# Create STDERR handler
handler = logging.StreamHandler(sys.stderr)
# ch.setLevel(logging.DEBUG)

# Create formatter and add it to the handler
formatter = logging.Formatter('%(name)s - %(levelname)s - %(message)s')
handler.setFormatter(formatter)

# Set STDERR handler as the only handler
logger.handlers = [handler]
[3]:
from qcodes.data import hdf5_format
reload(hdf5_format)
h5fmt = hdf5_format.HDF5Format()

Start a loop and generate data from dummy instruments

[4]:
station = qc.station.Station()
[5]:
from qcodes.tests.instrument_mocks import MockParabola
station.add_component(MockParabola(name='MockParabola'))
[5]:
'MockParabola'
[6]:
loop = Loop(station.MockParabola.x[-100:100:20]).each(station.MockParabola.skewed_parabola)
data_l = loop.run(name='MockParabola_run', formatter=qc.data.gnuplot_format.GNUPlotFormat())


qcodes.data.data_set - DEBUG - Attempting to write
qcodes.data.gnuplot_format - DEBUG - Attempting to write the following group: MockParabola_x_set
qcodes.data.gnuplot_format - DEBUG - Cannot match save range, skipping this group.
qcodes.data.data_set - DEBUG - Finalising the DataSet. Writing.
qcodes.data.gnuplot_format - DEBUG - Attempting to write the following group: MockParabola_x_set
qcodes.data.gnuplot_format - DEBUG - Wrote header to file
qcodes.data.gnuplot_format - DEBUG - Wrote to file from 0 to 10
Started at 2022-07-04 11:39:21
DataSet:
   location = 'data/2022-07-04/#008_MockParabola_run_11-39-21'
   <Type>   | <array_id>                   | <array.name>    | <array.shape>
   Setpoint | MockParabola_x_set           | x               | (10,)
   Measured | MockParabola_skewed_parabola | skewed_parabola | (10,)
Finished at 2022-07-04 11:39:21
[7]:
reload(hdf5_format)
h5fmt = hdf5_format.HDF5Format()
loop = Loop(station.MockParabola.x[-100:100:20]).loop(
    station.MockParabola.y[-100:50:10]).each(station.MockParabola.skewed_parabola)
data_l = loop.run(name='MockParabola_run', formatter=h5fmt)

h5py._conv - DEBUG - Creating converter from 5 to 3
qcodes.data.data_set - DEBUG - Attempting to write
qcodes.data.data_set - DEBUG - Finalising the DataSet. Writing.
Started at 2022-07-04 11:39:21
DataSet:
   location = 'data/2022-07-04/#009_MockParabola_run_11-39-21'
   <Type>   | <array_id>                   | <array.name>    | <array.shape>
   Setpoint | MockParabola_x_set           | x               | (10,)
   Setpoint | MockParabola_y_set           | y               | (10, 15)
   Measured | MockParabola_skewed_parabola | skewed_parabola | (10, 15)
Finished at 2022-07-04 11:39:21
[8]:
from importlib import reload
from qcodes.data import hdf5_format
reload(hdf5_format)
h5fmt = hdf5_format.HDF5Format()
data2 = qc.data.data_set.DataSet(location=data_l.location, formatter=h5fmt)
data2.read()
h5py._conv - DEBUG - Creating converter from 3 to 5