stella.util
Class FocusSpindleFit

java.lang.Object
  extended by util.PropertyContainer
      extended by util.PropertyResources
          extended by util.PropertyBundles
              extended by stella.util.FocusSpindleFit
All Implemented Interfaces:
Cloneable, Initializable, LocalizedSupplying, PropertySupplying, ResourceSupplying

public class FocusSpindleFit
extends PropertyBundles

This class allows the determination of the ellipticity of the focus spindel or the focus sledge used on STELLA-1/STELLA-2. We assume that the position on the CCD (x,y) can be described by a tilted ellipse, describing the polar angle as a linear function of the focus position, plus drifts in the x/y direction. The following formulars apply:

   φ=φ_0+2π·focus%lead
r=a*e/sqrt(1-e^2·cos^2(2φ)
x=r*cos(θ_0+φ)+v_x*focus+x_0
y=r*sin(θ_0+φ)+v_y*focus+y_0
With θ_0 being the tilt angle of the ellipse to the x/y direction, focus is the focus position in whatever units, while the lead is the distance the focus has to travel for a full rotation. In STELLA-1, the focus spindle has a flank lead of 5mm, such that we asume this value.

The process then boils down to fitting the 8 (9 if lead is also unknown) parameters x_0, y_0, v_x, v_y, θ_0, φ_0, and a and e of the ellipse. This is a nonlinear problem, thus we use an amoeba.


Nested Class Summary
private  class FocusSpindleFit.AbstractPosition
           
private  class FocusSpindleFit.CorkScrew
          Full model, including a cork-screw like dependency.
private  class FocusSpindleFit.Drift
          Simple model, center plus linear drift.
static interface FocusSpindleFit.PositionModel
           
static class FocusSpindleFit.Ses
          This solves for SES firecam-fits taken with thar-lamp on and using the linear slider.
static class FocusSpindleFit.Wifsip
          This solves for Wifsip focus sequences.
 
Nested classes/interfaces inherited from class util.PropertyResources
PropertyResources.URLResource
 
Field Summary
private  List<Point2D> ccd
          The list of pixels on the CCD.
private static int DEFREJECT
          Default rejection number.
private  List<Double> focus
          The measured focus positions, at the same index as ccd positions.
static String KEY_FLANKLEAD
          If this parameter is set, we fix the lead and solve for one par.
static String KEY_MODEL
          The class name for the model
static String KEY_REJECT
          Default rejection number.
private  FocusSpindleFit.PositionModel model
          The model for the measures.
 
Fields inherited from class util.PropertyBundles
KEY_LOCALECOUNTRY, KEY_LOCALELANGUAGE, KEY_RESOURCEBUNDLES
 
Fields inherited from class util.PropertyResources
KEY_NOINITONCREATE, localurl, locate, POSTFIX_DIR, POSTFIX_EXT, POSTFIX_FILE, POSTFIX_LIST, POSTFIX_URL, urlset
 
Fields inherited from class util.PropertyContainer
KEY_LISTSEPARATOR, KEY_MAPKEYVALUECHAR, KEY_MAPSEPARATOR
 
Fields inherited from interface util.ResourceSupplying
KEY_URLRESOURCES, KEY_URLUSECONFIG, KEY_URLUSECURRENT, KEY_URLUSEHOME
 
Fields inherited from interface util.PropertySupplying
CONFIG, KEY_CLASS
 
Constructor Summary
FocusSpindleFit(Map<String,String> prop)
          No defaults.
 
Method Summary
 boolean addHdu(double fpos, nom.tam.fits.ImageHDU img, Rectangle window, double sigfac, boolean invert)
          From an Image HDU, we extract an area around the given center, estimate the background by the mode, then do a CoG on all pixel that are at least the specified number of sigmas above the background.
 int addMeasure(Point2D xy, double f)
          Adds a measure, consisting of the focus position in arbitrary units and of a CCD position in pixel.
 int getMeasureCount()
          Returns the current number of measures.
 List<Point2D> getModel(VectorG solution)
          Returns the model on the same focus positions as the measures.
 double[] getResiduals(VectorG solution)
          Returns the distance between measurement and model in pixel.
 double getRms(VectorG solution)
          Returns the rms of the fitted model to the model data.
 void init()
          Loads URL-resources, if there are any.
 VectorG solve()
          We try to solve for the spindle model.
 
Methods inherited from class util.PropertyBundles
clone, getLocalized, getLocalized, getLocalizedString, getLocalizedString, loadResource
 
Methods inherited from class util.PropertyResources
createFrom, createFrom, createFrom, getApplet, getAsResources, getLocalClassLoader, getPropertiesToKey, getPropertiesToKey, getResource, getResourceAsStream, getResourceFromKey, getResources, keyCreate, keyCreate, reload, setApplet
 
Methods inherited from class util.PropertyContainer
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, reload, removeProperty, rescanned, setObject, setProperties, setProperty, stringProperties, toString
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface util.ResourceSupplying
getResource, getResourceAsStream, getResources
 
Methods inherited from interface util.PropertySupplying
defaultBoolean, 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, stringProperties
 

Field Detail

KEY_FLANKLEAD

public static final String KEY_FLANKLEAD
If this parameter is set, we fix the lead and solve for one par. less.

See Also:
Constant Field Values

KEY_REJECT

public static final String KEY_REJECT
Default rejection number.

See Also:
Constant Field Values

KEY_MODEL

public static final String KEY_MODEL
The class name for the model

See Also:
Constant Field Values

DEFREJECT

private static final int DEFREJECT
Default rejection number.

See Also:
Constant Field Values

ccd

private List<Point2D> ccd
The list of pixels on the CCD.


focus

private List<Double> focus
The measured focus positions, at the same index as ccd positions.


model

private FocusSpindleFit.PositionModel model
The model for the measures.

Constructor Detail

FocusSpindleFit

public FocusSpindleFit(Map<String,String> prop)
No defaults.

Method Detail

init

public void init()
Description copied from class: PropertyResources
Loads URL-resources, if there are any.

Specified by:
init in interface Initializable
Overrides:
init in class PropertyResources

addMeasure

public int addMeasure(Point2D xy,
                      double f)
Adds a measure, consisting of the focus position in arbitrary units and of a CCD position in pixel.

Returns:
The count of applied measures after this measure has been added.

getMeasureCount

public int getMeasureCount()
Returns the current number of measures.


solve

public VectorG solve()
We try to solve for the spindle model. We start by assigning the average of the CCD pixel values to the start value of x_0 and y_0, the maximum and minimum distance of this center to the CCD pixel define the semi major axis and the excentricity of the ellipsoid, while v_x and v_y are set zero. The alignment angle θ_0 is estimated from the direction of the center to the maximum point, while φ_0 is set such that for the maximum point's focus value we get a φ of zero. If no flank lead is set, we boldly assume that the total span in focus position adds up to one flank lead. Step width are estimated accordingly, and the solution is found with a Simplex search.


getModel

public List<Point2D> getModel(VectorG solution)
Returns the model on the same focus positions as the measures.


getRms

public double getRms(VectorG solution)
Returns the rms of the fitted model to the model data.


getResiduals

public double[] getResiduals(VectorG solution)
Returns the distance between measurement and model in pixel. We minimize for the square of the sum of these.

Parameters:
solution - The model parameters, not necessarily the best fit.

addHdu

public boolean addHdu(double fpos,
                      nom.tam.fits.ImageHDU img,
                      Rectangle window,
                      double sigfac,
                      boolean invert)
From an Image HDU, we extract an area around the given center, estimate the background by the mode, then do a CoG on all pixel that are at least the specified number of sigmas above the background. If the invert flag is set, we invert the adu, meaning searching for the dark spot.