qcodes_loop.data.location¶
Standard location_provider class(es) for creating DataSet locations.
- class qcodes_loop.data.location.FormatLocation(fmt=None, fmt_date=None, fmt_time=None, fmt_counter=None, record=None)¶
This is the default DataSet Location provider.
It provides a callable that returns a new (not used by another DataSet) location string, based on a format string
fmt
and a dictrecord
of information to pass tofmt
.Default record items are
date
,time
, andcounter
Record item priority from lowest to highest (double items will be overwritten):current
date
, andtime
record dict from
__init__
record dict from
__call__
automatic
counter
For example if any record dict contains a date keyword, it will no longer be auto-generated.
Uses
io.list
to search for existing data at a matching location.counter
must NOT be provided in the record. Iffmt
contains ‘{counter}’, we look for existing files matching everything BEFORE this, then find the highest counter (integer) among those files and use the next value.If the format string does not contain
{counter}
but the location we would return is occupied, we add'_{counter}'
to the end.Usage:
loc_provider = FormatLocation( fmt='{date}/#{counter}_{time}_{name}_{label}') loc = loc_provider(DiskIO('.'), record={'name': 'Rainbow', 'label': 'test'}) loc > '2016-04-30/#001_13-28-15_Rainbow_test'
- Parameters:
fmt (Optional[str]) – a format string that all the other info will be inserted into. Default ‘{date}/{time}’, or ‘{date}/{time}_{name}’ if there is a
name
in the record.fmt_date (Optional[str]) – a
datetime.strftime
format string, should only use the date part. The result will be inserted in ‘{date}’ infmt
. Default ‘%Y-%m-%d’.fmt_time (Optional[str]) – a
datetime.strftime
format string, should only use the time part. The result will be inserted in ‘{time}’ infmt
. Default ‘%H-%M-%S’.fmt_counter (Optional[str]) – a format string for the counter (integer) which is automatically generated from existing DataSets that the io manager can see. Default ‘{03}’.
record (Optional[dict]) – A dict of default values to provide when calling the location_provider. Values provided later will override these values.
Note
Do not include date/time or number formatting in
fmt
itself, such as ‘{date:%Y-%m-%d}’ or ‘{counter:03}’