This commit is contained in:
2016-09-22 14:42:11 +02:00
parent 9b660c8918
commit 6d1767e2ac
4 changed files with 71 additions and 19 deletions

View File

@@ -1,13 +1,13 @@
#Wed Sep 21 15:08:07 CEST 2016
#Thu Sep 22 09:23:52 CEST 2016
colormap=Grayscale
colormapAutomatic=true
colormapMax=0.0
colormapMin=0.0
flipHorizontally=false
flipVertically=false
flipVertically=true
grayscale=false
imageHeight=1024
imageWidth=1280
imageHeight=1200
imageWidth=1246
invert=false
rescaleFactor=1.0
rescaleOffset=0.0
@@ -18,9 +18,9 @@ roiY=0
rotation=0.0
rotationCrop=true
scale=1.0
spatialCalOffsetX=NaN
spatialCalOffsetY=NaN
spatialCalScaleX=NaN
spatialCalScaleY=NaN
spatialCalOffsetX=-630.0
spatialCalOffsetY=-612.0
spatialCalScaleX=26.761819803746654
spatialCalScaleY=26.595744680851062
spatialCalUnits=mm
transpose=false

View File

@@ -62,7 +62,7 @@
<Group type="102" alignment="1" attributes="0">
<Group type="103" groupAlignment="1" attributes="0">
<Component id="renderer" pref="500" max="32767" attributes="0"/>
<Component id="jPanel7" alignment="1" pref="0" max="32767" attributes="0"/>
<Component id="jPanel7" alignment="1" pref="602" max="32767" attributes="0"/>
<Component id="jPanel6" alignment="1" max="32767" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>

View File

@@ -14,7 +14,7 @@ import ch.psi.utils.IO;
import ch.psi.utils.swing.SwingUtils;
import ch.psi.utils.swing.TextEditor;
import ch.psi.pshell.epics.PsiCamera;
//import ch.psi.pshell.epics.Camtool;
import ch.psi.pshell.epics.Camtool;
import ch.psi.pshell.core.JsonSerializer;
import ch.psi.pshell.device.Device;
import ch.psi.pshell.epics.ArraySource;
@@ -690,7 +690,7 @@ public class ScreenPanel extends Panel {
}
return fit;
}
/*
public class Camtool extends ArraySource {
final String prefix;
@@ -802,14 +802,14 @@ public class ScreenPanel extends Panel {
ex.printStackTrace();
}
/*
if (roiEnabled.read() > 0) {
int[] s = roiShape.read();
//for (int x : s) System.out.println(x);
getConfig().imageHeight = s[3];
getConfig().imageWidth = s[2];
} else {
*/
//if (roiEnabled.read() > 0) {
// int[] s = roiShape.read();
// //for (int x : s) System.out.println(x);
// getConfig().imageHeight = s[3];
// getConfig().imageWidth = s[2];
//} else {
//
int[] s = shape.read();
//for (int x : s){ System.out.println(x);}
getConfig().imageHeight = s[0];
@@ -908,6 +908,7 @@ public class ScreenPanel extends Panel {
}
}
*/
void setHistogramVisible(boolean value) {
if (value) {

51
script/Correlation.py Normal file
View File

@@ -0,0 +1,51 @@
import math
from mathutils import fit_polynomial, PolynomialFunction
from plotutils import plot_line
if get_context().source == CommandSource.ui:
dx = "SINEG01-MSOL130:X"
dy = "SINEG01-MSOL130:Y"
interval = 0.10
window = 20
p = plot(None, "Data")[0]
if isinstance(dx, basestring): dx = Channel(dx)
if isinstance(dy, basestring): dy = Channel(dy)
sd=p.getSeries(0)
#d.setLinesVisible(False)
sd.setPointSize(4)
p.addSeries(LinePlotSeries("Fit Quadratic"))
sfq=p.getSeries(1)
while(True):
#Sample and plot data
x=dx.read()
y=dy.read()
sd.appendData(x, y)
if len(sd.x) > window:
#Remove First Element
sd.token.remove(0)
ax = sd.x
ay = sd.y
if len(ax)>2:
#Calculate, print and plot linear fit
pars_lin = (a0,a1) = fit_polynomial(ay, ax, 1)
print "Fit lin a1:" , a1, " a0:",a0
x1 = min(ax); y1 = poly(x1, pars_lin)
x2 = max(ax); y2 = poly(x2, pars_lin)
plot_line(p, x1, y1, x2, y2, width = 2, color = Color.GREEN, name = "Fit Linear")
#Calculate, print and plot quadratic fit
pars_quad = (a0,a1,a2) = fit_polynomial(ay, ax, 2)
print "Fit quad a2:" , a2, "a1:" , a1, " a0:",a0
fitted_quad_function = PolynomialFunction(pars_quad)
ay=[]
ax = frange(x1, x2, 1 if (x2==x1) else (x2-x1)/100, True)
for x in ax:
ay.append(fitted_polynomial_function.value(x))
sfq.setData(ax, ay)
time.sleep(interval)