Skip to content

Commit

Permalink
fix subscriber to make array params work correctly.
Browse files Browse the repository at this point in the history
  • Loading branch information
wpfff committed Oct 10, 2018
1 parent 42b8e7c commit 5b6b20e
Show file tree
Hide file tree
Showing 3 changed files with 179 additions and 1,688 deletions.
145 changes: 125 additions & 20 deletions doc/Client Examples.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,12 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"metadata": {
"ExecuteTime": {
"end_time": "2018-10-10T14:56:57.071319Z",
"start_time": "2018-10-10T14:56:56.729047Z"
}
},
"outputs": [],
"source": [
"%matplotlib notebook\n",
Expand All @@ -28,7 +33,12 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"metadata": {
"ExecuteTime": {
"end_time": "2018-10-10T14:56:57.530085Z",
"start_time": "2018-10-10T14:56:57.503303Z"
}
},
"outputs": [],
"source": [
"from plottr import client\n",
Expand Down Expand Up @@ -65,7 +75,12 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"metadata": {
"ExecuteTime": {
"end_time": "2018-10-10T14:19:31.660475Z",
"start_time": "2018-10-10T14:19:31.615346Z"
}
},
"outputs": [],
"source": [
"def make_1d_data(nx, start=0):\n",
Expand Down Expand Up @@ -99,7 +114,12 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"metadata": {
"ExecuteTime": {
"end_time": "2018-10-10T14:19:34.226465Z",
"start_time": "2018-10-10T14:19:34.175845Z"
}
},
"outputs": [],
"source": [
"# just a boring cos curve\n",
Expand Down Expand Up @@ -156,7 +176,12 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"metadata": {
"ExecuteTime": {
"end_time": "2018-10-04T08:43:46.713057Z",
"start_time": "2018-10-04T08:43:46.710469Z"
}
},
"outputs": [],
"source": [
"of = 0"
Expand All @@ -165,7 +190,12 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"metadata": {
"ExecuteTime": {
"end_time": "2018-10-04T08:43:53.387272Z",
"start_time": "2018-10-04T08:43:53.358536Z"
}
},
"outputs": [],
"source": [
"# execute this cell manually a few times to see the curve getting longer.\n",
Expand All @@ -189,7 +219,12 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"metadata": {
"ExecuteTime": {
"end_time": "2018-10-04T08:44:02.965629Z",
"start_time": "2018-10-04T08:43:57.731253Z"
}
},
"outputs": [],
"source": [
"import time\n",
Expand Down Expand Up @@ -267,18 +302,30 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"metadata": {
"ExecuteTime": {
"end_time": "2018-10-10T14:57:10.078358Z",
"start_time": "2018-10-10T14:57:08.648449Z"
}
},
"outputs": [],
"source": [
"import plottr # ; reload(plottr)\n",
"from plottr.client import DataSender\n",
"\n",
"from plottr import qcodes_dataset; reload(qcodes_dataset)\n",
"from plottr.qcodes_dataset import QcodesDatasetSubscriber"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"metadata": {
"ExecuteTime": {
"end_time": "2018-10-10T14:57:10.085262Z",
"start_time": "2018-10-10T14:57:10.080334Z"
}
},
"outputs": [],
"source": [
"import qcodes as qc\n",
Expand Down Expand Up @@ -325,6 +372,10 @@
"cell_type": "code",
"execution_count": null,
"metadata": {
"ExecuteTime": {
"end_time": "2018-10-10T14:57:27.356353Z",
"start_time": "2018-10-10T14:57:16.406960Z"
},
"scrolled": false
},
"outputs": [],
Expand All @@ -333,34 +384,44 @@
"meas = Measurement(exp=exp)\n",
"meas.write_period = 0.5\n",
"\n",
"meas.register_custom_parameter('x', unit='bogus')\n",
"meas.register_custom_parameter('y', unit='more bogus', setpoints=['x', ])\n",
"meas.register_custom_parameter('x', unit='bogus', paramtype='array')\n",
"meas.register_custom_parameter('y', unit='more bogus', setpoints=['x', ], paramtype='array')\n",
"\n",
"with meas.run() as datasaver:\n",
" datasaver.dataset.subscribe(QcodesDatasetSubscriber(datasaver.dataset), state=[], \n",
" min_wait=0, min_count=1)\n",
" \n",
" for x in np.linspace(0, 10, 101):\n",
" y = np.cos(x)\n",
" datasaver.add_result(('y', y), ('x', x))\n",
" datasaver.add_result(('y', np.array([y])), ('x', np.array([x])))\n",
" time.sleep(0.1)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"metadata": {
"ExecuteTime": {
"end_time": "2018-10-04T09:34:34.827916Z",
"start_time": "2018-10-04T09:34:34.820476Z"
}
},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"metadata": {
"ExecuteTime": {
"end_time": "2018-10-10T14:57:41.560566Z",
"start_time": "2018-10-10T14:57:41.461864Z"
}
},
"outputs": [],
"source": [
"xvals = np.array(datasaver.dataset.get_values('x'))\n",
"yvals = np.array(datasaver.dataset.get_values('y'))\n",
"xvals = np.array(datasaver.dataset.get_values('x')).reshape(-1)\n",
"yvals = np.array(datasaver.dataset.get_values('y')).reshape(-1)\n",
"\n",
"fig, ax = plt.subplots(1, 1)\n",
"ax.plot(xvals, yvals, 'o')"
Expand All @@ -383,7 +444,13 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"metadata": {
"ExecuteTime": {
"end_time": "2018-10-10T14:57:55.685928Z",
"start_time": "2018-10-10T14:57:45.662993Z"
},
"scrolled": true
},
"outputs": [],
"source": [
"exp = select_experiment('dev: plottr subscriber (again)', 'dummy 2D!')\n",
Expand All @@ -405,6 +472,43 @@
" time.sleep(0.1)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## 2D data with lines as 'hard sweeps'"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"ExecuteTime": {
"end_time": "2018-10-10T14:58:04.762794Z",
"start_time": "2018-10-10T14:58:01.174838Z"
}
},
"outputs": [],
"source": [
"exp = select_experiment('dev: plottr subscriber (again. v2.)', 'dummy 2D!')\n",
"meas = Measurement(exp=exp)\n",
"meas.write_period = 0.5\n",
"\n",
"meas.register_custom_parameter('x', unit='A')\n",
"meas.register_custom_parameter('y', unit='B', paramtype='array')\n",
"meas.register_custom_parameter('z', unit='C', setpoints=['x', 'y', ], paramtype='array')\n",
"\n",
"with meas.run() as datasaver:\n",
" datasaver.dataset.subscribe(QcodesDatasetSubscriber(datasaver.dataset), state=[], \n",
" min_wait=0, min_count=1) \n",
" \n",
" for x in np.linspace(0, 10, 31):\n",
" y = np.linspace(0, 10, 31)\n",
" z = np.cos(x) * np.sin(y)\n",
" datasaver.add_result(('z', z), ('y', y), ('x', x))\n",
" time.sleep(0.1)"
]
},
{
"cell_type": "code",
"execution_count": null,
Expand All @@ -416,7 +520,7 @@
"metadata": {
"hide_input": false,
"kernelspec": {
"display_name": "Python 3",
"display_name": "Python [default]",
"language": "python",
"name": "python3"
},
Expand All @@ -430,9 +534,10 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.4"
"version": "3.6.6"
},
"toc": {
"base_numbering": 1,
"nav_menu": {},
"number_sections": true,
"sideBar": true,
Expand All @@ -444,7 +549,7 @@
"height": "calc(100% - 180px)",
"left": "10px",
"top": "150px",
"width": "267px"
"width": "224px"
},
"toc_section_display": true,
"toc_window_display": true
Expand Down

0 comments on commit 5b6b20e

Please sign in to comment.