astro.fits
Class CrosstalkDark

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

public class CrosstalkDark
extends PropertyBundles

Small class to prepare the WiFSIP crosstalk measures for further processing. This starts with two dark frames taken between the crosstalk frames. These dark frames are already averaged and split into single-extension fits files, known to this class as the two arrays #DARK1 and #DARK2. We then take a measurement file (an out-of-focus image of Regulus spanning most of a single amplifier quadrant). From the sky estimate (either mode, median, or average of the image), we scale the two dark (α, β) such that we match this sky estimate, e.g. for amplifier 0 we have dark1-mode=2263, dark2-mod=3743. For reg_2amp, all of them taken just before DARK1 and way before dark 2, we get a sky estimate that is lower than 2263, thus we get negative β and an α > 1 (BC: α+β=1), for reg_1 and reg_3 accordingly 0< α,β< 1 and for reg4, taken after both darks, we expect β > 1 and α < 0.


Nested Class Summary
static class CrosstalkDark.Scale
          The known possible scaling values.
static class CrosstalkDark.Scalings
          Reads properties - normally none are sufficient - and prints the scaling factors for each quadrant and file for sanity checks.
static class CrosstalkDark.Subtract
          Creates dark-subtracted fits from the input list by scaling the two master darks to match the background estimate.
 
Nested classes/interfaces inherited from class util.PropertyResources
PropertyResources.URLResource
 
Field Summary
private  List<nom.tam.fits.ImageHDU> dark1
          The list of early dark HDU, one per amplifier section.
private  List<nom.tam.fits.ImageHDU> dark2
          The list of late dark HDU, one per amplifier section.
private static String DEFDARK1
          The default list of early dark images.
private static String DEFDARK2
          The default list of late dark images.
private static String DEFFITS
          The default list of fits files.
private static String DEFILLU
          The default list of illuminated quadrants.
private static double DEFLOWER
          The default upper bound for reject, times sigma.
private static int DEFREJECT
          The default number of maximum rejection loops.
private static String DEFSCALE
          The default scaling algorithm.
private static double DEFUPPER
          The default upper bound for reject, times sigma.
private  Map<File,Integer> illu
          For each file the quadrant index with the illuminated section.
static String KEY_DARK1
          The list of early dark images, one per amplifier.
static String KEY_DARK2
          The list of late dark images, one per amplifier.
static String KEY_FITS
          The list of images in the order they are processed.
static String KEY_ILLU
          The amplifier index in alpha beta where the illuminated image is.
static String KEY_LOWER
          The lower bound for reject (remove all at least xsigma below av.)
static String KEY_REJECT
          The default number of iterative rejection steps.
static String KEY_SCALE
          The scaling item: AVERGAE, MODE or median.
static String KEY_UPPER
          The upper bound for reject (remove all at least xsigma above av.)
private  VectorG scale1
          The 4Vector of scaling values in the early darks.
private  VectorG scale2
          The 4Vector of scaling values in the early darks.
 
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
CrosstalkDark(Map<String,String> prop)
          Constructs and defaults a new crosstalk-dark fitter.
 
Method Summary
private static double averageIndex(VectorG v, int i0)
          Takes the statistical mean over all indices in the vector except the one stated in i0.
 void darkCorrectAll()
          Does a scaling on all crosstalk fits to remove the dark background.
private  VectorG[] getAlphBeta(File amp)
          For a fits file, read its scaling factors and return the alpha and beta scaling to all its quadrants as a length-of-two array of 4-Vectors.
private  VectorG getDarkScaling(List<nom.tam.fits.ImageHDU> dark)
          Tries to read a list of dark, single-extension images, belonging to a single dark, ordered by amplifier.
private  CrosstalkDark.Scale getScaleFactor()
          Converts a string to the appropriate scaling.
private  double getScaling(nom.tam.fits.ImageHDU data, CrosstalkDark.Scale how)
          Takes a single Image HDU, calculates the ADU statistic and returns the scaling factor, i.e.
 void init()
          On init, we read the dark images and get their scaling factors.
private static String pretty(VectorG v)
          Converts an alpha or beta vector to a pretty print.
private  List<nom.tam.fits.ImageHDU> readDarkList(List<String> dark)
          Tries to read a list of dark, single-extension images, belonging to a single dark, ordered by amplifier.
private  VectorG readWifsip(File amp)
          Reads all four extension of a fits file, calculates for each the scaling factor, and return those as a four-vector.
private  nom.tam.fits.Fits subtractScaledDark(File f, VectorG alpha, VectorG beta)
          From a file f we read all HDUs and scale them such that the dark sky is (partly) removed.
 
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_DARK1

public static final String KEY_DARK1
The list of early dark images, one per amplifier.

See Also:
Constant Field Values

KEY_DARK2

public static final String KEY_DARK2
The list of late dark images, one per amplifier.

See Also:
Constant Field Values

KEY_SCALE

public static final String KEY_SCALE
The scaling item: AVERGAE, MODE or median.

See Also:
Constant Field Values

KEY_FITS

public static final String KEY_FITS
The list of images in the order they are processed.

See Also:
Constant Field Values

KEY_REJECT

public static final String KEY_REJECT
The default number of iterative rejection steps.

See Also:
Constant Field Values

KEY_UPPER

public static final String KEY_UPPER
The upper bound for reject (remove all at least xsigma above av.)

See Also:
Constant Field Values

KEY_LOWER

public static final String KEY_LOWER
The lower bound for reject (remove all at least xsigma below av.)

See Also:
Constant Field Values

KEY_ILLU

public static final String KEY_ILLU
The amplifier index in alpha beta where the illuminated image is.

See Also:
Constant Field Values

DEFSCALE

private static final String DEFSCALE
The default scaling algorithm.


DEFREJECT

private static final int DEFREJECT
The default number of maximum rejection loops.

See Also:
Constant Field Values

DEFUPPER

private static final double DEFUPPER
The default upper bound for reject, times sigma.

See Also:
Constant Field Values

DEFLOWER

private static final double DEFLOWER
The default upper bound for reject, times sigma.

See Also:
Constant Field Values

DEFDARK1

private static final String DEFDARK1
The default list of early dark images.

See Also:
Constant Field Values

DEFDARK2

private static final String DEFDARK2
The default list of late dark images.

See Also:
Constant Field Values

DEFILLU

private static final String DEFILLU
The default list of illuminated quadrants.

See Also:
Constant Field Values

DEFFITS

private static final String DEFFITS
The default list of fits files.

See Also:
Constant Field Values

dark1

private List<nom.tam.fits.ImageHDU> dark1
The list of early dark HDU, one per amplifier section.


scale1

private VectorG scale1
The 4Vector of scaling values in the early darks.


dark2

private List<nom.tam.fits.ImageHDU> dark2
The list of late dark HDU, one per amplifier section.


scale2

private VectorG scale2
The 4Vector of scaling values in the early darks.


illu

private Map<File,Integer> illu
For each file the quadrant index with the illuminated section.

Constructor Detail

CrosstalkDark

public CrosstalkDark(Map<String,String> prop)
Constructs and defaults a new crosstalk-dark fitter.

Method Detail

init

public void init()
On init, we read the dark images and get their scaling factors.

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

darkCorrectAll

public void darkCorrectAll()
                    throws nom.tam.fits.FitsException,
                           IOException
Does a scaling on all crosstalk fits to remove the dark background. Quadrants with the amplifier visible are estimated by averageing the dark from alpha-beta of all other quadrants.

Throws:
nom.tam.fits.FitsException
IOException

averageIndex

private static final double averageIndex(VectorG v,
                                         int i0)
Takes the statistical mean over all indices in the vector except the one stated in i0.


subtractScaledDark

private nom.tam.fits.Fits subtractScaledDark(File f,
                                             VectorG alpha,
                                             VectorG beta)
                                      throws nom.tam.fits.FitsException,
                                             IOException
From a file f we read all HDUs and scale them such that the dark sky is (partly) removed.

Throws:
nom.tam.fits.FitsException
IOException

readWifsip

private VectorG readWifsip(File amp)
                    throws nom.tam.fits.FitsException,
                           IOException
Reads all four extension of a fits file, calculates for each the scaling factor, and return those as a four-vector.

Throws:
nom.tam.fits.FitsException
IOException

getAlphBeta

private VectorG[] getAlphBeta(File amp)
                       throws nom.tam.fits.FitsException,
                              IOException
For a fits file, read its scaling factors and return the alpha and beta scaling to all its quadrants as a length-of-two array of 4-Vectors.

Throws:
nom.tam.fits.FitsException
IOException

readDarkList

private List<nom.tam.fits.ImageHDU> readDarkList(List<String> dark)
                                          throws nom.tam.fits.FitsException,
                                                 IOException
Tries to read a list of dark, single-extension images, belonging to a single dark, ordered by amplifier.

Throws:
nom.tam.fits.FitsException
IOException

getDarkScaling

private VectorG getDarkScaling(List<nom.tam.fits.ImageHDU> dark)
                        throws nom.tam.fits.FitsException,
                               IOException
Tries to read a list of dark, single-extension images, belonging to a single dark, ordered by amplifier.

Throws:
nom.tam.fits.FitsException
IOException

getScaling

private double getScaling(nom.tam.fits.ImageHDU data,
                          CrosstalkDark.Scale how)
                   throws nom.tam.fits.FitsException,
                          IOException
Takes a single Image HDU, calculates the ADU statistic and returns the scaling factor, i.e. the median, mode, or average according to the algortihm requested. The image hdu maus have a non-null data section.

Throws:
nom.tam.fits.FitsException
IOException

getScaleFactor

private final CrosstalkDark.Scale getScaleFactor()
Converts a string to the appropriate scaling.


pretty

private static String pretty(VectorG v)
Converts an alpha or beta vector to a pretty print.