Commit eeafde1e authored by Nick Sauerwein's avatar Nick Sauerwein
Browse files

fixed problems with interferometer and changed bokeh ids

parent 909ab5d1
......@@ -115,7 +115,7 @@ class Interferometer:
alpha= self.Alpha(measurement['im1'],measurement['im2'])
self.plot_server_ph.update(alpha[zmin/self.psize:zmax/self.psize, xmin/self.psize:xmax/self.psize], extent=[zmin, zmax, xmin, xmax])
self.plot_server_ph.update(np.flipud(alpha), extent=[zmin, zmax, xmin, xmax])
def turn_off(self):
self.cam.close()
......
......@@ -20,6 +20,7 @@ class Laser:
def __init__(self, config, DRS4):
self.drs = DRS4
self.set_config(config)
self.plot_server = None
def set_config(self, config):
self.max_angle = config['max_angle']
......@@ -56,8 +57,18 @@ class Laser:
def measure(self):
import datetime
time = datetime.datetime.now()
return {'time': time, 'intensity': np.max(self.drs.readChannel(self.channel))}
sig_time, sig_uvolt = self.drs.readChannel(self.channel)
return {'time': time,'sig_time':sig_time,'sig_uvolt': sig_uvolt, 'peak_uvolt': np.max(sig_uvolt)}
def plot_measure(self, measurement, config = None):
from PlottingServers import Plot1DServer
if self.plot_server == None:
self.plot_server = Plot1DServer({'title':'Laser', 'xlabel':'Time [ns]', 'ylabel': 'Signal [uV]'})
self.plot_server.update(measurement['sig_time'], measurement['sig_uvolt'])
\ No newline at end of file
......@@ -35,14 +35,14 @@
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": 2,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Optimal focus 2 (programm) loaded\n"
"Intensity scan loaded\n"
]
}
],
......@@ -57,25 +57,37 @@
},
{
"cell_type": "code",
"execution_count": 53,
"execution_count": 3,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"#dm.print_dict(config)"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {
"hideCode": false,
"hidePrompt": false
"hidePrompt": false,
"scrolled": true
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"-9 'Linux lwfaserver running'\n",
"-8 optimal compressor position\n",
"-7 optimal compression\n",
"-6 old periscope postiion (from elog downloaded 32)\n",
"-5 old parabolic mirror position (elog 32)\n",
"-4 Parabilic Mirror manual optimization\n",
"-3 Optimal focus (programm) \n",
"-2 Optimal focus (programm terminated, better =) )\n",
"-1 Optimal focus 2 (programm)\n"
"-9 optimal compression\n",
"-8 old periscope postiion (from elog downloaded 32)\n",
"-7 old parabolic mirror position (elog 32)\n",
"-6 Parabilic Mirror manual optimization\n",
"-5 Optimal focus (programm) \n",
"-4 Optimal focus (programm terminated, better =) )\n",
"-3 Optimal focus 2 (programm)\n",
"-2 beginning of longitudinal alignment\n",
"-1 Intensity scan\n"
]
}
],
......@@ -234,7 +246,7 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": 5,
"metadata": {
"hideCode": false,
"hidePrompt": false
......@@ -244,16 +256,24 @@
"name": "stdout",
"output_type": "stream",
"text": [
"hu\n",
"hu\n",
"hu\n",
"hu\n",
"dummmotor used\n",
"Connnection with motors sucessful!\n",
"c\n",
"x\n",
"y\n",
"z\n"
"Connection to motors failed. Close all programs that use the motors or restart the controllers\n"
]
},
{
"ename": "FtdiError",
"evalue": "b'device not found' (-3)",
"output_type": "error",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mFtdiError\u001b[0m Traceback (most recent call last)",
"\u001b[0;32m<ipython-input-5-85a132f2e043>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m()\u001b[0m\n\u001b[1;32m 15\u001b[0m 'sync_camera': False}\n\u001b[1;32m 16\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 17\u001b[0;31m \u001b[0mper\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mPeriscope\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mper_config\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mhome\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;32mFalse\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m",
"\u001b[0;32m/home/data/lwfaserver/Devices/Periscope.py\u001b[0m in \u001b[0;36m__init__\u001b[0;34m(self, config, home)\u001b[0m\n\u001b[1;32m 32\u001b[0m \u001b[0mtime\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0msleep\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;36m0.01\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 33\u001b[0m \u001b[0;32mtry\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 34\u001b[0;31m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mconnect_motors\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 35\u001b[0m \u001b[0mprint\u001b[0m \u001b[0;34m(\u001b[0m\u001b[0;34m'Connnection with motors sucessful!'\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 36\u001b[0m \u001b[0;32mexcept\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;32m/home/data/lwfaserver/Devices/Periscope.py\u001b[0m in \u001b[0;36mconnect_motors\u001b[0;34m(self)\u001b[0m\n\u001b[1;32m 108\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 109\u001b[0m \u001b[0;32mdef\u001b[0m \u001b[0mconnect_motors\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 110\u001b[0;31m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mMz\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mZ825B\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;36m83829619\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;31m#Z825B(83835879)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 111\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mPz\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mZ825B\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;36m83832249\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 112\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mPy\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mZ825B\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;36m83832219\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;32m/home/data/pyAPT/pyAPT/z825b.py\u001b[0m in \u001b[0;36m__init__\u001b[0;34m(self, *args, **kwargs)\u001b[0m\n\u001b[1;32m 7\u001b[0m \"\"\"\n\u001b[1;32m 8\u001b[0m \u001b[0;32mdef\u001b[0m \u001b[0m__init__\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m*\u001b[0m\u001b[0margs\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m**\u001b[0m\u001b[0mkwargs\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 9\u001b[0;31m \u001b[0msuper\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mZ825B\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m__init__\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m*\u001b[0m\u001b[0margs\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m**\u001b[0m\u001b[0mkwargs\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 10\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 11\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;32m/home/data/pyAPT/pyAPT/controller.py\u001b[0m in \u001b[0;36m__init__\u001b[0;34m(self, serial_number, label)\u001b[0m\n\u001b[1;32m 25\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 26\u001b[0m \u001b[0;31m# this takes up to 2-3s:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 27\u001b[0;31m \u001b[0mdev\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mpylibftdi\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mDevice\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mmode\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;34m'b'\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mdevice_id\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mserial_number\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 28\u001b[0m \u001b[0mdev\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mbaudrate\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;36m115200\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 29\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;32m/home/data/anaconda3/lib/python3.6/site-packages/pylibftdi/device.py\u001b[0m in \u001b[0;36m__init__\u001b[0;34m(self, device_id, mode, encoding, lazy_open, chunk_size, interface_select, device_index, **kwargs)\u001b[0m\n\u001b[1;32m 94\u001b[0m \u001b[0;31m# lazy_open tells us not to open immediately.\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 95\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0;32mnot\u001b[0m \u001b[0mlazy_open\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 96\u001b[0;31m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mopen\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 97\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 98\u001b[0m \u001b[0;32mdef\u001b[0m \u001b[0m__del__\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;32m/home/data/anaconda3/lib/python3.6/site-packages/pylibftdi/device.py\u001b[0m in \u001b[0;36mopen\u001b[0;34m(self)\u001b[0m\n\u001b[1;32m 134\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mfdll\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mftdi_deinit\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mbyref\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mctx\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 135\u001b[0m \u001b[0;32mdel\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mctx\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 136\u001b[0;31m \u001b[0;32mraise\u001b[0m \u001b[0mFtdiError\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mmsg\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 137\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 138\u001b[0m \u001b[0;31m# explicitly reset the device to serial mode with standard settings\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;31mFtdiError\u001b[0m: b'device not found' (-3)"
]
}
],
......@@ -289,8 +309,9 @@
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": 3,
"metadata": {
"collapsed": true,
"hideCode": false,
"hidePrompt": false
},
......@@ -307,7 +328,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 4,
"metadata": {
"collapsed": true,
"hideCode": false,
......@@ -333,7 +354,7 @@
},
{
"cell_type": "code",
"execution_count": 7,
"execution_count": 5,
"metadata": {
"hideCode": false,
"hidePrompt": false
......@@ -369,54 +390,30 @@
},
{
"cell_type": "code",
"execution_count": 27,
"execution_count": 6,
"metadata": {
"collapsed": true,
"hideCode": false,
"hidePrompt": false
},
"outputs": [
{
"ename": "RuntimeError",
"evalue": "Unknown exception",
"output_type": "error",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mRuntimeError\u001b[0m Traceback (most recent call last)",
"\u001b[0;32m<ipython-input-27-176bda7a6825>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m()\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0mmeasurement\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0minter\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mmeasure\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m",
"\u001b[0;32m/home/data/lwfaserver/Devices/Interferometer.py\u001b[0m in \u001b[0;36mmeasure\u001b[0;34m(self)\u001b[0m\n\u001b[1;32m 79\u001b[0m \u001b[0mD\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 80\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 81\u001b[0;31m \u001b[0;32mfor\u001b[0m \u001b[0mimg\u001b[0m \u001b[0;32min\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mcam\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mgrab_images\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;36m2\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 82\u001b[0m \u001b[0mD\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mappend\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mimg\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 83\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;32mPyPylon/cython/factory.pyx\u001b[0m in \u001b[0;36mgrab_images (cython/factory.cpp:5092)\u001b[0;34m()\u001b[0m\n",
"\u001b[0;31mRuntimeError\u001b[0m: Unknown exception"
]
}
],
"outputs": [],
"source": [
"measurement = inter.measure()"
"#measurement = inter.measure()"
]
},
{
"cell_type": "code",
"execution_count": 28,
"execution_count": 7,
"metadata": {
"collapsed": true,
"hideCode": false,
"hideOutput": true,
"hidePrompt": false,
"scrolled": true
},
"outputs": [
{
"ename": "NameError",
"evalue": "name 'measurement' is not defined",
"output_type": "error",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mNameError\u001b[0m Traceback (most recent call last)",
"\u001b[0;32m<ipython-input-28-59c329dc214f>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m()\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0minter\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mplot_measure\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mmeasurement\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m",
"\u001b[0;31mNameError\u001b[0m: name 'measurement' is not defined"
]
}
],
"outputs": [],
"source": [
"inter.plot_measure(measurement)"
"#inter.plot_measure(measurement)"
]
},
{
......@@ -463,7 +460,7 @@
{
"data": {
"text/plain": [
"{'time': '2017-05-18_10-59-30.116813'}"
"{'time': '2017-05-18_18-11-14.383969'}"
]
},
"execution_count": 9,
......@@ -609,7 +606,7 @@
},
{
"cell_type": "code",
"execution_count": 25,
"execution_count": 13,
"metadata": {
"collapsed": true,
"hideCode": false,
......@@ -629,7 +626,7 @@
},
{
"cell_type": "code",
"execution_count": 26,
"execution_count": 14,
"metadata": {
"collapsed": true,
"hideCode": false,
......@@ -640,7 +637,7 @@
},
"outputs": [],
"source": [
"devices = [delay,inter,laser, drs, fara, per]#, focus]#, per]#, blade] #use this to run the LWFA\n",
"devices = [delay,inter,laser, drs, fara]#, per]#, focus]#, per]#, blade] #use this to run the LWFA\n",
"#devices = [td1, td2,fara]#, inter]\n",
"#devices = [ para, laser, focus] #use this to do focus optimization\n",
"#devices = [td1, td2]#, delay]#, inter] #Use this do debug the gui and data menager\n",
......@@ -650,7 +647,7 @@
},
{
"cell_type": "code",
"execution_count": 24,
"execution_count": 15,
"metadata": {
"hideCode": false,
"hidePrompt": false,
......@@ -661,39 +658,57 @@
"name": "stdout",
"output_type": "stream",
"text": [
"DelayGenerator config time: 0.002592802047729492\n",
"Interferometer config time: 0.0005900859832763672\n",
"Laser config time: 0.001294851303100586\n",
"DRS4 config time: 0.0008764266967773438\n",
"FaradayCup config time: 2.384185791015625e-06\n",
"Periscope config time: 0.03824162483215332\n",
"DelayGenerator config time: 0.003587961196899414\n",
"Interferometer config time: 0.0007643699645996094\n",
"Laser config time: 0.0026557445526123047\n",
"DRS4 config time: 0.0018012523651123047\n",
"FaradayCup config time: 1.0251998901367188e-05\n",
"DelayGenerator measured\n",
"DelayGenerator measure time: 0.0009961128234863281\n",
"Laser measured\n",
"Laser measure time: 0.0013418197631835938\n",
"FaradayCup measured\n",
"FaradayCup measure time: 0.0012197494506835938\n",
"maximal possible rate: 19.1\n",
"[<Devices.DelayGenerator.DelayGenerator object at 0x7f0efba80710>, <Devices.Laser.Laser object at 0x7f0eea300278>, <Devices.FaradayCup.FaradayCup object at 0x7f0eea300080>]\n",
"DelayGenerator config time: 0.0025377273559570312\n",
"Laser config time: 0.0014672279357910156\n",
"FaradayCup config time: 1.6689300537109375e-05\n",
"DelayGenerator measured\n",
"DelayGenerator measure time: 0.000843048095703125\n",
"Laser measured\n",
"Laser measure time: 0.0015285015106201172\n",
"FaradayCup measured\n",
"FaradayCup measure time: 0.0014481544494628906\n",
"[<Devices.DelayGenerator.DelayGenerator object at 0x7f0efba80710>, <Devices.Laser.Laser object at 0x7f0eea300278>, <Devices.FaradayCup.FaradayCup object at 0x7f0eea300080>]\n",
"DelayGenerator config time: 0.0025141239166259766\n",
"Laser config time: 0.0014650821685791016\n",
"FaradayCup config time: 2.6226043701171875e-06\n",
"DelayGenerator measured\n",
"DelayGenerator measure time: 0.00044155120849609375\n",
"Laser measured\n",
"Laser measure time: 0.0015072822570800781\n",
"FaradayCup measured\n",
"FaradayCup measure time: 0.001573324203491211\n"
"DelayGenerator measure time: 0.0010149478912353516\n",
"Interferometer measured\n",
"Interferometer measure time: 0.26818370819091797\n",
"http://localhost:5006/?bokeh-session-id=Interferometer_Image\n"
]
},
{
"data": {
"text/html": [
"<script type='text/javascript'>window.open('http://localhost:5006/?bokeh-session-id=Interferometer_Image', '_blank','width=500, height=500');</script>"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"http://localhost:5006/?bokeh-session-id=Interferometer_Phase\n"
]
},
{
"data": {
"text/html": [
"<script type='text/javascript'>window.open('http://localhost:5006/?bokeh-session-id=Interferometer_Phase', '_blank','width=500, height=500');</script>"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"/home/data/lwfaserver/Devices/InterferometerTools/routines.py:207: RuntimeWarning: divide by zero encountered in true_divide\n",
" return np.exp(-1./x**2*(6.*(x[1]-x[0]))**2)\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"maximal possible rate: 0.5\n",
"set rate cannot be reached.\n"
]
}
],
......@@ -829,7 +844,7 @@
"metadata": {
"hideCode": false,
"hidePrompt": false,
"scrolled": false
"scrolled": true
},
"outputs": [
{
......
......@@ -9,14 +9,14 @@ from bokeh.driving import count
from NotebookTools import open_window
class DataStreamProcess_1D(Process):
def __init__(self,server, connecx, connecy, config, *args, **kwargs):
def __init__(self, connecx, connecy, config, *args, **kwargs):
self.connecx = connecx
self.connecy = connecy
self.config = config
Process.__init__(self, *args, **kwargs)
def run(self):
plot_server_1d(connecx = self.connecx, connecy = self.connecy, config = self.config)
def plot_server_1d( connecx = None, connecy = None, config = {'xlabel' : '','ylabel' : '', 'title': ''}):
plot_server_1d( connecx = self.connecx, connecy = self.connecy, config = self.config)
def plot_server_1d(connecx = None, connecy = None, config = {'xlabel' : '','ylabel' : '', 'title': ''}):
doc = Document()
doc.title = config['title']
x = np.linspace(0,1,2)
......@@ -37,8 +37,7 @@ def plot_server_1d( connecx = None, connecy = None, config = {'xlabel' : '','yla
# open a session to keep our local document in sync with server
session = push_session(doc)
session = push_session(doc, session_id = config['title'].replace(' ','_'))
def update():
# updating a single column of the the *same length* is OK
......@@ -52,24 +51,34 @@ def plot_server_1d( connecx = None, connecy = None, config = {'xlabel' : '','yla
doc.add_periodic_callback(update, 50)
doc.add_root(p)
open_window('http://localhost:5006/?bokeh-session-id='+str(session.id))
session.loop_until_closed() # run forever
class Plot1DServer:
def __init__(self, config = {'xlabel' : '','ylabel' : '', 'title': ''}):
def __init__(self, config = {'xlabel' : '','ylabel' : '', 'title': 'default1d'}):
self.connecx_ch, self.connecx_par = Pipe()
self.connecy_ch, self.connecy_par = Pipe()
self.data_stream = DataStreamProcess_1D(self, self.connecx_par, self.connecy_par, config)
self.data_stream = DataStreamProcess_1D( self.connecx_par, self.connecy_par, config)
self.data_stream.start()
self.id = config['title'].replace(' ','_')
self.url = 'http://localhost:5006/?bokeh-session-id='+str(self.id)
self.show()
def update(self, x,y):
self.connecx_ch.send(x)
self.connecy_ch.send(y)
def show(self):
open_window(self.url)
def close():
self.data_stream.close()
......@@ -82,7 +91,7 @@ class DataStreamProcess_2D(Process):
Process.__init__(self, *args, **kwargs)
def run(self):
plot_server_2d( connecim = self.connecim,connecext = self.connecext, config = self.config)
plot_server_2d(connecim = self.connecim,connecext = self.connecext, config = self.config)
def plot_server_2d(connecim = None,connecext = None, config = {'xlabel' : '','ylabel' : '', 'title': ''}):
doc = Document()
......@@ -105,7 +114,7 @@ def plot_server_2d(connecim = None,connecext = None, config = {'xlabel' : '','yl
# open a session to keep our local document in sync with server
session = push_session(doc)
session = push_session(doc, session_id=config['title'].replace(' ','_'))
def update():
# updating a single column of the the *same length* is OK
......@@ -127,19 +136,27 @@ def plot_server_2d(connecim = None,connecext = None, config = {'xlabel' : '','yl
doc.add_periodic_callback(update, 50)
doc.add_root(p)
open_window('http://localhost:5006/?bokeh-session-id='+str(session.id), width = 500)
session.loop_until_closed() # run forever
class Plot2DServer:
def __init__(self, config = {'xlabel' : '','ylabel' : '', 'title': ''}):
self.connecext_ch, self.connecext_par = Pipe()
self.connecim_ch, self.connecim_par = Pipe()
self.data_stream = DataStreamProcess_2D(self.connecim_par,self.connecext_par, config)
self.data_stream = DataStreamProcess_2D( self.connecim_par,self.connecext_par, config)
self.data_stream.start()
self.id = config['title'].replace(' ','_')
self.url = 'http://localhost:5006/?bokeh-session-id='+str(self.id)
self.show()
def show(self):
open_window(self.url, width = 500)
def update(self,image ,extent):
self.connecext_ch.send(extent)
......
......@@ -28,49 +28,55 @@
},
{
"cell_type": "code",
"execution_count": 22,
"execution_count": 10,
"metadata": {
"scrolled": true
},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"/home/data/anaconda3/lib/python3.6/site-packages/bokeh/models/sources.py:81: BokehUserWarning: ColumnDataSource's columns must be of the same length\n",
" lambda: warnings.warn(\"ColumnDataSource's columns must be of the same length\", BokehUserWarning))\n",
"/home/data/anaconda3/lib/python3.6/site-packages/bokeh/models/sources.py:81: BokehUserWarning: ColumnDataSource's columns must be of the same length\n",
" lambda: warnings.warn(\"ColumnDataSource's columns must be of the same length\", BokehUserWarning))\n"
]
}
],
"source": [
"ps1 = Plot1DServer({'title':'test', 'xlabel':'numbers', 'ylabel':'ja'})"
]
},
{
"cell_type": "code",
"execution_count": 11,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"http://localhost:5006/?bokeh-session-id=QFsyjTymTmdFXFhBdSWrxCCrQ0OmoGngJUJDbtnAsTDm\n"
"http://localhost:5006/?bokeh-session-id=test\n"
]
},
{
"data": {
"text/html": [
"<script type='text/javascript'>window.open('http://localhost:5006/?bokeh-session-id=QFsyjTymTmdFXFhBdSWrxCCrQ0OmoGngJUJDbtnAsTDm', '_blank','width=800, height=500');</script>"
"<script type='text/javascript'>window.open('http://localhost:5006/?bokeh-session-id=test', '_blank','width=800, height=500');</script>"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"/home/data/anaconda3/lib/python3.6/site-packages/bokeh/models/sources.py:81: BokehUserWarning: ColumnDataSource's columns must be of the same length\n",
" lambda: warnings.warn(\"ColumnDataSource's columns must be of the same length\", BokehUserWarning))\n",
"/home/data/anaconda3/lib/python3.6/site-packages/bokeh/models/sources.py:81: BokehUserWarning: ColumnDataSource's columns must be of the same length\n",
" lambda: warnings.warn(\"ColumnDataSource's columns must be of the same length\", BokehUserWarning))\n",
"/home/data/anaconda3/lib/python3.6/site-packages/bokeh/models/sources.py:81: BokehUserWarning: ColumnDataSource's columns must be of the same length\n",
" lambda: warnings.warn(\"ColumnDataSource's columns must be of the same length\", BokehUserWarning))\n",
"/home/data/anaconda3/lib/python3.6/site-packages/bokeh/models/sources.py:81: BokehUserWarning: ColumnDataSource's columns must be of the same length\n",
" lambda: warnings.warn(\"ColumnDataSource's columns must be of the same length\", BokehUserWarning))\n"
]
}
],
"source": [
"ps1 = Plot1DServer({'title':'test', 'xlabel':'numbers', 'ylabel':'ja'})"
"ps1.show()"
]
},
{
"cell_type": "code",
"execution_count": 28,
"execution_count": 12,
"metadata": {
"collapsed": true,
"scrolled": true
......@@ -117,6 +123,26 @@
"ps2d.update(np.random.random((70,100))*100,[0,2,0,5])"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"'uu'"
]
},
"execution_count": 2,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"'ua'.replace('a','u')"
]
},
{
"cell_type": "code",
"execution_count": null,
......@@ -132,18 +158,6 @@
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.0"
}
},
"nbformat": 4,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment