This commit is contained in:
sfop
2017-07-04 10:19:29 +02:00
parent 719b4e30ea
commit d50672dfae
17 changed files with 170 additions and 132 deletions
+4 -4
View File
@@ -1,9 +1,9 @@
#Wed Jun 14 11:54:37 CEST 2017
maxValue=180.0
minValue=-180.0
#Tue Jul 04 09:53:47 CEST 2017
maxValue=360.0
minValue=-360.0
offset=0.0
precision=3
resolution=1.0
rotation=true
rotation=false
scale=1.0
unit=deg
+11 -11
View File
@@ -1,16 +1,16 @@
#Mon Jun 19 13:19:05 CEST 2017
#Tue Jul 04 10:08:08 CEST 2017
colormap=Flame
colormapAutomatic=true
colormapMax=24.0
colormapAutomatic=false
colormapMax=1071.0
colormapMin=0.0
flipHorizontally=false
flipVertically=false
grayscale=false
imageHeight=2160
imageWidth=2560
imageHeight=1200
imageWidth=1246
invert=false
regionStartX=1
regionStartY=1
regionStartX=304
regionStartY=8
rescaleFactor=1.0
rescaleOffset=0.0
roiHeight=-1
@@ -21,9 +21,9 @@ rotation=0.0
rotationCrop=false
scale=1.0
serverURL=localhost\:10000
spatialCalOffsetX=447.40694006309144
spatialCalOffsetY=400.8840579710145
spatialCalScaleX=1.0
spatialCalScaleY=1.0
spatialCalOffsetX=-393.4993589250224
spatialCalOffsetY=-389.50586061323884
spatialCalScaleX=-18.903591441986975
spatialCalScaleY=-19.37984471513329
spatialCalUnits=mm
transpose=false
+1 -1
View File
@@ -1,4 +1,4 @@
#Thu May 11 14:22:56 CEST 2017
#Fri Jun 30 08:55:58 CEST 2017
colormap=Temperature
colormapAutomatic=true
colormapMax=30000.0
+1 -1
View File
@@ -1,4 +1,4 @@
#Fri May 26 11:30:37 CEST 2017
#Tue Jun 27 15:04:39 CEST 2017
colormap=Flame
colormapAutomatic=true
colormapMax=255.0
+1 -1
View File
@@ -1,4 +1,4 @@
#Thu Jun 01 10:19:48 CEST 2017
#Thu Jun 29 14:59:27 CEST 2017
colormap=Flame
colormapAutomatic=true
colormapMax=255.0
+9 -4
View File
@@ -31,24 +31,25 @@ public class SchottkyScan extends Panel {
public SchottkyScan() {
initComponents();
setPersistedComponents(SwingUtils.getComponentsByType(panelPars, JSpinner.class));
buttonSet.setEnabled(false);
}
//Overridable callbacks
@Override
public void onInitialize(int runCount) {
public void onInitialize(int runCount) {
}
@Override
public void onStateChange(State state, State former) {
buttonAbort.setEnabled(state.isProcessing());
buttonStart.setEnabled(state == State.Ready);
buttonSet.setEnabled(buttonStart.isEnabled());
//buttonSet.setEnabled(buttonStart.isEnabled());
spinnerStart.setEnabled(buttonStart.isEnabled());
spinnerStop.setEnabled(buttonStart.isEnabled());
spinnerStep.setEnabled(buttonStart.isEnabled());
spinnerSamples.setEnabled(buttonStart.isEnabled());
spinnerLatency.setEnabled(buttonStart.isEnabled());
spinnerPhaseRef.setEnabled(buttonStart.isEnabled());
//spinnerPhaseRef.setEnabled(buttonStart.isEnabled());
}
@Override
@@ -292,8 +293,9 @@ public class SchottkyScan extends Panel {
getLogger().info("Exception executing scan: " + ex);
} else {
Double bph_ref = (Double) ((List)ret).get(0);
Double rph_ref = (Double) ((List)ret).get(1);
spinnerPhaseRef.setValue(Convert.roundDouble(bph_ref, 1));
buttonSet.setEnabled(true);
spinnerPhaseRef.setEnabled(true);
}
return ret;
});
@@ -330,7 +332,10 @@ public class SchottkyScan extends Panel {
runAsync("RFscan/SchottkyScanSet", parameters).handle((ret, ex) -> {
if (ex != null) {
getLogger().info("Exception executing scan: " + ex);
showException((Exception) ex);
}
buttonSet.setEnabled(false);
spinnerPhaseRef.setEnabled(false);
return ret;
});
} catch (Exception ex) {
+67 -66
View File
@@ -132,31 +132,39 @@ public class ScreenPanel extends Panel {
double[] getCamtoolDoubleArray(String name) {
return (double[]) Convert.toDouble(((Camtool) camera).getValue(name));
}
Double getCamtoolDouble(String name, StreamValue cache) {
return (Double) Convert.toDouble(cache.__getitem__(name));
}
double[] getCamtoolDoubleArray(String name, StreamValue cache) {
return (double[]) Convert.toDouble(cache.__getitem__(name));
}
class ImageData {
ImageData(){
if (camera instanceof Camtool) {
cache = ((Camtool) camera).getStream().take();
StreamValue cache = ((Camtool) camera).getStream().take();
String prefix = goodRegion ? "gr_" : "";
x_fit_mean = getDouble(prefix + "x_fit_mean");
y_fit_mean = getDouble(prefix + "y_fit_mean");
x_fit_standard_deviation = getDouble(prefix + "x_fit_standard_deviation");
y_fit_standard_deviation = getDouble(prefix + "y_fit_standard_deviation");
x_fit_gauss_function = getDoubleArray(prefix +"x_fit_gauss_function");
y_fit_gauss_function = getDoubleArray(prefix +"y_fit_gauss_function");
x_profile = getDoubleArray("x_profile");
y_profile = getDoubleArray("y_profile");
x_center_of_mass = getDouble("x_center_of_mass");
y_center_of_mass = getDouble("y_center_of_mass");
x_rms = getDouble("x_rms");
y_rms = getDouble("y_rms");
x_fit_mean = getCamtoolDouble(prefix + "x_fit_mean", cache);
y_fit_mean = getCamtoolDouble(prefix + "y_fit_mean", cache);
x_fit_standard_deviation = getCamtoolDouble(prefix + "x_fit_standard_deviation", cache);
y_fit_standard_deviation = getCamtoolDouble(prefix + "y_fit_standard_deviation", cache);
x_fit_gauss_function = getCamtoolDoubleArray(prefix +"x_fit_gauss_function", cache);
y_fit_gauss_function = getCamtoolDoubleArray(prefix +"y_fit_gauss_function", cache);
x_profile = getCamtoolDoubleArray("x_profile", cache);
y_profile = getCamtoolDoubleArray("y_profile", cache);
x_center_of_mass = getCamtoolDouble("x_center_of_mass", cache);
y_center_of_mass = getCamtoolDouble("y_center_of_mass", cache);
x_rms = getCamtoolDouble("x_rms", cache);
y_rms = getCamtoolDouble("y_rms", cache);
if (goodRegion){
double[] gX2 = new double[x_profile.length];
Arrays.fill(gX2, Double.NaN);
try{
double x = getDoubleArray("gr_x_axis")[0];
double x = getCamtoolDoubleArray("gr_x_axis", cache)[0];
System.arraycopy(x_fit_gauss_function, 0, gX2, (int) ((renderer.getCalibration() != null) ? renderer.getCalibration().convertToImageX(x): x), x_fit_gauss_function.length);
} catch (Exception ex){
}
@@ -164,7 +172,7 @@ public class ScreenPanel extends Panel {
double[] gY2 = new double[y_profile.length];
Arrays.fill(gY2, Double.NaN);
try{
double y = getDoubleArray("gr_y_axis")[0];
double y = getCamtoolDoubleArray("gr_y_axis", cache)[0];
System.arraycopy(y_fit_gauss_function, 0, gY2, (int) ((renderer.getCalibration() != null) ? renderer.getCalibration().convertToImageY(y): y), y_fit_gauss_function.length);
} catch (Exception ex){
}
@@ -183,17 +191,7 @@ public class ScreenPanel extends Panel {
public double[] x_profile;
public double[] x_fit_gauss_function;
public double[] y_profile;
public double[] y_fit_gauss_function;
StreamValue cache;
Double getDouble(String name) {
return (Double) Convert.toDouble(cache.__getitem__(name));
}
double[] getDoubleArray(String name) {
return (double[]) Convert.toDouble(cache.__getitem__(name));
}
public double[] y_fit_gauss_function;
}
@@ -206,6 +204,7 @@ public class ScreenPanel extends Panel {
}
final ArrayList<Frame> imageBuffer = new ArrayList();
Frame currentFrame;
int imageBufferLenght = 0;
Text imageBufferOverlay;
@@ -671,6 +670,12 @@ public class ScreenPanel extends Panel {
if (cameraName == null) {
return;
}
synchronized (imageBuffer) {
currentFrame = null;
imageBuffer.clear();
}
try {
String configFolder = (String) getContext().getClassByName("SfCamera").getMethod("getConfigFolder", new Class[]{}).invoke(null);
@@ -752,11 +757,11 @@ public class ScreenPanel extends Panel {
}
//renderer.setCalibration(camera.getCalibration());
if (!renderer.isPaused()) {
if (imageBufferLenght > 1) {
if (data != null) {
synchronized (imageBuffer) {
imageBuffer.add(new Frame(data));
if (data != null) {
synchronized (imageBuffer) {
currentFrame =new Frame(data);
if (imageBufferLenght > 1) {
imageBuffer.add(currentFrame);
if (imageBuffer.size() > imageBufferLenght) {
imageBuffer.remove(0);
}
@@ -1011,31 +1016,25 @@ public class ScreenPanel extends Panel {
Pen penCross = new Pen(new Color(192, 105, 0), 1);
ImageData getCurrentImageData(){
return getImageData(null);
Frame getCurrentFrame(){
if ((imageBufferLenght > 1) && (renderer.isPaused())) {
int index = ((int) pauseSelection.getValue()) - 1;
synchronized (imageBuffer) {
return (index < imageBuffer.size()) ? imageBuffer.get(index) : null;
}
}
return currentFrame;
}
ImageData getImageData(Data data){
ImageData id = null;
if (renderer.isPaused()) {
synchronized (imageBuffer) {
if (data == null){
int index = ((int) pauseSelection.getValue()) - 1;
if (index < imageBuffer.size()) {
data = imageBuffer.get(index).data;
}
}
for (Frame f : imageBuffer) {
if (f.data == data) {
id = f;
break;
}
Frame getFrame(Data data){
synchronized (imageBuffer) {
for (Frame f : imageBuffer) {
if (f.data == data) {
return f;
}
}
} else {
id = new ImageData();
}
return id;
}
return null;
}
Overlay[][] getFitOverlays(Data data) {
@@ -1054,7 +1053,7 @@ public class ScreenPanel extends Panel {
if ((useCamtoolStats) && (camera instanceof Camtool)) {
try {
ImageData id = getImageData(data);
ImageData id = getFrame(data);
if (id==null){
return null;
}
@@ -1573,22 +1572,23 @@ public class ScreenPanel extends Panel {
}
}
void writeFrameMetadata(String path, ImageData id) throws Exception{
void writeFrameMetadata(String path, Frame frame) throws Exception{
getContext().getDataManager().setAttribute("/", "Camera", String.valueOf(cameraName));
getContext().getDataManager().setAttribute("/", "Screen", String.valueOf(valueScreen.getLabel().getText()));
getContext().getDataManager().setAttribute("/", "Filter", String.valueOf(valueFilter.getLabel().getText()));
Calibration cal = renderer.getCalibration();
getContext().getDataManager().setAttribute("/", "Calibration", cal == null ? new double[]{1,1,0,0} :
new double[]{cal.getScaleX(), cal.getScaleY(), cal.getOffsetX(), cal.getOffsetY()});
new double[]{cal.getScaleX(), cal.getScaleY(), cal.getOffsetX(), cal.getOffsetY()});
getContext().getDataManager().setAttribute(path, "Timestamp", Chrono.getTimeStr(frame.data.getTimestamp(), "HH:mm:ss.SSS"));
if (camera instanceof Camtool){
try{
getContext().getDataManager().setAttribute("/", "ROI", ((Camtool) camera).getRoi());
} catch (Exception ex){
getContext().getDataManager().setAttribute("/", "ROI", new int[]{0,0,-1,-1});
}
if (id!=null){
if (frame!=null){
for (Field f:ImageData.class.getFields()){
Object value = f.get(id);
Object value = f.get(frame);
getContext().getDataManager().setAttribute(path, f.getName(), (value == null) ? Double.NaN : value);
}
}
@@ -1607,16 +1607,17 @@ public class ScreenPanel extends Panel {
String path = "/data";
String snapshotFile = null;
synchronized (imageBuffer) {
ImageData id = getCurrentImageData();
//Object data = renderer.getData().getMatrix();
Object data = Convert.toBidimensional(id.getDoubleArray("image"),
//width & height are not always in the stream
renderer.getData().getWidth(), renderer.getData().getHeight());
getContext().getDataManager().setDataset(path, data, renderer.getData().isUnsigned());
Frame id = getCurrentFrame();
if (id==null){
throw new Exception("No current image");
}
Object data = id.data.getMatrix();
getContext().getDataManager().setDataset(path, data, id.data.isUnsigned());
writeFrameMetadata(path, id);
getContext().getDataManager().closeOutput();
getContext().getDataManager().closeOutput();
//Enforce the same timestamp to data & image files.
snapshotFile = getContext().getSetup().expandPath("{images}/{date}_{time}_snapshot.png", getContext().getExecutionPars().getStart());
//snapshotFile = getContext().getSetup().expandPath("{images}/{date}_{time}_snapshot.png", getContext().getExecutionPars().getStart());
snapshotFile = getContext().getExecutionPars().getPath() + ".png";
renderer.saveSnapshot(snapshotFile, "png", true);
}
@@ -1670,7 +1671,7 @@ public class ScreenPanel extends Panel {
Frame frame = imageBuffer.get(i);
String path = "/data_" + i;
getContext().getDataManager().setDataset(path, frame.data.getMatrix(), frame.data.isUnsigned());
writeFrameMetadata(path, getImageData(frame.data));
writeFrameMetadata(path, frame);
x.add(frame.x_fit_mean);
y.add(frame.y_fit_mean);
}
-1
View File
@@ -126,7 +126,6 @@
<Component id="buttonParkAll" linkSize="2" min="-2" max="-2" attributes="0"/>
<EmptySpace type="separate" max="32767" attributes="0"/>
<Component id="buttonMoveStart" linkSize="2" min="-2" max="-2" attributes="0"/>
<EmptySpace min="0" pref="0" max="-2" attributes="0"/>
</Group>
</Group>
<Component id="plot" pref="430" max="32767" attributes="0"/>
+1 -1
View File
@@ -901,7 +901,7 @@ public class WireScan extends Panel {
private void buttonScannerPanelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonScannerPanelActionPerformed
try {
String cmd = caqtdm + " -macro 'DEVICE=" + comboWireScanner.getSelectedItem() + "' /sf/op/config/qt/S_DI_WSC.ui";
String cmd = caqtdm + " -macro 'SYS=" + comboWireScanner.getSelectedItem() + "' /sf/common/config/qt/S_DI_WSC_EXPERT.ui";
Runtime.getRuntime().exec(new String[]{"bash", "-c", cmd.toString()});
} catch (Exception ex) {
showException(ex);
+12 -24
View File
@@ -2,14 +2,13 @@ import ch.psi.pshell.epics.Positioner as Positioner
import ch.psi.pshell.epics.ChannelDouble as ChannelDouble
dry_run = False
do_elog = True
if get_exec_pars().source == CommandSource.ui:
start = -180.0
stop = 180.0
step = 5.0
nb = 1
lat = 0.100
start = -30.0
stop = 30.0
step = 1.0
nb = 3
lat = 0.300
plt = None
else:
start = args[0]
@@ -40,10 +39,10 @@ else:
st.start()
st.waitValueChange(10000)
bph.config.minValue =-180.0
bph.config.maxValue = 180.0
bph.config.minValue = -360.0
bph.config.maxValue = 360.0
bph.config.precision = 3
bph.config.rotation = True
bph.config.rotation = False
bph.config.resolution = 1.0
bph.config.save()
bph.initialize()
@@ -75,20 +74,9 @@ finally:
#Setting the return value
index_max = charge.index(max(charge))
bph_ref_guess = beamphase[index_max] - 80
rph_ref_guess = rfphase[index_max] - 80
#bph_ref_guess = beamphase[index_max] - 80
#rph_ref_guess = rfphase[index_max] - 80
if do_elog:
if get_option("Generated data file:\n" + get_exec_pars().path +"\n\n" + "Save to ELOG?", "YesNo") == "Yes":
log_msg = "Data file: " + get_exec_pars().path + "\n"
log_msg = log_msg + "Beam phase reference: %0.1f" % bph_ref_guess + "deg \n"
log_msg = log_msg + "RF phase reference: %0.1f" % rph_ref_guess + "deg \n"
attachments = []
if plt is not None:
sleep(0.1) #Give some time to plot to be finished - it is not sync with acquisition
file_name = os.path.abspath(get_context().setup.getContextPath() + "/SchottkyScanPlot.png")
plt.saveSnapshot(file_name, "png")
attachments = [file_name,]
elog("Schottky scan", log_msg, attachments)
bph_ref_guess = (start + stop)/2
set_return([bph_ref_guess, rph_ref_guess])
set_return([bph_ref_guess])
+6 -7
View File
@@ -4,22 +4,21 @@ do_elog = True
if get_exec_pars().source == CommandSource.ui:
bph_ref_user = 0.0
plt = None
print "Debug"
else:
bph_ref_user = args[0]
plt = args[1]
rph_ref_new = rph_ref_guess + (bph_ref_guess - bph_ref_user)
phaseOffset = -rph_ref_new
bph_ref_new = rph_ref_new + phaseOffset
print "Args: " , bph_ref_user, plt
phaseOffsetInit = caget('SINEG01-RSYS:SET-VSUM-PHASE-OFFSET-BASE')
phaseOffset = phaseOffsetInit - bph_ref_user
print "Setting phase offset: ", phaseOffset
if not dry_run:
caput('SINEG01-RSYS:SET-VSUM-PHASE-OFFSET-BASE', phaseOffset)
caput('SINEG01-RSYS:CMD-LOAD-CALIB-BEAM', 1)
if do_elog:
log_msg = "RF phase reference: %0.1f" % rph_ref_new + "deg \n"
log_msg = log_msg + "Phase offset: %0.1f" % phaseOffset + "deg \n"
log_msg = log_msg + "Beam phase reference: %0.1f" % bph_ref_new + "deg \n"
log_msg = "Initial phase offset: %0.1f" % phaseOffsetInit + "deg \n"
log_msg = log_msg + "New phase offset: %0.1f" % phaseOffset + "deg \n"
attachments = []
if plt is not None:
sleep(0.1) #Give some time to plot to be finished - it is not sync with acquisition
+3 -3
View File
@@ -94,9 +94,9 @@ phase_offset = 90 - ph_crest
amplitude_scale = fit_amplitude / Ampl
power_scale = Power / math.pow(fit_amplitude,2)
caput(station + "-RSYS:SET-VSUM-PHASE-OFFSET-BASE", phase_offset)
caput(station + "-RSYS:SET-VSUM-AMPLT-SCALE", amplitude_scale)
caput(station + "-RSYS:SET-VOLT-POWER-SCALE", power_scale)
caput(station + "-RSYS:SET-VSUM-PHASE-OFFSET-BASE-CALC", phase_offset)
caput(station + "-RSYS:SET-VSUM-AMPLT-SCALE-CALC", amplitude_scale)
caput(station + "-RSYS:SET-VOLT-POWER-SCALE-CALC", power_scale)
if do_elog:
if get_option("Generated data file:\n" + get_exec_pars().path +"\n\n" + "Save to ELOG?", "YesNo") == "Yes":
+22
View File
@@ -0,0 +1,22 @@
if get_exec_pars().source == CommandSource.ui:
station = "STEST01"
else:
station = args[0]
phase_set = caget(station + "-RSYS:PHASE-SET")
ampli_set = caget(station + "-RSYS:AMPLT-SET")
power_set = caget(station + "-RSYS:POWER-SET")
if (phase_set == 'True'):
phase_offset = caget(station + "-RSYS:SET-VSUM-PHASE-OFFSET-BASE-CALC")
caput(station + "-RSYS:SET-VSUM-PHASE-OFFSET-BASE", phase_offset)
print phase_set
if (ampli_set == 'True'):
amplitude_scale = caget(station + "-RSYS:SET-VSUM-AMPLT-SCALE-CALC")
caput(station + "-RSYS:SET-VSUM-AMPLT-SCALE", amplitude_scale)
print ampli_set
if (power_set == 'True'):
power_scale = caget(station + "-RSYS:SET-VOLT-POWER-SCALE-CALC")
caput(station + "-RSYS:SET-VOLT-POWER-SCALE", power_scale)
print power_set
caput(station + "-RSYS:CMD-LOAD-CALIB-BEAM", 1)
+7 -1
View File
@@ -415,6 +415,12 @@ def bsget(channel):
return st.getValue(channel)
finally:
st.close()
#Machine utilities
def is_timing_ok():
return caget("SIN-TIMAST-TMA:SOS-COUNT-CHECK") == 0
def get_repetition_rate():
return caget("SIN-TIMAST-TMA:Evt-15-Freq-I")
+23 -5
View File
@@ -1,14 +1,32 @@
import ch.psi.pshell.imaging.Data as Data
d = load_data("2017/06/16/20170616_122305_snapshot.h5|/data")
atts = get_attributes("2017/06/16/20170616_122305_snapshot.h5|/data")
path = "2017/06/16/20170616_122305_snapshot.h5|/data"
path = "2017/06/19/20170619_113633_snapshot.h5|/data"
path = "2017/06/19/20170619_114839_snapshot.h5|/data"
path = "2017/06/19/20170619_115340_snapshot.h5|/data"
path = "2017/06/19/20170619_120203_snapshot.h5|/data"
path = "2017/06/19/20170619_141032_snapshot.h5|/data"
path = "2017/06/19/20170619_141203_snapshot.h5|/data"
path = "2017/06/19/20170619_142222_snapshot.h5|/data"
path = "2017/06/19/20170619_142310_snapshot.h5|/data"
path = "2017/06/19/20170619_142826_snapshot.h5|/data"
path = "2017/06/19/20170619_142836_snapshot.h5|/data"
path = "2017/06/19/20170619_144625_snapshot.h5|/data"
d = load_data(path)
atts = get_attributes(path)
data = Data(d)
iv = data.integrateVertically(False)
ih = data.integrateHorizontally(False)
xp = atts["x_profile"]
yp = atts["y_profile"]
p1, p2 = plot([xp, yp], ["X profile", "Y profile"])
p1.addSeries(LinePlotSeries("d"))
p2.addSeries(LinePlotSeries("d"))
p1.addSeries(LinePlotSeries("data X"))
p2.addSeries(LinePlotSeries("data Y"))
p1.getSeries(1).setData(iv)
p2.getSeries(1).setData(ih)
p2.getSeries(1).setData(ih)
p1.addSeries(LinePlotSeries("error X", None, 2))
p2.addSeries(LinePlotSeries("error Y", None, 2))
p1.getSeries(2).setData(arrsub(xp,iv))
p2.getSeries(2).setData(arrsub(yp,ih))
+1 -1
View File
@@ -3,7 +3,7 @@ import ch.psi.pshell.bs.Scalar as Scalar
import ch.psi.pshell.bs.Waveform as Waveform
dispatcher.config.disableCompression = False
dispatcher.config.disableCompression = True
set_exec_pars(persist = False)
#Arguments
+1 -1
View File
@@ -13,7 +13,7 @@ st1.addScalar("mcpu", "SINDI01-RLLE-STA:MASTER-CPUTIMER", 10, 0)
st1.addWaveform("amp", "SINDI01-RCIR-PUP10:SIG-AMPLT", 10, 0)
st1.initialize()
#st1.start(True)
st1.start(True)
class PseudoPositioner(Writable):