/* @file  pmDetrendDB.h
 * @brief Tools to query the detrend database system
 *
 * the functions in here do not perform the detrend database queries directly.  all interfaces
 * to the detrend database go through the external dettools functions.  this allows the modules
 * and directly dependent program to be sufficiently independent of the database schema that it
 * can be used with any properly defined detrend database tables.
 *
 * @author EAM, IfA
 *
 * @version $Revision: 1.8 $ $Name: not supported by cvs2svn $
 * @date $Date: 2007-01-31 00:35:24 $
 * Copyright 2004-2005 Institute for Astronomy, University of Hawaii
 */

#ifndef PM_DETREND_DB_H
#define PM_DETREND_DB_H

/// @addtogroup detrend Detrend Creation and Application
/// @{

#include "pmConfig.h"
#include "pmFPALevel.h"

typedef enum {
    PM_DETREND_TYPE_MASK,
    PM_DETREND_TYPE_BIAS,
    PM_DETREND_TYPE_DARK,
    PM_DETREND_TYPE_FLAT,
    PM_DETREND_TYPE_FLAT_CORRECTION,
    PM_DETREND_TYPE_SHUTTER,
    PM_DETREND_TYPE_FRINGE_IMAGE,
    PM_DETREND_TYPE_FRINGE_TABLE,
    PM_DETREND_TYPE_BACKGROUND,
} pmDetrendType;

typedef struct
{
    char *camera;   // name of camera
    psTime time;   // time of input data
    pmDetrendType type;   // type of detrend data
    char *filter;   // name of filter
    float exptime;   // exposure time (for dark, maybe flat & fringe)
    float airmass;   // for fringe
}
pmDetrendSelectOptions;

typedef struct
{
    char *detID;   // identifier of detrend run
    pmFPALevel level;   // level in FPA hierarchy of individual file
}
pmDetrendSelectResults;

typedef struct
{
    char *detID;   // identifier of detrend image
    char *classID;   // level in FPA hierarchy of individual file
}
pmDetrendFileOptions;

psString pmDetrendTypeToString (pmDetrendType type);

pmDetrendSelectOptions *pmDetrendSelectOptionsAlloc(const char *camera, psTime time, pmDetrendType type);
pmDetrendSelectResults *pmDetrendSelectResultsAlloc();
pmDetrendSelectResults *pmDetrendSelect (const pmDetrendSelectOptions *options, const pmConfig *config);
char *pmDetrendFile (const char *detID, const char *classID, const pmConfig *config);

/// @}
# endif
