From 276f0ea6912966b4bb2dc3828fd58f0a94abf9c3 Mon Sep 17 00:00:00 2001 From: "Jens H. Nielsen" Date: Thu, 15 Feb 2018 09:50:34 +0100 Subject: [PATCH 01/22] add version checks to zi driver This ensures that we can use apilevel 6 which we will do in the following --- qcodes/instrument_drivers/ZI/ZIUHFLI.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/qcodes/instrument_drivers/ZI/ZIUHFLI.py b/qcodes/instrument_drivers/ZI/ZIUHFLI.py index 06eac506e25..ee456eccfc3 100644 --- a/qcodes/instrument_drivers/ZI/ZIUHFLI.py +++ b/qcodes/instrument_drivers/ZI/ZIUHFLI.py @@ -3,6 +3,7 @@ import numpy as np from functools import partial from math import sqrt +from distutils.version import LooseVersion from typing import Callable, List, Union @@ -680,9 +681,16 @@ def __init__(self, name: str, device_ID: str, **kwargs) -> None: """ super().__init__(name, **kwargs) - self.api_level = 5 + self.api_level = 6 zisession = zhinst.utils.create_api_session(device_ID, self.api_level) (self.daq, self.device, self.props) = zisession + if not LooseVersion(self.props['serverversion']) > LooseVersion('17.06.00000'): + raise RuntimeError('This driver requires at least version 17.06 of LabOne along with ' + 'matching Python driver') + # check that python driver matches dataserver version + # raise if that is not the case + if not zhinst.utils.api_server_version_check(self.daq): + raise RuntimeError('ZI python driver version does not match ZI LabOne version') self.daq.setDebugLevel(3) # create (instantiate) an instance of each module we will use From 6cf3e23f332edb4b1467cae6b7f9fb61d97526df Mon Sep 17 00:00:00 2001 From: "Jens H. Nielsen" Date: Thu, 15 Feb 2018 16:50:12 +0100 Subject: [PATCH 02/22] add wip ZI driver with support for daq module --- .../Qcodes example with ZI UHF-LI.ipynb | 150 +++++++++++++++- qcodes/instrument_drivers/ZI/ZIUHFLI.py | 164 +++++++++++++++++- 2 files changed, 307 insertions(+), 7 deletions(-) diff --git a/docs/examples/driver_examples/Qcodes example with ZI UHF-LI.ipynb b/docs/examples/driver_examples/Qcodes example with ZI UHF-LI.ipynb index 472c31a512d..c0aa83bab01 100644 --- a/docs/examples/driver_examples/Qcodes example with ZI UHF-LI.ipynb +++ b/docs/examples/driver_examples/Qcodes example with ZI UHF-LI.ipynb @@ -24,7 +24,17 @@ "metadata": { "scrolled": true }, - "outputs": [], + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "User schema at C:\\Users\\Jens/qcodesrc_schema.json not found.User settings won't be validated\n", + "C:\\Users\\Jens\\Anaconda3\\envs\\qcodes\\lib\\site-packages\\h5py\\__init__.py:36: FutureWarning: Conversion of the second argument of issubdtype from `float` to `np.floating` is deprecated. In future, it will be treated as `np.float64 == np.dtype(float).type`.\n", + " from ._conv import register_converters as _register_converters\n" + ] + } + ], "source": [ "%matplotlib notebook\n", "import time\n", @@ -56,11 +66,19 @@ "scrolled": false }, "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Discovered device `dev2235`: UHFLI with options DIG.\n", + "Creating an API session for device `dev2235` on `127.0.0.1`, `8004` with apilevel `6`.\n" + ] + }, { "name": "stderr", "output_type": "stream", "text": [ - "c:\\users\\qcodes-jhn\\src\\qcodes\\qcodes\\instrument\\parameter.py:207: UserWarning: Wrapping get method, original get method will not be directly accessible. It is recommended to define get_raw in your subclass instead.\n", + "c:\\users\\jens\\src\\qcodes\\qcodes\\instrument\\parameter.py:209: UserWarning: Wrapping get method, original get method will not be directly accessible. It is recommended to define get_raw in your subclass instead.\n", " warnings.warn('Wrapping get method, original get method will not '\n" ] } @@ -3112,13 +3130,135 @@ "zi.demod1_phi()" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# DAQ Module" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Support for the daq module is still very much work in progress " + ] + }, { "cell_type": "code", - "execution_count": 23, + "execution_count": 4, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "'POS_EDGE'" + ] + }, + "execution_count": 4, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "zi.daqmodule.trigger_input('TRIGIN1')\n", + "zi.daqmodule.trigger_type.set('HW_TRIGGER')\n", + "zi.daqmodule.trigger_edge_type.get()" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": {}, + "outputs": [], + "source": [ + "zi.daqmodule.columns(200)" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "metadata": {}, + "outputs": [], + "source": [ + "zi.daqmodule.data.build_data_arrays()\n", + "data = zi.daqmodule.data.get()" + ] + }, + { + "cell_type": "code", + "execution_count": 9, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "array([9.62797523e-07, 8.04958443e-07, 1.06341157e-06, 1.37388952e-06,\n", + " 1.48258313e-06, 6.28058682e-07, 7.50828387e-07, 1.01222282e-06,\n", + " 6.65265286e-07, 8.06211928e-07, 9.54941147e-07, 9.84722871e-07,\n", + " 8.74885159e-07, 6.98346484e-07, 7.61979235e-08, 4.62138036e-07,\n", + " 9.87647727e-07, 1.61846368e-06, 1.74828512e-06, 2.00144208e-06,\n", + " 2.20700590e-06, 2.24925292e-06, 2.12170836e-06, 1.96977505e-06,\n", + " 1.81981399e-06, 1.47416780e-06, 1.14329624e-06, 1.28077167e-06,\n", + " 1.48811569e-06, 1.25731536e-06, 6.97670554e-07, 5.50757397e-07,\n", + " 6.75397686e-07, 1.03321685e-06, 7.77700400e-07, 7.08598022e-07,\n", + " 1.12070180e-06, 1.40184159e-06, 1.66593748e-06, 1.88603315e-06,\n", + " 1.40016752e-06, 7.09404817e-07, 4.41244289e-07, 7.16454724e-07,\n", + " 7.75920431e-07, 5.20011012e-07, 1.21193726e-06, 1.23576260e-06,\n", + " 8.35729185e-07, 1.47233450e-06, 2.10486934e-06, 2.65404487e-06,\n", + " 3.04980489e-06, 2.53689312e-06, 2.07792837e-06, 1.14731408e-06,\n", + " 2.11093393e-07, 5.92542416e-07, 8.30186441e-07, 8.91930080e-07,\n", + " 7.46569773e-07, 3.68208143e-07, 5.43955602e-07, 1.00859613e-06,\n", + " 1.50665029e-06, 1.71347597e-06, 1.07244252e-06, 7.30035808e-07,\n", + " 3.54153276e-07, 4.62622698e-07, 4.92681259e-07, 4.64292590e-07,\n", + " 2.74474863e-07, 1.05537583e-06, 1.43496846e-06, 1.50548009e-06,\n", + " 1.64151666e-06, 1.65117043e-06, 1.32389868e-06, 6.53702354e-07,\n", + " 5.14789950e-07, 7.63890673e-07, 5.04968945e-07, 4.31412728e-07,\n", + " 6.35746608e-07, 2.13302657e-07, 8.06077653e-07, 1.12156476e-06,\n", + " 1.09143933e-06, 9.74565605e-07, 1.04794735e-06, 1.12152904e-06,\n", + " 1.09824555e-06, 8.24341904e-07, 2.76915153e-07, 2.06543300e-07,\n", + " 5.43836461e-07, 1.29605307e-06, 1.54052534e-06, 1.41912129e-06,\n", + " 1.10192499e-06, 7.31329834e-07, 8.04124999e-07, 1.06866528e-06,\n", + " 1.33492687e-06, 1.24983995e-06, 1.24463723e-06, 1.31979414e-06,\n", + " 1.38392460e-06, 2.30962147e-06, 3.32331485e-06, 3.50715659e-06,\n", + " 3.22839019e-06, 2.50474036e-06, 1.87360168e-06, 1.80156203e-06,\n", + " 1.86163230e-06, 1.90178450e-06, 2.23166977e-06, 1.98599968e-06,\n", + " 1.62571355e-06, 1.36431003e-06, 1.24802862e-06, 1.00310654e-06,\n", + " 8.28769678e-07, 7.95466968e-07, 7.37302278e-07, 5.44224198e-07,\n", + " 2.82798564e-07, 5.00462508e-07, 6.97736978e-07, 9.84514058e-07,\n", + " 1.64826450e-06, 2.03425342e-06, 2.13572180e-06, 2.46080531e-06,\n", + " 2.40871716e-06, 2.32545058e-06, 2.37779238e-06, 2.80640844e-06,\n", + " 2.74705822e-06, 2.36795507e-06, 2.38890708e-06, 2.63284052e-06,\n", + " 2.40365047e-06, 2.00263320e-06, 1.42755511e-06, 6.91753900e-07,\n", + " 5.05061496e-07, 7.78450033e-07, 1.21070818e-06, 1.67870181e-06,\n", + " 2.12390807e-06, 2.07973872e-06, 2.09172895e-06, 2.04646909e-06,\n", + " 1.70347111e-06, 1.57525799e-06, 1.47930632e-06, 8.57162008e-07,\n", + " 5.34712357e-07, 6.57461822e-07, 9.58898225e-07, 1.12236703e-06,\n", + " 1.02895174e-06, 6.74954582e-07, 6.40933283e-07, 1.03378006e-06,\n", + " 6.85591836e-07, 8.15467194e-07, 1.51475641e-06, 1.94040429e-06,\n", + " 1.95794788e-06, 1.35824810e-06, 8.77464231e-07, 1.37068332e-07,\n", + " 1.06406271e-06, 1.67249589e-06, 2.60365326e-06, 2.84262930e-06,\n", + " 2.37061279e-06, 2.08979006e-06, 2.00656179e-06, 1.49767206e-06,\n", + " 7.48757064e-07, 5.89669534e-07, 4.72284194e-07, 2.80930687e-07,\n", + " 1.07171288e-07, 2.66211295e-07, 3.95928018e-07, 4.76909325e-07,\n", + " 7.83839818e-07, 5.94969018e-07, 6.22877229e-07, 1.08413528e-06,\n", + " 1.76413485e-06, 2.20431621e-06, 2.01482982e-06, 1.86831950e-06])" + ] + }, + "execution_count": 9, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "data" + ] + }, + { + "cell_type": "markdown", "metadata": { "collapsed": true }, - "outputs": [], "source": [ "zi.close()" ] @@ -3141,7 +3281,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.6.3" + "version": "3.6.4" } }, "nbformat": 4, diff --git a/qcodes/instrument_drivers/ZI/ZIUHFLI.py b/qcodes/instrument_drivers/ZI/ZIUHFLI.py index ee456eccfc3..9ebb7eef8e0 100644 --- a/qcodes/instrument_drivers/ZI/ZIUHFLI.py +++ b/qcodes/instrument_drivers/ZI/ZIUHFLI.py @@ -3,7 +3,7 @@ import numpy as np from functools import partial from math import sqrt -from distutils.version import LooseVersion +from distutils.version import StrictVersion from typing import Callable, List, Union @@ -107,6 +107,153 @@ def __init__(self, parent: 'ZIUHFLI', name: str, channum: int) -> None: val_mapping=outputvalmapping ) + +class DataAcquisitionArray(MultiParameter): + def __init__(self, name, instrument, **kwargs): + # The __init__ requires that we supply names and shapes, + # but there is no way to know what they could be known at this time. + # They are updated via build_data_arrays. + super().__init__(name, names=('',), shapes=((1,),), **kwargs) + self._instrument = instrument + + def build_data_arrays(self): + # todo setpoints and handle more than one signal correctly + self.names = ('foobar',) + self.labels = ('Foo Bar', ) + self.units = ('v or something',) + + n_signals = 1 + ncols = self._instrument.columns() + self.shapes = ((ncols,),)*n_signals + + def get(self): + # todo map this to parameters. Try to match both the + # scope api and the zi api as much as possible + trigger_demod_index = 0 + triggerpath = '/{}/demods/{}/sample.{}'.format(self._instrument._parent.device, + self._instrument.trigger_demodulator.get_raw(), + self._instrument.trigger_input.get()) + self._instrument._parent.data_acquisition_module.set('dataAcquisitionModule/triggernode', triggerpath) + # trigger_duration = 35e-3 + # The length of time to record the data for each time we trigger. + # self._parent.data_acquisition_module.set('dataAcquisitionModule/duration', trigger_duration) + trigger_delay = -0.01e-3 + self._instrument._parent.data_acquisition_module.set('dataAcquisitionModule/delay', trigger_delay) + # Do not return overlapped trigger events. + self._instrument._parent.data_acquisition_module.set('dataAcquisitionModule/holdoff/time', 200e-3) + self._instrument._parent.data_acquisition_module.set('dataAcquisitionModule/holdoff/count', 0) + self._instrument._parent.data_acquisition_module.set('dataAcquisitionModule/grid/mode', 4) + # dataAcquisitionModule/grid/repetitions (int) + # The number of times to average. + repetitions = 1 + self._instrument._parent.data_acquisition_module.set('dataAcquisitionModule/grid/repetitions', repetitions) + # dataAcquisitionModule/grid/cols (int) + # Specify the number of columns in the grid's matrix. The data from each + # row is interpolated onto a grid with the specified number of columns. + # num_cols = 512 + # self._parent.data_acquisition_module.set('dataAcquisitionModule/grid/cols', num_cols) + # dataAcquisitionModule/grid/rows (int) + # Specify the number of rows in the grid's matrix. Each row is the data + # recorded from one trigger. + num_rows = 1 + self._instrument._parent.data_acquisition_module.set('dataAcquisitionModule/grid/rows', num_rows) + # dataAcquisitionModule/grid/direction (int) + # Specify the ordering of the data stored in the grid's matrix. + # 0: Forward - the data in each row is ordered chronologically, e.g., the + # first data point in each row corresponds to the first timestamp in the + # trigger data. + # 1: Reverse - the data in each row is ordered reverse chronologically, + # e.g., the first data point in each row corresponds to the last + # timestamp in the trigger data. + # 2: Bidirectional - the ordering of the data alternates between Forward + # and Backward ordering from row-to-row. The first row is Forward ordered. + self._instrument._parent.data_acquisition_module.set('dataAcquisitionModule/grid/direction', 0) + + # The number of grids to record (if not running in endless mode). + # In grid mode, we will obtain dataAcquisitionModule/count grids. The total + # number of triggers is equal to n = dataAcquisitionModule/count * + # dataAcquisitionModule/grid/rows * dataAcquisitionModule/grid/repetitions + num_grids = 1 + self._instrument._parent.data_acquisition_module.set('dataAcquisitionModule/count', num_grids) + + datapath = '/{}/demods/{}/sample.r.avg'.format(self._instrument._parent.device, trigger_demod_index) + data = {} + data[triggerpath] = [] + + self._instrument._parent.data_acquisition_module.subscribe(datapath) + self._instrument._parent.data_acquisition_module.execute() + + # todo calculate meaning full timeout and handle correctly + timeout = 10 # [s] + t0 = time.time() + + while not self._instrument._parent.data_acquisition_module.finished(): + time.sleep(0.05) + if time.time() - t0 > timeout: + print('timed out') + break + return_flat_data_dict = True + data_read = self._instrument._parent.data_acquisition_module.read(return_flat_data_dict) + data = data_read[datapath] + return data[0]['value'][0] + + +class DataAcquisitionModule(InstrumentChannel): + def __init__(self, parent: 'ZIUHFLI', name: str) -> None: + super().__init__(parent, name) + self.data_acquisition_module = self._parent.data_acquisition_module + + self.add_parameter('trigger_type', + label='Trigger type', + set_cmd=partial(self.data_acquisition_module.set, 'dataAcquisitionModule/type'), + get_cmd=partial(self.data_acquisition_module.getInt, 'dataAcquisitionModule/type'), + val_mapping={'NO_TRIGGER': 0, + 'EDGE_TRIGGER': 1, + 'DIGITAL_TRIGGER': 2, + 'PULSE_TRIGGER':3, + 'TRACKING_TRIGGER':4, + 'HW_TRIGGER':6, + 'TRACKING_PULSE_TRIGGER':7, + 'EVENT_COUNT_TRIGGER':8}) + + self.add_parameter('trigger_edge_type', + label='Trigger edge type', + set_cmd=partial(self.data_acquisition_module.set, 'dataAcquisitionModule/edge'), + get_cmd=partial(self.data_acquisition_module.getInt, 'dataAcquisitionModule/edge'), + val_mapping={'POS_EDGE': 1, + 'NEG_EDGE': 2, + 'BOTH_EDGE': 3}) + + self.add_parameter('trigger_demodulator', + label='Trigger demodulator', + get_cmd=None, + set_cmd=None, + initial_value=1, + get_parser=lambda x: x+1, + set_parser=lambda x: x-1, + vals=vals.Ints(1,8)) + + self.add_parameter('trigger_input', + label='Trigger input', + get_cmd=None, + set_cmd=None, + initial_value='X', + vals=vals.Enum('X', 'Y', 'R', 'THETA', 'AUXIN0', 'AUXIN1', 'DIO', + 'TRIGIN1', 'TRIGIN2', 'TRIGIN3', 'TRIGIN4', + 'TRIGOUT1', 'TRIGOUT2', 'TRIGOUT3', 'TRIGOUT4', + 'TRIGDEMOD4PHASE', 'TRIGDEMOD8PHASE' + )) + + self.add_parameter('columns', + label='Columns', + set_cmd=partial(self.data_acquisition_module.set, 'dataAcquisitionModule/grid/cols'), + get_cmd=partial(self.data_acquisition_module.getInt, 'dataAcquisitionModule/grid/cols'), + vals=vals.Ints(1)) + + self.add_parameter('data', + parameter_class=DataAcquisitionArray) + + class Sweep(MultiParameter): """ Parameter class for the ZIUHFLI instrument class for the sweeper. @@ -684,20 +831,31 @@ def __init__(self, name: str, device_ID: str, **kwargs) -> None: self.api_level = 6 zisession = zhinst.utils.create_api_session(device_ID, self.api_level) (self.daq, self.device, self.props) = zisession - if not LooseVersion(self.props['serverversion']) > LooseVersion('17.06.00000'): + myversion = StrictVersion(self.props['serverversion']) + minversion = '17.06.00000' + mindaqversion = '17.12.00000' + if myversion < minversion: raise RuntimeError('This driver requires at least version 17.06 of LabOne along with ' 'matching Python driver') + self.has_data_acquisition_module = False + if myversion > mindaqversion: + self.has_data_acquisition_module = True # check that python driver matches dataserver version # raise if that is not the case if not zhinst.utils.api_server_version_check(self.daq): raise RuntimeError('ZI python driver version does not match ZI LabOne version') self.daq.setDebugLevel(3) + self.daq.sync() # create (instantiate) an instance of each module we will use self.sweeper = self.daq.sweep() self.sweeper.set('sweep/device', self.device) self.scope = self.daq.scopeModule() self.scope.subscribe('/{}/scopes/0/wave'.format(self.device)) + if self.has_data_acquisition_module: + self.data_acquisition_module = self.daq.dataAcquisitionModule() + self.data_acquisition_module.set('dataAcquisitionModule/device', self.device) + self.add_submodule('daqmodule', DataAcquisitionModule(self, 'daqmodule')) ######################################## # INSTRUMENT PARAMETERS @@ -2184,4 +2342,6 @@ def close(self): self.scope.clear() self.sweeper.clear() self.daq.disconnect() + self.data_acquisition_module.finish() + self.data_acquisition_module.clear() super().close() From 6d6ad1c9548c300a344c66d0c13e78394c8ec5d3 Mon Sep 17 00:00:00 2001 From: "Jens H. Nielsen" Date: Fri, 16 Feb 2018 15:06:05 +0100 Subject: [PATCH 03/22] add support for more than one signal to measure --- .../Qcodes example with ZI UHF-LI.ipynb | 1798 ++++++++++++++++- qcodes/instrument_drivers/ZI/ZIUHFLI.py | 112 +- 2 files changed, 1818 insertions(+), 92 deletions(-) diff --git a/docs/examples/driver_examples/Qcodes example with ZI UHF-LI.ipynb b/docs/examples/driver_examples/Qcodes example with ZI UHF-LI.ipynb index c0aa83bab01..74410d6f58e 100644 --- a/docs/examples/driver_examples/Qcodes example with ZI UHF-LI.ipynb +++ b/docs/examples/driver_examples/Qcodes example with ZI UHF-LI.ipynb @@ -202,7 +202,7 @@ }, { "cell_type": "code", - "execution_count": 6, + "execution_count": 11, "metadata": {}, "outputs": [ { @@ -228,6 +228,13 @@ " print(' {}, {} ({})'.format(param, zi.parameters[param].label, zi.parameters[param].unit))" ] }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + }, { "cell_type": "markdown", "metadata": {}, @@ -3052,16 +3059,16 @@ }, { "cell_type": "code", - "execution_count": 21, + "execution_count": 3, "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "array([ 9.23160746e-07])" + "array([0.03524339])" ] }, - "execution_count": 21, + "execution_count": 3, "metadata": {}, "output_type": "execute_result" } @@ -3144,9 +3151,16 @@ "Support for the daq module is still very much work in progress " ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "We can set and get the trigger. Here we chose to trigger on Trigger input 1 with a hardware trigger" + ] + }, { "cell_type": "code", - "execution_count": 4, + "execution_count": 3, "metadata": {}, "outputs": [ { @@ -3155,7 +3169,7 @@ "'POS_EDGE'" ] }, - "execution_count": 4, + "execution_count": 3, "metadata": {}, "output_type": "execute_result" } @@ -3166,92 +3180,1744 @@ "zi.daqmodule.trigger_edge_type.get()" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "And measure 200 points" + ] + }, { "cell_type": "code", - "execution_count": 5, + "execution_count": 4, "metadata": {}, "outputs": [], "source": [ "zi.daqmodule.columns(200)" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "From demod1 at a samplerate of 2 KHz" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": {}, + "outputs": [], + "source": [ + "zi.demod1_samplerate(2e3)" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Total time is 0.11650844444444444\n" + ] + } + ], + "source": [ + "print(\"Total time is {}\".format(zi.daqmodule.columns()/zi.demod1_samplerate()))" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "And average over 100 repetitions" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "metadata": {}, + "outputs": [], + "source": [ + "zi.daqmodule.repetitions(100)" + ] + }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [], "source": [ - "zi.daqmodule.data.build_data_arrays()\n", - "data = zi.daqmodule.data.get()" + "zi.signal_output1_on('ON')" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "We can then pick one or more samples to average over by demodulator and type" ] }, { "cell_type": "code", "execution_count": 9, "metadata": {}, + "outputs": [], + "source": [ + "zi.daqmodule.add_signal_to_daq(1, 'r')\n", + "zi.daqmodule.add_signal_to_daq(1, 'x')\n", + "zi.daqmodule.add_signal_to_daq(1, 'y')\n", + "zi.daqmodule.add_signal_to_daq(1, 'phase')" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Before we can get the date we need to prepare the daqmodule" + ] + }, + { + "cell_type": "code", + "execution_count": 10, + "metadata": {}, + "outputs": [], + "source": [ + "zi.daqmodule.data.build_data_arrays()" + ] + }, + { + "cell_type": "code", + "execution_count": 12, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "DataSet:\n", + " location = 'data/2018-02-16/#013_{name}_15-03-42'\n", + " | | | \n", + " Setpoint | time_set | time | (200,)\n", + " Measured | ZIUHFLI_daqmodule_r | r | (200,)\n", + " Measured | ZIUHFLI_daqmodule_x | x | (200,)\n", + " Measured | ZIUHFLI_daqmodule_y | y | (200,)\n", + " Measured | ZIUHFLI_daqmodule_phase | phase | (200,)\n", + "acquired at 2018-02-16 15:04:03\n" + ] + } + ], + "source": [ + "data = qc.Measure(zi.daqmodule.data).run()" + ] + }, + { + "cell_type": "code", + "execution_count": 13, + "metadata": { + "scrolled": false + }, "outputs": [ { "data": { - "text/plain": [ - "array([9.62797523e-07, 8.04958443e-07, 1.06341157e-06, 1.37388952e-06,\n", - " 1.48258313e-06, 6.28058682e-07, 7.50828387e-07, 1.01222282e-06,\n", - " 6.65265286e-07, 8.06211928e-07, 9.54941147e-07, 9.84722871e-07,\n", - " 8.74885159e-07, 6.98346484e-07, 7.61979235e-08, 4.62138036e-07,\n", - " 9.87647727e-07, 1.61846368e-06, 1.74828512e-06, 2.00144208e-06,\n", - " 2.20700590e-06, 2.24925292e-06, 2.12170836e-06, 1.96977505e-06,\n", - " 1.81981399e-06, 1.47416780e-06, 1.14329624e-06, 1.28077167e-06,\n", - " 1.48811569e-06, 1.25731536e-06, 6.97670554e-07, 5.50757397e-07,\n", - " 6.75397686e-07, 1.03321685e-06, 7.77700400e-07, 7.08598022e-07,\n", - " 1.12070180e-06, 1.40184159e-06, 1.66593748e-06, 1.88603315e-06,\n", - " 1.40016752e-06, 7.09404817e-07, 4.41244289e-07, 7.16454724e-07,\n", - " 7.75920431e-07, 5.20011012e-07, 1.21193726e-06, 1.23576260e-06,\n", - " 8.35729185e-07, 1.47233450e-06, 2.10486934e-06, 2.65404487e-06,\n", - " 3.04980489e-06, 2.53689312e-06, 2.07792837e-06, 1.14731408e-06,\n", - " 2.11093393e-07, 5.92542416e-07, 8.30186441e-07, 8.91930080e-07,\n", - " 7.46569773e-07, 3.68208143e-07, 5.43955602e-07, 1.00859613e-06,\n", - " 1.50665029e-06, 1.71347597e-06, 1.07244252e-06, 7.30035808e-07,\n", - " 3.54153276e-07, 4.62622698e-07, 4.92681259e-07, 4.64292590e-07,\n", - " 2.74474863e-07, 1.05537583e-06, 1.43496846e-06, 1.50548009e-06,\n", - " 1.64151666e-06, 1.65117043e-06, 1.32389868e-06, 6.53702354e-07,\n", - " 5.14789950e-07, 7.63890673e-07, 5.04968945e-07, 4.31412728e-07,\n", - " 6.35746608e-07, 2.13302657e-07, 8.06077653e-07, 1.12156476e-06,\n", - " 1.09143933e-06, 9.74565605e-07, 1.04794735e-06, 1.12152904e-06,\n", - " 1.09824555e-06, 8.24341904e-07, 2.76915153e-07, 2.06543300e-07,\n", - " 5.43836461e-07, 1.29605307e-06, 1.54052534e-06, 1.41912129e-06,\n", - " 1.10192499e-06, 7.31329834e-07, 8.04124999e-07, 1.06866528e-06,\n", - " 1.33492687e-06, 1.24983995e-06, 1.24463723e-06, 1.31979414e-06,\n", - " 1.38392460e-06, 2.30962147e-06, 3.32331485e-06, 3.50715659e-06,\n", - " 3.22839019e-06, 2.50474036e-06, 1.87360168e-06, 1.80156203e-06,\n", - " 1.86163230e-06, 1.90178450e-06, 2.23166977e-06, 1.98599968e-06,\n", - " 1.62571355e-06, 1.36431003e-06, 1.24802862e-06, 1.00310654e-06,\n", - " 8.28769678e-07, 7.95466968e-07, 7.37302278e-07, 5.44224198e-07,\n", - " 2.82798564e-07, 5.00462508e-07, 6.97736978e-07, 9.84514058e-07,\n", - " 1.64826450e-06, 2.03425342e-06, 2.13572180e-06, 2.46080531e-06,\n", - " 2.40871716e-06, 2.32545058e-06, 2.37779238e-06, 2.80640844e-06,\n", - " 2.74705822e-06, 2.36795507e-06, 2.38890708e-06, 2.63284052e-06,\n", - " 2.40365047e-06, 2.00263320e-06, 1.42755511e-06, 6.91753900e-07,\n", - " 5.05061496e-07, 7.78450033e-07, 1.21070818e-06, 1.67870181e-06,\n", - " 2.12390807e-06, 2.07973872e-06, 2.09172895e-06, 2.04646909e-06,\n", - " 1.70347111e-06, 1.57525799e-06, 1.47930632e-06, 8.57162008e-07,\n", - " 5.34712357e-07, 6.57461822e-07, 9.58898225e-07, 1.12236703e-06,\n", - " 1.02895174e-06, 6.74954582e-07, 6.40933283e-07, 1.03378006e-06,\n", - " 6.85591836e-07, 8.15467194e-07, 1.51475641e-06, 1.94040429e-06,\n", - " 1.95794788e-06, 1.35824810e-06, 8.77464231e-07, 1.37068332e-07,\n", - " 1.06406271e-06, 1.67249589e-06, 2.60365326e-06, 2.84262930e-06,\n", - " 2.37061279e-06, 2.08979006e-06, 2.00656179e-06, 1.49767206e-06,\n", - " 7.48757064e-07, 5.89669534e-07, 4.72284194e-07, 2.80930687e-07,\n", - " 1.07171288e-07, 2.66211295e-07, 3.95928018e-07, 4.76909325e-07,\n", - " 7.83839818e-07, 5.94969018e-07, 6.22877229e-07, 1.08413528e-06,\n", - " 1.76413485e-06, 2.20431621e-06, 2.01482982e-06, 1.86831950e-06])" - ] - }, - "execution_count": 9, - "metadata": {}, - "output_type": "execute_result" + "application/javascript": [ + "/* Put everything inside the global mpl namespace */\n", + "window.mpl = {};\n", + "\n", + "\n", + "mpl.get_websocket_type = function() {\n", + " if (typeof(WebSocket) !== 'undefined') {\n", + " return WebSocket;\n", + " } else if (typeof(MozWebSocket) !== 'undefined') {\n", + " return MozWebSocket;\n", + " } else {\n", + " alert('Your browser does not have WebSocket support.' +\n", + " 'Please try Chrome, Safari or Firefox ≥ 6. ' +\n", + " 'Firefox 4 and 5 are also supported but you ' +\n", + " 'have to enable WebSockets in about:config.');\n", + " };\n", + "}\n", + "\n", + "mpl.figure = function(figure_id, websocket, ondownload, parent_element) {\n", + " this.id = figure_id;\n", + "\n", + " this.ws = websocket;\n", + "\n", + " this.supports_binary = (this.ws.binaryType != undefined);\n", + "\n", + " if (!this.supports_binary) {\n", + " var warnings = document.getElementById(\"mpl-warnings\");\n", + " if (warnings) {\n", + " warnings.style.display = 'block';\n", + " warnings.textContent = (\n", + " \"This browser does not support binary websocket messages. \" +\n", + " \"Performance may be slow.\");\n", + " }\n", + " }\n", + "\n", + " this.imageObj = new Image();\n", + "\n", + " this.context = undefined;\n", + " this.message = undefined;\n", + " this.canvas = undefined;\n", + " this.rubberband_canvas = undefined;\n", + " this.rubberband_context = undefined;\n", + " this.format_dropdown = undefined;\n", + "\n", + " this.image_mode = 'full';\n", + "\n", + " this.root = $('
');\n", + " this._root_extra_style(this.root)\n", + " this.root.attr('style', 'display: inline-block');\n", + "\n", + " $(parent_element).append(this.root);\n", + "\n", + " this._init_header(this);\n", + " this._init_canvas(this);\n", + " this._init_toolbar(this);\n", + "\n", + " var fig = this;\n", + "\n", + " this.waiting = false;\n", + "\n", + " this.ws.onopen = function () {\n", + " fig.send_message(\"supports_binary\", {value: fig.supports_binary});\n", + " fig.send_message(\"send_image_mode\", {});\n", + " if (mpl.ratio != 1) {\n", + " fig.send_message(\"set_dpi_ratio\", {'dpi_ratio': mpl.ratio});\n", + " }\n", + " fig.send_message(\"refresh\", {});\n", + " }\n", + "\n", + " this.imageObj.onload = function() {\n", + " if (fig.image_mode == 'full') {\n", + " // Full images could contain transparency (where diff images\n", + " // almost always do), so we need to clear the canvas so that\n", + " // there is no ghosting.\n", + " fig.context.clearRect(0, 0, fig.canvas.width, fig.canvas.height);\n", + " }\n", + " fig.context.drawImage(fig.imageObj, 0, 0);\n", + " };\n", + "\n", + " this.imageObj.onunload = function() {\n", + " fig.ws.close();\n", + " }\n", + "\n", + " this.ws.onmessage = this._make_on_message_function(this);\n", + "\n", + " this.ondownload = ondownload;\n", + "}\n", + "\n", + "mpl.figure.prototype._init_header = function() {\n", + " var titlebar = $(\n", + " '
');\n", + " var titletext = $(\n", + " '
');\n", + " titlebar.append(titletext)\n", + " this.root.append(titlebar);\n", + " this.header = titletext[0];\n", + "}\n", + "\n", + "\n", + "\n", + "mpl.figure.prototype._canvas_extra_style = function(canvas_div) {\n", + "\n", + "}\n", + "\n", + "\n", + "mpl.figure.prototype._root_extra_style = function(canvas_div) {\n", + "\n", + "}\n", + "\n", + "mpl.figure.prototype._init_canvas = function() {\n", + " var fig = this;\n", + "\n", + " var canvas_div = $('
');\n", + "\n", + " canvas_div.attr('style', 'position: relative; clear: both; outline: 0');\n", + "\n", + " function canvas_keyboard_event(event) {\n", + " return fig.key_event(event, event['data']);\n", + " }\n", + "\n", + " canvas_div.keydown('key_press', canvas_keyboard_event);\n", + " canvas_div.keyup('key_release', canvas_keyboard_event);\n", + " this.canvas_div = canvas_div\n", + " this._canvas_extra_style(canvas_div)\n", + " this.root.append(canvas_div);\n", + "\n", + " var canvas = $('');\n", + " canvas.addClass('mpl-canvas');\n", + " canvas.attr('style', \"left: 0; top: 0; z-index: 0; outline: 0\")\n", + "\n", + " this.canvas = canvas[0];\n", + " this.context = canvas[0].getContext(\"2d\");\n", + "\n", + " var backingStore = this.context.backingStorePixelRatio ||\n", + "\tthis.context.webkitBackingStorePixelRatio ||\n", + "\tthis.context.mozBackingStorePixelRatio ||\n", + "\tthis.context.msBackingStorePixelRatio ||\n", + "\tthis.context.oBackingStorePixelRatio ||\n", + "\tthis.context.backingStorePixelRatio || 1;\n", + "\n", + " mpl.ratio = (window.devicePixelRatio || 1) / backingStore;\n", + "\n", + " var rubberband = $('');\n", + " rubberband.attr('style', \"position: absolute; left: 0; top: 0; z-index: 1;\")\n", + "\n", + " var pass_mouse_events = true;\n", + "\n", + " canvas_div.resizable({\n", + " start: function(event, ui) {\n", + " pass_mouse_events = false;\n", + " },\n", + " resize: function(event, ui) {\n", + " fig.request_resize(ui.size.width, ui.size.height);\n", + " },\n", + " stop: function(event, ui) {\n", + " pass_mouse_events = true;\n", + " fig.request_resize(ui.size.width, ui.size.height);\n", + " },\n", + " });\n", + "\n", + " function mouse_event_fn(event) {\n", + " if (pass_mouse_events)\n", + " return fig.mouse_event(event, event['data']);\n", + " }\n", + "\n", + " rubberband.mousedown('button_press', mouse_event_fn);\n", + " rubberband.mouseup('button_release', mouse_event_fn);\n", + " // Throttle sequential mouse events to 1 every 20ms.\n", + " rubberband.mousemove('motion_notify', mouse_event_fn);\n", + "\n", + " rubberband.mouseenter('figure_enter', mouse_event_fn);\n", + " rubberband.mouseleave('figure_leave', mouse_event_fn);\n", + "\n", + " canvas_div.on(\"wheel\", function (event) {\n", + " event = event.originalEvent;\n", + " event['data'] = 'scroll'\n", + " if (event.deltaY < 0) {\n", + " event.step = 1;\n", + " } else {\n", + " event.step = -1;\n", + " }\n", + " mouse_event_fn(event);\n", + " });\n", + "\n", + " canvas_div.append(canvas);\n", + " canvas_div.append(rubberband);\n", + "\n", + " this.rubberband = rubberband;\n", + " this.rubberband_canvas = rubberband[0];\n", + " this.rubberband_context = rubberband[0].getContext(\"2d\");\n", + " this.rubberband_context.strokeStyle = \"#000000\";\n", + "\n", + " this._resize_canvas = function(width, height) {\n", + " // Keep the size of the canvas, canvas container, and rubber band\n", + " // canvas in synch.\n", + " canvas_div.css('width', width)\n", + " canvas_div.css('height', height)\n", + "\n", + " canvas.attr('width', width * mpl.ratio);\n", + " canvas.attr('height', height * mpl.ratio);\n", + " canvas.attr('style', 'width: ' + width + 'px; height: ' + height + 'px;');\n", + "\n", + " rubberband.attr('width', width);\n", + " rubberband.attr('height', height);\n", + " }\n", + "\n", + " // Set the figure to an initial 600x600px, this will subsequently be updated\n", + " // upon first draw.\n", + " this._resize_canvas(600, 600);\n", + "\n", + " // Disable right mouse context menu.\n", + " $(this.rubberband_canvas).bind(\"contextmenu\",function(e){\n", + " return false;\n", + " });\n", + "\n", + " function set_focus () {\n", + " canvas.focus();\n", + " canvas_div.focus();\n", + " }\n", + "\n", + " window.setTimeout(set_focus, 100);\n", + "}\n", + "\n", + "mpl.figure.prototype._init_toolbar = function() {\n", + " var fig = this;\n", + "\n", + " var nav_element = $('
')\n", + " nav_element.attr('style', 'width: 100%');\n", + " this.root.append(nav_element);\n", + "\n", + " // Define a callback function for later on.\n", + " function toolbar_event(event) {\n", + " return fig.toolbar_button_onclick(event['data']);\n", + " }\n", + " function toolbar_mouse_event(event) {\n", + " return fig.toolbar_button_onmouseover(event['data']);\n", + " }\n", + "\n", + " for(var toolbar_ind in mpl.toolbar_items) {\n", + " var name = mpl.toolbar_items[toolbar_ind][0];\n", + " var tooltip = mpl.toolbar_items[toolbar_ind][1];\n", + " var image = mpl.toolbar_items[toolbar_ind][2];\n", + " var method_name = mpl.toolbar_items[toolbar_ind][3];\n", + "\n", + " if (!name) {\n", + " // put a spacer in here.\n", + " continue;\n", + " }\n", + " var button = $('');\n", + " button.click(method_name, toolbar_event);\n", + " button.mouseover(tooltip, toolbar_mouse_event);\n", + " nav_element.append(button);\n", + " }\n", + "\n", + " // Add the status bar.\n", + " var status_bar = $('');\n", + " nav_element.append(status_bar);\n", + " this.message = status_bar[0];\n", + "\n", + " // Add the close button to the window.\n", + " var buttongrp = $('
');\n", + " var button = $('');\n", + " button.click(function (evt) { fig.handle_close(fig, {}); } );\n", + " button.mouseover('Stop Interaction', toolbar_mouse_event);\n", + " buttongrp.append(button);\n", + " var titlebar = this.root.find($('.ui-dialog-titlebar'));\n", + " titlebar.prepend(buttongrp);\n", + "}\n", + "\n", + "mpl.figure.prototype._root_extra_style = function(el){\n", + " var fig = this\n", + " el.on(\"remove\", function(){\n", + "\tfig.close_ws(fig, {});\n", + " });\n", + "}\n", + "\n", + "mpl.figure.prototype._canvas_extra_style = function(el){\n", + " // this is important to make the div 'focusable\n", + " el.attr('tabindex', 0)\n", + " // reach out to IPython and tell the keyboard manager to turn it's self\n", + " // off when our div gets focus\n", + "\n", + " // location in version 3\n", + " if (IPython.notebook.keyboard_manager) {\n", + " IPython.notebook.keyboard_manager.register_events(el);\n", + " }\n", + " else {\n", + " // location in version 2\n", + " IPython.keyboard_manager.register_events(el);\n", + " }\n", + "\n", + "}\n", + "\n", + "mpl.figure.prototype._key_event_extra = function(event, name) {\n", + " var manager = IPython.notebook.keyboard_manager;\n", + " if (!manager)\n", + " manager = IPython.keyboard_manager;\n", + "\n", + " // Check for shift+enter\n", + " if (event.shiftKey && event.which == 13) {\n", + " this.canvas_div.blur();\n", + " event.shiftKey = false;\n", + " // Send a \"J\" for go to next cell\n", + " event.which = 74;\n", + " event.keyCode = 74;\n", + " manager.command_mode();\n", + " manager.handle_keydown(event);\n", + " }\n", + "}\n", + "\n", + "mpl.figure.prototype.handle_save = function(fig, msg) {\n", + " fig.ondownload(fig, null);\n", + "}\n", + "\n", + "\n", + "mpl.find_output_cell = function(html_output) {\n", + " // Return the cell and output element which can be found *uniquely* in the notebook.\n", + " // Note - this is a bit hacky, but it is done because the \"notebook_saving.Notebook\"\n", + " // IPython event is triggered only after the cells have been serialised, which for\n", + " // our purposes (turning an active figure into a static one), is too late.\n", + " var cells = IPython.notebook.get_cells();\n", + " var ncells = cells.length;\n", + " for (var i=0; i= 3 moved mimebundle to data attribute of output\n", + " data = data.data;\n", + " }\n", + " if (data['text/html'] == html_output) {\n", + " return [cell, data, j];\n", + " }\n", + " }\n", + " }\n", + " }\n", + "}\n", + "\n", + "// Register the function which deals with the matplotlib target/channel.\n", + "// The kernel may be null if the page has been refreshed.\n", + "if (IPython.notebook.kernel != null) {\n", + " IPython.notebook.kernel.comm_manager.register_target('matplotlib', mpl.mpl_figure_comm);\n", + "}\n" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + "" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" } ], "source": [ - "data" + "plot = qc.MatPlot(data.ZIUHFLI_daqmodule_x, data.ZIUHFLI_daqmodule_y)" ] }, { diff --git a/qcodes/instrument_drivers/ZI/ZIUHFLI.py b/qcodes/instrument_drivers/ZI/ZIUHFLI.py index 9ebb7eef8e0..cd9936c6202 100644 --- a/qcodes/instrument_drivers/ZI/ZIUHFLI.py +++ b/qcodes/instrument_drivers/ZI/ZIUHFLI.py @@ -117,16 +117,35 @@ def __init__(self, name, instrument, **kwargs): self._instrument = instrument def build_data_arrays(self): - # todo setpoints and handle more than one signal correctly - self.names = ('foobar',) - self.labels = ('Foo Bar', ) - self.units = ('v or something',) - - n_signals = 1 + signals = self._instrument._daq_signals + sigunits = {'x': 'V', 'y': 'V', 'r': 'Vrms', 'phase': 'degrees'} + names = [] + units = [] + setpoints = [] ncols = self._instrument.columns() - self.shapes = ((ncols,),)*n_signals + for sig in signals: + parts = sig.split('/') + name = parts[-1].split('.')[-1] + demod = int(parts[3])+1 + names.append(name) + units.append(sigunits[name]) + samplerate = self._instrument._parent.parameters['demod{}_samplerate'.format(demod)]() + setpointarray = np.linspace(0, 1 / samplerate * ncols, ncols) + setpoints.append((tuple(setpointarray),)) - def get(self): + self.names = tuple(names) + self.units = tuple(units) + self.labels = tuple(names) # TODO: What are good labels? + self.setpoints = setpoints + + self.setpoint_names = (('time',),)*len(signals) + self.setpoint_labels = (('Time',),)*len(signals) + self.setpoint_units = (('s',),)*len(signals) + self.shapes = ((ncols,),)*len(self._instrument._daq_signals) + + def get_raw(self): + if len(self._instrument._daq_signals) == 0: + raise RuntimeError("No signals selected") # todo map this to parameters. Try to match both the # scope api and the zi api as much as possible trigger_demod_index = 0 @@ -143,16 +162,7 @@ def get(self): self._instrument._parent.data_acquisition_module.set('dataAcquisitionModule/holdoff/time', 200e-3) self._instrument._parent.data_acquisition_module.set('dataAcquisitionModule/holdoff/count', 0) self._instrument._parent.data_acquisition_module.set('dataAcquisitionModule/grid/mode', 4) - # dataAcquisitionModule/grid/repetitions (int) - # The number of times to average. - repetitions = 1 - self._instrument._parent.data_acquisition_module.set('dataAcquisitionModule/grid/repetitions', repetitions) - # dataAcquisitionModule/grid/cols (int) - # Specify the number of columns in the grid's matrix. The data from each - # row is interpolated onto a grid with the specified number of columns. - # num_cols = 512 - # self._parent.data_acquisition_module.set('dataAcquisitionModule/grid/cols', num_cols) - # dataAcquisitionModule/grid/rows (int) + # Specify the number of rows in the grid's matrix. Each row is the data # recorded from one trigger. num_rows = 1 @@ -176,26 +186,36 @@ def get(self): num_grids = 1 self._instrument._parent.data_acquisition_module.set('dataAcquisitionModule/count', num_grids) - datapath = '/{}/demods/{}/sample.r.avg'.format(self._instrument._parent.device, trigger_demod_index) data = {} data[triggerpath] = [] - - self._instrument._parent.data_acquisition_module.subscribe(datapath) + for samplestring in self._instrument._daq_signals: + self._instrument._parent.data_acquisition_module.subscribe(samplestring) + self._instrument._parent.data_acquisition_module.subscribe(triggerpath) + # Below is from ZI example but the intention is somewhat unclear. Is it just + # that subscripe should be the last action that we do or that we must subscripe to + # trigger last. + # Note: We subscribe to the trigger signal path last to ensure that we obtain + # complete data on the other paths (known limitation). We must subscribe to + # the trigger signal path. self._instrument._parent.data_acquisition_module.execute() # todo calculate meaning full timeout and handle correctly - timeout = 10 # [s] + tracelength = max(max(max(self._instrument._parent.daqmodule.data.setpoints))) + # we set timeout somewhat abitrary as 2 times the total measuring time + timeout = 2 * tracelength * self._instrument.repetitions() # [s] t0 = time.time() while not self._instrument._parent.data_acquisition_module.finished(): time.sleep(0.05) if time.time() - t0 > timeout: - print('timed out') - break + raise RuntimeError("Measurement timed out, check your trigger") return_flat_data_dict = True data_read = self._instrument._parent.data_acquisition_module.read(return_flat_data_dict) - data = data_read[datapath] - return data[0]['value'][0] + for samplestring in self._instrument._daq_signals: + self._instrument._parent.data_acquisition_module.unsubscribe(samplestring) + self._instrument._parent.data_acquisition_module.unsubscribe(triggerpath) + data = tuple(data_read[samplestring][0]['value'][0] for samplestring in self._instrument._daq_signals) + return data class DataAcquisitionModule(InstrumentChannel): @@ -250,9 +270,49 @@ def __init__(self, parent: 'ZIUHFLI', name: str) -> None: get_cmd=partial(self.data_acquisition_module.getInt, 'dataAcquisitionModule/grid/cols'), vals=vals.Ints(1)) + self.add_parameter('repetitions', + label='Repetitions', + set_cmd=partial(self.data_acquisition_module.set, 'dataAcquisitionModule/grid/repetitions'), + get_cmd=partial(self.data_acquisition_module.getInt, 'dataAcquisitionModule/grid/repetitions'), + vals=vals.Ints(1)) + self.add_parameter('data', parameter_class=DataAcquisitionArray) + self._daq_signals = [] + + def add_signal_to_daq(self, demodulator, attribute): + valid_attributes = ['x', 'y', 'r', 'phase'] + # Validation + if demodulator not in range(1, 9): + raise ValueError('Can not select demodulator' + + ' {}. Only '.format(demodulator) + + 'demodulators 1-8 are available.') + if attribute not in valid_attributes: + raise ValueError('Can not select attribute:'+ + '{}. Only the following attributes are' + + ' available: ' + + ('{}, '*len(valid_attributes)).format(*valid_attributes)) + + signalstring = ('/' + self._parent.device + + '/demods/{}/sample.{}'.format(demodulator-1, + attribute)) + if signalstring not in self._daq_signals: + self._daq_signals.append(signalstring) + + + def remove_signal_from_daq(self, demodulator, attribute): + + signalstring = ('/' + self._parent.device + + '/demods/{}/sample.{}'.format(demodulator-1, + attribute)) + if signalstring not in self._daq_signals: + log.warning('Can not remove signal with {} of'.format(attribute) + + ' demodulator {}, since it was'.format(demodulator) + + ' not previously added.') + else: + self._daq_signals.remove(signalstring) + class Sweep(MultiParameter): """ From 7613c6aa4fced0a65c5ba5a04094e106ea9caf38 Mon Sep 17 00:00:00 2001 From: "Jens H. Nielsen" Date: Fri, 16 Feb 2018 15:28:51 +0100 Subject: [PATCH 04/22] for now always get avg data --- qcodes/instrument_drivers/ZI/ZIUHFLI.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/qcodes/instrument_drivers/ZI/ZIUHFLI.py b/qcodes/instrument_drivers/ZI/ZIUHFLI.py index cd9936c6202..b2fd573a6f0 100644 --- a/qcodes/instrument_drivers/ZI/ZIUHFLI.py +++ b/qcodes/instrument_drivers/ZI/ZIUHFLI.py @@ -125,7 +125,7 @@ def build_data_arrays(self): ncols = self._instrument.columns() for sig in signals: parts = sig.split('/') - name = parts[-1].split('.')[-1] + name = parts[-1].split('.')[-2] demod = int(parts[3])+1 names.append(name) units.append(sigunits[name]) @@ -202,7 +202,7 @@ def get_raw(self): # todo calculate meaning full timeout and handle correctly tracelength = max(max(max(self._instrument._parent.daqmodule.data.setpoints))) # we set timeout somewhat abitrary as 2 times the total measuring time - timeout = 2 * tracelength * self._instrument.repetitions() # [s] + timeout = 2 * tracelength * self._instrument.repetitions() + 1 # [s] t0 = time.time() while not self._instrument._parent.data_acquisition_module.finished(): @@ -295,7 +295,7 @@ def add_signal_to_daq(self, demodulator, attribute): ('{}, '*len(valid_attributes)).format(*valid_attributes)) signalstring = ('/' + self._parent.device + - '/demods/{}/sample.{}'.format(demodulator-1, + '/demods/{}/sample.{}.avg'.format(demodulator-1, attribute)) if signalstring not in self._daq_signals: self._daq_signals.append(signalstring) From 3919651a466bdaae54f8105ebf365deb64518793 Mon Sep 17 00:00:00 2001 From: "Jens H. Nielsen" Date: Fri, 16 Feb 2018 15:29:22 +0100 Subject: [PATCH 05/22] add notebook with avg --- .../Qcodes example with ZI UHF-LI.ipynb | 863 +++++++++++++++++- 1 file changed, 853 insertions(+), 10 deletions(-) diff --git a/docs/examples/driver_examples/Qcodes example with ZI UHF-LI.ipynb b/docs/examples/driver_examples/Qcodes example with ZI UHF-LI.ipynb index 74410d6f58e..adb091d4e61 100644 --- a/docs/examples/driver_examples/Qcodes example with ZI UHF-LI.ipynb +++ b/docs/examples/driver_examples/Qcodes example with ZI UHF-LI.ipynb @@ -3242,7 +3242,7 @@ "metadata": {}, "outputs": [], "source": [ - "zi.daqmodule.repetitions(100)" + "zi.daqmodule.repetitions(1)" ] }, { @@ -3291,7 +3291,7 @@ }, { "cell_type": "code", - "execution_count": 12, + "execution_count": 11, "metadata": {}, "outputs": [ { @@ -3299,14 +3299,14 @@ "output_type": "stream", "text": [ "DataSet:\n", - " location = 'data/2018-02-16/#013_{name}_15-03-42'\n", + " location = 'data/2018-02-16/#016_{name}_15-24-41'\n", " | | | \n", " Setpoint | time_set | time | (200,)\n", " Measured | ZIUHFLI_daqmodule_r | r | (200,)\n", " Measured | ZIUHFLI_daqmodule_x | x | (200,)\n", " Measured | ZIUHFLI_daqmodule_y | y | (200,)\n", " Measured | ZIUHFLI_daqmodule_phase | phase | (200,)\n", - "acquired at 2018-02-16 15:04:03\n" + "acquired at 2018-02-16 15:24:42\n" ] } ], @@ -3316,10 +3316,8 @@ }, { "cell_type": "code", - "execution_count": 13, - "metadata": { - "scrolled": false - }, + "execution_count": 12, + "metadata": {}, "outputs": [ { "data": { @@ -4104,7 +4102,7 @@ { "data": { "text/html": [ - "" + "" ], "text/plain": [ "" @@ -4118,10 +4116,855 @@ "plot = qc.MatPlot(data.ZIUHFLI_daqmodule_r, data.ZIUHFLI_daqmodule_phase)" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Now lets do some more avgerages" + ] + }, + { + "cell_type": "code", + "execution_count": 13, + "metadata": {}, + "outputs": [], + "source": [ + "zi.daqmodule.repetitions(100)" + ] + }, { "cell_type": "code", "execution_count": 15, "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "DataSet:\n", + " location = 'data/2018-02-16/#017_{name}_15-25-37'\n", + " | | | \n", + " Setpoint | time_set | time | (200,)\n", + " Measured | ZIUHFLI_daqmodule_r | r | (200,)\n", + " Measured | ZIUHFLI_daqmodule_x | x | (200,)\n", + " Measured | ZIUHFLI_daqmodule_y | y | (200,)\n", + " Measured | ZIUHFLI_daqmodule_phase | phase | (200,)\n", + "acquired at 2018-02-16 15:25:58\n" + ] + } + ], + "source": [ + "data = qc.Measure(zi.daqmodule.data).run()" + ] + }, + { + "cell_type": "code", + "execution_count": 16, + "metadata": { + "scrolled": false + }, + "outputs": [ + { + "data": { + "application/javascript": [ + "/* Put everything inside the global mpl namespace */\n", + "window.mpl = {};\n", + "\n", + "\n", + "mpl.get_websocket_type = function() {\n", + " if (typeof(WebSocket) !== 'undefined') {\n", + " return WebSocket;\n", + " } else if (typeof(MozWebSocket) !== 'undefined') {\n", + " return MozWebSocket;\n", + " } else {\n", + " alert('Your browser does not have WebSocket support.' +\n", + " 'Please try Chrome, Safari or Firefox ≥ 6. ' +\n", + " 'Firefox 4 and 5 are also supported but you ' +\n", + " 'have to enable WebSockets in about:config.');\n", + " };\n", + "}\n", + "\n", + "mpl.figure = function(figure_id, websocket, ondownload, parent_element) {\n", + " this.id = figure_id;\n", + "\n", + " this.ws = websocket;\n", + "\n", + " this.supports_binary = (this.ws.binaryType != undefined);\n", + "\n", + " if (!this.supports_binary) {\n", + " var warnings = document.getElementById(\"mpl-warnings\");\n", + " if (warnings) {\n", + " warnings.style.display = 'block';\n", + " warnings.textContent = (\n", + " \"This browser does not support binary websocket messages. \" +\n", + " \"Performance may be slow.\");\n", + " }\n", + " }\n", + "\n", + " this.imageObj = new Image();\n", + "\n", + " this.context = undefined;\n", + " this.message = undefined;\n", + " this.canvas = undefined;\n", + " this.rubberband_canvas = undefined;\n", + " this.rubberband_context = undefined;\n", + " this.format_dropdown = undefined;\n", + "\n", + " this.image_mode = 'full';\n", + "\n", + " this.root = $('
');\n", + " this._root_extra_style(this.root)\n", + " this.root.attr('style', 'display: inline-block');\n", + "\n", + " $(parent_element).append(this.root);\n", + "\n", + " this._init_header(this);\n", + " this._init_canvas(this);\n", + " this._init_toolbar(this);\n", + "\n", + " var fig = this;\n", + "\n", + " this.waiting = false;\n", + "\n", + " this.ws.onopen = function () {\n", + " fig.send_message(\"supports_binary\", {value: fig.supports_binary});\n", + " fig.send_message(\"send_image_mode\", {});\n", + " if (mpl.ratio != 1) {\n", + " fig.send_message(\"set_dpi_ratio\", {'dpi_ratio': mpl.ratio});\n", + " }\n", + " fig.send_message(\"refresh\", {});\n", + " }\n", + "\n", + " this.imageObj.onload = function() {\n", + " if (fig.image_mode == 'full') {\n", + " // Full images could contain transparency (where diff images\n", + " // almost always do), so we need to clear the canvas so that\n", + " // there is no ghosting.\n", + " fig.context.clearRect(0, 0, fig.canvas.width, fig.canvas.height);\n", + " }\n", + " fig.context.drawImage(fig.imageObj, 0, 0);\n", + " };\n", + "\n", + " this.imageObj.onunload = function() {\n", + " fig.ws.close();\n", + " }\n", + "\n", + " this.ws.onmessage = this._make_on_message_function(this);\n", + "\n", + " this.ondownload = ondownload;\n", + "}\n", + "\n", + "mpl.figure.prototype._init_header = function() {\n", + " var titlebar = $(\n", + " '
');\n", + " var titletext = $(\n", + " '
');\n", + " titlebar.append(titletext)\n", + " this.root.append(titlebar);\n", + " this.header = titletext[0];\n", + "}\n", + "\n", + "\n", + "\n", + "mpl.figure.prototype._canvas_extra_style = function(canvas_div) {\n", + "\n", + "}\n", + "\n", + "\n", + "mpl.figure.prototype._root_extra_style = function(canvas_div) {\n", + "\n", + "}\n", + "\n", + "mpl.figure.prototype._init_canvas = function() {\n", + " var fig = this;\n", + "\n", + " var canvas_div = $('
');\n", + "\n", + " canvas_div.attr('style', 'position: relative; clear: both; outline: 0');\n", + "\n", + " function canvas_keyboard_event(event) {\n", + " return fig.key_event(event, event['data']);\n", + " }\n", + "\n", + " canvas_div.keydown('key_press', canvas_keyboard_event);\n", + " canvas_div.keyup('key_release', canvas_keyboard_event);\n", + " this.canvas_div = canvas_div\n", + " this._canvas_extra_style(canvas_div)\n", + " this.root.append(canvas_div);\n", + "\n", + " var canvas = $('');\n", + " canvas.addClass('mpl-canvas');\n", + " canvas.attr('style', \"left: 0; top: 0; z-index: 0; outline: 0\")\n", + "\n", + " this.canvas = canvas[0];\n", + " this.context = canvas[0].getContext(\"2d\");\n", + "\n", + " var backingStore = this.context.backingStorePixelRatio ||\n", + "\tthis.context.webkitBackingStorePixelRatio ||\n", + "\tthis.context.mozBackingStorePixelRatio ||\n", + "\tthis.context.msBackingStorePixelRatio ||\n", + "\tthis.context.oBackingStorePixelRatio ||\n", + "\tthis.context.backingStorePixelRatio || 1;\n", + "\n", + " mpl.ratio = (window.devicePixelRatio || 1) / backingStore;\n", + "\n", + " var rubberband = $('');\n", + " rubberband.attr('style', \"position: absolute; left: 0; top: 0; z-index: 1;\")\n", + "\n", + " var pass_mouse_events = true;\n", + "\n", + " canvas_div.resizable({\n", + " start: function(event, ui) {\n", + " pass_mouse_events = false;\n", + " },\n", + " resize: function(event, ui) {\n", + " fig.request_resize(ui.size.width, ui.size.height);\n", + " },\n", + " stop: function(event, ui) {\n", + " pass_mouse_events = true;\n", + " fig.request_resize(ui.size.width, ui.size.height);\n", + " },\n", + " });\n", + "\n", + " function mouse_event_fn(event) {\n", + " if (pass_mouse_events)\n", + " return fig.mouse_event(event, event['data']);\n", + " }\n", + "\n", + " rubberband.mousedown('button_press', mouse_event_fn);\n", + " rubberband.mouseup('button_release', mouse_event_fn);\n", + " // Throttle sequential mouse events to 1 every 20ms.\n", + " rubberband.mousemove('motion_notify', mouse_event_fn);\n", + "\n", + " rubberband.mouseenter('figure_enter', mouse_event_fn);\n", + " rubberband.mouseleave('figure_leave', mouse_event_fn);\n", + "\n", + " canvas_div.on(\"wheel\", function (event) {\n", + " event = event.originalEvent;\n", + " event['data'] = 'scroll'\n", + " if (event.deltaY < 0) {\n", + " event.step = 1;\n", + " } else {\n", + " event.step = -1;\n", + " }\n", + " mouse_event_fn(event);\n", + " });\n", + "\n", + " canvas_div.append(canvas);\n", + " canvas_div.append(rubberband);\n", + "\n", + " this.rubberband = rubberband;\n", + " this.rubberband_canvas = rubberband[0];\n", + " this.rubberband_context = rubberband[0].getContext(\"2d\");\n", + " this.rubberband_context.strokeStyle = \"#000000\";\n", + "\n", + " this._resize_canvas = function(width, height) {\n", + " // Keep the size of the canvas, canvas container, and rubber band\n", + " // canvas in synch.\n", + " canvas_div.css('width', width)\n", + " canvas_div.css('height', height)\n", + "\n", + " canvas.attr('width', width * mpl.ratio);\n", + " canvas.attr('height', height * mpl.ratio);\n", + " canvas.attr('style', 'width: ' + width + 'px; height: ' + height + 'px;');\n", + "\n", + " rubberband.attr('width', width);\n", + " rubberband.attr('height', height);\n", + " }\n", + "\n", + " // Set the figure to an initial 600x600px, this will subsequently be updated\n", + " // upon first draw.\n", + " this._resize_canvas(600, 600);\n", + "\n", + " // Disable right mouse context menu.\n", + " $(this.rubberband_canvas).bind(\"contextmenu\",function(e){\n", + " return false;\n", + " });\n", + "\n", + " function set_focus () {\n", + " canvas.focus();\n", + " canvas_div.focus();\n", + " }\n", + "\n", + " window.setTimeout(set_focus, 100);\n", + "}\n", + "\n", + "mpl.figure.prototype._init_toolbar = function() {\n", + " var fig = this;\n", + "\n", + " var nav_element = $('
')\n", + " nav_element.attr('style', 'width: 100%');\n", + " this.root.append(nav_element);\n", + "\n", + " // Define a callback function for later on.\n", + " function toolbar_event(event) {\n", + " return fig.toolbar_button_onclick(event['data']);\n", + " }\n", + " function toolbar_mouse_event(event) {\n", + " return fig.toolbar_button_onmouseover(event['data']);\n", + " }\n", + "\n", + " for(var toolbar_ind in mpl.toolbar_items) {\n", + " var name = mpl.toolbar_items[toolbar_ind][0];\n", + " var tooltip = mpl.toolbar_items[toolbar_ind][1];\n", + " var image = mpl.toolbar_items[toolbar_ind][2];\n", + " var method_name = mpl.toolbar_items[toolbar_ind][3];\n", + "\n", + " if (!name) {\n", + " // put a spacer in here.\n", + " continue;\n", + " }\n", + " var button = $('');\n", + " button.click(method_name, toolbar_event);\n", + " button.mouseover(tooltip, toolbar_mouse_event);\n", + " nav_element.append(button);\n", + " }\n", + "\n", + " // Add the status bar.\n", + " var status_bar = $('');\n", + " nav_element.append(status_bar);\n", + " this.message = status_bar[0];\n", + "\n", + " // Add the close button to the window.\n", + " var buttongrp = $('
');\n", + " var button = $('');\n", + " button.click(function (evt) { fig.handle_close(fig, {}); } );\n", + " button.mouseover('Stop Interaction', toolbar_mouse_event);\n", + " buttongrp.append(button);\n", + " var titlebar = this.root.find($('.ui-dialog-titlebar'));\n", + " titlebar.prepend(buttongrp);\n", + "}\n", + "\n", + "mpl.figure.prototype._root_extra_style = function(el){\n", + " var fig = this\n", + " el.on(\"remove\", function(){\n", + "\tfig.close_ws(fig, {});\n", + " });\n", + "}\n", + "\n", + "mpl.figure.prototype._canvas_extra_style = function(el){\n", + " // this is important to make the div 'focusable\n", + " el.attr('tabindex', 0)\n", + " // reach out to IPython and tell the keyboard manager to turn it's self\n", + " // off when our div gets focus\n", + "\n", + " // location in version 3\n", + " if (IPython.notebook.keyboard_manager) {\n", + " IPython.notebook.keyboard_manager.register_events(el);\n", + " }\n", + " else {\n", + " // location in version 2\n", + " IPython.keyboard_manager.register_events(el);\n", + " }\n", + "\n", + "}\n", + "\n", + "mpl.figure.prototype._key_event_extra = function(event, name) {\n", + " var manager = IPython.notebook.keyboard_manager;\n", + " if (!manager)\n", + " manager = IPython.keyboard_manager;\n", + "\n", + " // Check for shift+enter\n", + " if (event.shiftKey && event.which == 13) {\n", + " this.canvas_div.blur();\n", + " event.shiftKey = false;\n", + " // Send a \"J\" for go to next cell\n", + " event.which = 74;\n", + " event.keyCode = 74;\n", + " manager.command_mode();\n", + " manager.handle_keydown(event);\n", + " }\n", + "}\n", + "\n", + "mpl.figure.prototype.handle_save = function(fig, msg) {\n", + " fig.ondownload(fig, null);\n", + "}\n", + "\n", + "\n", + "mpl.find_output_cell = function(html_output) {\n", + " // Return the cell and output element which can be found *uniquely* in the notebook.\n", + " // Note - this is a bit hacky, but it is done because the \"notebook_saving.Notebook\"\n", + " // IPython event is triggered only after the cells have been serialised, which for\n", + " // our purposes (turning an active figure into a static one), is too late.\n", + " var cells = IPython.notebook.get_cells();\n", + " var ncells = cells.length;\n", + " for (var i=0; i= 3 moved mimebundle to data attribute of output\n", + " data = data.data;\n", + " }\n", + " if (data['text/html'] == html_output) {\n", + " return [cell, data, j];\n", + " }\n", + " }\n", + " }\n", + " }\n", + "}\n", + "\n", + "// Register the function which deals with the matplotlib target/channel.\n", + "// The kernel may be null if the page has been refreshed.\n", + "if (IPython.notebook.kernel != null) {\n", + " IPython.notebook.kernel.comm_manager.register_target('matplotlib', mpl.mpl_figure_comm);\n", + "}\n" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + "" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/plain": [ + "[]" + ] + }, + "execution_count": 14, + "metadata": {}, + "output_type": "execute_result" } ], "source": [ - "# I wonder what kind of sweep we have made now...\n", - "zi.print_sweeper_settings()" + "# This we may manually plot.\n", + "plt.figure()\n", + "plt.yscale('log')\n", + "plt.plot(X, lw=2, color=(0.5, 0, 0.3))\n", + "plt.plot(Y, lw=2, color=(0.5, 0.3, 0))\n", + "plt.plot(R, lw=2, color=(0.3, 0, 0.5))" ] }, { "cell_type": "code", - "execution_count": 12, + "execution_count": 16, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "ACQUISITION\n", - " Sweeper bandwidth control mode: fixed ()\n", - " Fixed bandwidth sweeper bandwidth (NEP): 78.12499999999996 ()\n", - " Sweeper filter order: 4 ()\n", - " Minimal no. of samples to average at each sweep point: 25 ()\n", - " Minimal averaging time: 0.1 (s)\n", - " Minimal settling time for the sweeper: 1e-06 (s)\n", - " Sweep filter settling time: 9.998049677807453 ()\n", - "HORISONTAL\n", - " Start value of the sweep: 1000000.0\n", - " Stop value of the sweep: 10000000.0\n", - " Units of sweep x-axis: Hz\n", - " Length of the sweep (pts): 100\n", - " Parameter to sweep (sweep x-axis): Osc 1 Frequency\n", - " Sweep mode: Sequential\n", - " Sweep timeout: 600\n", - "VERTICAL\n", - " Signal 1: Demodulator 1: Xrms\n", - " Signal 2: Demodulator 1: Yrms\n", - " Signal 3: Demodulator 1: Rrms\n", - "DEMODULATORS\n", - " Demodulator 1: Filter time constant: 0.000981 (s)\n", - " Demodulator 1: Filter order: 4.000000 ()\n", - " Demodulator 1: Sample rate: 858.306885 (Sa/s)\n", - "META\n", - " Expected sweep time: 3.9 (s)\n", - " Sweep timeout: 600 (s)\n", - " Sweep built and ready to execute: True\n" + "DataSet:\n", + " location = 'data/2018-02-22/#037_{name}_16-23-57'\n", + " | | | \n", + " Setpoint | frequency_set | frequency | (100,)\n", + " Measured | ZIUHFLI_Xrms | Xrms | (100,)\n", + " Measured | ZIUHFLI_Yrms | Yrms | (100,)\n", + " Measured | ZIUHFLI_Rrms | Rrms | (100,)\n", + "acquired at 2018-02-22 16:24:03\n" ] } ], "source": [ - "# Gee, that looks good! Note the last line, the sweep is NOT ready to execute.\n", - "zi.Sweep.build_sweep()\n", - "# Now it is!\n", - "zi.print_sweeper_settings()" - ] - }, - { - "cell_type": "code", - "execution_count": 13, - "metadata": {}, - "outputs": [], - "source": [ - "# We can now execute the sweeper by simply invoking Sweep.get\n", - "# This returns a tuple with the signals we asked for\n", - "(X, Y, R) = zi.Sweep.get()" + "# A more correct way to do this is to perform a proper QCoDeS measurement\n", + "sweepdata = qc.Measure(zi.Sweep).run()" ] }, { "cell_type": "code", - "execution_count": 14, + "execution_count": 17, "metadata": {}, "outputs": [ { @@ -1219,7 +2045,7 @@ { "data": { "text/html": [ - "" + "" ], "text/plain": [ "" @@ -1231,50 +2057,16 @@ { "data": { "text/plain": [ - "[]" + "" ] }, - "execution_count": 14, + "execution_count": 17, "metadata": {}, "output_type": "execute_result" } ], "source": [ - "# This we may manually plot.\n", - "plt.figure()\n", - "plt.yscale('log')\n", - "plt.plot(X, lw=2, color=(0.5, 0, 0.3))\n", - "plt.plot(Y, lw=2, color=(0.5, 0.3, 0))\n", - "plt.plot(R, lw=2, color=(0.3, 0, 0.5))" - ] - }, - { - "cell_type": "code", - "execution_count": 15, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Debug (100,) (100,)\n", - "Debug (100,) (100,)\n", - "Debug (100,) (100,)\n", - "DataSet:\n", - " mode = DataMode.LOCAL\n", - " location = 'data/2017-03-01/#011_{name}_11-49-47'\n", - " | | | \n", - " Measured | Hz | Hz | (100,)\n", - " Measured | ZIUHFLI_Xrms | Xrms | (100,)\n", - " Measured | ZIUHFLI_Yrms | Yrms | (100,)\n", - " Measured | ZIUHFLI_Rrms | Rrms | (100,)\n", - "acquired at 2017-03-01 11:49:51\n" - ] - } - ], - "source": [ - "# A more correct way to do this is to perform a proper QCoDeS measurement\n", - "sweepdata = qc.Measure(zi.Sweep).run()" + "qc.MatPlot(sweepdata.ZIUHFLI_Xrms,sweepdata.ZIUHFLI_Yrms,sweepdata.ZIUHFLI_Rrms)" ] }, { @@ -1299,14 +2091,14 @@ }, { "cell_type": "code", - "execution_count": 15, + "execution_count": 18, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "Current scope settings: SR: 56.2 MHz, Length: 7030, duration: 0.000125 (s)\n", + "Current scope settings: SR: 56.2 MHz, Length: 16384, duration: 0.000292 (s)\n", "The length is 562000, 562000\n", "The duration is 0.005, 0.005 and the length is 281000\n", "Finally, length: 281000 points, duration : 0.01 (s)\n" @@ -1347,7 +2139,7 @@ }, { "cell_type": "code", - "execution_count": 18, + "execution_count": 19, "metadata": {}, "outputs": [], "source": [ @@ -1385,7 +2177,7 @@ }, { "cell_type": "code", - "execution_count": 19, + "execution_count": 20, "metadata": {}, "outputs": [ { @@ -1413,7 +2205,7 @@ }, { "cell_type": "code", - "execution_count": 20, + "execution_count": 22, "metadata": {}, "outputs": [ { @@ -2199,7 +2991,7 @@ { "data": { "text/html": [ - "" + "" ], "text/plain": [ "" @@ -2991,7 +3783,7 @@ { "data": { "text/html": [ - "" + "" ], "text/plain": [ "" @@ -3008,30 +3800,26 @@ " if chandata is not None:\n", " fig, axs = plt.subplots(len(chandata), 1)\n", " for ind, ax in enumerate(axs):\n", - " ax.plot(chandata[ind, :])" + " ax.plot(chandata[ind, :])\n", + " fig.tight_layout()" ] }, { "cell_type": "code", - "execution_count": 19, + "execution_count": 23, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "Debug (5,) (5,)\n", - "Debug (5, 7030) (5, 7030)\n", - "Debug (5,) (5,)\n", - "Debug (5, 7030) (5, 7030)\n", "DataSet:\n", - " mode = DataMode.LOCAL\n", - " location = 'data/2017-03-01/#012_{name}_11-57-04'\n", + " location = 'data/2018-02-22/#038_{name}_16-24-55'\n", " | | | \n", - " Measured | Time | Time | (5, 7030)\n", + " Setpoint | Time_set | Time | (5, 7030)\n", " Measured | ZIUHFLI_Sig. In 1 | Sig. In 1 | (5, 7030)\n", " Measured | ZIUHFLI_Sig. In 2 | Sig. In 2 | (5, 7030)\n", - "acquired at 2017-03-01 11:57:05\n" + "acquired at 2018-02-22 16:24:56\n" ] } ], @@ -3059,16 +3847,16 @@ }, { "cell_type": "code", - "execution_count": 3, + "execution_count": 24, "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "array([0.03524339])" + "array([0.03514797])" ] }, - "execution_count": 3, + "execution_count": 24, "metadata": {}, "output_type": "execute_result" } @@ -3079,16 +3867,16 @@ }, { "cell_type": "code", - "execution_count": 23, + "execution_count": 25, "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "array([ 1.24196735e-06])" + "array([-0.00446041])" ] }, - "execution_count": 23, + "execution_count": 25, "metadata": {}, "output_type": "execute_result" } @@ -3099,16 +3887,16 @@ }, { "cell_type": "code", - "execution_count": 22, + "execution_count": 26, "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "array([ 1.39759855e-06])" + "array([0.03541409])" ] }, - "execution_count": 22, + "execution_count": 26, "metadata": {}, "output_type": "execute_result" } @@ -3119,16 +3907,16 @@ }, { "cell_type": "code", - "execution_count": 24, + "execution_count": 27, "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "array([ 116.36020379])" + "array([-7.22955065])" ] }, - "execution_count": 24, + "execution_count": 27, "metadata": {}, "output_type": "execute_result" } @@ -3160,24 +3948,34 @@ }, { "cell_type": "code", - "execution_count": 4, + "execution_count": 28, + "metadata": {}, + "outputs": [], + "source": [ + "zi.data_acquisition.trigger_input('TRIGIN1')\n", + "zi.data_acquisition.trigger_type.set('HW_TRIGGER')\n", + "zi.data_acquisition.trigger_edge_type.get()\n", + "zi.data_acquisition.trigger_delay(-1e-3)" + ] + }, + { + "cell_type": "code", + "execution_count": 29, "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "'POS_EDGE'" + "-0.001" ] }, - "execution_count": 4, + "execution_count": 29, "metadata": {}, "output_type": "execute_result" } ], "source": [ - "zi.data_acquisition.trigger_input('TRIGIN1')\n", - "zi.data_acquisition.trigger_type.set('HW_TRIGGER')\n", - "zi.data_acquisition.trigger_edge_type.get()" + "zi.data_acquisition.trigger_delay()" ] }, { @@ -3189,7 +3987,7 @@ }, { "cell_type": "code", - "execution_count": 5, + "execution_count": 30, "metadata": {}, "outputs": [], "source": [ @@ -3205,7 +4003,7 @@ }, { "cell_type": "code", - "execution_count": 6, + "execution_count": 31, "metadata": {}, "outputs": [], "source": [ @@ -3214,7 +4012,7 @@ }, { "cell_type": "code", - "execution_count": 7, + "execution_count": 32, "metadata": {}, "outputs": [ { @@ -3233,12 +4031,12 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "And average over 100 repetitions" + "And no averageing" ] }, { "cell_type": "code", - "execution_count": 37, + "execution_count": 47, "metadata": {}, "outputs": [], "source": [ @@ -3247,7 +4045,7 @@ }, { "cell_type": "code", - "execution_count": 38, + "execution_count": 48, "metadata": {}, "outputs": [], "source": [ @@ -3263,7 +4061,7 @@ }, { "cell_type": "code", - "execution_count": 39, + "execution_count": 49, "metadata": {}, "outputs": [], "source": [ @@ -3273,6 +4071,62 @@ "zi.data_acquisition.add_signal_to_daq(1, 'phase')" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Lets set holdoff so we are sure not to get overlapping triggers" + ] + }, + { + "cell_type": "code", + "execution_count": 50, + "metadata": {}, + "outputs": [], + "source": [ + "zi.data_acquisition.holdoff(zi.data_acquisition.columns()/zi.demod1_samplerate())" + ] + }, + { + "cell_type": "code", + "execution_count": 51, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "0.11650844444444444" + ] + }, + "execution_count": 51, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "zi.data_acquisition.holdoff()" + ] + }, + { + "cell_type": "code", + "execution_count": 52, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "0" + ] + }, + "execution_count": 52, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "zi.data_acquisition.holdoff_count()" + ] + }, { "cell_type": "markdown", "metadata": {}, @@ -3282,7 +4136,7 @@ }, { "cell_type": "code", - "execution_count": 40, + "execution_count": 53, "metadata": {}, "outputs": [], "source": [ @@ -3291,7 +4145,7 @@ }, { "cell_type": "code", - "execution_count": 41, + "execution_count": 54, "metadata": {}, "outputs": [ { @@ -3299,24 +4153,26 @@ "output_type": "stream", "text": [ "DataSet:\n", - " location = 'data/2018-02-22/#006_{name}_13-37-25'\n", + " location = 'data/2018-02-22/#040_{name}_16-26-30'\n", " | | | \n", " Setpoint | time_set | time | (200,)\n", " Measured | ZIUHFLI_data_acquisition_r | r | (200,)\n", " Measured | ZIUHFLI_data_acquisition_x | x | (200,)\n", " Measured | ZIUHFLI_data_acquisition_y | y | (200,)\n", " Measured | ZIUHFLI_data_acquisition_phase | phase | (200,)\n", - "acquired at 2018-02-22 13:37:26\n" + "acquired at 2018-02-22 16:26:31\n", + "Wall time: 987 ms\n" ] } ], "source": [ + "%%time\n", "data = qc.Measure(zi.data_acquisition.data).run()" ] }, { "cell_type": "code", - "execution_count": 42, + "execution_count": 55, "metadata": {}, "outputs": [ { @@ -4102,7 +4958,7 @@ { "data": { "text/html": [ - "" + "" ], "text/plain": [ "" @@ -4125,16 +4981,16 @@ }, { "cell_type": "code", - "execution_count": 43, + "execution_count": 56, "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "4.5108860691936425e-05" + "6.135095388425799e-05" ] }, - "execution_count": 43, + "execution_count": 56, "metadata": {}, "output_type": "execute_result" } @@ -4145,16 +5001,17 @@ }, { "cell_type": "code", - "execution_count": 44, + "execution_count": 57, "metadata": {}, "outputs": [], "source": [ - "zi.data_acquisition.repetitions(100)" + "zi.data_acquisition.repetitions(100)\n", + "zi.data_acquisition.data.build_data_arrays()" ] }, { "cell_type": "code", - "execution_count": 45, + "execution_count": 58, "metadata": {}, "outputs": [ { @@ -4162,24 +5019,26 @@ "output_type": "stream", "text": [ "DataSet:\n", - " location = 'data/2018-02-22/#007_{name}_13-37-33'\n", + " location = 'data/2018-02-22/#041_{name}_16-26-34'\n", " | | | \n", " Setpoint | time_set | time | (200,)\n", " Measured | ZIUHFLI_data_acquisition_r | r | (200,)\n", " Measured | ZIUHFLI_data_acquisition_x | x | (200,)\n", " Measured | ZIUHFLI_data_acquisition_y | y | (200,)\n", " Measured | ZIUHFLI_data_acquisition_phase | phase | (200,)\n", - "acquired at 2018-02-22 13:37:54\n" + "acquired at 2018-02-22 16:26:47\n", + "Wall time: 12.7 s\n" ] } ], "source": [ + "%%time\n", "data = qc.Measure(zi.data_acquisition.data).run()" ] }, { "cell_type": "code", - "execution_count": 46, + "execution_count": 59, "metadata": { "scrolled": false }, @@ -4967,7 +5826,7 @@ { "data": { "text/html": [ - "" + "" ], "text/plain": [ "" @@ -4983,16 +5842,16 @@ }, { "cell_type": "code", - "execution_count": 47, + "execution_count": 60, "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "3.580901274599646e-06" + "3.7162948984398314e-06" ] }, - "execution_count": 47, + "execution_count": 60, "metadata": {}, "output_type": "execute_result" } @@ -5003,7 +5862,7 @@ }, { "cell_type": "code", - "execution_count": 36, + "execution_count": 24, "metadata": {}, "outputs": [ { @@ -5789,7 +6648,7 @@ { "data": { "text/html": [ - "" + "" ], "text/plain": [ "" @@ -5804,10 +6663,10 @@ ] }, { - "cell_type": "markdown", - "metadata": { - "collapsed": true - }, + "cell_type": "code", + "execution_count": 61, + "metadata": {}, + "outputs": [], "source": [ "zi.close()" ] From 795f021fb4022f49f8732fc5a2b41ef872cf3116 Mon Sep 17 00:00:00 2001 From: Jens Hedegaard Nielsen Date: Mon, 26 Feb 2018 10:52:25 +0100 Subject: [PATCH 13/22] validate all outputs correctly --- qcodes/instrument_drivers/ZI/ZIUHFLI.py | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/qcodes/instrument_drivers/ZI/ZIUHFLI.py b/qcodes/instrument_drivers/ZI/ZIUHFLI.py index 41695ff1238..86a1d26d273 100644 --- a/qcodes/instrument_drivers/ZI/ZIUHFLI.py +++ b/qcodes/instrument_drivers/ZI/ZIUHFLI.py @@ -2032,11 +2032,18 @@ def ampdef_valid(number, value): def update_range_offset_amp(): range_val = params['signal_output{}_range'.format(number+1)].get() offset_val = params['signal_output{}_offset'.format(number+1)].get() - amp_val = params['signal_output{}_amplitude1'.format(number+1)].get() - if -range_val < offset_val + amp_val > range_val: - #The GUI would allow higher values but it would clip the signal. - raise ValueError('Signal Output: Amplitude and/or ' - 'offset out of range.') + + if 'MF' in self.props['options']: + amps_val = [params['signal_output{}_amplitude{}'.format( + number + 1, output)].get() for output in range(1,9)] + else: + amps_val = [params['signal_output{}_amplitude'.format( + number+1)].get()] + for amp_val in amps_val: + if -range_val < offset_val + amp_val > range_val: + #The GUI would allow higher values but it would clip the signal. + raise ValueError('Signal Output: Amplitude and/or ' + 'offset out of range.') def update_offset(): self.parameters['signal_output{}_offset'.format(number+1)].get() From e2a90ed5feb6c881b4f1fb41ca78b5a229f1f192 Mon Sep 17 00:00:00 2001 From: "Jens H. Nielsen" Date: Wed, 14 Mar 2018 11:04:12 +0100 Subject: [PATCH 14/22] zi daq make it possible to supply a custom x axis --- qcodes/instrument_drivers/ZI/ZIUHFLI.py | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/qcodes/instrument_drivers/ZI/ZIUHFLI.py b/qcodes/instrument_drivers/ZI/ZIUHFLI.py index 86a1d26d273..9254d5c6f2d 100644 --- a/qcodes/instrument_drivers/ZI/ZIUHFLI.py +++ b/qcodes/instrument_drivers/ZI/ZIUHFLI.py @@ -124,7 +124,8 @@ def __init__(self, name, instrument, **kwargs): super().__init__(name, names=('',), shapes=((1,),), **kwargs) self._instrument = instrument - def build_data_arrays(self): + def build_data_arrays(self, setpoints_name=None, setpoints_unit=None, setpoints_label=None, + setpoints_start=None, setpoints_stop=None): signals = self._instrument._daq_signals sigunits = {'x': 'V', 'y': 'V', 'r': 'Vrms', 'phase': 'degrees'} names = [] @@ -143,8 +144,13 @@ def build_data_arrays(self): names.append(name) units.append(sigunits[name]) - setpointarray = np.linspace(0, 1 / max_sample_rate * ncols, ncols) - setpointarray = setpointarray + self._instrument.trigger_delay() + if setpoints_start is not None and setpoints_stop is not None: + setpointarray = np.linspace(setpoints_start, setpoints_stop, ncols) + elif setpoints_start is None and setpoints_stop is None: + setpointarray = np.linspace(0, 1 / max_sample_rate * ncols, ncols) + setpointarray = setpointarray + self._instrument.trigger_delay() + else: + raise RuntimeError("Must either supply both start and stop or neither") nested_setpoints = ((tuple(setpointarray),),) setpoints = nested_setpoints*len(signals) @@ -154,9 +160,12 @@ def build_data_arrays(self): self.labels = tuple(names) # TODO: What are good labels? self.setpoints = setpoints - self.setpoint_names = (('time',),)*len(signals) - self.setpoint_labels = (('Time',),)*len(signals) - self.setpoint_units = (('s',),)*len(signals) + base_setpoint_name = setpoints_name or 'time' + base_setpoint_label = setpoints_label or setpoints_name or 'Time' + base_setpoint_unit = setpoints_unit or 's' + self.setpoint_names = ((base_setpoint_name,),)*len(signals) + self.setpoint_labels = ((base_setpoint_label,),)*len(signals) + self.setpoint_units = ((base_setpoint_unit,),)*len(signals) self.shapes = ((ncols,),)*len(self._instrument._daq_signals) self._instrument._daq_prepared = True From b2d111386508ebde1a5170ce7abcdd966861c41a Mon Sep 17 00:00:00 2001 From: "Jens H. Nielsen" Date: Wed, 14 Mar 2018 11:05:00 +0100 Subject: [PATCH 15/22] add example of custom x axis on daq --- .../Qcodes example with ZI UHF-LI.ipynb | 995 ++++++++++++++++-- 1 file changed, 935 insertions(+), 60 deletions(-) diff --git a/docs/examples/driver_examples/Qcodes example with ZI UHF-LI.ipynb b/docs/examples/driver_examples/Qcodes example with ZI UHF-LI.ipynb index 286da5f695c..7af97059000 100644 --- a/docs/examples/driver_examples/Qcodes example with ZI UHF-LI.ipynb +++ b/docs/examples/driver_examples/Qcodes example with ZI UHF-LI.ipynb @@ -30,7 +30,7 @@ "output_type": "stream", "text": [ "User schema at C:\\Users\\Jens/qcodesrc_schema.json not found.User settings won't be validated\n", - "C:\\Users\\Jens\\Anaconda3\\envs\\qcodes\\lib\\site-packages\\h5py\\__init__.py:36: FutureWarning: Conversion of the second argument of issubdtype from `float` to `np.floating` is deprecated. In future, it will be treated as `np.float64 == np.dtype(float).type`.\n", + "C:\\Users\\Jens\\Miniconda3\\envs\\qcodes\\lib\\site-packages\\h5py\\__init__.py:36: FutureWarning: Conversion of the second argument of issubdtype from `float` to `np.floating` is deprecated. In future, it will be treated as `np.float64 == np.dtype(float).type`.\n", " from ._conv import register_converters as _register_converters\n" ] } @@ -3948,7 +3948,7 @@ }, { "cell_type": "code", - "execution_count": 28, + "execution_count": 7, "metadata": {}, "outputs": [], "source": [ @@ -3960,7 +3960,7 @@ }, { "cell_type": "code", - "execution_count": 29, + "execution_count": 8, "metadata": {}, "outputs": [ { @@ -3969,7 +3969,7 @@ "-0.001" ] }, - "execution_count": 29, + "execution_count": 8, "metadata": {}, "output_type": "execute_result" } @@ -3987,7 +3987,7 @@ }, { "cell_type": "code", - "execution_count": 30, + "execution_count": 9, "metadata": {}, "outputs": [], "source": [ @@ -4003,7 +4003,7 @@ }, { "cell_type": "code", - "execution_count": 31, + "execution_count": 10, "metadata": {}, "outputs": [], "source": [ @@ -4012,7 +4012,7 @@ }, { "cell_type": "code", - "execution_count": 32, + "execution_count": 11, "metadata": {}, "outputs": [ { @@ -4036,7 +4036,7 @@ }, { "cell_type": "code", - "execution_count": 47, + "execution_count": 12, "metadata": {}, "outputs": [], "source": [ @@ -4045,7 +4045,7 @@ }, { "cell_type": "code", - "execution_count": 48, + "execution_count": 13, "metadata": {}, "outputs": [], "source": [ @@ -4061,7 +4061,7 @@ }, { "cell_type": "code", - "execution_count": 49, + "execution_count": 14, "metadata": {}, "outputs": [], "source": [ @@ -4080,7 +4080,7 @@ }, { "cell_type": "code", - "execution_count": 50, + "execution_count": 15, "metadata": {}, "outputs": [], "source": [ @@ -4089,7 +4089,7 @@ }, { "cell_type": "code", - "execution_count": 51, + "execution_count": 16, "metadata": {}, "outputs": [ { @@ -4098,7 +4098,7 @@ "0.11650844444444444" ] }, - "execution_count": 51, + "execution_count": 16, "metadata": {}, "output_type": "execute_result" } @@ -4109,7 +4109,7 @@ }, { "cell_type": "code", - "execution_count": 52, + "execution_count": 17, "metadata": {}, "outputs": [ { @@ -4118,7 +4118,7 @@ "0" ] }, - "execution_count": 52, + "execution_count": 17, "metadata": {}, "output_type": "execute_result" } @@ -4136,7 +4136,7 @@ }, { "cell_type": "code", - "execution_count": 53, + "execution_count": 22, "metadata": {}, "outputs": [], "source": [ @@ -4145,7 +4145,7 @@ }, { "cell_type": "code", - "execution_count": 54, + "execution_count": 23, "metadata": {}, "outputs": [ { @@ -4153,15 +4153,15 @@ "output_type": "stream", "text": [ "DataSet:\n", - " location = 'data/2018-02-22/#040_{name}_16-26-30'\n", + " location = 'data/2018-03-14/#011_{name}_10-58-36'\n", " | | | \n", " Setpoint | time_set | time | (200,)\n", " Measured | ZIUHFLI_data_acquisition_r | r | (200,)\n", " Measured | ZIUHFLI_data_acquisition_x | x | (200,)\n", " Measured | ZIUHFLI_data_acquisition_y | y | (200,)\n", " Measured | ZIUHFLI_data_acquisition_phase | phase | (200,)\n", - "acquired at 2018-02-22 16:26:31\n", - "Wall time: 987 ms\n" + "acquired at 2018-03-14 10:58:37\n", + "Wall time: 1.08 s\n" ] } ], @@ -4172,7 +4172,7 @@ }, { "cell_type": "code", - "execution_count": 55, + "execution_count": 24, "metadata": {}, "outputs": [ { @@ -4257,7 +4257,7 @@ " };\n", "\n", " this.imageObj.onunload = function() {\n", - " fig.ws.close();\n", + " this.ws.close();\n", " }\n", "\n", " this.ws.onmessage = this._make_on_message_function(this);\n", @@ -4904,12 +4904,9 @@ " // Check for shift+enter\n", " if (event.shiftKey && event.which == 13) {\n", " this.canvas_div.blur();\n", - " event.shiftKey = false;\n", - " // Send a \"J\" for go to next cell\n", - " event.which = 74;\n", - " event.keyCode = 74;\n", - " manager.command_mode();\n", - " manager.handle_keydown(event);\n", + " // select the cell after this one\n", + " var index = IPython.notebook.find_cell_index(this.cell_info[0]);\n", + " IPython.notebook.select(index + 1);\n", " }\n", "}\n", "\n", @@ -4958,7 +4955,7 @@ { "data": { "text/html": [ - "" + "" ], "text/plain": [ "" @@ -4981,16 +4978,16 @@ }, { "cell_type": "code", - "execution_count": 56, + "execution_count": 25, "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "6.135095388425799e-05" + "4.0035991776574825e-05" ] }, - "execution_count": 56, + "execution_count": 25, "metadata": {}, "output_type": "execute_result" } @@ -5001,7 +4998,7 @@ }, { "cell_type": "code", - "execution_count": 57, + "execution_count": 26, "metadata": {}, "outputs": [], "source": [ @@ -5011,7 +5008,7 @@ }, { "cell_type": "code", - "execution_count": 58, + "execution_count": 27, "metadata": {}, "outputs": [ { @@ -5019,14 +5016,14 @@ "output_type": "stream", "text": [ "DataSet:\n", - " location = 'data/2018-02-22/#041_{name}_16-26-34'\n", + " location = 'data/2018-03-14/#012_{name}_10-58-42'\n", " | | | \n", " Setpoint | time_set | time | (200,)\n", " Measured | ZIUHFLI_data_acquisition_r | r | (200,)\n", " Measured | ZIUHFLI_data_acquisition_x | x | (200,)\n", " Measured | ZIUHFLI_data_acquisition_y | y | (200,)\n", " Measured | ZIUHFLI_data_acquisition_phase | phase | (200,)\n", - "acquired at 2018-02-22 16:26:47\n", + "acquired at 2018-03-14 10:58:55\n", "Wall time: 12.7 s\n" ] } @@ -5038,7 +5035,7 @@ }, { "cell_type": "code", - "execution_count": 59, + "execution_count": 28, "metadata": { "scrolled": false }, @@ -5125,7 +5122,7 @@ " };\n", "\n", " this.imageObj.onunload = function() {\n", - " fig.ws.close();\n", + " this.ws.close();\n", " }\n", "\n", " this.ws.onmessage = this._make_on_message_function(this);\n", @@ -5772,12 +5769,9 @@ " // Check for shift+enter\n", " if (event.shiftKey && event.which == 13) {\n", " this.canvas_div.blur();\n", - " event.shiftKey = false;\n", - " // Send a \"J\" for go to next cell\n", - " event.which = 74;\n", - " event.keyCode = 74;\n", - " manager.command_mode();\n", - " manager.handle_keydown(event);\n", + " // select the cell after this one\n", + " var index = IPython.notebook.find_cell_index(this.cell_info[0]);\n", + " IPython.notebook.select(index + 1);\n", " }\n", "}\n", "\n", @@ -5826,7 +5820,7 @@ { "data": { "text/html": [ - "" + "" ], "text/plain": [ "" @@ -5842,16 +5836,16 @@ }, { "cell_type": "code", - "execution_count": 60, + "execution_count": 29, "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "3.7162948984398314e-06" + "3.927870213235596e-06" ] }, - "execution_count": 60, + "execution_count": 29, "metadata": {}, "output_type": "execute_result" } @@ -5862,8 +5856,10 @@ }, { "cell_type": "code", - "execution_count": 24, - "metadata": {}, + "execution_count": 30, + "metadata": { + "scrolled": true + }, "outputs": [ { "data": { @@ -5947,7 +5943,7 @@ " };\n", "\n", " this.imageObj.onunload = function() {\n", - " fig.ws.close();\n", + " this.ws.close();\n", " }\n", "\n", " this.ws.onmessage = this._make_on_message_function(this);\n", @@ -6594,12 +6590,9 @@ " // Check for shift+enter\n", " if (event.shiftKey && event.which == 13) {\n", " this.canvas_div.blur();\n", - " event.shiftKey = false;\n", - " // Send a \"J\" for go to next cell\n", - " event.which = 74;\n", - " event.keyCode = 74;\n", - " manager.command_mode();\n", - " manager.handle_keydown(event);\n", + " // select the cell after this one\n", + " var index = IPython.notebook.find_cell_index(this.cell_info[0]);\n", + " IPython.notebook.select(index + 1);\n", " }\n", "}\n", "\n", @@ -6648,7 +6641,7 @@ { "data": { "text/html": [ - "" + "" ], "text/plain": [ "" @@ -6662,14 +6655,896 @@ "plot = qc.MatPlot(data.ZIUHFLI_data_acquisition_x, data.ZIUHFLI_data_acquisition_y)" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Sometimes you may want to label the x axis differently because you know that the time on\n", + "that axis actually matches a different parameter such as a voltage sweep. This can be\n", + "done by passing name, label, unit and start adn stop to build_data_arrays" + ] + }, { "cell_type": "code", - "execution_count": 61, + "execution_count": 31, "metadata": {}, "outputs": [], "source": [ - "zi.close()" + "zi.data_acquisition.data.build_data_arrays(setpoints_name='voltage', \n", + " setpoints_label='Voltage',\n", + " setpoints_unit='V',\n", + " setpoints_start=-1,\n", + " setpoints_stop=0.3)" + ] + }, + { + "cell_type": "code", + "execution_count": 34, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "DataSet:\n", + " location = 'data/2018-03-14/#013_{name}_11-00-45'\n", + " | | | \n", + " Setpoint | voltage_set | voltage | (200,)\n", + " Measured | ZIUHFLI_data_acquisition_r | r | (200,)\n", + " Measured | ZIUHFLI_data_acquisition_x | x | (200,)\n", + " Measured | ZIUHFLI_data_acquisition_y | y | (200,)\n", + " Measured | ZIUHFLI_data_acquisition_phase | phase | (200,)\n", + "acquired at 2018-03-14 11:00:58\n", + "Wall time: 12.7 s\n" + ] + } + ], + "source": [ + "%%time\n", + "data = qc.Measure(zi.data_acquisition.data).run()" + ] + }, + { + "cell_type": "code", + "execution_count": 35, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "1.937451982760713e-06" + ] + }, + "execution_count": 35, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "data.ZIUHFLI_data_acquisition_r.ndarray.max()-data.ZIUHFLI_data_acquisition_r.ndarray.min()" ] + }, + { + "cell_type": "code", + "execution_count": 36, + "metadata": {}, + "outputs": [ + { + "data": { + "application/javascript": [ + "/* Put everything inside the global mpl namespace */\n", + "window.mpl = {};\n", + "\n", + "\n", + "mpl.get_websocket_type = function() {\n", + " if (typeof(WebSocket) !== 'undefined') {\n", + " return WebSocket;\n", + " } else if (typeof(MozWebSocket) !== 'undefined') {\n", + " return MozWebSocket;\n", + " } else {\n", + " alert('Your browser does not have WebSocket support.' +\n", + " 'Please try Chrome, Safari or Firefox ≥ 6. ' +\n", + " 'Firefox 4 and 5 are also supported but you ' +\n", + " 'have to enable WebSockets in about:config.');\n", + " };\n", + "}\n", + "\n", + "mpl.figure = function(figure_id, websocket, ondownload, parent_element) {\n", + " this.id = figure_id;\n", + "\n", + " this.ws = websocket;\n", + "\n", + " this.supports_binary = (this.ws.binaryType != undefined);\n", + "\n", + " if (!this.supports_binary) {\n", + " var warnings = document.getElementById(\"mpl-warnings\");\n", + " if (warnings) {\n", + " warnings.style.display = 'block';\n", + " warnings.textContent = (\n", + " \"This browser does not support binary websocket messages. \" +\n", + " \"Performance may be slow.\");\n", + " }\n", + " }\n", + "\n", + " this.imageObj = new Image();\n", + "\n", + " this.context = undefined;\n", + " this.message = undefined;\n", + " this.canvas = undefined;\n", + " this.rubberband_canvas = undefined;\n", + " this.rubberband_context = undefined;\n", + " this.format_dropdown = undefined;\n", + "\n", + " this.image_mode = 'full';\n", + "\n", + " this.root = $('
');\n", + " this._root_extra_style(this.root)\n", + " this.root.attr('style', 'display: inline-block');\n", + "\n", + " $(parent_element).append(this.root);\n", + "\n", + " this._init_header(this);\n", + " this._init_canvas(this);\n", + " this._init_toolbar(this);\n", + "\n", + " var fig = this;\n", + "\n", + " this.waiting = false;\n", + "\n", + " this.ws.onopen = function () {\n", + " fig.send_message(\"supports_binary\", {value: fig.supports_binary});\n", + " fig.send_message(\"send_image_mode\", {});\n", + " if (mpl.ratio != 1) {\n", + " fig.send_message(\"set_dpi_ratio\", {'dpi_ratio': mpl.ratio});\n", + " }\n", + " fig.send_message(\"refresh\", {});\n", + " }\n", + "\n", + " this.imageObj.onload = function() {\n", + " if (fig.image_mode == 'full') {\n", + " // Full images could contain transparency (where diff images\n", + " // almost always do), so we need to clear the canvas so that\n", + " // there is no ghosting.\n", + " fig.context.clearRect(0, 0, fig.canvas.width, fig.canvas.height);\n", + " }\n", + " fig.context.drawImage(fig.imageObj, 0, 0);\n", + " };\n", + "\n", + " this.imageObj.onunload = function() {\n", + " this.ws.close();\n", + " }\n", + "\n", + " this.ws.onmessage = this._make_on_message_function(this);\n", + "\n", + " this.ondownload = ondownload;\n", + "}\n", + "\n", + "mpl.figure.prototype._init_header = function() {\n", + " var titlebar = $(\n", + " '
');\n", + " var titletext = $(\n", + " '
');\n", + " titlebar.append(titletext)\n", + " this.root.append(titlebar);\n", + " this.header = titletext[0];\n", + "}\n", + "\n", + "\n", + "\n", + "mpl.figure.prototype._canvas_extra_style = function(canvas_div) {\n", + "\n", + "}\n", + "\n", + "\n", + "mpl.figure.prototype._root_extra_style = function(canvas_div) {\n", + "\n", + "}\n", + "\n", + "mpl.figure.prototype._init_canvas = function() {\n", + " var fig = this;\n", + "\n", + " var canvas_div = $('
');\n", + "\n", + " canvas_div.attr('style', 'position: relative; clear: both; outline: 0');\n", + "\n", + " function canvas_keyboard_event(event) {\n", + " return fig.key_event(event, event['data']);\n", + " }\n", + "\n", + " canvas_div.keydown('key_press', canvas_keyboard_event);\n", + " canvas_div.keyup('key_release', canvas_keyboard_event);\n", + " this.canvas_div = canvas_div\n", + " this._canvas_extra_style(canvas_div)\n", + " this.root.append(canvas_div);\n", + "\n", + " var canvas = $('');\n", + " canvas.addClass('mpl-canvas');\n", + " canvas.attr('style', \"left: 0; top: 0; z-index: 0; outline: 0\")\n", + "\n", + " this.canvas = canvas[0];\n", + " this.context = canvas[0].getContext(\"2d\");\n", + "\n", + " var backingStore = this.context.backingStorePixelRatio ||\n", + "\tthis.context.webkitBackingStorePixelRatio ||\n", + "\tthis.context.mozBackingStorePixelRatio ||\n", + "\tthis.context.msBackingStorePixelRatio ||\n", + "\tthis.context.oBackingStorePixelRatio ||\n", + "\tthis.context.backingStorePixelRatio || 1;\n", + "\n", + " mpl.ratio = (window.devicePixelRatio || 1) / backingStore;\n", + "\n", + " var rubberband = $('');\n", + " rubberband.attr('style', \"position: absolute; left: 0; top: 0; z-index: 1;\")\n", + "\n", + " var pass_mouse_events = true;\n", + "\n", + " canvas_div.resizable({\n", + " start: function(event, ui) {\n", + " pass_mouse_events = false;\n", + " },\n", + " resize: function(event, ui) {\n", + " fig.request_resize(ui.size.width, ui.size.height);\n", + " },\n", + " stop: function(event, ui) {\n", + " pass_mouse_events = true;\n", + " fig.request_resize(ui.size.width, ui.size.height);\n", + " },\n", + " });\n", + "\n", + " function mouse_event_fn(event) {\n", + " if (pass_mouse_events)\n", + " return fig.mouse_event(event, event['data']);\n", + " }\n", + "\n", + " rubberband.mousedown('button_press', mouse_event_fn);\n", + " rubberband.mouseup('button_release', mouse_event_fn);\n", + " // Throttle sequential mouse events to 1 every 20ms.\n", + " rubberband.mousemove('motion_notify', mouse_event_fn);\n", + "\n", + " rubberband.mouseenter('figure_enter', mouse_event_fn);\n", + " rubberband.mouseleave('figure_leave', mouse_event_fn);\n", + "\n", + " canvas_div.on(\"wheel\", function (event) {\n", + " event = event.originalEvent;\n", + " event['data'] = 'scroll'\n", + " if (event.deltaY < 0) {\n", + " event.step = 1;\n", + " } else {\n", + " event.step = -1;\n", + " }\n", + " mouse_event_fn(event);\n", + " });\n", + "\n", + " canvas_div.append(canvas);\n", + " canvas_div.append(rubberband);\n", + "\n", + " this.rubberband = rubberband;\n", + " this.rubberband_canvas = rubberband[0];\n", + " this.rubberband_context = rubberband[0].getContext(\"2d\");\n", + " this.rubberband_context.strokeStyle = \"#000000\";\n", + "\n", + " this._resize_canvas = function(width, height) {\n", + " // Keep the size of the canvas, canvas container, and rubber band\n", + " // canvas in synch.\n", + " canvas_div.css('width', width)\n", + " canvas_div.css('height', height)\n", + "\n", + " canvas.attr('width', width * mpl.ratio);\n", + " canvas.attr('height', height * mpl.ratio);\n", + " canvas.attr('style', 'width: ' + width + 'px; height: ' + height + 'px;');\n", + "\n", + " rubberband.attr('width', width);\n", + " rubberband.attr('height', height);\n", + " }\n", + "\n", + " // Set the figure to an initial 600x600px, this will subsequently be updated\n", + " // upon first draw.\n", + " this._resize_canvas(600, 600);\n", + "\n", + " // Disable right mouse context menu.\n", + " $(this.rubberband_canvas).bind(\"contextmenu\",function(e){\n", + " return false;\n", + " });\n", + "\n", + " function set_focus () {\n", + " canvas.focus();\n", + " canvas_div.focus();\n", + " }\n", + "\n", + " window.setTimeout(set_focus, 100);\n", + "}\n", + "\n", + "mpl.figure.prototype._init_toolbar = function() {\n", + " var fig = this;\n", + "\n", + " var nav_element = $('
')\n", + " nav_element.attr('style', 'width: 100%');\n", + " this.root.append(nav_element);\n", + "\n", + " // Define a callback function for later on.\n", + " function toolbar_event(event) {\n", + " return fig.toolbar_button_onclick(event['data']);\n", + " }\n", + " function toolbar_mouse_event(event) {\n", + " return fig.toolbar_button_onmouseover(event['data']);\n", + " }\n", + "\n", + " for(var toolbar_ind in mpl.toolbar_items) {\n", + " var name = mpl.toolbar_items[toolbar_ind][0];\n", + " var tooltip = mpl.toolbar_items[toolbar_ind][1];\n", + " var image = mpl.toolbar_items[toolbar_ind][2];\n", + " var method_name = mpl.toolbar_items[toolbar_ind][3];\n", + "\n", + " if (!name) {\n", + " // put a spacer in here.\n", + " continue;\n", + " }\n", + " var button = $('