Index: unk/Ohana/src/getstar/include/addstar.h
===================================================================
--- /trunk/Ohana/src/getstar/include/addstar.h	(revision 3304)
+++ 	(revision )
@@ -1,47 +1,0 @@
-# include <ohana.h>
-# include <loneos.h>
-# include <signal.h>
-
-typedef struct {
-  double X;
-  double Y;
-  double R;
-  double D;
-  double M, dM;
-  char   dophot;
-  double sky;
-  double fx, fy, df;
-  double Mgal, Map;
-  int found;
-} Stars;
-
-/* global variables set in parameter file */
-char   ImageCat[256];
-char   ImageTemplate[256];
-char   CatTemplate[256];
-char   GSCFILE[256];
-char   CATDIR[256];
-double DEFAULT_RADIUS, NSIGMA, SNLIMIT;
-double ZeroPt;
-int    VERBOSE;
-int    SKIP_MISSED;
-int    XOVERSCAN, YOVERSCAN;
-int    XMIN, XMAX, YMIN, YMAX;
-int    ACCEPT_ASTROM;
-
-PhotCode *thiscode;
-
-char DateKeyword[64];
-char DateMode[64];
-char UTKeyword[64];
-char MJDKeyword[64];
-char JDKeyword[64];
-char ExptimeKeyword[64];
-char AirmassKeyword[64];
-char CCDNumKeyword[64];
-
-int CalReference;
-int CalColor;
-int CALIBRATE;
-int DUMP_MATCHES;
-int ONLY_IMAGES;
Index: unk/Ohana/src/getstar/src/addstar.c
===================================================================
--- /trunk/Ohana/src/getstar/src/addstar.c	(revision 3304)
+++ 	(revision )
@@ -1,223 +1,0 @@
-# include "addstar.h"
-
-/* these variables are needed by Shutdown */
-static FILE *f = (FILE *) NULL;
-static int Protect = FALSE;
-static int Trapped = FALSE;
-
-/* clean up open / locked ImageCat before shutting down */
-int Shutdown () {  
-  int dbstate;
-
-  Protect = TRUE;
-  fclearlockfile (ImageCat, f, LCK_HARD, &dbstate);
-  fprintf (stderr, "ERROR: addstar halted\n");
-  exit (1);
-}
-
-void TrapSignal (int sig) {
-    fprintf (stderr, "trapped signal %d, exiting gracefully\n", sig);
-    if (sig == 11) {
-      fprintf (stderr, "seg fault\n");
-      exit (1);
-    }
-    if (Protect) {
-      Trapped = TRUE;
-      fprintf (stderr, "blocking until protected sections are clear\n");
-      return;
-    }
-    Shutdown ();
-}    
-
-main (int argc, char **argv) {
-
-  int i, N, mode, dbstate;
-  int Nstars, Nimage, Nregions, Nmissed;
-  Stars *stars, *gstars();
-  Image image, *pimage, *gimages();
-  GSCRegion *region, *gregions();
-  Catalog catalog;
-  struct timeval now, then;  
-  
-  SetSignals ();
-  args (argc, argv);
-
-  /* load the input datafile */
-  stars = gstars (argv[1], &Nstars, &image);
-  if (Nstars == 0) {
-    if (VERBOSE) fprintf (stderr, "no stars in data file, skipping\n");
-    fprintf (stderr, "SUCCESS\n");
-    exit (0);
-  }
-
-  /* lock the image catalog */
-  check_permissions (ImageCat);
-  f = fsetlockfile (ImageCat, 3600.0, LCK_HARD, &dbstate);
-  if ((f == (FILE *) NULL) && (dbstate != LCK_EMPTY)) {
-    fprintf (stderr, "ERROR: can't lock image catalog\n");
-    exit (1);
-  }
-  fseek (f, 0, SEEK_SET);
-
-  /* load images */
-  if (dbstate == LCK_EMPTY) {
-    Nimage = 0;
-  } else {
-    pimage = gimages (f, &image, &Nimage);
-  }
-  region = gregions (&image, &Nregions);
-  fprintf (stderr, "region %f %f %f %f\n", region[0].RA[0], region[0].RA[1], region[0].DEC[0], region[0].DEC[1]);
-
-  for (i = 0; i < Nregions; i++) {
-    check_permissions (region[i].filename);
-  }
-
-  if (CALIBRATE) { InitCalibration (); }
-
-  for (i = 0; i < Nregions; i++) {
-    catalog.filename = region[i].filename;  /* don't free region before catalog! */
-    fprintf (stderr, "adding to %s\n", region[i].filename);
-    
-    switch (lock_catalog (&catalog, LCK_XCLD)) {
-    case 0:
-      /* this is a serious error because ImageCat was NOT locked */
-      fprintf (stderr, "ERROR: can't lock file %s\n", catalog.filename);
-      exit (1);
-    case 1:
-      gcatalog (&catalog); /* load from disk */
-      break;
-    case 2:
-      mkcatalog (&region[i], &catalog); /* fills in new header info */
-      break;
-    }
-    find_matches (&region[i], stars, Nstars, &catalog, &image, pimage, Nimage);
-
-    /* protect wcatalog from interrupt signals */
-    Protect = TRUE;
-    if (!DUMP_MATCHES && !ONLY_IMAGES) wcatalog (&catalog);
-    if (Trapped) Shutdown ();
-    Protect = FALSE;
-    unlock_catalog (&catalog);
-  }
-
-  if (CALIBRATE) { FindCalibration (&image); }
-  if (DUMP_MATCHES) Shutdown ();
-
-  for (Nmissed = i = 0; i < Nstars; i++) {
-    if (stars[i].found == -1) {
-      fprintf (stderr, "%d %f %f %f %f\n", i, stars[i].R, stars[i].D, stars[i].M, stars[i].dM);
-      Nmissed ++;
-    }
-  }
-  if (Nmissed) fprintf (stderr, "WARNING: %d stars in image were missed!\n", Nmissed);
-
-  /* protect wimage from interrupt signals */
-  Protect = TRUE;
-  wimage (f, dbstate, &image, Nstars); 
-  if (Trapped) Shutdown ();
-  Protect = FALSE;
-
-  fclearlockfile (ImageCat, f, LCK_HARD, &dbstate);
-
-  mode = S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH;
-  chmod (ImageCat, mode);
-
-  fprintf (stderr, "SUCCESS\n");
-  exit (0);
-
-}
-
-int SetSignals () {
-
-  int i;
-
-  /* disable almost all signal interrupts */
-  for (i = 0; i < 36; i++) {
-    switch (i) {
-      /* can't redirect this signals */
-    case SIGKILL:    /* kill -9: cannot be caught or ignored */
-    case SIGSTOP:    /* SIGSTOP: cannot be caught or ignored */
-      /* ignore these signals */
-    case SIGCHLD:    /* child halted: ignore */
-    case SIGPWR:     /* power failure - why ignore this? */
-    case SIGWINCH:   /* window resized */
-    case SIGCONT:    /* continue - maintain this action */
-    case SIGTSTP:    /* stop signal sent from tty - why ignore? */
-    case SIGURG:     /* socket signal, ignore this */
-      break;
-      
-    default:
-      signal (i, TrapSignal);
-    }
-  }
-
-}
-/*
-
-       Signal     Value     Action   Comment
-       -------------------------------------------------------------------------
-       SIGHUP        1        A      Hangup detected on controlling terminal
-                                     or death of controlling process
-       SIGINT        2        A      Interrupt from keyboard
-       SIGQUIT       3        A      Quit from keyboard
-       SIGILL        4        A      Illegal Instruction
-       SIGABRT       6        C      Abort signal from abort(3)
-       SIGFPE        8        C      Floating point exception
-       SIGKILL       9       AEF     Kill signal
-       SIGSEGV      11        C      Invalid memory reference
-       SIGPIPE      13        A      Broken pipe: write to pipe with no readers
-       SIGALRM      14        A      Timer signal from alarm(2)
-       SIGTERM      15        A      Termination signal
-       SIGUSR1   30,10,16     A      User-defined signal 1
-       SIGUSR2   31,12,17     A      User-defined signal 2
-       SIGCHLD   20,17,18     B      Child stopped or terminated
-       SIGCONT   19,18,25            Continue if stopped
-       SIGSTOP   17,19,23    DEF     Stop process
-       SIGTSTP   18,20,24     D      Stop typed at tty
-       SIGTTIN   21,21,26     D      tty input for background process
-       SIGTTOU   22,22,27     D      tty output for background process
-
-       Next various other signals.
-
-       Signal       Value     Action   Comment
-       ---------------------------------------------------------------------
-       SIGTRAP        5         CG     Trace/breakpoint trap
-       SIGIOT         6         CG     IOT trap. A synonym for SIGABRT
-       SIGEMT       7,-,7       G
-       SIGBUS      10,7,10      AG     Bus error
-       SIGSYS      12,-,12      G      Bad argument to routine (SVID)
-       SIGSTKFLT    -,16,-      AG     Stack fault on coprocessor
-       SIGURG      16,23,21     BG     Urgent condition on socket (4.2 BSD)
-       SIGIO       23,29,22     AG     I/O now possible (4.2 BSD)
-       SIGPOLL                  AG     A synonym for SIGIO (System V)
-       SIGCLD       -,-,18      G      A synonym for SIGCHLD
-       SIGXCPU     24,24,30     AG     CPU time limit exceeded (4.2 BSD)
-       SIGXFSZ     25,25,31     AG     File size limit exceeded (4.2 BSD)
-       SIGVTALRM   26,26,28     AG     Virtual alarm clock (4.2 BSD)
-       SIGPROF     27,27,29     AG     Profile alarm clock
-       SIGPWR      29,30,19     AG     Power failure (System V)
-       SIGINFO      29,-,-      G      A synonym for SIGPWR
-       SIGLOST      -,-,-       AG     File lock lost
-       SIGWINCH    28,28,20     BG     Window resize signal (4.3 BSD, Sun)
-       SIGUNUSED    -,31,-      AG     Unused signal
-       (Here - denotes that a signal is absent; there where three values are given, the first one is usually  valid  for  alpha  and
-       sparc,  the  middle  one  for i386 and ppc, the last one for mips. Signal 29 is SIGINFO / SIGPWR on an alpha but SIGLOST on a
-       sparc.)
-
-       The letters in the "Action" column have the following meanings:
-
-       A      Default action is to terminate the process.
-
-       B      Default action is to ignore the signal.
-
-       C      Default action is to dump core.
-
-       D      Default action is to stop the process.
-
-       E      Signal cannot be caught.
-
-       F      Signal cannot be ignored.
-
-       G      Not a POSIX.1 conformant signal.
-
-*/
Index: unk/Ohana/src/getstar/src/calibrate.c
===================================================================
--- /trunk/Ohana/src/getstar/src/calibrate.c	(revision 3304)
+++ 	(revision )
@@ -1,143 +1,0 @@
-# include "addstar.h"
-
-static int Ncal, NCAL;
-static float *Mobs, *dMobs, *Mref, *Cref, *Airm;
-static float *RA, *DEC, *X, *Y;
-int *Nstar;
-
-InitCalibration () {
-
-    fprintf (stderr, "calibrating the image...  %d\n", CalReference);
-    Ncal = 0;
-    NCAL = 1000;
-    ALLOCATE (Mobs,  float,  NCAL);
-    ALLOCATE (dMobs, float, NCAL);
-    ALLOCATE (Mref,  float,  NCAL);
-    ALLOCATE (Cref,  float,  NCAL);
-    ALLOCATE (Airm,  float,  NCAL);
-    ALLOCATE (Nstar, int, NCAL);
-    ALLOCATE (RA, float, NCAL);
-    ALLOCATE (DEC, float, NCAL);
-    ALLOCATE (X, float, NCAL);
-    ALLOCATE (Y, float, NCAL);
-}
-  
-SaveCalibration (float M, float dM, float Mr, float Mc, float A, int N, float ra, float dec, float x, float y) {
-
-  Mobs[Ncal] = M;
-  dMobs[Ncal] = dM;
-  Mref[Ncal] = Mr;
-  Cref[Ncal] = Mc;
-  Airm[Ncal] = A;
-  Nstar[Ncal] = N;
-
-  RA[Ncal] = ra;
-  DEC[Ncal] = dec;
-  X[Ncal] = x;
-  Y[Ncal] = y;
-  Ncal ++;
-
-  if (Ncal == NCAL) {
-    NCAL += 1000;
-    REALLOCATE (dMobs, float, NCAL);
-    REALLOCATE (Mobs,  float, NCAL);
-    REALLOCATE (Mref,  float, NCAL);
-    REALLOCATE (Cref,  float, NCAL);
-    REALLOCATE (Airm,  float, NCAL);
-    REALLOCATE (Nstar, int,   NCAL);
-    REALLOCATE (RA, float, NCAL);
-    REALLOCATE (DEC, float, NCAL);
-    REALLOCATE (X, float, NCAL);
-    REALLOCATE (Y, float, NCAL);
-  }
-}
-
-FindCalibration (Image *image) {
-
-  int i, MaxN, *Nlist, Nkeep;
-  float N, M1, M2, Klam, Clam, Xlam, Mabs, dM, dm, *Dmag;
-  float dAs, dMs, dYs;
-  
-  /* reject multiple matched-stars */
-  /* find maximum value of Nstar[] */
-  MaxN = -1;
-  for (i = 0; i < Ncal; i++) {
-    MaxN = MAX (Nstar[i], MaxN);
-  }
-  if (MaxN == -1) {
-    fprintf (stderr, "no clean stars\n");
-    image[0].Mcal = 10000;
-    image[0].dMcal = 10000;
-    return;
-  }
-  /* create a hash array from Nstar[] entries */
-  ALLOCATE (Nlist, int, MAX (1, MaxN + 1));
-  bzero (Nlist, MAX (0, MaxN*sizeof(int)));
-  for (i = 0; i < Ncal; i++) {
-    Nlist[Nstar[i]] ++;
-  }
-  
-  /* accumulate delta mags */
-  ALLOCATE (Dmag, float, Ncal);
-  Nkeep = 0;
-  Klam = thiscode[0].K;
-  Clam = thiscode[0].C;
-  Xlam = thiscode[0].X;
-  for (i = 0; i < Ncal; i++) {
-    /* if this entry has too many (or two few?) matches, skip it */
-    if (Nlist[Nstar[i]] != 1) continue;
-    Mabs = 0.001*(Mobs[i] + Klam*(Airm[i] - 1000) + Clam + Xlam*(Mref[i] - Cref[i])) - ZeroPt;
-
-    /* subpix correction : make parameters global! */
-    dAs = 0;
-    if (Y[i] < 400) dAs = 0.06 - 0.00015*Y[i];
-    dYs = Y[i] - (int) (Y[i]) + 0.55;
-    dMs = dAs * sin (6.28*dYs);
-    /* Mabs -= dMs; */
-
-    if (DUMP_MATCHES) 
-      fprintf (stdout, "%d  %6.3f %6.3f %6.3f  %10.6f %10.6f  %7.2f %7.2f\n", 
-	       i, Mabs, 0.001*Mref[i], 0.001*Cref[i], RA[i], DEC[i], X[i], Y[i]);
-
-    /* skip stars brighter than 8.0 */
-    /* if (Mabs < 8.0) continue; */
-    
-    Dmag[Nkeep] = (Mabs - 0.001*Mref[i]);
-    Nkeep ++;
-  }
-
-  if (Nkeep < 3) {
-    fprintf (stderr, "too few stars\n");
-    image[0].Mcal = 10000;
-    image[0].dMcal = 10000;
-    return;
-  }
-  fsort (Dmag, Nkeep);
-
-  /* accumulate delta mags (25% - 75% of list) */
-  M1 = 0.0;
-  M2 = 0.0;
-  N  = 0.0;
-  for (i = 0.25*Nkeep; i <= 0.75*Nkeep; i++) {
-
-    /* a straight mean works better, given the bad photometry of skyprobe */
-    M1 += Dmag[i];
-    M2 += SQ (Dmag[i]);
-    N  += 1.0; 
-
-  }
-
-  if (N > 1) {
-    M1 = M1 / N;
-    M2 = sqrt (fabs(M2/N - M1*M1));
-    fprintf (stderr, "N: %.0f, mean: %f, stdev: %f, precision: %f\n", N, M1, M2, M2 / sqrt (N));
-    image[0].Mcal = 1000 * M1;
-    image[0].dMcal = 1000 * M2 / sqrt (N);
-  } else {
-    fprintf (stderr, "too few stars\n");
-    image[0].Mcal = 10000;
-    image[0].dMcal = 10000;
-  }
-}
-
-
Index: unk/Ohana/src/getstar/src/check_permissions.c
===================================================================
--- /trunk/Ohana/src/getstar/src/check_permissions.c	(revision 3304)
+++ 	(revision )
@@ -1,91 +1,0 @@
-# include "addstar.h"
-
-check_permissions (char *basefile) {
-  
-  FILE *f;
-  char *c, dir[256], filename[256];
-  struct stat filestat;
-  uid_t fuid, uid;
-  gid_t fgid, gid;
-  int status, cmode;
-
-  uid = getuid();
-  gid = getgid();
-
-  /* check permission to write to directory */
-  sprintf (filename, "%s\0", basefile);
-  c = strrchr (filename, '/');
-  if (c == (char *) NULL) {
-    strcpy (dir, ".");
-  } else {
-    *c = 0;
-    strcpy (dir, filename);
-  }
-  status = stat (dir, &filestat);
-  if (status == -1) {
-    fprintf (stderr, "directory %s does not exist, creating...\n", dir);
-    cmode = S_IRWXU | S_IRWXG | S_IRWXO;
-    status = mkdir (dir, cmode);
-    if (status == -1) {
-      fprintf (stderr, "ERROR: can't create %s\n", dir);
-      exit (1);
-    }
-  } 
-  status = stat (dir, &filestat);
-  if (((uid == filestat.st_uid) && (filestat.st_mode & S_IRWXU)) ||
-      ((gid == filestat.st_gid) && (filestat.st_mode & S_IRWXG)) || 
-      (filestat.st_mode & S_IRWXO)) {
-  } else {
-    fprintf (stderr, "ERROR: can't write to %s\n", dir);
-    exit (1);
-  }
-  
-  /* check permission to write to file */
-  sprintf (filename, "%s\0", basefile);
-  status = stat (filename, &filestat);
-  if (status == 0) { /* file exists, are permissions OK? */
-    if (((uid == filestat.st_uid) && (filestat.st_mode & S_IRUSR) && (filestat.st_mode & S_IWUSR)) ||
-	((gid == filestat.st_gid) && (filestat.st_mode & S_IRGRP) && (filestat.st_mode & S_IWGRP)) || 
-	((filestat.st_mode & S_IROTH) && (filestat.st_mode & S_IWOTH))) {
-    } else {
-      fprintf (stderr, "ERROR: can't write to %s\n", filename);
-      exit (1);
-    }
-  }
-  
-  /* check permission to write to backup file */
-  sprintf (filename, "%s~\0", basefile);
-  status = stat (filename, &filestat);
-  if (status == 0) { /* file exists, are permissions OK? */
-    if (((uid == filestat.st_uid) && (filestat.st_mode & S_IRUSR) && (filestat.st_mode & S_IWUSR)) ||
-	((gid == filestat.st_gid) && (filestat.st_mode & S_IRGRP) && (filestat.st_mode & S_IWGRP)) || 
-	((filestat.st_mode & S_IROTH) && (filestat.st_mode & S_IWOTH))) {
-    } else {
-      fprintf (stderr, "ERROR: can't write to %s\n", filename);
-      exit (1);
-    }
-  }
-  
-}
-
-/* uses cp only */
-make_backup (char *filename) {
-
-  int status, cmode;
-  struct stat filestat;
-  char line [256];
-
-  status = stat (filename, &filestat);
-  if (status == 0) { /* file exists, make backup copy */
-    sprintf (line, "cp %s %s~\0", filename, filename);
-    status = system (line);
-    if (status) {
-      fprintf (stderr, "ERROR: unable to create %s~, exiting\n", filename);
-      exit (1);
-    }
-    cmode = S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH;
-    sprintf (line, "%s~\0", filename);
-    chmod (line, cmode);
-  }
-  
-}
Index: unk/Ohana/src/getstar/src/coordops.c
===================================================================
--- /trunk/Ohana/src/getstar/src/coordops.c	(revision 3304)
+++ 	(revision )
@@ -1,342 +1,0 @@
-# include "addstar.h"
-
-XY_to_RD (ra, dec, x, y, coords)
-double *ra, *dec;
-double  x, y;
-Coords coords[];
-{
-
-  double L, M, X, Y, T;
-  double R, sphi, cphi, stht, ctht;
-  double alpha, delta, salp, calp, sdel, sdp, cdp;
-  
-  *ra  = 0;
-  *dec = 0;
-
-# if 1
-  if (!strcmp(&coords[0].ctype[4], "-PLY")) {
-    X = coords[0].cdelt1*(x - coords[0].crpix1 + x*x*coords[0].polyterms[0][0] + x*y*coords[0].polyterms[1][0] + y*y*coords[0].polyterms[2][0]
-			  + x*x*x*coords[0].polyterms[3][0] + x*x*y*coords[0].polyterms[4][0] + x*y*y*coords[0].polyterms[5][0] + y*y*y*coords[0].polyterms[6][0]);
-    Y = coords[0].cdelt2*(y - coords[0].crpix2 + x*x*coords[0].polyterms[0][1] + x*y*coords[0].polyterms[1][1] + y*y*coords[0].polyterms[2][1]
-			  + x*x*x*coords[0].polyterms[3][1] + x*x*y*coords[0].polyterms[4][1] + x*y*y*coords[0].polyterms[5][1] + y*y*y*coords[0].polyterms[6][1]);
-  } else {
-# else
-  {
-# endif
-    X = coords[0].cdelt1*(x - coords[0].crpix1);
-    Y = coords[0].cdelt2*(y - coords[0].crpix2);
-  }    
-
-  L = (X*coords[0].pc1_1 + Y*coords[0].pc1_2);
-  M = (X*coords[0].pc2_1 + Y*coords[0].pc2_2);
-
-  if (!strcmp(&coords[0].ctype[4], "-PLY") || !strcmp(&coords[0].ctype[4], "-TAN") || !strcmp(&coords[0].ctype[4], "-SIN") || !strcmp(&coords[0].ctype[0], "MM")) {
-    R = hypot (L,M);
-    if ((L == 0) && (M == 0)) {
-      sphi = 0;
-      cphi = 1;
-    }
-    else {
-      sphi =  L / R;
-      cphi = -M / R;
-    }
-
-    if (!strcmp(&coords[0].ctype[4], "-PLY") || !strcmp(&coords[0].ctype[4], "-TAN")) {
-      if (R == 0) {
-	stht = 1.0;
-	ctht = 0.0;
-      }
-      else {
-	T = DEG_RAD / R;
-	stht =   T / sqrt ( 1.0 + T*T);
-	ctht = 1.0 / sqrt ( 1.0 + T*T);
-      }
-    }
-    if (!strcmp(&coords[0].ctype[4], "-SIN") || !strcmp(&coords[0].ctype[0], "MM")) {
-      ctht = RAD_DEG * R;
-      stht = sqrt (1 - ctht*ctht);
-    }
-
-    sdp  = sin(RAD_DEG*coords[0].crval2);
-    cdp  = cos(RAD_DEG*coords[0].crval2);
-    
-    sdel = stht*sdp - ctht*cphi*cdp;
-    salp = ctht*sphi;
-    calp = stht*cdp + ctht*cphi*sdp;
-    alpha = atan2 (salp, calp);
-    delta = asin (sdel);
-    
-    *ra  = DEG_RAD*alpha + coords[0].crval1;
-    *dec = DEG_RAD*delta;
-  }
-  if (!strcmp(&coords[0].ctype[4], "-LIN") || !strcmp(&coords[0].ctype[0], "GENE")) {
-    *ra  = L + coords[0].crval1;
-    *dec = M + coords[0].crval2;
-  }
-
-}
-
-
-fXY_to_RD (ra, dec, x, y, coords)
-float *ra, *dec;
-double  x, y;
-Coords coords[];
-{
-
-  double L, M, X, Y, T;
-  double R, sphi, cphi, stht, ctht;
-  double alpha, delta, salp, calp, sdel, sdp, cdp;
-  
-  *ra  = 0;
-  *dec = 0;
-
-  if (!strcmp(&coords[0].ctype[4], "-PLY")) {
-    X = coords[0].cdelt1*(x - coords[0].crpix1 + x*x*coords[0].polyterms[0][0] + x*y*coords[0].polyterms[1][0] + y*y*coords[0].polyterms[2][0]
-			  + x*x*x*coords[0].polyterms[3][0] + x*x*y*coords[0].polyterms[4][0] + x*y*y*coords[0].polyterms[5][0] + y*y*y*coords[0].polyterms[6][0]);
-    Y = coords[0].cdelt2*(y - coords[0].crpix2 + x*x*coords[0].polyterms[0][1] + x*y*coords[0].polyterms[1][1] + y*y*coords[0].polyterms[2][1]
-			  + x*x*x*coords[0].polyterms[3][1] + x*x*y*coords[0].polyterms[4][1] + x*y*y*coords[0].polyterms[5][1] + y*y*y*coords[0].polyterms[6][1]);
-  } else {
-    X = coords[0].cdelt1*(x - coords[0].crpix1);
-    Y = coords[0].cdelt2*(y - coords[0].crpix2);
-  }    
-  L = (X*coords[0].pc1_1 + Y*coords[0].pc1_2);
-  M = (X*coords[0].pc2_1 + Y*coords[0].pc2_2);
-
-  if (!strcmp(&coords[0].ctype[4], "-PLY") || !strcmp(&coords[0].ctype[4], "-TAN") || !strcmp(&coords[0].ctype[4], "-SIN") || !strcmp(&coords[0].ctype[0], "MM")) {
-    R = hypot (L,M);
-    if ((L == 0) && (M == 0)) {
-      sphi = 0;
-      cphi = 1;
-    }
-    else {
-      sphi =  L / R;
-      cphi = -M / R;
-    }
-
-    if (!strcmp(&coords[0].ctype[4], "-PLY") || !strcmp(&coords[0].ctype[4], "-TAN") ) {
-      if (R == 0) {
-	stht = 1.0;
-	ctht = 0.0;
-      }
-      else {
-	T = DEG_RAD / R;
-	stht =   T / sqrt ( 1.0 + T*T);
-	ctht = 1.0 / sqrt ( 1.0 + T*T);
-      }
-    }
-    if (!strcmp(&coords[0].ctype[4], "-SIN") || !strcmp(&coords[0].ctype[0], "MM")) {
-      ctht = RAD_DEG * R;
-      stht = sqrt (1 - ctht*ctht);
-    }
-
-    sdp  = sin(RAD_DEG*coords[0].crval2);
-    cdp  = cos(RAD_DEG*coords[0].crval2);
-    
-    sdel = stht*sdp - ctht*cphi*cdp;
-    salp = ctht*sphi;
-    calp = stht*cdp + ctht*cphi*sdp;
-    alpha = atan2 (salp, calp);
-    delta = asin (sdel);
-    
-    *ra  = DEG_RAD*alpha + coords[0].crval1;
-    *dec = DEG_RAD*delta;
-  }
-  if (!strcmp(&coords[0].ctype[4], "-LIN") || !strcmp(&coords[0].ctype[0], "GENE")) {
-    *ra  = L + coords[0].crval1;
-    *dec = M + coords[0].crval2;
-  }
-
-}
-
-
-RD_to_XY (x, y, ra, dec, coords)
-double *x, *y;
-double  ra, dec;
-Coords coords[];
-{
-
-  double tmp_d;
-  double X, Y, sphi, cphi, stht;
-  double salp, calp, sdel, cdel, sdp, cdp;
-
-  if (!strcmp(&coords[0].ctype[4], "-PLY")) {
-    /* fprintf (stderr, "approximate to polynomial TAN plane fit\n");  */
-  }
-
-  *x = 0;
-  *y = 0;
-  if (!strcmp(&coords[0].ctype[0], "GENE") || !strcmp(&coords[0].ctype[4], "-LIN")) {
-    X = (ra  - coords[0].crval1);
-    Y = (dec - coords[0].crval2);
-  }
-  
-  if (!strcmp(&coords[0].ctype[4], "-PLY") || !strcmp(&coords[0].ctype[4], "-TAN") || !strcmp(&coords[0].ctype[4], "-SIN") || !strcmp(&coords[0].ctype[0], "MM")) {
-    sdp  = sin(RAD_DEG*coords[0].crval2);
-    cdp  = cos(RAD_DEG*coords[0].crval2);
-    salp = sin(RAD_DEG*(ra - coords[0].crval1));
-    calp = cos(RAD_DEG*(ra - coords[0].crval1));
-    sdel = sin(RAD_DEG*dec);
-    cdel = cos(RAD_DEG*dec);
-
-    stht = sdel*sdp + cdel*cdp*calp;  /* sin(theta) */
-    sphi = cdel*salp;  /* = cos(theta)*sin(phi) */
-    cphi = cdel*sdp*calp - sdel*cdp; /* = cos(theta)*cos(phi) */
-
-    if (!strcmp(&coords[0].ctype[4], "-PLY") || !strcmp(&coords[0].ctype[4], "-TAN") ) {
-      X =  DEG_RAD * sphi / stht;
-      Y = -DEG_RAD * cphi / stht;
-    }
-    if (!strcmp(&coords[0].ctype[4], "-SIN") || !strcmp(&coords[0].ctype[0], "MM")) {
-      X =  DEG_RAD * sphi;
-      Y = -DEG_RAD * cphi;
-    }
-    X = X;
-    Y = Y;
-  }
-  
-  tmp_d = 1.0 / (coords[0].pc1_1*coords[0].pc2_2 - coords[0].pc1_2*coords[0].pc2_1);
-  *x = tmp_d * (coords[0].pc2_2*X - coords[0].pc1_2*Y) / coords[0].cdelt1 + coords[0].crpix1;
-  *y = tmp_d * (coords[0].pc1_1*Y - coords[0].pc2_1*X) / coords[0].cdelt2 + coords[0].crpix2;
- 
-}
-
-
-fRD_to_XY (x, y, ra, dec, coords)
-float *x, *y;
-double  ra, dec;
-Coords coords[];
-{
-
-  double tmp_d;
-  double X, Y, sphi, cphi, stht;
-  double salp, calp, sdel, cdel, sdp, cdp;
-
-  *x = 0;
-  *y = 0;
-  if (!strcmp(&coords[0].ctype[0], "GENE") || !strcmp(&coords[0].ctype[4], "-LIN")) {
-    X = (ra  - coords[0].crval1);
-    Y = (dec - coords[0].crval2);
-  }
-  
-  if (!strcmp(&coords[0].ctype[4], "-PLY") || !strcmp(&coords[0].ctype[4], "-TAN") || !strcmp(&coords[0].ctype[4], "-SIN") || !strcmp(&coords[0].ctype[0], "MM")) {
-    sdp  = sin(RAD_DEG*coords[0].crval2);
-    cdp  = cos(RAD_DEG*coords[0].crval2);
-    salp = sin(RAD_DEG*(ra - coords[0].crval1));
-    calp = cos(RAD_DEG*(ra - coords[0].crval1));
-    sdel = sin(RAD_DEG*dec);
-    cdel = cos(RAD_DEG*dec);
-
-    stht = sdel*sdp + cdel*cdp*calp;  /* sin(theta) */
-    sphi = cdel*salp;  /* = cos(theta)*sin(phi) */
-    cphi = cdel*sdp*calp - sdel*cdp; /* = cos(theta)*cos(phi) */
-
-    if (!strcmp(&coords[0].ctype[4], "-PLY") || !strcmp(&coords[0].ctype[4], "-TAN") ) {
-      X =  DEG_RAD * sphi / stht;
-      Y = -DEG_RAD * cphi / stht;
-    }
-    if (!strcmp(&coords[0].ctype[4], "-SIN") || !strcmp(&coords[0].ctype[0], "MM")) {
-      X =  DEG_RAD * sphi;
-      Y = -DEG_RAD * cphi;
-    }
-    X = X;
-    Y = Y;
-  }
-  
-  tmp_d = 1.0 / (coords[0].pc1_1*coords[0].pc2_2 - coords[0].pc1_2*coords[0].pc2_1);
-  *x = tmp_d * (coords[0].pc2_2*X - coords[0].pc1_2*Y) / coords[0].cdelt1 + coords[0].crpix1;
-  *y = tmp_d * (coords[0].pc1_1*Y - coords[0].pc2_1*X) / coords[0].cdelt2 + coords[0].crpix2;
- 
-}
-
-
-
-GetCoords (coords, header) 
-Coords coords[];
-Header header[];
-{
-
-  int status;
-  double rotate;
-
-  rotate = 0.0;
-  coords[0].crval1 = coords[0].crpix1 = coords[0].cdelt1 = 0.0;
-  coords[0].crval2 = coords[0].crpix2 = coords[0].cdelt2 = 0.0;
-  coords[0].pc1_1 = coords[0].pc2_2 = 1.0;
-  coords[0].pc2_1 = coords[0].pc1_2 = 0.0;
-  strcpy (coords[0].ctype, "NONE");
-
-  status = TRUE; 
-  if (fits_scan (header, "CTYPE2", "%s", 1, coords[0].ctype)) {
-    status  = fits_scan (header, "CRVAL1", "%lf", 1, &coords[0].crval1);
-    status &= fits_scan (header, "CRPIX1", "%lf", 1, &coords[0].crpix1);
-    status &= fits_scan (header, "CRVAL2", "%lf", 1, &coords[0].crval2);  
-    status &= fits_scan (header, "CRPIX2", "%lf", 1, &coords[0].crpix2);
-    if (fits_scan (header, "CDELT1", "%lf", 1, &coords[0].cdelt1)) {
-      status &= fits_scan (header, "CDELT2", "%lf", 1, &coords[0].cdelt2);
-      if (fits_scan (header, "CROTA2", "%lf", 1, &rotate)) {
-	coords[0].pc1_1 =  cos(rotate*RAD_DEG);
-	coords[0].pc1_2 = -sin(rotate*RAD_DEG);
-	coords[0].pc2_1 =  sin(rotate*RAD_DEG);
-	coords[0].pc2_2 =  cos(rotate*RAD_DEG);
-      }
-      if (fits_scan (header, "PC001001", "%lf", 1, &coords[0].pc1_1)) {
-	status &= fits_scan (header, "PC001002", "%lf", 1, &coords[0].pc1_2);
-	status &= fits_scan (header, "PC002001", "%lf", 1, &coords[0].pc2_1);
-	status &= fits_scan (header, "PC002002", "%lf", 1, &coords[0].pc2_2);
-      }
-    }
-    else {
-      if (fits_scan (header, "CD1_1", "%lf", 1, &coords[0].pc1_1)) {
-	status &= fits_scan (header, "CD1_2", "%lf", 1, &coords[0].pc1_2);
-	status &= fits_scan (header, "CD2_1", "%lf", 1, &coords[0].pc2_1);
-	status &= fits_scan (header, "CD2_2", "%lf", 1, &coords[0].pc2_2);
-	coords[0].cdelt1 = coords[0].cdelt2 = 1.0;
-      }
-      else {
-	status = FALSE;
-      }
-    }
-  }
-  else {
-    if (fits_scan (header, "RA_O", "%lf", 1, &coords[0].crval1)) {
-      status  = fits_scan (header, "RA_X", "%lf", 1, &coords[0].pc1_1);
-      status &= fits_scan (header, "RA_Y", "%lf", 1, &coords[0].pc1_2);
-      status &= fits_scan (header, "DEC_O", "%lf", 1, &coords[0].crval2);  
-      status &= fits_scan (header, "DEC_X", "%lf", 1, &coords[0].pc2_1);
-      status &= fits_scan (header, "DEC_Y", "%lf", 1, &coords[0].pc2_2);
-      coords[0].crpix1 = coords[0].crpix2 = 0.0;
-      coords[0].cdelt1 = coords[0].cdelt2 = 1.0;
-      strcpy (coords[0].ctype, "GENE");
-    }
-  }
-  if (!status) {
-    fprintf (stderr, "error getting all elements for coordinate mode %d\n", coords[0].ctype);
-    coords[0].crval1 = coords[0].crpix1 = coords[0].cdelt1 = 0.0;
-    coords[0].crval2 = coords[0].crpix2 = coords[0].cdelt2 = 0.0;
-    coords[0].pc1_1 = coords[0].pc2_2 = 1.0;
-    coords[0].pc2_1 = coords[0].pc1_2 = 0.0;
-    strcpy (coords[0].ctype, "NONE");
-  }
-}
-
-
-  /* -PLY projection is an extrapolation of the -TAN projection. 
-     In addition to the usual linear terms of CRPIXi, PC00i00j, there are 
-     higher order polynomial terms (up to 3rd order):
-     Axis 1 terms:
-     PCA1X2Y0 = coords.polyterm[0][0] = x^2                                             
-     PCA1X1Y1 = coords.polyterm[1][0] = xy                                          
-     PCA1X0Y2 = coords.polyterm[2][0] = y^2                                             
-     PCA1X3Y0 = coords.polyterm[3][0] = x^3                                             
-     PCA1X2Y1 = coords.polyterm[4][0] = x^2 y                                             
-     PCA1X1Y2 = coords.polyterm[5][0] = x y^2                                             
-     PCA1X0Y3 = coords.polyterm[6][0] = y^2                                              
-     Axis 2 terms:
-     PCA2X2Y0 = coords.polyterm[0][1] = x^2                                               
-     PCA2X1Y1 = coords.polyterm[1][1] = xy                                                
-     PCA2X0Y2 = coords.polyterm[2][1] = y^2                                               
-     PCA2X3Y0 = coords.polyterm[3][1] = x^3                                               
-     PCA2X2Y1 = coords.polyterm[4][1] = x^2 y                                             
-     PCA2X1Y2 = coords.polyterm[5][1] = x y^2                                             
-     PCA2X0Y3 = coords.polyterm[6][1] = y^2                                               
-  */
Index: unk/Ohana/src/getstar/src/gstars.c
===================================================================
--- /trunk/Ohana/src/getstar/src/gstars.c	(revision 3304)
+++ 	(revision )
@@ -1,276 +1,0 @@
-# include "addstar.h"
-# define D_NSTARS 1000
-# define BYTES_STAR 66
-# define BLOCK 1000
-#include <sys/time.h>
-#include <time.h>
-
-Stars *gstars (file, NSTARS, image) 
-char file[];
-int *NSTARS;
-Image *image;
-{
-
-  FILE *f;
-  Header header;
-  int j, N, Ninstar;
-  int nbytes, Nbytes;
-  Stars *stars;
-  char *buffer, *c, *c2, photcode[64];
-  double tmp;
-  int done, doneread, Nskip, Nextra, itmp;
-  unsigned short int Nc;
-
-  if (!fits_read_header (file, &header)) {
-    fprintf (stderr, "ERROR: can't read header for %s\n", file);
-    exit (1);
-  }
-
-  /* open file */
-  f = fopen (file, "r");
-  if (f == NULL) {
-    fprintf (stderr, "ERROR: can't read data from %s\n", file);
-    exit (1);
-  }
-  fseek (f, header.size, SEEK_SET); 
-
-  /* find image rootname */
-  c = strrchr (file, 0x2f);
-  if (c == (char *) NULL) {
-    strcpy (image[0].name, file);
-  } else { 
-    strcpy (image[0].name, (c+1));
-  }
-
-  /* get astrometry information */
-  if (!GetCoords (&image[0].coords, &header)) {
-    fprintf (stderr, "ERROR: no astrometric solution in header\n");
-    exit (1);
-  }
-  while (image[0].coords.crval1 < 0) image[0].coords.crval1 += 360.0;
-  while (image[0].coords.crval1 > 360.0) image[0].coords.crval1 -= 360.0;
-  itmp = 0;
-  fits_scan (&header, "NASTRO",   "%d", 1, &itmp);
-  if ((itmp == 0) && !ACCEPT_ASTROM) {
-    fprintf (stderr, "ERROR: bad astrometric solution in header\n");
-    exit (1);
-  }
-    
-  /* CERROR in data file is in arcsec */
-  if (!fits_scan (&header, "CERROR",   "%lf", 1, &tmp)) tmp = 1.0;
-  image[0].cerror = tmp * 50.0;
-  fits_scan (&header, "NAXIS1",   "%hd", 1, &image[0].NX); 
-  fits_scan (&header, "NAXIS2",   "%hd", 1, &image[0].NY);
- 
-  /* get photcode from header */
-  if (thiscode == NULL) {
-    fits_scan (&header, "PHOTCODE", "%s", 1, photcode);
-    thiscode = GetPhotcodebyName (photcode);
-  }
-  if (thiscode == NULL) {
-    fprintf (stderr, "ERROR: photcode %s not found in photcode table\n", photcode);
-    exit (1);
-  }
-  image[0].source = thiscode[0].code;
-
-  image[0].NX -= XOVERSCAN;
-  image[0].NY -= YOVERSCAN;
-  fits_scan (&header, ExptimeKeyword,  "%lf", 1, &tmp);
-  image[0].exptime = tmp;
-  
-  tmp = 0;
-  /* fits_scan (&header, "APMIFIT",  "%lf", 1, &tmp); */
-  image[0].apmifit = tmp * 1000.0;
-
-  tmp = 0;
-  /* fits_scan (&header, "dAPMIFIT", "%lf", 1, &tmp); */
-  image[0].dapmifit = tmp * 1000.0;
-
-  tmp = 0;
-  fits_scan (&header, "FLIMIT",   "%lf", 1, &tmp);
-  image[0].detection_limit = tmp * 10.0;
-
-  tmp = 0;
-  fits_scan (&header, "FSATUR",   "%lf", 1, &tmp);
-  image[0].saturation_limit = tmp * 10.0;
-
-  tmp = 0;
-  fits_scan (&header, "FWHM_X",   "%lf", 1, &tmp);
-  image[0].fwhm_x = tmp * 25.0 * image[0].coords.cdelt1 * 3600.0;
-
-  tmp = 0;
-  fits_scan (&header, "FWHM_Y",   "%lf", 1, &tmp);
-  image[0].fwhm_y = tmp * 25.0 * image[0].coords.cdelt1 * 3600.0;
-
-  if (!fits_scan (&header, "TZERO",   "%d",  1, &image[0].tzero)) {
-    image[0].tzero = parse_time (&header);
-  }
-
-  tmp = 0;
-  fits_scan (&header, "TRATE",   "%lf", 1, &tmp);
-  image[0].trate = 10000 * tmp;
-
-  tmp = 0;
-  fits_scan (&header, AirmassKeyword, "%lf", 1, &tmp);
-  image[0].secz = MIN (NO_MAG, 1000*tmp);
-
-  if (!fits_scan (&header, CCDNumKeyword, "%d", 1, &itmp)) {
-    image[0].ccdnum = 0xff;
-  } else {
-    image[0].ccdnum = itmp;
-  }
-
-  fits_scan (&header, "ZERO_PT", "%lf", 1, &ZeroPt);
-
-  /* secz is in units milli-airmass */
-  image[0].Mcal = 0.0;
-  image[0].code = 0;
-  image[0].Xm   = NO_MAG;
-  bzero (image[0].dummy, sizeof(image[0].dummy));
-
-  /* find expected number of stars */
-  fits_scan (&header, "NSTARS", "%d", 1, &image[0].nstar);
-  if (image[0].nstar == 0) {
-    fprintf (stderr, "ERROR: can't get NSTARS from header\n");
-    exit (1);
-  }
-  ALLOCATE (stars, Stars, image[0].nstar);
-
-  /* load in stars by blocks of 1000 */
-  N = 0;
-  ALLOCATE (buffer, char, (BLOCK*BYTES_STAR) + 1);
-  buffer[BLOCK*BYTES_STAR] = 0;
-  Nextra = 0;
-  doneread = FALSE;
-  while (!doneread) {
-    Nbytes = BYTES_STAR * BLOCK - Nextra;
-    nbytes = Fread (&buffer[Nextra], 1, Nbytes, f, "char");
-    if (nbytes == 0) {
-      doneread = TRUE;
-      continue;
-    }
-    nbytes += Nextra;
-    /* check line-by-line integrity */
-    c = buffer;
-    done = FALSE;
-    while ((c < buffer + nbytes) && (!done)) { 
-      for (c2 = c; *c2 == '\n'; c2++);
-      if (c2 > c) { /* extra return chars */
-	memmove (c, c2, (int)(buffer + nbytes - c2));
-	Nskip = c2 - c;
-	nbytes -= Nskip;
-	bzero (buffer + nbytes, Nskip);
-	if (VERBOSE) fprintf (stderr, "deleted %d extra return chars\n", Nskip);
-      }
-      c2 = strchr (c, '\n');
-      if (c2 == (char *) NULL) {
-	done = TRUE;	
-	continue;
-      }
-      c2++;
-      if ((c2 - c) != BYTES_STAR) { /* bad line, delete it */
-	memmove (c, c2, (int)(buffer + nbytes - c2));
-	Nskip = c2 - c;
-	nbytes -= Nskip;
-	bzero (buffer + nbytes, Nskip);
-	if (VERBOSE) fprintf (stderr, "deleted line, %d extra chars\n", Nskip);
-      } else {
-	c = c2;
-      }
-    }
-    Ninstar = nbytes / BYTES_STAR;
-    Nextra = nbytes % BYTES_STAR;
-    for (j = 0; j < Ninstar; j++, N++) {
-      dparse (&stars[N].X,  1, &buffer[j*BYTES_STAR]);
-      dparse (&stars[N].Y,  2, &buffer[j*BYTES_STAR]);
-      dparse (&stars[N].M,  3, &buffer[j*BYTES_STAR]);
-      dparse (&stars[N].dM, 4, &buffer[j*BYTES_STAR]);
-      /* allow for some dynamic filtering of star list */
-      if (stars[N].dM > 1000.0 / SNLIMIT) { N--; continue; }
-      if (XMAX && (stars[N].X > XMAX))    { N--; continue; }
-      if (XMIN && (stars[N].X < XMIN))    { N--; continue; }
-      if (YMAX && (stars[N].Y > YMAX))    { N--; continue; }
-      if (YMIN && (stars[N].Y < YMIN))    { N--; continue; }
-
-      dparse (&tmp,         5, &buffer[j*BYTES_STAR]);
-      stars[N].dophot = tmp;
-      dparse (&stars[N].Mgal, 7, &buffer[j*BYTES_STAR]);
-      dparse (&stars[N].Map,  8, &buffer[j*BYTES_STAR]);
-      dparse (&stars[N].fx,   9, &buffer[j*BYTES_STAR]);
-      dparse (&stars[N].fy,  10, &buffer[j*BYTES_STAR]);
-      dparse (&stars[N].df,  11, &buffer[j*BYTES_STAR]);
-
-      XY_to_RD (&stars[N].R, &stars[N].D, stars[N].X, stars[N].Y, &image[0].coords);
-      while (stars[N].R < 0.0) stars[N].R += 360.0;
-      while (stars[N].R >= 360.0) stars[N].R -= 360.0;
-      stars[N].found = -1;
-    }
-  }
-
-  image[0].nstar = N;
-  REALLOCATE (stars, Stars, image[0].nstar);
-  if (VERBOSE) fprintf (stderr, "read %d stars from target file\n", image[0].nstar);
-  *NSTARS = image[0].nstar;
-
-  return (stars);
-}
-
-
-
-
-# if (0)
-  /* left over fraction of a block */
-  nbytes = Fread (buffer, 1, (Nbytes % (BLOCK*BYTES_STAR)), f, "char");
-  if (nbytes != (Nbytes % (BLOCK*BYTES_STAR))) {
-    fprintf (stderr, "ERROR: failed to read in stars (2)\n");
-    exit (1);
-  }
-  /* check line-by-line integrity */
-  Nnew = 0;
-  c = buffer;
-  done = FALSE;
-  while ((c < buffer + nbytes) && (!done)) { 
-    for (c2 = c; *c2 == '\n'; c2++);
-    if (c2 > c) { /* extra return chars */
-      memmove (c, c2, (int)(buffer + nbytes - c2));
-      Nnew += c2 - c;
-      fprintf (stderr, "deleting %d extra return chars\n", (int)(c2-c));
-    }
-    c2 = strchr (c, '\n');
-    if (c2 == (char *) NULL) {
-      if (Nnew > 0) {
-	nnew = Fread (&buffer[nbytes-Nnew], 1, Nnew, f, "char");
-	if (nnew != Nnew) {
-	  fprintf (stderr, "ERROR: failed to read in stars (1)\n");
-	  exit (1);
-	}
-      } else {
-	done = TRUE;	
-      }
-      continue;
-    }
-    c2++;
-    if ((c2 - c) != BYTES_STAR) {
-      /* this is a bad line, delete it, adjust data in buffer, 
-	 and be ready to read the rest of the last line */
-      memmove (c, c2, (int)(buffer + nbytes - c2));
-      Nnew += c2 - c;
-      fprintf (stderr, "deleting bad line with %d chars\n", (int)(c2-c));
-    } else {
-      c = c2;
-    }
-  }
-  for (j = 0; j < nbytes / BYTES_STAR; j++, nstar++, N++) {
-    dparse (&stars[N].X, 1, &buffer[j*BYTES_STAR]);
-    dparse (&stars[N].Y, 2, &buffer[j*BYTES_STAR]);
-    dparse (&stars[N].M, 3, &buffer[j*BYTES_STAR]);
-    dparse (&stars[N].dM, 4, &buffer[j*BYTES_STAR]);
-    XY_to_RD (&stars[N].R, &stars[N].D, stars[N].X, stars[N].Y, &image[0].coords);
-    while (stars[N].R < 0.0) stars[N].R += 360.0;
-    while (stars[N].R >= 360.0) stars[N].R -= 360.0;
-    dparse (&tmp, 5, &buffer[j*BYTES_STAR]);
-    stars[N].dophot = tmp;
-    stars[N].found = -1;
-  }
-
-# endif
Index: unk/Ohana/src/getstar/src/misc.c
===================================================================
--- /trunk/Ohana/src/getstar/src/misc.c	(revision 3304)
+++ 	(revision )
@@ -1,398 +1,0 @@
-# include "getstar.h"
-
-/***** convert [-]00:00:00 to 0.0000 ****/
-int dms_to_ddd (double *Value, char *string) {
-  
-  int valid, neg, status;
-  double tmp, value;
-  char *p1, *p2, *px;
-
-  valid = FALSE; 
-  neg = FALSE;
-  stripwhite (string);
-  p1 = string;
-  px = string + strlen(string);
-
-  if (string[0] == '-') { 
-    valid = TRUE; 
-    neg = TRUE;
-    p1 = &string[1];
-  }
-  if (string[0] == '+') { 
-    valid = TRUE; 
-    neg = FALSE;
-    p1 = &string[1];
-  }
-  if (isdigit(string[0])) { 
-    valid = TRUE;
-    p1 = &string[0];
-  }
-  if (!valid) { return (FALSE); }
-
-  status = 1;
-  tmp = strtod (p1, &p2);
-  if (p2 == p1) return (FALSE); /* entry not a number: +fred */
-  value = tmp;
-  if (p2 == px) goto escape;    /* entry only number: +1.0 */ 
-  p1 = p2 + 1;
-
-  tmp = strtod (p1, &p2);
-  if (p2 == p1) goto escape;    /* entry not a number: +1:fred */
-  status = 2;
-  value += tmp / 60.0;
-  if (p2 == px) goto escape;    /* entry only number: +1:1 */
-  p1 = p2 + 1;
-
-  tmp = strtod (p1, &p2);
-  if (p2 == p1) goto escape;    /* entry not a number: +1:1:fred */
-  value += tmp / 3600.0;
-
- escape:
-  if (neg) {
-    value *= -1;
-  }
-  *Value = value;
-
-  return (status);
-}
-
-/**********/
-int str_to_radec (double *ra, double *dec, char *str1, char *str2) {
-
-  double Ra, Dec;
-
-  *ra = *dec = 0;
-  switch (dms_to_ddd (&Ra, str1)) {
-  case 0:
-    fprintf (stderr, "syntax error in RA\n");
-    return (FALSE);
-  case 1:
-    break;
-  case 2:
-    Ra = Ra * 15;
-    break;
-  }
-  switch (dms_to_ddd (&Dec, str2)) {
-  case 0:
-    fprintf (stderr, "syntax error in DEC\n");
-    return (FALSE);
-  case 1:
-  case 2:
-    break;
-  }
-  *ra = Ra;
-  *dec = Dec;
-  return (TRUE);
-}
-
-# define FORMAT_DAYS    1
-# define FORMAT_HOURS   2
-# define FORMAT_MINUTES 3
-# define FORMAT_SECONDS 4
-# define FORMAT_JD      5
-# define FORMAT_DATE    6
-
-/**********/
-int chk_time (char *line) {
-
-  char *p1, *p2;
-  double tmp;
-  int mode;
-
-  p1 = line;
-  tmp = strtod (p1, &p2);
-  if (p2 == p1 + strlen (p1) - 1) {
-    if (*p2 == 'd') {
-      mode = FORMAT_DAYS;
-    }
-    if (*p2 == 'h') {
-      mode = FORMAT_HOURS;
-    }
-    if (*p2 == 'm') {
-      mode = FORMAT_MINUTES;
-    }
-    if (*p2 == 's') {
-      mode = FORMAT_SECONDS;
-    }
-    if (*p2 == 'j') {
-      mode = FORMAT_JD;
-    }
-  } else { 
-    mode = FORMAT_DATE;
-  }
-  return (mode);
-}
-
-/**********/
-int str_to_time (char *line, unsigned int *second) {
-  
-  char *tmpline;
-  struct tm *gmt;
-  struct timeval now;
-  double jd;
-  unsigned long tsec;
-
-  if (!strcasecmp (line, "NOW")) {
-    gettimeofday (&now, (struct timezone *) NULL);
-    *second = now.tv_sec;
-    return (TRUE);
-  }
-    
-  if (!strncasecmp (line, "TODAY", 5)) {
-    gettimeofday (&now, (struct timezone *) NULL);
-    if (line[5]) { /* line has extra data (ie, hh:mm:ss) */
-      tsec = now.tv_sec;
-      ALLOCATE (tmpline, char, 64);
-      gmt   = gmtime (&tsec);
-      sprintf (tmpline, "%04d/%02d/%02d,%s", 
-	       1900 + gmt[0].tm_year, gmt[0].tm_mon+1, gmt[0].tm_mday, &line[6]);
-      *second = date_to_sec (tmpline);
-      free (tmpline);
-      return (TRUE);
-    } else {
-      *second = 86400 * ((int)(now.tv_sec / 86400));
-      return (TRUE); 
-    }
-  }
-    
-  switch (chk_time (line)) {
-  case 0:
-    return (FALSE);
-  case FORMAT_DAYS:
-    *second = strtod (line, 0) * 86400.0;
-    return (TRUE);
-  case FORMAT_HOURS:
-    *second = strtod (line, 0) * 3600.0;
-    return (TRUE);
-  case FORMAT_MINUTES:
-    *second = strtod (line, 0) * 60.0;
-    return (TRUE);
-  case FORMAT_SECONDS:
-    *second = strtod (line, 0);
-    return (TRUE);
-  case FORMAT_JD:
-    jd = strtod (line, 0);
-    *second = jd_to_sec (jd);
-    return (TRUE);
-  case FORMAT_DATE:
-    *second = date_to_sec (line);
-    return (TRUE);
-  }
-  return (FALSE);
-}
-
-
-/**********/
-int str_to_dtime (char *line, double *second) {
-  
-  switch (chk_time (line)) {
-  case 0:
-  case FORMAT_JD:
-  case FORMAT_DATE:
-    return (FALSE);
-  case FORMAT_DAYS:
-    *second = strtod (line, 0) * 86400.0;
-    return (TRUE);
-  case FORMAT_HOURS:
-    *second = strtod (line, 0) * 3600.0;
-    return (TRUE);
-  case FORMAT_MINUTES:
-    *second = strtod (line, 0) * 60.0;
-    return (TRUE);
-  case FORMAT_SECONDS:
-    *second = strtod (line, 0);
-    return (TRUE);
-  }
-  return (FALSE);
-}
-
-/**********/
-double sec_to_jd (unsigned long second) {
-
-  double jd;
-  
-  jd = second/86400.0 + 2440587.5;
-  return (jd);
-}
-
-/**********/
-unsigned long int jd_to_sec (double jd) {
-
-  unsigned long int second;
-
-  second = (jd - 2440587.5)*86400;
-  return (second);
-}
-
-/**********/
-char *sec_to_date (unsigned long second) {
-  
-  struct tm *gmt;
-  char *line;
-  
-  ALLOCATE (line, char, 64);
-  gmt   = gmtime (&second);
-  sprintf (line, "%04d/%02d/%02d,%02d:%02d:%02d", 
-	   1900 + gmt[0].tm_year, gmt[0].tm_mon+1, gmt[0].tm_mday, 
-	   gmt[0].tm_hour, gmt[0].tm_min, gmt[0].tm_sec); 
-  return (line);
-
-}
-
-/***** date in format yyyy/mm/dd,hh:mm:ss *****/
-unsigned long date_to_sec (char *date) {
-  
-  unsigned long second;
-  double tmp, jd;
-  struct tm now;
-  char *p1, *p2, *px;
-  
-  p1 = date;
-  px = date + strlen(date);
-  bzero (&now, sizeof(now));
-
-  tmp = strtod (p1, &p2);
-  if (p2 == p1) goto escape;
-  now.tm_year = tmp;
-  if (now.tm_year > 1000) now.tm_year -= 1900;
-  if (now.tm_year <   50) now.tm_year += 100;
-  if (p2 == px) goto escape;  
-  p1 = p2 + 1;
-
-  tmp = strtod (p1, &p2);
-  if (p2 == p1) goto escape;
-  now.tm_mon = tmp - 1; /* mon runs from 0 - 11 */
-  if (p2 == px) goto escape;  
-  p1 = p2 + 1;
-
-  tmp = strtod (p1, &p2);
-  if (p2 == p1) goto escape;
-  now.tm_mday = tmp;
-  if (p2 == px) goto escape;  
-  p1 = p2 + 1;
-
-  tmp = strtod (p1, &p2);
-  if (p2 == p1) goto escape;
-  p1 = p2 + 1;
-  now.tm_hour = tmp;
-  if (p2 == px) goto escape;  
-
-  tmp = strtod (p1, &p2);
-  if (p2 == p1) goto escape;
-  now.tm_min = tmp;
-  if (p2 == px) goto escape;  
-  p1 = p2 + 1;
-
-  tmp = strtod (p1, &p2);
-  if (p2 == p1) goto escape;
-  now.tm_sec = tmp;
-  if (p2 == px) goto escape;  
-  p1 = p2 + 1;
-
- escape:
-  jd = now.tm_mday - 32075 + (int)(1461*(1900 + now.tm_year + 4800 + (int)(((now.tm_mon+1)-14)/12))/4)
-    + (int)(367*((now.tm_mon+1) - 2 - (int)(((now.tm_mon+1) - 14)/12)*12)/12)
-    - (int)(3*(int)((1900 + now.tm_year + 4900 + (int)(((now.tm_mon+1) - 14)/12))/100)/4) - 0.5;
-  
-  second = (jd - 2440587.5)*86400 + 3600.0*now.tm_hour + now.tm_min*60.0 + now.tm_sec;
-
-  return (second);
-}
-
-
-
-/* times may be in forms as:
-   20040200450s (N seconds since 1970.0)
-   2440900.232j (julian date)
-   99/02/23,03:22:18 (date string)
-   (separators may be anything except space, +, -)
-   99:02:15:12:23:30
-   99:02:15:12h23m30s
-   */
-
-
-int GetTimeFormat (unsigned int *TimeReference, int *TimeFormat) {
-
-  char *p;
-
-  *TimeReference = 0;
-  if ((p = get_variable ("TIMEREF")) != (char *) NULL) {
-    if (!str_to_time (p, TimeReference)) {
-      fprintf (stderr, "error in TIME_REF format\n");
-      return (FALSE);
-    }
-    free (p);
-  }
-  *TimeFormat = FALSE;
-  if ((p = get_variable ("TIMEFORMAT")) != (char *) NULL) {
-    if (!strcasecmp (p, "date")) *TimeFormat   = TIME_DATE;
-    if (!strcasecmp (p, "hours")) *TimeFormat  = TIME_HOURS;
-    if (!strcasecmp (p, "days")) *TimeFormat   = TIME_DAYS;
-    if (!strcasecmp (p, "JD")) *TimeFormat     = TIME_JD;
-    if (!strcasecmp (p, "MJD")) *TimeFormat    = TIME_MJD;
-    if (!strcasecmp (p, "sec")) *TimeFormat    = TIME_SEC;
-    if (!*TimeFormat) fprintf (stderr, "unknown TIME_FORMAT\n");
-    free (p);
-    return (FALSE);
-  }
-  if (!*TimeFormat) *TimeFormat = TIME_SEC;
-  return (TRUE);
-}
-  
-/* convert UNIX time to a value referenced to the TimeReference in the given unit */
-double TimeValue (unsigned int time, unsigned int TimeReference, int TimeFormat) {
-
-  double value, dt;
-
-  dt = (time > TimeReference) ? (time - TimeReference) : -1 * (double)(TimeReference - time);
-  switch (TimeFormat) {
-  case TIME_HOURS:
-    value = dt / 3600.0;
-    break;
-  case TIME_DAYS:
-    value = dt / 86400.0;
-    break;
-  case TIME_JD:
-    value = time / 86400.0 + 2440587.5;
-    break;
-  case TIME_MJD:
-    value = time / 86400.0 + 40587.0;
-    break;
-  case TIME_SEC:
-  default:
-    value = dt;
-    break;
-  }
-  return (value);
-}
-  
-/* convert time value referenced to the TimeReference in the given unit to UNIX time */
-unsigned int TimeRef (double value, unsigned int TimeReference, int TimeFormat) {
-
-  int dt;
-  unsigned int time;
-
-  switch (TimeFormat) {
-  case TIME_HOURS:
-    dt = value * 3600.0;
-    break;
-  case TIME_DAYS:
-    dt = value * 86400.0;
-    break;
-  case TIME_JD:
-    time = (value -  2440587.5) * 86400.0;
-    return (time);
-    break;
-  case TIME_MJD:
-    time = (value -  40587.0) * 86400.0;
-    return (time);
-    break;
-  case TIME_SEC:
-  default:
-    dt = value;
-    break;
-  }
-
-  time = TimeReference + dt;
-  return (time);
-}
Index: unk/Ohana/src/getstar/src/mkcatalog.c
===================================================================
--- /trunk/Ohana/src/getstar/src/mkcatalog.c	(revision 3304)
+++ 	(revision )
@@ -1,42 +1,0 @@
-# include "addstar.h"
-# include <time.h>
-
-mkcatalog (GSCRegion *region, Catalog *catalog) {
-  
-  char filename[64], line[64];
-  int i, Nmeas, Nmiss;
-  struct tm *local;
-  struct timeval now;
-  char mode;
-  int status, Nextra, in, out, j;
-  SecFilt *insec, *outsec;
-
-  if (VERBOSE) fprintf (stderr, "new catalog file: %s\n", region[0].filename);
-  if (!fits_read_header (CatTemplate, &catalog[0].header)) {
-    fprintf (stderr, "ERROR: can't find template header %s\n", CatTemplate);
-    exit (1);
-  }
-  
-  /* assign header values for RA, DEC, DATE, etc */
-  fits_modify (&catalog[0].header, "RA0", "%lf", 1, region[0].RA[0]);
-  fits_modify (&catalog[0].header, "DEC0", "%lf", 1, region[0].DEC[0]);
-  fits_modify (&catalog[0].header, "RA1", "%lf", 1, region[0].RA[1]);
-  fits_modify (&catalog[0].header, "DEC1", "%lf", 1, region[0].DEC[1]);
-  gettimeofday (&now, NULL);
-  local = localtime (&now.tv_sec);
-  sprintf (line, "%02d/%02d/%02d\0", local[0].tm_year, local[0].tm_mon + 1, local[0].tm_mday); 
-  fits_modify (&catalog[0].header, "DATE", "%s", 1, line);
-  strcpy (filename, CatTemplate);
-  ALLOCATE (catalog[0].average, Average, 1);
-  ALLOCATE (catalog[0].measure, Measure, 1);
-  ALLOCATE (catalog[0].missing, Missing, 1);
-  catalog[0].Naverage = catalog[0].Nmeasure = catalog[0].Nmissing = 0;
-
-  /* setup secondary filters to match photcodes */
-  ALLOCATE (catalog[0].secfilt, SecFilt, 1);
-  catalog[0].Nsecfilt = GetPhotcodeNsecfilt ();
-
-  /* Nsecfilt is number of filters.  Number of entries in array is
-     Nsecfilt * Naverage.  At this point, N entries == 0 */
-
-}
Index: unk/Ohana/src/getstar/src/parse_time.c
===================================================================
--- /trunk/Ohana/src/getstar/src/parse_time.c	(revision 3304)
+++ 	(revision )
@@ -1,126 +1,0 @@
-# include "addstar.h"
-
-parse_time (Header *header) {
-
-  double jd;
-  int Ny, Nf, mode;
-  int Nsec, hour, min, sec, year, month, day;
-  char *py, *pm, *pd, *c;
-  char line[256];
-
-  /* we want to find JD or MJD to get Nsec (seconds since 01/01/1970) */
-
-  /* try JD first */
-  if (strcasecmp (JDKeyword, "NONE")) {
-    uppercase (JDKeyword);
-    fits_scan (header, JDKeyword, "%lf", 1, &jd);
-    Nsec = (jd - 2440587.5)*86400;
-    return (Nsec);
-  }
-
-  /* try MJD next */
-  if (strcasecmp (MJDKeyword, "NONE")) {
-    uppercase (MJDKeyword);
-    fits_scan (header, MJDKeyword, "%lf", 1, &jd);
-    Nsec = (jd - 40587.0)*86400;
-    return (Nsec);
-  }
-    
-  /* get UT and DATE */
-  uppercase (UTKeyword);
-  fits_scan (header, UTKeyword, "%s", 1, line);
-  /* remove ':' characters */
-  for (c = strchr (line, 0x3a); c != (char *) NULL; c = strchr (line, 0x3a)) { *c = ' '; }
-  sscanf (line, "%d %d %d", &hour, &min, &sec);
-
-  /* parse mode line */
-  uppercase (DateMode);
-  for (Ny = 0, c = strchr (DateMode, 'Y'); c != (char ) NULL; c = strchr (c + 1, 'Y'), Ny++);
-  if ((Ny != 2) && (Ny != 4)) {
-    fprintf (stderr, "error in DATE-MODE format: %s\n", DateMode);
-    exit (1);
-  }
-  py = strchr (DateMode, 'Y');
-  pm = strchr (DateMode, 'M');
-  pd = strchr (DateMode, 'D');
-  if ((py == (char *) NULL) || (pm == (char *) NULL) || (pd == (char *) NULL)) {
-    fprintf (stderr, "error in DATE-MODE format: %s\n", DateMode);
-    exit (1);
-  }
-  if ((py > pm) && (py < pd)) {
-    fprintf (stderr, "error in DATE-MODE format: %s\n", DateMode);
-    exit (1);
-  }
-  if ((py > pd) && (py < pm)) {
-    fprintf (stderr, "error in DATE-MODE format: %s\n", DateMode);
-    exit (1);
-  }
-  mode = 0;
-  if ((py < pm) && (pm < pd)) { mode = 1; }  /* yyyy-mm-dd */
-  if ((py < pm) && (pm > pd)) { mode = 2; }  /* yyyy-dd-mm */
-  if ((py > pm) && (pm < pd)) { mode = 3; }  /* mm-dd-yyyy */
-  if ((py > pm) && (pm > pd)) { mode = 4; }  /* dd-mm-yyyy */
-  if (!mode) {
-    fprintf (stderr, "error in DATE-MODE format: %s\n", DateMode);
-    exit (1);
-  }
-
-  /* parse date entry */
-  uppercase (DateKeyword);
-  fits_scan (header, DateKeyword, "%s",  1, line);
-  /* remove possible separators: ':', '/' '.', '-' */
-  for (c = strchr (line, 0x3a); c != (char *) NULL; c = strchr (line, 0x3a)) { *c = ' '; }
-  for (c = strchr (line, 0x2f); c != (char *) NULL; c = strchr (line, 0x2f)) { *c = ' '; }
-  for (c = strchr (line, 0x2e); c != (char *) NULL; c = strchr (line, 0x2e)) { *c = ' '; }
-  for (c = strchr (line, 0x2d); c != (char *) NULL; c = strchr (line, 0x2d)) { *c = ' '; }
-
-  switch (mode) {
-  case 1:
-    Nf = sscanf (line, "%d %d %d", &year, &month, &day);
-    break;
-  case 2:
-    Nf = sscanf (line, "%d %d %d", &year, &day, &month);
-    break;
-  case 3:
-    Nf = sscanf (line, "%d %d %d", &month, &day, &year);
-    break;
-  case 4:
-    Nf = sscanf (line, "%d %d %d", &day, &month, &year);
-    break;
-  }
-  if (Nf != 3) {
-    fprintf (stderr, "error in date entry (%s) or DATE-MODE format (%s)\n", line, DateMode);
-    exit (1);
-  }
-
-  if (year > 1000) {
-    if (Ny == 2) {
-      fprintf (stderr, "warning: mode line claims 2 digit year, but 4 digit year found\n");
-    }
-  } else {
-    if (Ny == 4) {
-      fprintf (stderr, "warning: mode line claims 4 digit year, but 2 digit year found\n");
-    }
-    if (year < 50) year += 100;
-    year += 1900;
-  }    
-
-  /* convert yy.mm.dd hh.mm.ss to Nsec since 1970 (jd = 2440587.5) */
-  /* note that in this section, tm_mon has range 1-12, unlike for gmtime () */
-  jd = day - 32075 + (int)(1461*(year + 4800 + (int)(((month)-14)/12))/4)
-    + (int)(367*((month) - 2 - (int)(((month) - 14)/12)*12)/12)
-    - (int)(3*(int)((year + 4900 + (int)(((month) - 14)/12))/100)/4) - 0.5;
-  /* jd is the julian day of the whole day only not the time */
-  Nsec = (jd - 2440587.5)*86400 + 3600.0*hour + min*60.0 + sec;
-  
-  return (Nsec);
-
-}
-
-uppercase (char *string) {
-
-  int i;
-    
-  for (i = 0; i < strlen (string); i++) string[i] = toupper (string[i]);
-
-}
Index: unk/Ohana/src/getstar/src/wcatalog.c
===================================================================
--- /trunk/Ohana/src/getstar/src/wcatalog.c	(revision 3304)
+++ 	(revision )
@@ -1,37 +1,0 @@
-# include "addstar.h"
-
-wcatalog (Catalog *catalog) {
-  
-  int status;
-
-  /* we'll leave these for now, but they are LONEOS specific */
-  fits_modify (&catalog[0].header, "MARKSTAR", "%t", 1, FALSE);
-  fits_modify (&catalog[0].header, "ADDUSNO", "%t", 1, FALSE);
-  fits_modify (&catalog[0].header, "MARKROCK", "%t", 1, FALSE);
-
-  if (!save_catalog (catalog, VERBOSE)) {
-    fprintf (stderr, "ERROR: failure saving catalog\n");
-    exit (1);
-  }
-
-  /* free, initialize data structures */
-
-  if (catalog[0].Naverage) {
-    free (catalog[0].average); 
-    catalog[0].Naverage = 0;
-  }
-  if (catalog[0].Nmeasure) {
-    free (catalog[0].measure); 
-    catalog[0].Nmeasure = 0;
-  }
-  if (catalog[0].Nmissing) {
-    free (catalog[0].missing); 
-    catalog[0].Nmissing = 0;
-  }
-  if (catalog[0].Nsecfilt) {
-    free (catalog[0].secfilt); 
-    catalog[0].Nsecfilt = 0;
-  }
-  fits_free_header (&catalog[0].header);
-}
-
Index: unk/Ohana/src/getstar/src/wimage.c
===================================================================
--- /trunk/Ohana/src/getstar/src/wimage.c	(revision 3304)
+++ 	(revision )
@@ -1,52 +1,0 @@
-# include "getstar.h"
-
-wimage (FILE *f, int dbstate, Image *image, int Nstars) {
-  
-  int Nimages, status, mode;
-  Header header;
-
-  /* place file pointer at beginning of file */
-  fseek (f, 0, SEEK_SET);
-
-  if (dbstate == LCK_EMPTY) {
-    if (VERBOSE) fprintf (stderr, "can't find %s, creating a new one\n", ImageCat);
-    if (!fits_read_header (ImageTemplate, &header)) {
-      fprintf (stderr, "ERROR: can't find template header %s\n", ImageTemplate);
-      exit (1);
-    }
-    /* assign Zero Point provided by first image in dB */
-    fits_modify (&header, "ZERO_PT", "%lf", 1, ZeroPt);
-  } else {
-    if (!fits_load_header (f, &header)) {
-      fprintf (stderr, "ERROR: can't read image header %s\n", ImageCat);
-      exit (1);
-    }
-  }
-  
-  Nimages = 0;
-  fits_scan (&header, "NIMAGES", "%d", 1, &Nimages);
-  Nimages ++;
-  fits_modify (&header, "NIMAGES", "%d", 1, Nimages);
-
-  /* position to begining of file to write header */
-  fseek (f, 0, SEEK_SET);
-  status = Fwrite (header.buffer, 1, header.size, f, "char");
-  if (status != header.size) {
-    fprintf (stderr, "ERROR: failed writing data to image header\n");
-    exit (1);
-  }
-
-  /* position to end of file for new image data */
-  fseek (f, 0, SEEK_END);
-  status = Fwrite (image, sizeof(Image), 1, f, "image");
-  if (status != 1) {
-    fprintf (stderr, "ERROR: failed writing data to image catalog\n");
-    exit (1);
-  }
-}
-
-/* the image we add in this routine is always a new image.  
-   We only need to do two things:
-     1) append the data for the image to the end of the file
-     2) update the NIMAGES field in the header (which means, read in header, re-write)
- */
