Commit 6a07bd76 authored by Nick Sauerwein's avatar Nick Sauerwein
Browse files

before change from multiprocessing to threading in measurement

parent 75c2d3ab
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -18,23 +18,28 @@ pos_L: radius of blade set by linear stage [mm]
measurement file (n.a)
'''
default_config = {'pos_R': 329, 'pos_L':-1.6}
class BladePositioning:
def __init__(self, config, init = 1):
if init:
s.init()
self.set_config(config)
self.config = config
@property
def config(self):
config = {}
config['pos_R'] = s.getposR()
config['pos_L'] = s.getposL() - cor(s.getposR())
return config
@config.setter
def set_config(self, config):
s.maaR(config['pos_R'])
s.mpaL(config['pos_L']+cor(s.getposR()))
print ('cor: ', cor(s.getposR()))
def get_config(self):
config = {}
config['pos_R'] = s.getposR()
config['pos_L'] = s.getposL() - cor(s.getposR())
return config
# -*- coding: utf-8 -*-
"""
Created on Sat Feb 25 17:33:30 2017
@author: nicks
"""
from instruments.srs import SRSDG645
import quantities as pq
'''
config file:
jet_triggered: boolean, true if jet opens on fire
mode: 'one shot' or 'continuous'
rate: float, maximal possible rate (single shot) or rate of trigger (continuous)
t_sleep: time that the program sleeps until measurement finished
measurement file (n.a)
'''
class CameraDelay:
def __init__(self, config):
self.ddg = SRSDG645.open_tcpip('172.21.11.124',5025)
self.ddg.trigger_source = 3
self.jet = self.ddg.Output(self.ddg,3)
self.set_config(config)
def get_config(self):
config = {}
config['mode'] = self.getMode()
config['jet_triggered'] = self.getJet()
config['rate'] = self.getRate()
config['t_sleep'] = self.t_sleep
return config
def set_config(self, config):
self.setMode(config['mode'])
self.setJet(config['jet_triggered'])
self.setRate(config['rate'])
self.t_sleep = config['t_sleep']
def setMode(self, mode):
if mode == 'single shot':
self.ddg.trigger_source = 3
return
if mode == 'continuous':
self.ddg.trigger_source = 1
return
print ('mode: '+mode+' unknown')
raise
def getMode(self):
mode = {3: 'single shot', 1: 'continuous'}
return mode[self.ddg.trigger_source]
def setRate(self, rate):
self.ddg.holdoff = pq.sec*1/rate - pq.sec*1e-3
def getRate(self):
return 1/float(self.ddg.holdoff)
def singleMode(self):
self.ddg.trigger_source = 3
def setJet(self, On):
if On:
self.jet.level_amplitude = pq.volt*5
else:
self.jet.level_amplitude = pq.volt*0.51
def getJet(self):
if self.jet.level_amplitude == pq.volt*5:
return True
else:
return False
def measure(self):
import datetime
import time
from threading import Thread
def trigger():
time.sleep(self.t_sleep)
self.ddg.trigger()
t1 = Thread(target = trigger)
t1.start()
time = str(datetime.datetime.now()).replace(':','-').replace(' ','_')
measurement = {'time': time}
return measurement
from epics import PV, caput, caget
import time
import socket
Channels_Sign = {0 :'A', 1:'B', 2:'C', 3:'D', 4:'E', 5:'F', 6:'G', 7:'H',
8:'I', 9:'J', 10: 'L', 11:'M', 12:'N', 13:'O', 14:'P', 15:'Q'}
......@@ -16,19 +17,19 @@ delay: time to wait before trigger send
measure file: (measurements of channels are part of devices, i.e. FaradayCup, Laser)
time: time of tigger send
'''
import socket
default_config = {'trigger_level_CH0': 100,
'trigger_mode':2,
'delay': 0.0}
class DRS4:
def __init__(self, config):
caput('FIN-LSCP-DRS1:FLAG_GAIN',1)
self.set_config(config)
self.config = config
def set_config(self, config):
self.setTriggerMode(config['trigger_mode'])
self.setTriggerLevel( 0, config['trigger_level_CH0'])
self.delay = config['delay']
def get_config(self):
@property
def config(self):
config = {}
config['trigger_mode'] = self.getTriggerMode()
config['trigger_level_CH0'] = self.getTriggerLevel(0)
......@@ -36,6 +37,12 @@ class DRS4:
return config
@config.setter
def config(self, config):
self.setTriggerMode(config['trigger_mode'])
self.setTriggerLevel( 0, config['trigger_level_CH0'])
self.delay = config['delay']
def VoltageCalibration(self):
caput('FIN-LSCP-DRS1:START_GAIN_CAL.PROC',1)
......
......@@ -17,7 +17,10 @@ t_sleep: time that the program sleeps until measurement finished
measurement file (n.a)
'''
default_config = {'jet_triggered': True,
'mode': 'single shot',
'rate': 10.,
't_sleep': 0.05}
class DelayGenerator:
def __init__(self, config):
......@@ -25,8 +28,15 @@ class DelayGenerator:
self.ddg.trigger_source = 3
self.jet = self.ddg.Output(self.ddg,3)
self.set_config(config)
self.config = config
@property
def config(self, config):
self.setMode(config['mode'])
self.setJet(config['jet_triggered'])
self.setRate(config['rate'])
self.t_sleep = config['t_sleep']
@config.setter
def get_config(self):
config = {}
config['mode'] = self.getMode()
......@@ -35,11 +45,7 @@ class DelayGenerator:
config['t_sleep'] = self.t_sleep
return config
def set_config(self, config):
self.setMode(config['mode'])
self.setJet(config['jet_triggered'])
self.setRate(config['rate'])
self.t_sleep = config['t_sleep']
def setMode(self, mode):
if mode == 'single shot':
......
import numpy as np
import matplotlib.pyplot as plt
from Scripts.PlottingServers import Plot1DServer
'''
config file:
channel: channel on DRS4 where Cup is connected to
......@@ -16,24 +18,33 @@ peak_uvolt: negative peak voltage [uV]
charge: charge [fC]
'''
default_config = {'channel':2,
'R': 50.,
'amplification': 316}
class FaradayCup:
#mendatory functions
def __init__(self, config, DRS4):
self.drs = DRS4
self.set_config(config)
self.config = config
self.plot_server = None
def set_config(self,config):
self.channel = config['channel']
self.R = config['R']
self.amplification = config['amplification']
def get_config(self):
@property
def config(self):
config = {}
config['channel'] = self.channel
config['amplification'] = self.amplification
config['R'] = self.R
return config
@config.setter
def config(self,config):
self.channel = config['channel']
self.R = config['R']
self.amplification = config['amplification']
def measure(self):
import time as ttime
......@@ -47,9 +58,6 @@ class FaradayCup:
return measurement
def plot_measure(self, measurement, config = None):
from PlottingServers import Plot1DServer
if self.plot_server == None:
self.plot_server = Plot1DServer({'title':'FaradayCup', 'xlabel':'Time [ns]', 'ylabel': 'Signal [uV]'})
......
......@@ -6,7 +6,8 @@ import matplotlib.pyplot as plt
import numpy as np
from Devices.CameraTools import binArray
from Devices.CameraTools.binning import binArray
from Scripts.PlottingServers import Plot2DServer
'''
config file:
......@@ -25,6 +26,11 @@ cymm: y coordinate of contour [mm]
maxit: maximal intensity [0 - 4096]
'''
default_config = {'ExposureTimeAbs': 10000,
'camera_serial_number':22005848,
'min_intensity': 2000,
'measure_full' : True}
class FocusCamera:
......@@ -37,10 +43,19 @@ class FocusCamera:
self.connect_camera()
self.set_config(config)
self.config = config
self.plot_server_im = None
@property
def config(self):
config = {}
config['ExposureTimeAbs'] = self.cam.properties['ExposureTimeAbs']
config['min_intensity'] = self.min_intensity
config['measure_full'] = self.measure_full
return config
@config.setter
def set_config(self,config):
self.min_intensity = config['min_intensity']
......@@ -48,12 +63,7 @@ class FocusCamera:
self.min_intensity = config['min_intensity']
self.measure_full = config['measure_full']
def get_config(self):
config = {}
config['ExposureTimeAbs'] = self.cam.properties['ExposureTimeAbs']
config['min_intensity'] = self.min_intensity
config['measure_full'] = self.measure_full
return config
def measure(self):
import datetime
......@@ -84,8 +94,6 @@ class FocusCamera:
def plot_measure(self, measurement, config = None):
from PlottingServers import Plot2DServer
if self.plot_server_im == None:
self.plot_server_im = Plot2DServer({'title':'FocusCamera', 'xlabel':'y [um]', 'ylabel': 'x [um]', 'image': True})
......@@ -118,12 +126,9 @@ class FocusCamera:
#autobinning
n_binning = math.ceil(((xmaxum - xminum)/self.psize)/500)
print (n_binning)
im = binArray(im, 0, n_binning, n_binning, np.mean)
im = binArray(im, 1, n_binning, n_binning, np.mean)
print ('bla')
self.plot_server_im.update(np.flipud(im),extent=(yminum,ymaxum, yminum, ymaxum))
......
......@@ -10,7 +10,9 @@ import pypylon
import matplotlib.pyplot as plt
import Devices.InterferometerTools.routines as r
from Devices.CameraTools import binArray
from Devices.CameraTools.binning import binArray
from Scripts.PlottingServers import Plot2DServer
import time as t
# camera setup
......@@ -49,6 +51,27 @@ time: time (datetime object)
im1: first image
im2: second image
'''
default_config = inter_config = {'xmax':4.,
'xmin':0.,
'zmin':-7.,
'zmax':7.,
'x0': 4.,
'z0': 10.5,
'ExposureTimeAbs':35,
'BitsOfImage':12,
'TriggerMode':False,
'binning':10,
'Tomography':False,
'num_av': 9,
'num_dir': 2,
'take_data': True,
'Ly': 11.,
'x_tomo': 0.4,
'shift':209,
'y_calib': 1.,
'live_preview':True}
mode = {False: 'Off', True: 'On'}
modei = {'Off': False, 'On': True}
......@@ -69,7 +92,7 @@ class Interferometer:
self.connect_camera()
print ('done')
self.set_config(config)
self.config = config
self.blade = blade
self.delay = delay
......@@ -77,8 +100,31 @@ class Interferometer:
self.plot_server_im = None
self.plot_server_ph = None
self.plot_server_tomo = None
@property
def config(self):
config = {}
config['ExposureTimeAbs'] = self.cam.properties['ExposureTimeAbs']
config['TriggerMode'] = modei[self.cam.properties['TriggerMode']]
config['BitsOfImage'] = int(self.cam.properties['PixelFormat'][4:])
config['binning'] = self.n_binning
def set_config(self,config):
config['xmin'], config['xmax'],config['zmin'], config['zmax']= (self.xmin, self.xmax, self.zmin, self.zmax)
config['x0'], config['z0'] = (self.x0, self.z0)
config['Tomography'] = self.Tomography
config['num_dir'] = self.num_dir
config['num_av'] = self.num_av
config['take_data'] = self.take_data
config['Ly'] = self.Ly
config['x_tomo'] = self.x_tomo
config['shift'] = self.shift
config['live_preview'] = self.live_preview
config['y_calib'] = self.y_calib
return config
@config.setter
def config(self,config):
self.take_data = config['take_data']
self.cam.properties['PixelFormat'] = 'Mono'+str(config['BitsOfImage'])
self.cam.properties['ExposureTimeAbs']=config['ExposureTimeAbs']
......@@ -102,27 +148,6 @@ class Interferometer:
self.live_preview = config['live_preview']
self.y_calib = config['y_calib']
def get_config(self):
config = {}
config['ExposureTimeAbs'] = self.cam.properties['ExposureTimeAbs']
config['TriggerMode'] = modei[self.cam.properties['TriggerMode']]
config['BitsOfImage'] = int(self.cam.properties['PixelFormat'][4:])
config['binning'] = self.n_binning
config['xmin'], config['xmax'],config['zmin'], config['zmax']= (self.xmin, self.xmax, self.zmin, self.zmax)
config['x0'], config['z0'] = (self.x0, self.z0)
config['Tomography'] = self.Tomography
config['num_dir'] = self.num_dir
config['num_av'] = self.num_av
config['take_data'] = self.take_data
config['Ly'] = self.Ly
config['x_tomo'] = self.x_tomo
config['shift'] = self.shift
config['live_preview'] = self.live_preview
config['y_calib'] = self.y_calib
return config
def measure(self):
import datetime
......@@ -141,8 +166,6 @@ class Interferometer:
return measurement
else:
from PlottingServers import Plot2DServer
if self.plot_server_tomo == None:
self.plot_server_tomo = Plot2DServer({'title':'Tomography live', 'xlabel':'z [mm]', 'ylabel': 'x [mm]','image': True})
......
import numpy as np
from epics import PV, caput, caget
from Scripts.PlottingServers import Plot1DServer
'''
config file:
max_angle: position of rotation stage where energy is maximal [deg]
......@@ -15,28 +18,34 @@ intensity: peak of signal on photodiode (mV)
'''
default_config = {'max_angle': -22.9,
'attenuation': 100,
'comp_lin': 38.020,
'channel': 1}
class Laser:
def __init__(self, config, DRS4):
self.old_comp_lin = 0
self.drs = DRS4
self.set_config(config)
self.config = config
self.plot_server = None
def set_config(self, config):
self.max_angle = config['max_angle']
self.set_attenuation(config['attenuation'])
self.set_lin_comp(config['comp_lin'])
self.channel = config['channel']
def get_config(self):
@property
def config(self):
config = {}
config['max_angle'] = self.max_angle
config['attenuation'] = self.get_attenuation()
config['comp_lin'] = self.get_lin_comp()
config['channel'] = self.channel
return config
return config
@config.setter
def config(self, config):
self.max_angle = config['max_angle']
self.set_attenuation(config['attenuation'])
self.set_lin_comp(config['comp_lin'])
self.channel = config['channel']
def set_attenuation(self, percent):
......@@ -70,8 +79,7 @@ class Laser:
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]'})
......
......@@ -14,6 +14,9 @@ pos_Paz: current position of motor Paz
measurement file (n.a)
'''
default_config = {'pos_Pay': 3.99396444,
'pos_Paz': 5.16051188}
class ParabolicMirror:
def __init__(self, config, home = False):
import time
......@@ -28,19 +31,22 @@ class ParabolicMirror:
if home:
self.home()
self.set_config(config)
def set_config(self,config):
self.Pay.goto(config['pos_Pay'])
self.Paz.goto(config['pos_Paz'])
def get_config(self):
self.config = config
@property
def config(self):
config = {}
config['pos_Pay'] = float(self.Pay.position())
config['pos_Paz'] = float(self.Paz.position())
return config
@config.setter
def config(self,config):
self.Pay.goto(config['pos_Pay'])
self.Paz.goto(config['pos_Paz'])
def connect_motors(self):
......
......@@ -26,6 +26,16 @@ sync_camera: boolean
measurement file (n.a)
'''
default_config = {'pos_l_x': 0.1,
'pos_l_y': 0.1,
'pos_l_z': 0.1,
'pos_g_origin_x': -25./2,
'pos_g_origin_y': 25./2,
'pos_g_origin_z': 25./2,
'deltaz_Mz': 0,
'deltaz_Cz': 0,
'sync_camera': False}
class Periscope:
def __init__(self, config, home = False):
import time
......@@ -39,10 +49,30 @@ class Periscope:
if home:
self.home()
self.set_config(config)
self.config = config
@property
def config(self):
config = {}
pos_g = self.get_position()
config['pos_g_origin_x'] = float(self.pos_local_origin_g[0])