Commit 2abfc98f authored by Nick Sauerwein's avatar Nick Sauerwein
Browse files

plot colormap changed, plasmacamera added

parent b733a47d
File mode changed from 100644 to 100755
This diff is collapsed.
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
......@@ -29,6 +29,8 @@ xmax: maximal x in mm
xmin: minimal x in mm
zmax: maximal z in mm
zmin: minimal z in mm
z0: offset of z to fit blade edge
x0: offset of x to fit blade edge
ExposureTimeAbs: exposure time in us
TriggerMode: On/Off
......@@ -62,15 +64,17 @@ class Interferometer:
self.cam.properties['TriggerMode']=config['TriggerMode']
self.xmin, self.xmax, self.zmin, self.zmax = (config['xmin'], config['xmax'],
config['zmin'], config['zmax'])
self.x0, self.z0 = (config['x0'], config['z0'])
self.set_frame(config['xmin'], config['xmax'],
config['zmin'], config['zmax'])
def get_config(self):
config = {}
config['ExposureTimeAbs'] = self.cam.properties['ExposureTimeAbs']
config['TriggerMode'] = self.cam.properties['TriggerMode']
config['xmin'], config['xmax'],config['zmin'], config['zmax']= (self.xmin, self.xmax, self.zmin, self.zmax)
config['x0'], config['z0'] = (self.x0, self.z0)
return config
def measure(self):
import datetime
......@@ -79,10 +83,7 @@ class Interferometer:
D=[]
for img in self.cam.grab_images(2):
D.append(img)
D.append(np.fliplr(img))
measurement = {'time': time,'im1': D[0], 'im2': D[1]}
return measurement
......@@ -93,24 +94,28 @@ class Interferometer:
zmax = config['zmax']
xmin = config['xmin']
xmax = config['xmax']
z0 = config['z0']
x0 = config['x0']
else:
zmin = self.zmin
zmax = self.zmax
xmin = self.xmin
xmax = self.xmax
x0 = self.x0
z0 = self.z0
from PlottingServers import Plot2DServer
if self.plot_server_im == None:
self.plot_server_im = Plot2DServer({'title':'Interferometer Image', 'xlabel':'z [mm]', 'ylabel': 'x [mm]'})
self.plot_server_im = Plot2DServer({'title':'Interferometer Image', 'xlabel':'z [mm]', 'ylabel': 'x [mm]','image': True})
if self.plot_server_ph == None:
self.plot_server_ph = Plot2DServer({'title':'Interferometer Phase', 'xlabel':'z [mm]', 'ylabel': 'x [mm]'})
self.plot_server_ph = Plot2DServer({'title':'Interferometer Phase', 'xlabel':'z [mm]', 'ylabel': 'x [mm]','image': False})
im1 = measurement['im1']
shape = measurement['im1'].shape
self.plot_server_im.update(np.flipud(im1),extent=self.psize*np.array([0.,shape[1], 0., shape[0]]))
self.plot_server_im.update(np.flipud(im1),extent=self.psize*np.array([0.,shape[1], 0., shape[0]])-np.array([z0, z0, x0,x0]))
alpha= self.Alpha(measurement['im1'],measurement['im2'])
......@@ -150,11 +155,11 @@ class Interferometer:
self.cam = cam
def set_frame(self, xmin, xmax, ymin, ymax):
self.x1p=int(1750-xmax/self.psize)
self.x2p=int(1750-xmin/self.psize)
self.y1p=int(ymin/self.psize)
self.y2p=int(ymax/self.psize)
def set_frame(self, xmin, xmax, zmin, zmax):
self.x1p=int(1750-(xmax + self.x0)/self.psize)
self.x2p=int(1750-(xmin+ self.x0)/self.psize)
self.z1p=int((zmin+ self.z0)/self.psize)
self.z2p=int((zmax+ self.z0)/self.psize)
def Alpha(self, D1, D2):
sigmax=5
......@@ -167,7 +172,7 @@ class Interferometer:
Ds2=ndimage.filters.gaussian_filter(np.array(D2,dtype=float), [sigmax, sigmay], mode='nearest', truncate=2)
#calculate phase
alpha=-r.unwrap(Ds1[self.x1p:self.x2p,:],Ds2[self.x1p:self.x2p,:])[:,self.y1p:self.y2p]
alpha=-r.unwrap(Ds1[self.x1p:self.x2p,:],Ds2[self.x1p:self.x2p,:])[:,self.z1p:self.z2p]
return alpha
# -*- coding: utf-8 -*-
"""
Created on Fri Oct 14 10:46:54 2016
@author: hermann_b
"""
import numpy as np
import pypylon
import matplotlib.pyplot as plt
import Devices.InterferometerTools.routines as r
# camera setup
# optical parameters
'''
config file:
y0: y offset in mm
z0: z offset in mm
ExposureTimeAbs: exposure time in us
TriggerMode: On/Off
measurement file:
time: time (datetime object)
im1: first image
im2: second image
'''
class PlasmaCamHorizontal:
#mendatory functions
def __init__(self, config):
self.psize=1./127.95*3/1.70 #mm
self.ep=1.74/self.psize
print ('connecting camera')
self.connect_camera()
print ('done')
self.set_config(config)
self.plot_server_im = None
def set_config(self,config):
self.cam.properties['ExposureTimeAbs']=config['ExposureTimeAbs']
self.cam.properties['TriggerMode']=config['TriggerMode']
self.y0 = config['y0']
self.z0 = config['z0']
def get_config(self):
config = {}
config['ExposureTimeAbs'] = self.cam.properties['ExposureTimeAbs']
config['TriggerMode'] = self.cam.properties['TriggerMode']
config['y0'] = self.y0
config['z0'] = self.z0
return config
def measure(self):
import datetime
time = datetime.datetime.now()
D=[]
for img in self.cam.grab_images(1):
D.append(np.fliplr(img))
measurement = {'time': time,'im1': D[0]}
return measurement
def plot_measure(self, measurement, config = None):
from PlottingServers import Plot2DServer
if self.plot_server_im == None:
self.plot_server_im = Plot2DServer({'title':'PlasmaCamHorizontal', 'xlabel':'z [mm]', 'ylabel': 'y [mm]', 'image': True})
im1 = measurement['im1']
shape = measurement['im1'].shape
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 turn_off(self):
self.cam.close()
#additional function
def connect_camera(self):
available_cameras = pypylon.factory.find_devices()
if len(available_cameras) == 0:
assert 'No cameras found'
print ('available cameras:')
for cam in available_cameras:
print(cam)
for availca in available_cameras:
if str(availca)[-3] == '3':
self.cam_to_connect = availca
cam = pypylon.factory.create_device(availca)
print ('camera found =) Be happy')
try:
cam.open()
except:
assert('camera not found')
#cam.properties['GevSCPSPacketSize']=9014
self.cam = cam
\ No newline at end of file
No preview for this file type
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
No preview for this file type
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
This diff is collapsed.
......@@ -93,7 +93,7 @@ class DataStreamProcess_2D(Process):
def run(self):
plot_server_2d(connecim = self.connecim,connecext = self.connecext, config = self.config)
def plot_server_2d(connecim = None,connecext = None, config = {'xlabel' : '','ylabel' : '', 'title': ''}):
def plot_server_2d(connecim = None,connecext = None, config = {'xlabel' : '','ylabel' : '', 'title': '', 'image': False}):
doc = Document()
doc.title = config['title']
img = np.array([[0,0],[0,0]])
......@@ -105,9 +105,19 @@ def plot_server_2d(connecim = None,connecext = None, config = {'xlabel' : '','yl
p.add_tools(BoxZoomTool(match_aspect = True))
p.plot_height = 400
p.plot_width = 400
from bokeh.palettes import Viridis256
if config['image']:
from bokeh.palettes import Greys256
palette = Greys256
else:
from matplotlib.pyplot import cm
import matplotlib
cmap = cm.get_cmap('seismic', 256)
palette = [matplotlib.colors.rgb2hex(cmap(i)[:3]) for i in range(cmap.N)]
r1 = p.image(image=[np.flipud(img)], x=[0], y=[0],
dw=[img.shape[0]], dh=[img.shape[1]],palette = Viridis256)
dw=[img.shape[0]], dh=[img.shape[1]],palette = palette)
p.xaxis.axis_label = config['xlabel']
p.yaxis.axis_label = config['ylabel']
......@@ -142,7 +152,7 @@ def plot_server_2d(connecim = None,connecext = None, config = {'xlabel' : '','yl
session.loop_until_closed() # run forever
class Plot2DServer:
def __init__(self, config = {'xlabel' : '','ylabel' : '', 'title': ''}):
def __init__(self, config = {'xlabel' : '','ylabel' : '', 'title': '', 'image': False}):
self.connecext_ch, self.connecext_par = Pipe()
self.connecim_ch, self.connecim_par = Pipe()
......
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