public class MomentsFocusser extends PropertyResources implements DriverDepending, ParameterDepending, Initializable
#crudeFocus.| Modifier and Type | Class and Description |
|---|---|
static class |
MomentsFocusser.IntExt
This class takes a extra focal and an intra focal image and calculates
the focus that follows from the A4 parameter.
|
PropertyResources.Load, PropertyResources.URLResource| Modifier and Type | Field and Description |
|---|---|
private static String |
A4MOM |
private static String |
A4MOMREM |
private Value |
alt
The value that delivers the altitude relevant for focus model.
|
private CcdDriver |
ccd
The CCD to take images with.
|
private static double |
DEFA4ERROR
Default A4 error (2011-10-14).
|
private static double |
DEFA4MINVALUE |
private static double |
DEFA4SLOPE
Default A4 slope (2011-10-14).
|
private static Dimension |
DEFADUSIZE
The default size around the bright spot.
|
private static String |
DEFALTTARGET
Default focus temperature parameter name.
|
private static Dimension |
DEFBLOBSIZE
The default blob size.
|
private static double |
DEFCOARSEACCEPT
Default always do sequence.
|
private static boolean |
DEFDOSAVE
If true we save the individual images during focus.
|
private static boolean |
DEFDOSEARCH
If temperature model is accurate enough, we can skip the search.
|
private static double |
DEFERRORCRUDE
Default temperature focusing error in steps.
|
private static double |
DEFERRORZERNIKE
Default always do sequence.
|
private static int |
DEFEXTENSION
The moment during fine focus.
|
private static String |
DEFFILTERSHIFT
The parameter name that holds the current filter.
|
private static Dimension |
DEFFOCUSBINNING
The default binning on acquire.
|
private static int |
DEFFOCUSORDER
The moment during fine focus.
|
private static int |
DEFFOCUSRETRY
Default no retries.
|
private static int |
DEFFWHMCACHE
Default report, if 10 FWHM in a row are too high.
|
private static double |
DEFFWHMEXCEED
Default report, if FWHM exceeds 10 pixel permanently.
|
private static String |
DEFFWHMMEASURE
Default fwhm measure parameter name.
|
private static Dimension |
DEFFWHMSIZE
The default size around the bright spot.
|
private static double |
DEFHIGHSKYSIGMA
Per default we do not do ADU rejection, thus this is zero.
|
private static double |
DEFINCREASERETRY
Default no step increse.
|
private static double |
DEFLOWSKYSIGMA
Per default we do not do ADU rejection, thus this is zero.
|
private static boolean |
DEFMEDIANSKY
Default we use median for sky-level determination.
|
private static String |
DEFMOMENTS
Default moments parameter name.
|
private static int |
DEFSEARCHORDER
The moment during coarse focus.
|
private static int |
DEFSEARCHSTEPS
Default half-number of search steps.
|
private static int |
DEFSKYFRAME
The default sky frame size.
|
private static double |
DEFSTEPSINALT
Default steptemp (March 2013)
|
private static String |
DEFTMPFITS |
private static String |
DEFUNIQUE
Default unique parameter name.
|
private static double |
DEFZERNIKEACCEPT
Default always do sequence.
|
private static double |
DEFZERNIKESTEP
Default no extra Zernike images.
|
private static double |
DEFZEXPOSE
Default no extra increase in exposure time on Zernikes.
|
private long |
expt
The exposure time in ms calculated once per focus sequence.
|
static String |
EXTRAFOCAL
Extension for extrafocal image in Zernike coefficient determination.
|
private static String |
FOCMOM |
private static String |
FOCMOMREM |
private Shelf<Double> |
fwhm
Collect the FWHM of the final foci, report if permanently off.
|
private static String |
FWHMGAUSS |
private static String |
FWHMGAUSSREM |
static String |
INTRAFOCAL
Extension for intrafocal image in Zernike coefficient determination.
|
static String |
KEY_A4ERROR
This is the error estimate for A4 slope.
|
static String |
KEY_A4MINVALUE
If the zernike value is below this, we cannot trust focus.
|
static String |
KEY_A4SLOPE
This is the slope of A4 versus steps.
|
static String |
KEY_ADUSIZE
The box to scan for A4.
|
static String |
KEY_ALTTARGET
The name of the altitude of the object to use (target/telescope).
|
static String |
KEY_BLOBSIZE
The default blob size.
|
static String |
KEY_CCD
The name of the ccd to use.
|
static String |
KEY_COARSEACCEPT
If the coarse error is below this, we spare the sequence.
|
static String |
KEY_DOSAVE
Save the focus sequence images.
|
static String |
KEY_DOSEARCH
Once the temperature model is accurate enough, we do not search.
|
static String |
KEY_ERRORCRUDE
Estimated focusing error on crude focus.
|
static String |
KEY_ERRORZERNIKE
If the zernike error is below this, we spare the sequence.
|
static String |
KEY_EXTENSION
The extension with best signal if more than one amplifier.
|
static String |
KEY_FILTERSHIFT
The parameter name that holds the current filter focus shift.
|
static String |
KEY_FOCUSBINNING
The binning for focus images.
|
static String |
KEY_FOCUSFRAME
The frame for focus images.
|
static String |
KEY_FOCUSOFFSET
The offset from the optimal focus for image 1&2.
|
static String |
KEY_FOCUSORDER
The moment during fine focus.
|
static String |
KEY_FOCUSRETRY
Maximum number of final focus retries.
|
static String |
KEY_FWHMCACHE
The number of last fwhms to keep
|
static String |
KEY_FWHMEXCEED
If we have a FWHM higher than this for at least n times, report.
|
static String |
KEY_FWHMMEASURE
The name of the fwhm measurement parameter to use.
|
static String |
KEY_FWHMSIZE
The box to scan for FWHM.
|
static String |
KEY_HIGHSKYSIGMA
If greater than zero, the high bound sigma for background rejection.
|
static String |
KEY_INCREASERETRY
Increase in left/right final focus offset on retries..
|
static String |
KEY_LOWSKYSIGMA
If greater than zero, the low-bound sigma for background rejection.
|
static String |
KEY_MAXFOCUSEXPOSE
If the exposure time required for moments exceed this, do T only.
|
static String |
KEY_MEDIANSKY
If true, use median in background frame.
|
static String |
KEY_MOMENTS
The name of the fits moments to use.
|
static String |
KEY_MOMENTSFRAME
The frame for focus moments, smaller than image frame.
|
static String |
KEY_SEARCHOFFSET
The step with, if focus model is bad.
|
static String |
KEY_SEARCHORDER
The moment during coarse focus.
|
static String |
KEY_SEARCHSTEPS
The number of search steps in either direction.
|
static String |
KEY_SKYFRAME
The default sky frame size.
|
static String |
KEY_STEP0
The focus position for focus temperature T0.
|
static String |
KEY_STEPSINALT
Per sine height, we add this number of steps.
|
static String |
KEY_STEPTEMP
Per degree difference to T0, we add this number of steps.
|
static String |
KEY_TEMP0
At this temperature, optimal focus is at step0.
|
static String |
KEY_TEMPERATURE
The name of the temperature to use.
|
static String |
KEY_TMPFITS
Only on string-only CCD drivers.
|
static String |
KEY_UNIQUE
The name of the unique parameter.
|
static String |
KEY_ZERNIKEACCEPT
If the zernike error is below this, we spare the sequence.
|
static String |
KEY_ZERNIKESTEP
If this multiplier to searchsteps is greater 0, we do Zernikes.
|
static String |
KEY_ZEXPOSE
Multiplier to nominal exposure time for extra/intra focal Zernike.
|
private FwhmMeasure |
measfwhm
We also measure the FWHM in the final focus image.
|
private FitsMoments |
moments
The fits-moments parameter.
|
private static String |
MOMFOC |
private static String |
SETFOCUS |
private static String |
SETFOCUSREM |
private Value |
shiftfocus
The value that delivers a focus shift due to a filter selected.
|
private Focusable |
telescope
The object that allows me to set the focus.
|
private Value |
temp
The value that delivers the temperature relevant for focus model.
|
private Parameter |
unique
The unique parameter.
|
KEY_NOINITONCREATE, POSTFIX_ALPHABET, POSTFIX_BYTES, POSTFIX_DIR, POSTFIX_EXT, POSTFIX_FILE, POSTFIX_LIST, POSTFIX_MODTIME, POSTFIX_URLKEY_LISTSEPARATOR, KEY_MAPKEYVALUECHAR, KEY_MAPSEPARATORKEY_URLRESOURCES, KEY_URLUSECONFIG, KEY_URLUSECURRENT, KEY_URLUSEHOMECONFIG, KEY_CLASS| Constructor and Description |
|---|
MomentsFocusser(Map<String,String> prop)
Constructor chaining.
|
| Modifier and Type | Method and Description |
|---|---|
ErrorEvent |
doFocus()
Task of this object is to auto focus after a successful acquire.
|
private Vector2D |
doZernikes(double zernike,
double pos0)
Does two zernike out-of-focus image and returns true if the focus
obtained is good enough.
|
private double |
getCrudeFocus() |
private ErrorEvent |
getErrorFromFwhm(double ffwhm,
boolean setsucc) |
private double |
getFwhm(MImageHDU f0) |
private Pair<VectorG,MFits> |
getMomentAt(double step,
int order)
We position the linear stage at the indicated step, take an image with
the CCD camera on the
#KEY_FOCSUFRAME and calculate the moments
of this image. |
private double |
getMomentValue(CentralMoments cm,
int order)
Gets the requested value from our central moments.
|
void |
init() |
boolean |
isReady()
Checks, if all required values and objects are in place, sparing expt.
|
boolean |
isValid()
Checks, if all required values and objects are in place.
|
private Vector2D |
limitCoarseFocus()
In the coarse focus, we do a temperature model, even if very inaccurate,
then procced to in and out with
#KEY_SEARCH step, doing a image
on the small frame along the offsets. |
private Vector2D |
limitCrudeFocus()
We position the linear sledge at the temperature model focus.
|
boolean |
registerDriver(Driver d)
If this driver is a ccd and its name equals
KEY_CCD. |
void |
registerExposureTime(long ms)
The exposure time is set from the outside.
|
void |
registerFocus(Focusable f)
We register the object that can set a focus position.
|
void |
registerParameter(Parameter p)
We use the parameter, if it is a fitsmoments and if the name agrees with
the property
KEY_MOMENTS |
private double |
scanA4(MImageHDU hdu)
We calculate the A4 parameter from second image moments following
Equation 5 in PASP118, 1165, but without pixel scaling.
|
private Tuple3<Double,Integer,Double> |
scanFwhm(double x0,
char fitsmark) |
private boolean |
store(MHeader primary,
MImageHDU image,
String store,
List<MHeaderCard> extra)
From a possibly multi-extension fits only the requested extension is
permanently stored with the provided name.
|
private MFits |
takeSingleImage(CcdDriver ccd,
long ms,
Dimension bin)
Takes a single image, stores it, if desired.
|
clone, createFrom, createFrom, createFrom, createInstance, getApplet, getAsResources, getLocate, getPropertiesToKey, getPropertiesToKey, getResource, getResourceAsStream, getResourceFromKey, getResources, hasLocalURLs, initProperties, keyCreate, keyCreate, reload, setAppletaugment, augment, augment, augment, augment, defaultBoolean, defaultChar, defaultDouble, defaultFloat, defaultInt, defaultLong, defaultObject, defaultObject, defaultProperties, defaultProperty, getAsBoolean, getAsChar, getAsDouble, getAsEnums, getAsFloat, getAsInt, getAsList, getAsLong, getAsMap, getAsMap, getAsObject, getAsObject, getProperties, getProperty, has, isNew, parseObject, parseObject, reload, removeProperty, requires, rescanned, setObject, setProperties, setProperty, stringProperties, toStringequals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitdefaultBoolean, defaultChar, defaultDouble, defaultFloat, defaultInt, defaultLong, defaultObject, defaultObject, defaultProperties, defaultProperty, getAsBoolean, getAsChar, getAsDouble, getAsFloat, getAsInt, getAsList, getAsLong, getAsMap, getAsObject, getAsObject, getProperties, getProperty, has, parseObject, removeProperty, setObject, setProperty, stringPropertiesprivate static final String MOMFOC
private static final String A4MOMREM
private static final String A4MOM
private static final String FWHMGAUSSREM
private static final String FWHMGAUSS
private static final String FOCMOMREM
private static final String FOCMOM
private static final String SETFOCUSREM
private static final String SETFOCUS
public static final String EXTRAFOCAL
public static final String INTRAFOCAL
public static final String KEY_UNIQUE
public static final String KEY_MOMENTS
public static final String KEY_TEMPERATURE
public static final String KEY_ALTTARGET
public static final String KEY_FWHMMEASURE
public static final String KEY_CCD
public static final String KEY_FOCUSRETRY
public static final String KEY_INCREASERETRY
public static final String KEY_FOCUSOFFSET
public static final String KEY_FOCUSORDER
public static final String KEY_EXTENSION
public static final String KEY_SEARCHSTEPS
public static final String KEY_SEARCHOFFSET
public static final String KEY_SEARCHORDER
public static final String KEY_DOSEARCH
public static final String KEY_FOCUSFRAME
public static final String KEY_MOMENTSFRAME
public static final String KEY_FOCUSBINNING
public static final String KEY_MAXFOCUSEXPOSE
public static final String KEY_FILTERSHIFT
public static final String KEY_STEP0
public static final String KEY_TEMP0
public static final String KEY_STEPTEMP
public static final String KEY_STEPSINALT
public static final String KEY_DOSAVE
public static final String KEY_ZERNIKESTEP
public static final String KEY_ZEXPOSE
public static final String KEY_A4SLOPE
public static final String KEY_A4ERROR
public static final String KEY_BLOBSIZE
public static final String KEY_ADUSIZE
public static final String KEY_FWHMSIZE
public static final String KEY_SKYFRAME
public static final String KEY_MEDIANSKY
public static final String KEY_LOWSKYSIGMA
public static final String KEY_HIGHSKYSIGMA
public static final String KEY_ERRORZERNIKE
public static final String KEY_FWHMEXCEED
public static final String KEY_FWHMCACHE
public static final String KEY_ZERNIKEACCEPT
public static final String KEY_A4MINVALUE
public static final String KEY_COARSEACCEPT
public static final String KEY_ERRORCRUDE
public static final String KEY_TMPFITS
private static final String DEFUNIQUE
private static final String DEFMOMENTS
private static final String DEFFWHMMEASURE
private static final String DEFFILTERSHIFT
private static final String DEFALTTARGET
private static final double DEFSTEPSINALT
private static final int DEFSEARCHSTEPS
private static final boolean DEFDOSEARCH
private static final int DEFSEARCHORDER
private static final int DEFFOCUSORDER
private static final int DEFFOCUSRETRY
private static final double DEFINCREASERETRY
private static final int DEFEXTENSION
private static final Dimension DEFFOCUSBINNING
private static final boolean DEFDOSAVE
private static final double DEFZERNIKESTEP
private static final double DEFZEXPOSE
private static final double DEFA4SLOPE
private static final double DEFA4ERROR
private static final Dimension DEFBLOBSIZE
private static final Dimension DEFADUSIZE
private static final Dimension DEFFWHMSIZE
private static final int DEFSKYFRAME
private static final boolean DEFMEDIANSKY
private static final double DEFLOWSKYSIGMA
private static final double DEFHIGHSKYSIGMA
private static final double DEFERRORZERNIKE
private static final double DEFFWHMEXCEED
private static final int DEFFWHMCACHE
private static final double DEFERRORCRUDE
private static final double DEFZERNIKEACCEPT
private static final double DEFA4MINVALUE
private static final double DEFCOARSEACCEPT
private static final String DEFTMPFITS
private Parameter unique
private Value temp
private Value alt
private Value shiftfocus
private FitsMoments moments
private FwhmMeasure measfwhm
private long expt
private Focusable telescope
private CcdDriver ccd
public void init()
init in interface Initializablepublic void registerParameter(Parameter p)
KEY_MOMENTSregisterParameter in interface ParameterDependingpublic boolean registerDriver(Driver d)
KEY_CCD.registerDriver in interface DriverDependingpublic void registerFocus(Focusable f)
public void registerExposureTime(long ms)
public boolean isValid()
public boolean isReady()
private Vector2D limitCrudeFocus()
private double getCrudeFocus()
public ErrorEvent doFocus()
private ErrorEvent getErrorFromFwhm(double ffwhm, boolean setsucc)
private Vector2D limitCoarseFocus()
#KEY_SEARCH step, doing a image
on the small frame along the offsets. For each image, the value of the
KEY_SEARCHORDER moment is recorded, in this list the maximum is
found. From this maximum and from its neighbouring values, a parabola is
fit through this three points, the maximum is the new focus, which we
also set. If the maximum value in the original sequence is at the edge,
we return a value slightly inside, depending on the two inner points to
the maximum.private double getFwhm(MImageHDU f0)
private Vector2D doZernikes(double zernike, double pos0)
private double scanA4(MImageHDU hdu) throws BasicFitsException
A4 = sqrt(Mx+My), withCentered on the brightest pixel blob in the image, we use a rectangle of size
Mx,y = Σ(x,y_ij-x,y_c)^2*ADU_ij/ΣADU_ij
KEY_ADUSIZE and around that a #SKYFRAME thick frame
for background determination. The background is either the median or the
mean of the ADUs in the sky frame, the RMS estimate is either the
quartile-sigma or the standard deviation. The two values
KEY_LOWSKYSIGMA and KEY_HIGHSKYSIGMA define which range
of ADUs should be considered background. This background count is removed
from the image prior to calculating the moments.BasicFitsExceptionprivate MFits takeSingleImage(CcdDriver ccd, long ms, Dimension bin)
private boolean store(MHeader primary, MImageHDU image, String store, List<MHeaderCard> extra)
image - ext - store - extra - private Pair<VectorG,MFits> getMomentAt(double step, int order)
#KEY_FOCSUFRAME and calculate the moments
of this image. The value returned is the indicated central normalized
moment, except for 1 that returns the average and 2 returns the square
root of the variance. If the positioning fails (or if the requested
position is out of range) null is returned.private double getMomentValue(CentralMoments cm, int order)