Skip to content

Commit

Permalink
Merge pull request #3 from QCoDeS/master
Browse files Browse the repository at this point in the history
Update
  • Loading branch information
ThorvaldLarsen authored Nov 29, 2017
2 parents ce910b3 + 4c7ed38 commit 341dd9a
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 12 deletions.
3 changes: 2 additions & 1 deletion docs/start/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ Installation
To setup an Anaconda environment for QCoDeS it's convenient to download
QCoDeS environment.yml file from
`here <https://github.com/QCoDeS/Qcodes/blob/master/environment.yml>`__.
Right click on raw and select save link as and download the file to a location
Right click on `this link <https://raw.githubusercontent.com/QCoDeS/Qcodes/master/environment.yml>`__
and select save link as and download the file to a location
that you can find again.
Once Anaconda is installed and the environment.yml file downloaded
launch an Anaconda Prompt.
Expand Down
36 changes: 27 additions & 9 deletions qcodes/data/data_set.py
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,7 @@ def read_metadata(self):
return
self.formatter.read_metadata(self)

def write(self, write_metadata=False, only_complete=True):
def write(self, write_metadata=False, only_complete=True, filename=None):
"""
Writes updates to the DataSet to storage.
N.B. it is recommended to call data_set.finalize() when a DataSet is
Expand All @@ -480,15 +480,26 @@ def write(self, write_metadata=False, only_complete=True):
only_complete (bool): passed on to the match_save_range inside
self.formatter.write. Used to ensure that all new data gets
saved even when some columns are strange.
filename (Optional[str]): The filename (minus extension) to use.
The file gets saved in the usual location.
"""
if self.location is False:
return

self.formatter.write(self,
self.io,
self.location,
write_metadata=write_metadata,
only_complete=only_complete)
# Only the gnuplot formatter has a "filename" kwarg
if isinstance(self.formatter, GNUPlotFormat):
self.formatter.write(self,
self.io,
self.location,
write_metadata=write_metadata,
only_complete=only_complete,
filename=filename)
else:
self.formatter.write(self,
self.io,
self.location,
write_metadata=write_metadata,
only_complete=only_complete)

def write_copy(self, path=None, io_manager=None, location=None):
"""
Expand Down Expand Up @@ -562,21 +573,28 @@ def save_metadata(self):
self.snapshot()
self.formatter.write_metadata(self, self.io, self.location)

def finalize(self):
def finalize(self, filename=None, write_metadata=True):
"""
Mark the DataSet complete and write any remaining modifications.
Also closes the data file(s), if the ``Formatter`` we're using
supports that.
Args:
filename (Optional[str]): The file name (minus extension) to
write to. The location of the file is the usual one.
write_metadata (bool): Whether to save a snapshot. For e.g. dumping
raw data inside a loop, a snapshot is not wanted.
"""
log.debug('Finalising the DataSet. Writing.')
# write all new data, not only (to?) complete columns
self.write(only_complete=False)
self.write(only_complete=False, filename=filename)

if hasattr(self.formatter, 'close_file'):
self.formatter.close_file(self)

self.save_metadata()
if write_metadata:
self.save_metadata()

def snapshot(self, update=False):
"""JSON state of the DataSet."""
Expand Down
11 changes: 9 additions & 2 deletions qcodes/data/gnuplot_format.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ def _get_labels(self, labelstr):
return [l.replace('\\"', '"').replace('\\\\', '\\') for l in parts]

def write(self, data_set, io_manager, location, force_write=False,
write_metadata=True, only_complete=True):
write_metadata=True, only_complete=True, filename=None):
"""
Write updates in this DataSet to storage.
Expand All @@ -259,6 +259,9 @@ def write(self, data_set, io_manager, location, force_write=False,
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.
"""
arrays = data_set.arrays

Expand All @@ -271,7 +274,11 @@ def write(self, data_set, io_manager, location, force_write=False,
for group in groups:
log.debug('Attempting to write the following '
'group: {}'.format(group))
fn = io_manager.join(location, group.name + self.extension)

if filename:
fn = io_manager.join(location, filename + self.extension)
else:
fn = io_manager.join(location, group.name + self.extension)

written_files.add(fn)

Expand Down
7 changes: 7 additions & 0 deletions qcodes/instrument_drivers/ZI/ZIUHFLI.py
Original file line number Diff line number Diff line change
Expand Up @@ -513,6 +513,9 @@ def get(self):
ValueError: If the scope has not been prepared by running the
prepare_scope function.
"""
t_start = time.monotonic()
log.info('Scope get method called')

if not self._instrument.scope_correctly_built:
raise ValueError('Scope not properly prepared. Please run '
'prepare_scope before measuring.')
Expand Down Expand Up @@ -616,6 +619,10 @@ def get(self):
finally:
# cleanup and make ready for next scope acquisition
scope.finish()

t_stop = time.monotonic()
log.info('scope get method returning after {} s'.format(t_stop -
t_start))
return data

@staticmethod
Expand Down

0 comments on commit 341dd9a

Please sign in to comment.