ccd
Class DarkOverlapTiler

java.lang.Object
  extended by util.PropertyContainer
      extended by util.PropertyResources
          extended by util.PropertyBundles
              extended by ccd.DarkOverlapTiler
All Implemented Interfaces:
DriverDepending, Cloneable, ExitCleaning, Initializable, LocalizedSupplying, PropertySupplying, ResourceSupplying

public class DarkOverlapTiler
extends PropertyBundles
implements ExitCleaning, DriverDepending

A dark tiler splits an available (guider) CCD into individual tiles and tries to generate darks and bias for it. Different to the first class that had problematic points at the edges of the two layers, this is an overlapping tiler with four layers. Any point on the CCD (except points at the physical edge of the CCD) can be located in a tile where it has at least a quarter of the tile dimension to either side. It works as follows:

The class can be used in connection with AuxiliaryMaster to generated a heap of reductional frames for the guider CCD whenever the Telescope is idle and it is dark.
First test were with the KAF 3200E, acquire tiles 168x92 pixel and guide tiles of 42x46 pixel.


Nested Class Summary
static class DarkOverlapTiler.Check
          Checks the entire CCD for best tile-nr and edge distance.
static class DarkOverlapTiler.Current
          Retrieves the best-fitting dark and bias frames.
static class DarkOverlapTiler.Scan
          A class that allows scanning of directories to reconstruct the lookup tables.
static class DarkOverlapTiler.Standalone
          A standalone class, mainly for testing.
private  class DarkOverlapTiler.TilerThread
          A tiler thread is a thread that runs forever until its cancel method is called.
 
Nested classes/interfaces inherited from class util.PropertyResources
PropertyResources.URLResource
 
Field Summary
private static String AVERAGECOMMENT
          Fits comment for average temperatue.
private static String AVERAGETEMP
          Fits key word for average temperatue.
private static String BIAS
          Default bias ID.
private  List<SortedMap<Double,File>>[] biaslookup
          Lookup list for the different tiles sizes.
private  List<Dimension> binnings
          All tile binnings.
private  CcdDriver ccd
          My CCD driver interface.
private  int[] columns
          The number of tiles in x direction.
private static String DARK
          Default dark ID.
private  List<SortedMap<Double,File>>[] darklookup
          Lookup list for the different tiles sizes.
private static int DEFAVERAGECOUNT
          Number of frames to record on each tile for bias/dark.
private static long DEFBIASEXPOSE
          Exposure time in ms for the bias frames.
private static Point DEFCORNER
          Point of the upper left corner, i.e.
private static long DEFDARKEXPOSE
          Exposure time in ms for the dark frames.
private static Format DEFDARKFORMAT
          The formatter to name sub-dirs below dark.
private static String DEFEXITSTATE
          Resource where we write/read our current tile number.
private static boolean DEFSIMULATE
          Points to true if we should only simulate action.
private static Dimension DEFTILEBINNING
          Default binning used on all tile sizes, if not overruled.
private static Format DEFTILEFORMAT
          The formatter to name sub-dirs below dark runs.
private static Insets DEFTILEFRAME
          Frame of the overlap as an inset.
private static String HEADER
          Comment line in tile/temperature/fits-file lookup table.
static String KEY_ACTIVEAREA
          Size of the active area on the chip.
static String KEY_AVERAGECOUNT
          Number of frames to record on each tile for bias/dark.
static String KEY_BIASEXPOSE
          Exposure time in ms for the bias frames.
static String KEY_BIASLOOKUP
          The resource for restoring the bias lookup lists.
static String KEY_CORNER
          Point of the upper left corner, i.e.
static String KEY_DARKDIRECTORY
          Directory where we put the master frames.
static String KEY_DARKEXPOSE
          Exposure time in ms for the dark frames.
static String KEY_DARKFORMAT
          The formatter to name sub-dirs below dark.
static String KEY_DARKLOOKUP
          The resource for restoring the bias lookup lists.
static String KEY_DRIVER
          Name of the ccd driver.
static String KEY_EXITSTATE
          Resource where we write/read our current tile number.
static String KEY_SIMULATE
          Points to true if we should only simulate action.
static String KEY_TEMPERATURE
          Temperature sensor for matching dark currents.
static String KEY_TILEBINNING
          List of binning of the tiles, separator '|'.
static String KEY_TILEDIRECTORY
          Directory where we get the tile frames.
static String KEY_TILEFORMAT
          The formatter to name sub-dirs below dark.
static String KEY_TILEFRAME
          Extra border that overlaps each tile, if readout spoils.
static String KEY_TILESIZE
          List of dimension of the single tiles, separator '|'.
private static String MASTER
          Default master ID.
private  boolean matchnag
          Avoid to many errors.
private  int[] rows
          The number of tiles in y direction.
private  int runnr
          The current run number.
private static String SIGMA
          Default master ID.
private static String SIGMACOMMENT
          Fits comment for average temperatue.
private static String SIGMATEMP
          Fits key word for average temperatue.
private  int sizenr
          The tile size that is currently processed, index in array.
private  Value temperature
          If we have a temperature sensor.
private  int tilenr
          The tile number that is currently processed.
private  DarkOverlapTiler.TilerThread tilerthread
          The thread that does the work.
private  List<Dimension> tiles
          All tile sizes the active area is cut into.
private static String XOFF
          Fits key word for x corner.
private static String XOFFCOMMENT
          Fits comment for x corner .
private static String YOFF
          Fits key word for x corner.
private static String YOFFCOMMENT
          Fits comment for x corner .
 
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
DarkOverlapTiler(Map<String,String> prop)
          Construct the dark tiler.
 
Method Summary
private  int closestTile(int t0, Point2D p0)
          Scans for the tile which center is closest to the given point.
 void exit()
          On exit, we save the current tile.
 Rectangle getAccessible()
          Returns the accessible area on this dark tiler.
 Guiding.RawFrame getAround(int tilesize, Point2D tentative)
          Supply a tentative center of view in ccd-pixel, in the same pixel coordinate system as the acquire center and guiding center are defined.
private  File getMatching(int sizeidx, int tileidx, List<SortedMap<Double,File>>[] tab)
          Scans the look-up lists for the bias/dark frame that fits closest to the frame queried.
private  double getTemperature()
          Gets the current temperature, if applicable or zero.
private  int getTileCount(int tilesizeindex)
          Returns the number of tiles in the given tile size.
private  Dimension getTileSize(int tilesizeindex)
          Returns the tile dimension to the given index.
private  Rectangle getTileWindow(int nr, int sizeindex)
          From a valid tile number, we calculate the characteristics of the tile window, i.e.
 void init()
          On init, we first test if the active area can host the tile size.
private  List<SortedMap<Double,File>>[] loadLookup(URL resource)
          Creates a lookup list-array.
 boolean registerDriver(Driver fechi)
          Registers the CCD-driver.
private static boolean saveLookup(File write, List<SortedMap<Double,File>>[] tab)
          Saves our specific look-up list (bias or dark) to the specified file.
private static boolean saveLookup(URL where, List<SortedMap<Double,File>>[] tab)
          Saves our specific look-up list (bias or dark) to the specified resource if this resource points to a file that can be writtn.
private static boolean saveRun(File state, int run, int size, int tile)
          Saves the current run number, size number and tile number.
 boolean start()
          Starts the tiler.
 boolean stop()
          Stops the tiler.
 
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_DRIVER

public static final String KEY_DRIVER
Name of the ccd driver.

See Also:
Constant Field Values

KEY_CORNER

public static final String KEY_CORNER
Point of the upper left corner, i.e. where the active area stars.

See Also:
Constant Field Values

KEY_TILESIZE

public static final String KEY_TILESIZE
List of dimension of the single tiles, separator '|'.

See Also:
Constant Field Values

KEY_TILEFRAME

public static final String KEY_TILEFRAME
Extra border that overlaps each tile, if readout spoils.

See Also:
Constant Field Values

KEY_TILEBINNING

public static final String KEY_TILEBINNING
List of binning of the tiles, separator '|'.

See Also:
Constant Field Values

KEY_ACTIVEAREA

public static final String KEY_ACTIVEAREA
Size of the active area on the chip.

See Also:
Constant Field Values

KEY_EXITSTATE

public static final String KEY_EXITSTATE
Resource where we write/read our current tile number.

See Also:
Constant Field Values

KEY_TEMPERATURE

public static final String KEY_TEMPERATURE
Temperature sensor for matching dark currents.

See Also:
Constant Field Values

KEY_AVERAGECOUNT

public static final String KEY_AVERAGECOUNT
Number of frames to record on each tile for bias/dark.

See Also:
Constant Field Values

KEY_BIASEXPOSE

public static final String KEY_BIASEXPOSE
Exposure time in ms for the bias frames.

See Also:
Constant Field Values

KEY_DARKEXPOSE

public static final String KEY_DARKEXPOSE
Exposure time in ms for the dark frames.

See Also:
Constant Field Values

KEY_TILEDIRECTORY

public static final String KEY_TILEDIRECTORY
Directory where we get the tile frames.

See Also:
Constant Field Values

KEY_DARKDIRECTORY

public static final String KEY_DARKDIRECTORY
Directory where we put the master frames.

See Also:
Constant Field Values

KEY_DARKFORMAT

public static final String KEY_DARKFORMAT
The formatter to name sub-dirs below dark.

See Also:
Constant Field Values

KEY_TILEFORMAT

public static final String KEY_TILEFORMAT
The formatter to name sub-dirs below dark.

See Also:
Constant Field Values

KEY_SIMULATE

public static final String KEY_SIMULATE
Points to true if we should only simulate action.

See Also:
Constant Field Values

KEY_BIASLOOKUP

public static final String KEY_BIASLOOKUP
The resource for restoring the bias lookup lists.

See Also:
Constant Field Values

KEY_DARKLOOKUP

public static final String KEY_DARKLOOKUP
The resource for restoring the bias lookup lists.

See Also:
Constant Field Values

BIAS

private static final String BIAS
Default bias ID.

See Also:
Constant Field Values

DARK

private static final String DARK
Default dark ID.

See Also:
Constant Field Values

MASTER

private static final String MASTER
Default master ID.

See Also:
Constant Field Values

SIGMA

private static final String SIGMA
Default master ID.

See Also:
Constant Field Values

AVERAGETEMP

private static final String AVERAGETEMP
Fits key word for average temperatue.

See Also:
Constant Field Values

AVERAGECOMMENT

private static final String AVERAGECOMMENT
Fits comment for average temperatue.

See Also:
Constant Field Values

SIGMATEMP

private static final String SIGMATEMP
Fits key word for average temperatue.

See Also:
Constant Field Values

SIGMACOMMENT

private static final String SIGMACOMMENT
Fits comment for average temperatue.

See Also:
Constant Field Values

XOFF

private static final String XOFF
Fits key word for x corner.

See Also:
Constant Field Values

XOFFCOMMENT

private static final String XOFFCOMMENT
Fits comment for x corner .

See Also:
Constant Field Values

YOFF

private static final String YOFF
Fits key word for x corner.

See Also:
Constant Field Values

YOFFCOMMENT

private static final String YOFFCOMMENT
Fits comment for x corner .

See Also:
Constant Field Values

HEADER

private static final String HEADER
Comment line in tile/temperature/fits-file lookup table.

See Also:
Constant Field Values

DEFCORNER

private static final Point DEFCORNER
Point of the upper left corner, i.e. where the active area stars.


DEFTILEFRAME

private static final Insets DEFTILEFRAME
Frame of the overlap as an inset. Real frame bigger by that amount.


DEFTILEBINNING

private static final Dimension DEFTILEBINNING
Default binning used on all tile sizes, if not overruled.


DEFEXITSTATE

private static final String DEFEXITSTATE
Resource where we write/read our current tile number.

See Also:
Constant Field Values

DEFAVERAGECOUNT

private static final int DEFAVERAGECOUNT
Number of frames to record on each tile for bias/dark.

See Also:
Constant Field Values

DEFBIASEXPOSE

private static final long DEFBIASEXPOSE
Exposure time in ms for the bias frames.

See Also:
Constant Field Values

DEFDARKEXPOSE

private static final long DEFDARKEXPOSE
Exposure time in ms for the dark frames.

See Also:
Constant Field Values

DEFDARKFORMAT

private static final Format DEFDARKFORMAT
The formatter to name sub-dirs below dark.


DEFTILEFORMAT

private static final Format DEFTILEFORMAT
The formatter to name sub-dirs below dark runs.


DEFSIMULATE

private static final boolean DEFSIMULATE
Points to true if we should only simulate action.

See Also:
Constant Field Values

ccd

private CcdDriver ccd
My CCD driver interface.


biaslookup

private List<SortedMap<Double,File>>[] biaslookup
Lookup list for the different tiles sizes. Maps temperature to path.


darklookup

private List<SortedMap<Double,File>>[] darklookup
Lookup list for the different tiles sizes. Maps temperature to path.


tiles

private List<Dimension> tiles
All tile sizes the active area is cut into.


binnings

private List<Dimension> binnings
All tile binnings.


columns

private int[] columns
The number of tiles in x direction.


rows

private int[] rows
The number of tiles in y direction.


runnr

private int runnr
The current run number.


tilenr

private int tilenr
The tile number that is currently processed.


sizenr

private int sizenr
The tile size that is currently processed, index in array.


temperature

private Value temperature
If we have a temperature sensor.


tilerthread

private DarkOverlapTiler.TilerThread tilerthread
The thread that does the work.


matchnag

private boolean matchnag
Avoid to many errors.

Constructor Detail

DarkOverlapTiler

public DarkOverlapTiler(Map<String,String> prop)
Construct the dark tiler.

Method Detail

init

public void init()
On init, we first test if the active area can host the tile size. This means that the active area is a plain multiple of the tile size, both in x and y and that the tile size fits at least twice in both directions. If this still holds, we see if we have a exit state to restore, otherwise we start with tile number zero. If a temperature sensor is indicated, we construct it here.

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

registerDriver

public boolean registerDriver(Driver fechi)
Registers the CCD-driver. Registering is successful if the driver is a CCD-driver and the driver name matches the KEY_DRIVER property. We query its size to see if the active area plus the corner offset fits into it.

Specified by:
registerDriver in interface DriverDepending
Returns:
True if registering at the driver was successful.

getAccessible

public Rectangle getAccessible()
Returns the accessible area on this dark tiler.


start

public boolean start()
Starts the tiler. This creates and starts a new tiler thread, which can be canceled using stop(). If the tiler is already active, we return silently.


stop

public boolean stop()
Stops the tiler. This sets the cancel flag on the tiler thread, which will stop the execution of the tiler as soon as the next readout finished.


exit

public void exit()
On exit, we save the current tile. This method should be called only after the tiler thread has been canceld with stop(), otherwise it may take some time to execute.

Specified by:
exit in interface ExitCleaning

getAround

public Guiding.RawFrame getAround(int tilesize,
                                  Point2D tentative)
Supply a tentative center of view in ccd-pixel, in the same pixel coordinate system as the acquire center and guiding center are defined. This method then scans its repository of known tiles and returns a combined object that holds the tile window (set this on the guider chip), and, if applicable, the bias and dark frame currently best fitting to temperature.


closestTile

private int closestTile(int t0,
                        Point2D p0)
Scans for the tile which center is closest to the given point. If the point is not in the active area, null is returned.


getTileWindow

private Rectangle getTileWindow(int nr,
                                int sizeindex)
From a valid tile number, we calculate the characteristics of the tile window, i.e. its upper-left corner and size.


getMatching

private File getMatching(int sizeidx,
                         int tileidx,
                         List<SortedMap<Double,File>>[] tab)
Scans the look-up lists for the bias/dark frame that fits closest to the frame queried. Returns null if no frame is available for the queired tile size or tile number. If there is a frame available, the current temperature is used to get the fits file with the closest temperature. No effort is made to interpolate between neighbouring frames.


getTemperature

private double getTemperature()
Gets the current temperature, if applicable or zero.


getTileCount

private int getTileCount(int tilesizeindex)
Returns the number of tiles in the given tile size.


getTileSize

private Dimension getTileSize(int tilesizeindex)
Returns the tile dimension to the given index.


loadLookup

private List<SortedMap<Double,File>>[] loadLookup(URL resource)
Creates a lookup list-array. The index in the array points to the tile size. Each lookup-list is actually a list of tile numbers to sorted lookup-maps of temperature values to file path's. Format of the ascii-resource:
       tilesizeindex tilenumber Temperature absoultePath.


saveRun

private static boolean saveRun(File state,
                               int run,
                               int size,
                               int tile)
Saves the current run number, size number and tile number.


saveLookup

private static boolean saveLookup(URL where,
                                  List<SortedMap<Double,File>>[] tab)
Saves our specific look-up list (bias or dark) to the specified resource if this resource points to a file that can be writtn. No exceptions are thrown, as this method is normally invoked on system exit.


saveLookup

private static boolean saveLookup(File write,
                                  List<SortedMap<Double,File>>[] tab)
Saves our specific look-up list (bias or dark) to the specified file. No exceptions are thrown, as this method is normally invoked on system exit.