astro.fits
Class IcatFinalize

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

public class IcatFinalize
extends Icat

Last class in the chain of ICAT-preparation tools. This class again reads the science lookup tables and copies the final, reduced frame on the original location, but augmented by #ICATFINAL to indicate this frame as the final, single-extension ICAT frame. The sextractor output is also copied to this location, with the SEXTRACTOR extension. This may be fed into the stella db on the wifsip table, using


Nested Class Summary
static class IcatFinalize.Products
          The final data products.
 
Nested classes/interfaces inherited from class astro.fits.Icat
Icat.Compress, Icat.Snoop, Icat.Uncompress
 
Nested classes/interfaces inherited from class util.PropertyResources
PropertyResources.URLResource
 
Field Summary
private static String DEFEXTENSIONCARDS
          Default cards that remain in extension.
private static String DEFKEEP
          Default we keep the data, the mosaic, and the flat-field corr.
private static boolean DEFONLYCLEAN
          Default only act on clean targets.
private static String DEFREMOVECARDS
          Default cards that are removed.
private static boolean DEFWASJOINED
          Default only act on clean targets.
private  List<IcatFinalize.Products> keep
          The list of products we want to keep.
static String KEY_EXTENSIONCARDS
          Cards the are left in the extension section, all others moved up.
static String KEY_KEEP
          Which data products I want to keep.
static String KEY_ONLYCLEAN
          If true, we only proceed if a clean output dir was encountered.
static String KEY_REMOVECARDS
          Cards that are removed, if present.
static String KEY_WASJOINED
          If true, we also check for joined files..
private static String PRODUCTKEY
           
 
Fields inherited from class astro.fits.Icat
BIASCOMBINED, DATAEXTENSION, DEFFROM, EXPTIME, FE, FLATHEADBIAS, FLATHEADDARK, FLATMASTERBIAS, FLATMASTERDARK, FLATMASTERSIGMA, INDEXCAL, INDEXSCI, INPUTBIAS, INPUTDARK, INPUTFLATPART, KEY_ANALYSISPAR, KEY_ANALYSISPARNO, KEY_ANALYSISPARYES, KEY_ARCHIVE, KEY_CALIBPAR, KEY_CALIBPARDARK, KEY_CALIBPARNODARK, KEY_CALIBPARSKIP, KEY_DATEKEY, KEY_EXPOSUREKEY, KEY_FILTERKEY, KEY_FROM, KEY_ICATDIR, KEY_ICATIN, KEY_IMAGETYPEKEY, KEY_IMCOPY, KEY_IMCOPYFLAG, KEY_LOCALFITS, KEY_LOCALTMP, KEY_MODEANALYSE, KEY_MODEPAR, KEY_REDUCED, KEY_REDUCEDONE, KEY_REPLACEFROM, KEY_REPLACETO, KEY_SERIALIZE, KEY_TO, lookbias, lookdark, lookflat, lookup, OUT, OUTBDSFLAT, OUTBIAS, OUTBSFLAT, PHOTOMETRYASC, QUADRANTS, SCIENCEBDFLAT, SCIENCEBFLAT, SCIENCEBIAS, SCIENCEDARK, SCIENCEFINAL, SCIENCERAW, SCIENCETEMP, YYYYMMDD
 
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
IcatFinalize(Map<String,String> prop)
          Defaults the data products to keep permanently.
 
Method Summary
private  boolean bias(String prod, String ext, String rem)
          Method called to copy the bias subtracted, per quadrant fits to a single fits with four extension.
 boolean checkLookup()
          We check, if the restored lookup-tables can be orderly matched to files in the output directories.
private  boolean data(String prod, String ext, String rem)
          Method called to copy the sextractor output files to the original source directory.
private  boolean flat(String prod, String ext, String rem)
          Method called to copy the bias/dark subtracted, flat normalized per quadrant fits to a single fits with four extension.
private  boolean flatSigma(String prod, String ext, String rem)
          Method called to preserve the sigma maps master flat.
 boolean generateProducts()
          Generates all data products requested.
 void init()
          On init, we restore the lookup tables and prepare the fits-key jugling.
static void main(String[] arg)
           
private  boolean masterBias(String prod, String ext, String rem)
          Method called to preserve the master bias.
private  boolean masterFlat(String prod, String ext, String rem)
          Method called to preserve the normalized master flat.
private  boolean mosaic(String prod, String ext, String rem)
          Method called to copy the mosaic file to the original source directory.
private  boolean quadrants(Map<File,String> restore, String icatext, String ext, String prod, String rem)
          Method called to merge four single-quadrant output files into a single fits and compress it.
private static int removeMatch(List<String> ls, Collection<String> trunk, String need, String... allow)
          We scan all names in the trunk collection for occurences in the file listing, in a way that we throw an exception if a file trunk+need is not found, and report missing files according to trunk+allow[].
 
Methods inherited from class astro.fits.Icat
addExtension, compress, getIcatInputExtension, getIcatName, getIcatOutputExtension, getInput, getMain, getOutput, getQuadrantInput, getQuadrantOutput, getSerializeFile, reducedDir, restoreLookup, saveLookup, sendMail, uncompress
 
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_KEEP

public static final String KEY_KEEP
Which data products I want to keep.

See Also:
Constant Field Values

KEY_ONLYCLEAN

public static final String KEY_ONLYCLEAN
If true, we only proceed if a clean output dir was encountered.

See Also:
Constant Field Values

KEY_WASJOINED

public static final String KEY_WASJOINED
If true, we also check for joined files..

See Also:
Constant Field Values

KEY_EXTENSIONCARDS

public static final String KEY_EXTENSIONCARDS
Cards the are left in the extension section, all others moved up.

See Also:
Constant Field Values

KEY_REMOVECARDS

public static final String KEY_REMOVECARDS
Cards that are removed, if present.

See Also:
Constant Field Values

DEFKEEP

private static final String DEFKEEP
Default we keep the data, the mosaic, and the flat-field corr.

See Also:
Constant Field Values

DEFONLYCLEAN

private static final boolean DEFONLYCLEAN
Default only act on clean targets.

See Also:
Constant Field Values

DEFWASJOINED

private static final boolean DEFWASJOINED
Default only act on clean targets.

See Also:
Constant Field Values

DEFEXTENSIONCARDS

private static final String DEFEXTENSIONCARDS
Default cards that remain in extension.

See Also:
Constant Field Values

DEFREMOVECARDS

private static final String DEFREMOVECARDS
Default cards that are removed.

See Also:
Constant Field Values

PRODUCTKEY

private static final String PRODUCTKEY
See Also:
Constant Field Values

keep

private List<IcatFinalize.Products> keep
The list of products we want to keep.

Constructor Detail

IcatFinalize

public IcatFinalize(Map<String,String> prop)
Defaults the data products to keep permanently.

Method Detail

init

public void init()
On init, we restore the lookup tables and prepare the fits-key jugling.

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

checkLookup

public boolean checkLookup()
We check, if the restored lookup-tables can be orderly matched to files in the output directories. If matching fails, this is considered a severe error and an IllegalArgumentException is thrown. If more files are found than restored, false is returned.

Returns:
True, if the lookuplist exactly correponds to files in the output dir.

removeMatch

private static int removeMatch(List<String> ls,
                               Collection<String> trunk,
                               String need,
                               String... allow)
We scan all names in the trunk collection for occurences in the file listing, in a way that we throw an exception if a file trunk+need is not found, and report missing files according to trunk+allow[]. After all checks, the remaining file list should be empty, otherwise we have leftover from an undefined reduction run.


generateProducts

public boolean generateProducts()
Generates all data products requested. Returns false if not all products have been available.


mosaic

private boolean mosaic(String prod,
                       String ext,
                       String rem)
Method called to copy the mosaic file to the original source directory.


data

private boolean data(String prod,
                     String ext,
                     String rem)
Method called to copy the sextractor output files to the original source directory.


bias

private boolean bias(String prod,
                     String ext,
                     String rem)
              throws nom.tam.fits.FitsException,
                     IOException
Method called to copy the bias subtracted, per quadrant fits to a single fits with four extension.

Throws:
nom.tam.fits.FitsException
IOException

flat

private boolean flat(String prod,
                     String ext,
                     String rem)
              throws nom.tam.fits.FitsException,
                     IOException
Method called to copy the bias/dark subtracted, flat normalized per quadrant fits to a single fits with four extension.

Throws:
nom.tam.fits.FitsException
IOException

masterFlat

private boolean masterFlat(String prod,
                           String ext,
                           String rem)
                    throws nom.tam.fits.FitsException,
                           IOException
Method called to preserve the normalized master flat.

Throws:
nom.tam.fits.FitsException
IOException

flatSigma

private boolean flatSigma(String prod,
                          String ext,
                          String rem)
                   throws nom.tam.fits.FitsException,
                          IOException
Method called to preserve the sigma maps master flat.

Throws:
nom.tam.fits.FitsException
IOException

masterBias

private boolean masterBias(String prod,
                           String ext,
                           String rem)
                    throws nom.tam.fits.FitsException,
                           IOException
Method called to preserve the master bias.

Throws:
nom.tam.fits.FitsException
IOException

quadrants

private boolean quadrants(Map<File,String> restore,
                          String icatext,
                          String ext,
                          String prod,
                          String rem)
                   throws nom.tam.fits.FitsException,
                          IOException
Method called to merge four single-quadrant output files into a single fits and compress it.

Throws:
nom.tam.fits.FitsException
IOException

main

public static void main(String[] arg)