Index: trunk/psModules/src/objects/pmSourceIO_Ghosts.c
===================================================================
--- trunk/psModules/src/objects/pmSourceIO_Ghosts.c	(revision 41348)
+++ trunk/psModules/src/objects/pmSourceIO_Ghosts.c	(revision 41367)
@@ -135,5 +135,13 @@
     pmFPAview *view = pmFPAviewAlloc (0);
 
-    GET_1D_POLY ("GHOST.MIRROR.RAD", mirrorRad);
+    //We need to check whether we are dealing with an old style ghost_model, or a new style model. Check if the mirror_rad polynomial exists
+    float mirCheck = 0;
+    md = psMetadataLookupMetadata (&status, ghostModel, "GHOST.MIRROR.RAD"); 
+    if (!md) { psLogMsg ("psastro", PS_LOG_INFO, "No ghost mirror_rad polynomial found. Assuming old-style ghost masking"); } 
+    if (md) {
+        GET_1D_POLY ("GHOST.MIRROR.RAD", mirrorRad);
+        mirCheck = 1;
+    }  
+
     GET_2D_POLY ("GHOST.CENTER.X", centerX);
     GET_2D_POLY ("GHOST.CENTER.Y", centerY);
@@ -143,4 +151,5 @@
     GET_1D_POLY ("GHOST.INNER.MAJOR", innerMajor);
     GET_1D_POLY ("GHOST.INNER.MINOR", innerMinor);
+
 
     // select the input astrometry data (also carries the refstars)
@@ -153,5 +162,5 @@
 
     // really error-out here?  or just skip?
-    if (!psastroZeroPointFromRecipe (&zeropt, &exptime, &MAX_MAG, fpa_ast, recipe)) {
+    if (!psastroZeroPointFromRecipeGlint (&zeropt, &exptime, &MAX_MAG,NULL, fpa_ast, recipe)) {
         psLogMsg ("psastro", PS_LOG_INFO, "failed to load zeropt data from recipe");
 	goto escape;
@@ -201,11 +210,19 @@
      	                double theta0 = atan2(ref->FP->y,ref->FP->x);
 
-		        double ghost_offset_rad = psPolynomial1DEval (mirrorRad, rSrc);
-		        double ghost_x_fpa_mirror = ref->FP->x + ((ref->FP->x*-1.)/abs(ref->FP->x)*abs(cos(theta0)*ghost_offset_rad));
-		        double ghost_y_fpa_mirror = ref->FP->y + ((ref->FP->y*-1.)/abs(ref->FP->y)*abs(sin(theta0)*ghost_offset_rad));
-
-		        // Now use the mirrored position together with the 2D ghost center fitting to get the actual ghost position in FPA coords 
-		        ghost->FP->x = ghost_x_fpa_mirror + psPolynomial2DEval(centerX, ghost_x_fpa_mirror, ghost_y_fpa_mirror);
-		        ghost->FP->y = ghost_y_fpa_mirror + psPolynomial2DEval(centerY, ghost_x_fpa_mirror, ghost_y_fpa_mirror);
+                        if(mirCheck) {
+                            //TdB: first mirror the reference star positions (around the 0,0 pixel) using the radial offset coefficients and the ghost/star angle
+		            double ghost_offset_rad = psPolynomial1DEval (mirrorRad, rSrc);
+		            double ghost_x_fpa_mirror = ref->FP->x + ((ref->FP->x*-1.)/abs(ref->FP->x)*abs(cos(theta0)*ghost_offset_rad));
+		            double ghost_y_fpa_mirror = ref->FP->y + ((ref->FP->y*-1.)/abs(ref->FP->y)*abs(sin(theta0)*ghost_offset_rad));
+
+		            // Now use the mirrored position together with the 2D ghost center fitting to get the actual ghost position in FPA coords 
+		            ghost->FP->x = ghost_x_fpa_mirror + psPolynomial2DEval(centerX, ghost_x_fpa_mirror, ghost_y_fpa_mirror);
+		            ghost->FP->y = ghost_y_fpa_mirror + psPolynomial2DEval(centerY, ghost_x_fpa_mirror, ghost_y_fpa_mirror);
+                        }  
+                        if(!mirCheck) {
+                            //Use the old-style ghost position determination
+                            ghost->FP->x = -ref->FP->x + psPolynomial2DEval(centerX, -ref->FP->x, -ref->FP->y);
+                            ghost->FP->y = -ref->FP->y + psPolynomial2DEval(centerY, -ref->FP->x, -ref->FP->y);
+                        }
 
  			ghost->inner.major = psPolynomial1DEval (innerMajor, rSrc);
@@ -503,2 +520,4 @@
   return true;
 }
+
+
