Index: trunk/psModules/src/pmAstrometry.h
===================================================================
--- trunk/psModules/src/pmAstrometry.h	(revision 4754)
+++ trunk/psModules/src/pmAstrometry.h	(revision 4770)
@@ -8,6 +8,6 @@
 *  @author GLG, MHPCC
 *
-*  @version $Revision: 1.1 $ $Name: not supported by cvs2svn $
-*  @date $Date: 2005-08-11 00:03:51 $
+*  @version $Revision: 1.2 $ $Name: not supported by cvs2svn $
+*  @date $Date: 2005-08-16 01:10:34 $
 *
 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -143,11 +143,16 @@
     // Information
     psImage *image;                     ///< Imaging area of readout
+    // XXX: The following mask was removed from the pmReadout struct in recent SDRS
+    // versions.  However, I'm keeping it here since al ot of modules still require
+    // it.
+    psImage *mask;                      ///< Mask of input image
     psMetadata *analysis;               ///< Readout-level analysis metadata
     psMetadata *concepts;               ///< Cache for PS Concepts
     pmCell *parent;                     ///< Parent cell
 }
-psReadout;
-
-/** Allocates a psReadout
+pmReadout;
+
+
+/** Allocates a pmReadout
  *
  *  The constructor shall make an empty pmReadout. If the parent cell is not
@@ -156,20 +161,19 @@
  *  other pointers in the structure shall be initialized to NULL.
  *
- *  @return psReadout*    newly allocated psReadout with all internal pointers set to NULL
- */
-psReadout *pmReadoutAlloc(
+ *  @return pmReadout*    newly allocated pmReadout with all internal pointers set to NULL
+ */
+pmReadout *pmReadoutAlloc(
     pmCell *cell                        ///< Parent cell
 );
 
-/** Allocates a psCell
+/** Allocates a pmCell
  *
  *  The constructor shall make an empty pmCell. If the parent chip is not NULL,
- *  the parent link is made and the cell shall be placed in the parentThe
- *  constructor shall make an empty psCell.s array of cells. The readouts
- *  array shall be allocated with a zero size, and the metadata containers
- *  constructed. All other pointers in the structure shall be initialized to
- *  NULL.
- *
- *  @return psCell*    newly allocated psCell
+ *  the parent link is made and the cell shall be placed in the parents array of
+ *  cells. The readouts array shall be allocated with a zero size, and the
+ *  metadata containers constructed. All other pointers in the structure shall be
+ *  initialized to NULL.
+ *
+ *  @return pmCell*    newly allocated pmCell
  */
 pmCell *pmCellAlloc(
@@ -198,8 +202,29 @@
  */
 pmFPA *pmFPAAlloc(
-    const psMetadata *camera           ///< Camera configuration
-    //    psDB *db                            ///< Database handle
-);
-
+    const psMetadata *camera,           ///< Camera configuration
+    psDB *db                            ///< Database handle
+);
+
+
+/** Verify parent links.
+ * 
+ *  This function checks the validity of the parent links in the FPA hierarchy.
+ *  If a parent link is not set (or not set correctly), it is corrected, and the
+ *  function shall return false. If all the parent pointers were correct, the
+ *  function shall return true.
+ * 
+ */
+bool pmFPACheckParents(
+    pmFPA *fpa
+);
+
+
+
+/** FUNC DESC
+ * 
+ * 
+ * 
+ * 
+ */
 
 
@@ -211,217 +236,33 @@
 
 
-
-
-
-
-
-/** Wallace's Grommit
- *
- *  SLALib requires several elements to perform the transformations between
- *  the tangent plane and the sky.  Pre-computing these quantities for each
- *  exposure means that subsequent transformations are faster.  For historical
- *  reasons, this structure is known colloquially as "Wallace's Grommit".
- *
- */
-
-/*
-typedef struct
-{
-   const double latitude;           ///< geodetic latitude (radians)
-   const double longitude;          ///< longitude + ... (radians)
-   const double height;             ///< height (HM)
-   const double abberationMag;      ///< magnitude of diurnal aberration vector
-   const double temperature;        ///< ambient temperature (TDK)
-   const double pressure;           ///< pressure (PMB)
-   const double humidity;           ///< relative humidity (RH)
-   const double wavelength;         ///< wavelength (WL)
-   const double lapseRate;          ///< lapse rate (TLR)
-   const double refractA, refractB; ///< refraction constants A and B (radians)
-   const double siderealTime;       ///< local apparent sidereal time (radians)
-}
-psGrommit;
-*/
-
-
-/** Fixed Pattern Corrections
- *
- *  The fixed pattern is a correction to the general astrometric solution
- *  formed by summing the residuals from many observations. The intent is to
- *  correct for higher-order distortions in the camera system on a coarse
- *  grid (larger than individual pixels, but smaller than a single cell).
- *  Hence, in addition to the offsets, we need to specify the size and scale
- *  of the grid in x and y as well as the origin of the grid.
- */
-/*
-typedef struct
-{
-    psS32 nX;                            ///< Number of elements in x direction
-    psS32 nY;                            ///< Number of elements in y direction
-    double x0;                         ///< X Position of 0,0 corner on focal plane
-    double y0;                         ///< Y Position of 0,0 corner on focal plane
-    double xScale;                     ///< Scale of the grid in x direction
-    double yScale;                     ///< Scale of the grid in x direction
-    /// XXX: I added the following memvers to facilitate the psFreeing of the x,y data structures.
-    psS32 p_ps_xRows;                    ///< Number of rows in the x member
-    psS32 p_ps_xCols;                    ///< Number of cols in the x member
-    psS32 p_ps_yRows;                    ///< Number of rows in the y member
-    psS32 p_ps_yCols;                    ///< Number of cols in the y member
-    double **x;                        ///< The grid of offsets in x
-    double **y;                        ///< The grid of offsets in y
-}
-psFixedPattern;
-*/
-
-
-/** Observatory Information
- *
- *  A container for the observatory data that doesn't change per exposure.
- *
- */
-/*typedef struct
-{
-    const char* name;                  ///< Name of observatory
-    const double latitude;             ///< Latitude of observatory, east positive (degrees?)
-    const double longitude;            ///< Longitude of observatory (degrees?)
-    const double height;               ///< Height of observatory in meters
-    const double tlr;                  ///< Tropospheric Lapse Rate
-}
-psObservatory;
-*/
-
-/** Exposure Information
- *
- *  Several quantities from the telescope in order to make a first guess at
- *  the astrometric solution.  From these quantities, further quantities can
- *  be derivedand stored for later use.
- *
- */
-/*typedef struct psExposure
-{
-    const double ra;                   ///< Telescope boresight, right ascention
-    const double dec;                  ///< Telescope boresight, declination
-    const double hourAngle;            ///< Hour angle
-    const double zenithDistance;       ///< Zenith distance
-    const double azimuth;              ///< Azimuth
-    const psTime* time;                ///< Time of observation
-    const float rotAngle;              ///< Rotator position angle in degrees? XXX: see bug#209
-    const float temperature;           ///< Air temperature in Kelvin
-    const float pressure;              ///< Air pressure in mB
-    const float humidity;              ///< Relative humidity, for refraction
-    const float exposureTime;          ///< Exposure time
-    const float wavelength;            ///< Wavelength in microns
-    const psObservatory* observatory;  ///< Observatory data
- 
-    // Derived quantities
-    const double lst;                  ///< Local Sidereal Time
-    const float positionAngle;         ///< Position angle
-    const float parallacticAngle;      ///< Parallactic angle
-    const float airmass;               ///< Airmass, calculated from zenith distance
-    const float parallacticFactor;     ///< Parallactic factor
-    const char* cameraName;            ///< name of camera which provided exposure
-    const char* telescopeName;         ///< name of telescope which provided exposure
-}
-psExposure;
-*/
-
-/** Allocator for psFixedPattern struct
- *
- *  Allocates a new psFixedPattern struct with the attributes coorsponding
- *  to the parameters set to the said input values.
- *
- *  @return psFixedPattern*     New psFixedPattern struct.
- */
-/*psFixedPattern* psFixedPatternAlloc(
-    double x0,           ///< X Position of 0,0 corner on focal plane
-    double y0,           ///< Y Position of 0,0 corner on focal plane
-    double xScale,       ///< Scale of the grid in x direction
-    double yScale,       ///< Scale of the grid in x direction
-    const psImage *x,    ///< The grid of offsets in x
-    const psImage *y     ///< The grid of offsets in y
-);
-*/
-
-/** Allocator for psExposure
- *
- *  We need several quantities from the telescope in order to make a first
- *  guess at the astrometric solution. From these quantities, further
- *  quantities can be derived and stored for later use.
- *
- *  @return     psExposure*    New psExposure struct
- */
-/*psExposure* psExposureAlloc(
-    double ra,                         ///< Telescope boresight, right ascention
-    double dec,                        ///< Telescope boresight, declination
-    double hourAngle,                  ///< Hour angle
-    double zenithDistance,             ///< Zenith distance
-    double azimuth,                    ///< Azimuth
-    const psTime* time,                ///< time of observation
-    float rotAngle,                    ///< Rotator position angle
-    float temperature,                 ///< Temperature
-    float pressure,                    ///< Pressure
-    float humidity,                    ///< Relative humidity
-    float exposureTime,                ///< Exposure time
-    float wavelength,                  ///< wavelength
-    const psObservatory* observatory   ///< Observatory data
-);
-*/
-
-/** Allocator for psObservatory
- *
- *  This function shall construct a new psObservatory with attributes
- *  cooresponding to the function parameters.
- *
- *  @return psObservatory*    new psObservatory struct
- */
-/*psObservatory* psObservatoryAlloc(
-    const char* name,                  ///< Name of observatory
-    double latitude,                   ///< Latitude of observatory, east positive
-    double longitude,                  ///< Longitude of observatory
-    double height,                     ///< Height of observatory
-    double tlr                         ///< Tropospheric Lapse Rate
-);
-*/
-
-/** Allocates a Wallace's Grommit structure.
- *
- *  The psGrommit is calculated from telescope information for the particular
- *  exposure.
- *
- *  @return psGrommit* New grommit structure.
- */
-/*psGrommit* psGrommitAlloc(
-    const psExposure* exp              ///< the cooresponding exposure structure.
-);
-*/
-
 /** Find cooresponding cell for given FPA coordinate
  *
- *  @return psCell*    the cell cooresponding to the coord in FPA
- */
-/*psCell* psCellInFPA(
+ *  @return pmCell*    the cell cooresponding to the coord in FPA
+ */
+pmCell* pmCellInFPA(
     const psPlane* coord,              ///< the coordinate in FPA plane
-    const psFPA* FPA                   ///< the FPA to search for the cell
-);
-*/
+    const pmFPA* FPA                   ///< the FPA to search for the cell
+);
+
 
 /** Find cooresponding chip for given FPA coordinate
  *
- *  @return psChip*    the chip cooresponding to coord
- */
-/*psChip* psChipInFPA(
+ *  @return pmChip*    the chip cooresponding to coord
+ */
+pmChip* pmChipInFPA(
     const psPlane* coord,              ///< the coordinate in FPA plane
-    const psFPA* FPA                   ///< the FPA to search for the cell
-);
-*/
+    const pmFPA* FPA                   ///< the FPA to search for the cell
+);
+
 
 /** Find cooresponding cell for given Chip coordinate
  *
- *  @return psCell*    the cell cooresponding to coord
- */
-/*psCell* psCellInChip(
+ *  @return pmCell*    the cell cooresponding to coord
+ */
+pmCell* pmCellInChip(
     const psPlane* coord,              ///< the coordinate in Chip plane
-    const psChip* chip                 ///< the chip to search for the cell
-);
-*/
+    const pmChip* chip                 ///< the chip to search for the cell
+);
+
 
 /** Translate a cell coordinate into a chip coordinate
@@ -429,10 +270,10 @@
  *  @return psPlane*    the resulting chip coordinate
  */
-/*psPlane* psCoordCellToChip(
+psPlane* psCoordCellToChip(
     psPlane* out,                      ///< a plane struct to recycle. If NULL, a new struct is created
     const psPlane* in,                 ///< the coordinate within Cell
-    const psCell* cell                 ///< the Cell in interest
-);
-*/
+    const pmCell* cell                 ///< the Cell in interest
+);
+
 
 /** Translate a chip coordinate into a FPA coordinate
@@ -440,10 +281,10 @@
  *  @return psPlane*    the resulting FPA coordinate
  */
-/*psPlane* psCoordChipToFPA(
+psPlane* psCoordChipToFPA(
     psPlane* out,                      ///< a plane struct to recycle. If NULL, a new struct is created
     const psPlane* in,                 ///< the coordinate within Chip
-    const psChip* chip                 ///< the chip in interest
-);
-*/
+    const pmChip* chip                 ///< the chip in interest
+);
+
 
 /** Translate a FPA coordinate into a Tangent Plane coordinate
@@ -451,12 +292,12 @@
  *  @return psPlane*    the resulting Tangent Plane coordinate
  */
-/*psPlane* psCoordFPAToTP(
+psPlane* psCoordFPAToTP(
     psPlane* out,                      ///< a plane struct to recycle. If NULL, a new struct is created
     const psPlane* in,                 ///< the coordinate within FPA
     double color,                      ///< Color of source
     double magnitude,                  ///< Magnitude of source
-    const psFPA* fpa                   ///< the FPA in interest
-);
-*/
+    const pmFPA* fpa                   ///< the FPA in interest
+);
+
 
 /** Translate a Tangent Plane coordinate into a Sky coordinate
@@ -464,10 +305,9 @@
  *  @return psSphere*    the resulting Sky coordinate
  */
-/*psSphere* psCoordTPToSky(
+psSphere* psCoordTPToSky(
     psSphere* out,                     ///< a sphere struct to recycle. If NULL, a new struct is created
-    const psPlane* in,                 ///< the coordinate within Tangent Plane
-    const psGrommit* grommit           ///< the grommit of the tangent plane
-);
-*/
+    const psPlane* in,                ///< the coordinate within Tangent Plane
+    const psProjection *projection
+);
 
 /** Translate a cell coordinate into a FPA coordinate
@@ -475,10 +315,10 @@
  *  @return psPlane*    the resulting FPA coordinate
  */
-/*psPlane* psCoordCellToFPA(
+psPlane* psCoordCellToFPA(
     psPlane* out,                      ///< a plane struct to recycle. If NULL, a new struct is created
     const psPlane* in,                 ///< the coordinate within cell
-    const psCell* cell                 ///< the cell in interest
-);
-*/
+    const pmCell* cell                 ///< the cell in interest
+);
+
 
 /** Translate a cell coordinate into a Sky coordinate
@@ -486,12 +326,12 @@
  *  @return psSphere*    the resulting Sky coordinate
  */
-/*psSphere* psCoordCellToSky(
+psSphere* psCoordCellToSky(
     psSphere* out,                     ///< a sphere struct to recycle. If NULL, a new struct is created
     const psPlane* in,                 ///< the coordinate within cell
     double color,                      ///< Color of source
     double magnitude,                  ///< Magnitude of source
-    const psCell* cell                 ///< the cell in interest
-);
-*/
+    const pmCell* cell                 ///< the cell in interest
+);
+
 
 /** Translate a cell coordinate into a Sky coordinate using a 'quick and
@@ -500,10 +340,10 @@
  *  @return psSphere*    the resulting Sky coordinate
  */
-/*psSphere* psCoordCellToSkyQuick(
+psSphere* psCoordCellToSkyQuick(
     psSphere* out,                     ///< a sphere struct to recycle. If NULL, a new struct is created
     const psPlane* in,                 ///< the coordinate within cell
-    const psCell* cell                 ///< the cell in interest
-);
-*/
+    const pmCell* cell                 ///< the cell in interest
+);
+
 
 /** Translate a Sky coordinate into a Tangent Plane coordinate
@@ -511,10 +351,9 @@
  *  @return psPlane*    the resulting Tangent Plane coordinate
  */
-/*psPlane* psCoordSkyToTP(
+psPlane* psCoordSkyToTP(
     psPlane* out,                      ///< a plane struct to recycle. If NULL, a new struct is created
     const psSphere* in,                ///< the sky coordinate
-    const psGrommit* grommit           ///< the grommit
-);
-*/
+    const psProjection *projection
+);
 
 /** Translate a Tangent Plane coordinate into a FPA coordinate
@@ -522,12 +361,12 @@
  *  @return psPlane*    the resulting FPA coordinate
  */
-/*psPlane* psCoordTPToFPA(
+psPlane* psCoordTPToFPA(
     psPlane* out,                      ///< a plane struct to recycle. If NULL, a new struct is created
     const psPlane* in,                 ///< the coordinate within tangent plane
     double color,                      ///< Color of source
     double magnitude,                  ///< Magnitude of source
-    const psFPA* fpa                   ///< the FPA of interest
-);
-*/
+    const pmFPA* fpa                   ///< the FPA of interest
+);
+
 
 /** Translate a FPA coordinate into a chip coordinate
@@ -535,10 +374,10 @@
  *  @return psPlane*    the resulting chip coordinate
  */
-/*psPlane* psCoordFPAToChip(
+psPlane* psCoordFPAToChip(
     psPlane* out,                      ///< a plane struct to recycle. If NULL, a new struct is created
     const psPlane* in,                 ///< the FPA coordinate
-    const psChip* chip                 ///< the chip of interest
-);
-*/
+    const pmChip* chip                 ///< the chip of interest
+);
+
 
 /** Translate a chip coordinate into a cell coordinate
@@ -546,10 +385,10 @@
  *  @return psPlane*    the resulting cell coordinate
  */
-/*psPlane* psCoordChipToCell(
+psPlane* psCoordChipToCell(
     psPlane* out,                      ///< a plane struct to recycle. If NULL, a new struct is created
     const psPlane* in,                 ///< the Chip coordinate
-    const psCell* cell                 ///< the cell of interest
-);
-*/
+    const pmCell* cell                 ///< the cell of interest
+);
+
 
 /** Translate a sky coordinate into a cell coordinate
@@ -557,12 +396,12 @@
  *  @return psPlane*    the resulting cell coordinate
  */
-/*psPlane* psCoordSkyToCell(
+psPlane* psCoordSkyToCell(
     psPlane* out,                      ///< a plane struct to recycle. If NULL, a new struct is created
     const psSphere* in,                ///< the Sky coordinate
-    double color,                      ///< Color of source
-    double magnitude,                  ///< Magnitude of source
-    const psCell* cell                 ///< the cell of interest
-);
-*/
+    float color,                       ///< Color of source
+    float magnitude,                   ///< Magnitude of source
+    const pmCell* cell                 ///< the cell of interest
+);
+
 
 /** Translate a sky coordinate into a cell coordinate using a 'quick and
@@ -571,10 +410,10 @@
  *  @return psPlane*    the resulting cell coordinate
  */
-/*psPlane* psCoordSkyToCellQuick(
+psPlane* psCoordSkyToCellQuick(
     psPlane* out,                      ///< a plane struct to recycle. If NULL, a new struct is created
     const psSphere* in,                ///< the Sky coordinate
-    const psCell* cell                 ///< the cell of interest
-);
-*/
+    const pmCell* cell                 ///< the cell of interest
+);
+
 
 #endif // #ifndef PS_ASTROMETRY_H
