Commit 46292639 authored by Andrey Filippov's avatar Andrey Filippov

Fixing old bug where sample coordinates did not match measured lens

center
parent 60e0334d
...@@ -45,13 +45,6 @@ import java.util.concurrent.atomic.AtomicInteger; ...@@ -45,13 +45,6 @@ import java.util.concurrent.atomic.AtomicInteger;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
//import FocusingField.FocusingFieldMeasurement; //import FocusingField.FocusingFieldMeasurement;
//import FocusingField.MeasuredSample; //import FocusingField.MeasuredSample;
import Jama.Matrix; // Download here: http://math.nist.gov/javanumerics/jama/ import Jama.Matrix; // Download here: http://math.nist.gov/javanumerics/jama/
...@@ -3441,6 +3434,21 @@ if (MORE_BUTTONS) { ...@@ -3441,6 +3434,21 @@ if (MORE_BUTTONS) {
return; return;
} }
double [][][][][] rFullResults=new double [1][][][][]; double [][][][][] rFullResults=new double [1][][][][];
double [][][] sampleCoord=null;
double pX0;
double pY0;
if (FOCUSING_FIELD!=null){
sampleCoord=FOCUSING_FIELD.getSampleCoord();
pX0=FOCUSING_FIELD.pX0_distortions;
pY0=FOCUSING_FIELD.pY0_distortions;
} else {
pX0=FOCUS_MEASUREMENT_PARAMETERS.result_PX0;
pY0=FOCUS_MEASUREMENT_PARAMETERS.result_PY0;
sampleCoord=FOCUS_MEASUREMENT_PARAMETERS.sampleCoordinates(
pX0,
pY0);
}
double [][] metrics=measurePSFMetrics( double [][] metrics=measurePSFMetrics(
imp_sel, imp_sel,
LENS_DISTORTION_PARAMETERS, LENS_DISTORTION_PARAMETERS,
...@@ -3452,6 +3460,7 @@ if (MORE_BUTTONS) { ...@@ -3452,6 +3460,7 @@ if (MORE_BUTTONS) {
COMPONENTS, COMPONENTS,
OTF_FILTER, OTF_FILTER,
PSF_PARS, PSF_PARS,
sampleCoord,
rFullResults, rFullResults,
THREADS_MAX, THREADS_MAX,
UPDATE_STATUS, UPDATE_STATUS,
...@@ -3481,6 +3490,8 @@ if (MORE_BUTTONS) { ...@@ -3481,6 +3490,8 @@ if (MORE_BUTTONS) {
IJ.showMessage("Error","Image with selection is required"); IJ.showMessage("Error","Image with selection is required");
return; return;
} }
Rectangle oldWOI=FOCUS_MEASUREMENT_PARAMETERS.margins;
System.out.println("Old WOI="+oldWOI);
FOCUS_MEASUREMENT_PARAMETERS.margins=imp_sel.getRoi().getBounds(); FOCUS_MEASUREMENT_PARAMETERS.margins=imp_sel.getRoi().getBounds();
return; return;
} }
...@@ -3732,6 +3743,12 @@ if (MORE_BUTTONS) { ...@@ -3732,6 +3743,12 @@ if (MORE_BUTTONS) {
FOCUS_MEASUREMENT_PARAMETERS.result_PY0=camPars.eyesisSubCameras[stationNumber][0].py0; FOCUS_MEASUREMENT_PARAMETERS.result_PY0=camPars.eyesisSubCameras[stationNumber][0].py0;
FOCUS_MEASUREMENT_PARAMETERS.result_PSI=-camPars.eyesisSubCameras[stationNumber][0].psi; // "-" to show the current rotation (error), not where to rotate to correct FOCUS_MEASUREMENT_PARAMETERS.result_PSI=-camPars.eyesisSubCameras[stationNumber][0].psi; // "-" to show the current rotation (error), not where to rotate to correct
FOCUS_MEASUREMENT_PARAMETERS.result_FocalLength=camPars.eyesisSubCameras[stationNumber][0].focalLength; FOCUS_MEASUREMENT_PARAMETERS.result_FocalLength=camPars.eyesisSubCameras[stationNumber][0].focalLength;
// Update calcualted LENS_DISTORTION_PARAMETERS - especially px0, py0 - they were used to generate samples (not anymore)
LENS_DISTORTION_PARAMETERS.setIntrincicFromSubcamera(camPars.eyesisSubCameras[stationNumber][0]);
// Use rotation from head lasers // Use rotation from head lasers
if (FOCUS_MEASUREMENT_PARAMETERS.useHeadLasers){ if (FOCUS_MEASUREMENT_PARAMETERS.useHeadLasers){
psi=-headPointersTilt; // "-" - correction, instead of the target tilt psi=-headPointersTilt; // "-" - correction, instead of the target tilt
...@@ -3938,6 +3955,21 @@ if (MORE_BUTTONS) { ...@@ -3938,6 +3955,21 @@ if (MORE_BUTTONS) {
MOTORS.setDebug(FOCUS_MEASUREMENT_PARAMETERS.motorDebug); MOTORS.setDebug(FOCUS_MEASUREMENT_PARAMETERS.motorDebug);
// int historyFrom=MOTORS.historySize()-1; // before scanning // int historyFrom=MOTORS.historySize()-1; // before scanning
int historyFrom=MOTORS.historySize(); // first during scanning (not yet exist) int historyFrom=MOTORS.historySize(); // first during scanning (not yet exist)
double [][][] sampleCoord=null;
double pX0;
double pY0;
if (FOCUSING_FIELD!=null){
sampleCoord=FOCUSING_FIELD.getSampleCoord();
pX0=FOCUSING_FIELD.pX0_distortions;
pY0=FOCUSING_FIELD.pY0_distortions;
} else {
pX0=FOCUS_MEASUREMENT_PARAMETERS.result_PX0;
pY0=FOCUS_MEASUREMENT_PARAMETERS.result_PY0;
sampleCoord=FOCUS_MEASUREMENT_PARAMETERS.sampleCoordinates(
pX0,
pY0);
}
double[] range= ScanFocus( double[] range= ScanFocus(
null, // center at current position null, // center at current position
MOTORS, MOTORS,
...@@ -3951,6 +3983,7 @@ if (MORE_BUTTONS) { ...@@ -3951,6 +3983,7 @@ if (MORE_BUTTONS) {
COMPONENTS, COMPONENTS,
OTF_FILTER, OTF_FILTER,
PSF_PARS, PSF_PARS,
sampleCoord,
THREADS_MAX, THREADS_MAX,
UPDATE_STATUS, UPDATE_STATUS,
MASTER_DEBUG_LEVEL, MASTER_DEBUG_LEVEL,
...@@ -4016,6 +4049,7 @@ if (MORE_BUTTONS) { ...@@ -4016,6 +4049,7 @@ if (MORE_BUTTONS) {
COMPONENTS, COMPONENTS,
OTF_FILTER, OTF_FILTER,
PSF_PARS, PSF_PARS,
sampleCoord,
THREADS_MAX, THREADS_MAX,
UPDATE_STATUS, UPDATE_STATUS,
MASTER_DEBUG_LEVEL, MASTER_DEBUG_LEVEL,
...@@ -4031,6 +4065,14 @@ if (MORE_BUTTONS) { ...@@ -4031,6 +4065,14 @@ if (MORE_BUTTONS) {
if (!FOCUS_MEASUREMENT_PARAMETERS.showScanningSetup("Setup scanning parameters for LMA")) return; if (!FOCUS_MEASUREMENT_PARAMETERS.showScanningSetup("Setup scanning parameters for LMA")) return;
MOTORS.setHysteresis(FOCUS_MEASUREMENT_PARAMETERS.motorHysteresis); MOTORS.setHysteresis(FOCUS_MEASUREMENT_PARAMETERS.motorHysteresis);
MOTORS.setDebug(FOCUS_MEASUREMENT_PARAMETERS.motorDebug); MOTORS.setDebug(FOCUS_MEASUREMENT_PARAMETERS.motorDebug);
// FOCUSING_FIELD=null;
// Here re-generate measurement sample coordinates, in other places - try to use existent
double pX0=FOCUS_MEASUREMENT_PARAMETERS.result_PX0;
double pY0=FOCUS_MEASUREMENT_PARAMETERS.result_PY0;
double [][][] sampleCoord=FOCUS_MEASUREMENT_PARAMETERS.sampleCoordinates(
pX0,
pY0);
double[] range= ScanFocusTilt( double[] range= ScanFocusTilt(
null, // center at current position null, // center at current position
MOTORS, MOTORS,
...@@ -4044,6 +4086,7 @@ if (MORE_BUTTONS) { ...@@ -4044,6 +4086,7 @@ if (MORE_BUTTONS) {
COMPONENTS, COMPONENTS,
OTF_FILTER, OTF_FILTER,
PSF_PARS, PSF_PARS,
sampleCoord,
THREADS_MAX, THREADS_MAX,
UPDATE_STATUS, UPDATE_STATUS,
MASTER_DEBUG_LEVEL, MASTER_DEBUG_LEVEL,
...@@ -4054,12 +4097,6 @@ if (MORE_BUTTONS) { ...@@ -4054,12 +4097,6 @@ if (MORE_BUTTONS) {
IJ.showMessage(msg); IJ.showMessage(msg);
return; return;
} }
double pX0=FOCUS_MEASUREMENT_PARAMETERS.result_PX0;
double pY0=FOCUS_MEASUREMENT_PARAMETERS.result_PY0;
double [][][] sampleCoord=FOCUS_MEASUREMENT_PARAMETERS.sampleCoordinates( //{x,y,r}
pX0, // lens center on the sensor
pY0);
// set file path // set file path
String path=null; String path=null;
String dir=getResultsPath(FOCUS_MEASUREMENT_PARAMETERS); String dir=getResultsPath(FOCUS_MEASUREMENT_PARAMETERS);
...@@ -4154,6 +4191,23 @@ if (MORE_BUTTONS) { ...@@ -4154,6 +4191,23 @@ if (MORE_BUTTONS) {
IJ.showMessage("LENS_DISTORTION_PARAMETERS is not set"); IJ.showMessage("LENS_DISTORTION_PARAMETERS is not set");
return; return;
} }
double [][][] sampleCoord=null;
double pX0;
double pY0;
if (FOCUSING_FIELD!=null){
sampleCoord=FOCUSING_FIELD.getSampleCoord();
pX0=FOCUSING_FIELD.pX0_distortions;
pY0=FOCUSING_FIELD.pY0_distortions;
} else {
pX0=FOCUS_MEASUREMENT_PARAMETERS.result_PX0;
pY0=FOCUS_MEASUREMENT_PARAMETERS.result_PY0;
sampleCoord=FOCUS_MEASUREMENT_PARAMETERS.sampleCoordinates(
pX0,
pY0);
}
int mode=autoMove? (FOCUS_MEASUREMENT_PARAMETERS.confirmFirstAuto?2:3):1; int mode=autoMove? (FOCUS_MEASUREMENT_PARAMETERS.confirmFirstAuto?2:3):1;
if (fineFocus) mode=FOCUS_MEASUREMENT_PARAMETERS.confirmFirstAuto?4:5; if (fineFocus) mode=FOCUS_MEASUREMENT_PARAMETERS.confirmFirstAuto?4:5;
int [] newPos=null; int [] newPos=null;
...@@ -4174,6 +4228,7 @@ if (MORE_BUTTONS) { ...@@ -4174,6 +4228,7 @@ if (MORE_BUTTONS) {
COMPONENTS, COMPONENTS,
OTF_FILTER, OTF_FILTER,
PSF_PARS, PSF_PARS,
sampleCoord,
THREADS_MAX, THREADS_MAX,
UPDATE_STATUS, UPDATE_STATUS,
MASTER_DEBUG_LEVEL, MASTER_DEBUG_LEVEL,
...@@ -4200,6 +4255,7 @@ if (MORE_BUTTONS) { ...@@ -4200,6 +4255,7 @@ if (MORE_BUTTONS) {
COMPONENTS, COMPONENTS,
OTF_FILTER, OTF_FILTER,
PSF_PARS, PSF_PARS,
sampleCoord,
THREADS_MAX, THREADS_MAX,
UPDATE_STATUS, UPDATE_STATUS,
MASTER_DEBUG_LEVEL, MASTER_DEBUG_LEVEL,
...@@ -4238,6 +4294,7 @@ if (MORE_BUTTONS) { ...@@ -4238,6 +4294,7 @@ if (MORE_BUTTONS) {
COMPONENTS, COMPONENTS,
OTF_FILTER, OTF_FILTER,
PSF_PARS, PSF_PARS,
sampleCoord,
THREADS_MAX, THREADS_MAX,
UPDATE_STATUS, UPDATE_STATUS,
MASTER_DEBUG_LEVEL, MASTER_DEBUG_LEVEL,
...@@ -4270,6 +4327,7 @@ if (MORE_BUTTONS) { ...@@ -4270,6 +4327,7 @@ if (MORE_BUTTONS) {
COMPONENTS, COMPONENTS,
OTF_FILTER, OTF_FILTER,
PSF_PARS, PSF_PARS,
sampleCoord,
THREADS_MAX, THREADS_MAX,
UPDATE_STATUS, UPDATE_STATUS,
MASTER_DEBUG_LEVEL, MASTER_DEBUG_LEVEL,
...@@ -4345,7 +4403,21 @@ if (MORE_BUTTONS) { ...@@ -4345,7 +4403,21 @@ if (MORE_BUTTONS) {
FOCUS_MEASUREMENT_PARAMETERS, FOCUS_MEASUREMENT_PARAMETERS,
MOTORS.getMicronsPerStep(), //double micronsPerStep, MOTORS.getMicronsPerStep(), //double micronsPerStep,
DEBUG_LEVEL); DEBUG_LEVEL);
double [][][] sampleCoord=null;
double pX0;
double pY0;
if (FOCUSING_FIELD!=null){
sampleCoord=FOCUSING_FIELD.getSampleCoord();
pX0=FOCUSING_FIELD.pX0_distortions;
pY0=FOCUSING_FIELD.pY0_distortions;
} else {
pX0=FOCUS_MEASUREMENT_PARAMETERS.result_PX0;
pY0=FOCUS_MEASUREMENT_PARAMETERS.result_PY0;
sampleCoord=FOCUS_MEASUREMENT_PARAMETERS.sampleCoordinates(
pX0,
pY0);
}
moveAndMaybeProbe( moveAndMaybeProbe(
false, false,
MOTORS.readElphel10364Motors().clone(), // null OK MOTORS.readElphel10364Motors().clone(), // null OK
...@@ -4360,6 +4432,7 @@ if (MORE_BUTTONS) { ...@@ -4360,6 +4432,7 @@ if (MORE_BUTTONS) {
COMPONENTS, COMPONENTS,
OTF_FILTER, OTF_FILTER,
PSF_PARS, PSF_PARS,
sampleCoord,
THREADS_MAX, THREADS_MAX,
UPDATE_STATUS, UPDATE_STATUS,
MASTER_DEBUG_LEVEL+1, MASTER_DEBUG_LEVEL+1,
...@@ -4387,6 +4460,10 @@ if (MORE_BUTTONS) { ...@@ -4387,6 +4460,10 @@ if (MORE_BUTTONS) {
DEBUG_LEVEL=MASTER_DEBUG_LEVEL; DEBUG_LEVEL=MASTER_DEBUG_LEVEL;
double pX0=FOCUS_MEASUREMENT_PARAMETERS.result_PX0; double pX0=FOCUS_MEASUREMENT_PARAMETERS.result_PX0;
double pY0=FOCUS_MEASUREMENT_PARAMETERS.result_PY0; double pY0=FOCUS_MEASUREMENT_PARAMETERS.result_PY0;
// temporary - for generating correction files
// pX0=LENS_DISTORTION_PARAMETERS.px0; // pixel coordinate of the the optical center
// pY0=LENS_DISTORTION_PARAMETERS.py0; // pixel coordinate of the the optical center
double [][][] sampleCoord=FOCUS_MEASUREMENT_PARAMETERS.sampleCoordinates( //{x,y,r} double [][][] sampleCoord=FOCUS_MEASUREMENT_PARAMETERS.sampleCoordinates( //{x,y,r}
pX0, // lens center on the sensor pX0, // lens center on the sensor
pY0); pY0);
...@@ -4522,7 +4599,7 @@ if (MORE_BUTTONS) { ...@@ -4522,7 +4599,7 @@ if (MORE_BUTTONS) {
FOCUSING_FIELD.LevenbergMarquardt( FOCUSING_FIELD.LevenbergMarquardt(
null, // measurement null, // measurement
true, // open dialog true, // open dialog
// false, // filterZ true,// boolean autoSel,
DEBUG_LEVEL); //boolean openDialog, int debugLevel){ DEBUG_LEVEL); //boolean openDialog, int debugLevel){
return; return;
} }
...@@ -4690,6 +4767,21 @@ if (MORE_BUTTONS) { ...@@ -4690,6 +4767,21 @@ if (MORE_BUTTONS) {
if (MASTER_DEBUG_LEVEL>0) System.out.println("Measured hysteresis is "+measuredHysteresis+" steps, configured hysteresis is set to "+ if (MASTER_DEBUG_LEVEL>0) System.out.println("Measured hysteresis is "+measuredHysteresis+" steps, configured hysteresis is set to "+
FOCUS_MEASUREMENT_PARAMETERS.motorHysteresis+" motor steps"); FOCUS_MEASUREMENT_PARAMETERS.motorHysteresis+" motor steps");
} }
double [][][] sampleCoord=null;
double pX0;
double pY0;
if (FOCUSING_FIELD!=null){
sampleCoord=FOCUSING_FIELD.getSampleCoord();
pX0=FOCUSING_FIELD.pX0_distortions;
pY0=FOCUSING_FIELD.pY0_distortions;
} else {
pX0=FOCUS_MEASUREMENT_PARAMETERS.result_PX0;
pY0=FOCUS_MEASUREMENT_PARAMETERS.result_PY0;
sampleCoord=FOCUS_MEASUREMENT_PARAMETERS.sampleCoordinates(
pX0,
pY0);
}
if (FOCUS_MEASUREMENT_PARAMETERS.lensDistanceMoveToGoal && (newPos!=null)){ if (FOCUS_MEASUREMENT_PARAMETERS.lensDistanceMoveToGoal && (newPos!=null)){
moveAndMaybeProbe( moveAndMaybeProbe(
...@@ -4706,6 +4798,7 @@ if (MORE_BUTTONS) { ...@@ -4706,6 +4798,7 @@ if (MORE_BUTTONS) {
COMPONENTS, COMPONENTS,
OTF_FILTER, OTF_FILTER,
PSF_PARS, PSF_PARS,
sampleCoord,
THREADS_MAX, THREADS_MAX,
UPDATE_STATUS, UPDATE_STATUS,
MASTER_DEBUG_LEVEL, MASTER_DEBUG_LEVEL,
...@@ -5043,6 +5136,15 @@ if (MORE_BUTTONS) { ...@@ -5043,6 +5136,15 @@ if (MORE_BUTTONS) {
return; return;
} }
} }
double [][][] sampleCoord=null;
if (FOCUSING_FIELD!=null){
sampleCoord=FOCUSING_FIELD.getSampleCoord();
} else {
sampleCoord=FOCUS_MEASUREMENT_PARAMETERS.sampleCoordinates(
FOCUS_MEASUREMENT_PARAMETERS.result_PX0,
FOCUS_MEASUREMENT_PARAMETERS.result_PY0);
}
MOTORS.focusingHistory.optimalMotorPosition( // recalculate calibration to estimate current distance from center PSF MOTORS.focusingHistory.optimalMotorPosition( // recalculate calibration to estimate current distance from center PSF
FOCUS_MEASUREMENT_PARAMETERS, FOCUS_MEASUREMENT_PARAMETERS,
MOTORS.getMicronsPerStep(), //double micronsPerStep, MOTORS.getMicronsPerStep(), //double micronsPerStep,
...@@ -5061,6 +5163,7 @@ if (MORE_BUTTONS) { ...@@ -5061,6 +5163,7 @@ if (MORE_BUTTONS) {
COMPONENTS, COMPONENTS,
OTF_FILTER, OTF_FILTER,
PSF_PARS, PSF_PARS,
sampleCoord,
THREADS_MAX, THREADS_MAX,
UPDATE_STATUS, UPDATE_STATUS,
MASTER_DEBUG_LEVEL, MASTER_DEBUG_LEVEL,
...@@ -5090,7 +5193,7 @@ if (MORE_BUTTONS) { ...@@ -5090,7 +5193,7 @@ if (MORE_BUTTONS) {
gd.addCheckbox("Erase previous measurement history",modeAverage); gd.addCheckbox("Erase previous measurement history",modeAverage);
gd.addCheckbox("Allow tilt scan when looking for the best fit",!noTiltScan); gd.addCheckbox("Allow tilt scan when looking for the best fit",!noTiltScan);
gd.addCheckbox("Use LMA calculations for focus/tilt",useLMA); gd.addCheckbox("Use LMA calculations for focus/tilt",useLMA);
double scanMinutes=modeAverage?1.0:30.0; double scanMinutes=modeAverage?2.0:30.0;
gd.addNumericField("Measure for ", scanMinutes , 1,5," minutes"); gd.addNumericField("Measure for ", scanMinutes , 1,5," minutes");
gd.showDialog(); gd.showDialog();
if (gd.wasCanceled()) return; if (gd.wasCanceled()) return;
...@@ -5108,9 +5211,22 @@ if (MORE_BUTTONS) { ...@@ -5108,9 +5211,22 @@ if (MORE_BUTTONS) {
long endTime=startTime+(long) (6E10*scanMinutes); long endTime=startTime+(long) (6E10*scanMinutes);
if (MASTER_DEBUG_LEVEL>0) System.out.println(" startTime= "+startTime+", endTime="+endTime); if (MASTER_DEBUG_LEVEL>0) System.out.println(" startTime= "+startTime+", endTime="+endTime);
int runs=0; int runs=0;
while (System.nanoTime()<endTime){ double [][][] sampleCoord=null;
double pX0;
double pY0;
if (FOCUSING_FIELD!=null){
sampleCoord=FOCUSING_FIELD.getSampleCoord();
pX0=FOCUSING_FIELD.pX0_distortions;
pY0=FOCUSING_FIELD.pY0_distortions;
} else {
pX0=FOCUS_MEASUREMENT_PARAMETERS.result_PX0;
pY0=FOCUS_MEASUREMENT_PARAMETERS.result_PY0;
sampleCoord=FOCUS_MEASUREMENT_PARAMETERS.sampleCoordinates(
pX0,
pY0);
}
while (System.nanoTime()<endTime){
moveAndMaybeProbe( moveAndMaybeProbe(
true, // just move, not probe true, // just move, not probe
null, // no move, just measure null, // no move, just measure
...@@ -5125,6 +5241,7 @@ if (MORE_BUTTONS) { ...@@ -5125,6 +5241,7 @@ if (MORE_BUTTONS) {
COMPONENTS, COMPONENTS,
OTF_FILTER, OTF_FILTER,
PSF_PARS, PSF_PARS,
sampleCoord,
THREADS_MAX, THREADS_MAX,
UPDATE_STATUS, UPDATE_STATUS,
MASTER_DEBUG_LEVEL, MASTER_DEBUG_LEVEL,
...@@ -5141,11 +5258,6 @@ if (MORE_BUTTONS) { ...@@ -5141,11 +5258,6 @@ if (MORE_BUTTONS) {
} }
// LMA version // LMA version
double pX0=FOCUS_MEASUREMENT_PARAMETERS.result_PX0;
double pY0=FOCUS_MEASUREMENT_PARAMETERS.result_PY0;
double [][][] sampleCoord=FOCUS_MEASUREMENT_PARAMETERS.sampleCoordinates( //{x,y,r}
pX0, // lens center on the sensor
pY0);
FocusingField ff= null; FocusingField ff= null;
if (useLMA){ if (useLMA){
ff= new FocusingField( ff= new FocusingField(
...@@ -8882,7 +8994,16 @@ if (MORE_BUTTONS) { ...@@ -8882,7 +8994,16 @@ if (MORE_BUTTONS) {
MOTORS.getMicronsPerStep(), //double micronsPerStep, MOTORS.getMicronsPerStep(), //double micronsPerStep,
DEBUG_LEVEL); DEBUG_LEVEL);
*/ */
double [][][] sampleCoord=null;
if (FOCUSING_FIELD!=null){
sampleCoord=FOCUSING_FIELD.getSampleCoord();
} else {
sampleCoord=FOCUS_MEASUREMENT_PARAMETERS.sampleCoordinates(
FOCUS_MEASUREMENT_PARAMETERS.result_PX0,
FOCUS_MEASUREMENT_PARAMETERS.result_PY0);
}
// No-move measure, add to history // No-move measure, add to history
moveAndMaybeProbe( moveAndMaybeProbe(
true, // just move, not probe true, // just move, not probe
null, // no move, just measure null, // no move, just measure
...@@ -8897,6 +9018,7 @@ if (MORE_BUTTONS) { ...@@ -8897,6 +9018,7 @@ if (MORE_BUTTONS) {
COMPONENTS, COMPONENTS,
OTF_FILTER, OTF_FILTER,
PSF_PARS, PSF_PARS,
sampleCoord,
THREADS_MAX, THREADS_MAX,
UPDATE_STATUS, UPDATE_STATUS,
MASTER_DEBUG_LEVEL, MASTER_DEBUG_LEVEL,
...@@ -9354,6 +9476,7 @@ if (MORE_BUTTONS) { ...@@ -9354,6 +9476,7 @@ if (MORE_BUTTONS) {
EyesisAberrations.ColorComponents colorComponents, EyesisAberrations.ColorComponents colorComponents,
EyesisAberrations.OTFFilterParameters otfFilterParameters, EyesisAberrations.OTFFilterParameters otfFilterParameters,
EyesisAberrations.PSFParameters psfParameters, EyesisAberrations.PSFParameters psfParameters,
double [][][] sampleCoord, // restored from history or null - will create old way
int threadsMax, int threadsMax,
boolean updateStatus, boolean updateStatus,
int debugLevel, int debugLevel,
...@@ -9377,6 +9500,7 @@ if (MORE_BUTTONS) { ...@@ -9377,6 +9500,7 @@ if (MORE_BUTTONS) {
colorComponents, colorComponents,
otfFilterParameters, otfFilterParameters,
psfParameters, psfParameters,
sampleCoord, // restored from history or null - will create old way
threadsMax, threadsMax,
updateStatus, updateStatus,
debugLevel, debugLevel,
...@@ -9414,6 +9538,7 @@ if (MORE_BUTTONS) { ...@@ -9414,6 +9538,7 @@ if (MORE_BUTTONS) {
colorComponents, colorComponents,
otfFilterParameters, otfFilterParameters,
psfParameters, psfParameters,
sampleCoord, // restored from history or null - will create old way
threadsMax, threadsMax,
updateStatus, updateStatus,
debugLevel, debugLevel,
...@@ -9453,6 +9578,7 @@ if (MORE_BUTTONS) { ...@@ -9453,6 +9578,7 @@ if (MORE_BUTTONS) {
EyesisAberrations.ColorComponents colorComponents, EyesisAberrations.ColorComponents colorComponents,
EyesisAberrations.OTFFilterParameters otfFilterParameters, EyesisAberrations.OTFFilterParameters otfFilterParameters,
EyesisAberrations.PSFParameters psfParameters, EyesisAberrations.PSFParameters psfParameters,
double [][][] sampleCoord, // restored from history or null - will create old way
int threadsMax, int threadsMax,
boolean updateStatus, boolean updateStatus,
int debugLevel, int debugLevel,
...@@ -9496,6 +9622,7 @@ if (MORE_BUTTONS) { ...@@ -9496,6 +9622,7 @@ if (MORE_BUTTONS) {
colorComponents, colorComponents,
otfFilterParameters, otfFilterParameters,
psfParameters, psfParameters,
sampleCoord, // restored from history or null - will create old way
threadsMax, threadsMax,
updateStatus, updateStatus,
debugLevel, debugLevel,
...@@ -9596,6 +9723,7 @@ if (MORE_BUTTONS) { ...@@ -9596,6 +9723,7 @@ if (MORE_BUTTONS) {
colorComponents, colorComponents,
otfFilterParameters, otfFilterParameters,
psfParameters, psfParameters,
sampleCoord, // restored from history or null - will create old way
threadsMax, threadsMax,
updateStatus, updateStatus,
debugLevel, debugLevel,
...@@ -9640,6 +9768,7 @@ if (MORE_BUTTONS) { ...@@ -9640,6 +9768,7 @@ if (MORE_BUTTONS) {
EyesisAberrations.ColorComponents colorComponents, EyesisAberrations.ColorComponents colorComponents,
EyesisAberrations.OTFFilterParameters otfFilterParameters, EyesisAberrations.OTFFilterParameters otfFilterParameters,
EyesisAberrations.PSFParameters psfParameters, EyesisAberrations.PSFParameters psfParameters,
double [][][] sampleCoord, // restored from history or null - will create old way
int threadsMax, int threadsMax,
boolean updateStatus, boolean updateStatus,
int debugLevel, int debugLevel,
...@@ -9677,6 +9806,7 @@ if (MORE_BUTTONS) { ...@@ -9677,6 +9806,7 @@ if (MORE_BUTTONS) {
colorComponents, colorComponents,
otfFilterParameters, otfFilterParameters,
psfParameters, psfParameters,
sampleCoord, // restored from history or null - will create old way
threadsMax, threadsMax,
updateStatus, updateStatus,
debugLevel, debugLevel,
...@@ -9745,6 +9875,7 @@ if (MORE_BUTTONS) { ...@@ -9745,6 +9875,7 @@ if (MORE_BUTTONS) {
colorComponents, colorComponents,
otfFilterParameters, otfFilterParameters,
psfParameters, psfParameters,
sampleCoord, // restored from history or null - will create old way
threadsMax, threadsMax,
updateStatus, updateStatus,
debugLevel, debugLevel,
...@@ -9799,6 +9930,7 @@ if (MORE_BUTTONS) { ...@@ -9799,6 +9930,7 @@ if (MORE_BUTTONS) {
colorComponents, colorComponents,
otfFilterParameters, otfFilterParameters,
psfParameters, psfParameters,
sampleCoord, // restored from history or null - will create old way
threadsMax, threadsMax,
updateStatus, updateStatus,
debugLevel, debugLevel,
...@@ -9844,6 +9976,7 @@ if (MORE_BUTTONS) { ...@@ -9844,6 +9976,7 @@ if (MORE_BUTTONS) {
EyesisAberrations.ColorComponents colorComponents, EyesisAberrations.ColorComponents colorComponents,
EyesisAberrations.OTFFilterParameters otfFilterParameters, EyesisAberrations.OTFFilterParameters otfFilterParameters,
EyesisAberrations.PSFParameters psfParameters, EyesisAberrations.PSFParameters psfParameters,
double [][][] sampleCoord, // restored from history or null - will create old way
int threadsMax, int threadsMax,
boolean updateStatus, boolean updateStatus,
int debugLevel, int debugLevel,
...@@ -9864,6 +9997,7 @@ if (MORE_BUTTONS) { ...@@ -9864,6 +9997,7 @@ if (MORE_BUTTONS) {
colorComponents, colorComponents,
otfFilterParameters, otfFilterParameters,
psfParameters, psfParameters,
sampleCoord, // restored from history or null - will create old way
threadsMax, threadsMax,
updateStatus, updateStatus,
debugLevel, debugLevel,
...@@ -9914,6 +10048,7 @@ if (MORE_BUTTONS) { ...@@ -9914,6 +10048,7 @@ if (MORE_BUTTONS) {
colorComponents, colorComponents,
otfFilterParameters, otfFilterParameters,
psfParameters, psfParameters,
sampleCoord, // restored from history or null - will create old way
threadsMax, threadsMax,
updateStatus, updateStatus,
debugLevel, debugLevel,
...@@ -10024,6 +10159,7 @@ if (MORE_BUTTONS) { ...@@ -10024,6 +10159,7 @@ if (MORE_BUTTONS) {
EyesisAberrations.ColorComponents colorComponents, EyesisAberrations.ColorComponents colorComponents,
EyesisAberrations.OTFFilterParameters otfFilterParameters, EyesisAberrations.OTFFilterParameters otfFilterParameters,
EyesisAberrations.PSFParameters psfParameters, EyesisAberrations.PSFParameters psfParameters,
double [][][] sampleCoord, // restored from history or null - will create old way
int threadsMax, int threadsMax,
boolean updateStatus, boolean updateStatus,
int debugLevel, int debugLevel,
...@@ -10066,6 +10202,7 @@ if (MORE_BUTTONS) { ...@@ -10066,6 +10202,7 @@ if (MORE_BUTTONS) {
colorComponents, colorComponents,
otfFilterParameters, otfFilterParameters,
psfParameters, psfParameters,
sampleCoord, // restored from history or null - will create old way
threadsMax, threadsMax,
updateStatus, updateStatus,
debugLevel, debugLevel,
...@@ -10108,6 +10245,7 @@ if (MORE_BUTTONS) { ...@@ -10108,6 +10245,7 @@ if (MORE_BUTTONS) {
colorComponents, colorComponents,
otfFilterParameters, otfFilterParameters,
psfParameters, psfParameters,
sampleCoord, // restored from history or null - will create old way
threadsMax, threadsMax,
updateStatus, updateStatus,
debugLevel, debugLevel,
...@@ -10145,6 +10283,7 @@ if (MORE_BUTTONS) { ...@@ -10145,6 +10283,7 @@ if (MORE_BUTTONS) {
colorComponents, colorComponents,
otfFilterParameters, otfFilterParameters,
psfParameters, psfParameters,
sampleCoord, // restored from history or null - will create old way
threadsMax, threadsMax,
updateStatus, updateStatus,
debugLevel, debugLevel,
...@@ -10185,6 +10324,7 @@ if (MORE_BUTTONS) { ...@@ -10185,6 +10324,7 @@ if (MORE_BUTTONS) {
colorComponents, colorComponents,
otfFilterParameters, otfFilterParameters,
psfParameters, psfParameters,
sampleCoord, // restored from history or null - will create old way
threadsMax, threadsMax,
updateStatus, updateStatus,
debugLevel, debugLevel,
...@@ -10222,6 +10362,7 @@ if (MORE_BUTTONS) { ...@@ -10222,6 +10362,7 @@ if (MORE_BUTTONS) {
colorComponents, colorComponents,
otfFilterParameters, otfFilterParameters,
psfParameters, psfParameters,
sampleCoord, // restored from history or null - will create old way
threadsMax, threadsMax,
updateStatus, updateStatus,
debugLevel, debugLevel,
...@@ -10268,6 +10409,7 @@ if (MORE_BUTTONS) { ...@@ -10268,6 +10409,7 @@ if (MORE_BUTTONS) {
colorComponents, colorComponents,
otfFilterParameters, otfFilterParameters,
psfParameters, psfParameters,
sampleCoord, // restored from history or null - will create old way
threadsMax, threadsMax,
updateStatus, updateStatus,
debugLevel, debugLevel,
...@@ -10308,6 +10450,7 @@ if (MORE_BUTTONS) { ...@@ -10308,6 +10450,7 @@ if (MORE_BUTTONS) {
colorComponents, colorComponents,
otfFilterParameters, otfFilterParameters,
psfParameters, psfParameters,
sampleCoord, // restored from history or null - will create old way
threadsMax, threadsMax,
updateStatus, updateStatus,
debugLevel, debugLevel,
...@@ -10348,6 +10491,7 @@ if (MORE_BUTTONS) { ...@@ -10348,6 +10491,7 @@ if (MORE_BUTTONS) {
EyesisAberrations.ColorComponents colorComponents, EyesisAberrations.ColorComponents colorComponents,
EyesisAberrations.OTFFilterParameters otfFilterParameters, EyesisAberrations.OTFFilterParameters otfFilterParameters,
EyesisAberrations.PSFParameters psfParameters, EyesisAberrations.PSFParameters psfParameters,
double [][][] sampleCoord, // restored from history or null - will create old way
int threadsMax, int threadsMax,
boolean updateStatus, boolean updateStatus,
int debugLevel, int debugLevel,
...@@ -10396,6 +10540,7 @@ if (MORE_BUTTONS) { ...@@ -10396,6 +10540,7 @@ if (MORE_BUTTONS) {
colorComponents, colorComponents,
otfFilterParameters, otfFilterParameters,
psfParameters, psfParameters,
sampleCoord, // restored from history or null - will create old way
threadsMax, threadsMax,
updateStatus, updateStatus,
debugLevel, debugLevel,
...@@ -10426,6 +10571,7 @@ if (MORE_BUTTONS) { ...@@ -10426,6 +10571,7 @@ if (MORE_BUTTONS) {
colorComponents, colorComponents,
otfFilterParameters, otfFilterParameters,
psfParameters, psfParameters,
sampleCoord, // restored from history or null - will create old way
threadsMax, threadsMax,
updateStatus, updateStatus,
debugLevel, debugLevel,
...@@ -10447,6 +10593,7 @@ if (MORE_BUTTONS) { ...@@ -10447,6 +10593,7 @@ if (MORE_BUTTONS) {
colorComponents, colorComponents,
otfFilterParameters, otfFilterParameters,
psfParameters, psfParameters,
sampleCoord, // restored from history or null - will create old way
threadsMax, threadsMax,
updateStatus, updateStatus,
debugLevel, debugLevel,
...@@ -10474,6 +10621,7 @@ if (MORE_BUTTONS) { ...@@ -10474,6 +10621,7 @@ if (MORE_BUTTONS) {
EyesisAberrations.ColorComponents colorComponents, EyesisAberrations.ColorComponents colorComponents,
EyesisAberrations.OTFFilterParameters otfFilterParameters, EyesisAberrations.OTFFilterParameters otfFilterParameters,
EyesisAberrations.PSFParameters psfParameters, EyesisAberrations.PSFParameters psfParameters,
double [][][] sampleCoord, // restored from history or null - will create old way
int threadsMax, int threadsMax,
boolean updateStatus, boolean updateStatus,
int debugLevel, int debugLevel,
...@@ -10493,6 +10641,7 @@ if (MORE_BUTTONS) { ...@@ -10493,6 +10641,7 @@ if (MORE_BUTTONS) {
colorComponents, colorComponents,
otfFilterParameters, otfFilterParameters,
psfParameters, psfParameters,
sampleCoord, // restored from history or null - will create old way
threadsMax, threadsMax,
updateStatus, updateStatus,
debugLevel, debugLevel,
...@@ -10513,6 +10662,7 @@ if (MORE_BUTTONS) { ...@@ -10513,6 +10662,7 @@ if (MORE_BUTTONS) {
EyesisAberrations.ColorComponents colorComponents, EyesisAberrations.ColorComponents colorComponents,
EyesisAberrations.OTFFilterParameters otfFilterParameters, EyesisAberrations.OTFFilterParameters otfFilterParameters,
EyesisAberrations.PSFParameters psfParameters, EyesisAberrations.PSFParameters psfParameters,
double [][][] sampleCoord, // restored from history or null - will create old way
int threadsMax, int threadsMax,
boolean updateStatus, boolean updateStatus,
int debugLevel, int debugLevel,
...@@ -10597,6 +10747,7 @@ if (MORE_BUTTONS) { ...@@ -10597,6 +10747,7 @@ if (MORE_BUTTONS) {
colorComponents, colorComponents,
otfFilterParameters, otfFilterParameters,
psfParameters, psfParameters,
sampleCoord, // restored from history or null - will create old way
rFullResults, rFullResults,
threadsMax, threadsMax,
updateStatus, updateStatus,
...@@ -10677,6 +10828,7 @@ if (MORE_BUTTONS) { ...@@ -10677,6 +10828,7 @@ if (MORE_BUTTONS) {
EyesisAberrations.ColorComponents colorComponents, EyesisAberrations.ColorComponents colorComponents,
EyesisAberrations.OTFFilterParameters otfFilterParameters, EyesisAberrations.OTFFilterParameters otfFilterParameters,
EyesisAberrations.PSFParameters psfParameters, EyesisAberrations.PSFParameters psfParameters,
double [][][] sampleCoord, // restored from history or null - will create old way
int threadsMax, int threadsMax,
boolean updateStatus, boolean updateStatus,
int debugLevel, int debugLevel,
...@@ -10707,6 +10859,7 @@ if (MORE_BUTTONS) { ...@@ -10707,6 +10859,7 @@ if (MORE_BUTTONS) {
colorComponents, colorComponents,
otfFilterParameters, otfFilterParameters,
psfParameters, psfParameters,
sampleCoord, // restored from history or null - will create old way
threadsMax, threadsMax,
updateStatus, updateStatus,
1, //debugLevel, 1, //debugLevel,
...@@ -10745,6 +10898,7 @@ if (MORE_BUTTONS) { ...@@ -10745,6 +10898,7 @@ if (MORE_BUTTONS) {
colorComponents, colorComponents,
otfFilterParameters, otfFilterParameters,
psfParameters, psfParameters,
sampleCoord, // restored from history or null - will create old way
threadsMax, threadsMax,
updateStatus, updateStatus,
debugLevel, //debugLevel, // 1, debugLevel, //debugLevel, // 1,
...@@ -10768,6 +10922,7 @@ if (MORE_BUTTONS) { ...@@ -10768,6 +10922,7 @@ if (MORE_BUTTONS) {
EyesisAberrations.ColorComponents colorComponents, EyesisAberrations.ColorComponents colorComponents,
EyesisAberrations.OTFFilterParameters otfFilterParameters, EyesisAberrations.OTFFilterParameters otfFilterParameters,
EyesisAberrations.PSFParameters psfParameters, EyesisAberrations.PSFParameters psfParameters,
double [][][] sampleCoord, // restored from history or null - will create old way
int threadsMax, int threadsMax,
boolean updateStatus, boolean updateStatus,
int debugLevel, int debugLevel,
...@@ -10805,7 +10960,7 @@ if (MORE_BUTTONS) { ...@@ -10805,7 +10960,7 @@ if (MORE_BUTTONS) {
throw new IllegalArgumentException (msg); throw new IllegalArgumentException (msg);
} }
matchSimulatedPattern.debugLevel=debugLevel; matchSimulatedPattern.debugLevel=debugLevel;
if (debugLevel>2){ if (debugLevel>1){
System.out.println("Samples Map:\n"+ System.out.println("Samples Map:\n"+
focusMeasurementParameters.showSamplesMap( focusMeasurementParameters.showSamplesMap(
lensDistortionParameters.px0, // pixel coordinate of the the optical center lensDistortionParameters.px0, // pixel coordinate of the the optical center
...@@ -10824,6 +10979,7 @@ if (MORE_BUTTONS) { ...@@ -10824,6 +10979,7 @@ if (MORE_BUTTONS) {
colorComponents, colorComponents,
otfFilterParameters, otfFilterParameters,
psfParameters, psfParameters,
sampleCoord, // restored from history or null - will create old way
rFullResults, rFullResults,
threadsMax, threadsMax,
updateStatus, updateStatus,
...@@ -10960,6 +11116,7 @@ if (MORE_BUTTONS) { ...@@ -10960,6 +11116,7 @@ if (MORE_BUTTONS) {
EyesisAberrations.ColorComponents colorComponents, EyesisAberrations.ColorComponents colorComponents,
EyesisAberrations.OTFFilterParameters otfFilterParameters, EyesisAberrations.OTFFilterParameters otfFilterParameters,
EyesisAberrations.PSFParameters psfParameters, EyesisAberrations.PSFParameters psfParameters,
double [][][] sampleCoord, // restored from history or null - will create old way
double [][][][][] returnFullResults, // null OK =- will return [0][i][j][0,1,2(r/g/b)][0,1] double [][][][][] returnFullResults, // null OK =- will return [0][i][j][0,1,2(r/g/b)][0,1]
int threadsMax, int threadsMax,
boolean updateStatus, boolean updateStatus,
...@@ -10997,10 +11154,13 @@ if (MORE_BUTTONS) { ...@@ -10997,10 +11154,13 @@ if (MORE_BUTTONS) {
updateStatus, updateStatus,
loopDebugLevel); // debug level loopDebugLevel); // debug level
// DEBUG_LEVEL=MASTER_DEBUG_LEVEL; // DEBUG_LEVEL=MASTER_DEBUG_LEVEL;
double [][][] sampleCoord=focusMeasurementParameters.sampleCoordinates( if (sampleCoord==null){ // old way
System.out.println ("***** sampleCoord==null, genearting from lensDistortionParameters.p{x,y}0) *****");
sampleCoord=focusMeasurementParameters.sampleCoordinates(
lensDistortionParameters.px0, // pixel coordinate of the the optical center lensDistortionParameters.px0, // pixel coordinate of the the optical center
lensDistortionParameters.py0); // pixel coordinate of the the optical center lensDistortionParameters.py0); // pixel coordinate of the the optical center
}
if (debugLevel>0) System.out.println ("Top left sample coordinates: x="+IJ.d2s(sampleCoord[0][0][0],3)+", y="+IJ.d2s(sampleCoord[0][0][1],3));
double [][][] anglePerPixel=pixToAngles( double [][][] anglePerPixel=pixToAngles(
sampleCoord, sampleCoord,
lensDistortionParameters.px0, // pixel coordinate of the the optical center lensDistortionParameters.px0, // pixel coordinate of the the optical center
......
...@@ -12398,7 +12398,7 @@ Which parameters affect which matrices ...@@ -12398,7 +12398,7 @@ Which parameters affect which matrices
public int getGoniometerHorizontalIndex(){return 6;} public int getGoniometerHorizontalIndex(){return 6;}
public int getGoniometerAxialIndex(){return 7;} public int getGoniometerAxialIndex(){return 7;}
public int getSensorWidth() { return this.sensorWidth;} public int getSensorWidth() { return this.sensorWidth;}
public int getSensorHeight() { return this.sensorWidth;} public int getSensorHeight() { return this.sensorHeight;}
public int getSensorWidth(int subCam) { return this.sensorWidth;} // for the future? different sensors public int getSensorWidth(int subCam) { return this.sensorWidth;} // for the future? different sensors
public int getSensorHeight(int subCam) { return this.sensorHeight;}// for the future? different sensors public int getSensorHeight(int subCam) { return this.sensorHeight;}// for the future? different sensors
public double getPixelSize(int subCamNumber){return this.eyesisSubCameras[0][subCamNumber].pixelSize;} // use station 0's pixel size public double getPixelSize(int subCamNumber){return this.eyesisSubCameras[0][subCamNumber].pixelSize;} // use station 0's pixel size
...@@ -13952,6 +13952,33 @@ Which parameters affect which matrices ...@@ -13952,6 +13952,33 @@ Which parameters affect which matrices
this.flipVertical=flipVertical; this.flipVertical=flipVertical;
recalcCommons(); recalcCommons();
} }
public void setIntrincicFromSubcamera(EyesisSubCameraParameters pars){
setLensDistortionParameters(
pars.focalLength,
pars.pixelSize, //um
pars.distortionRadius, // mm
pars.distortionA8, // r^7
pars.distortionA7, // r^6
pars.distortionA6, // r^5
pars.distortionA5, // r^4
pars.distortionA, // r^4
pars.distortionB, // r^3
pars.distortionC, // r^2
// orientation/position parameters
this.yaw, // (keep) angle in degrees from perpendicular to the pattern, 0 - towards wall, positive - clockwise from top
this.pitch, // (keep) angle in degrees from perpendicular to the pattern, 0 - towards wall, positive - up
this.roll, // (keep) angle in degrees rotation around camera optical axis (perpendicular to pattern if yaw==0, pitch==0), positive - clockwise
this.x0, // (keep) lens axis from pattern center, mm (to the right)
this.y0, // (keep) lens axis from pattern center, mm (down)
this.z0, // (keep) lens axis from pattern center, mm (away)
this.distance, // (keep) distance from the lens input pupil to the pattern plane along the camera axis, mm
pars.px0, // center of the lens on the sensor, pixels
pars.py0, // center of the lens on the sensor, pixels
this.flipVertical // (keep) acquired image is mirrored vertically (mirror used)
);
}
public void setLensDistortionParameters(LensDistortionParameters ldp public void setLensDistortionParameters(LensDistortionParameters ldp
){ ){
this.focalLength=ldp.focalLength; this.focalLength=ldp.focalLength;
...@@ -765,6 +765,9 @@ public double [][] flattenSampleCoord(){ ...@@ -765,6 +765,9 @@ public double [][] flattenSampleCoord(){
for (int i=0;i<sampleCoord.length;i++) for (int j=0;j<sampleCoord[0].length;j++) flatSampleCoord[index++]= sampleCoord[i][j]; for (int i=0;i<sampleCoord.length;i++) for (int j=0;j<sampleCoord[0].length;j++) flatSampleCoord[index++]= sampleCoord[i][j];
return flatSampleCoord; // last dimension is not cloned return flatSampleCoord; // last dimension is not cloned
} }
public double [][][] getSampleCoord(){
return this.sampleCoord;
}
public class MeasuredSample{ public class MeasuredSample{
public int [] motors = new int[3]; public int [] motors = new int[3];
public String timestamp; public String timestamp;
...@@ -2890,23 +2893,31 @@ public void stepLevenbergMarquardtAction(int debugLevel){// ...@@ -2890,23 +2893,31 @@ public void stepLevenbergMarquardtAction(int debugLevel){//
/** /**
* Dialog to select Levenberg-Marquardt algorithm and related parameters * Dialog to select Levenberg-Marquardt algorithm and related parameters
* @param autoSel - disable default stop, suggest strategy 0
* @return true if OK, false if canceled * @return true if OK, false if canceled
*
*/ */
public boolean selectLMAParameters(){ public boolean selectLMAParameters(boolean autoSel){
// int numSeries=fittingStrategy.getNumSeries(); // int numSeries=fittingStrategy.getNumSeries();
// boolean resetCorrections=false; // boolean resetCorrections=false;
GenericDialog gd = new GenericDialog("Levenberg-Marquardt algorithm parameters lens aberrations approxiamtion"); GenericDialog gd = new GenericDialog("Levenberg-Marquardt algorithm parameters lens aberrations approxiamtion");
//TODO: change to selection using series comments //TODO: change to selection using series comments
// gd.addNumericField("Fitting series number", this.currentStrategyStep, 0, 3," (-1 - current)"); // gd.addNumericField("Fitting series number", this.currentStrategyStep, 0, 3," (-1 - current)");
int suggestStep=this.currentStrategyStep;
boolean suggestStopEachStep=this.stopEachStep;
if (autoSel){
suggestStep=0;
suggestStopEachStep=false;
}
FieldStrategies fs=fieldFitting.fieldStrategies; FieldStrategies fs=fieldFitting.fieldStrategies;
String [] indices=new String[fs.getNumStrategies()+1]; String [] indices=new String[fs.getNumStrategies()+1];
indices[0]="current strategy"; indices[0]="current strategy";
for (int i=0;i<fs.getNumStrategies();i++) { for (int i=0;i<fs.getNumStrategies();i++) {
indices[i+1]=i+": "+fs.getComment(i)+" ("+(fs.isStopAfterThis(i)?"STOP":"CONTINUE")+")"; indices[i+1]=i+": "+fs.getComment(i)+" ("+(fs.isStopAfterThis(i)?"STOP":"CONTINUE")+")";
} }
if (this.currentStrategyStep>=(indices.length-1)) this.currentStrategyStep=indices.length-2; if (suggestStep>=(indices.length-1)) suggestStep=indices.length-2; // last one
gd.addChoice("Fitting series", indices,indices[this.currentStrategyStep+1]); gd.addChoice("Fitting series", indices,indices[suggestStep+1]);
gd.addCheckbox("Debug df/dX0, df/dY0", false); gd.addCheckbox("Debug df/dX0, df/dY0", false);
gd.addNumericField("Debug Jacobian for point number", this.debugPoint, 0, 5,"(-1 - none)"); gd.addNumericField("Debug Jacobian for point number", this.debugPoint, 0, 5,"(-1 - none)");
...@@ -2920,7 +2931,7 @@ public boolean selectLMAParameters(){ ...@@ -2920,7 +2931,7 @@ public boolean selectLMAParameters(){
gd.addNumericField("Threshold lambda to fail", this.maxLambda, 5); gd.addNumericField("Threshold lambda to fail", this.maxLambda, 5);
gd.addNumericField("Maximal number of iterations", this.numIterations, 0); gd.addNumericField("Maximal number of iterations", this.numIterations, 0);
gd.addCheckbox("Dialog after each iteration step", this.stopEachStep); gd.addCheckbox("Dialog after each iteration step", suggestStopEachStep); //this.stopEachStep);
gd.addCheckbox("Dialog after each iteration series", this.stopEachSeries); gd.addCheckbox("Dialog after each iteration series", this.stopEachSeries);
gd.addCheckbox("Dialog after each failure", this.stopOnFailure); gd.addCheckbox("Dialog after each failure", this.stopOnFailure);
gd.addCheckbox("Show modified parameters", this.showParams); gd.addCheckbox("Show modified parameters", this.showParams);
...@@ -3995,12 +4006,13 @@ public void calculateGoodSamples(){ ...@@ -3995,12 +4006,13 @@ public void calculateGoodSamples(){
public boolean LevenbergMarquardt( public boolean LevenbergMarquardt(
FocusingFieldMeasurement measurement, // null in calibrate mode FocusingFieldMeasurement measurement, // null in calibrate mode
boolean openDialog, boolean openDialog,
boolean autoSel,
// boolean filterZ, // for adjust mode // boolean filterZ, // for adjust mode
int debugLevel){ int debugLevel){
boolean calibrate=measurement==null; boolean calibrate=measurement==null;
double savedLambda=this.lambda; double savedLambda=this.lambda;
this.debugLevel=debugLevel; this.debugLevel=debugLevel;
if (openDialog && !selectLMAParameters()) return false; if (openDialog && !selectLMAParameters(autoSel)) return false;
this.startTime=System.nanoTime(); this.startTime=System.nanoTime();
// create savedVector (it depends on parameter masks), restore from it if aborted // create savedVector (it depends on parameter masks), restore from it if aborted
// fieldFitting.initSampleCorrVector( // fieldFitting.initSampleCorrVector(
...@@ -5000,6 +5012,7 @@ public boolean LevenbergMarquardt( ...@@ -5000,6 +5012,7 @@ public boolean LevenbergMarquardt(
boolean OK=LevenbergMarquardt( boolean OK=LevenbergMarquardt(
measurement, measurement,
false, // true, // open dialog false, // true, // open dialog
true,// boolean autoSel,
debugLevel); debugLevel);
if (!OK){ if (!OK){
if (debugLevel>1) System.out.println("testMeasurement() failed: LMA failed"); if (debugLevel>1) System.out.println("testMeasurement() failed: LMA failed");
...@@ -8675,7 +8688,7 @@ f_corr: d_fcorr/d_zcorr=0, other: a, reff, kx -> ar[1], ar[2], ar[3], ar[4] ...@@ -8675,7 +8688,7 @@ f_corr: d_fcorr/d_zcorr=0, other: a, reff, kx -> ar[1], ar[2], ar[3], ar[4]
System.out.println("qualBOptimize LMA failed"); System.out.println("qualBOptimize LMA failed");
} }
// zTxTy[0]-=best_qb_corr[0]; - absolute, no need to calculate best_qb_corr; // zTxTy[0]-=best_qb_corr[0]; - absolute, no need to calculate best_qb_corr;
this.qualBOptimizationResults=zTxTy; this.qualBOptimizationResults=zTxTy.clone();
return zTxTy; return zTxTy;
} }
......
...@@ -297,13 +297,13 @@ public class LensAdjustment { ...@@ -297,13 +297,13 @@ public class LensAdjustment {
public double motorsPreSigma=3584.0; // when fitting parabola for focusing sharpness in the center, far measurements decay with this sigma public double motorsPreSigma=3584.0; // when fitting parabola for focusing sharpness in the center, far measurements decay with this sigma
public double maxLinearStep= 3584.0; // If there are insufficient measurements to fit parabola - make this step public double maxLinearStep= 3584.0; // If there are insufficient measurements to fit parabola - make this step
public int scanStep=200; // motor step (all 3 motors) in scan focus mode (signed value) public int scanStep=320; // 200; // motor step (all 3 motors) in scan focus mode (signed value)
public int scanNumber=50; // number of scanStep steps to run public int scanNumber=50; // number of scanStep steps to run
public int scanNumberNegative=15; // number of scanStep steps negative from the start public int scanNumberNegative=20; // 15; // number of scanStep steps negative from the start
public boolean scanHysteresis=true; // scan both ways public boolean scanHysteresis=false; // true; // scan both ways
public int scanHysteresisNumber=5; // number of test points for the Hysteresis measurement public int scanHysteresisNumber=5; // number of test points for the Hysteresis measurement
public boolean scanTiltEnable=true; // enable scanning tilt public boolean scanTiltEnable=false; //true; // enable scanning tilt
public boolean scanTiltReverse=false; // enable scanning tilt in both directions public boolean scanTiltReverse=false; // enable scanning tilt in both directions
public boolean scanMeasureLast=false; // Calculate PSF after last move (to original position) public boolean scanMeasureLast=false; // Calculate PSF after last move (to original position)
public int scanTiltRangeX=14336; // 4 periods public int scanTiltRangeX=14336; // 4 periods
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment