IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 4555


Ignore:
Timestamp:
Jul 14, 2005, 2:54:03 PM (21 years ago)
Author:
Paul Price
Message:

Major changes to configuration, focal plane hierarchy.

Location:
trunk/doc/modules
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/doc/modules/CameraImages.tex

    r4176 r4555  
    1 \section{Astronomical Images}
     1\section{Focal Plane}
     2\label{sec:focalplane}
    23
    34\subsection{Overview}
    45
    5 Above, we have defined a basic container for a single 2D collection of
    6 pixels (\code{psImage}), along with basic operations to manipulate the
    7 image pixels.  For astronomical applications, this data structure is
    8 insufficient for two reasons.  First, it does provide sufficient
    9 additional metadata to describe the data in detail.  Second, astronomy
    10 applications frequent involve multiple, related images.  For
    11 Pan-STARRS, and for general astronomical applications, we require a
    12 richer collection of data structures which describe a very general
    13 image concept.  We have defined several layers in the hierarchy which
    14 are necessary to describe the image data which will be produced by the
    15 Pan-STARRS Gigapixel cameras as well as other standard astronomical
    16 images. 
    17 
    18 A simple 2D image is a basic data unit for much of astronomical
    19 imaging.  If we consider various optical and IR array cameras, a
    20 single readout of the detector produces a collection of pixels
    21 measurements which is well represented as a single 2D image.  We
    22 define our lowest-level astronomical image structure,
    23 \code{psReadout}, to contain the pixels produced by a single readout
    24 of the detector, along with metadata needed to define that readout:
    25 the origin and binning of the image relative to the original detector
    26 pixels explicitly in the structure, and pointers to the general
    27 metadata and derived objects, if any.
     6In PSLib, we have defined a basic container for a single 2D collection
     7of pixels (\code{psImage}), along with basic operations to manipulate
     8the image pixels.  For astronomical applications, this data structure
     9is insufficient for two reasons.  First, it does not provide
     10sufficient additional metadata to describe the data in detail.
     11Second, astronomy applications frequently involve multiple, related
     12images.  For Pan-STARRS, and for general astronomical applications, we
     13require a richer collection of data structures which describe a very
     14general image concept.  We have defined several layers in the
     15hierarchy which are necessary to describe the image data which will be
     16produced by the Pan-STARRS GigaPixel Cameras as well as other standard
     17astronomical images.
     18
     19A simple 2D image is the basic data unit for much of astronomical
     20imaging: if we consider various optical and IR array cameras, a single
     21readout of the detector produces a collection of pixel measurements
     22which is well represented as a single 2D image.  We define our
     23lowest-level astronomical image structure, \code{pmReadout}, to
     24contain the pixels produced by a single readout of the detector, along
     25with metadata needed to define that readout: the origin and binning of
     26the image relative to the original detector pixels explicitly in the
     27structure, and pointers to the general metadata and derived objects,
     28if any.
    2829
    2930A single detector may be read multiple times in sequence.  For
     
    3334though the binning or rastering may be different between the two
    3435readouts.  Another example is the video sequence produced by the
    35 Pan-STARRS Gigapix camera guide cells, each of which represents a
     36Pan-STARRS GigaPixel Camera guide cells, each of which represents a
    3637series of many images from a subraster of pixels in the detector
    3738readout portion.  The second level of our image container hierarchy,
    38 \code{psCell}, consists of a collection of readouts from a single
     39\code{pmCell}, consists of a collection of readouts from a single
    3940detector.
    4041
    41 In the Pan-STARRS Gigapix camera, the basic readout region is a
     42In the Pan-STARRS GigaPixel camera, the basic readout region is a
    4243fraction of the full imaging area of a single CCD chip.  The chip is
    43 divided into 64 cells, any fraction of which may have been readout
    44 for a given exposure.  In other cameras, such as Megacam at CFHT, the
     44divided into 64 cells, any fraction of which may have been readout for
     45a given exposure.  In other cameras, such as Megacam at CFHT, the
    4546individual CCDs have multiple amplifiers addressing contiguous
    4647portions of the detector.  In such cameras, each amplifier produces a
    4748separate collection of pixels.  In the third level of our image
    48 container hierarchy, the data structure \code{psChip} represents a
    49 collection of different cells.   
     49container hierarchy, the data structure \code{pmChip} represents a
     50collection of different cells.
    5051
    5152The top level of our image container hierarchy is a complete focal
    52 plane array (\code{psFPA}).  This structure represents the collection
     53plane array (\code{pmFPA}).  This structure represents the collection
    5354of chips in the camera, all of which are read out in a given
    5455exposure. 
     
    5657For example, take a mosaic camera consisting of eight $2k\times 4k$
    5758CCDs, each of which is read out through two amplifiers.  Then there
    58 would be sixteen cells in total, each of which is presumably $2k\times
    59 2k$.  There would be eight chips, each consisting of two cells, and
     59would be sixteen cells in total, each of which is presumably $1k\times
     604k$.  There would be eight chips, each consisting of two cells, and
    6061the focal plane consists of these eight chips.
    6162
     
    6970functions or the structures that each instance of one of these data
    7071structures represent the physical hardware.  For example, it is not
    71 necessary that an instance of \code{psFPA} always carry the data for
    72 all 60 (or 64) Gigapixel camera OTAs.  The usage of these structures
    73 is such that all astronomical operations which apply to a CCD image
    74 should be performed on an instance of \code{psFPA}.  If a particular
     72necessary that an instance of \code{pmFPA} always carry the data for
     73all 60 GigaPixel Camera OTAs.  The usage of these structures is such
     74that all astronomical operations which apply to a CCD image should be
     75performed on an instance of \code{pmFPA}.  If a particular
    7576circumstance only requires a single 2D image, then that is represented
    76 by an instance of \code{psFPA} with one \code{psChip}, which in turn
    77 has one \code{psCell}, which in turn has one \code{psReadout}. 
     77by an instance of \code{pmFPA} with one \code{pmChip}, which in turn
     78has one \code{pmCell}, which in turn has one \code{pmReadout}.
    7879
    7980The data structures defined below provide two additional features
    8081beyond the hierarchy of relationships.  First, each level of the
    81 hierarchy includes a generic \code{psMetadata} pointer to provide
    82 whatever metadata would be appropriate for that level.  The functions
    83 within PSLib do not specify the contents of those metadata containers.
    84 One example of their usage is provided in the documentation for the
    85 Pan-STARRS IPP collection of data processing modules. 
     82hierarchy includes hooks for carrying metadata to provide the PS
     83concepts and analysis metadata that would be appropriate for that
     84level.  The functions within PSLib do not specify the contents of
     85those metadata containers.
    8686
    8787While the \code{psMetadata} pointers provide a mechanism to carry
     
    9191information are provided.  In the first case, basic offsets (and in
    9292the case of the readouts, binning and flips) are defined to specify
    93 the location of a given \code{psCell} with respect to its containing
    94 \code{psChip} in the assumption that the pixels in the entire focal
     93the location of a given \code{pmCell} with respect to its containing
     94\code{pmChip} in the assumption that the pixels in the entire focal
    9595plane array are laid out on a uniform grid.  This is a crude
    9696approximation, and cannot be assumed for careful astrometric analysis,
     
    9999transformations between one frame and the next are also provided.
    100100
    101 \tbd{in the future, it may be worthwhile to migrate all of these
     101\tbd{In the future, it may be worthwhile to migrate all of these
    102102additional pieces to the psMetadata since there is no pressing need to
    103103have them visible in the data structures}
     
    108108
    109109A readout is the result of a single read of a cell (or a portion
    110 thereof).  It contains a pointer to the pixel data, and additional
    111 pointers to the objects found in the readout, and the readout
    112 metadata.  It also contains the offset from the lower-left corner of
    113 the chip, in the case that the CCD was windowed.
     110thereof).  It contains the offset from the lower-left corner of
     111the chip, in the case that the CCD was windowed, as well as the
     112binning factors and parity (if the binning value is negative, then
     113the parity is reversed).  It also contains the pixel data, metadata
     114containers for the concepts and analysis, and a link to the parent.
    114115
    115116\begin{verbatim}
    116117typedef struct {
    117     const int col0;                    ///< Offset from the left of cell.
    118     const int row0;                    ///< Offset from the bottom of cell.
    119     const int colParity;               ///< Readout Direction X
    120     const int rowParity;               ///< Readout Direction Y
    121     const unsigned int colBins;        ///< Amount of binning in x-dimension
    122     const unsigned int rowBins;        ///< Amount of binning in y-dimension
    123     psImage* image;                    ///< imaging area of Readout
    124     psMetadata* metadata;              ///< readout-level metadata
    125 } psReadout;
     118    // Position on the cell
     119    int col0;                          // Offset from the left of cell.
     120    int row0;                          // Offset from the bottom of cell.
     121    int colBins;                       // Amount of binning in x-dimension and parity (from sign)
     122    int rowBins;                       // Amount of binning in y-dimension and parity (from sign)
     123    // Information
     124    psImage *image;                    // Imaging area of readout
     125    psMetadata *analysis;              // Readout-level analysis metadata
     126    psMetadata *concepts;              // Cache for PS concepts
     127    pmCell *parent;                    // Parent cell
     128} pmReadout;
    126129\end{verbatim}   
    127130
    128 The constructor for \code{psReadout} shall be:
    129 \begin{verbatim}
    130 psReadout *psReadoutAlloc();
    131 \end{verbatim}
    132 All pointers in the structure shall be initialized to \code{NULL}.
     131The constructor for \code{pmReadout} shall be:
     132\begin{verbatim}
     133pmReadout *pmReadoutAlloc(pmCell *cell);
     134\end{verbatim}
     135The constructor shall make an empty \code{pmReadout}.  If the parent
     136\code{cell} is not \code{NULL}, the \code{parent} link is made and the
     137readout shall be placed in the parent's array of \code{readouts}.  The
     138metadata containers shall be allocated.  All other pointers in the
     139structure shall be initialized to \code{NULL}.
    133140
    134141\subsubsection{A Cell}
    135142
    136 A cell consists of one or more readouts (usually only one except in the
    137 case that the cell has been used for fast guiding).  It also contains
    138 a pointer to the cell metadata, and a pointer to its parent chip.  On
    139 the astrometry side, it also contains coordinate transforms from the
    140 cell to the chip and, as a convenience, from the cell to the focal
    141 plane.  It is expected that these transforms will consist of two
    142 first-order 2D polynomials, simply specifying a translation, rotation
    143 and magnification; hence they are easily inverted, and there is no
    144 need to add reverse transformations.  We also add an additional
    145 transformation, which is intended to provide a ``quick and dirty''
    146 transform from the cell coordinates to the sky; this transformation
    147 not guaranteed to be as precise as the ``standard'' transformation of
    148 Cell $\rightarrow$ Chip $\rightarrow$ Focal Plane $\rightarrow$
    149 Tangent Plane $\rightarrow$ Sky, but will be faster.
     143A cell consists of one or more readouts (usually only one except in
     144the case that the cell has been used for fast guiding, or similar
     145situations).  It have values which specifies the position of the cell
     146on the chip for rough positioning, along with more precise coordinate
     147transforms from the cell to the chip and, as a convenience, from the
     148cell directly to the focal plane.  It is expected that these
     149transforms will consist of two first-order 2D polynomials, simply
     150specifying a translation, rotation and magnification; hence they are
     151easily inverted, and there is no need to add reverse transformations.
     152We also add an additional transformation, which is intended to provide
     153a ``quick and dirty'' transform from the cell coordinates to the sky;
     154this transformation not guaranteed to be as precise as the
     155``standard'' transformation of Cell $\rightarrow$ Chip $\rightarrow$
     156Focal Plane $\rightarrow$ Tangent Plane $\rightarrow$ Sky, but will be
     157faster.  The cell also contains metadata containers for the concepts
     158and analysis, a link to the parent, and pointers to the various FITS
     159data, if that corresponds to this level.
    150160
    151161\begin{verbatim}
    152162typedef struct {
    153     const int col0;                    ///< Offset from the left of chip.
    154     const int row0;                    ///< Offset from the bottom of chip.
    155     psArray* readouts;                 ///< readouts from the cell
    156     psMetadata* metadata;              ///< cell-level metadata
    157     psPlaneTransform* toChip;          ///< transformations from cell to chip coordinates
    158     psPlaneTransform* toFPA;           ///< transformations from cell to FPA coordinates
    159     psPlaneTransform* toSky;           ///< transformations from cell to sky coordinates
    160     psChip *parent;
    161 } psCell;
    162 \end{verbatim}
    163 
    164 The constructor for \code{psCell} shall be:
    165 \begin{verbatim}
    166 psCell *psCellAlloc(int nReadouts, struct psChip *parentChip);
    167 \end{verbatim}
    168 The constructor shall make an empty \code{psCell}, with the
    169 \code{nReadouts} allocated pointers to \code{psReadout}s being set to
    170  \code{NULL}.  If \code{nreadouts} is zero or less, then 1 readout
    171 shall be allocated.  In either case, the value of
    172 \code{psCell.readouts.n} should be initially set to 0.  If the
    173 \code{parentChip} is not NULL, this link is made, otherwise it is set
    174 to \code{NULL}. All other pointers in the structure shall be
    175 initialized to \code{NULL}.
     163    // Offset specifying position on chip
     164    int col0;                          // Offset from the left of chip.
     165    int row0;                          // Offset from the bottom of chip.
     166    // Astrometric transformations
     167    psPlaneTransform* toChip;          // Transformations from cell to chip coordinates
     168    psPlaneTransform* toFPA;           // Transformations from cell to FPA coordinates
     169    psPlaneTransform* toSky;           // Transformations from cell to sky coordinates
     170    // Information
     171    psMetadata *concepts;              // Cache for PS concepts
     172    psMetadata *analysis;              // Cell-level analysis metadata
     173    psArray *readouts;                 // The readouts (referred to by number)
     174    pmChip *parent;                    // Parent chip
     175    // FITS data
     176    const char *extname;               // Extension name, if it corresponds to this level
     177    psArray *pixels;                   // The pixel data, if it corresponds to this level
     178    psMetadata *header;                // The FITS header, if it corresponds to this level
     179} pmCell;
     180\end{verbatim}
     181
     182The constructor for \code{pmCell} shall be:
     183\begin{verbatim}
     184pmCell *pmCellAlloc(pmChip *chip);
     185\end{verbatim}
     186The constructor shall make an empty \code{pmCell}.  If the parent
     187\code{chip} is not \code{NULL}, the \code{parent} link is made and the
     188cell shall be placed in the parent's array of \code{cells}.  The
     189\code{readouts} array shall be allocated with a zero size, and the
     190metadata containers constructed.  All other pointers in the structure
     191shall be initialized to \code{NULL}.
    176192
    177193\subsubsection{A Chip}
    178194
    179195A chip consists of one or more cells (according to the number of
    180 amplifiers on the CCD).  It contains a pointer to the chip metadata,
    181 and a pointer to the parent focal plane.  For astrometry, it contains
    182 a coordinate transform from the chip to the focal plane.  It is
    183 expected that this transforms will consist of two second-order 2D
    184 polynomials; hence we think that it is prudent to include a reverse
    185 transformation which will be derived from numerically inverting the
    186 forward transformation.
     196amplifiers on the device).  The chip contains metadata containers for
     197the concepts and analysis, a link to the parent, and pointers to the
     198various FITS data, if that corresponds to this level.  For astrometry,
     199in addition to the rough positioning information, it contains a
     200coordinate transform from the chip to the focal plane.  It is expected
     201that this transform will consist of two second-order 2D polynomials;
     202hence we think that it is prudent to include a reverse transformation
     203which will be derived from numerically inverting the forward
     204transformation.
    187205
    188206\begin{verbatim}
    189207typedef struct {
    190     const int col0;                    ///< Offset from the left of FPA.
    191     const int row0;                    ///< Offset from the bottom of FPA.
    192     psArray* cells;                    ///< cells in the chip
    193     psMetadata* metadata;              ///< chip-level metadata
    194     psPlaneTransform* toFPA;           ///< transformation from chip to FPA coordinates
    195     psPlaneTransform* fromFPA;         ///< transformation from FPA to chip coordinates
    196     psFPA *parent;
    197 } psChip;
    198 \end{verbatim}
    199 
    200 The constructor for \code{psChip} shall be:
    201 \begin{verbatim}
    202 psChip *psChipAlloc(int nCells, psFPA *parentFPA);
    203 \end{verbatim}
    204 The constructor shall make an empty \code{psChip}, with the
    205  \code{nCells} allocated pointers to \code{psCell}s being set to
    206  \code{NULL}.  If \code{nCells} is zero or less, then 1 cell shall be
    207  allocated.  In either case, the value of \code{psChip.cells.n} should
    208  be initially set to 0.  If the \code{parentFPA} is not NULL, this
    209  link is made, otherwise it is set to \code{NULL}. All other pointers
    210  in the structure shall be initialized to \code{NULL}.
     208    // Offset specifying position on focal plane
     209    int col0;                          // Offset from the left of FPA.
     210    int row0;                          // Offset from the bottom of FPA.
     211    // Astrometric transformations
     212    psPlaneTransform* toFPA;           // Transformation from chip to FPA coordinates
     213    psPlaneTransform* fromFPA;         // Transformation from FPA to chip coordinates
     214    // Information
     215    psMetadata *concepts;              // Cache for PS concepts
     216    psMetadata *analysis;              // Chip-level analysis metadata
     217    psArray *cells;                    // The cells (referred to by name)
     218    pmFPA *parent;                     // Parent FPA
     219    // FITS data
     220    const char *extname;               // Extension name, if it corresponds to this level
     221    psArray *pixels;                   // The pixel data, if it corresponds to this level
     222    psMetadata *header;                // The FITS header, if it corresponds to this level
     223} pmChip;
     224\end{verbatim}
     225
     226The constructor for \code{pmChip} shall be:
     227\begin{verbatim}
     228pmChip *pmChipAlloc(pmFPA *fpa);
     229\end{verbatim}
     230The constructor shall make an empty \code{pmChip}.  If the parent
     231\code{fpa} is not NULL, the \code{parent} link is made and the chip
     232shall be placed in the parent's array of \code{chips}.  The
     233\code{cells} array shall be allocated with a zero size, and the
     234metadata containers constructed. All other pointers in the structure
     235shall be initialized to \code{NULL}.
    211236
    212237\subsubsection{A Focal Plane}
    213238
    214239A focal plane consists of one or more chips (according to the number
    215 of pieces of contiguous silicon).  It contains pointers to the focal
    216 plane metadata and the exposure information.  For astrometry, it
    217 contains a transformation from the focal plane to the tangent plane
     240of pieces of contiguous silicon).  It contains metadata containers for
     241the concepts and analysis, a link to the parent, and pointers to the
     242various FITS data, if that corresponds to this level.  For astrometry,
     243it contains a transformation from the focal plane to the tangent plane
    218244and the fixed pattern residuals.  It is expected that the
    219245transformation will consist of two 4D polynomials (i.e.\ a function of
     
    222248the effects of the atmosphere; hence we think that it is prudent to
    223249include a reverse transformation which will be derived from
    224 numerically inverting the forward transformation.  Since colors are
    225 involved in the transformation, it is necessary to specify the color
    226 the transformation is defined for.  We also include some values to
    227 characterize the quality of the transformation: the root mean square
    228 deviation for the x and y transformation fits, and the $\chi^2$ for
    229 the transformation fit.
     250numerically inverting the forward transformation.
    230251
    231252\begin{verbatim}
    232253typedef struct {
    233     psArray* chips;                    ///< chips in the focal plane array
    234     psMetadata* metadata;              ///< focal-plane's metadata
    235     psPlaneDistort* fromTangentPlane;  ///< transformation from tangent plane to focal plane
    236     psPlaneDistort* toTangentPlane;    ///< transformation from focal plane to tangent plane
    237     psFixedPattern* pattern;           ///< fixed pattern residual offsets
    238     const struct psExposure* exposure; ///< information about this exposure
    239     const psGrommit* grommit;          ///< grommit allows conversion from tangent plane to sky
    240     psPhotSystem* colorPlus;           ///< Color reference
    241     psPhotSystem* colorMinus;          ///< Color reference
    242     float rmsX;                        ///< RMS for x transformation fits
    243     float rmsY;                        ///< RMS for y transformation fits
    244     float chi2;                        ///< chi^2 of astrometric solution
    245 } psFPA;
    246 \end{verbatim}
    247 
    248 The constructor for \code{psFPA} shall be:
    249 \begin{verbatim}
    250 psFPA *psFPAAlloc(int nChips, const psExposure *exp);
    251 \end{verbatim}
    252 The constructor shall make an empty \code{psFPA}, with the
    253 \code{nChips} allocated pointers to \code{psChip}s being set to
    254 \code{NULL}.  If \code{nChips} is zero or less, then 1 chip shall be
    255  allocated.  In either case, the value of \code{psFPA.chips.n} should
    256  be initially set to 0.  If the value of \code{exp} is not
    257  \code{NULL}, this value shall be assigned an used to set the value of
    258  \code{grommit}.  Otherwise both shall be set to \code{NULL}.  All
    259  other pointers in the structure shall be initialized to \code{NULL}.
    260 
    261 Two utility functions are defined to manage the collection of
    262 backward-pointing links:
    263 \begin{verbatim}
    264 bool psFPASetLinks (psFPA *fpa);
    265 bool psFPATestLinks (psFPA *fpa);
    266 \end{verbatim}
    267 The first of these functions constructs the \code{parent} pointers for
    268 all entries in a \code{psFPA} structure.  The second structure checks
    269 the validity of the links in an \code{psFPA} structure and returns
    270 \code{TRUE} if they are all correctly assigned, otherwise \code{FALSE}.
     254    // Astrometric transformations
     255    psPlaneDistort* fromTangentPlane;  // Transformation from tangent plane to focal plane
     256    psPlaneDistort* toTangentPlane;    // Transformation from focal plane to tangent plane
     257    psProjection *projection;          // Projection from tangent plane to sky
     258    // Information
     259    psMetadata *concepts;              // Cache for PS concepts
     260    psMetadata *analysis;              // FPA-level analysis metadata
     261    const psMetadata *camera;          // Camera configuration
     262    psDB *db;                          // Database handle
     263    psArray *chips;                    // The chips
     264    // FITS data
     265    const char *extname;               // Extension name, if it corresponds to this level
     266    psArray *pixels;                   // The pixel data, if it corresponds to this level
     267    psMetadata *header;                // The FITS header, if it corresponds to this level
     268} pmFPA;
     269\end{verbatim}
     270
     271The constructor for \code{pmFPA} shall be:
     272\begin{verbatim}
     273pmFPA *pmFPAAlloc(const psMetadata *camera, psDB *db);
     274\end{verbatim}
     275The constructor shall make an empty \code{pmFPA}.  The \code{chips}
     276array shall be allocated with a zero size, the \code{camera} and
     277\code{db} pointers set to the values provided, and the \code{concepts}
     278metadata constructed. All other pointers in the structure shall be
     279initialized to \code{NULL}.
     280
     281
     282The inclusion of hierarchical links pointing both down (via the
     283arrays) and up (via the \code{parent}) could make for difficulties.
     284For this reason, we specify a utility function to manage the
     285collection of upward-pointing links:
     286\begin{verbatim}
     287bool pmFPACheckParents(pmFPA *fpa);
     288\end{verbatim}
     289This function checks the validity of the \code{parent} links in the
     290FPA hierarchy.  If a \code{parent} link is not set (or not set
     291correctly), it is corrected, and the function shall return
     292\code{false}.  If all the \code{parent} pointers were correct, the
     293function shall return \code{true}.
    271294
    272295\subsection{Detector Coordinate Transformations}
     
    303326the containing hierarchy is defined for each data level.  For example,
    304327the origin of the coordinates for a single chip are located in the
    305 camera grid at \code{psChip.cell0,row0}.  The \code{psReadout} data
     328camera grid at \code{pmChip.cell0,row0}.  The \code{pmReadout} data
    306329level has additional information to specify the details of the readout
    307 process.  The elements \code{psReadout.colParity,rowParity} specify
    308 the parity of the specific readout (readout direction), while the
    309 elements \code{psReadout.colBins,rowBins} specify the binning factor
    310 in the two dimensions.  Note that the value of
    311 \code{psReadout.col0,row0} must be assigned in such a way that it
    312 represents the coordinate of the origin pixel in the actual image: the
    313 overscan or pre-scan pixels must be accounted for.  Putting all of
    314 these element together, we can see that the pixel coordinates in the
    315 camera grid may be determined from the pixel coordinates in the image
    316 grid from the following relationship:
    317 
    318 \begin{verbatim}
    319 psFPA(cell,row) = psChip.cell0,row0 + psCell.cell0,row0 + psReadout.cell0,row0 +
    320                   psReadout.cellParity,rowParity * psReadout.cellBins,rowBins *
     330process.  The elements \code{pmReadout.colBins,rowBins} specify the
     331binning factor in the two dimensions, while the sign indicates the
     332parity of the specific readout (readout direction).  Note that the
     333value of \code{pmReadout.col0,row0} must be assigned in such a way
     334that it represents the coordinate of the origin pixel in the actual
     335image: the overscan or pre-scan pixels must be accounted for.  Putting
     336all of these element together, we can see that the pixel coordinates
     337in the camera grid may be determined from the pixel coordinates in the
     338image grid from the following relationship:
     339
     340\begin{verbatim}
     341pmFPA(cell,row) = pmChip.cell0,row0 + pmCell.cell0,row0 + pmReadout.cell0,row0 +
     342                  pmReadout.cellParity,rowParity * pmReadout.cellBins,rowBins *
    321343                  psImage.data(cell,row)
    322344\end{verbatim}
     345
     346\subsection{Input/Output of a Focal Plane Hierarchy}
     347
     348We specify two functions to construct a focal plane hierarchy from a
     349camera configuration and read from a FITS file.  These two operations
     350are decoupled so that the big investment of memory from the read only
     351occurs when it is necessary.
     352
     353\begin{prototype}
     354pmFPA *pmFPAConstruct(const psMetadata *camera, psDB *db);
     355bool pmFPARead(pmFPA *fpa, psFits *fits);
     356\end{prototype}
     357
     358\code{pmFPAConstruct} shall construct a focal plane hierarchy from a
     359\code{camera} configuration.  A \code{db} handle is also provided so
     360that may be set in the \code{pmFPA}.  The resultant \code{pmFPA} and
     361its lower-down components shall be ready for to read a FITS file into
     362it by setting the \code{extname} pointers at the appropriate levels to
     363the appropriate FITS extension name.
     364
     365\code{pmFPARead} shall read a \code{fits} file (the contents of which
     366are described by the previous \code{camera} configuration) into an
     367extant \code{fpa}.
     368
     369\tbd{Functions to remove things from an fpa so that only certain
     370pieces of the FITS file are read in, and not the whole thing?}
     371
     372We specify an additional two functions to write out a focal plane
     373hierarchy to a FITS file.
     374
     375\begin{prototype}
     376bool pmFPAMorph(pmFPA *toFPA, pmFPA *fromFPA, int chipNum, int cellNum);
     377bool pmFPAWrite(psFits *fits, pmFPA *fpa);
     378\end{prototype}
     379
     380\code{pmFPAMorph} shall morph the \code{fromFPA} focal plane hierarchy
     381to the \code{toFPA} focal plane hierarchy.  This allows us to write
     382the pixels out using a different (though consistent) camera
     383configuration.  In the event that the \code{toFPA} has different
     384levels than the \code{fromFPA}, only the chip and cell specified by
     385\code{chipNum} and \code{cellNum} shall be written; if the levels are
     386the same, these numbers are ignored.  This function shall break apart
     387pixel regions or splice them together where required in order to
     388satisfy the demands of the \code{toFPA}.  If the bias and trim
     389sections are specified by headers in the \code{toFPA}, these shall be
     390updated appropriately; otherwise, the function is permitted to fail,
     391in which case it shall return \code{false}.
     392
     393\tbd{pmFPAMorph is a fairly involved operation, since it must cover
     394several combinations.  IfA is working on a prototype --- do not
     395attempt to code yet.}
     396
     397\code{pmFPAWrite} shall write the focal plane hierarchy, \code{fpa},
     398to the specified \code{fits} file, returning \code{true} upon success
     399and \code{false} otherwise.  The \code{fpa} should contain sufficient
     400information with which to write the FITS images.
    323401
    324402%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
     
    376454%
    377455\begin{verbatim}
    378 psCell *psCellInFPA (const psPlane *coord, const psFPA *fpa);
    379 psChip *psChipInFPA (const psPlane *coord, const psFPA *fpa);
    380 psCell *psCellInChip(const psPlane *coord, const psChip *chip);
     456pmCell *pmCellInFPA (const psPlane *coord, const pmFPA *fpa);
     457pmChip *pmChipInFPA (const psPlane *coord, const pmFPA *fpa);
     458pmCell *pmCellInChip(const psPlane *coord, const pmChip *chip);
    381459\end{verbatim}
    382460
     
    417495
    418496\begin{verbatim}
    419 psPlane *psCoordCellToChip (psPlane *out, const psPlane *in, const psCell *cell);
     497psPlane *pmCoordCellToChip (psPlane *out, const psPlane *in, const pmCell *cell);
    420498% astrometry comes from cell (no need for parent)
    421499\end{verbatim}
     
    424502
    425503\begin{verbatim}
    426 psPlane *psCoordChipToFPA (psPlane *out, const psPlane *in, const psChip *chip);
     504psPlane *pmCoordChipToFPA (psPlane *out, const psPlane *in, const pmChip *chip);
    427505% astrometry comes from chip (no need for parent)
    428506\end{verbatim}
     
    431509
    432510\begin{verbatim}
    433 psPlane *psCoordFPAToTP(psPlane *out, const psPlane *in, float color, float mag, const psFPA *fpa);
     511psPlane *pmCoordFPAToTP(psPlane *out, const psPlane *in, float color, float mag, const pmFPA *fpa);
    434512% astrometry comes from FPA (no need for parent)
    435513\end{verbatim}
     
    441519
    442520\begin{verbatim}
    443 psSphere *psCoordTPToSky(psSphere *out, const psPlane *in, const psGrommit *grommit);
     521psSphere *pmCoordTPToSky(psSphere *out, const psPlane *in, const psProjection *projection);
    444522\end{verbatim}
    445523which converts the tangent plane coordinates \code{in} to (RA,Dec) on
    446 the sky, based on the environmental information specified by
    447 \code{grommit}.
     524the sky, using the specified \code{projection}.
    448525
    449526% astrometry comes from cell
    450527\begin{verbatim}
    451 psPlane *psCoordCellToFPA(psPlane *out, const psPlane *in, const psCell *cell);
     528psPlane *pmCoordCellToFPA(psPlane *out, const psPlane *in, const pmCell *cell);
    452529\end{verbatim}
    453530which performs the single-step conversion between Cell coordinates
     
    456533% astrometry comes from cell,chip,fpa (PARENT IS NEEDED HERE)
    457534\begin{verbatim}
    458 psSphere *psCoordCellToSky(psSphere *out, const psPlane *in, float color, float mag, const psCell *cell);
     535psSphere *pmCoordCellToSky(psSphere *out, const psPlane *in, float color, float mag, const pmCell *cell);
    459536\end{verbatim}
    460537which converts coordinates on the specified cell to (RA,Dec).  This
     
    463540Tangent Plane to Sky.  The information needed for each of these
    464541transformations is available in the \code{.parent} elements of
    465 \code{psCell} and \code{psChip}, and the \code{psFPA.exposure}
    466 element.  The \code{color} and magnitude (\code{mag}) of the source is
    467 necessary in order to perform the distortion between the focal plane
    468 and the tangent plane.
     542\code{pmCell} and \code{pmChip}, and the \code{pmFPA.projection}.  The
     543\code{color} and magnitude (\code{mag}) of the source is necessary in
     544order to perform the distortion between the focal plane and the
     545tangent plane.
    469546
    470547% astrometry comes from cell (no need for parent)
    471548\begin{verbatim}
    472 psSphere *psCoordCellToSkyQuick(psSphere *out, const psPlane *in, const psCell *cell);
     549psSphere *pmCoordCellToSkyQuick(psSphere *out, const psPlane *in, const pmCell *cell);
    473550\end{verbatim}
    474551which uses the 'quick-and-dirty' transformation to convert coordinates
    475552on the specified cell to (RA,Dec).  This transformation should use the
    476553locally linear transformation specified by the element
    477 \code{psCell.toTP}.  Although the accuracy of this transformation
     554\code{pmCell.toTP}.  Although the accuracy of this transformation
    478555is lower than the complete transformation above, the calculation is
    479556substantially faster as it only involves linear transformations.
     
    483560
    484561\begin{verbatim}
    485 psPlane *psCoordSkyToTP(psPlane *out, const psSphere *in, const psGrommit *grommit);
     562psPlane *pmCoordSkyToTP(psPlane *out, const psSphere *in, const psProjection *projection);
    486563\end{verbatim}
    487564which converts (RA,Dec) coordinates \code{in} to tangent plane coords
    488 based on the enviromental information supplied by \code{grommit}.
    489 
    490 \begin{verbatim}
    491 psPlane *psCoordTPToFPA(psPlane *out, const psPlane *in, float color, float mag, const psFPA *fpa);
     565using the specified \code{projection}.
     566
     567\begin{verbatim}
     568psPlane *pmCoordTPToFPA(psPlane *out, const psPlane *in, float color, float mag, const pmFPA *fpa);
    492569\end{verbatim}
    493570which converts the tangent plane coordinates \code{in} to focal plane
     
    497574
    498575\begin{verbatim}
    499 psPlane *psCoordFPAToChip (psPlane *out, const psPlane *in, const psChip *chip);
     576psPlane *pmCoordFPAToChip (psPlane *out, const psPlane *in, const pmChip *chip);
    500577\end{verbatim}
    501578which converts the specified FPA coordinates \code{in} to the
    502579coordinates on the given Chip.  The specified chip need not contain
    503580the input coordinate.  To find the chip which contains a particular
    504 coordinate, the function \code{psChipInFPA}, defined above, should be
     581coordinate, the function \code{pmChipInFPA}, defined above, should be
    505582used.
    506583
    507584\begin{verbatim}
    508 psPlane *psCoordChipToCell (psPlane *out, const psPlane *in, const psCell *cell);
     585psPlane *pmCoordChipToCell (psPlane *out, const psPlane *in, const pmCell *cell);
    509586\end{verbatim}
    510587which converts the specified Chip coordinate \code{in} to the
    511588coordinate on the given Cell.  The specified Cell need not contain the
    512589input coordinate.  To find the cell which contains a particular
    513 coordinate, the function \code{psCellInChip}, defined above, should be
     590coordinate, the function \code{pmCellInChip}, defined above, should be
    514591used.
    515592
    516593\begin{verbatim}
    517 psPlane *psCoordSkyToCell(psPlane *out, const psSphere *in, float color, float mag, psCell *cell);
     594psPlane *pmCoordSkyToCell(psPlane *out, const psSphere *in, float color, float mag, pmCell *cell);
    518595\end{verbatim}
    519596which directly converts (RA,Dec) \code{in} to coordinates on the
     
    524601
    525602\begin{verbatim}
    526 psPlane *psCoordSkyToCellQuick(psPlane *out, const psSphere *in, psCell *cell);
     603psPlane *pmCoordSkyToCellQuick(psPlane *out, const psSphere *in, pmCell *cell);
    527604\end{verbatim}
    528605which directly converts (RA,Dec) \code{in} to coordinates on the
    529606specified cell.  The specified cell need not contain the input
    530607coordinates.  This transformation should use the locally linear
    531 transformation specified by the element \code{psCell.toTP}.
     608transformation specified by the element \code{pmCell.toTP}.
    532609Although the accuracy of this transformation is lower than the
    533610complete transformation above, the calculation is substantially faster
     
    536613%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    537614
    538 \section{Astrometry and World Coordinate System}
     615\subsection{FITS World Coordinate System}
    539616
    540617The FITS World Coordinate System (WCS) headers are commonly employed
     
    550627
    551628\begin{verbatim}
    552 bool psAstrometryReadWCS(psPlaneTransform **transform, // Output transformation
     629bool pmAstrometryReadWCS(psPlaneTransform **transform, // Output transformation
    553630                         psProjection **projection, // Output projection
    554631                         psMetadata *header // Input FITS header
    555632                         );
    556 bool psAstrometryWriteWCS(psMetadata *header, // Output FITS header
     633bool pmAstrometryWriteWCS(psMetadata *header, // Output FITS header
    557634                          psPlaneTransform *transform, // Input transformation
    558                           psProjection *projection, // Input projection
    559                           double color, // Mean color to use
    560                           double magnitude, // Mean magnitude to use
     635                          psProjection *projection, // Input projection
     636                          double color, // Mean color to use
     637                          double magnitude, // Mean magnitude to use
    561638                          );
    562 bool psAstrometrySimplify(psPlaneTransform **transform, // Output transformation
     639bool pmAstrometrySimplify(psPlaneTransform **transform, // Output transformation
    563640                          psProjection **projection, // Output projection
    564                           psCell *cell // Cell for which to generate transform and projection
     641                          pmCell *cell // Cell for which to generate transform and projection
    565642                          );
    566 \end{verbatim}                 
     643\end{verbatim}
    567644
    568645\code{pmReadAstrometry} shall parse the specified FITS \code{header},
     
    588665output; otherwise it shall return \code{false}.
    589666
    590 \section{Observatory data}
    591 
    592 We need a container for the observatory data that doesn't change per
    593 exposure.
    594 
    595 \begin{verbatim}
    596 typedef struct {
    597     const char *name;                   ///< Name of observatory
    598     const double latitude;              ///< Latitude of observatory, east positive
    599     const double longitude;             ///< Longitude of observatory
    600     const double height;                ///< Height of observatory
    601     const double tlr;                   ///< Tropospheric Lapse Rate
    602 } psObservatory;
    603 \end{verbatim}
    604 
    605 The constructor for \code{psObservatory} shall be:
    606 \begin{verbatim}
    607 psObservatory *psObservatoryAlloc(const char *name, double latitude, double longitude,
    608                                   double height, double tlr);
    609 \end{verbatim}
    610 
    611 \section{Exposure information}
    612 
    613 We need several quantities from the telescope in order to make a
    614 first guess at the astrometric solution.  From these quantities,
    615 further quantities can be derived and stored for later use.
    616 
    617 \begin{verbatim}
    618 typedef struct {
    619     const double ra, dec;               ///< Telescope boresight
    620     const double ha;                    ///< Hour angle
    621     const double zd;                    ///< Zenith distance
    622     const double az;                    ///< Azimuth
    623     const psTime *time;                 ///< Time of observation
    624     const float rotAngle;               ///< Rotator position angle
    625     const float temp;                   ///< Air temperature, for estimating refraction
    626     const float pressure;               ///< Air pressure, for calculating refraction
    627     const float humidity;               ///< Relative humidity, for calculating refraction
    628     const float exptime;                ///< Exposure time
    629     const float wavelength;             ///< Wavelength of observation
    630     const psObservatory *observatory;   ///< Observatory data
    631     /* Derived quantities */
    632     const psTime lst;                   ///< Local Sidereal Time
    633     const float posAngle;               ///< Position angle
    634     const float parallactic;            ///< Parallactic angle
    635     const float airmass;                ///< Airmass, calculated from zenith distance
    636     const float pf;                     ///< Parallactic factor
    637     const char *cameraName;             ///< name of camera which provided exposure
    638     const char *telescopeName;          ///< name of telescope which provided exposure
    639 } psExposure;
    640 \end{verbatim}
    641 
    642 The constructor for \code{psExposure} shall be:
    643 \begin{verbatim}
    644 psExposure *psExposureAlloc(double ra, double dec, double ha, double zd, double az,
    645                             const psTime *time, float rotAngle, float temp, float pressure, float humidity,
    646                             float exptime, float wavelength, const psObservatory *observatory);
    647 \end{verbatim}
    648 
  • trunk/doc/modules/ChangeLogSDRS.tex

    r4176 r4555  
    1 %%% $Id: ChangeLogSDRS.tex,v 1.22 2005-06-09 05:15:49 eugene Exp $
     1%%% $Id: ChangeLogSDRS.tex,v 1.23 2005-07-15 00:54:03 price Exp $
    22
    33\subsection{Changes from version 00 (16 August 2004) to version 01 (12 October 2004)}
     
    7878\item added object function abstractions to Objects
    7979\item modified pmSource to include modelPSF and modelFLT
     80\item Major changes to configuration.  Modifyied \code{pmConfig}
     81  functions, and \code{pmCameraFromHeader}, and added various other
     82  functions.
     83\item Modifying \code{psReadout, psCell, psChip, psFPA} structures.
     84\item Removing \code{psObservatory, psExposure, psGrommit} which were
     85  centered on slalib.
     86\item Added \code{pmFPAConstruct, pmFPARead, pmFPAMorph, pmFPAWrite}.
    8087\end{itemize}
  • trunk/doc/modules/ModulesSDRS.tex

    r4402 r4555  
    1 %%% $Id: ModulesSDRS.tex,v 1.45 2005-06-27 23:28:30 price Exp $
     1%%% $Id: ModulesSDRS.tex,v 1.46 2005-07-15 00:54:03 price Exp $
    22\documentclass[panstarrs]{panstarrs}
    33
     
    7979functions are available to fill a \code{psMetadata} collection from a
    8080text-based configuration file using a particular syntax, and to fill a
    81 \code{psMetadata} collection from a properly formatted XML document. 
     81\code{psMetadata} collection from a properly formatted XML document.
    8282
    8383In the IPP Modules, we use \code{psMetadata} collections to carry
     
    9494
    9595All modules need to load some configuration information defining
    96 parameters which may be configured at run-time.  Some module require
    97 only a basic amount of information, while others require configuration
    98 information defining the camera or details of an analysis (the {\it
    99 recipe}).  We define three utility functions to load these files from
    100 standard locations, with optional command-line override values.
    101 
    102 \begin{prototype}
    103 bool pmConfigLoadSite   (psMetadata **site, int *argc, char **argv);
    104 bool pmConfigLoadCamera (psMetadata **camera, psMetadata *site, psMetadata *header, int *argc, char **argv);
    105 bool pmConfigLoadRecipe (psMetadata **recipe, psMetadata *camera, int *argc, char **argv, char *script);
    106 \end{prototype}
    107 
    108 \code{pmConfigLoadSite} loads basic configuration information from a
    109 general configuration file.  By default, this file has the name
    110 \code{~/.ipprc} in the user's home directory.  This file may be
    111 overridden on the command line with the optional flag \code{-site
    112 (file)}.
    113 
    114 % eventually, we should define the complete sequence:
    115 % $FOO, ~/.foorc, /prefix/config/foorc
    116 
    117 \code{pmConfigLoadCamera} loads camera configuration information from
    118 a file which depends on the camera of interest.  In some cases, the
    119 camera may be determined from the header of an image currently in
    120 hand.  In other cases, the camera must be specified without reference
    121 to a file.  This function attempts to determine the appropriate camera
    122 configuration file by examining, in order, the command-line options,
    123 the header data, and the site configuration data.  The camera config
    124 file may be specified on the command line with the option
    125 \code{-camera (file)}.  If this does not exist, the
    126 \code{pmConfigLoadCamera} examines the provided header to determine
    127 the camera by using the function \code{pmCameraFromHeader} (defined
    128 below).  If this fails, the function attempts to determine the camera
    129 from the provided site config data, looking for the keyword
    130 \code{CAMERA} in the site config data.  The camera name is used to
    131 select the camera configuration file, defined in the site
    132 configuration file with the keyword \code{CAMERA.name}, where
    133 \code{name} is substituted with the name of the camera.
    134 
    135 \code{pmConfigLoadRecipe} loads the recipe configuration information
    136 from a file which depends on the camera of interest and the particular
    137 analysis task.  The camera configuration file must define recipe files
    138 for each of the analysis tasks of interest.  The function attempts to
    139 load the recipe file using the keyword \code{RECIPE.name}, where
    140 \code{name} is substituted with the name of the analysis task, for
    141 example \code{PHASE2}.  The choice of the recipe file may be
    142 overridden on the command line with the option \code{-recipe (file)}.
    143 
    144 \subsection{Indirect Configuration Data}
    145 
    146 Some configuration data is not provided directly by the configuration
    147 files.  Instead, the configuration system provides a mechanism to
    148 define indirect references to configuration data.  Three indirect
    149 configuration data sources are currently defined: data from a FITS
    150 header, data from the Metadata Database, and data from the Pan-STARRS
    151 Status Server.  The configuration data may specify that a certain
    152 value is provided by one of these mechanisms. 
    153 
    154 In order to specify that the configuration data should be derived from
    155 a FITS header, the data value is given in the form: \code{HD:KEYWORD},
    156 where \code{KEYWORD} specifies the keyword to be used in search the
    157 FITS header. 
    158 
    159 If the data is to be extracted from the Metadata Database, the data
    160 value is given in the form: \code{MD:TABLE,FIELD,KEY}.  In this case,
    161 \code{TABLE} specifies the Metadata Database table to be used to find
    162 the value, \code{FIELD} specifies the field in that table to be used,
    163 and \code{KEY} specifies the value of the primary key which gives the
    164 value of interest.
    165 
    166 If the data is to be extracted from the Status Server, the data value
    167 is given in the form: \code{SS:PATH}.  In this case, \code{PATH}
    168 specifies the Status Server path to the data value of interest. 
    169 
    170 {\bf \it note that the Metadata Database and Status Server
    171   interactions require us to define the APIs for these interactions.
    172   These two methods are not available until the MD and SS APIs are
    173   defined.}
    174 
    175 As an example, consider the definition of the data region of an image.
    176 This value is frequenty represented in the FITS header with the
    177 keyword \code{DATASEC}.  However, in some cameras, this value may not
    178 be defined, or another value may be used.  We must be able to flexibly
    179 define both the appropriate keyword, or the actual value, if known.
    180 These two cases may be written as follows, using the configuration
    181 file format parsed by \code{psMetadataParseConfig}:
     96parameters which may be configured at run-time.  We break these
     97parameters down into three levels:
     98\begin{itemize}
     99\item Options for the particular site installation of the
     100  pipeline: the {\it site};
     101\item Options specifying the instrument setup, and in particular the
     102  format of the FITS file: the {\it camera}; and
     103\item Options specifying the particular parameter choices that affect
     104  the details of an analysis: the {\it recipe}.
     105\end{itemize}
     106Note that these are arranged in an hierarchical order, with the site
     107configuration being the most general, and the recipe configuration the
     108most specific.  For example, not all sites will have to deal with all
     109cameras, and different cameras will have different recipes according
     110to their particular quirks.
     111
     112Each of the levels will have a metadata configuration file.  In the
     113case of the site configuration, the filename shall be that specified
     114by the \code{-site} option on the command line if provided, the
     115environment variable \code{PS_SITE}, if defined, or \code{~/.ipprc}
     116otherwise.  The camera configuration shall be specified by the
     117\code{camera} option on the command line if provided, or shall be
     118inferred from a FITS header (more detail below).  The recipe
     119configuration shall be specified by the \code{-recipe} option on the
     120command line if provided, or from the the camera configuration (more
     121detail below).
     122
     123\begin{prototype}
     124bool pmConfigRead(psMetadata **site, psMetadata **camera, psMetadata **recipe,
     125                  int *argc, char **argv, const char *recipeName);
     126psMetadata *pmConfigCameraFromHeader(const psMetadata *site, const psMetadata *header);
     127psMetadata *pmConfigRecipeFromCamera(const psMetadata *camera, const char *recipeName);
     128\end{prototype}
     129
     130\code{pmConfigRead} shall load the \code{site} configuration
     131(according to the above rule for determining the source).  The
     132\code{camera} configuration shall also be loaded if it is specified on
     133the command line (\code{argc, argv}); otherwise it shall be set to
     134\code{NULL}.  The \code{recipe} shall also be loaded from the command
     135line (if specified) or, if the camera configuration has been loaded,
     136from the camera configuration and recipe specification therein (see
     137below).  In dealing with the command line parameters, the functions
     138shall use the appropriate functions in psLib to retrieve and remove
     139the relevant options from the argument list; this simplifies
     140assignment of the mandatory arguments, since all the optional command
     141line arguments are removed leaving only the mandatory arguments.
     142
     143\code{pmConfigCameraFromHeader} shall load the \code{camera}
     144configuration based on the contents of the FITS \code{header}, using
     145the list of known cameras contained in the \code{site} configuration.
     146If more than one camera matches the FITS header, a warning shall be
     147generated and the first matching camera returned.
     148
     149\code{pmConfigRecipeFromCamera} shall load the \code{recipe}
     150configuration based on the \code{recipeName} and the list of known
     151recipes contained in the \code{camera} configuration (details below).
     152
     153We also specify an additional function:
     154\begin{prototype}
     155bool pmConfigValidateCamera(psMetadata *camera, psMetadata *header);
     156\end{prototype}
     157
     158This function, used by \code{pmConfigCameraFromHeader}, shall return
     159\code{true} if the FITS \code{header} matches the rule contained in
     160the \code{camera} configuration (see \S\ref{sec:camerarule});
     161otherwise it shall return \code{false}.
     162
     163\subsubsection{Example usage}
     164
     165The following is provided as an example of how the above functions
     166are envisioned in use.
     167
    182168\begin{verbatim}
    183 DATA.REGION  STR  [1:100,2:400]
    184 DATA.REGION  STR  HD:DATASEC
     169int main(int argc, char *argv[])
     170{
     171    // Parse other command-line arguments here
     172    psMetadata *site = NULL;            // Site configuration
     173    psMetadata *camera = NULL;          // Camera configuration
     174    psMetadata *recipe = NULL;          // Recipe configuration
     175    if (! pmConfigRead(&site, &camera, &recipe, &argc, argv, "moduleName")) {
     176        psLogMsg("moduleName", PS_LOG_ERROR, "Can't find site configuration!\n");
     177        exit(EXIT_FAILURE);
     178    }
     179    // Parse other command-line arguments here
     180
     181    // The command-line argument list now contains only mandatory arguments
     182    // Assume the first of these is an input image
     183    char *imageName = argv[1];          // Name of FITS file
     184    psFits *imageFH = psFitsOpen(imageName, "r"); // File handle for FITS file
     185    if (! imageFH) {
     186        psLogMsg("moduleName", PS_LOG_ERROR, "Can't open input image %s\n", imageName);
     187        exit(EXIT_FAILURE);
     188    }
     189    psMetadata *header = psFitsReadHeader(NULL, imageFH); // FITS header
     190
     191    if (!camera && !(camera = pmConfigCameraFromHeader(site, header))) {
     192        psLogMsg("moduleName", PS_LOG_ERROR, "Can't find camera configuration!\n");
     193        exit(EXIT_FAILURE);
     194    }
     195
     196    if (! recipe && !(recipe = pmConfigRecipeFromCamera(camera, "moduleName"))) {
     197        psLogMsg("moduleName", PS_LOG_ERROR, "Can't find recipe configuration!\n");
     198        exit(EXIT_FAILURE);
     199    }
     200
     201    // Now go on and do stuff
     202    ....
     203}
    185204\end{verbatim}
    186 In the first case, the data provided in the configuration file is the
    187 data of interest.  (\code{[1:100,2:400]}).  In the second case, the
    188 three-character code \code{HD:} specifies that the value of interest
    189 may be determined by searching for the value associated with the
    190 header keyword \code{DATASEC}.
    191 
    192 We provide utilities functions to extract this type of potentially
    193 indirect configuration information.  We provide four functions
    194 returning four data types.  The first three return the value from the
    195 appropriate location assuming the data type to be \code{char*},
    196 \code{psS32}, and \code{psF64}.  The fourth version searches for a
    197 string which is passed to the function \code{psRegionFromString}
    198 before being returned as a \code{psRegion} pointer.
    199 
    200 \begin{prototype}
    201 psSTR     pmConfigLookupSTR    (psMetadata *config, psMetadata *header, char *name);
    202 psS32     pmConfigLookupS32    (psMetadata *config, psMetadata *header, char *name);
    203 psF64     pmConfigLookupF64    (psMetadata *config, psMetadata *header, char *name);
    204 psRegion *pmConfigLookupRegion (psMetadata *config, psMetadata *header, char *name);
    205 \end{prototype}
    206 
    207 \input{CameraImages.tex}
    208 
    209 \section{Camera Data Organization \& Camera Geometry}
    210 
    211 We require several utility functions to define the geometry of the
    212 detectors in a camera and to specify the organization of the camera
    213 data in real FITS images.  The camera data organization is defined in
    214 a set of \code{psMetadata} structures, and may be stored on disk in
    215 the file format parsed by \code{psMetadataParseConfig}.
    216 
    217 PSLib defines a hierarchy of data structures related to the
    218 organization of the pixels in a camera.  These structures, starting
    219 from the top level, follow the sequence \code{psFPA}, \code{psChip},
    220 \code{psCell}, \code{psReadout}, \code{psImage}.  Each lower level
    221 structure is carried as an array in the higher level.  The containers
    222 as defined by PSLib include functions which specify the astrometric
    223 relationships between these levels, and provide a single
    224 \code{psMetadata} container pointer for each level.  In this section,
    225 we define the type of metadata is stored in these metadata containers
    226 and how the image headers are parse to define the data hierarchy in
    227 memory. 
    228 
    229 \subsection{Camera Config Data \& the {\tt psFPA}}
    230 
    231 A relevant collection of metadata is the externally supplied camera
    232 definition metadata loaded with the function
    233 \code{pmConfigLoadCamera}.  This metadata defines the expected layout
    234 of a specific camera along with information detailing how to interpret
    235 the headers for an image from that camera.  The camera metadata
    236 consists of keyword / value pairs which are relevant to the entire
    237 camera, and a set of metadata collections specified for each cell.
    238 This top-level metadata is added to the \code{psFPA} with the name
    239 'CAMERA.LAYOUT'.  For example:
     205
     206\subsection{Configuration Files}
     207
     208\subsubsection{Site Configuration}
     209
     210The site configuration file must contain the following:
     211\begin{itemize}
     212\item The database configuration:
     213  \begin{itemize}
     214  \item \code{DBSERVER} of type \code{STR}: The database host name for
     215    \code{psDBInit}.
     216  \item \code{DBUSER} of type \code{STR}: The database user name for
     217    \code{psDBInit}.
     218  \item \code{DBPASSWORD} of type \code{STR}: The corresponding
     219    database password for \code{psDBInit}.
     220  \end{itemize}
     221\item \code{CAMERAS} of type \code{METADATA}: A list of instruments
     222  that the system can handle.  Cameras are specified as separate
     223  metadata entries, with the name of the camera as the key, and the
     224  filename of the camera configuration file (of type \code{STR}) as
     225  the data.
     226\end{itemize}
     227
     228An example site configuration file:
     229
    240230\begin{verbatim}
    241 fpa->metadata = psMetadataAdd (fpa->metadata, PS_LIST_TAIL, "CAMERA", PS_META_META, "camera", camera);
     231### Example .ipprc file
     232
     233### Database configuration
     234DBSERVER        STR     ippdb.ifa.hawaii.edu    # Database host name (for psDBInit)
     235DBUSER          STR     ipp                     # Database user name (for psDBInit)
     236DBPASSWORD      STR     password                # Database password (for psDBInit)
     237
     238### Setups for each camera system
     239CAMERAS         METADATA
     240        MEGACAM_RAW     STR     megacam_raw.config
     241        MEGACAM_SPLICE  STR     megacam_splice.config
     242        GPC1_RAW        STR     gpc1_raw.config
     243        LRIS_BLUE       STR     lris_blue.config
     244        LRIS_RED        STR     lris_red.config
     245END
    242246\end{verbatim}
    243 The specific cell-level entries are also placed on the correpsonding
    244 \code{psCell} elements.  These entries are added to the metadata with
    245 the name 'CELL':
    246 \begin{verbatim}
    247 cell->metadata = psMetadataAdd (cell->metadata, PS_LIST_TAIL, "CELL", PS_META_META, "cell", cellMD);
    248 \end{verbatim}
    249 
    250 \subsection{FITS File Data Representations}
     247
     248\subsubsection{Camera Configuration}
     249
     250The camera configuration is the most complicated and involved, since
     251it must not only specify how to translate the pixels from a FITS file
     252into a focal plane hierarchy (\S\ref{sec:focalplane}), but it must
     253also specify how to derive the values of the PS concepts
     254(\S\ref{sec:concepts}).  Moreover, it must be able to do these for the
     255great variety of cameras in use in the astronomical community.
     256
     257Example camera configuration files are included in an appendix, but
     258below we explain the components.
     259
     260\paragraph{FITS File to Focal Plane Hierarchy}
     261
     262The Focal Plane hierarchy (\code{pmFPA, pmChip, pmCell, pmReadout}) is
     263explained in more detail in \S\ref{sec:focalplane}.  The top level, an
     264FPA contains one or more chips, which correspond to a contiguous piece
     265of silicon.  A chip contains one or more cells, which correspond to a
     266single amplifier.  A cell contains one or more readouts, which
     267correspond to individual reads of the detector.
    251268
    252269Within the FITS data representation, there are various choices which
    253 can and have been made for the placement of the pixels in a data file.
     270can and have been made for the placement of the pixels in the file.
    254271In the simplest case, the camera consists of a single chip consisting
    255272of a single cell always read with a single readout.  In this case, the
     
    261278with separate extensions for each cell (CFH12K.split, GPC).  Another
    262279camera may write a single file with multiple extensions for each cell
    263 (Megacam.raw), or multiple extensions per chip, which each cell
     280(Megacam.raw), or multiple extensions per chip, with each cell
    264281representing portions of the chip image (Megacam.splice, CFHT-IR).
    265282
    266 In all of these representations, there are only two principal
    267 distinctions in how the pixel data is stored.  Either a single data
    268 block (a single FITS image) represents only a single cell, or it
    269 represents a collection of cells.  This affects the way in which an
    270 image is read in, the way the header is associated with a level of the
    271 data hierarchy, and the way in which the header keywords are
    272 interpretted to define the layout of the pixels in the cell.  We
    273 distinguish these two cases as 'cell-based' and 'chip-based' layout.
    274 
    275 The FITS headers are attached to the \code{psFPA} data hierarchy by
    276 adding them to the \code{psMetadata} entries for the appropriate data
    277 level.  Each of the data levels \code{psFPA}, \code{psChip}, and
    278 \code{psCell} have \code{metadata} elements to store relevant metadata
    279 of any type.  A FITS header metadata collection may be added to one of
    280 these metadata collections using the metadata name 'HEADER':
     283In all of these representations, there are only two basic distinctions
     284in how the pixel data is stored: what level the entire FITS file
     285corresponds to (FPA or chip), and what level the extensions correspond
     286to (chip, cell or no extensions at all).  Knowing these, and having
     287a list of the components, we can construct the focal plane hierarchy.
     288
     289We therefore specify the following keywords:
     290\begin{itemize}
     291\item \code{PHU} of type \code{STR}: May be one of \code{CHIP} or
     292  \code{CELL}.  This specifies what the scale of the Primary Header
     293  Unit (and hence the entire FITS file) is.
     294\item \code{EXTENSIONS} of type \code{STR}: May be one of \code{CHIP},
     295  \code{CELL} or \code{NONE}, though not of a level higher than that
     296  specified by the \code{PHU}.  This specifies what each extension
     297  represents.
     298\item \code{CONTENTS} which may be of type \code{METADATA} or
     299  \code{STR}, depending upon the \code{PHU} and \code{EXTENSIONS},
     300  specifies what the contents of the FITS file are:
     301  \begin{itemize}
     302    \item \code{PHU=FPA, EXTENSIONS=CHIP}: Type \code{METADATA} with
     303      the component keywords being the extension names and the values
     304      the names of the cells, separated by commas or whitespace.
     305    \item \code{PHU=FPA, EXTENSIONS=CELL}: Type \code{METADATA} with
     306      the component keywords being the extension names and the values
     307      the chip name and the cell type, separated by a colon.
     308    \item \code{PHU=FPA, EXTENSIONS=NONE}: Type \code{METADATA} with
     309      the component keywords being the chip names and the values the
     310      names of the cells, separated by commas or whitespace.
     311    \item \code{PHU=CHIP, EXTENSIONS=CELL}: Type \code{METADATA} with
     312      the component keywords being the extension names and the values
     313      the corresponding cell type.
     314    \item \code{PHU=CHIP, EXTENSIONS=NONE}: Type \code{STR} with the
     315      value being the cell types separated by commas or whitespace.
     316  \end{itemize}
     317\item \code{CELLS} of type \code{METADATA} with the component keywords
     318  being the cell names or types, each of type \code{METADATA}.  Within
     319  each cell should be specified various PS concept values appropriate
     320  for each cell.
     321\end{itemize}
     322
     323An example:
     324
    281325\begin{verbatim}
    282 fpa->metadata = psMetadataAdd (fpa->metadata, PS_LIST_TAIL, "HEADER", PS_META_META, "header", header);
     326# How to read this data
     327PHU             STR     FPA     # The FITS file represents an entire FPA
     328EXTENSIONS      STR     CELL    # The extensions represent cells
     329 
     330# What's in the FITS file?
     331CONTENTS        METADATA
     332        # Extension name, chip name:type
     333        amp00   STR     ccd00:left
     334        amp01   STR     ccd00:right
     335        amp02   STR     ccd01:left
     336        amp03   STR     ccd01:right
     337        amp04   STR     ccd02:left
     338END
     339
     340# Specify the cell data
     341CELLS   METADATA
     342        left    METADATA        # Left amplifier
     343                CELL.BIASSEC            STR     BIASSEC
     344                CELL.TRIMSEC            STR     DATASEC
     345                CELL.PARITY             S32     1
     346        END
     347        right   METADATA        # Right amplifier
     348                # This cell is read out in the opposite direction
     349                CELL.BIASSEC            STR     BIASSEC
     350                CELL.TRIMSEC            STR     DATASEC
     351                CELL.PARITY             S32     -1
     352        END
     353END
    283354\end{verbatim}
    284355
    285 In 'cell-based' layout, the headers are attached to the corresponding
    286 \code{psCell} element.  In 'chip-based' layout, the headers are
    287 attached to the \code{psChip} element.  This difference is natural
    288 since a 'cell-based' data file has one FITS extension, and therefore
    289 one FITS header, for each \code{cell}.  Conversely, in a 'chip-based'
    290 data file, there is one extension per chip, and therefore multiple
    291 cells for each FITS header, but only one chip for each FITS header. 
    292 
    293 \subsection{Determine the Camera from the Primary Header}
    294 
    295 \begin{prototype}
    296 char *pmCameraFromHeader (psFitsHeader *header, psMetadata *rules);
    297 \end{prototype}
    298 
    299 This function examines a primary header unit (\code{header}) and
    300 determines the camera which provided the data.  The rules which
    301 identify the camera are defined as a \code{psMetadata} structure
    302 containing one element for each known camera.  These are generally to
    303 be provided as part of the site configuration information.  The
    304 elements of this \code{psMetadata} container are in turn
    305 \code{psMetadata} containers consisting of the expected header
    306 keywords and their required values.  The function
    307 \code{pmCameraFromHeader} tests each of the defined cameras in
    308 succession.  For each camera, it searches for each of the given
    309 keywords and compares the value with the value expected.  If the
    310 keyword does not exist, or if the keyword has the wrong value, the
    311 camera is rejected.  The name of first camera which matches the header
    312 is returned as an allocated string.  If no match is found, the
    313 returned value must be \code{UNKNOWN}.  This condition may be treated
    314 by calling functions as either an error or only a warning.  If an
    315 error is encountered in parsing the metadata containers, then
    316 \code{NULL} is returned.  An example of the metadata keyword / value
    317 pairs is given below (note that this uses an undefined metadata config
    318 file representation \code{METADATA}):
    319 
     356Observe how the \code{CONTENTS} specifies the extension name, which we
     357know from the \code{EXTENSIONS} is a cell, and that each extension is
     358associated with a chip, and has a cell type.
     359
     360The \code{_SOURCE} keywords will be explained in \S\ref{sec:concepts}.
     361
     362\paragraph{Deriving concept values}
     363
     364The PS concepts are described in more detail in \S\ref{sec:concepts}.
     365Basically, astronomical cameras generally store the important details
     366(``concepts'') in different ways.  This is generally manifested in the
     367choice of different FITS header keywords to describe the same concept,
     368but one can also imagine deriving values from a database or a known
     369default.
     370
     371We therefore specify the following keywords:
     372\begin{itemize}
     373\item \code{TRANSLATION} of type \code{METADATA} is a translation
     374  table for understanding PS concepts in terms of FITS headers.  The
     375  PS concept (keyword) is derived from the FITS header given in the
     376  value.
     377\item \code{DATABASE} of type \code{METADATA} is a formula for
     378  obtaining a PS concept from the database.  Each component is of a
     379  user-specified type containing \code{TABLE}, \code{COLUMN},
     380  \code{GIVENDBCOL} and \code{GIVENPS}.  The idea is that to obtain
     381  the value of a PS concept, one refers to a particular \code{COLUMN}
     382  in a particular \code{TABLE}, where the value of certain PS concepts
     383  (\code{GIVENPS}; multiple values separated by a comma or semicolon)
     384  match certain database columns (\code{GIVENDBCOL}; multiple values
     385  separated by a comma or semicolon).
     386\item \code{DEFAULTS} of type \code{METADATA} is a set of default
     387  values of PS concepts for the camera.  The PS concept (keyword) is
     388  assigned the value.  There is also limited dependency allowed; see
     389  \S\ref{sec:concepts}.
     390\end{itemize}
     391
     392An example:
    320393\begin{verbatim}
    321 CFH12K.MEF      METADATA
    322   TELESCOP      STR   CFHT
    323   INSTRUME      STR   CFH12K
    324   EXTEND        BOOL  T
    325   NEXTEND       S32   12
    326 END
    327 
    328 CFH12K.SPLIT    METADATA
    329   TELESCOP      STR   CFHT
    330   INSTRUME      STR   CFH12K
    331   EXTEND        BOOL  F
     394# How to translate PS concepts into FITS headers
     395TRANSLATION     METADATA
     396        FPA.NAME        STR     EXPNUM
     397        FPA.AIRMASS     STR     AIRMASS
     398        FPA.FILTER      STR     FILTER
     399        FPA.POSANGLE    STR     ROTANGLE
     400        FPA.RA          STR     RA
     401        FPA.DEC         STR     DEC
     402        FPA.RADECSYS    STR     RADECSYS
     403        FPA.MJD         STR     MJD-OBS
     404        CELL.EXPOSURE   STR     EXPTIME
     405        CELL.DARKTIME   STR     DARKTIME
     406        CELL.XBIN       STR     CCDBIN1
     407        CELL.YBIN       STR     CCDBIN2
     408        CELL.SATURATION STR     SATURATE
     409END
     410
     411# Default PS concepts that may be specified by value
     412DEFAULTS        METADATA
     413        CELL.BAD                S32     0
     414        CELL.YPARITY_DEPEND     STR     CHIP.NAME
     415        CELL.YPARITY    METADATA
     416                ccd00   S32     -1
     417                ccd01   S32     -1
     418                ccd02   S32     -1
     419                ccd03   S32     -1
     420        END
     421END
     422
     423# How to translation PS concepts into database lookups
     424DATABASE        METADATA
     425        TYPE            dbEntry         TABLE           COLUMN          GIVENDBCOL      GIVENPS
     426        CELL.GAIN       dbEntry         Camera          gain            chipId,cellId   CHIP.NAME,CELL.NAME
     427        CELL.READNOISE  dbEntry         Camera          readNoise       chipId,cellId   CHIP.NAME,CELL.NAME
    332428END
    333429\end{verbatim}
    334430
    335 \begin{figure}
    336 \begin{center}
    337 \psfig{file=CameraHierarchy,width=5.0in}
    338 \caption{Camera Data and Metadata Hierarchy\label{CameraHierarchy}}
    339 \end{center}
    340 \end{figure}
    341 
    342 \subsection{Validate the Header set \& Construct the FPA}
    343 
    344 \begin{prototype}
    345 bool  pmCameraValidateHeaders (psMetadata *headers, psMetadata *camera);
    346 psFPA *pmFPAfromHeader (psMetadata *headers, psMetadata *camera);
    347 \end{prototype}
    348 
    349 These funtions examine the collection of \code{headers} and compare
    350 them with the camera definitions in the metadata structure
    351 \code{camera}.  One function (\code{pmFPAfromHeader}) uses the header
    352 set and camera definition file to construct a \code{psFPA} with all
    353 \code{psChip} and \code{psCell} entries allocated, but without any
    354 \code{psReadout} or pixel data.  The other function validates the
    355 header set against the camera definition, but does not actually
    356 construct the \code{psFPA}. 
    357 
    358 The camera definition metadata collection defines the relationship
    359 between chips, cells, and the FITS extensions.  An example of the data
    360 needed by \code{pmCameraValidateHeaders} and \code{pmFPAfromHeader} is
    361 given below for several types of cameras in the form of a metadata
    362 config file. 
    363 
     431The \code{_DEPEND} entry in the \code{DEFAULTS} will be explained in
     432\S\ref{sec:concepts}.
     433
     434\paragraph{Indentification by rule}
     435\label{sec:camerarule}
     436
     437The function \code{pmConfigCameraFromHeader} requires that the camera
     438configuration also contains a rule on how to recognise that a FITS
     439header comes from that camera.
     440
     441We therefore specify another keyword: \code{RULE} of type
     442\code{METADATA}: Contains a list of FITS headers keywords and values
     443(of the appropriate type) against which actual headers are compared to
     444determine if it matches the camera type.
     445
     446An example is:
    364447\begin{verbatim}
    365 MEGACAM.RAW     METADATA   
    366   NCELL         S32    72
    367   CELL.FMT      STR    CELL.%02d
    368   EXT.TYPE      STR    CELL
    369   EXT.KEY       STR    EXTNAME
    370   PHU           STR    FPA
    371   #
    372   #                    EXT.KEY  CHIP 
    373   CELL.00       CELL   amp00    CHIP.00
    374   CELL.01       CELL   amp01    CHIP.00
    375   CELL.02       CELL   amp02    CHIP.01
    376   CELL.03       CELL   amp03    CHIP.01
    377   ...
    378 END
    379 
    380 MEGACAM.SPLICE  METADATA     
    381   NCELL         S32    36
    382   CELL.FMT      STR    CELL.%02d
    383   EXT.TYPE      STR    CHIP
    384   EXT.KEY       STR    EXTNAME
    385   PHU           STR    FPA
    386   #
    387   #                    EXT.KEY  CHIP 
    388   CELL.00       CELL   ccd00    CHIP.00
    389   CELL.01       CELL   ccd00    CHIP.00
    390   CELL.02       CELL   ccd01    CHIP.01
    391   CELL.03       CELL   ccd01    CHIP.01
    392   ...
    393 END
    394 
    395 CFH12K.SPLIT    METADATA
    396   NCELL         S32    12
    397   CELL.FMT      STR    CELL.%02d
    398   EXT.TYPE      STR    CELL
    399   EXT.KEY       STR    EXTNAME
    400   PHU           STR    NONE
    401   #
    402   #                    EXT.KEY  CHIP   
    403   CELL.00       CELL   chip00   CHIP.00
    404   CELL.01       CELL   chip01   CHIP.01
    405   CELL.02       CELL   chip02   CHIP.02
    406   ...
    407 END
    408 
    409 GPC.RAW         METADATA   
    410   NCELL         S32    4096
    411   CELL.FMT      STR    CELL.%04d
    412   EXT.TYPE      STR    CELL
    413   EXT.KEY       STR    EXTNAME
    414   PHU           STR    CHIP
    415   #
    416   #                    EXT.KEY  CHIP 
    417   CELL.0000     CELL   amp00    CHIP.00
    418   CELL.0001     CELL   amp01    CHIP.00
    419   CELL.0002     CELL   amp02    CHIP.00
    420   CELL.0003     CELL   amp03    CHIP.00
    421   ...
    422   CELL.0065     CELL   amp03    CHIP.01
    423   CELL.0066     CELL   amp03    CHIP.01
    424   ...
     448# How to identify this type
     449RULE    METADATA
     450        TELESCOP        STR     CFHT 3.6m
     451        DETECTOR        STR     MegaCam
     452        EXTEND          BOOL    T
     453        NEXTEND         S32     72
    425454END
    426455\end{verbatim}
    427456
    428 Among the important elements of the camera definition information are:
     457\paragraph{Recipes}
     458
     459The camera configuration file must also contain filenames for the
     460recipe configuration files.  We include \code{RECIPES} of type
     461\code{METADATA} with component keywords being the various recipe names
     462and the values (of type \code{STR}) the corresponding recipe
     463configuration filename.
     464
     465\subsubsection{Recipe Configuration}
     466
     467\tbd{The contents of the recipe configuration file are dependent upon
     468the particular module, and hence are not specified here at this time.}
     469
     470
     471\subsection{PS Concepts}
     472\label{sec:concepts}
     473
     474Each image has associated with it what we will call {\it concepts}
     475(for want of a better word).  These are values corresponding to
     476general quantities and qualities relevant to the IPP such as airmass,
     477date, read noise and filter.  These concepts are not always known by
     478the same name, or are obtained in the same manner for all cameras, and
     479so their source or value must be specified in the camera configuration
     480file.  Some of these concepts make most sense to be defined at the FPA
     481level, while others are logically defined at the cell level.
     482
     483Below is a list of concepts that the IPP should require, with the
     484expected type and a short description.
     485
    429486\begin{itemize}
    430 \item \code{NCELL} - this defines the possible number of cells from this
    431   camera.
    432 \item \code{CELL.FMT} - this defines the format of the \code{CELL.nn}
    433   keywords below in the metadata collection, one for each of the
    434   \code{NCELL} values
    435 \item \code{EXT.TYPE} - this defines the lowest data level
    436   corresponding to a single FITS extension: \code{CELL} or
    437   \code{CHIP}.  In some cases, a single extension represents a chip,
    438   and is subdivided into cells by header keywords specifying certain
    439   regions.  In other cases, a single extension represents only the
    440   data from a single amplifier, ie, a cell.  These two cases require
    441   somewhat different handling.
    442 \item \code{EXT.KEY} - this entry defines a header keyword which
    443   allows the unique identification of a given header with one of the
    444   cell or chip entries (depending on the value of \code{EXT.TYPE}).
    445 \item \code{PHU} - this entry defines the meaning of the FITS file
    446   primary header unit.
     487\item \code{FPA.AIRMASS} (F32): Airmass at which the observation is made
     488  (boresight).
     489\item \code{FPA.FILTER} (STR): Filter used in observation
     490\item \code{FPA.POSANGLE} (F32): Position angle for camera
     491\item \code{FPA.RA}: Right Ascension of boresight
     492\item \code{FPA.DEC}: Declination of boresight
     493\item \code{FPA.RADECSYS}: System of RA,Dec (e.g., J2000 or ICRS)
     494\item \code{FPA.NAME}: An identifier (e.g., observation number) for the FPA instance
     495\item \code{CHIP.NAME}: The name of the chip (unique within the FPA) --- set at FITS read
     496\item \code{CELL.NAME}: The name of the cell (unique within the parent chip) --- set at FITS read
     497\item \code{CELL.TIME}: Time of observation start
     498\item \code{CELL.TIMESYS}: Time system in use (e.g., UTC)
     499\item \code{CELL.BIASSEC}: Overscan region(s)
     500\item \code{CELL.TRIMSEC}: Trim region
     501\item \code{CELL.GAIN}: CCD gain (e/ADU)
     502\item \code{CELL.READNOISE}: CCD read noise (e)
     503\item \code{CELL.SATURATION}: CCD saturation point (ADU)
     504\item \code{CELL.BAD}: CCD bad pixel point (ADU)
     505\item \code{CELL.BINNING}: CCD Binning
     506\item \code{CELL.PARITY}: Direction of CCD readout
     507\item \code{READOUT.EXPOSURE}: Exposure time of image (sec)
     508\item \code{READOUT.DARKTIME}: Dark time for image (sec)
    447509\end{itemize}
    448 In addition to these generic parameters, the camera definition
    449 metadata includes an entry for each cell giving specific values
    450 required to define that cell. 
    451 
    452 Both functions \code{pmCameraValidateHeaders} and
    453 \code{pmFPAfromHeader} must start with the set of headers and attempt
    454 to identify the corresponding cell or chip.  All available cells and
    455 chips must be identified, and the cells corresponding to each chip
    456 must be tracked.  In the case of \code{pmCameraValidateHeaders}, the
    457 function must only verify the headers contain valid extensions,
    458 without allocating the correpsonding \code{psFPA}, while
    459 \code{pmFPAfromHeader} must also allocate the \code{psFPA}, the
    460 contained \code{psChip} arrays, and the correct number of
    461 \code{psCell} arrays for each \code{psChip}.
    462 
    463 These functions also add to the metadata containers for the chips and
    464 cells, following the rules discussed above. Each \code{psCell} entry
    465 should have the \code{CELL} metadata lines from above attached to the
    466 \code{psCell.metadata} element as an additional metadata collection
    467 with the name \code{CELL.LAYOUT}.  The complete camera metadata
    468 collection (including the cells), are attached to the
    469 \code{psFPA.metadata} element with the name \code{CAMERA.LAYOUT}.  The
    470 image header data are also attached to metadata entries, at a level
    471 which depends on the value of \code{EXT.TYPE} in the camera layout
    472 data above.  If the value is \code{CELL}, the header metadata
    473 collections are attached to the \code{psCell.metadata} elements with
    474 the name \code{HEADER}.  If the value of \code{EXT.TYPE} is chip, the
    475 header metadata is attached to the \code{psChip.metadata} element,
    476 again with the name \code{HEADER}. 
    477 
    478 An image file may also have a primary header unit which is not
    479 associated with a data block.  This metadata block must also be added
    480 to the data heirarchy so successive operations may update the metadata
    481 as needed.  The disposition of the primary header unit is defined by
    482 the camera layout key \code{PHU}.  If this has a value of \code{NONE},
    483 there is no primary header unit, or it should be ignored.  If the
    484 value is \code{FPR}, the primary header data is attached to the
    485 \code{psFPA.metadata} element with the value PHU.  Alternatively, if
    486 it has the value \code{CHIP}, then the primary header metadata is
    487 attached to the \code{psChip.metadata} element.
    488 
    489 \subsection{Coordinate Transforms and Header Data}
    490 \tbd{the algorithms for three functions in this section are not
    491   well-defined.  do not code yet}.
    492 
    493 Astrometric and geometric information about an image from a camera may
    494 be represented in a variety of ways.  A crude representation of the
    495 pixel geometry is specified in many image headers using the IRAF-style
    496 region keywords \code{DATASEC}, \code{DETSEC}, etc.  These keywords
    497 are used to define the location of a single image's pixels in the
    498 frame of the full mosaic of detectors in the assumption that the
    499 mosaic can be represented as a single uniform grid of pixels.  An
    500 alternative set of keywords have been used in cases where multiple
    501 cells are saved together in a single FITS image extension.  More
    502 sophisticated astrometric representations require elements to define
    503 projections, scaling, distortion, etc.  Several versions of header
    504 keywords have been used to represent these astrometric
    505 transformations.  In this section, we define three functions to
    506 interpret a collection of image headers and construct the appropriate
    507 offset and/or astrometry parameters.
    508 
    509 \begin{prototype}
    510 bool  pmFPADefineOffsets (psFPA fpa);
    511 bool  pmFPADefineWCS (psFPA fpa);
    512 bool  pmFPADefineWCSfromOffsets (psFPA fpa);
    513 \end{prototype}
    514 
    515 The first function takes a \code{psFPA} structure which has been
    516 populated with header and camera configuration metadata in the
    517 appropriate locations as discussed above.  Using the information in
    518 the camera config metadata and the headers, the function sets the
    519 values for the elements \code{psChip.col0,row0},
    520 \code{psCell.col0,row0}, \code{psReadout.col0,row0},
    521 \code{psReadout.colParity,rowParity}, and
    522 \code{psReadout.colBinning,rowBinning}.  This information is
    523 determined by examining the regions defined by the following names.
    524 
    525 % how do we handle the CCDSUM keyword case?
     510
     511The value of a concept shall be found by searching in the following
     512order:
     513\begin{itemize}
     514\item A cache of values.
     515\item The FITS header via the \code{TRANSLATION} table.
     516\item The \code{DATABASE} lookup.
     517\item The \code{DEFAULTS} value.
     518\end{itemize}
     519When a concept is retrieved, it shall be stored in the cache to
     520optimise future retrieval.  We have specified a cache and FITS header
     521storage in the various focal plane structures for the purposes of
     522concept retrieval.
     523
     524Because of the variety of methods for specifying these concepts
     525(especially in FITS headers), we must also specify additional
     526information in the camera configuration that specifies how to
     527interpret the data provided. 
     528
     529In the \code{DEFAULTS} table in the camera configuration, we allow the
     530specification of the concept with an additional suffix,
     531\code{_DEPEND}.  The value (of type \code{STR}) of the
     532\code{CONCEPT_DEPEND} is the name of a concept on which the first
     533concept depends.  For example, it might depend on the chip name.  Then
     534the first concept becomes of type \code{METADATA}, with the component
     535keywords being the value of the second concept (on which the first
     536depends).  To avoid infinite recursion, no further dependency is
     537permitted.  An example of the dependency:
     538
    526539\begin{verbatim}
    527 psCell.metadata:CELL:CCDBIN1 $\rightarrow$ psReadout.colBins
    528 psCell.metadata:CELL:CCDBIN2 $\rightarrow$ psReadout.rowBins
    529 
    530 DETSEC from psCell.metadata:CELL:DETSEC
    531 CCDSEC from psCell.metadata:CELL:CCDSEC
    532 DATASEC from psCell.metadata:CELL:DATASEC
    533 
    534 if (DETSEC.x0 > DETSEC.x1) then psReadout.colParity = -1
    535 if (DETSEC.y0 > DETSEC.y1) then psReadout.rowParity = -1
     540# Default PS concepts that may be specified by value
     541DEFAULTS        METADATA
     542        CELL.GAIN_DEPEND     STR     CHIP.NAME
     543        CELL.GAIN    METADATA
     544                ccd00   F32     1.2
     545                ccd01   F32     3.4
     546                ccd02   F32     5.6
     547        END
     548END
    536549\end{verbatim}
    537550
    538 The second function examines the contents of the headers of the chips
    539 and cells and constructs the collection of astrometric coordinate
    540 transformations..
    541 
    542 The third function uses the offset information and the basic telescope
    543 pointing information to construct a approximate guess at the
    544 astrometric coefficients based on the detector geometry.
    545 
    546 \begin{figure}
    547 \begin{center}
    548 \psfig{file=CameraLayout,width=5.5in}
    549 \caption{Camera Pixel Layout\label{CameraLayout}}
    550 \end{center}
    551 \end{figure}
    552 
    553 \begin{figure}
    554 \begin{center}
    555 \psfig{file=CameraRegionKeywords.ps,width=5.5in}
    556 \caption{Camera Region Keyword Definitions\label{CameraRegionKeywords}}
    557 \end{center}
    558 \end{figure}
    559 
    560 \subsection{Chip \& Cell from FITS File}
    561 \tbd{the algorithm for the function in this section is not
    562   well-defined.  do not code yet}.
    563 
    564 When loading data from disk, it is may be necessary to use the
    565 information in the DATASEC and DETSEC entries to determine which part
    566 of the image should be read.  If the data is stored in a chip-based
    567 format, then the data for each cell corresponds to only a fraction of
    568 the pixels stored in a single image extension.  We specify the
    569 following function to perform the correct read of data from a FITS
    570 file into the corresponding \code{psCell} entry respecting the
    571 boundaries of the cells within chip-based images.
    572 
    573 \begin{prototype}
    574 psReadout *pmReadoutLoad (psReadout *input, psFits *f, psCell *cell, int plane);
    575 \end{prototype}
     551In the FITS \code{TRANSLATION} table in the camera configuration, for
     552certain concepts we allow the specification of the concept with an
     553additional suffix, \code{_FORMAT} which specifies the format of the
     554FITS header.  The value is dependent upon the particular concept.
     555
     556\paragraph{CELL.TIME}
     557
     558The time at which the shutter opens is represented in a variety of
     559ways in FITS files, so care must be taken to specify what the format
     560is in the file under consideration.  Permitted values of
     561\code{CELL.TIME_FORMAT} are:
     562
     563\begin{itemize}
     564\item \code{JD}: The value pointed to by \code{CELL.TIME} is to be
     565  interpreted as a Julian Date.
     566\item \code{MJD}: The value pointed to by \code{CELL.TIME} is to be
     567  interpreted as a Modified Julian Date.
     568\item \code{ISO}: The value pointed to by \code{CELL.TIME} is to be
     569  interpreted as an ISO date-time (yyyy-mm-ddThh:mm:ss.ss).
     570\item \code{SEPARATE}: The date and time are specified separately, and
     571  the \code{CELL.TIME} contains the headers for the date and the time
     572  separated by whitespace or a comma.  Then it might be necessary to
     573  add additional qualifiers to specify the formats of these:
     574  \begin{itemize}
     575  \item \code{PRE2000}: The year is in the old style two-digit format
     576    popular before the year 2000, and it should be assumed that the
     577    date is in the twentieth century.
     578  \item \code{BACKWARDS}: The date is in the format dd-mm-yyyy or
     579    dd/mm/yyyy.
     580  \item \code{SOD}: The time is specified as seconds-of-day.
     581  \end{itemize}
     582\end{itemize}
     583
     584Note that the FITS standard is that the time in the header refers to
     585the {\it start} of the observation.  \tbd{In the future, we might add
     586additional qualifiers that calculate the start time of the observation
     587based on someone foolishly putting the end- or mid-time in the header.}
     588
     589\paragraph{CELL.BINNING}
     590
     591The binning is usually specified in FITS headers either as separate
     592headers for the x and the y, or in the same FITS header separated by a
     593space or a comma.  Permitted values of \code{CELL.BINNING_FORMAT} are:
     594
     595\begin{itemize}
     596\item \code{SEPARATE}: The \code{CELL.BINNING} contains the headers
     597  for the x and the y binning separated by whitespace or a comma.
     598\item \code{TOGETHER}: The value pointed to by \code{CELL.BINNING}
     599  contains the x and y binning separated by whitespace and/or a comma.
     600\end{itemize}
     601
     602\paragraph{FPA.RA and FPA.DEC}
     603
     604The RA and Declination of the boresight might be specified in a few
     605ways.  We need to specify both how the value is interpreted and the
     606units.  \code{FPA.RA_FORMAT} and \code{FPA.DEC_FORMAT} should be one
     607of the following:
     608
     609\begin{itemize}
     610\item \code{HOURS}: The value pointed to by the concept should be
     611  interpreted as being in hours.
     612\item \code{DEGREES}: The value pointed to by the concept should be
     613  interpreted as being in degrees.
     614\item \code{RADIANS}: The value pointed to by the concept should be
     615  interpreted as being in radians.
     616\end{itemize}
     617
     618How the value is interpreted can be determined from the type of the
     619header: if it is of type \code{STR}, then we can reasonably assume
     620that it is in sexagesimal format with colons or spaces as separators;
     621and if it is of type \code{F32} (or \code{F64}), then we can assume
     622that it is in decimal format.
     623
     624\subsubsection{CELLS}
     625
     626The \code{CELLS} entry in the camera configuration contains data
     627appropriate to each cell.  These will generally consist of the
     628\code{CELL.BIASSEC} and \code{CELL.TRIMSEC} concepts, though it might
     629contain \code{CELL.GAIN} and \code{CELL.READNOISE} values as well
     630instead of going to the trouble of specifying these in the
     631\code{DEFAULTS} with a long \code{_DEPENDS} listing.
     632
     633However, we need to specify for these where the value comes from.  It
     634should be sufficient to declare the following rules:
     635
     636\begin{itemize}
     637\item If the type is other than \code{STR}, then the concept has that
     638  value for the cell.
     639\item If the type is \code{STR} and contains square brackets
     640  \code{[]}, then it shall be interpreted as a value for one of the
     641  image section concepts (\code{CELL.BIASSEC} and
     642  \code{CELL.TRIMSEC}).
     643\item Otherwise, it shall be interpreted as a FITS header keyword
     644  which will provide the value.
     645\end{itemize}
     646
     647These rules mean that we don't have to bother adding an additional
     648suffix like \code{_SOURCE}.
     649
     650\subsubsection{Lookups}
     651
     652We here specify a series of ``one-stop shops'' for lookups of the
     653concepts.  These will be what the user utilises, so the goal is to
     654provide a simple interface providing a single type back, so the user
     655doesn't have to go to the trouble of checking types, etc.
     656
     657\begin{prototype}
     658float pmFPAGetAirmass(pmFPA *fpa);     // FPA.AIRMASS
     659psString pmFPAGetFilter(pmFPA *fpa);   // FPA.FILTER
     660float pmFPAGetPosAngle(pmFPA *fpa);    // FPA.POSANGLE
     661double pmFPAGetRA(pmFPA *fpa);         // FPA.RA
     662double pmFPAGetDec(pmFPA *fpa);        // FPA.DEC
     663psString pmFPAGetRADecSys(pmFPA *fpa); // FPA.RADECSYS
     664psString pmFPAGetName(pmFPA *fpa);     // FPA.NAME
     665psString pmChipGetName(pmChip *chip);  // CHIP.NAME
     666psString pmCellGetName(pmCell *cell);  // CELL.NAME
     667psTime *pmCellGetTime(pmCell *cell);   // CELL.TIME
     668psList *pmCellGetBiasSec(pmCell *cell); // CELL.BIASSEC
     669psRegion pmCellGetTrimSec(pmCell *cell); // CELL.TRIMSEC
     670float pmCellGetGain(pmCell *cell);     // CELL.GAIN
     671float pmCellGetReadNoise(pmCell *cell); // CELL.READNOISE
     672float pmCellGetSaturation(pmCell *cell); // CELL.SATURATION
     673float pmCellGetBad(pmCell *cell);      // CELL.BAD
     674psPixelCoord pmCellGetBin(pmCell *cell); // CELL.BIN
     675psPixelCoord pmCellGetParity(pmCell *cell); // CELL.PARITY
     676float pmReadoutGetExposure(pmReadout *readout); // READOUT.EXPOSURE
     677float pmReadoutGetDarkTime(pmReadout *readout); // READOUT.DARKTIME
     678\end{prototype}
     679
     680Most of these are straight-forward, but some need some explanation.
     681
     682\code{pmCellGetBiasSec} shall return a list of \code{psRegion}s, one
     683for each bias section.
     684
     685\code{pmCellGetBin} shall return a \code{psPixelCoord} with the
     686binning factors appropriately set in the \code{x} and \code{y}
     687members.  Similarly with \code{pmCellGetParity}.
     688
     689
     690\input{CameraImages.tex}
     691
     692%\input{CameraGeometry.tex}
    576693
    577694\section{Photometry}
     
    665782
    666783Each of these shall be discussed in turn, below.  Those modules which
    667 are \tbd{TBD} will be deferred until they may be properly defined,
     784are \tbd{} will be deferred until they may be properly defined,
    668785some of which requires further research to define the best algorithm.
    669786
     
    679796The API shall be the following:
    680797\begin{prototype}
    681 psReadout *pmSubtractBias(psReadout *in, void *fitSpec, const psList *overscans,
     798pmReadout *pmSubtractBias(pmReadout *in, void *fitSpec, const psList *overscans,
    682799                          pmOverscanAxis overscanAxis, const psStats *stat,
    683                           int nBin, pmFit fit, const psReadout *bias);
     800                          int nBin, pmFit fit, const pmReadout *bias);
    684801\end{prototype}
    685802
     
    809926
    810927\begin{prototype}
    811 psReadout *pmNonLinearityPolynomial(psReadout *in, const psPolynomial1D *coeff);
     928pmReadout *pmNonLinearityPolynomial(pmReadout *in, const psPolynomial1D *coeff);
    812929\end{prototype}
    813930
     
    820937
    821938\begin{prototype}
    822 psReadout *pmNonLinearityLookup(psReadout *in, const psVector *inFlux, const psVector *outFlux);
     939pmReadout *pmNonLinearityLookup(pmReadout *in, const psVector *inFlux, const psVector *outFlux);
    823940\end{prototype}
    824941
     
    856973updating the mask as appropriate.  The API shall be the following:
    857974\begin{prototype}
    858 bool pmFlatField(psReadout *in, psReadout *mask, const psReadout *flat);
     975bool pmFlatField(pmReadout *in, pmReadout *mask, const pmReadout *flat);
    859976\end{prototype}
    860977
     
    9211038shall be the following:
    9221039\begin{prototype}
    923 psReadout *pmMaskBadPixels(psReadout *in, const psImage *mask, unsigned int maskVal,
     1040pmReadout *pmMaskBadPixels(pmReadout *in, const psImage *mask, unsigned int maskVal,
    9241041                           float sat, unsigned int growVal, int grow);
    9251042\end{prototype}
     
    9531070the following:
    9541071\begin{prototype}
    955 psReadout *pmSubtractSky(psReadout *in, psPolynomial2D *poly, psImage *mask, psU8 maskVal,
     1072pmReadout *pmSubtractSky(pmReadout *in, psPolynomial2D *poly, psImage *mask, psU8 maskVal,
    9561073                         int binFactor, psStats *stats, float clipSD);
    9571074\end{prototype}
     
    10401157If the \code{inputs} is \code{NULL}, the module shall generate an
    10411158error and return \code{NULL}.  Otherwise, the \code{inputs} shall be a
    1042 list of \code{psReadout}s.  The images contained within the
    1043 \code{psReadout}s need not all be of the same size, but the module
     1159list of \code{pmReadout}s.  The images contained within the
     1160\code{pmReadout}s need not all be of the same size, but the module
    10441161shall take into account the offsets (\code{col0,row0}) from the corner
    10451162of the detector when comparing pixels, so that it is the same
     
    10521169this structure instead of supplying the values separately in order to
    10531170keep down the number of parameters to \code{pmReadoutCombine}; the
    1054 \code{psCombineParams} may be recycled for subsequent calls to
     1171\code{pmCombineParams} may be recycled for subsequent calls to
    10551172\code{pmReadoutCombine} since the values are not dependent upon the
    10561173choice of inputs, but merely specify how the combination is to be
     
    10631180
    10641181If the \code{maskVal} is non-zero, then pixels in the \code{mask} of
    1065 each \code{psReadout} in the \code{inputs} which satisfy the
     1182each \code{pmReadout} in the \code{inputs} which satisfy the
    10661183\code{maskVal} shall not have the corresponding pixels placed in the
    10671184stack for combination.
     
    12701387  psVector *dparams;        // parameter errors
    12711388  psF32 chisq;              // fit chisq
    1272   psS32 nDOF;               // number of degrees of freedom
     1389  psS32 nDOF;               // number of degrees of freedom
    12731390  psS32 nIter;              // number of iterations
    12741391} pmModel;
     
    13071424typedef struct {
    13081425    psS32 type;             ///< PSF Model in use
    1309     psArray *params;        ///< Model parameters (psPolynomial2D)
     1426    psArray *params;        ///< Model parameters (psPolynomial2D)
    13101427    psF32 chisq;            ///< PSF goodness statistic
    1311     psS32 nPSFstars;        ///< number of stars used to measure PSF
     1428    psS32 nPSFstars;        ///< number of stars used to measure PSF
    13121429} pmPSF;
    13131430\end{datatype}
     
    17761893                        );
    17771894\end{prototype}
     1895
     1896\tbd{This algorithm will change: an addition will be made to avoid
     1897masking pixels in the wings of a star when combining images taken in
     1898different seeing, and the gradient limit criteria will be changed.}
    17781899
    17791900\code{pmRejectPixels} inspects those questionable \code{pixels}
     
    19442065    pmSubtractionKernelType type;       // Type of kernels --- allowing the use of multiple kernels
    19452066    int size;                           // Size of kernel in x and y
    1946     int spatialOrder;                   // Maximum order of spatial variations
     2067    int spatialOrder;                   // Maximum order of spatial variations
    19472068    psVector *u, *v;                    // Offset (for POIS) or polynomial order (for ISIS)
    19482069    psVector *sigma;                    // Width of Gaussian (for ISIS)
     
    20192140    psImage *matrix;                    // Associated matrix
    20202141    psVector *vector;                   // Associated vector
    2021     psStampStatus status;               // Status of stamp
     2142    pmStampStatus status;               // Status of stamp
    20222143} pmStamp;
    20232144\end{datatype}
     
    23622483%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    23632484
     2485\section{Example Camera Configuration Files}
     2486
     2487\tbd{Some of these don't exactly match the specifications of this
     2488document yet, because they have been changed from the prototype, but
     2489it is hoped that they will be useful.  Questions are welcome.}
     2490
     2491\subsection{MegaCam Raw}
     2492
     2493\begin{verbatim}
     2494# The raw MegaCam data comes off the telescope with each of the chips stored in extensions of a MEF file.
     2495
     2496# How to identify this type
     2497RULE    METADATA
     2498        TELESCOP        STR     CFHT 3.6m
     2499        DETECTOR        STR     MegaCam
     2500        EXTEND          BOOL    T
     2501        NEXTEND         S32     72
     2502END
     2503
     2504# How to read this data
     2505PHU             STR     FPA     # The FITS file represents an entire FPA
     2506EXTENSIONS      STR     CELL    # The extensions represent cells
     2507
     2508# What's in the FITS file?
     2509CONTENTS        METADATA
     2510        # Extension name, chip name:type
     2511        amp00   STR     ccd00:left
     2512        amp01   STR     ccd00:right
     2513        amp02   STR     ccd01:left
     2514        amp03   STR     ccd01:right
     2515        amp04   STR     ccd02:left
     2516        amp05   STR     ccd02:right
     2517        amp06   STR     ccd03:left
     2518        amp07   STR     ccd03:right
     2519        amp08   STR     ccd04:left
     2520        amp09   STR     ccd04:right
     2521        amp10   STR     ccd05:left
     2522        amp11   STR     ccd05:right
     2523        amp12   STR     ccd06:left
     2524        amp13   STR     ccd06:right
     2525        amp14   STR     ccd07:left
     2526        amp15   STR     ccd07:right
     2527        amp16   STR     ccd08:left
     2528        amp17   STR     ccd08:right
     2529        amp18   STR     ccd09:left
     2530        amp19   STR     ccd09:right
     2531        amp20   STR     ccd10:left
     2532        amp21   STR     ccd10:right
     2533        amp22   STR     ccd11:left
     2534        amp23   STR     ccd11:right
     2535        amp24   STR     ccd12:left
     2536        amp25   STR     ccd12:right
     2537        amp26   STR     ccd13:left
     2538        amp27   STR     ccd13:right
     2539        amp28   STR     ccd14:left
     2540        amp29   STR     ccd14:right
     2541        amp30   STR     ccd15:left
     2542        amp31   STR     ccd15:right
     2543        amp32   STR     ccd16:left
     2544        amp33   STR     ccd16:right
     2545        amp34   STR     ccd17:left
     2546        amp35   STR     ccd17:right
     2547        amp36   STR     ccd18:left
     2548        amp37   STR     ccd18:right
     2549        amp38   STR     ccd19:left
     2550        amp39   STR     ccd19:right
     2551        amp40   STR     ccd20:left
     2552        amp41   STR     ccd20:right
     2553        amp42   STR     ccd21:left
     2554        amp43   STR     ccd21:right
     2555        amp44   STR     ccd22:left
     2556        amp45   STR     ccd22:right
     2557        amp46   STR     ccd23:left
     2558        amp47   STR     ccd23:right
     2559        amp48   STR     ccd24:left
     2560        amp49   STR     ccd24:right
     2561        amp50   STR     ccd25:left
     2562        amp51   STR     ccd25:right
     2563        amp52   STR     ccd26:left
     2564        amp53   STR     ccd26:right
     2565        amp54   STR     ccd27:left
     2566        amp55   STR     ccd27:right
     2567        amp56   STR     ccd28:left
     2568        amp57   STR     ccd28:right
     2569        amp58   STR     ccd29:left
     2570        amp59   STR     ccd29:right
     2571        amp60   STR     ccd30:left
     2572        amp61   STR     ccd30:right
     2573        amp62   STR     ccd31:left
     2574        amp63   STR     ccd31:right
     2575        amp64   STR     ccd32:left
     2576        amp65   STR     ccd32:right
     2577        amp66   STR     ccd33:left
     2578        amp67   STR     ccd33:right
     2579        amp68   STR     ccd34:left
     2580        amp69   STR     ccd34:right
     2581        amp70   STR     ccd35:left
     2582        amp71   STR     ccd35:right
     2583END
     2584
     2585# Specify the cell data
     2586CELLS   METADATA
     2587        left    METADATA        # Left amplifier
     2588                CELL.BIASSEC    STR     HEADER:BIASSEC
     2589                CELL.TRIMSEC    STR     HEADER:DATASEC
     2590                CELL.XPARITY    S32     1       # We could have specified this as a DEFAULT, but this works
     2591        END
     2592        right   METADATA        # Right amplifier
     2593                CELL.BIASSEC    STR     HEADER:BIASSEC
     2594                CELL.TRIMSEC    STR     HEADER:DATASEC
     2595                CELL.XPARITY    S32     -1      # This cell is read out in the opposite direction
     2596        END
     2597END
     2598
     2599# How to translate PS concepts into FITS headers
     2600TRANSLATION     METADATA
     2601        FPA.NAME        STR     EXPNUM
     2602        FPA.AIRMASS     STR     AIRMASS
     2603        FPA.FILTER      STR     FILTER
     2604        FPA.POSANGLE    STR     ROTANGLE
     2605        FPA.RA          STR     RA
     2606        FPA.DEC         STR     DEC
     2607        FPA.RADECSYS    STR     RADECSYS
     2608        FPA.MJD         STR     MJD-OBS
     2609        CELL.EXPOSURE   STR     EXPTIME
     2610        CELL.DARKTIME   STR     DARKTIME
     2611        CELL.XBIN       STR     CCDBIN1
     2612        CELL.YBIN       STR     CCDBIN2
     2613        CELL.GAIN       STR     GAIN
     2614        CELL.READNOISE  STR     RDNOISE
     2615        CELL.SATURATION STR     SATURATE
     2616END
     2617
     2618# Default PS concepts that may be specified by value
     2619DEFAULTS        METADATA
     2620        CELL.BAD                S32     0
     2621        CELL.YPARITY_DEPEND     STR     CHIP.NAME
     2622        CELL.YPARITY    METADATA
     2623                ccd00   S32     -1
     2624                ccd01   S32     -1
     2625                ccd02   S32     -1
     2626                ccd03   S32     -1
     2627                ccd04   S32     -1
     2628                ccd05   S32     -1
     2629                ccd06   S32     -1
     2630                ccd07   S32     -1
     2631                ccd08   S32     -1
     2632                ccd09   S32     -1
     2633                ccd10   S32     -1
     2634                ccd11   S32     -1
     2635                ccd12   S32     -1
     2636                ccd13   S32     -1
     2637                ccd14   S32     -1
     2638                ccd15   S32     -1
     2639                ccd16   S32     -1
     2640                ccd17   S32     -1
     2641                ccd18   S32     1
     2642                ccd19   S32     1
     2643                ccd20   S32     1
     2644                ccd21   S32     1
     2645                ccd22   S32     1
     2646                ccd23   S32     1
     2647                ccd24   S32     1
     2648                ccd25   S32     1
     2649                ccd26   S32     1
     2650                ccd27   S32     1
     2651                ccd28   S32     1
     2652                ccd29   S32     1
     2653                ccd30   S32     1
     2654                ccd31   S32     1
     2655                ccd32   S32     1
     2656                ccd33   S32     1
     2657                ccd34   S32     1
     2658                ccd35   S32     1
     2659        END
     2660END
     2661
     2662# How to translation PS concepts into database lookups
     2663DATABASE        METADATA
     2664        TYPE            dbEntry         TABLE           COLUMN          GIVENDBCOL      GIVENPS
     2665#       CELL.GAIN       dbEntry         Camera          gain            chipId,cellId   CHIP.NAME,CELL.NAME
     2666#       CELL.READNOISE  dbEntry         Camera          readNoise       chipId,cellId   CHIP.NAME,CELL.NAME
     2667
     2668# A database entry refers to a particular column (COLUMN) in a
     2669# particular table (TABLE), given certain PS concepts (GIVENPS) that
     2670# match certain database columns (GIVENDBCOL).
     2671
     2672END
     2673\end{verbatim}
     2674
     2675\subsection{MegaCam Splice}
     2676
     2677\begin{verbatim}
     2678# The spliced MecaCam data is stored in single extensions for each chip
     2679
     2680# How to recognise this type
     2681RULE    METADATA
     2682        TELESCOP        STR     CFHT 3.6m
     2683        DETECTOR        STR     MegaCam
     2684        EXTEND          BOOL    T
     2685        NEXTEND         S32     36
     2686END
     2687
     2688# How to read this data
     2689PHU             STR     FPA     # The FITS file represents an entire FPA
     2690EXTENSIONS      STR     CHIP    # The extensions represent chips
     2691
     2692# What's in the FITS file?
     2693CONTENTS        METADATA
     2694        # Extension name, components
     2695        ccd00           STR     left right
     2696        ccd01           STR     left right
     2697        ccd02           STR     left right
     2698        ccd03           STR     left right
     2699        ccd04           STR     left right
     2700        ccd05           STR     left right
     2701        ccd06           STR     left right
     2702        ccd07           STR     left right
     2703        ccd08           STR     left right
     2704        ccd09           STR     left right
     2705        ccd10           STR     left right
     2706        ccd11           STR     left right
     2707        ccd12           STR     left right
     2708        ccd13           STR     left right
     2709        ccd14           STR     left right
     2710        ccd15           STR     left right
     2711        ccd16           STR     left right
     2712        ccd17           STR     left right
     2713        ccd18           STR     left right
     2714        ccd19           STR     left right
     2715        ccd20           STR     left right
     2716        ccd21           STR     left right
     2717        ccd22           STR     left right
     2718        ccd23           STR     left right
     2719        ccd24           STR     left right
     2720        ccd25           STR     left right
     2721        ccd26           STR     left right
     2722        ccd27           STR     left right
     2723        ccd28           STR     left right
     2724        ccd29           STR     left right
     2725        ccd30           STR     left right
     2726        ccd31           STR     left right
     2727        ccd32           STR     left right
     2728        ccd33           STR     left right
     2729        ccd34           STR     left right
     2730        ccd35           STR     left right
     2731END
     2732
     2733# Specify the cells
     2734CELLS           METADATA
     2735        left            METADATA
     2736                CELL.BIASSEC    STR     HEADER:BSECA
     2737                CELL.TRIMSEC    STR     HEADER:TSECA
     2738        END
     2739
     2740        right           METADATA
     2741                CELL.BIASSEC    STR     HEADER:BSECB
     2742                CELL.TRIMSEC    STR     HEADER:TSECB
     2743        END
     2744END
     2745
     2746# How to translate PS concepts into FITS headers
     2747TRANSLATION     METADATA
     2748        FPA.NAME        STR     EXPNUM
     2749        FPA.AIRMASS     STR     AIRMASS
     2750        FPA.FILTER      STR     FILTER
     2751        FPA.POSANGLE    STR     ROTANGLE
     2752        FPA.RA          STR     RA
     2753        FPA.DEC         STR     DEC
     2754        FPA.RADECSYS    STR     RADECSYS
     2755        FPA.MJD         STR     MJD-OBS
     2756        CELL.EXPOSURE   STR     EXPTIME
     2757        CELL.DARKTIME   STR     DARKTIME
     2758        CELL.XBIN       STR     CCDBIN1
     2759        CELL.YBIN       STR     CCDBIN2
     2760        CELL.GAIN       STR     GAIN
     2761        CELL.READNOISE  STR     RDNOISE
     2762        CELL.SATURATION STR     SATURATE
     2763END
     2764
     2765# Default PS concepts that may be specified by value
     2766DEFAULTS        METADATA
     2767        CELL.BAD                S32     0
     2768        CELL.XPARITY            S32     1
     2769        CELL.YPARITY            S32     1
     2770END
     2771
     2772
     2773# How to translation PS concepts into database lookups
     2774DATABASE        METADATA
     2775        TYPE            dbEntry         TABLE           COLUMN          GIVENDBCOL      GIVENPS
     2776#       CELL.GAIN       dbEntry         Camera          gain            chipId,cellId   CHIP.NAME,CELL.NAME
     2777#       CELL.READNOISE  dbEntry         Camera          readNoise       chipId,cellId   CHIP.NAME,CELL.NAME
     2778
     2779# A database entry refers to a particular column (COLUMN) in a
     2780# particular table (TABLE), given certain PS concepts (GIVENPS) that
     2781# match certain database columns (GIVENDBCOL).
     2782
     2783END             
     2784\end{verbatim}
     2785
     2786\subsection{LRIS Blue}
     2787
     2788\begin{verbatim}
     2789# The Low Resolution Imager and Spectrograph (LRIS) blue side
     2790
     2791# We have no choice but to hard-code the various regions, because Keck
     2792# only stores them as:
     2793# WINDOW  = '1,0,0,2048,4096'
     2794# PREPIX  =                   51
     2795# POSTPIX =                   80
     2796# BINNING = '1,1     '
     2797# AMPPSIZE= '[1:1024,1:4096]'
     2798
     2799# I don't know how we would get the IPP to react to changes in the
     2800# windowing on the fly --- we have no mechanism for setting the region
     2801# sizes on the basis of the above keywords.  Therefore, we hard-code
     2802# the regions and assert on our assumptions in the RULE.
     2803
     2804
     2805# How to identify this type
     2806RULE    METADATA
     2807        TELESCOP        STR     Keck I
     2808        INSTRUME        STR     LRISBLUE
     2809        AMPLIST         STR     1,4,0,0
     2810        WINDOW          STR     1,0,0,2048,4096
     2811        PREPIX          S32     51
     2812        POSTPIX         S32     80
     2813        BINNING         STR     1,1
     2814        AMPPSIZE        STR     [1:1024,1:4096]
     2815        NAXIS1          S32     4620
     2816        NAXIS2          S32     4096
     2817END
     2818
     2819# How to read this data
     2820PHU             STR     FPA     # The FITS file represents an entire FPA
     2821EXTENSIONS      STR     NONE    # There are no extensions
     2822
     2823# What's in the FITS file?
     2824CONTENTS        METADATA
     2825        LeftChip        STR     amp1 amp2
     2826        RightChip       STR     amp3 amp4
     2827END
     2828
     2829# Specify the cell data
     2830CELLS   METADATA
     2831        amp1            METADATA
     2832                CELL.BIASSEC    STR     VALUE:[1:51,1:4096];[4301:4380,1:4096]
     2833                CELL.TRIMSEC    STR     VALUE:[205:1228,1:4096]
     2834                CELL.GAIN       STR     VALUE:1.2
     2835                CELL.READNOISE  STR     VALUE:5.6
     2836        END
     2837
     2838        amp2    METADATA
     2839                CELL.BIASSEC    STR     VALUE:[52:102,1:4096];[4381:4460,1:4096]
     2840                CELL.TRIMSEC    STR     VALUE:[1229:2252,1:4096]
     2841                CELL.GAIN       STR     VALUE:1.3
     2842                CELL.READNOISE  STR     VALUE:6.7
     2843        END
     2844
     2845        amp3            METADATA
     2846                CELL.BIASSEC    STR     VALUE:[103:153,1:4096];[4461:4540,1:4096]
     2847                CELL.TRIMSEC    STR     VALUE:[2253:3276,1:4096]
     2848                CELL.GAIN       STR     VALUE:1.4
     2849                CELL.READNOISE  STR     VALUE:7.8
     2850        END
     2851
     2852        amp4    METADATA
     2853                CELL.BIASSEC    STR     VALUE:[154:204,1:4096];[4541:4620,1:4096]
     2854                CELL.TRIMSEC    STR     VALUE:[3277:4300,1:4096]
     2855                CELL.GAIN       STR     VALUE:1.5
     2856                CELL.READNOISE  STR     VALUE:8.9
     2857        END
     2858END
     2859
     2860# How to translate PS concepts into FITS headers
     2861TRANSLATION     METADATA
     2862        FPA.AIRMASS     STR     AIRMASS
     2863        FPA.FILTER      STR     BLUFILT
     2864        FPA.POSANGLE    STR     ROTPOSN
     2865        FPA.RA          STR     RA
     2866        FPA.DEC         STR     DEC
     2867        CELL.EXPOSURE   STR     EXPOSURE
     2868        CELL.DARKTIME   STR     EXPOSURE        // No special darktime header; use exposure time
     2869        CELL.DATE       STR     DATE            // NOTE: There are TWO keywords called "DATE" (creation, exp)!
     2870        CELL.TIME       STR     UT
     2871END
     2872
     2873# Default PS concepts that may be specified by value
     2874DEFAULTS        METADATA
     2875        FPA.RADECSYS    STR     ICRS
     2876END
     2877\end{verbatim}
     2878
     2879\subsection{LRIS Red}
     2880
     2881\begin{verbatim}
     2882# The Low Resolution Imager and Spectrograph (LRIS) red side
     2883
     2884# We have no choice but to hard-code the various regions, because Keck
     2885# only stores them as:
     2886# WINDOW  = '0,0,0,2048,2048'
     2887# PREPIX  =                   20
     2888# POSTPIX =                   80
     2889# BINNING = '1,1     '
     2890# AMPPSIZE= '[1:1024,1:4096]'
     2891
     2892# I don't know how we would get the IPP to react to changes in the
     2893# windowing on the fly --- we have no mechanism for setting the region
     2894# sizes on the basis of the above keywords.  Therefore, we hard-code
     2895# the regions and assert on our assumptions in the RULE.
     2896
     2897
     2898# How to identify this type
     2899RULE    METADATA
     2900        TELESCOP        STR     Keck I
     2901        INSTRUME        STR     LRIS
     2902        AMPLIST         STR     2,1,0,0
     2903        WINDOW          STR     0,0,0,2048,2048
     2904        PREPIX          S32     20
     2905        POSTPIX         S32     80
     2906        BINNING         STR     1, 1
     2907        CCDPSIZE        STR     [1:2048,1:2048]
     2908        NAXIS1          S32     2248
     2909        NAXIS2          S32     2048
     2910        IMTYPE          STR     TWOAMPTOP
     2911END
     2912
     2913# How to read this data
     2914PHU             STR     CHIP    # The FITS file represents a single chip
     2915EXTENSIONS      STR     NONE    # There are no extensions
     2916
     2917# What's in the FITS file?
     2918CONTENTS        STR     LeftSide RightSide
     2919
     2920# Specify the cell data
     2921CELLS   METADATA
     2922        LeftSide        METADATA
     2923                CELL.BIASSEC    STR     VALUE:[1:20,1:2048];[2089:2168,1:2048]
     2924                CELL.TRIMSEC    STR     VALUE:[41:1064,1:2048]
     2925                CELL.GAIN       STR     VALUE:1.2
     2926                CELL.READNOISE  STR     VALUE:5.6
     2927        END
     2928
     2929        RightSide       METADATA
     2930                CELL.BIASSEC    STR     VALUE:[21:40,1:2048];[2169:2248,1:2048]
     2931                CELL.TRIMSEC    STR     VALUE:[1065:2088,1:2048]
     2932                CELL.GAIN       STR     VALUE:1.3
     2933                CELL.READNOISE  STR     VALUE:6.5
     2934        END
     2935END
     2936
     2937# How to translate PS concepts into FITS headers
     2938TRANSLATION     METADATA
     2939        FPA.AIRMASS     STR     AIRMASS
     2940        FPA.FILTER      STR     FILTER
     2941        FPA.POSANGLE    STR     POSANG
     2942        FPA.RA          STR     OBJ-RA
     2943        FPA.DEC         STR     OBJ-DEC
     2944        CELL.EXPOSURE   STR     EXPTIME
     2945        CELL.DARKTIME   STR     DARKTIME
     2946        CELL.DATE       STR     DATE-OBS
     2947        CELL.TIME       STR     TIME-OBS
     2948END
     2949
     2950# Default PS concepts that may be specified by value
     2951DEFAULTS        METADATA
     2952        FPA.RADECSYS    STR     ICRS
     2953END
     2954\end{verbatim}
     2955
     2956\subsection{GPC OTA}
     2957
     2958\begin{verbatim}
     2959# The raw GPC data comes off the telescope with each of the chips stored in separate files
     2960
     2961# How to identify this type
     2962RULE    METADATA
     2963#       TELESCOP        STR     PS1
     2964#       DETECTOR        STR     GPC1
     2965        EXTEND          BOOL    T
     2966        NEXTEND         S32     64
     2967        NAMPS           S32     64
     2968END
     2969
     2970# How to read this data
     2971PHU             STR     CHIP    # The FITS file represents a single chip
     2972EXTENSIONS      STR     CELL    # The extensions represent cells
     2973
     2974# What's in the FITS file?
     2975CONTENTS        METADATA
     2976        # Extension name, type
     2977        xy00    STR     pitch10u
     2978        xy01    STR     pitch10u
     2979        xy02    STR     pitch10u
     2980        xy03    STR     pitch10u
     2981        xy04    STR     pitch10u
     2982        xy05    STR     pitch10u
     2983        xy06    STR     pitch10u
     2984        xy07    STR     pitch10u
     2985        xy10    STR     pitch10u
     2986        xy11    STR     pitch10u
     2987        xy12    STR     pitch10u
     2988        xy13    STR     pitch10u
     2989        xy14    STR     pitch10u
     2990        xy15    STR     pitch10u
     2991        xy16    STR     pitch10u
     2992        xy17    STR     pitch10u
     2993        xy20    STR     pitch10u
     2994        xy21    STR     pitch10u
     2995        xy22    STR     pitch10u
     2996        xy23    STR     pitch10u
     2997        xy24    STR     pitch10u
     2998        xy25    STR     pitch10u
     2999        xy26    STR     pitch10u
     3000        xy27    STR     pitch10u
     3001        xy30    STR     pitch10u
     3002        xy31    STR     pitch10u
     3003        xy32    STR     pitch10u
     3004        xy33    STR     pitch10u
     3005        xy34    STR     pitch10u
     3006        xy35    STR     pitch10u
     3007        xy36    STR     pitch10u
     3008        xy37    STR     pitch10u
     3009        xy40    STR     pitch10u
     3010        xy41    STR     pitch10u
     3011        xy42    STR     pitch10u
     3012        xy43    STR     pitch10u
     3013        xy44    STR     pitch10u
     3014        xy45    STR     pitch10u
     3015        xy46    STR     pitch10u
     3016        xy47    STR     pitch10u
     3017        xy50    STR     pitch10u
     3018        xy51    STR     pitch10u
     3019        xy52    STR     pitch10u
     3020        xy53    STR     pitch10u
     3021        xy54    STR     pitch10u
     3022        xy55    STR     pitch10u
     3023        xy56    STR     pitch10u
     3024        xy57    STR     pitch10u
     3025        xy60    STR     pitch10u
     3026        xy61    STR     pitch10u
     3027        xy62    STR     pitch10u
     3028        xy63    STR     pitch10u
     3029        xy64    STR     pitch10u
     3030        xy65    STR     pitch10u
     3031        xy66    STR     pitch10u
     3032        xy67    STR     pitch10u
     3033        xy70    STR     pitch10u
     3034        xy71    STR     pitch10u
     3035        xy72    STR     pitch10u
     3036        xy73    STR     pitch10u
     3037        xy74    STR     pitch10u
     3038        xy75    STR     pitch10u
     3039        xy76    STR     pitch10u
     3040        xy77    STR     pitch10u
     3041END
     3042
     3043# Specify the cell data
     3044CELLS   METADATA
     3045        pitch10u        METADATA
     3046                CELL.BIASSEC    STR     VALUE:[575:606,1:594]
     3047                CELL.TRIMSEC    STR     VALUE:[1:574,1:594]
     3048        #       CELL.BIASSEC    STR     HEADER:BIASSEC
     3049        #       CELL.TRIMSEC    STR     HEADER:DATASEC
     3050        END
     3051
     3052        # This is just in here for fun
     3053        pitch12u        METADATA
     3054                CELL.BIASSEC    STR     VALUE:[1:10,1:512];[523:574,1:512]
     3055                CELL.TRIMSEC    STR     VALUE:[11:522,1:512]
     3056        #       CELL.BIASSEC    STR     HEADER:BIASSEC
     3057        #       CELL.TRIMSEC    STR     HEADER:TRIMSEC
     3058        END
     3059END
     3060
     3061
     3062# How to translate PS concepts into FITS headers
     3063TRANSLATION     METADATA
     3064        CELL.BIN        STR     CCDSUM
     3065        CELL.SATURATION STR     SATURATE
     3066END
     3067
     3068# Default PS concepts that may be specified by value
     3069DEFAULTS        METADATA
     3070        FPA.AIRMASS     F32     0.0
     3071        FPA.FILTER      STR     NONE
     3072        FPA.POSANGLE    F32     0.0
     3073        FPA.RA          STR     0:0:0
     3074        FPA.DEC         STR     0:0:0
     3075        FPA.RADECSYS    STR     ICRS
     3076        FPA.NAME        S32     0
     3077        FPA.MJD         F32     12345.6789
     3078        CELL.EXPOSURE   F32     0.0
     3079        CELL.DARKTIME   F32     0.0
     3080        CELL.GAIN       F32     1.0
     3081        CELL.READNOISE  F32     0.0
     3082        CELL.BAD        S32     0
     3083        CELL.BIN        S32     1
     3084        CELL.XPARITY    S32     1
     3085        CELL.YPARITY    S32     1
     3086END
     3087
     3088# How to translation PS concepts into database lookups
     3089DATABASE        METADATA
     3090        TYPE            dbEntry         TABLE           COLUMN          GIVENDBCOL      GIVENPS
     3091        CELL.GAIN       dbEntry         Camera          gain            chipId,cellId   CHIP,CELL
     3092        CELL.READNOISE  dbEntry         Camera          readNoise       chipId,cellId   CHIP,CELL
     3093
     3094# A database entry refers to a particular column (COLUMN) in a
     3095# particular table (TABLE), given certain PS concepts (GIVENPS) that
     3096# match certain database columns (GIVENDBCOL).
     3097
     3098END
     3099\end{verbatim}
     3100
     3101
     3102%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
     3103
    23643104\section{Revision Change Log}
    23653105\input{ChangeLogSDRS.tex}
Note: See TracChangeset for help on using the changeset viewer.