Index: /branches/eam_branches/ipp-20140904/Ohana/src/fakeastro/src/make_fake_images.c
===================================================================
--- /branches/eam_branches/ipp-20140904/Ohana/src/fakeastro/src/make_fake_images.c	(revision 37456)
+++ /branches/eam_branches/ipp-20140904/Ohana/src/fakeastro/src/make_fake_images.c	(revision 37457)
@@ -1,7 +1,64 @@
 # include "fakeastro.h"
 
-Images *make_boresites (Images *images, int Nimages; int *nbores) {
+Image *make_fake_images (Image *image, int *nfakeImage) {
 
+  // given an image (really, the WCS) which defines an exposure, generate the image
+  // parameters for a full set of chips in an exposure
   
+  int NfakeImage = 65;
+  Image *fakeImage = NULL;
 
+  ALLOCATE (fakeImage, Image, NfakeImage);
+
+  // first image is the PHU, copy basic data:
+
+  fakeImage[0] = image[0];
+
+  int N = 1;
+
+  int ix, iy;
+  for (ix = 0; ix < 8; ix++) {
+    for (iy = 0; iy < 8; iy++) {
+      
+      fakeImage[N] = fakeImage[0];
+
+      // coords map relative to image center:
+      fakeImage[N].coords.crval1 = 0.0;
+      fakeImage[N].coords.crval2 = 0.0;
+
+      if (ix < 4) {
+	fakeImage[N].coords.crpix1 = (ix - 3)*4900;
+	fakeImage[N].coords.crpix2 = (iy - 3)*4900;
+	fakeImage[N].coords.pc1_1 = 1.0
+	fakeImage[N].coords.pc2_2 = 1.0
+      } else {
+	fakeImage[N].coords.crpix1 = (3 - ix)*4900;
+	fakeImage[N].coords.crpix2 = (4 - iy)*4900;
+	fakeImage[N].coords.pc1_1 = -1.0
+	fakeImage[N].coords.pc2_2 = -1.0
+      } 
+
+      fakeImage[N].coords.cdelt1 = 1.0;
+      fakeImage[N].coords.cdelt2 = 1.0;
+
+      fakeImage[N].coords.pc1_2 = 0.0;
+      fakeImage[N].coords.pc1_2 = 0.0;
+
+      strcpy (fakeImage[N].coords.ctype, "DEC--WRP");
+      fakeImage[N].coords.Npolyterms = 1;
+
+      fakeImage[N].coords.mosaic = &fakeImage[0].coords;
+
+      fakeImage[N].NX = 4850;
+      fakeImage[N].NY = 4850;
+
+      fakeImage[N].photcode = 10000 + iy*10 + ix;
+      fakeImage[N].exptime = 45.0;
+      N++;
+    }
+  }
+
+  *nfakeImage = NfakeImage;
+  return fakeImage;
 }
+
Index: /branches/eam_branches/ipp-20140904/Ohana/src/fakeastro/src/make_fake_stars.c
===================================================================
--- /branches/eam_branches/ipp-20140904/Ohana/src/fakeastro/src/make_fake_stars.c	(revision 37457)
+++ /branches/eam_branches/ipp-20140904/Ohana/src/fakeastro/src/make_fake_stars.c	(revision 37457)
@@ -0,0 +1,59 @@
+# include "fakeastro.h"
+
+Stars *make_fake_stars (Image *image, int *nfakeStars) {
+
+  // find the R,D coords of the 4 corners and 4 edge midpoints
+
+  static double Xpt[] = {0, 2425, 4850,    0, 4850,    0, 2425, 4850};
+  static double Ypt[] = {0,    0,    0, 2425, 2425, 4850, 4850, 4850};
+
+  double Rmin = +480.0;
+  double Rmax = -360.0;
+  double Dmin =  +90.0;
+  double Dmax =  -90.0;
+
+  for (i = 0; i < 8; i++) {
+    double R, D;
+    XY_to_RD (&R, &D, Xpt[i], Ypt[i], image->coords);
+
+    Rmin = MIN(R,Rmin);
+    Rmax = MAX(R,Rmax);
+    Dmin = MIN(D,Dmin);
+    Dmax = MAX(D,Dmax);
+
+  }
+
+  SkyRegion *regions = SkyListByBounds (skyTable, -1, Rmin, Rmax, Dmin, Dmax);
+
+  // load stars from database in these regions
+  for (i = 0; i < regions->Nregions; i++) {
+
+    // set the parameters which guide catalog open/load/create
+    catalog.filename  = skylist[0].filename[i];
+    catalog.catformat = dvo_catalog_catformat (CATFORMAT);  // set the default catformat from config data
+    catalog.catmode   = dvo_catalog_catmode (CATMODE);      // set the default catmode from config data
+    catalog.catflags  = LOAD_AVES | LOAD_MEAS | LOAD_MISS | LOAD_SECF | LOAD_LENSING;
+    catalog.Nsecfilt  = GetPhotcodeNsecfilt ();
+    if (options.update) catalog.catflags = LOAD_AVES | LOAD_MISS | LOAD_SECF;
+
+      if (!dvo_catalog_open (&catalog, skylist[0].regions[i], VERBOSE, "r")) {
+	continue;
+      }
+    } else {
+      // an error exit status here is a significant error (disk I/O or file access)
+      // XXX should this be "a" for options.update?
+      if (!dvo_catalog_open (&catalog, skylist[0].regions[i], VERBOSE, "w")) {
+	fprintf (stderr, "ERROR: failure to open/create catalog file %s\n", catalog.filename);
+	exit (2);
+      }
+
+    // load refstars in region
+    load_something ();
+
+    // generate fake measurements for this image
+    stars = make_fake_stars_region (inCatalog);
+
+    save_fake_stars (stars);
+  }
+}
+
