astro.fits
Class FlatCheck

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

public class FlatCheck
extends FitsCheck

Class to do some statistical test on sky flats. Problems encountered were stuck filter wheel, too slow telescope leading to overexposure or underexposure, non-working window readout mode etc. We have a few test in repartoir.

The purpose is to decide posteriori, which flats should be used during the reduction process. A delicate flat with just a small shift in the filter wheel is flat20110110A-0016. "U=:B=:V=:R=:I=:u=:b=:v=:y=:up=:gp=:rp=:ip=:zp=:han=:haw=:hbn=:hbw="


Nested Class Summary
static class FlatCheck.FileF
          Reads the fits file on the command line and does a check on all quadrants.
static class FlatCheck.Mark
          Reads the unique on the command line and executes raw tests on it, writes the resulting .use file.
static class FlatCheck.MarkAll
          Excecutes raw test on all files for a specified telescope
 
Nested classes/interfaces inherited from class astro.fits.FitsCheck
FitsCheck.Failure
 
Nested classes/interfaces inherited from class util.PropertyResources
PropertyResources.URLResource
 
Field Summary
private  Polynom c4lower
          The polynom for the lower c4-sigma boundary.
private  Polynom c4upper
          The polynom for the lower c4-sigma boundary.
private static String DEFC4LOWER
          Default polynom.
private static double DEFC4MAX
          Default property value.
private static double DEFC4MIN
          Default property value.
private static String DEFC4UPPER
          Default polynom.
private static double DEFFLATCENTROIDX
          Default property list.
private static double DEFFLATCENTROIDY
          Default property list.
private static String DEFREGIONQ1Q0
          Different allowed regions for different filters.
private static String DEFREGIONQ3Q2
          Different allowed regions for different filters.
private static int DEFSUBS
          Default int.
private static double DEFTILEC4
          The allowed maximum curtosis per median tile, same for all quadrants.
private static String DEFTILERATIO
          Different allowed maximum ratios for different quadrants/filters.
private static double DEFTILESIGMA
          The allowed maximum span in tile sigams, same for all quadrants.
private static double DEFTILESIGMAC4
          The allowed maximum kurtosis in tile sigams, same for all quadrants.
static String KEY_C4LOWER
          Lower limit for the C4 standard deviation of the quadrants.
static String KEY_C4MAX
          Maximum average C4 of the quadrants.
static String KEY_C4MIN
          Minimum average C4 of the quadrants.
static String KEY_C4UPPER
          Upper limit for the C4 standard deviation of the quadrants.
static String KEY_FLATCENTROIDX
          Maximum absolute centroid shift in x.
static String KEY_FLATCENTROIDY
          Maximum absolute centroid shift in x.
static String KEY_REGIONQ1Q0
          The ellipse definition for the range of Quadrant 1/0 median tiles.
static String KEY_REGIONQ3Q2
          The ellipse definition for the range of Quadrant 3/2 median tiles.
static String KEY_SUBS
          The number of sub-windows.
static String KEY_TILEC4
          The maximum tile kurtosis.
static String KEY_TILERATIO
          The ratio in the span-to-average of the sub-windows.
static String KEY_TILESIGMA
          The maximum tile standard deviation span.
static String KEY_TILESIGMAC4
          The maximum kurtosis in tile sigams.
private  Map<String,Ellipse> q1q0
          Each filter, has a q1/q0 and a q3/q2 valid range as an ellipse.
private  Map<String,Ellipse> q3q2
          Each filter, has a q1/q0 and a q3/q2 valid range as an ellipse.
private  Map<String,List<Double>> ratios
          The parsed maximum span-to-median ratios.
 
Fields inherited from class astro.fits.FitsCheck
DEFFAILEXT, KEY_BIASMAXIMA, KEY_BIASMINIMA, KEY_DARKMAXIMA, KEY_DARKMINIMA, KEY_FAILDIR, KEY_FAILEXT, KEY_OBSDB, KEY_TMPDIR, KEY_TMPFITS, obs, PREFIX_FLATMAXIMA, PREFIX_FLATMINIMA, PREFIX_SCIENCEMAXIMA, PREFIX_SCIENCEMINIMA
 
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
FlatCheck(Map<String,String> prop)
          Defaults everything.
 
Method Summary
 List<FitsCheck.Failure> checkC4(String unique)
          We calculate a statistic on the central normalized fourth moment of the four quadrants.
 List<FitsCheck.Failure> checkC4FromMoment(float[] av)
          We calculate a statistic on the central normalized fourth moment of the four quadrants.
 List<FitsCheck.Failure> checkCentroidFromAverage(float[] av)
          From the average of a flat observation, we check if the centroid is withinin bounds.
 List<FitsCheck.Failure> checkFlat(String unique)
          We check a single flat field for possible failures.
 List<FitsCheck.Failure> checkTiles(String unique)
          From the unique id of the observation, we extract the fitz file to a temporary file and do a tile-check on it.
 List<FitsCheck.Failure> checkTilesInFile(File fits, String filter)
           
 void init()
          Creates the lists for adu max and min and the polynoms for upper and lower c4 boundaries.
private static Map<String,Ellipse> parseRegionMap(Map<String,String> region)
          Parses a string to string mapping of filter to ellipse definitions into a filter to region mappping.
static Vector2D[] tileRatio(nom.tam.fits.ImageHDU flat, int sub)
          An exhaustive but time-consuming final check by dividing each quadrant into the stated number of quadratic sub-windows.
 
Methods inherited from class astro.fits.FitsCheck
check, checkAdu, checkBias, checkCentroid, checkCentroidFromAverage, checkDark, checkScience, getAduConstraints, isAduCompatible, readFailure, readFailureFile, updateFailure, writeFailure, writeFailureFile
 
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_FLATCENTROIDX

public static final String KEY_FLATCENTROIDX
Maximum absolute centroid shift in x.

See Also:
Constant Field Values

KEY_FLATCENTROIDY

public static final String KEY_FLATCENTROIDY
Maximum absolute centroid shift in x.

See Also:
Constant Field Values

KEY_C4MAX

public static final String KEY_C4MAX
Maximum average C4 of the quadrants.

See Also:
Constant Field Values

KEY_C4MIN

public static final String KEY_C4MIN
Minimum average C4 of the quadrants.

See Also:
Constant Field Values

KEY_C4UPPER

public static final String KEY_C4UPPER
Upper limit for the C4 standard deviation of the quadrants.

See Also:
Constant Field Values

KEY_C4LOWER

public static final String KEY_C4LOWER
Lower limit for the C4 standard deviation of the quadrants.

See Also:
Constant Field Values

KEY_SUBS

public static final String KEY_SUBS
The number of sub-windows.

See Also:
Constant Field Values

KEY_TILERATIO

public static final String KEY_TILERATIO
The ratio in the span-to-average of the sub-windows.

See Also:
Constant Field Values

KEY_TILEC4

public static final String KEY_TILEC4
The maximum tile kurtosis.

See Also:
Constant Field Values

KEY_TILESIGMA

public static final String KEY_TILESIGMA
The maximum tile standard deviation span.

See Also:
Constant Field Values

KEY_TILESIGMAC4

public static final String KEY_TILESIGMAC4
The maximum kurtosis in tile sigams.

See Also:
Constant Field Values

KEY_REGIONQ1Q0

public static final String KEY_REGIONQ1Q0
The ellipse definition for the range of Quadrant 1/0 median tiles.

See Also:
Constant Field Values

KEY_REGIONQ3Q2

public static final String KEY_REGIONQ3Q2
The ellipse definition for the range of Quadrant 3/2 median tiles.

See Also:
Constant Field Values

DEFFLATCENTROIDX

private static final double DEFFLATCENTROIDX
Default property list.

See Also:
Constant Field Values

DEFFLATCENTROIDY

private static final double DEFFLATCENTROIDY
Default property list.

See Also:
Constant Field Values

DEFC4MAX

private static final double DEFC4MAX
Default property value.

See Also:
Constant Field Values

DEFC4MIN

private static final double DEFC4MIN
Default property value.

See Also:
Constant Field Values

DEFC4UPPER

private static final String DEFC4UPPER
Default polynom.

See Also:
Constant Field Values

DEFC4LOWER

private static final String DEFC4LOWER
Default polynom.

See Also:
Constant Field Values

DEFSUBS

private static final int DEFSUBS
Default int.

See Also:
Constant Field Values

DEFTILEC4

private static final double DEFTILEC4
The allowed maximum curtosis per median tile, same for all quadrants.

See Also:
Constant Field Values

DEFTILESIGMA

private static final double DEFTILESIGMA
The allowed maximum span in tile sigams, same for all quadrants.

See Also:
Constant Field Values

DEFTILESIGMAC4

private static final double DEFTILESIGMAC4
The allowed maximum kurtosis in tile sigams, same for all quadrants.

See Also:
Constant Field Values

DEFTILERATIO

private static final String DEFTILERATIO
Different allowed maximum ratios for different quadrants/filters.

See Also:
Constant Field Values

DEFREGIONQ1Q0

private static final String DEFREGIONQ1Q0
Different allowed regions for different filters.

See Also:
Constant Field Values

DEFREGIONQ3Q2

private static final String DEFREGIONQ3Q2
Different allowed regions for different filters.

See Also:
Constant Field Values

c4lower

private Polynom c4lower
The polynom for the lower c4-sigma boundary.


c4upper

private Polynom c4upper
The polynom for the lower c4-sigma boundary.


ratios

private Map<String,List<Double>> ratios
The parsed maximum span-to-median ratios.


q1q0

private Map<String,Ellipse> q1q0
Each filter, has a q1/q0 and a q3/q2 valid range as an ellipse.


q3q2

private Map<String,Ellipse> q3q2
Each filter, has a q1/q0 and a q3/q2 valid range as an ellipse.

Constructor Detail

FlatCheck

public FlatCheck(Map<String,String> prop)
Defaults everything.

Method Detail

init

public void init()
Creates the lists for adu max and min and the polynoms for upper and lower c4 boundaries. Throws IllegalArgumentException if min/max list have different length.

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

parseRegionMap

private static Map<String,Ellipse> parseRegionMap(Map<String,String> region)
                                           throws ParseException
Parses a string to string mapping of filter to ellipse definitions into a filter to region mappping.

Throws:
ParseException

checkCentroidFromAverage

public List<FitsCheck.Failure> checkCentroidFromAverage(float[] av)
From the average of a flat observation, we check if the centroid is withinin bounds. The centroid is approximated by using the average of the four quadrants and weiging them with their respective x/y position on the CCD.
       x_c=0.5*(-Q0+Q1-Q2+Q3)/ΣQ
       y_c=0.5*(-Q0-Q1+Q2+Q3)/ΣQ
       
where the Q's are the average of the respective quadrants. A stuck filter wheel will manifest itself in a possible higher y-centroid.


checkC4

public List<FitsCheck.Failure> checkC4(String unique)
We calculate a statistic on the central normalized fourth moment of the four quadrants. The average to standard deviation relation is a very good proxy for the detection of a stuck filter wheel.


checkC4FromMoment

public List<FitsCheck.Failure> checkC4FromMoment(float[] av)
We calculate a statistic on the central normalized fourth moment of the four quadrants. The average to standard deviation relation is a very good proxy for the detection of a stuck filter wheel.


checkFlat

public List<FitsCheck.Failure> checkFlat(String unique)
We check a single flat field for possible failures. Only if the #checkLightLevel, the FitsCheck.checkCentroid(java.lang.String, float, float), and the checkC4(java.lang.String) test are passed, we also do the tile-check test.

Overrides:
checkFlat in class FitsCheck

checkTiles

public List<FitsCheck.Failure> checkTiles(String unique)
                                   throws IOException,
                                          nom.tam.fits.FitsException
From the unique id of the observation, we extract the fitz file to a temporary file and do a tile-check on it.

Throws:
IOException
nom.tam.fits.FitsException

checkTilesInFile

public List<FitsCheck.Failure> checkTilesInFile(File fits,
                                                String filter)
                                         throws IOException,
                                                nom.tam.fits.FitsException
Throws:
IOException
nom.tam.fits.FitsException

tileRatio

public static Vector2D[] tileRatio(nom.tam.fits.ImageHDU flat,
                                   int sub)
                            throws nom.tam.fits.FitsException
An exhaustive but time-consuming final check by dividing each quadrant into the stated number of quadratic sub-windows. From the median adus we deduce for a stuck filter wheel by checking the stretch of the medians vs. their average. In the ideal case of a totally flat image, this span/average should tend to zero, and in fact for true flats it tends to a few percent, while in a stuck filter wheel, this ratio may well reach one.

Throws:
nom.tam.fits.FitsException