diff --git a/devices/CurrentCamera.properties b/devices/CurrentCamera.properties index 3ef7a30..7cfc948 100644 --- a/devices/CurrentCamera.properties +++ b/devices/CurrentCamera.properties @@ -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 diff --git a/plugins/ScreenPanel.form b/plugins/ScreenPanel.form index e991e65..3246f7b 100644 --- a/plugins/ScreenPanel.form +++ b/plugins/ScreenPanel.form @@ -62,7 +62,7 @@ - + diff --git a/plugins/ScreenPanel.java b/plugins/ScreenPanel.java index 0f2e6b9..2caaeee 100644 --- a/plugins/ScreenPanel.java +++ b/plugins/ScreenPanel.java @@ -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) { diff --git a/script/Correlation.py b/script/Correlation.py new file mode 100644 index 0000000..494aa7e --- /dev/null +++ b/script/Correlation.py @@ -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) + \ No newline at end of file