qcodes_loop.data.gnuplot_format¶
- class qcodes_loop.data.gnuplot_format.GNUPlotFormat(extension='dat', terminator='\n', separator='\t', comment='# ', number_format='.15g', metadata_file=None)¶
Saves data in one or more gnuplot-format files. We make one file for each set of matching dependent variables in the loop.
- Parameters:
extension (str) – file extension for data files. Defaults to ‘dat’
terminator (str) – newline character(s) to use on write not used for reading, we will read any combination of ‘\r’ and ‘\n’. Defaults to ‘\n’
separator (str) – field (column) separator, must be whitespace. Only used for writing, we will read with any whitespace separation. Defaults to ‘\t’.
comment (str) – lines starting with this are not data Comments are written with this full string, and identified on read by just the string after stripping whitespace. Defaults to ‘# ‘.
number_format (str) – from the format mini-language, how to format numeric data into a string. Defaults to ‘g’.
always_nest (bool) – whether to always make a folder for files or just make a single data file if all data has the same setpoints. Defaults to bool.
These files are basically tab-separated values, but any quantity of any whitespace characters is accepted.
Each row represents one setting of the setpoint variable(s) the setpoint variable(s) are in the first column(s) measured variable(s) come after.
The data is preceded by comment lines (starting with #). We use three:
one for the variable name
the (longer) axis label, in quotes so a label can contain whitespace.
for each dependent var, the (max) number of points in that dimension (this also tells us how many dependent vars we have in this file)
# id1 id2 id3... # "label1" "label2" "label3"... # 100 250 1 2 3... 2 3 4...
For data of 2 dependent variables, gnuplot puts each inner loop into one block, then increments the outer loop in the next block, separated by a blank line.
We extend this to an arbitrary quantity of dependent variables by using one blank line for each loop level that resets. (gnuplot does seem to use 2 blank lines sometimes, to denote a whole new dataset, which sort of corresponds to our situation.)
- read_metadata(data_set)¶
Read the metadata from this DataSet from storage.
Subclasses must override this method.
- Parameters:
data_set – the data to read metadata into
- read_one_file(data_set, f, ids_read)¶
Called by Formatter.read to bring one data file into a DataSet. Setpoint data may be duplicated across multiple files, but each measured DataArray must only map to one file.
- Parameters:
data_set – the DataSet we are reading into
f – a file-like object to read from
ids_read – a set of array_ids that we have already read. when you read an array, check that it’s not in this set (except setpoints, which can be in several files with different inner loop) then add it to the set so other files know not to read it again
- write(data_set: qcodes_loop.data.data_set.DataSet, io_manager, location, force_write=False, write_metadata=True, only_complete=True, filename=None)¶
Write updates in this DataSet to storage.
Will choose append if possible, overwrite if not.
- Parameters:
data_set – the data we’re storing
io_manager (io_manager) – the base location to write to
location (str) – the file location within io_manager
only_complete (bool) – passed to match_save_range, answers the following question: Should we write all available new data, or only complete rows? Is used to make sure that everything gets written when the DataSet is finalised, even if some dataarrays are strange (like, full of nans)
filename (Optional[str]) – Filename to save to. Will override the usual naming scheme and possibly overwrite files, so use with care. The file will be saved in the normal location.
- write_metadata(data_set: qcodes_loop.data.data_set.DataSet, io_manager, location, read_first=True, **kwargs)¶
Write all metadata in this DataSet to storage.
- Parameters:
data_set – the data we’re storing
io_manager (io_manager) – the base location to write to
location (str) – the file location within io_manager
read_first (Optional[bool]) – read previously saved metadata before writing? The current metadata will still be the used if there are changes, but if the saved metadata has information not present in the current metadata, it will be retained. Default True.