Closedown
This commit is contained in:
+23
-4
@@ -18,22 +18,32 @@
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" attributes="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Component id="jPanel1" alignment="0" min="-2" max="-2" attributes="0"/>
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<Group type="102" attributes="0">
|
||||
<EmptySpace min="-2" pref="42" max="-2" attributes="0"/>
|
||||
<Component id="buttonStart" min="-2" pref="102" max="-2" attributes="0"/>
|
||||
<EmptySpace min="-2" pref="39" max="-2" attributes="0"/>
|
||||
<Component id="buttonAbort" min="-2" pref="102" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<Component id="jPanel1" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace min="-2" pref="77" max="-2" attributes="0"/>
|
||||
<Component id="panelImageCounter" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
<EmptySpace pref="216" max="32767" attributes="0"/>
|
||||
<EmptySpace pref="26" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
<DimensionLayout dim="1">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<Component id="jPanel1" min="-2" max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Component id="jPanel1" min="-2" max="-2" attributes="0"/>
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="panelImageCounter" min="-2" pref="74" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
<EmptySpace pref="74" max="32767" attributes="0"/>
|
||||
<Group type="103" groupAlignment="3" attributes="0">
|
||||
<Component id="buttonStart" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
@@ -228,5 +238,14 @@
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="buttonAbortActionPerformed"/>
|
||||
</Events>
|
||||
</Component>
|
||||
<Component class="ch.psi.pshell.swing.DeviceValuePanel" name="panelImageCounter">
|
||||
<Properties>
|
||||
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
|
||||
<Border info="org.netbeans.modules.form.compat2.border.TitledBorderInfo">
|
||||
<TitledBorder title="Image Counter"/>
|
||||
</Border>
|
||||
</Property>
|
||||
</Properties>
|
||||
</Component>
|
||||
</SubComponents>
|
||||
</Form>
|
||||
|
||||
+20
-5
@@ -2,6 +2,7 @@
|
||||
* Copyright (c) 2014-2017 Paul Scherrer Institute. All rights reserved.
|
||||
*/
|
||||
|
||||
import ch.psi.pshell.epics.AreaDetector;
|
||||
import ch.psi.pshell.ui.Panel;
|
||||
import ch.psi.utils.State;
|
||||
import java.util.HashMap;
|
||||
@@ -20,7 +21,7 @@ public class Omega extends Panel {
|
||||
//Overridable callbacks
|
||||
@Override
|
||||
public void onInitialize(int runCount) {
|
||||
|
||||
panelImageCounter.setDevice(((AreaDetector)getDevice("det")).getImageCounter());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -58,6 +59,7 @@ public class Omega extends Panel {
|
||||
jLabel4 = new javax.swing.JLabel();
|
||||
buttonStart = new javax.swing.JButton();
|
||||
buttonAbort = new javax.swing.JButton();
|
||||
panelImageCounter = new ch.psi.pshell.swing.DeviceValuePanel();
|
||||
|
||||
jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder("Parameters"));
|
||||
|
||||
@@ -173,24 +175,33 @@ public class Omega extends Panel {
|
||||
}
|
||||
});
|
||||
|
||||
panelImageCounter.setBorder(javax.swing.BorderFactory.createTitledBorder("Image Counter"));
|
||||
|
||||
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
|
||||
this.setLayout(layout);
|
||||
layout.setHorizontalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addGap(42, 42, 42)
|
||||
.addComponent(buttonStart, javax.swing.GroupLayout.PREFERRED_SIZE, 102, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addGap(39, 39, 39)
|
||||
.addComponent(buttonAbort, javax.swing.GroupLayout.PREFERRED_SIZE, 102, javax.swing.GroupLayout.PREFERRED_SIZE)))
|
||||
.addContainerGap(216, Short.MAX_VALUE))
|
||||
.addComponent(buttonAbort, javax.swing.GroupLayout.PREFERRED_SIZE, 102, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addGap(77, 77, 77)
|
||||
.addComponent(panelImageCounter, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
|
||||
.addContainerGap(26, Short.MAX_VALUE))
|
||||
);
|
||||
layout.setVerticalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addComponent(panelImageCounter, javax.swing.GroupLayout.PREFERRED_SIZE, 74, javax.swing.GroupLayout.PREFERRED_SIZE)))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 74, Short.MAX_VALUE)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(buttonStart)
|
||||
@@ -209,6 +220,9 @@ public class Omega extends Panel {
|
||||
|
||||
private void buttonStartActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonStartActionPerformed
|
||||
try {
|
||||
if ((Double)spinnerEnd.getValue() <= (Double)spinnerStart.getValue()){
|
||||
throw new Exception ("Invalid range");
|
||||
}
|
||||
HashMap<String, Object> pars = new HashMap<>();
|
||||
pars.put("startphi", spinnerStart.getValue());
|
||||
pars.put("endphi", spinnerEnd.getValue());
|
||||
@@ -232,6 +246,7 @@ public class Omega extends Panel {
|
||||
private javax.swing.JLabel jLabel5;
|
||||
private javax.swing.JLabel jLabel6;
|
||||
private javax.swing.JPanel jPanel1;
|
||||
private ch.psi.pshell.swing.DeviceValuePanel panelImageCounter;
|
||||
private javax.swing.JSpinner spinnerEnd;
|
||||
private javax.swing.JSpinner spinnerPasses;
|
||||
private javax.swing.JSpinner spinnerStart;
|
||||
|
||||
@@ -2,21 +2,23 @@ import mathutils
|
||||
import plotutils
|
||||
|
||||
|
||||
#ascan([scx, scy], [scd,], [scx.minValue,scy.minValue], [scx.maxValue,scy.maxValue], [0.1, 0.1], latency = 0.0, relative = False, zigzag = True)
|
||||
#A area scan (2d) on x & y
|
||||
ascan([scx, scy], [scd,], [scx.minValue,scy.minValue], [scx.maxValue,scy.maxValue], [0.1, 0.1], latency = 0.0, relative = False, zigzag = True)
|
||||
|
||||
|
||||
|
||||
# A line scn (1d) on Y
|
||||
scy.move(0.0)
|
||||
#r = lscan(scx, scd, scx.minValue, scx.maxValue, 0.1, latency = 0.0)
|
||||
xdata = r.getPositions(0)
|
||||
ydata = r.getReadable(0)
|
||||
|
||||
maxy=max(ydata)
|
||||
maxx=ydata.indexOf(maxy)
|
||||
print "maxx =" , maxx
|
||||
print "maxy =" , maxy
|
||||
|
||||
#Fitting a gaussian
|
||||
|
||||
#Fitting a gaussian on the 1d scan
|
||||
(normalization, mean_val, sigma) = mathutils.fit_gaussian(ydata, xdata)
|
||||
print "fit mean = ", mean_val
|
||||
#Plotting the gaussian
|
||||
@@ -24,8 +26,8 @@ gaussian = mathutils.Gaussian(normalization, mean_val, sigma)
|
||||
plotutils.plot_function(get_plots(None)[0], gaussian, "Fit", frange(scx.minValue, scx.maxValue, 0.01))
|
||||
|
||||
|
||||
|
||||
|
||||
#Binary search for maximum
|
||||
r = bsearch([scx, scy], scd, [scx.minValue,scy.minValue], [scx.maxValue,scy.maxValue], [0.01, 0.01], maximum=True, strategy = "FullNeighborhood", latency = 0.01, title = "Binary Search")
|
||||
|
||||
#Hill-climbing search for maximum
|
||||
r = hsearch([scx, scy], scd, [scx.minValue,scy.minValue], [scx.maxValue,scy.maxValue], [0.2, 0.2], [0.01, 0.01], noise_filtering_steps = 3, relative = False, maximum=True, latency = 0.01, title = "Hill Climbing")
|
||||
|
||||
Reference in New Issue
Block a user