Index: /trunk/archive/pslib/include/psAstrom.h
===================================================================
--- /trunk/archive/pslib/include/psAstrom.h	(revision 250)
+++ /trunk/archive/pslib/include/psAstrom.h	(revision 251)
@@ -1,4 +1,4 @@
-#if !defined(PS_ASTROM_H)
-#define PS_ASTROM_H
+# if !defined(PS_ASTROM_H)
+# define PS_ASTROM_H
 
 /** \file psAstrom.h
@@ -7,211 +7,220 @@
  */
 
+/** Astrometric solution for an OTA.
+ * 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 
+ * 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
+ */
+
+/** Information needed (by SLALIB) to convert Apparent to Observed Position */
+typedef struct {
+    double latitude;                    ///< geodetic latitude (radians)
+    double sinLat, cosLat;              ///< sine and cosine of geodetic latitude
+    double abberationMag;               ///< magnitude of diurnal aberration vector
+    double height;                      ///< height (HM)
+    double temperature;                 ///< ambient temperature (TDK)
+    double pressure;                    ///< pressure (PMB)
+    double humidity;                    ///< relative humidity (RH)
+    double wavelength;                  ///< wavelength (WL)
+    double lapseRate;                   ///< lapse rate (TLR)
+    double refractA, refractB;          ///< refraction constants A and B (radians)
+    double longitudeOffset;             ///< longitude + eqn of equinoxes + ``sidereal UT'' (radians)
+    double siderealTime;                ///< local apparent sidereal time (radians)
+} psGrommit;
+
+/** Exposure information from the telescope */
+typedef struct {
+    // Telescope longitude, latitude and height are stored separately, since they don't change with pointing
+    double ra, dec;                     //!< Telescope boresight
+    double ha;                          //!< Hour angle
+    double zd;                          //!< Zenith distance
+    double az;                          //!< Azimuth
+    double lst;                         //!< Local Sidereal Time
+    float mjd;                          //!< MJD of observation
+    float rotAngle;                     //!< Rotator position angle
+    float temp;                         //!< Air temperature, for estimating refraction
+    float pressure;                     //!< Air pressure, for calculating refraction
+    float humidity;                     //!< Relative humidity, for calculating refraction
+    float exptime;                      //!< Exposure time
+    /* Derived quantities */
+    float posAngle;                     //!< Position angle
+    float parallactic;                  //!< Parallactic angle
+    float airmass;                      //!< Airmass, calculated from zenith distance
+    float pf;                           //!< Parallactic factor
+    char *cameraName;                   ///< name of camera which provided exposure
+    char *telescopeName;                ///< name of telescope which provided exposure
+    psGrommit *grommit;                 //!< Data needed to convert from the sky to the tangent plane
+} psExposure;
+
+/** a Focal plane array: a collection of chips.  Not all chips in a camera need to be listed in an instance of
+ *  psFPA.
+ */
+typedef struct {
+    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 
+    psExposure *exp;                    ///< information about this exposure
+    psMatrix *dx, *dy;                  //!< Focal Plane fixed pattern residual offsets
+    psPhotSystem colorPlus, colorMinus; ///< Colour reference
+    float rmsX, rmsY;                   //!< Dispersion in astrometric solution
+    float chi2;                         //!< chi^2 of astrometric solution
+} psFPA;
+
+/** a Chip: a collection of cells.  Not all valid cells in a chip need to be listed in an
+ *  instance of psChip.
+ */
+typedef struct {
+    int nCells;                         ///< Number of Cells assigned
+    psCell *cells;                      ///< Cells in the Chip
+    psMetaData *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
+} psChip;
+
+/** a Cell: a collection of pixels.
+ */
+typedef struct {
+    psObjectTable *objects;             ///< objects derived from cell
+    psImage *image;                     ///< imaging area of cell 
+    psImage *overscan;                  ///< bias region (subimage) of cell
+    psMetaData *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
+} psCell;
+
+/*** Functions ***********************************************************************/
+
 /***********************************************************************************************************/
 
-/** Exposure information from the telescope */
-typedef struct {
-    // Telescope longitude, latitude and height are stored separately, since they don't change with pointing
-    double ra, dec;			//!< Telescope boresight
-    double ha;				//!< Hour angle
-    double zd;				//!< Zenith distance
-    double az;				//!< Azimuth
-    double lst;				//!< Local Sidereal Time
-    float mjd;				//!< MJD of observation
-    float rotAngle;			//!< Rotator position angle
-    float temp;				//!< Air temperature, for estimating refraction
-    float pressure;			//!< Air pressure, for calculating refraction
-    float humidity;			//!< Relative humidity, for calculating refraction
-    float exptime;			//!< Exposure time
-    /* Derived quantities */
-    float posAngle;			//!< Position angle
-    float parallactic;			//!< Parallactic angle
-    float airmass;	                //!< Airmass, calculated from zenith distance
-    float pf;				//!< Parallactic factor
-} psExposure;
+/* Calculating and applying astrometric solutions */
+
+/** returns Cell in Chip which contains the given point */
+int
+psCellInChip (psChip *chip, 		///< chip description
+	      psCoords *coords		///< coordinate to find
+	      );
+
+/** 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	///< 
+		   );
+
+/** returns the Chip coords for the specified Chip corresponding to the given FPA coords */
+psCoords
+psChipCoordsInFPA (psFPA *fpa, 		///< 
+		   int chip, 		///< 
+		   psCoords *coords	///< 
+		   );
+
+/** 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
+	  );
+
+/** Get the airmass for a given position and sidereal time */
+float
+psGetAirmass(psCoords *coords,		//!< Position on the sky
+             double siderealTime        //!< Sidereal time
+             );
+
+/** Get the parallactic angle for a given position and sidereal time */
+float
+psGetParallactic(psCoords *coords,	//!< Position on the sky
+                 double siderealTime    //!< Sidereal time
+                 );
+
+/** Estimate atmospheric refraction, along the parallactic */
+float
+psGetRefraction(float colour,           //!< Colour of object
+                psColourRef colourRef,  //!< 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 ******************************************************/
 
 /** Constructor */
 psExposure *
-psExposureAlloc(double ra, double dec,	//!< Telescope boresight
-		double ha,		//!< Hour angle
-		double zd,		//!< Zenith distance
-		double az,		//!< Azimuth
-		double lst,		//!< Local Sidereal Time
-		float mjd,		//!< MJD
-		float rotAngle,		//!< Rotator position angle
-		float temp,		//!< Temperature
-		float pressure,		//!< Pressure
-		float humidity,		//!< Relative humidity
-		float exptime		//!< Exposure time
-    );
+psExposureAlloc(double ra, double dec,  //!< Telescope boresight
+                double ha,              //!< Hour angle
+                double zd,              //!< Zenith distance
+                double az,              //!< Azimuth
+                double lst,             //!< Local Sidereal Time
+                float mjd,              //!< MJD
+                float rotAngle,         //!< Rotator position angle
+                float temp,             //!< Temperature
+                float pressure,         //!< Pressure
+                float humidity,         //!< Relative humidity
+                float exptime           //!< Exposure time
+		);
 
 /** Destructor */
 void
 psExposureFree(psExposure *restrict myExp //!< Object to destroy
-    );
-
-
-/***********************************************************************************************************/
-
-/** Cell details: specifies how the cell is mounted on its parent OTA */
-typedef struct {
-    double x, y;			//!< Position of cell in its OTA.  Specifies the position of the
-					//!< (imaginary) pixel (0,0)
-    double xErr, yErr;			//!< Error in position of cell in the OTA.
-    double rotation;			//!< Rotation of cell in its OTA.  Specified from +x through +y
-    int xSize, ySize;			//!< Number of pixels in x and y
-    double scale;			//!< Relative pixel scales, if CCD pitch varies over the OTA. Specify
-					//!< a positive scale for a left-handed coordinate system, negative
-					//!< for right. If NULL, then every chip has identical scale, and
-					//!< system is left-handed.
-} psCellDescription;
-
-/** Constructor */
-psCellDescription *
-psCellDescriptionAlloc(void);
-
-/** Destructor */
-void
-psCellDescriptionFree(psCellDescription *restrict myCell //!< Cell description to destroy
-    );
-
-/***********************************************************************************************************/
-
-/** Array of cell descriptions */
-typedef struct {
-    psType type;			//!< Type of data.  THIS STRUCT ELEMENT MUST BE FIRST IN THE STRUCT!
-    int size;				//!< Total number of elements available
-    int n;				//!< Number of elements in use
-    double *arr;			//!< The array data
-} psCellDescriptionArray;
-
-/** Constructor */
-psCellDescriptionArray *psCellDescriptionArrayAlloc(int s, //!< Total number of elements to make available
-						    int n //!< Number of elements that will be used
-						    );
-/** Reallocator */
-psCellDescriptionArray *psCellDescriptionArrayRealloc(psCellDescriptionArray *myArray, //!< Array to
-										       //!< reallocate
-						      int s //!< Total number of elements to make available
-						      );
-/** Destructor */
-void psCellDescriptionArrayFree(psCellDescriptionArray *restrict myArray //!< Array to free
-				);
-
-/***********************************************************************************************************/
-
-/** OTA details: specifies how the OTA is mounted on the focal plane */
-typedef struct {
-    double x, y;			//!< Position of OTA on the focal plane.  Specifies the position of
-					//!< the bottom left-hand corner.
-    double xErr, yErr;			//!< Error in the position of the OTA.
-    double rotation;			//!< Rotation of OTA on the focal plane.  Specified from +x through +y
-    psCellDescriptionArray *restrict cells; //!< Cell descriptions
-    struct psOTAAstrom *astrom;		//!< OTA astrometry
-    psExposure *exp;			//!< Exposure data
-} psOTADescription;
-
-/** Constructor */
-psOTADescription *
-psOTADescriptionAlloc(void);
-
-/** Destructor. */
-void
-psOTADescriptionFree(psOTADescription *restrict myOTA //!< OTA description to destroy
-    );
-
-/***********************************************************************************************************/
-
-/** Astrometric solution for an OTA.
- * There are four coordinate frames that we need to worry about:
- * 1. Chip frame: chip# plus x,y in pixels
- * 2. Focal plane frame: X,Y in microns
- * 3. Tangent plane: xi,eta in arcsec from the telescope boresight.
- * 4. Sky frame: RA,Dec
- *
- * 1 <--> 2: OTA description (parent of this struct) specifies how the chips are mounted on the focal plane.
- * 2 <--> 3: The astrometric solution corrects for distortions in the optics so we can go from what the
- * telescope sees on the focal plane to what it really should be like (i.e. the tangent plane).
- * 3 <--> 4: SLALib converts between the tangent plane and the celestial sphere using a set of numbers one
- * must calculate for each tangent point.
- *
- * Coordinate frames 2 and 3 are generally hidden from the user because all they care about is going between
- * frames 1 and 4.
- */
-typedef struct {
-    /* Focal plane to and from tangent plane */
-    psDPolynomial4D *restrict tpToFPX, *restrict tpToFPY; //!< General astrometric solution for tangent plane
-							  //!< to focal plane
-    psDPolynomial4D *restrict fpToTPXi, *restrict fpToTPEta; //!< General astrometric solution for focal plane
-							     //!< to tangent plane
-    psMatrix *pattern;		        //!< Fixed pattern distortions for focal plane to tangent plane (simply
-					//!< * -1 for the reverse); MAY NEED TO BE REVISED UPON IMPLEMENTATION
-    /* Tangent plane to and from the celestial sphere */
-    psDoubleArray *restrict tp;		//!< Data needed to convert from the sky to the tangent plane and back;
-					//!< produced by and used by SLALib (a.k.a. "Wallace's Grommit")
-    psColourRef colorRef;		//!< Colour reference
-    /* Characterisation of the solution */
-    float rmsX, rmsY;		        //!< Dispersion in astrometric solution
-    float chi2;				//!< chi^2 of astrometric solution
-} psOTAAstrom;
-
-/** Constructor */
-psOTAAstrom *
-psOTAAstromAlloc(const psExposure *exp //!< Telescope pointing, used to initialise the tp data.
-    );
-
-/** Destructor */
-void
-psOTAAstromFree(psOTAAstrom *restrict myAstrom	//!< Object to destroy
-    );
-
-/***********************************************************************************************************/
-
-/* Calculating and applying astrometric solutions */
-
-/** Convert (RA,Dec) to (cell#,x,y) */
-psOTAPos *
-psSkyToOTA(const psSkyPos *restrict position, //!< Position on the sky
-	   const psOTADescription *restrict ota //!< OTA details
-    );
-
-/** Convert (cell#,x,y) to (RA,Dec) */
-psSkyPos *
-psOTAToSky(const psOTAPos *restrict position, //!< Position on the detector
-	   const psOTADescription *restrict ota //!< OTA details
-    );
-
-/** 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
-	    );
-
-/***********************************************************************************************************/
-
-/* Functions needed for astrometry, and will likely be useful elsewhere */
-
-/** Get the airmass for a given position and sidereal time */
-float
-psGetAirmass(const psSkyPos *restrict position, //!< Position on the sky
-	     double siderealTime	//!< Sidereal time
-	     );
-
-/** Get the parallactic angle for a given position and sidereal time */
-float
-psGetParallactic(const psSkyPos *restrict position, //!< Position on the sky
-		 double siderealTime	//!< Sidereal time
-		 );
-
-/** Estimate atmospheric refraction, along the parallactic */
-float
-psGetRefraction(float colour,		//!< Colour of object
-		psColourRef colourRef,	//!< Colour reference
-		psExposure *exp		//!< Telescope pointing information, for airmass, temp and pressure
-    );
-
-/***********************************************************************************************************/
+	       );
 
 #endif
Index: /trunk/archive/pslib/include/psImage.h
===================================================================
--- /trunk/archive/pslib/include/psImage.h	(revision 250)
+++ /trunk/archive/pslib/include/psImage.h	(revision 251)
@@ -8,4 +8,5 @@
 
 /** General image manipulation functions.
+ *  These functions operate on individual 2D images
  */
 
@@ -27,6 +28,4 @@
     struct psImage *children;		///< children of this region 
     int Nchildren;			///< number of subimages 
-    struct psMetaDataSet *md;		///< metadata associated with image
-    psObjectArray *objtable;		///< objects associated with image
 } psImage;
 
Index: /trunk/archive/pslib/include/psLib.h
===================================================================
--- /trunk/archive/pslib/include/psLib.h	(revision 250)
+++ /trunk/archive/pslib/include/psLib.h	(revision 251)
@@ -33,11 +33,11 @@
 
 /** @defgroup AstroGroup Astronomy-Specific Utilities */
-# include <psAstrom.h>
-# include <psPhotom.h>
-# include <psImage.h>
-# include <psObject.h>
 # include <psPosition.h>
 # include <psDateTime.h>
 # include <psMetaData.h>
+# include <psImage.h>
+# include <psPhotom.h>
+# include <psAstrom.h>
+# include <psObject.h>
 
 # endif
Index: /trunk/archive/pslib/include/psObject.h
===================================================================
--- /trunk/archive/pslib/include/psObject.h	(revision 250)
+++ /trunk/archive/pslib/include/psObject.h	(revision 251)
@@ -11,6 +11,6 @@
 /** Object definition, to handle both objects we detect, and catalogues */
 typedef struct {
-    psOTAPos *otaPos;			//!< Centre position on OTA, with associated error
-    psSkyPos *skyPos;			//!< Position on the sky, with associated error
+    psCoord *cell;			//!< Centre position on Cell, with associated error
+    psCoord *sky;			//!< Position on the sky, with associated error
     float mag, magErr;			//!< Magnitude and associated error
     float isoMag, isoMagErr;		//!< Isophotal magnitude and associated error
@@ -20,6 +20,7 @@
     float sky, skyErr;			//!< Local sky level, and associated error
     float colour, colourErr;		//!< Colour and associated error, if known
-    psColourRef colourRef;		//!< Colour reference
+    psPhotSysrem colorPlus, colorMinus;	//!< Colour reference
     psBitMask *quality;			//!< Bit mask for quality information
+    psCell *parentCell;			///< Cell this measurement came from
 } psObject;
 
Index: /trunk/archive/pslib/include/psPosition.h
===================================================================
--- /trunk/archive/pslib/include/psPosition.h	(revision 250)
+++ /trunk/archive/pslib/include/psPosition.h	(revision 251)
@@ -7,138 +7,37 @@
  */
 
-/***********************************************************************************************************/
+/*************************************************/
+typedef struct {
+    union {
+	double x;				//!< x position
+	double r;				//!< x position
+    }
+    union {
+	double xErr;				//!< Error in x position
+	double rErr;				//!< Error in x position
+    }
+    union {
+	double y;				//!< y position
+	double d;				//!< y position
+    }
+    union {
+	double yErr;				//!< Error in y position
+	double dErr;				//!< Error in y position
+    }
+} psCoord;
 
-/** Planets */
-typedef enum {
-    PS_MERCURY = 1,
-    PS_VENUS = 2,
-    PS_MARS = 4,
-    PS_JUPITER = 5,
-    PS_SATURN = 6,
-    PS_URANUS = 7,
-    PS_NEPTUNE = 8,
-    PS_PLUTO = 9
-} psPlanetNum;
+typedef struct {
+    psDPolynomial4D *x;
+    psDPolynomial4D *y;
+} psDistortion;
 
-/** Catalogues */
-typedef enum {
-    PS_PANSTARRS,			//!< Pan-STARRS object catalogue
-    PS_USNO,				//!< USNO-B1 catalogue
-    PS_2MASS,				//!< 2MASS catalogue
-    PS_TYCHO,				//!< Tycho catalogue
-    PS_UCAC2 = 4			//!< UCAC2 catalogue
-} psCatalogue;
+typedef struct {
+    psDPolynomial2D *x;
+    psDPolynomial2D *y;
+} psCoordXform;
 
-/***********************************************************************************************************/
+psCoord *psCoordXformApply (psCoordXform *frame, psCoord *coords);
 
-/** A position on an OTA */
-typedef struct {
-    int chip;				//!< Chip number
-    float x;				//!< x position
-    float xErr;				//!< Error in x position
-    float y;				//!< y position
-    float yErr;				//!< Error in y position
-} psOTAPos;
-
-/** Constructor */
-psOTAPos *
-psOTAPosAlloc(void);
-
-/** Destructor */
-void
-psOTAPosFree(psOTAPos *restrict myOTAPos	//!< Object to destroy
-    );
-
-/***********************************************************************************************************/
-
-/** A position on a cell */
-typedef psOTAPos psCellPos;		//!< Same thing as for an OTA.
-#define psCellPosAlloc() psOTAPosAlloc() //!< Constructor
-#define psCellPosFree(C) psOTAPosFree(C) //!< Destructor
-
-/***********************************************************************************************************/
-
-/** An array of detector positions */
-typedef struct {
-    psType type;			//!< Type of data.  THIS STRUCT ELEMENT MUST BE FIRST IN THE STRUCT!
-    int size;				//!< Total number of elements available
-    int n;				//!< Number of elements in use
-    psOTAPos *arr;			//!< The array data
-} psOTAPosArray;
-
-/** Constructor */
-psOTAPosArray *psOTAPosArrayAlloc(int s, //!< Total number of elements to make available
-				  int n	//!< Number of elements that will be used
-    );
-/** Reallocator */
-psOTAPosArray *psOTAPosArrayRealloc(psOTAPosArray *myArray, //!< Array to reallocate
-				    int s	//!< Total number of elements to make available
-    );
-/** Destructor */
-void psOTAPosArrayFree(psOTAPosArray *restrict myArray //!< Array to free
-    );
-
-/***********************************************************************************************************/
-
-/*
- * \brief A simple RA/Dec position on the sky, default system is ICRS.  Double precision needed for
- * milli-arcsec.
- */
-typedef struct {
-    double ra;				//!< Right Ascension
-    double raErr;			//!< Error in RA
-    double dec;				//!< Declination
-    double decErr;			//!< Error in Dec
-} psSkyPos;
-
-/** Constructor */
-psSkyPos *
-psSkyPosAlloc(void);
-
-/** Destructor */
-void
-psSkyPosFree(psSkyPos *restrict mySkyPos	//!< Object to destroy
-    );
-
-/***********************************************************************************************************/
-
-/** An array of sky positions */
-typedef struct {
-    psType type;			//!< Type of data.  THIS STRUCT ELEMENT MUST BE FIRST IN THE STRUCT!
-    int size;				//!< Total number of elements available
-    int n;				//!< Number of elements in use
-    psSkyPos *arr;			//!< The array data
-} psSkyPosArray;
-
-/** Constructor */
-psSkyPosArray *psSkyPosArrayAlloc(int s, //!< Total number of elements to make available
-				  int n	//!< Number of elements that will be used
-    );
-/** Reallocator */
-psSkyPosArray *psSkyPosArrayRealloc(psSkyPosArray *myArray, //!< Array to reallocate
-				    int s	//!< Total number of elements to make available
-    );
-/** Destructor */
-void psSkyPosArrayFree(psSkyPosArray *restrict myArray //!< Array to free
-    );
-
-/***********************************************************************************************************/
-
-/** Latitude and Longitude.  Double precision needed for milli-arcsec */
-typedef struct {
-    double lat;				//!< Latitude
-    double latErr;			//!< Error in Latitude
-    double lng;			        //!< Longitude (can't use "long")
-    double lngErr;			//!< Error in Longitude
-} psLatLong;
-
-/** Constructor */
-psLatLong *
-psLatLongAlloc(void);
-
-/** Destructor */
-void
-psLatLongFree(psLatLong *restrict myLatLong //!< Object to destroy
-    );
+psCoord *psDistortionApply (psCoordXform *frame, psCoord *coords);
 
 /***********************************************************************************************************/
@@ -147,14 +46,16 @@
 
 /** Get offset (RA,Dec) on the sky between two positions position1 and position2 may not be identical */
-psSkyPos *
-psGetOffset(const psSkyPos *restrict position1, //!< Position 1
-	    const psSkyPos *restrict position2 //!< Position 2
+psCoords *
+psGetOffset(const psCoords *restrict position1, //!< Position 1
+	    const psCoords *restrict position2, //!< Position 2
+	    char *system
 	    );
 
 /** Apply an offset to a position */
-psSkyPos *
-psApplyOffset(const psSkyPos *restrict position, //!< Position
-	      const psSkyPos *restrict offset //!< Offset
-	      );
+psCoords *
+psApplyOffset(const psCoords *restrict position, //!< Position
+	      const psCoords *restrict offset, //!< Offset
+	      char *system
+    );
 
 /***********************************************************************************************************/
@@ -163,10 +64,10 @@
 
 /** Get Sun Position */
-psSkyPos *
+psCoords *
 psGetSunPos(float mjd			//!< MJD to get position for
 	    );
 
 /** Get Moon position */
-psSkyPos *
+psCoords *
 psGetMoonPos(float mjd,			//!< MJD to get position for
 	     double latitude,		//!< Latitude for apparent position
@@ -180,16 +81,7 @@
 
 /** Get Planet positions */
-psSkyPos *
-psGetPlanetPos(psPlanetNum myPlanetNum, //!< Number for planet
-	       float mjd		//!< MJD to get position for
-	       );
-
-/** Get star list from catalogue */
-struct psObjectArray *
-psReadStarCatalogue(double ra,		//!< RA of centre of search
-		    double dec,		//!< Declination of centre of search
-		    float radius,	//!< Radius of search for stars in catalogue
-		    float mjd,		//!< The epoch (in MJD) for which to get positions
-		    psCatalogue myCatalogue //!< The catalogue to use
+psCoords *
+psGetSolarSystemPos(char *solarSystemObject, //!< Named S.S. object
+		    float mjd		//!< MJD to get position for
     );
 
@@ -199,21 +91,21 @@
 
 /** Convert ICRS to Ecliptic */
-psLatLong *
-psCoordinatesItoE(const psSkyPos *restrict coordinates //!< ICRS coordinates to convert
+psCoord *
+psCoordinatesItoE(const psCoord *restrict coordinates //!< ICRS coordinates to convert
 		  );
 
 /** Convert Ecliptic to ICRS */
-psSkyPos *
-psCoordinatesEtoI(const psLatLong *restrict coordinates //!< Ecliptic coordinates to convert
+psCoord *
+psCoordinatesEtoI(const psCoord *restrict coordinates //!< Ecliptic coordinates to convert
 		  );
 
 /** Convert ICRS to Galactic */
-psLatLong *
-psCoordinatesItoG(const psSkyPos *restrict coordinates //!< ICRS coordinates to convert
+psCoord *
+psCoordinatesItoG(const psCoord *restrict coordinates //!< ICRS coordinates to convert
 		  );
 
 /** Convert Galactic to ICRS */
-psSkyPos *
-psCoordinatesGtoI(const psLatLong *restrict coordinates //!< Galactic coordinates to convert
+psCoord *
+psCoordinatesGtoI(const psCoord *restrict coordinates //!< Galactic coordinates to convert
 		  );
 
