Index: trunk/archive/pslib/include/psAstrom.h
===================================================================
--- trunk/archive/pslib/include/psAstrom.h	(revision 251)
+++ trunk/archive/pslib/include/psAstrom.h	(revision 253)
@@ -7,16 +7,16 @@
  */
 
-/** Astrometric solution for an OTA.
+/* Astrometric transformations for a focal plane array.
  * There are five coordinate frames that we need to worry about:
- * 1. Cell frame:    x,y in pixels (raw coordinates; lower-left pixel center is 0.5,0.5 TBR)
- * 2. Chip frame:    X,Y in pixels
- * 3. FPA frame:     P,Q in microns 
+ * 1. Cell:          x,y in pixels (raw coordinates; lower-left pixel center is 0.5,0.5 TBR)
+ * 2. Chip:          X,Y in pixels
+ * 3. FPA:           P,Q in microns 
  * 4. Tangent plane: L,M in arcsec (TBR - angles or linear?) from the telescope boresight.
  * 5. Sky frame:     R,D in degrees (TBR - radians?)
  *
- * 1 <--> 2: cell.coords : a 2-D linear transformation : rotation, scaling, offset, (skew)
- * 2 <--> 3: chip.coords : a 2-D cubic (max) transform : specifies how the chips are mounted on the focal plane.
- * 3 <--> 4: fpa.distort : a 2-D quartic (?) transform : specifies the distortions in the optics
- * 4 <--> 5: fpa.SLpars  : SLALib parameters generated based on the telescope, ra, dec, time, etc from exposure info
+ * 1 <--> 2: 2 2-D polynomials: (X,Y) = f(x,y)
+ * 2 <--> 3: 2 2-D polynomials: (P.Q) = f(X,Y)
+ * 3 <--> 4: 2 4-D polynomials: (L,M) = f(P,Q,m,c) (m & c are magnitude and color of object)
+ * 4 <--> 5: SLALib transformation using exposure parameters (psExposure or psGrommit)
  */
 
@@ -67,8 +67,9 @@
     int nChips;                         ///< Number of Cells assigned
     int nAlloc;                         ///< Number of Cells available
-    psChip *chips;                      ///< Chips in the Focal Plane Array
-    psMetaData *md;                     ///< FPA-level metadata
-    psDistort *TPtoFP;                  ///< Transformation term from 
-    psDistort *FPtoTP;                  ///< Transformation term from 
+    struct psChip *chips;		///< Chips in the Focal Plane Array
+
+    psMetaDataSet *md;			///< FPA-level metadata 
+    psDistortion *TPtoFP;		///< Transformation term from 
+    psDistortion *FPtoTP;		///< Transformation term from 
     psExposure *exp;                    ///< information about this exposure
     psMatrix *dx, *dy;                  //!< Focal Plane fixed pattern residual offsets
@@ -83,11 +84,11 @@
 typedef struct {
     int nCells;                         ///< Number of Cells assigned
-    psCell *cells;                      ///< Cells in the Chip
-    psMetaData *md;                     ///< Chip-level metadata
-
+    struct psCell *cells;               ///< Cells in the Chip
+
+    psMetaDataSet *md;			///< Chip-level metadata
     psCoordXform *chipToFPA;            ///< Transformations from chip coordinates to FPA coordinates
     psCoordXform *FPAtoChip;            ///< Transformations from chip coordinates to FPA coordinates
 
-    psFPA *parentFPA;                   ///< FPA which contains this chip
+    struct psFPA *parentFPA;		///< FPA which contains this chip
 } psChip;
 
@@ -95,13 +96,14 @@
  */
 typedef struct {
-    psObjectTable *objects;             ///< objects derived from cell
+    int nImage;				///< number of images in this cell realization
     psImage *image;                     ///< imaging area of cell 
+    psDlist *objects;			///< objects derived from cell
     psImage *overscan;                  ///< bias region (subimage) of cell
-    psMetaData *md;                     ///< Cell-level metadata
+    psMetaDataSet *md;			///< Cell-level metadata
 
     psCoordXform *cellToChip;		///< Transformations from cell coordinates to chip coordinates
     psCoordXform *cellToFPA;		///< Transformations from cell coordinates to FPA coordinates
 
-    psChip  *parentChip;                ///< chip which contains this cell
+    struct psChip  *parentChip;		///< chip which contains this cell
 } psCell;
 
@@ -112,69 +114,69 @@
 /* Calculating and applying astrometric solutions */
 
-/** returns Cell in Chip which contains the given point */
-int
+/** returns Chip in FPA which contains the given FPA coordinate */
+psChip *
+psChipInFPA (psFPA *fpa, 		///< FPA description
+	     psCoord *coord		///< coordinate in FPA
+	     );
+
+/** returns Cell in Chip which contains the given chip coordinate */
+psCell *
 psCellInChip (psChip *chip, 		///< chip description
-	      psCoords *coords		///< coordinate to find
+	      psCoord *coord		///< coordinate in chip
 	      );
 
-/** returns the Cell coords for the specified Cell corresponding to the given Chip coords */
-psCoords
-psChipCoordsOnCell (psCell *cell, 	///< source cell for coordinate
-		    psCoords *coords	///< coordinate of interest
-		    );
-
-/** returns the Cell coords for the specified Cell corresponding to the given Chip coords */
-psCoords
-psCellCoordsInChip (psChip *chip, 	///< 
-		    int cell, 		///< 
-		    psCoords *coords	///< 
-		    );
-
-/** returns Chip in FPA which contains the given point */
-int
-psChipInFPA (psFPA *fpa, 		///< 
-	     psCoords *coords		///< 
-	     );
-
-/** returns the Chip coords for the specified Chip corresponding to the given FPA coords */
-psCoords
-psFPACoordsOnChip (psChip *chip, 	///< 
-		   psCoords *coords	///< 
+/** Convert (RA,Dec) to tangent plane coords */
+psCoord *
+psCoordSkyToTP(psExposure *exp,		//!< Exposure description
+	       psCoord *coord		//!< input Sky coordinate
+	       );
+
+/** Convert tangent plane coords to focal plane coordinates */
+psCoord *
+psCoordTPtoFPA(psFPA *fpa,		//!< FPA description
+	       psCoord *coord		//!< input TP coordinate
+	       );
+
+/** converts the specified FPA coord to the coord on the given Chip */
+psCoord *
+psCoordFPAtoChip (psFPA *fpa, 		///< FPA description
+		  psChip *chip,		///< Chip of interest
+		  psCoord *coord	///< input FPA coordinate
+		  ); 
+
+/** converts the specified Chip coord to the coord on the given Cell */
+psCoord *
+psCoordChiptoCell (psChip *chip,	///< Chip description
+		   psCell *cell, 	///< Cell of interest
+		   psCoord *coord	///< input Chip coordinate
 		   );
 
-/** returns the Chip coords for the specified Chip corresponding to the given FPA coords */
-psCoords
-psChipCoordsInFPA (psFPA *fpa, 		///< 
-		   int chip, 		///< 
-		   psCoords *coords	///< 
+/** converts the specified Cell coord to the coord on the parent Chip */
+psCoord *
+psCoordCelltoChip (psCell *cell, 	///< Cell description
+		   psCoord *coord	///< input Cell coordinate
 		   );
 
-/** Convert (RA,Dec) to (cell#,x,y) */
-psCoords *
-psSkyToFPA(psFPA *fpa,			//!< OTA details
-	   psCoords *coords		//!< Position on the sky
-           );
-
-/** Convert (cell#,x,y) to (RA,Dec) */
-psCoords *
-psFPAToSky(psFPA *fpa,			//!< OTA details
-	   psCoords *coords		//!< Position on the sky
-           );
-
-/** Convert (RA,Dec) to (cell#,x,y) */
-psCoords *
-psSkyToTP(psExposure *exp,		//!< OTA details
-	  psCoords *coords		//!< Position on the sky
-	  );
-
-/** Convert (RA,Dec) to (cell#,x,y) */
-psCoords *
-psTPtoSky(psExposure *exp,		//!< OTA details
-	  psCoords *coords		//!< Position on the sky
-	  );
+/** converts the specified Chip coord to the coord on the parent FPA */
+psCoord *
+psCoordChiptoFPA (psChip *chip, 	///< Chip description
+		  psCoord *coord	///< input Chip coordinate
+		  );
+
+/** Convert focal plane coords to tangent plane coordinates */
+psCoord *
+psCoordFPAToTP(psFPA *fpa,			//!< FPA description
+	       psCoord *coord		//!< input FPA coordinate
+	       );
+
+/** Convert tangent plane coords to (RA,Dec) */
+psCoord *
+psCoordTPtoSky(psExposure *exp,		//!< Exposure description
+	       psCoord *coord		//!< input TP coordinate
+	       );
 
 /** Get the airmass for a given position and sidereal time */
 float
-psGetAirmass(psCoords *coords,		//!< Position on the sky
+psGetAirmass(psCoord *coord,		//!< Position on the sky
              double siderealTime        //!< Sidereal time
              );
@@ -182,5 +184,5 @@
 /** Get the parallactic angle for a given position and sidereal time */
 float
-psGetParallactic(psCoords *coords,	//!< Position on the sky
+psGetParallactic(psCoord *coord,	//!< Position on the sky
                  double siderealTime    //!< Sidereal time
                  );
@@ -189,16 +191,8 @@
 float
 psGetRefraction(float colour,           //!< Colour of object
-                psColourRef colourRef,  //!< Colour reference
+		psPhotSystem colorPlus,	// 
+		psPhotSystem colorMinus, ///< Colour reference
                 psExposure *exp         //!< Telescope pointing information, for airmass, temp and pressure
 		);
-
-/** Fit astrometric solution to list of (chip#,x,y) and (RA,Dec) */
-int
-psFitAstrom(psOTADescription *restrict ota, //!< Initial guess for coefficients
-            const psOTAPosArray *restrict detector, //!< Positions on OTA (chip#,x,y)
-            const psSkyPosArray *restrict sky, //!< Positions on the sky (RA,Dec)
-            const psExposure *exp       //!< Telescope pointing information, for airmass, parallactic angle
-                                        //!< which may help set the astrometric solution
-            );
 
 /*** Constructors / Destructors ******************************************************/
@@ -223,4 +217,15 @@
 psExposureFree(psExposure *restrict myExp //!< Object to destroy
 	       );
-
 #endif
+
+/*
+   example images:
+
+   GPC:          1 Chip per file, 1 Cell per extension 
+   Megacam:      1 FPA per file, 1 Chip per extension, 2 Cell per extension (DSEC) 
+   CFH12K (MEF): 1 FPA per file, 1 Chip per extension, 1 Cell per extension
+   CFHT-IR:      1 FPA per file, 1 Chip per extension, 4 Cell per extension (NAXIS = 3)
+   WIRCAM:       1 FPA per file, 1 Chip per extension, 1 Cell per extension (?)
+   
+
+*/
