Commit 93d2b3f9 authored by Nick Sauerwein's avatar Nick Sauerwein
Browse files

special function capability added =)

parent d825ea60
...@@ -21,9 +21,7 @@ measurement file (n.a) ...@@ -21,9 +21,7 @@ measurement file (n.a)
default_config = {'pos_R': 329, 'pos_L':-1.6} default_config = {'pos_R': 329, 'pos_L':-1.6}
class BladePositioning: class BladePositioning:
def __init__(self, config, init = 1): def __init__(self, config):
if init:
s.init()
self.config = config self.config = config
@property @property
...@@ -41,5 +39,7 @@ class BladePositioning: ...@@ -41,5 +39,7 @@ class BladePositioning:
print ('cor: ', cor(s.getposR())) print ('cor: ', cor(s.getposR()))
def spec_home(self):
s.init()
...@@ -173,5 +173,9 @@ class FocusCamera: ...@@ -173,5 +173,9 @@ class FocusCamera:
self.cam = cam self.cam = cam
def spec_reconnect(self):
self.cam.close()
self.connect_camera()
def turn_off(self): def turn_off(self):
self.cam.close() self.cam.close()
\ No newline at end of file
...@@ -289,7 +289,9 @@ class Interferometer: ...@@ -289,7 +289,9 @@ class Interferometer:
def turn_off(self): def turn_off(self):
self.cam.close() self.cam.close()
def spec_reconnect(self):
self.cam.close()
self.connect_camera()
#additional function #additional function
def connect_camera(self): def connect_camera(self):
available_cameras = pypylon.factory.find_devices() available_cameras = pypylon.factory.find_devices()
......
...@@ -18,7 +18,13 @@ default_config = {'pos_Pay': 3.99396444, ...@@ -18,7 +18,13 @@ default_config = {'pos_Pay': 3.99396444,
'pos_Paz': 5.16051188} 'pos_Paz': 5.16051188}
class ParabolicMirror: class ParabolicMirror:
def __init__(self, config, home = False): def __init__(self, config, FocusCamera, Periscope, Laser):
self.focus = FocusCamera
self.per = Periscope
self.laser = Laser
import time import time
time.sleep(0.1) time.sleep(0.1)
try: try:
...@@ -53,12 +59,18 @@ class ParabolicMirror: ...@@ -53,12 +59,18 @@ class ParabolicMirror:
self.Paz = Z806(83835804) self.Paz = Z806(83835804)
self.Pay = Z806(83835879) self.Pay = Z806(83835879)
self.motors = [self.Pay, self.Paz] self.motors = [self.Pay, self.Paz]
def spec_home(self):
self.home()
def home(self): def home(self):
for motor in self.motors: for motor in self.motors:
motor.home() motor.home()
def spec_align(self):
self.optimize()
def optimize(self, focus, laser, per, wanted_focus_um, n_av = 1, sleep_time = 0.2, output = True, maxiter = 100): def optimize(self, wanted_focus_um = 8, n_av = 1, sleep_time = 0.2, output = True, maxiter = 100):
#this variable is necessary to compensate the attenuation of the laser #this variable is necessary to compensate the attenuation of the laser
global intmult global intmult
intmult = 1. intmult = 1.
...@@ -111,9 +123,9 @@ class ParabolicMirror: ...@@ -111,9 +123,9 @@ class ParabolicMirror:
print ('Parameters: ',(y, z, zc)) print ('Parameters: ',(y, z, zc))
config = {'pos_Pay': y, 'pos_Paz': z} config = {'pos_Pay': y, 'pos_Paz': z}
self.set_config(config) self.config = config
config_per = per.get_config() config_per = self.per.config()
config_per['deltaz_Cz'] = zc config_per['deltaz_Cz'] = zc
#Cz.mAbs(zc) #Cz.mAbs(zc)
...@@ -134,11 +146,11 @@ class ParabolicMirror: ...@@ -134,11 +146,11 @@ class ParabolicMirror:
return to_min()[0] return to_min()[0]
config0 = self.get_config() config0 = self.config
config_per0 = per.get_config() config_per0 = self.per.config
config0_focus = focus.get_config() config0_focus = self.focus.config
config0_focus['measure_full']=True config0_focus['measure_full']=True
focus.set_config(config0_focus) self.focus.config = config0_focus
x0 = [config0['pos_Pay'], x0 = [config0['pos_Pay'],
config0['pos_Paz'], config0['pos_Paz'],
config_per0['deltaz_Cz']/30.] config_per0['deltaz_Cz']/30.]
...@@ -148,9 +160,9 @@ class ParabolicMirror: ...@@ -148,9 +160,9 @@ class ParabolicMirror:
print ('step done') print ('step done')
global reduce_int, intmult global reduce_int, intmult
if reduce_int: if reduce_int:
config_laser = laser.get_config() config_laser = self.laser.config
config_laser['attenuation'] = config_laser['attenuation']/1.2 config_laser['attenuation'] = config_laser['attenuation']/1.2
laser.set_config(config_laser) laser.config = config_laser
intmult *= 1.2 intmult *= 1.2
reduce_int = False reduce_int = False
print ('laser attenuated') print ('laser attenuated')
......
...@@ -37,7 +37,7 @@ default_config = {'pos_l_x': 0.1, ...@@ -37,7 +37,7 @@ default_config = {'pos_l_x': 0.1,
'sync_camera': False} 'sync_camera': False}
class Periscope: class Periscope:
def __init__(self, config, home = False): def __init__(self, config):
import time import time
time.sleep(0.01) time.sleep(0.01)
try: try:
...@@ -94,7 +94,8 @@ class Periscope: ...@@ -94,7 +94,8 @@ class Periscope:
self.mAbs_l(pos_l, sync_camera = self.sync_camera) self.mAbs_l(pos_l, sync_camera = self.sync_camera)
def spec_home(self):
self.home()
def get_position(self, kind = 'global'): def get_position(self, kind = 'global'):
pos_g = np.array([-self.Px.position(), self.Py.position(), self.Pz.position()]) pos_g = np.array([-self.Px.position(), self.Py.position(), self.Pz.position()])
......
...@@ -113,7 +113,11 @@ class PlasmaCamHorizontal: ...@@ -113,7 +113,11 @@ class PlasmaCamHorizontal:
im1 = binArray(im1, 1, self.n_binning, self.n_binning, np.mean) im1 = binArray(im1, 1, self.n_binning, self.n_binning, np.mean)
self.plot_server_im.update(np.flipud(im1),extent=self.psize*np.array([0.,shape[1], 0., shape[0]]) - np.array([self.z0, self.z0, self.y0, self.y0])) self.plot_server_im.update(np.flipud(im1),extent=self.psize*np.array([0.,shape[1], 0., shape[0]]) - np.array([self.z0, self.z0, self.y0, self.y0]))
def spec_reconnect(self):
self.cam.close()
self.connect_camera()
def turn_off(self): def turn_off(self):
self.cam.close() self.cam.close()
......
...@@ -131,7 +131,9 @@ class ScreenCamera: ...@@ -131,7 +131,9 @@ class ScreenCamera:
def turn_off(self): def turn_off(self):
self.cam.close() self.cam.close()
def spec_reconnect(self):
self.cam.close()
self.connect_camera()
#additional function #additional function
def connect_camera(self): def connect_camera(self):
......
...@@ -53,5 +53,6 @@ class test_device1: ...@@ -53,5 +53,6 @@ class test_device1:
self.plot_server.update(range(len(measurement['value'])),measurement['value']) self.plot_server.update(range(len(measurement['value'])),measurement['value'])
def spec_home(self):
print ('this stuff will be homed')
\ No newline at end of file
...@@ -2,12 +2,21 @@ ...@@ -2,12 +2,21 @@
"cells": [ "cells": [
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 1, "execution_count": 7,
"metadata": { "metadata": {
"hideCode": false, "hideCode": false,
"hidePrompt": false "hidePrompt": false
}, },
"outputs": [], "outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"The autoreload extension is already loaded. To reload it, use:\n",
" %reload_ext autoreload\n"
]
}
],
"source": [ "source": [
"import numpy as np\n", "import numpy as np\n",
"import matplotlib.pyplot as plt\n", "import matplotlib.pyplot as plt\n",
...@@ -30,7 +39,7 @@ ...@@ -30,7 +39,7 @@
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
"from Scripts.DevicePool as DevicePool\n", "from Scripts.DevicePool import DevicePool\n",
"from Scripts.MeasurementManager import MeasurementManager\n", "from Scripts.MeasurementManager import MeasurementManager\n",
"from Scripts.GUI import DevicePoolInterface, IoInterface, MeasurementManagerInterface\n", "from Scripts.GUI import DevicePoolInterface, IoInterface, MeasurementManagerInterface\n",
"from Scripts.DataManager import IO" "from Scripts.DataManager import IO"
...@@ -53,20 +62,13 @@ ...@@ -53,20 +62,13 @@
"cell_type": "code", "cell_type": "code",
"execution_count": 4, "execution_count": 4,
"metadata": { "metadata": {
"scrolled": false "scrolled": true
}, },
"outputs": [ "outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"Widget Javascript not detected. It may not be installed or enabled properly.\n"
]
},
{ {
"data": { "data": {
"application/vnd.jupyter.widget-view+json": { "application/vnd.jupyter.widget-view+json": {
"model_id": "2c5d127f5eb14fe8b2ba9a951309ab63" "model_id": "f25b76441d3845daa4f5f7a7284b62d6"
} }
}, },
"metadata": {}, "metadata": {},
...@@ -80,7 +82,7 @@ ...@@ -80,7 +82,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 11, "execution_count": 5,
"metadata": { "metadata": {
"scrolled": false "scrolled": false
}, },
...@@ -88,7 +90,7 @@ ...@@ -88,7 +90,7 @@
{ {
"data": { "data": {
"application/vnd.jupyter.widget-view+json": { "application/vnd.jupyter.widget-view+json": {
"model_id": "b9941677dffd4fb5a3fb4a16eafde98c" "model_id": "282f85cb7b4848eeb6e0e611b57b9ba3"
} }
}, },
"metadata": {}, "metadata": {},
...@@ -101,32 +103,40 @@ ...@@ -101,32 +103,40 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 26, "execution_count": 6,
"metadata": { "metadata": {
"scrolled": true "scrolled": true
}, },
"outputs": [ "outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"PlasmaCamHorizontal config time: 1.1920928955078125e-06\n",
"FaradayCup config time: 2.384185791015625e-06\n",
"test_device1 config time: 1.1920928955078125e-06\n",
"DelayGenerator config time: 1.1920928955078125e-06\n",
"DRS4 config time: 7.152557373046875e-07\n",
"FocusCamera config time: 9.5367431640625e-07\n",
"ScreenCamera config time: 1.1920928955078125e-06\n",
"Periscope config time: 1.9073486328125e-06\n",
"BladePositioning config time: 9.5367431640625e-07\n",
"Interferometer config time: 7.152557373046875e-07\n",
"Laser config time: 9.5367431640625e-07\n",
"ParabolicMirror config time: 7.152557373046875e-07\n",
"test_device2 config time: 7.152557373046875e-07\n",
"Choose parameter!!!\n",
"Choose parameter!!!\n"
]
},
{ {
"data": { "data": {
"application/vnd.jupyter.widget-view+json": { "application/vnd.jupyter.widget-view+json": {
"model_id": "e9b902c1c44c4839b5598c2ee6ea254f" "model_id": "ea246539d2704e42b3dedd065e00b2ff"
} }
}, },
"metadata": {}, "metadata": {},
"output_type": "display_data" "output_type": "display_data"
},
{
"ename": "AttributeError",
"evalue": "'ParameterChooser' object has no attribute 'parameter'",
"output_type": "error",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mAttributeError\u001b[0m Traceback (most recent call last)",
"\u001b[0;32m/home/data/lwfaserver/Scripts/GUI.py\u001b[0m in \u001b[0;36mscan\u001b[0;34m(self, bt)\u001b[0m\n\u001b[1;32m 424\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 425\u001b[0m \u001b[0;32mdef\u001b[0m \u001b[0mscan\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mbt\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;32mNone\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 426\u001b[0;31m self.measurement_manager.scan(self.scan_configurator.parameters,\n\u001b[0m\u001b[1;32m 427\u001b[0m \u001b[0mn_loop\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mn_loop_int\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mvalue\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 428\u001b[0m \u001b[0mrate\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mrate_float\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mvalue\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;32m/home/data/lwfaserver/Scripts/GUI.py\u001b[0m in \u001b[0;36mparameters\u001b[0;34m(self)\u001b[0m\n\u001b[1;32m 540\u001b[0m \u001b[0;32mdef\u001b[0m \u001b[0mparameters\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[1;32m 541\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 542\u001b[0;31m \u001b[0;32mreturn\u001b[0m \u001b[0;34m[\u001b[0m\u001b[0mpc\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mparameter\u001b[0m \u001b[0;32mfor\u001b[0m \u001b[0mpc\u001b[0m \u001b[0;32min\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mparameter_choosers\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 543\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 544\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;32m/home/data/lwfaserver/Scripts/GUI.py\u001b[0m in \u001b[0;36m<listcomp>\u001b[0;34m(.0)\u001b[0m\n\u001b[1;32m 540\u001b[0m \u001b[0;32mdef\u001b[0m \u001b[0mparameters\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[1;32m 541\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 542\u001b[0;31m \u001b[0;32mreturn\u001b[0m \u001b[0;34m[\u001b[0m\u001b[0mpc\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mparameter\u001b[0m \u001b[0;32mfor\u001b[0m \u001b[0mpc\u001b[0m \u001b[0;32min\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mparameter_choosers\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 543\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 544\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;31mAttributeError\u001b[0m: 'ParameterChooser' object has no attribute 'parameter'"
]
} }
], ],
"source": [ "source": [
...@@ -3011,62 +3021,6 @@ ...@@ -3011,62 +3021,6 @@
"plt.show()" "plt.show()"
] ]
}, },
{
"cell_type": "code",
"execution_count": 98,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": 17,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{'im': array([[0, 0, 1, ..., 1, 1, 1],\n",
" [0, 1, 1, ..., 0, 0, 1],\n",
" [1, 1, 1, ..., 0, 1, 0],\n",
" ..., \n",
" [1, 1, 0, ..., 1, 1, 1],\n",
" [0, 0, 1, ..., 1, 0, 1],\n",
" [1, 1, 1, ..., 0, 0, 1]], dtype=uint8),\n",
" 'time': datetime.datetime(2017, 10, 8, 18, 10, 49, 739764)}"
]
},
"execution_count": 17,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"device_pool['PlasmaCamHorizontal'].measure()"
]
},
{
"cell_type": "code",
"execution_count": 23,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"False"
]
},
"execution_count": 23,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"a = {'b': 1}\n",
"\n",
"'a' in a"
]
},
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": null,
......
...@@ -32,6 +32,7 @@ class Device: ...@@ -32,6 +32,7 @@ class Device:
self.measureable = hasattr(getattr(self.module, self.name), 'measure') self.measureable = hasattr(getattr(self.module, self.name), 'measure')
self.plotable = hasattr(getattr(self.module, self.name), 'plot_measure') self.plotable = hasattr(getattr(self.module, self.name), 'plot_measure')
self.spec_funcs = [name for name in getattr(self.module, self.name).__dict__.keys() if (len(name) > 4) & (name[:4] == 'spec' )]
self.obj = None self.obj = None
@property @property
......
...@@ -146,10 +146,23 @@ class DeviceInterface: ...@@ -146,10 +146,23 @@ class DeviceInterface:
self.bt_make_plot.observe(self.plot_device, names = 'value') self.bt_make_plot.observe(self.plot_device, names = 'value')
self.conmeas += [self.bt_make_plot] self.conmeas += [self.bt_make_plot]
self.spec_func_bts = []
for spec_func in self.device.spec_funcs:
self.spec_func_bts += [widgets.Button(description=spec_func[5:])]
self.spec_func_bts[-1].on_click(self.spec_func_run)
self.widget = widgets.HBox([widgets.VBox(self.conmeas+self.spec_func_bts), self.config_setter])
def spec_func_run(self, bt):
spec_func_name = 'spec_'+bt.description
if self.device.connected:
getattr(self.device.obj, spec_func_name)()
self.widget = widgets.HBox([widgets.VBox(self.conmeas), self.config_setter])
def connect_device(self, bt = None): def connect_device(self, bt = None):
......
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