The Location Formatter controls the format of the location to which data are saved.
This notebook shows some examples of setting different location formats.
%matplotlib nbagg
import matplotlib.pyplot as plt
import time
import numpy as np
import qcodes as qc
Magic only supported for Python version 3.6 and up
# First we set up some mock experiment
from qcodes.tests.instrument_mocks import DummyInstrument
gates = DummyInstrument('some_gates', gates=['plunger', 'left', 'topo'])
meter = DummyInstrument('meter', gates=['voltage', 'current'])
station = qc.Station(gates, meter)
Now let's run some loops to get datasets and see where they end up.
When writing the location format, some fields are automatically filled out.
That is the fields '{date}', '{time}', and '{counter}'. All other fields must have their values provided via the record dict.
loc_fmt='{date}/#{counter}_{name}_{date}_{time}' # set the desired location format
rcd={'name': 'unicorn'} # provide a value for 'name'
loc_provider = qc.FormatLocation(fmt=loc_fmt, record=rcd) # create a location provider using that format
loop = qc.Loop(gates.plunger.sweep(0, 1, num=25), 0).each(meter.voltage)
data2 = loop.run(location=loc_provider)
Started at 2017-12-15 11:09:08 DataSet: location = '2017-12-15/#005_unicorn_2017-12-15_11-09-08' <Type> | <array_id> | <array.name> | <array.shape> Setpoint | some_gates_plunger_set | plunger | (25,) Measured | meter_voltage | voltage | (25,) Finished at 2017-12-15 11:09:08
# Now let's do that a few times with different formats
import numpy as np
loc_fmt='my_custom_folder/#{counter}_randomnumber_{name}_{date}_{time}'
rcd = {'name': str(np.random.randint(1, 100))}
loc_provider = qc.FormatLocation(fmt=loc_fmt, record=rcd)
loop = qc.Loop(gates.plunger.sweep(0, 1, num=25), 0).each(meter.voltage)
data2 = loop.run(location=loc_provider)
Started at 2017-12-15 11:09:09 DataSet: location = 'my_custom_folder/#011_randomnumber_69_2017-12-15_11-09-09' <Type> | <array_id> | <array.name> | <array.shape> Setpoint | some_gates_plunger_set | plunger | (25,) Measured | meter_voltage | voltage | (25,) Finished at 2017-12-15 11:09:09
# You can also overwrite the custom fields
loc_fmt='{date}/#{counter}_{name}_{date}_{time}'
rcd = {'time': 'hammer_time'}
loc_provider = qc.FormatLocation(fmt=loc_fmt, record=rcd)
loop = qc.Loop(gates.plunger.sweep(0, 1, num=25), 0).each(meter.voltage)
data2 = loop.run(location=loc_provider)
Started at 2017-12-15 11:09:09 DataSet: location = '2017-12-15/#006_{name}_2017-12-15_hammer_time' <Type> | <array_id> | <array.name> | <array.shape> Setpoint | some_gates_plunger_set | plunger | (25,) Measured | meter_voltage | voltage | (25,) Finished at 2017-12-15 11:09:09