diff --git a/docs/examples/Tutorial.ipynb b/docs/examples/Tutorial.ipynb index 46d9d0ee0c8..a4131864ce2 100644 --- a/docs/examples/Tutorial.ipynb +++ b/docs/examples/Tutorial.ipynb @@ -480,23 +480,11 @@ }, { "cell_type": "code", - "execution_count": 7, + "execution_count": 5, "metadata": { "collapsed": false }, "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Data is DataSet:\n", - " mode = DataMode.LOCAL\n", - " location = 'data/2016-08-25/#031_{name}_16-41-22'\n", - " | | | \n", - " Setpoint | gates_chan0_set | chan0 | (401,)\n", - " Measured | meter_amplitude | amplitude | (401,)\n" - ] - }, { "data": { "application/javascript": [ @@ -1264,7 +1252,7 @@ { "data": { "text/html": [ - "" + "" ], "text/plain": [ "" @@ -1279,11 +1267,11 @@ "text": [ "DataSet:\n", " mode = DataMode.LOCAL\n", - " location = 'data/2016-08-25/#031_{name}_16-41-22'\n", + " location = 'data/2016-08-26/#002_{name}_09-05-27'\n", " | | | \n", " Setpoint | gates_chan0_set | chan0 | (401,)\n", " Measured | meter_amplitude | amplitude | (401,)\n", - "started at 2016-08-25 16:41:46\n" + "started at 2016-08-26 09:05:50\n" ] }, { @@ -1291,13 +1279,13 @@ "text/plain": [ "DataSet:\n", " mode = DataMode.LOCAL\n", - " location = 'data/2016-08-25/#031_{name}_16-41-22'\n", + " location = 'data/2016-08-26/#002_{name}_09-05-27'\n", " | | | \n", " Setpoint | gates_chan0_set | chan0 | (401,)\n", " Measured | meter_amplitude | amplitude | (401,)" ] }, - "execution_count": 7, + "execution_count": 5, "metadata": {}, "output_type": "execute_result" } @@ -1309,16 +1297,11 @@ "\n", "# data = qc.Loop(c0.sweep(-20,20,0.1), delay=0.003).each(meter.amplitude).run(location='testsweep', overwrite=True)\n", "loop = qc.Loop(c0.sweep(-20,20,0.1), delay=0.01).each(meter.amplitude)\n", - "data = loop.get_data_set(data_manager=False, write_period=None)\n", - "print('Data is %r' % data)\n", + "data = loop.get_data_set(data_manager=False)\n", "#plot = qc.QtPlot()\n", "plot = qc.MatPlot()\n", "plot.add(data.meter_amplitude)\n", - "def bg():\n", - " #data.sync()\n", - " plot.update_bg()\n", - " pass\n", - "loop.with_bg_task(bg, 0.0005).run(name='testsweep',background=False)\n", + "loop.with_bg_task(plot.update, 0.0005).run(name='testsweep',background=False)\n", "#loop.run(name='testsweep',background=False,location=False)\n", "\n", "# There should be two extra processes running, DataServer and a sweep \n", diff --git a/qcodes/data/data_set.py b/qcodes/data/data_set.py index d19427e2184..4d288141594 100644 --- a/qcodes/data/data_set.py +++ b/qcodes/data/data_set.py @@ -271,6 +271,7 @@ def __init__(self, location=None, mode=DataMode.LOCAL, arrays=None, self.write_period = write_period self.last_write = 0 + self.last_store = -1 self.metadata = {} @@ -384,7 +385,9 @@ def sync(self): # version on the DataServer from the main copy) if not self.is_live_mode: # LOCAL DataSet - just read it in - # TODO: compare timestamps to know if we need to read? + # Compare timestamps to avoid overwriting unsaved data + if self.last_store > self.last_write: + return True try: self.read() except IOError: @@ -592,6 +595,7 @@ def store(self, loop_indices, ids_values): else: for array_id, value in ids_values.items(): self.arrays[array_id][loop_indices] = value + self.last_store = time.time() if (self.write_period is not None and time.time() > self.last_write + self.write_period): self.write() diff --git a/qcodes/plots/base.py b/qcodes/plots/base.py index fc145f6593b..d8c9d96209c 100644 --- a/qcodes/plots/base.py +++ b/qcodes/plots/base.py @@ -266,19 +266,6 @@ def update(self): if any_updates is False: self.halt() - def update_bg(self): - """ - Update the data in this plot, using the updaters given with - MatPlot.add() or in the included DataSets, then include this in - the plot. - - This is a wrapper routine that a loop background task may call, - inside this we call self.update_plot() which should be subclassed - """ - for updater in self.data_updaters: - updates = updater() - self.update_plot() - def update_plot(self): """ Update the plot itself (typically called by self.update).