Index: /trunk/Ohana/src/addstar/src/GetFileMode.c
===================================================================
--- /trunk/Ohana/src/addstar/src/GetFileMode.c	(revision 35107)
+++ /trunk/Ohana/src/addstar/src/GetFileMode.c	(revision 35108)
@@ -22,5 +22,17 @@
   if (havePHOT_VER && haveTARG_VER) return SDSS_OBJ;
 
-  if (haveNaxis && ((Naxis == 2) || TEXTMODE || !simple)) {
+  if (haveNaxis && (Naxis == 2)) {
+    int Nx, Ny;
+    gfits_scan (header, "NAXIS1",  "%d", 1, &Nx);
+    gfits_scan (header, "NAXIS2",  "%d", 1, &Ny);
+    if ((Nx > 0) && (Ny > 0)) {
+      if (haveCTYPE && !strcmp (&ctype[4], "-WRP")) {
+	return MOSAIC_CMP;
+      }
+      return SIMPLE_CMP;
+    }
+  }
+
+  if (haveNaxis && (TEXTMODE || !simple)) {
     if (haveCTYPE && !strcmp (&ctype[4], "-WRP")) {
       return MOSAIC_CMP;
Index: /trunk/Ohana/src/addstar/src/mkcmf.c
===================================================================
--- /trunk/Ohana/src/addstar/src/mkcmf.c	(revision 35107)
+++ /trunk/Ohana/src/addstar/src/mkcmf.c	(revision 35108)
@@ -40,4 +40,10 @@
   Coords coords;
 
+  int APPEND = FALSE;
+  if ((N = get_argument (argc, argv, "-append"))) {
+    remove_argument (N, &argc, argv);
+    APPEND = TRUE;
+  }
+
   static char *photcode = "SIMTEST.r.Chip";
   if ((N = get_argument (argc, argv, "-photcode"))) {
@@ -69,4 +75,14 @@
   }
 
+  char extname[80], exthead[80];
+  strcpy (extname, "Chip.psf");
+  strcpy (exthead, "Chip.hdr");
+  if ((N = get_argument (argc, argv, "-extname"))) {
+    remove_argument (N, &argc, argv);
+    snprintf (extname, 80, "%s.psf", argv[N]);
+    snprintf (exthead, 80, "%s.hdr", argv[N]);
+    remove_argument (N, &argc, argv);
+  }
+
   double RA = 10.0;
   double DEC = 20.0;
@@ -101,4 +117,17 @@
     remove_argument (N, &argc, argv);
     airmass = atof (argv[N]);
+    remove_argument (N, &argc, argv);
+  }  
+
+  int imageID = -1;
+  if ((N = get_argument (argc, argv, "-imageID"))) {
+    remove_argument (N, &argc, argv);
+    imageID = atof (argv[N]);
+    remove_argument (N, &argc, argv);
+  }  
+  int sourceID = -1;
+  if ((N = get_argument (argc, argv, "-sourceID"))) {
+    remove_argument (N, &argc, argv);
+    sourceID = atof (argv[N]);
     remove_argument (N, &argc, argv);
   }  
@@ -254,14 +283,13 @@
   gfits_modify (&header, "EXPTIME", "%lf", 1, exptime);
   gfits_modify (&header, "AIRMASS", "%lf", 1, airmass);
-  gfits_modify (&header, "NASTRO",   "%d", 1, 10); 
-
-  int imageID = 1000.0*drand48();
-  int sourceID = 100.0*drand48();
-
+  gfits_modify (&header, "NASTRO",   "%d", 1, 100); 
+
+  if (imageID == -1) imageID = 1000.0*drand48();
+  if (sourceID == -1) sourceID = 100.0*drand48();
   gfits_modify (&header, "IMAGEID",  "%d", 1, imageID);
   gfits_modify (&header, "SOURCEID", "%d", 1, sourceID);
 
   PutCoords (&coords, &header);
-  gfits_modify (&header, "EXTNAME",   "%s", 1, "Chip.hdr");
+  gfits_modify (&header, "EXTNAME",   "%s", 1, exthead);
 
   ftable.header = &theader;
@@ -298,11 +326,26 @@
   }
 
-  gfits_modify (ftable.header, "EXTHEAD",   "%s", 1, "Chip.hdr");
-  gfits_modify (ftable.header, "EXTNAME",   "%s", 1, "Chip.psf");
-
-  fits = fopen (argv[2], "w");
+  gfits_modify (ftable.header, "EXTHEAD",   "%s", 1, exthead);
+  gfits_modify (ftable.header, "EXTNAME",   "%s", 1, extname);
+
+  // open for append (if you want a new file, need to blow the old object)
+  if (APPEND) {
+    fits = fopen (argv[2], "a+");
+  } else {
+    fits = fopen (argv[2], "w");
+  }
   if (fits == NULL) {
     fprintf (stderr, "ERROR: can't open output file %s\n", argv[2]);
     exit (1);
+  }
+
+  /* if we are appending, fix up header */
+  if (APPEND) {
+    static char simple[] = "XTENSION= 'IMAGE  '            / Image extension";
+    int Ns, No;
+    Ns = strlen (simple);
+    No = 80 - Ns;
+    strncpy (header.buffer, simple, Ns);
+    memset (&header.buffer[Ns], ' ', No);
   }
 
@@ -516,4 +559,6 @@
     stars[i].dSky      = DSKY;
     stars[i].psfChisq  = PSFCHI;
+    stars[i].psfNdof   = 1;
+    stars[i].psfNpix   = 2;
     stars[i].crNsigma  = CRN;
     stars[i].extNsigma = EXTN;
@@ -570,4 +615,6 @@
     stars[i].dSky      = DSKY;
     stars[i].psfChisq  = PSFCHI;
+    stars[i].psfNdof   = 1;
+    stars[i].psfNpix   = 2;
     stars[i].crNsigma  = CRN;
     stars[i].extNsigma = EXTN;
@@ -624,4 +671,6 @@
     stars[i].dSky      = DSKY;
     stars[i].psfChisq  = PSFCHI;
+    stars[i].psfNdof   = 1;
+    stars[i].psfNpix   = 2;
     stars[i].crNsigma  = CRN;
     stars[i].extNsigma = EXTN;
@@ -690,4 +739,6 @@
     stars[i].dSky      = DSKY;
     stars[i].psfChisq  = PSFCHI;
+    stars[i].psfNdof   = 1;
+    stars[i].psfNpix   = 2;
     stars[i].crNsigma  = CRN;
     stars[i].extNsigma = EXTN;
