diff --git a/config/AbsortionSpectrum/Ni_L23_fine.abs b/config/AbsortionSpectrum/Ni_L23_fine.abs new file mode 100644 index 0000000..a76aa9c Binary files /dev/null and b/config/AbsortionSpectrum/Ni_L23_fine.abs differ diff --git a/config/AbsortionSpectrum/Ni_L3_fine.abs b/config/AbsortionSpectrum/Ni_L3_fine.abs new file mode 100644 index 0000000..e4ed733 Binary files /dev/null and b/config/AbsortionSpectrum/Ni_L3_fine.abs differ diff --git a/config/ROIs/6-8_01.roi b/config/ROIs/6-8_01.roi new file mode 100644 index 0000000..f6a96fa Binary files /dev/null and b/config/ROIs/6-8_01.roi differ diff --git a/config/ROIs/test.roi b/config/ROIs/test.roi index ad826d3..a465f57 100755 Binary files a/config/ROIs/test.roi and b/config/ROIs/test.roi differ diff --git a/config/devices.properties b/config/devices.properties index db8e722..9a1a34a 100755 --- a/config/devices.properties +++ b/config/devices.properties @@ -75,5 +75,6 @@ CADC3=ch.psi.pshell.epics.ChannelDouble|X11MA-ES1:CADC3|Read||true #CADC5=ch.psi.pshell.epics.ChannelDouble|X11MA-ES1:CADC5|Read||true #CADC6=ch.psi.pshell.epics.ChannelDouble|X11MA-ES1:CADC6|Read||true #CADC7=ch.psi.pshell.epics.ChannelDouble|X11MA-ES1:CADC7|Read||true +girder_x=ch.psi.pshell.epics.Positioner|X11MA-HG:X_SET X11MA-HG:X1|||true image=ch.psi.pshell.imaging.CameraSource|eiger|||true axis=ch.psi.pshell.imaging.MjpegSource|http://axis-x11ma.psi.ch/axis-cgi/mjpg/video.cgi?id=176 true||-200|false diff --git a/config/session_metadata.properties b/config/session_metadata.properties index 1b84427..76377f8 100755 --- a/config/session_metadata.properties +++ b/config/session_metadata.properties @@ -1,5 +1,5 @@ -#Mon Apr 26 10:07:44 CEST 2021 +#Fri Apr 30 17:00:58 CEST 2021 keywords=List;[] -ownerEmail=String;moritz.bigalke@giub.unibe.ch -contactEmail=String;carlos.vaz@psi.ch +ownerEmail=String;jgpark10@snu.ac.kr +contactEmail=String;armin.kleibert@psi.ch owner=String;Erik Folven diff --git a/config/sessions.properties b/config/sessions.properties index 3870215..73eaa2e 100755 --- a/config/sessions.properties +++ b/config/sessions.properties @@ -1,2 +1,2 @@ -#Tue Apr 27 09:06:10 CEST 2021 -SessionCounter=19 +#Tue May 04 08:05:11 CEST 2021 +SessionCounter=20 diff --git a/config/settings.properties b/config/settings.properties index 81c2a53..83a28da 100755 --- a/config/settings.properties +++ b/config/settings.properties @@ -1,23 +1,23 @@ -#Tue Apr 27 09:07:34 CEST 2021 +#Tue May 04 16:48:06 CEST 2021 HARMONIC_ID_1=1 RSYNC_USER= OUTLIERS_THRESHOLD=1000000000 NORM_FILE=/sls/X11MA/data/X11MA/Data1/2021/Yona250121/s250121 -AUTO_SWITCH_VALVE=false +AUTO_SWITCH_VALVE=true DRY_RUN=false -POL_ID_2=Lin_Hor +POL_ID_2=Lin_Ver OFFSET_ID_1=0.0 -ID=ID2 +ID=ID1_ID2 OFFSET_ID_2=-1.1 proposal=proposal -ENERGY=800.0 +ENERGY=852.5 proposer=proposer POL_ID_1=Lin_Hor RSYNC_HOST= sample=sample RSYNC_PATH= pgroup=pgroup -ALPHA_ID_2=45.0 +ALPHA_ID_2=0.0 ALPHA_ID_1=15.0 RSYNC_DEL=true AVERAGING_DETECTOR=true diff --git a/config/variables.properties b/config/variables.properties index 4aab92a..7159ee6 100755 --- a/config/variables.properties +++ b/config/variables.properties @@ -1,4 +1,4 @@ -#Tue Apr 27 10:43:38 CEST 2021 -LastRunDate=210427 -FileSequentialNumber=7047 -DaySequentialNumber=5 +#Wed May 05 17:03:21 CEST 2021 +LastRunDate=210505 +FileSequentialNumber=7364 +DaySequentialNumber=76 diff --git a/devices/girder_x.properties b/devices/girder_x.properties new file mode 100644 index 0000000..626fd2d --- /dev/null +++ b/devices/girder_x.properties @@ -0,0 +1,10 @@ +#Wed May 05 15:14:33 CEST 2021 +offset=0.0 +maxValue=3.0 +rotation=false +precision=3 +scale=1.0 +resolution=0.005 +minValue=2.0 +unit=mm +sign_bit=0 diff --git a/devices/image.properties b/devices/image.properties index fd76383..9ff5fc4 100755 --- a/devices/image.properties +++ b/devices/image.properties @@ -1,4 +1,4 @@ -#Mon Apr 26 13:48:18 CEST 2021 +#Wed May 05 09:55:16 CEST 2021 spatialCalOffsetY=NaN spatialCalOffsetX=NaN colormapLogarithmic=false @@ -6,7 +6,7 @@ scale=1.0 grayscale=false spatialCalScaleX=NaN spatialCalScaleY=NaN -colormapMax=900.0 +colormapMax=81.992 rescaleOffset=0.0 roiWidth=-1 colormap=Grayscale diff --git a/devices/obj_stig_a.properties b/devices/obj_stig_a.properties new file mode 100644 index 0000000..415fed3 --- /dev/null +++ b/devices/obj_stig_a.properties @@ -0,0 +1,10 @@ +#Wed May 05 11:46:59 CEST 2021 +offset=0.0 +maxValue=100.0 +rotation=false +precision=3 +scale=1.0 +resolution=0.5 +minValue=-100.0 +unit=mA +sign_bit=0 diff --git a/devices/obj_stig_b.properties b/devices/obj_stig_b.properties new file mode 100644 index 0000000..7143588 --- /dev/null +++ b/devices/obj_stig_b.properties @@ -0,0 +1,10 @@ +#Wed May 05 11:47:00 CEST 2021 +offset=0.0 +maxValue=100.0 +rotation=false +precision=3 +scale=1.0 +resolution=0.5 +minValue=-100.0 +unit=mA +sign_bit=0 diff --git a/devices/objective.properties b/devices/objective.properties new file mode 100644 index 0000000..903dfce --- /dev/null +++ b/devices/objective.properties @@ -0,0 +1,10 @@ +#Wed May 05 11:45:21 CEST 2021 +offset=0.0 +maxValue=1570.0 +rotation=false +precision=2 +scale=1.0 +resolution=0.05 +minValue=1350.0 +unit=mA +sign_bit=0 diff --git a/plugins/DataAcquisition.form b/plugins/DataAcquisition.form index 489eb52..9b229ef 100755 --- a/plugins/DataAcquisition.form +++ b/plugins/DataAcquisition.form @@ -1503,18 +1503,20 @@ - + - + + + + + + + + + + - - - - - - - @@ -1544,32 +1546,42 @@ - + - + + + + + + - - + + + + + + + + + + + + + + + + + - - + + - - - - - - - - - - @@ -1590,7 +1602,12 @@ - + + + + + + @@ -1657,6 +1674,19 @@ + + + + + + + + + + + + + diff --git a/plugins/DataAcquisition.java b/plugins/DataAcquisition.java index 1cdef8b..f91be15 100755 --- a/plugins/DataAcquisition.java +++ b/plugins/DataAcquisition.java @@ -261,6 +261,8 @@ public class DataAcquisition extends Panel { model.setValueAt(rois.get(i).getWidth(), i, 3); model.setValueAt(rois.get(i).getHeight(), i, 4); } + Map> roi_dict = getRois(); + setGlobalVar("DAQ_PANEL_ROIS", roi_dict); } void addRoi(Rect roi) { @@ -438,6 +440,7 @@ public class DataAcquisition extends Panel { String folder = getContext().getSetup().expandPath("{year}_{month}/{date}"); args.put("FOLDER", folder); args.put("ROI", getRois()); + args.put("EXPOSURE", spinnerImgOTFExp.getValue()); args.put("SAVE_IMAGES", checkImgOTFSaveImages.isSelected()); buttonImgOTFAbort.setEnabled(true); @@ -582,6 +585,8 @@ public class DataAcquisition extends Panel { jLabel5 = new javax.swing.JLabel(); spinnerDelay = new javax.swing.JSpinner(); checkImgOTFSaveImages = new javax.swing.JCheckBox(); + jLabel27 = new javax.swing.JLabel(); + spinnerImgOTFExp = new javax.swing.JSpinner(); buttonImgOTFStart = new javax.swing.JButton(); buttonImgOTFAbort = new javax.swing.JButton(); @@ -1575,6 +1580,11 @@ public class DataAcquisition extends Panel { checkImgOTFSaveImages.setText("Save images"); + jLabel27.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING); + jLabel27.setText("Exposure(s):"); + + spinnerImgOTFExp.setModel(new javax.swing.SpinnerNumberModel(0.2d, 0.0d, 3600.0d, 1.0d)); + javax.swing.GroupLayout panelParametersLayout = new javax.swing.GroupLayout(panelParameters); panelParameters.setLayout(panelParametersLayout); panelParametersLayout.setHorizontalGroup( @@ -1582,27 +1592,34 @@ public class DataAcquisition extends Panel { .addGroup(panelParametersLayout.createSequentialGroup() .addContainerGap() .addGroup(panelParametersLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) - .addComponent(checkImgOTFSaveImages) + .addGroup(panelParametersLayout.createSequentialGroup() + .addGap(0, 0, Short.MAX_VALUE) + .addComponent(jLabel27) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(spinnerImgOTFExp, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGroup(panelParametersLayout.createSequentialGroup() .addGroup(panelParametersLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) - .addComponent(jLabel3) - .addComponent(jLabel1)) + .addComponent(checkImgOTFSaveImages) + .addGroup(panelParametersLayout.createSequentialGroup() + .addGroup(panelParametersLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) + .addComponent(jLabel3) + .addComponent(jLabel1)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(panelParametersLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(spinnerE1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(spinnerTime, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 175, Short.MAX_VALUE) + .addGroup(panelParametersLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jLabel5, javax.swing.GroupLayout.Alignment.TRAILING) + .addComponent(jLabel2, javax.swing.GroupLayout.Alignment.TRAILING)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(panelParametersLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(spinnerE1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) - .addComponent(spinnerTime, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 175, Short.MAX_VALUE) - .addGroup(panelParametersLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(jLabel5, javax.swing.GroupLayout.Alignment.TRAILING) - .addComponent(jLabel2, javax.swing.GroupLayout.Alignment.TRAILING)) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addGroup(panelParametersLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(spinnerE2, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) - .addComponent(spinnerDelay, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addComponent(spinnerE2, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(spinnerDelay, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))) .addContainerGap(151, Short.MAX_VALUE)) ); - panelParametersLayout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {spinnerDelay, spinnerE1, spinnerE2, spinnerTime}); + panelParametersLayout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {spinnerDelay, spinnerE1, spinnerE2, spinnerImgOTFExp, spinnerTime}); panelParametersLayout.setVerticalGroup( panelParametersLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) @@ -1618,7 +1635,11 @@ public class DataAcquisition extends Panel { .addComponent(spinnerTime, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel5) .addComponent(spinnerDelay, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 119, Short.MAX_VALUE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(panelParametersLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel27) + .addComponent(spinnerImgOTFExp, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 87, Short.MAX_VALUE) .addComponent(checkImgOTFSaveImages) .addContainerGap()) ); @@ -1642,16 +1663,17 @@ public class DataAcquisition extends Panel { jPanel7.setLayout(jPanel7Layout); jPanel7Layout.setHorizontalGroup( jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel7Layout.createSequentialGroup() + .addGroup(jPanel7Layout.createSequentialGroup() .addContainerGap() - .addComponent(panelParameters, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(panelParameters, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel7Layout.createSequentialGroup() + .addGap(0, 0, Short.MAX_VALUE) + .addComponent(buttonImgOTFStart) + .addGap(64, 64, 64) + .addComponent(buttonImgOTFAbort) + .addGap(0, 0, Short.MAX_VALUE))) .addContainerGap()) - .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel7Layout.createSequentialGroup() - .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addComponent(buttonImgOTFStart) - .addGap(64, 64, 64) - .addComponent(buttonImgOTFAbort) - .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) ); jPanel7Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {buttonImgOTFAbort, buttonImgOTFStart}); @@ -2007,6 +2029,7 @@ public class DataAcquisition extends Panel { private javax.swing.JLabel jLabel24; private javax.swing.JLabel jLabel25; private javax.swing.JLabel jLabel26; + private javax.swing.JLabel jLabel27; private javax.swing.JLabel jLabel29; private javax.swing.JLabel jLabel3; private javax.swing.JLabel jLabel30; @@ -2066,6 +2089,7 @@ public class DataAcquisition extends Panel { private javax.swing.JSpinner spinnerImgEng2; private javax.swing.JSpinner spinnerImgExp; private javax.swing.JSpinner spinnerImgMeasurements; + private javax.swing.JSpinner spinnerImgOTFExp; private javax.swing.JSpinner spinnerOutliersThreshold; private javax.swing.JSpinner spinnerScans; private javax.swing.JSpinner spinnerSpecAvg; diff --git a/plugins/Eiger.form b/plugins/Eiger.form index d365612..d6e73ac 100755 --- a/plugins/Eiger.form +++ b/plugins/Eiger.form @@ -34,43 +34,38 @@ - - + + + + + + + + + + - + - - - - - + - - - - - - - - - - - - + - - - - - + - + + + + + + + @@ -120,7 +115,7 @@ - + @@ -169,12 +164,11 @@ - + - @@ -188,7 +182,7 @@ - + @@ -221,7 +215,7 @@ - + @@ -229,7 +223,7 @@ - + @@ -249,7 +243,7 @@ - + @@ -278,7 +272,7 @@ - + @@ -286,7 +280,7 @@ - + diff --git a/plugins/Eiger.java b/plugins/Eiger.java index a929d81..9cb8ae3 100755 --- a/plugins/Eiger.java +++ b/plugins/Eiger.java @@ -5,6 +5,7 @@ import ch.psi.pshell.ui.Panel; import ch.psi.utils.State; import java.io.IOException; import java.util.logging.Level; +import java.util.concurrent.TimeUnit; /** * @@ -66,12 +67,12 @@ public class Eiger extends Panel { } catch (Exception ex){ } try{ - spinnerExpusure.setValue(exposure.take()); + spinnerExposure.setValue(exposure.take()); } catch (Exception ex){ } comboDepth.setEnabled(bitDepth.isInitialized()); comboMode.setEnabled(mode.isInitialized()); - spinnerExpusure.setEnabled(exposure.isInitialized()); + spinnerExposure.setEnabled(exposure.isInitialized()); } finally{ updatingControls=false; @@ -95,7 +96,7 @@ public class Eiger extends Panel { jLabel2 = new javax.swing.JLabel(); comboMode = new javax.swing.JComboBox<>(); jLabel3 = new javax.swing.JLabel(); - spinnerExpusure = new javax.swing.JSpinner(); + spinnerExposure = new javax.swing.JSpinner(); deviceValuePanel1 = new ch.psi.pshell.swing.DeviceValuePanel(); deviceValuePanel2 = new ch.psi.pshell.swing.DeviceValuePanel(); deviceValuePanel3 = new ch.psi.pshell.swing.DeviceValuePanel(); @@ -119,7 +120,7 @@ public class Eiger extends Panel { jLabel1.setText("Bit Depth:"); - comboDepth.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "4", "8", "16", "32", "Unknown" })); + comboDepth.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "4", "8", "16", "32" })); comboDepth.setEnabled(false); comboDepth.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { @@ -127,7 +128,7 @@ public class Eiger extends Panel { } }); - buttonStartDetector.setText("Start Eiger"); + buttonStartDetector.setText("Start EIGER"); buttonStartDetector.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { buttonStartDetectorActionPerformed(evt); @@ -146,11 +147,11 @@ public class Eiger extends Panel { jLabel3.setText("Exposure [s]:"); - spinnerExpusure.setModel(new javax.swing.SpinnerNumberModel(1.0d, 0.001d, 300.0d, 1.0d)); - spinnerExpusure.setEnabled(false); - spinnerExpusure.addChangeListener(new javax.swing.event.ChangeListener() { + spinnerExposure.setModel(new javax.swing.SpinnerNumberModel(1.0d, 0.001d, 300.0d, 1.0d)); + spinnerExposure.setEnabled(false); + spinnerExposure.addChangeListener(new javax.swing.event.ChangeListener() { public void stateChanged(javax.swing.event.ChangeEvent evt) { - spinnerExpusureStateChanged(evt); + spinnerExposureStateChanged(evt); } }); @@ -160,7 +161,7 @@ public class Eiger extends Panel { deviceValuePanel3.setDeviceName("eiger_exposure_rbv"); - buttonStopDetector.setText("Stop Eiger"); + buttonStopDetector.setText("Stop EIGER"); buttonStopDetector.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { buttonStopDetectorActionPerformed(evt); @@ -183,14 +184,14 @@ public class Eiger extends Panel { } }); - buttonAquire.setText("Aquire"); + buttonAquire.setText("Start"); buttonAquire.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { buttonAquireActionPerformed(evt); } }); - buttonDone.setText("Done"); + buttonDone.setText("Stop"); buttonDone.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { buttonDoneActionPerformed(evt); @@ -259,35 +260,32 @@ public class Eiger extends Panel { .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(buttonCloseVG10, javax.swing.GroupLayout.PREFERRED_SIZE, 127, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(buttonStopDetector, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addContainerGap(68, Short.MAX_VALUE)) + .addComponent(buttonStopDetector, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + .addGroup(layout.createSequentialGroup() + .addComponent(spinnerExposure, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(deviceValuePanel3, javax.swing.GroupLayout.PREFERRED_SIZE, 106, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(deviceValuePanel4, javax.swing.GroupLayout.PREFERRED_SIZE, 127, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(buttonShowDetectorPanel, javax.swing.GroupLayout.PREFERRED_SIZE, 127, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGroup(layout.createSequentialGroup() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() - .addComponent(spinnerExpusure, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(comboMode, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(deviceValuePanel3, javax.swing.GroupLayout.PREFERRED_SIZE, 106, javax.swing.GroupLayout.PREFERRED_SIZE) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(deviceValuePanel4, javax.swing.GroupLayout.PREFERRED_SIZE, 127, javax.swing.GroupLayout.PREFERRED_SIZE) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(buttonShowDetectorPanel, javax.swing.GroupLayout.PREFERRED_SIZE, 127, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addComponent(deviceValuePanel1, javax.swing.GroupLayout.PREFERRED_SIZE, 106, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGroup(layout.createSequentialGroup() - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(layout.createSequentialGroup() - .addComponent(comboMode, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(deviceValuePanel1, javax.swing.GroupLayout.PREFERRED_SIZE, 106, javax.swing.GroupLayout.PREFERRED_SIZE)) - .addGroup(layout.createSequentialGroup() - .addComponent(comboDepth, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(deviceValuePanel2, javax.swing.GroupLayout.PREFERRED_SIZE, 106, javax.swing.GroupLayout.PREFERRED_SIZE))) + .addComponent(comboDepth, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(buttonAquire, javax.swing.GroupLayout.PREFERRED_SIZE, 127, javax.swing.GroupLayout.PREFERRED_SIZE) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(buttonOpenVG10, javax.swing.GroupLayout.PREFERRED_SIZE, 127, javax.swing.GroupLayout.PREFERRED_SIZE) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(buttonStartDetector))) - .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))) + .addComponent(deviceValuePanel2, javax.swing.GroupLayout.PREFERRED_SIZE, 106, javax.swing.GroupLayout.PREFERRED_SIZE))) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(buttonAquire, javax.swing.GroupLayout.PREFERRED_SIZE, 127, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(buttonOpenVG10, javax.swing.GroupLayout.PREFERRED_SIZE, 127, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(buttonStartDetector))) + .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addGroup(layout.createSequentialGroup() .addComponent(renderer, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) @@ -303,7 +301,7 @@ public class Eiger extends Panel { .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))) ); - layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {buttonStartDetector, buttonStopDetector, comboDepth, comboMode, deviceValuePanel1, deviceValuePanel2, deviceValuePanel3, spinnerExpusure}); + layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {buttonStartDetector, buttonStopDetector, comboDepth, comboMode, deviceValuePanel1, deviceValuePanel2, deviceValuePanel3, spinnerExposure}); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) @@ -329,7 +327,7 @@ public class Eiger extends Panel { .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER) .addComponent(jLabel3) - .addComponent(spinnerExpusure, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(spinnerExposure, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(deviceValuePanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(deviceValuePanel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(buttonShowDetectorPanel, javax.swing.GroupLayout.PREFERRED_SIZE, 35, javax.swing.GroupLayout.PREFERRED_SIZE)) @@ -355,14 +353,16 @@ public class Eiger extends Panel { .addComponent(renderer, javax.swing.GroupLayout.DEFAULT_SIZE, 409, Short.MAX_VALUE)))) ); - layout.linkSize(javax.swing.SwingConstants.VERTICAL, new java.awt.Component[] {buttonStartDetector, buttonStopDetector, comboDepth, comboMode, deviceValuePanel1, deviceValuePanel2, deviceValuePanel3, deviceValuePanel4, spinnerExpusure}); + layout.linkSize(javax.swing.SwingConstants.VERTICAL, new java.awt.Component[] {buttonStartDetector, buttonStopDetector, comboDepth, comboMode, deviceValuePanel1, deviceValuePanel2, deviceValuePanel3, deviceValuePanel4, spinnerExposure}); }// //GEN-END:initComponents private void comboDepthActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_comboDepthActionPerformed try{ if (!updatingControls){ - if (comboDepth.getSelectedIndex()!=comboDepth.getItemCount()-1) { + ((ch.psi.pshell.device.Camera) getDevice("eiger")).stop(); + TimeUnit.SECONDS.sleep(1); + if (comboDepth.getSelectedIndex()!=comboDepth.getItemCount()) { Integer value = Integer.valueOf((String)comboDepth.getSelectedItem()); bitDepth.write(value); } @@ -392,6 +392,8 @@ public class Eiger extends Panel { if (value==1){ value++; } + ((ch.psi.pshell.device.Camera) getDevice("eiger")).stop(); + TimeUnit.SECONDS.sleep(1); mode.write(value); } } catch (Exception ex){ @@ -399,15 +401,17 @@ public class Eiger extends Panel { } }//GEN-LAST:event_comboModeActionPerformed - private void spinnerExpusureStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_spinnerExpusureStateChanged + private void spinnerExposureStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_spinnerExposureStateChanged try{ if (!updatingControls){ - exposure.write((Double)spinnerExpusure.getValue()); + ((ch.psi.pshell.device.Camera) getDevice("eiger")).stop(); + TimeUnit.SECONDS.sleep(1); + exposure.write((Double)spinnerExposure.getValue()); } } catch (Exception ex){ showException(ex); } - }//GEN-LAST:event_spinnerExpusureStateChanged + }//GEN-LAST:event_spinnerExposureStateChanged private void buttonStopDetectorActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonStopDetectorActionPerformed try { @@ -506,9 +510,9 @@ public class Eiger extends Panel { private void spinnerMaxStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_spinnerMaxStateChanged ColormapSource source = (ColormapSource) renderer.getOrigin(); - source.getConfig().colormapMax = (Double)spinnerMax.getValue(); try { + source.getConfig().colormapMax = ((Integer)spinnerMax.getValue()); source.getConfig().save(); } catch (Exception ex) { getLogger().log(Level.WARNING, null, ex); @@ -518,9 +522,9 @@ public class Eiger extends Panel { private void spinnerMinStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_spinnerMinStateChanged ColormapSource source = (ColormapSource) renderer.getOrigin(); - source.getConfig().colormapMax = (Double)spinnerMin.getValue(); - + try { + source.getConfig().colormapMin = ((Integer)spinnerMin.getValue()); source.getConfig().save(); } catch (Exception ex) { getLogger().log(Level.WARNING, null, ex); @@ -551,7 +555,7 @@ public class Eiger extends Panel { private javax.swing.JLabel jLabel5; private javax.swing.JLabel jLabel6; private ch.psi.pshell.imaging.Renderer renderer; - private javax.swing.JSpinner spinnerExpusure; + private javax.swing.JSpinner spinnerExposure; private javax.swing.JSpinner spinnerMax; private javax.swing.JSpinner spinnerMin; // End of variables declaration//GEN-END:variables diff --git a/script/devices/LEEM2000.py b/script/devices/LEEM2000.py index 4da30dd..2dc9155 100755 --- a/script/devices/LEEM2000.py +++ b/script/devices/LEEM2000.py @@ -123,6 +123,13 @@ class LEEM2000(TcpDevice): ret.initialize() return ret + def get_positioner(self, var, name=None): + if name is None: + name=var + ret = LEEM2000Positioner(name, var, self) + ret.initialize() + return ret + def get_motor(self, motor_id, name=None): if name is None: name=str(motor_id) @@ -186,6 +193,24 @@ class LEEM2000Child(RegisterBase): def doWrite(self, val): self.microscope.set_value(self.var, val) +class LEEM2000Positioner (PositionerBase): + def __init__(self, name, var, microscope): + PositionerBase.__init__(self, name, PositionerConfig()) + self.var = var + self.microscope = microscope + self.setpoint = None + + def doRead(self): + if self.setpoint is None: + self.setpoint = self.doReadReadback() + return self.setpoint + + def doWrite(self, val): + self.microscope.set_value(self.var, val) + self.setpoint = val + + def doReadReadback(self): + return self.microscope.get_value(self.var) class LEEM2000Motor(RegisterBase): def __init__(self,name, motor_id, microscope): @@ -227,9 +252,13 @@ add_device (microscope.get_motor(11,"manip_x"), True) add_device (microscope.get_motor(10,"manip_y"), True) add_device (microscope.get_tilt('L','R', "tilt_h"), True) add_device (microscope.get_tilt('D','U', "tilt_v"), True) +#add_device (microscope.get_positioner("MOBJ","objective"), True) +#add_device (microscope.get_positioner("OSTIGA","obj_stig_a"), True) +#add_device (microscope.get_positioner("OSTIGB","obj_stig_b"), True) add_device (microscope.get_child("MOBJ","objective"), True) add_device (microscope.get_child("OSTIGA","obj_stig_a"), True) add_device (microscope.get_child("OSTIGB","obj_stig_b"), True) + microscope.setPolling(5000) class TiltMotor(RegisterBase): diff --git a/script/devices/eiger.py b/script/devices/eiger.py index 8b9baa5..a1c234e 100755 --- a/script/devices/eiger.py +++ b/script/devices/eiger.py @@ -280,7 +280,7 @@ def init_eiger(exposure=None, check=True, retries=2): else: print "Error initializing Eiger, retrying: " + str(sys.exc_info()[1]) -def restore_eiger(check=True, retries=2): +def restore_eiger(check=True, retries=2, exposure_time = 0.2): """ Set Eiger default mode """ @@ -290,7 +290,7 @@ def restore_eiger(check=True, retries=2): stop_eiger() eiger.setNumImages(1)# Is it relevant? set_eiger_number_of_frames(1, check) - set_exposure_time(0.2, check) + set_exposure_time(exposure_time, check) apply_averaging_detector(False) eiger.grabMode=eiger.GrabMode.Continuous eiger.start() diff --git a/script/local.py b/script/local.py index ddbea3c..f0deb98 100755 --- a/script/local.py +++ b/script/local.py @@ -227,7 +227,7 @@ def convert_file_full(input_file_name, output_file_name, pol = None): #os.rename(input_file_name, get_context().setup.expandPath("{data}/OTF/" + ntpath.basename(input_file_name))) ################################################################################################### -#OTF function +#Scan commands ################################################################################################### def otf(start, end, time, delay = 0.0, mode = None, offset = None, alpha = None, name = None, folder = 'TEST'): """ @@ -245,6 +245,65 @@ def otf2(start, end, time, delay = 0.0, mode = None, offset = None, alpha = None #folder = get_context().setup.expandPath("{year}_{month}/{date}"); run("templates/EnergyScan_v2", {"E1":start, "E2":end, "TIME":time, "DELAY":float(delay), "MODE":mode, "OFFSET":(offset), "FOLDER":folder, "FILE":name, "ALPHA":float(alpha) if alpha is not None else None}) + +def two_pol(switching="Tune_Detune", sequence="A", measurements=4, exposure=1.0, average=2, name = None): + set_exec_pars(open=False) + if name: + set_exec_pars(name=name) + + run("templates/Eiger2Img", { \ + "METHOD": "Two_Pol", "AUTO_SAVE": True, \ + "MEASUREMENTS": int(measurements), "EXPOSURE": float(exposure), "AVERAGE": int(average), \ + "SWITCHING": switching, "SEQUENCE": sequence, \ + "ENERGY_1":None, "ENERGY_2":None, \ + "NUMBER_SCANS":1, "SWITCH_POL": False, \ + }) + +def two_energies(energy_1, energy_2, measurements=4, exposure=1.0, average=2, name = None): + set_exec_pars(open=False) + if name: + set_exec_pars(name=name) + + run("templates/Eiger2Img", { \ + "METHOD": "Two_Energies", "AUTO_SAVE": True, \ + "MEASUREMENTS": int(measurements), "EXPOSURE": float(exposure), "AVERAGE": int(average), \ + "SWITCHING": None, "SEQUENCE": None, \ + "ENERGY_1":energy_1, "ENERGY_2":energy_2, \ + "NUMBER_SCANS":1, "SWITCH_POL": False, \ + }) + +def take_image(scans=1, switch_pol=False, measurements=4, exposure=1.0, average=2, name = None): + set_exec_pars(open=False) + if name: + set_exec_pars(name=name) + + run("templates/Eiger2Img", { \ + "METHOD": "Take_Image", "AUTO_SAVE": True, \ + "MEASUREMENTS": int(measurements), "EXPOSURE": float(exposure), "AVERAGE": int(average), \ + "SWITCHING": None, "SEQUENCE": None, \ + "ENERGY_1":None, "ENERGY_2":None, \ + "NUMBER_SCANS":scans, "SWITCH_POL": switch_pol, \ + }) + +def abs_spec(ranges, roi=None, switch_pol=False, scans=1, exposure=1.0, average=2, name = None): + set_exec_pars(open=False) + if name: + set_exec_pars(name=name) + if ROI is None: + if ("DAQ_PANEL_ROIS" in globals()) and (len(DAQ_PANEL_ROIS) > 0): + ROI = DAQ_PANEL_ROIS + else: + width, height = eiger.getImageSize() + ROI = {"Region1": [0, 0, width, height]} + + run("templates/EigerAbsSpec", { \ + "ROI": roi, "SAVE_SPECTRUM": True, "SAVE_IMAGES":True, "WITH_I0": True, \ + "RANGES": ranges, "SWITCH_POL": switch_pol, \ + "NUMBER_SCANS": int(scans), "EXPOSURE": float(exposure), "AVERAGE": int(average), \ + }) + + + ################################################################################################### #Devices ################################################################################################### @@ -613,7 +672,7 @@ def restore_beamline_setup(): ################################################################################################### -def fit(ydata, xdata = None): +def fit(ydata, xdata = None, limit_to_range=False): """ Gaussian fit """ @@ -627,9 +686,15 @@ def fit(ydata, xdata = None): print "Max index:" + str(index_max), print " x:" + str(max_x), print " y:" + str(max_y) - gaussians = fit_gaussians(ydata, xdata, [index_max,]) - (norm, mean, sigma) = gaussians[0] p = plot([ydata],["data"],[xdata], title="Fit" )[0] + gaussians = fit_gaussians(ydata, xdata, [index_max,]) + if gaussians[0] is None: + if limit_to_range: + print "Max -> " + str(max_x) + p.addMarker(max_x, None, "Max="+str(round(max_x,2)), Color.MAGENTA.darker()) + return (None , max_x, None) + (norm, mean, sigma) = gaussians[0] + print " mean:" + str(mean) fitted_gaussian_function = Gaussian(norm, mean, sigma) scale_x = [float(min(xdata)), float(max(xdata)) ] points = max((len(xdata)+1), 100) @@ -640,15 +705,37 @@ def fit(ydata, xdata = None): fit_y.append(fitted_gaussian_function.value(x)) p.addSeries(LinePlotSeries("fit")) p.getSeries(1).setData(fit_x, fit_y) - - if abs(mean - xdata[index_max]) < ((scale_x[0] + scale_x[1])/2): + + if abs(mean - xdata[index_max]) < abs((scale_x[0] + scale_x[1])/2): + if limit_to_range and not (scale_x[0] <= mean <= scale_x[1]): + print "Limiting to range ", scale_x, " max=", str(max_x) + p.addMarker(max_x, None, "Max="+str(round(max_x,2)), Color.MAGENTA.darker()) + return (None , max_x, None) print "Mean -> " + str(mean) p.addMarker(mean, None, "Mean="+str(round(norm,2)), Color.MAGENTA.darker()) return (norm, mean, sigma) else: - p.addMarker(max_x, None, "Max="+str(round(max_x,2)), Color.GRAY) - print "Invalid gaussian fit: " + str(mean) - return (None, None, None) + if limit_to_range: + print "Max -> " + str(max_x) + p.addMarker(max_x, None, "Max="+str(round(max_x,2)), Color.MAGENTA.darker()) + return (None , max_x, None) + else: + p.addMarker(max_x, None, "Max="+str(round(max_x,2)), Color.GRAY) + print "Invalid gaussian fit: " + str(mean) + return (None, None, None) + +################################################################################################### +#Additional initialization +################################################################################################### + +run("templates/FocusScan") + +def auto_focus(): + run("templates/AutoFocus") + +def auto_intensity(): + return scan_focus(girder_x, 0.05, 0.005, average=3) + ################################################################################################### #Settings ################################################################################################### diff --git a/script/templates/AutoFocus.py b/script/templates/AutoFocus.py new file mode 100644 index 0000000..67acd8d --- /dev/null +++ b/script/templates/AutoFocus.py @@ -0,0 +1,28 @@ +RANGE_OBJ = 4.0 +STEP_OBJ = 0.2 +RANGE_STIG = 20.0 +STEP_STIG = 2.0 +UPDATE_POSITION = True +AVERAGE = 1 +width, height = eiger.getImageSize() +ROI = Rectangle(width/3, height/3, width/3, height/3,) + +initial_state = objective.read(),obj_stig_a.read(),obj_stig_b.read() +print "Initial state:" , initial_state + +def apply_pos(pos): + objective.write(pos[0]) + obj_stig_a.write(pos[1]) + obj_stig_b.write(pos[2]) + + +r=scan_focus(objective, RANGE_OBJ, STEP_OBJ, roi = ROI, average = AVERAGE, update_position = UPDATE_POSITION) +r=scan_focus(obj_stig_a, RANGE_STIG, STEP_STIG, roi = ROI, average = AVERAGE, update_position = UPDATE_POSITION) +r=scan_focus(obj_stig_b, RANGE_STIG, STEP_STIG, roi = ROI, average = AVERAGE, update_position = UPDATE_POSITION) +r=scan_focus(objective, RANGE_OBJ, STEP_OBJ, roi = ROI, average = AVERAGE, update_position = UPDATE_POSITION) +r=scan_focus(obj_stig_a, RANGE_STIG, STEP_STIG, roi = ROI, average = AVERAGE, update_position = UPDATE_POSITION) +r=scan_focus(obj_stig_b, RANGE_STIG, STEP_STIG, roi = ROI, average = AVERAGE, update_position = UPDATE_POSITION) +r=scan_focus(objective, RANGE_OBJ, STEP_OBJ, roi = ROI, average = AVERAGE, update_position = UPDATE_POSITION) + +final_state = objective.read(),obj_stig_a.read(),obj_stig_b.read() +print "Final state:" , final_state diff --git a/script/templates/EnergyScan_img.py b/script/templates/EnergyScan_img.py index 898e178..54b9d5d 100755 --- a/script/templates/EnergyScan_img.py +++ b/script/templates/EnergyScan_img.py @@ -8,6 +8,7 @@ if get_exec_pars().source == CommandSource.ui: FILE = 'ImageOTF' ROI = {"Region1": [286, 86, 79, 70], "Region2": [153, 279, 95, 82]} SAVE_IMAGES=True + EXPOSURE = 0.2 SAVE_DIAGS = True @@ -76,6 +77,9 @@ class Time(Readable): scan_completed = False try: + if EXPOSURE != eiger.getExposure(): + restore_eiger(exposure_time = EXPOSURE) + caput('START', '1') #av = create_averager(CADC1, -1, -1) @@ -115,5 +119,7 @@ except: caput('START', '0') time.sleep(0.1) raise +finally: + restore_eiger() after_sample() #To call check_id_error() \ No newline at end of file diff --git a/script/templates/FocusScan.py b/script/templates/FocusScan.py new file mode 100644 index 0000000..1547108 --- /dev/null +++ b/script/templates/FocusScan.py @@ -0,0 +1,63 @@ +SETTLING_TIME =0.5 +MAX_CONTRAST = 10e14 + + +import java.awt.Rectangle as Rectangle + +class RoiContrast(ReadonlyRegisterBase): + def doRead(self): + if hasattr(self, "roi"): + return image.getData().getGradientVariance(False, self.roi) + return 0.0 + def getName(self): + return "roi_contrast" + def set_roi(self, roi): + self.roi=roi + +if get_device("image_contrast") is None: + add_device(image.getContrast(), False) + +if get_device("roi_contrast") is None: + add_device(RoiContrast(), False) + + +def scan_focus(positioner, pos_range, pos_step, roi = None, average = 1, update_position = True): + def after_read(rec): + if rec[positioner] > MAX_CONTRAST: + print "Invalid contrast value" + time.sleep(eiger.exposure) + rec.invalidate() + + def before_pass(scan, num_pass): + print "Waiting to reach scan init pos" + time.sleep(1.0) + + + if roi is None: + sensor = image_contrast + else: + sensor = roi_contrast + roi_contrast.set_roi(roi) + + if average > 1: + sensor = create_averager(sensor, average, interval = eiger.exposure, name = image_contrast.name, monitored = False) + + r = lscan( positioner, [sensor,], -pos_range, pos_range, pos_step, \ + latency=eiger.exposure+SETTLING_TIME, relative=True, after_read=after_read, before_pass=before_pass) + + ydata, xdata = r[sensor], r[positioner] + if average > 1: + ydata = [v.doubleValue() for v in ydata] + (norm, mn, std ) = fit (ydata, xdata, limit_to_range=True) + + range_scan = (min(r[positioner]), max(r[positioner])) + if (mn is not None) and (range_scan[0] <= mn <= range_scan[1]): + print "Valid fit for ", positioner.name, mn + if update_position: + time.sleep(0.5) # Wait restoring positions + print "Updating position: ", positioner.name, mn + positioner.write(mn) + else: + print "Invalid fit for ", positioner.name, mn, range_scan + time.sleep(1.0) # Wait restoring positions + return r diff --git a/script/templates/LEEM_tilt_scan.py b/script/templates/LEEM_tilt_scan.py index abb17cc..d5f9a08 100644 --- a/script/templates/LEEM_tilt_scan.py +++ b/script/templates/LEEM_tilt_scan.py @@ -1,6 +1,6 @@ -CENTER = [400.0, 600.0] -RANGE = 400 -STEP = 200.0 +CENTER = [0.0, 0.0] +RANGE = 2000 +STEP = 1000.0 SETTLING_TIME = 1.0 RANGE_H = [CENTER[0]-RANGE, CENTER[0]+RANGE] @@ -8,7 +8,7 @@ RANGE_V = [CENTER[1]-RANGE, CENTER[1]+RANGE] STEP_H = STEP STEP_V = STEP INIT_TILT = True # True - tilt must be manually set to 0,0 before the scan - # False - tilt set 0.0 al leasts once at PShell startut + # False - tilt set 0.0 at least once at PShell start up if INIT_TILT: init_tilt()