Index: /trunk/pstamp/src/ppstampArguments.c
===================================================================
--- /trunk/pstamp/src/ppstampArguments.c	(revision 17269)
+++ /trunk/pstamp/src/ppstampArguments.c	(revision 17270)
@@ -21,5 +21,6 @@
     fprintf(stderr, "\n");
     fprintf(stderr, "Optional arguments:\n");
-    fprintf(stderr, "         -chip chipName    selects chip (only used with -pixcenter)\n");
+    fprintf(stderr, "   [-chip chipName]     selects chip (only used with -pixcenter)\n");
+    fprintf(stderr, "   [-astrom astrom.cmp] : provide an alternative astrometry calibration\n");
     fprintf(stderr, "\n");
 
@@ -60,5 +61,4 @@
     }
 
-
     if (!gotCenter) {
         psError(PSTAMP_ERR_ARGUMENTS, true, "must specify center of region of interest\n");
@@ -77,4 +77,6 @@
     }
 
+    pmConfigFileSetsMD(config->arguments, &argc, argv, "ASTROM",   "-astrom", "-astromlist");
+
     // the input file is a required argument; if not found, we will exit
     bool status = pmConfigFileSetsMD (config->arguments, &argc, argv, "INPUT", "-file", "-list");
@@ -83,4 +85,5 @@
         usage();
     }
+    
 
     // finally the output file
Index: /trunk/pstamp/src/ppstampMakeStamp.c
===================================================================
--- /trunk/pstamp/src/ppstampMakeStamp.c	(revision 17269)
+++ /trunk/pstamp/src/ppstampMakeStamp.c	(revision 17270)
@@ -381,6 +381,7 @@
 // is completely contained on a single chip
 
-static ppstampOverlap findROI(ppstampOptions *options, pmFPAview *view, pmFPAfile *input, pmChip *chip,
-                       pmAstromObj *center)
+static ppstampOverlap findROI(ppstampOptions *options, pmFPAview *view,
+                    pmFPAfile *input, pmFPAfile *astrom, bool bilevelAstrometry,
+                    pmChip *chip, pmAstromObj *center)
 {
     psString chipName = psMetadataLookupStr(NULL, chip->concepts, "CHIP.NAME");
@@ -392,22 +393,23 @@
 
     // set up the astrometry
-    pmHDU *hdu = pmHDUFromChip(chip);
+    pmHDU *hdu = pmFPAviewThisHDU(view, astrom->fpa);
     PS_ASSERT_PTR_NON_NULL(hdu, 1)
     PS_ASSERT_PTR_NON_NULL(hdu->header, 1)
 
-    // for some reason these are getting initialized to garbag
-    input->fpa->fromTPA = 0;
-    input->fpa->toTPA = 0;
-    input->fpa->toSky = 0;
-    chip->toFPA = 0;
-    chip->fromFPA = 0;
-
-    if (!pmAstromReadWCS(input->fpa, chip, hdu->header, 1.0)) {
-        // we can live without WCS if the ROI is specified in pixels
-
-        if (options->roip.celestialCenter || options->roip.celestialRange) {
-            psError(PSTAMP_ERR_DATA, false, "Failed to Read WCS, cannot proceed\n");
-            psFree(chipBounds);
-            return PSTAMP_ERROR;
+    // we can live without astrometry if the ROI is completely specified in pixel coordinates
+    bool mustHaveAstrometry = false;
+    if (options->roip.celestialCenter || options->roip.celestialRange) {
+        mustHaveAstrometry = true;
+    }
+    if (bilevelAstrometry) {
+        if (!pmAstromReadBilevelChip (chip, hdu->header) && mustHaveAstrometry) {
+            psError(PS_ERR_UNKNOWN, false, "Unable to read bilevel chip astrometry for input FPA.");
+            return false;
+        }
+    } else {
+        // we use a default FPA pixel scale of 1.0
+        if (!pmAstromReadWCS (input->fpa, chip, hdu->header, 1.0) && mustHaveAstrometry) {
+            psError(PS_ERR_UNKNOWN, false, "Unable to read WCS astrometry for input FPA.");
+            return false;
         }
     }
@@ -478,10 +480,20 @@
     bool        returnval = false;;
     bool        foundOverlap = false;
-    pmAstromObj *center = pmAstromObjAlloc();
 
     pmFPAfile *input = psMetadataLookupPtr(&status, config->files, "PPSTAMP.INPUT");
     if (!status) {
-        psError(PS_ERR_UNKNOWN, true, "Can't find input data!\n");
-        psFree(center);
+        psError(PS_ERR_UNKNOWN, true, "Can't find input file!\n");
+        return false;
+    }
+
+    pmFPAfile *astrom = psMetadataLookupPtr(&status, config->files, "PSWARP.ASTROM");
+    if (!status) {
+        psError(PS_ERR_UNKNOWN, true, "Can't find input astrometry!\n");
+        return false;
+    }
+    if (!astrom) {
+        astrom = input;
+    } else if (astrom->camera != input->camera) {
+        psError(PS_ERR_UNKNOWN, true, "Input camera and astrometry camera do not match");
         return false;
     }
@@ -492,10 +504,25 @@
     if (!pmFPAfileIOChecks(config, view, PM_FPA_BEFORE)) {
         psError(PS_ERR_UNKNOWN, false, "Failed to load input.");
-        psFree(center);
         psFree (view);
         return false;
     }
+    bool bilevelAstrometry  = false;
+    pmHDU *phu = pmFPAviewThisPHU(view, astrom->fpa);
+    if (phu) {
+        char *ctype = psMetadataLookupStr(NULL, phu->header, "CTYPE1");
+        if (ctype) {
+            bilevelAstrometry = !strcmp (&ctype[4], "-DIS");
+        }
+    }
+    if (bilevelAstrometry) {
+        if (!pmAstromReadBilevelMosaic(input->fpa, phu->header)) {
+            psError(PS_ERR_UNKNOWN, false, "Unable to read bilevel mosaic astrometry for input FPA.");
+            psFree(view);
+            return false;
+        }
+    }
 
     // Loop over the chips and find the one that contains the center
+    pmAstromObj *center = pmAstromObjAlloc();
     pmChip *chip;
     while ((chip = pmFPAviewNextChip(view, input->fpa, 1)) != NULL) {
@@ -512,5 +539,5 @@
         }
 
-        ppstampOverlap overlap = findROI(options, view, input, chip, center);
+        ppstampOverlap overlap = findROI(options, view, input, astrom, bilevelAstrometry, chip, center);
 
         switch (overlap) {
Index: /trunk/pstamp/src/ppstampParseCamera.c
===================================================================
--- /trunk/pstamp/src/ppstampParseCamera.c	(revision 17269)
+++ /trunk/pstamp/src/ppstampParseCamera.c	(revision 17270)
@@ -34,4 +34,16 @@
     }
 
+    // XXX: create a filerule for PPSTAMP.ASTROM
+    pmFPAfile *astrom = pmFPAfileDefineFromArgs(&status, config, "PSWARP.ASTROM", "ASTROM");
+    if (!status) {
+        psError(PS_ERR_UNKNOWN, false, "failed to find astrom definitiion");
+        return NULL;
+    }
+    if (astrom) {
+        psLogMsg ("ppstamp", 3, "using supplied astrometry\n");
+    } else {
+        psLogMsg ("ppstamp", 3, "using header astrometry\n");
+    }
+
 #ifdef notyet
     // add recipe options supplied on command line
@@ -55,5 +67,5 @@
     }
 
-    // TODO: only do the workaround if the file level is chip, skycells should be fine
+    // XXX: TODO: only do the workaround if the file level is chip, skycells should be fine
     if (!strcmp(config->cameraName, "MEGACAM")) {
         // workaround bug 986 and related
