Index: unk/Ohana/src/opihi/dvo2/Makefile
===================================================================
--- /trunk/Ohana/src/opihi/dvo2/Makefile	(revision 6245)
+++ 	(revision )
@@ -1,62 +1,0 @@
-include ../../../Configure
-
-default: all
-
-HOME    =       $(ROOT)/src/opihi
-BIN     =       $(HOME)/bin
-LIB     =       $(HOME)/lib
-INC     =       $(HOME)/include
-HELP    =       $(HOME)/help
-SDIR    =       $(HOME)/dvo2
-#
-DESTBIN =       $(LBIN)
-DESTLIB =       $(LLIB)
-DESTINC =       $(LINC)
-DESTMAN =       $(LMAN)
-#  
-INCS    =       -I$(INC) -I$(LINC) -I$(XINC)
-LFLAGS  =       -L$(LLIB) -L$(LIB)
-LIBS1   =       -lsocket -lnsl -lreadline -ltermcap -ldvo -lFITS -lohana -lm
-LIBS2   =       -lbasiccmd -ldatacmd -lastrocmd -lshell -ldata 
-LIBS    =       $(LIBS2) $(LIBS1) 
-CFLAGS  =       $(INCS)
-CCFLAGS =       $(LIBS) 
-
-# dvo2 user commands and support functions ########################
-
-dvo2 = \
-$(SDIR)/init.$(ARCH).o            \
-$(SDIR)/mkregions.$(ARCH).o	  \
-$(SDIR)/skydbtile.$(ARCH).o	  \
-$(SDIR)/dvo2.$(ARCH).o
-
-libs = \
-$(DESTLIB)/libshell.a \
-$(DESTLIB)/libdata.a \
-$(DESTLIB)/libbasiccmd.a \
-$(DESTLIB)/libastrocmd.a \
-$(DESTLIB)/libdatacmd.a
-
-all: dvo2
-
-dvo2: $(BIN)/dvo2.$(ARCH)
-	@echo done
-
-$(BIN)/dvo2.$(ARCH) : $(dvo2) $(libs)
-
-install: $(DESTBIN)/dvo2
-
-mkst = \
-$(SDIR)/mkskytable.$(ARCH).o \
-$(SDIR)/skydbutils.$(ARCH).o
-
-$(BIN)/mkskytable.$(ARCH): $(mkst)
-mkskytable: $(BIN)/mkskytable.$(ARCH)
-mkskytable.install: $(DESTBIN)/mkskytable
-
-.PHONY: dvo
-.PHONY: mkskytable
-
-include ../Makefile.Common
-
-
Index: unk/Ohana/src/opihi/dvo2/dvo2.c
===================================================================
--- /trunk/Ohana/src/opihi/dvo2/dvo2.c	(revision 6245)
+++ 	(revision )
@@ -1,57 +1,0 @@
-# include "opihi.h"
-
-# define opihi_name "DVO2"
-# define opihi_prompt "dvo2: "
-# define opihi_description "an image manipulation tool\n"
-# define opihi_history ".dvo"
-# define opihi_rcfile ".dvorc"
-
-/* program-dependent initialization */
-void initialize (int argc, char **argv) {
-  
-  auto_break = TRUE;
-
-  /* load the commands used by this implementation */
-  InitBasic ();
-  InitData ();
-  InitAstro ();
-  InitDVO2 ();
-
-  rl_readline_name = opihi_name;
-  rl_attempted_completion_function = command_completer;
-
-  set_str_variable ("HISTORY", opihi_history);
-  set_str_variable ("PROMPT", opihi_prompt);
-  set_str_variable ("RCFILE", opihi_rcfile);
-# ifdef HELPDIR_DEFAULT
-  set_str_variable ("HELPDIR", MACRO_NAME(HELPDIR_DEFAULT));
-# endif
-
-  { /* check history file permission */
-    FILE *f;
-    f = fopen (opihi_history, "a");
-    if (f == NULL) /* no current history file here */
-      fprintf (stderr, "can't save history.\n");
-    else
-      fclose (f);
-    stifle_history (200);
-    read_history (opihi_history);
-  }
-
-  signal (SIGINT, SIG_IGN);
-  return;
-}
-
-/* standard welcome message */
-void welcome () {
-  fprintf (stderr, "\n");
-  fprintf (stderr, "Welcome to %s - %s\n\n", opihi_name, opihi_description);
-}
-
-/* add program-dependent exit functions here */
-void cleanup () {
-  /* -libdisplay */
-  QuitImage ();
-  QuitGraph ();
-  return;
-}
Index: unk/Ohana/src/opihi/dvo2/init.c
===================================================================
--- /trunk/Ohana/src/opihi/dvo2/init.c	(revision 6245)
+++ 	(revision )
@@ -1,17 +1,0 @@
-# include "dvo2.h"
-
-int mkregions	    PROTO((int, char **));
-
-static Command cmds[] = {  
-  {"mkregions",     mkregions,       "make region list"},
-}; 
-
-void InitDVO2 () {
-  
-  int i;
-
-  for (i = 0; i < sizeof (cmds) / sizeof (Command); i++) {
-    AddCommand (&cmds[i]);
-  }
-
-}
Index: unk/Ohana/src/opihi/dvo2/mkregions.c
===================================================================
--- /trunk/Ohana/src/opihi/dvo2/mkregions.c	(revision 6245)
+++ 	(revision )
@@ -1,35 +1,0 @@
-# include "dvo2.h"
-
-int mkregions (int argc, char **argv) {
-
-  int i, status, Nlevels, Nlist;
-  SkyRegion *list;
-
-  if (argc != 2) {
-    fprintf (stderr, "USAGE: mkregions (Nlevel)\n");
-    return (FALSE);
-  }
-  
-  Nlevels = atoi (argv[1]);
-
-  fprintf (stderr, "make regions\n");
-  list = SkyMakeRegions (Nlevels, &Nlist);
-
-  fprintf (stderr, "make names\n");
-  status = SkyMakeNames (list, NULL, 0);
-  if (!status) {
-    fprintf (stderr, "error making region names\n");
-    return (FALSE);
-  }
-
-  /*
-  for (i = 0; i < Nlist; i++) {
-    fprintf (stderr, "%24s : %10.6f - %10.6f : %10.6f - %10.6f : %3d  %3d  %3d - %3d\n", 
-	     list[i].name,
-	     list[i].Rmin, list[i].Rmax, list[i].Dmin, list[i].Dmax, 
-	     list[i].child, list[i].depth, list[i].childS, list[i].childE);
-  }
-  */
-  return (TRUE);
-
-}
Index: unk/Ohana/src/opihi/dvo2/skydb_io.c
===================================================================
--- /trunk/Ohana/src/opihi/dvo2/skydb_io.c	(revision 6245)
+++ 	(revision )
@@ -1,216 +1,0 @@
-# include "dvo2.h"
-
-/* variables which describe the skydb table */
-char *dBFile = (char *) NULL;
-FILE *f;
-Header header;
-Header theader;
-Matrix matrix;
-FTable table;
-SkyRegions *region;
-int Nregion;
-int lockstate;
-int dbstate = LCK_UNLOCK;
-
-SkyRegions *get_regions (int *N) {
-  *N = Nregion;
-  return (region);
-}
-
-int set_regions (SkyRegions *new, int Nnew) {
-
-  int Nbytes;
-
-  /* assign pointers to new data block */
-  free (region);
-  Nregion = Nnew;
-  region = new;
-
-  /* update header, table structures */
-  fits_modify (table.header, "NAXIS2", "%d", 1, Nnew);
-  table.header[0].Naxis[1] = Nnew;
-  Nbytes = fits_matrix_size (table.header);
-
-  /* add padding space to buffer */
-  REALLOCATE ((char *) region, char, Nbytes);
-  table.buffer = (char *) region;
-  table.size = Nbytes;
-
-  return (TRUE);
-}
-
-int load_db () {
-
-  int Nx, Ny;
-
-  lockstate = (output.modify || output.delete) ? LCK_HARD : LCK_SOFT;
-  header.buffer = matrix.buffer = theader.buffer = table.buffer = (char *) NULL;
-
-  if (dBFile == (char *) NULL) {
-    fprintf (stderr, "ERROR: db file is not set\n");
-    exit (1);
-  }
-
-  /* lock database (soft) */
-  f = fsetlockfile (dBFile, 300.0, lockstate, &dbstate);
-  if (dbstate == LCK_EMPTY) return (0);
-  if (f == (FILE *) NULL) {
-    fprintf (stderr, "ERROR: can't set lock on %s\n", dBFile);
-    exit (1);
-  }
-
-  /* init & load in table data */
-  table.header = &theader;
-  if (!fits_fread_header (f, &header))                   escape (UNLOCK, "ERROR: can't read primary header"); 
-  if (!fits_fread_matrix (f, &matrix, &header))          escape (UNLOCK, "ERROR: can't read primary matrix");
-  if (!fits_fread_ftable (f, &table, "SKY_REGIONS"))     escape (UNLOCK, "ERROR: can't read table");
-
-  /* convert to internal format */
-  region = (SkyRegions *) table.buffer;
-  fits_scan (table.header, "NAXIS1", "%d", 1, &Nx);  /* double check that Nx matches structure? */
-  fits_scan (table.header, "NAXIS2", "%d", 1, &Ny);
-  Nregion = Ny;
-
-  if (!ConvertStruct ((char *) region, sizeof (SkyRegions), Nregion, "skyregions"))
-    escape (UNLOCK, "ERROR: can't convert data"); 
-
-  return (1);
-}
-
-/* save complete db file */
-int save_db () {
-
-  if (!ConvertStruct ((char *) region, sizeof (SkyRegions), Nregion, "skyregions")) 
-    escape (UNLOCK, "ERROR: can't convert from native format");
-
-  /* write all regions to file */
-  make_backup (dBFile);
-  Fseek (f, 0, SEEK_SET);
-  if (!fits_fwrite_header  (f, &header))  escape (LOCK, "ERROR: can't update db");
-  if (!fits_fwrite_matrix  (f, &matrix))  escape (LOCK, "ERROR: can't update db");
-  if (!fits_fwrite_Theader (f, &theader)) escape (LOCK, "ERROR: can't update db");
-  if (!fits_fwrite_table   (f, &table))   escape (LOCK, "ERROR: can't update db");
-
-  fits_free_header (&header);
-  fits_free_matrix (&matrix);
-  fits_free_header (&theader);
-  fits_free_table  (&table);
-
-  fclearlockfile (dBFile, f, lockstate, &dbstate);
-  return (TRUE);
-}
-
-/* save subset in db file */
-int update_db (int *match, int Nmatch) {
-
-  int i, N, Nx, Ny;
-  VTable vtable;
-
-  fits_scan (table.header, "NAXIS1", "%d", 1, &Nx);
-  fits_scan (table.header, "NAXIS2", "%d", 1, &Ny);
-
-  /* make empty vtable from table */
-  vtable.header = table.header;
-  vtable.size = table.size;
-  vtable.Nrow = Ny;
-  vtable.pad = vtable.size - Nx*Ny;
-
-  /* insert selected rows in vtable */ 
-  ALLOCATE (vtable.row, int, Nmatch);
-  ALLOCATE (vtable.buffer, char *, Nmatch);
-  for (N = i = 0; i < Nmatch; i++) {
-    if (match[i] == -1) continue;
-    vtable.row[N] = match[i];
-    ALLOCATE (vtable.buffer[N], char, Nx);
-    memcpy (vtable.buffer[N], &region[match[i]], sizeof (SkyRegions));
-    ConvertStruct ((char *) vtable.buffer[N], sizeof (SkyRegions), 1, "skyregions");
-    N++;
-  }
-  vtable.Nrow = N;
-
-  /* write subset to file */
-  make_backup (dBFile);
-  Fseek (f, 0, SEEK_SET);
-  if (!fits_fwrite_header (f, &header))   escape (LOCK, "ERROR: can't update db");
-  if (!fits_fwrite_matrix (f, &matrix))   escape (LOCK, "ERROR: can't update db");
-  if (!fits_fwrite_Theader (f, &theader)) escape (LOCK, "ERROR: can't update db");
-  if (!fits_fwrite_vtable   (f, &vtable)) escape (LOCK, "ERROR: can't update db");
-
-  fits_free_header (&header);
-  fits_free_matrix (&matrix);
-  fits_free_header (&theader);
-  fits_free_vtable (&vtable);
-  fits_free_table  (&table);
-
-  fclearlockfile (dBFile, f, lockstate, &dbstate);
-  return (TRUE);
-}
-
-int append_db (SkyRegions *new, int Nnew) {
-
-  VTable vtable;
-
-  /* add error checks! */
-  fits_table_to_vtable (&table, &vtable, 0, 0);
-
-  ConvertStruct ((char *) new, sizeof (SkyRegions), Nnew, "skyregions");
-  fits_vadd_rows (&vtable, new, Nnew, sizeof(SkyRegions));
-
-  /* write subset to file */
-  Fseek (f, 0, SEEK_SET);
-  if (!fits_fwrite_header  (f, &header))  escape (LOCK, "ERROR: can't append to db");
-  if (!fits_fwrite_matrix  (f, &matrix))  escape (LOCK, "ERROR: can't append to db");
-  if (!fits_fwrite_Theader (f, &theader)) escape (LOCK, "ERROR: can't append to db");
-  if (!fits_fwrite_vtable  (f, &vtable))  escape (LOCK, "ERROR: can't append to db");
-
-  fits_free_header (&header);
-  fits_free_matrix (&matrix);
-  fits_free_header (&theader);
-  fits_free_vtable (&vtable);
-
-  fclearlockfile (dBFile, f, lockstate, &dbstate);
-  return (TRUE);
-}
-
-int create_db () {
-
-  /* f & dBFile set by load_db */
-
-  /* define table layout */
-  define_table (&header, &matrix, &theader, &table);
-
-  /* convert to internal format */
-  region = (SkyRegions *) table.buffer;
-  Nregion = 0;
-
-  return (TRUE);
-}
-
-int close_db () {
-
-  fits_free_header (&header);
-  fits_free_matrix (&matrix);
-  fits_free_header (&theader);
-
-  if (dbstate == LCK_UNLOCK) return (TRUE);
-  fclearlockfile (dBFile, f, lockstate, &dbstate);
-  return (TRUE);
-}  
-
-int close_lock_db () {
-
-  fits_free_header (&header);
-  fits_free_matrix (&matrix);
-  fits_free_header (&theader);
-
-  if (dbstate == LCK_UNLOCK) return (TRUE);
-  fclearlockfile (dBFile, f, LCK_XCLD, &dbstate);
-  return (TRUE);
-}  
-
-int escape (int mode, char *message) {
-  
-  if (mode == UNLOCK) close_db ();
-  fprintf (stderr, "%s\n", message);
-  exit (1);
-}
Index: unk/Ohana/src/opihi/dvo2/skydbsearch.c
===================================================================
--- /trunk/Ohana/src/opihi/dvo2/skydbsearch.c	(revision 6245)
+++ 	(revision )
@@ -1,201 +1,0 @@
-# include "dvo2.h"
-
-/* each region is bounded on the sky by lines of constant RA & DEC.
-   the region represents a specified depth, and it may or may not have
-   children.  The start and end of the children in the array are childS and childE 
-   If the region at the given depth is populated with an object table, then 'object' is TRUE.
-   If the region at the given depth is populated with an image table, then 'image' is TRUE.
-   I have defined no accelerators other than the table hierarchy */
-
-/* find region which overlaps c at given depth (-1 : max depth) */
-SkyRegion *SkyFindPoint (SkyRegionTable *table, double ra, double dec, int depth) {
-  
-  SkyRegion *region;
-
-  region = table[0].region;
-
-  Ns = 0;
-  Ne = 1;
-
-  while (1) {
-    No = -1;
-    for (i = Ns; (i < Ne) && (i < table[0].Nregion); i++) {
-      if (ra  < region[i].Rmin) continue;
-      if (ra  > region[i].Rmax) continue;
-      if (dec < region[i].Dmin) continue;
-      if (dec > region[i].Dmax) continue;
-      No = i;
-      break;
-    }
-    if (No == -1) return (NULL);
-    if (depth == region[No].depth) return (&region[No]);
-    if ((depth == -1) && (!region[No].child)) return (&region[No]);
-    if ((depth > region[No].depth) && !region[No].child) return (NULL);
-
-    /* need to check Ns, Ne, or guarantee valid range */
-    Ns = region[No].childS;
-    Ne = region[No].childE;
-  }
-}
-
-/* find regions at all levels which overlap c */
-SkyRegionList *SkyFindLevels (SkyRegionTable *table, double ra, double dec) {
-
-  SkyRegion *region;
-  SkyRegionList *list;
-  
-  Ns = 0;
-  Ne = 1;
-
-  N = 0;
-  NREGION = 10;
-  ALLOCATE (list, SkyRegionList, 1);
-  ALLOCATE (list[0].region,  SkyRegion *, NREGION);
-  list[0].Nregion = N;
-
-  region = table[0].region;
-
-  while (1) {
-    No = -1;
-    for (i = Ns; (i < Ne) && (i < table[0].region); i++) {
-      if (ra  < region[i].Rmin) continue;
-      if (ra  > region[i].Rmax) continue;
-      if (dec < region[i].Dmin) continue;
-      if (dec > region[i].Dmax) continue;
-      No = i;
-      break;
-    }
-    if (No == -1) return (list);
-
-    list[N] = &region[No];
-    N++;
-    if (N == NREGION) {
-      NREGION += 10;
-      REALLOCATE (list[0].region, SkyRegion *, NREGION);
-    }      
-    list[0].Nregion = N;
-
-    /* need to check Ns, Ne, or guarantee valid range */
-    if (region[No].child) {
-      Ns = region[No].childS;
-      Ne = region[No].childE;
-    } else {
-      return (list);
-    }
-  }
-}
-
-/* find regions contained within rectangular region  c1 - c2 */
-SkyRegion **SkyFindArea (SkyRegion *db, SkyCoord c1, SkyCoord c2, int *nlist) {
-
-  int Nlist;
-  SkyRegion *list, *new, *sub;
-
-  while (c1.r > 360.0) c1.r -= 360.0;
-  while (c1.r <   0.0) c1.r += 360.0;
-  while (c2.r > 360.0) c2.r -= 360.0;
-  while (c2.r <   0.0) c2.r += 360.0;
-
-  /* check on c1.r > c2.r : cross boundary */
-  if (c1.r > c2.r) {
-    c0 = c2; c0.r = 360.0;
-    list = SkyFindArea (db, c1, c0, &Nlist);
-    c0 = c1; c0.r = 0.0;
-    new  = SkyFindArea (db, c0, c2, &Nnew);
-    REALLOCATE (list, SkyRegion *, MAX (1, Nlist + Nnew));
-    memcpy (&list[Nlist], new, Nnew*sizeof(SkyRegion *));
-    free (new);
-    Nlist += Nnew;
-    *nlist = Nlist;
-    return (list);
-  }    
-
-  Ns = 0;
-  Ne = 1;
-  Nlist = 1;
-  ALLOCATE (list, SkyRegion *, Nlist);
-  list[0] = &region[0];
-  getchild = region[0].child;
-
-  while (getchild) {
-
-    getchild = FALSE;
-    Nnew = 0;
-    NNEW = 100;
-    ALLOCATE (new, SkyRegion *, NNEW);
-
-    for (i = Ns; i < Ne; i++) {
-      children = SkyFindChildren(db, list[i], c1, c2, &Nchildren);
-      if (children == NULL) continue;
-      if (Nnew + Nchildren >= NNEW) {
-	NNEW += 100;
-	REALLOCATE (new, SkyRegion *, NNEW);
-      }
-      for (i = 0; i < Nchildren; i++) {
-	getchild |= children[i][0].child;
-	new[Nnew] = children[i];
-	Nnew++;
-      }
-      free (children);
-    }
-
-    REALLOCATE (list, SkyRegion *, Nlist + Nnew);
-    memcpy (&list[Nlist], new, Nnew*sizeof(SkyRegion *));
-    free (new);
-    Nlist += Nnew;
-  }
-  return (list);
-  *nlist = Nlist;
-}
-
-/* find all children of the given sky region */
-SkyRegion **SkyFindChildren (SkyRegion *db, SkyRegion *parent, SkyCoord c1, SkyCoord c2, int *Nchildren) {
-
-  int i, Ns, Ne, Nregion, NREGION;
-  SkyRegion **region;
-  
-  *Nchildren = 0;
-  if (!parent[0].child) return (NULL);
-
-  Ns = parent[0].childS;
-  Ne = parent[0].childE;
-
-  Nregion = 0;
-  NREGION = 100;
-  ALLOCATE (region, SkyRegion *, NREGION);
-
-  for (i = Ns; i < Ne; i++) {
-    if (region[i].Rmax < c1.r) continue;
-    if (region[i].Rmin > c2.r) continue;
-    if (region[i].Dmax < c1.d) continue;
-    if (region[i].Dmin > c2.d) continue;
-    region[Nregion] = &region[i];
-    Nregion++;
-    if (Nregion == NREGION) {
-      NREGION += 100;
-      REALLOCATE (region, SkyRegion *, NREGION);
-    }      
-  }
-  *Nchildren = Nregion; 
-  return (region);
-}
-
-/* region is pointer to entry in db */
-SkyRegion *SkyExtend (SkyRegion *db, SkyRegion *region) {
-
-}
-
-/* region is pointer to entry in db */
-SkyRegion *SkyContract (SkyRegion *db, SkyRegion *region) {
-
-}
-
-SkyRegion *SkyFindGCircle (SkyRegion *db, SkyCoord c1, SkyCoord c2) {
-
-}
-
-
-/* is entire db in memory, or do we load from disk for each operation? 
-   10,000 at level 3, 100,000 @ 4 : 0.5MB, 5MB */
-
-
Index: unk/Ohana/src/opihi/dvo2/skydbtile.c
===================================================================
--- /trunk/Ohana/src/opihi/dvo2/skydbtile.c	(revision 6245)
+++ 	(revision )
@@ -1,283 +1,0 @@
-# include "dvo2.h"
-SkyRegion *SkyDivideList (SkyRegion *list, int Nlist);
-
-/* region names:
-
- depth Ntables  Name 
- 0     1      	fullsky.cpt
- 1     16     	n????.cpt, s????.cpt
- 2     256    	n????/r????.cpt
- 3     4096   	n????/t????.cpt
- 4     65536  	n????/r????/r????.cpt
- 5     1.0+06  	n????/t????/t????.cpt
- 6     1.7+07  	n????/r????/r????/r????.cpt
-
- depth Ntables  Name 
- 0     1      	fullsky
- 1     16     	d%02
- 2     256    	d%02/r%03d
- 3     4096   	d%02/t%04d
- 4     65536  	d%02/r%03d/r%03d
- 5     1.0+06  	d%02/t%04d/t%04d
- 6     1.7+07  	d%02/r%03d/r%03d/r%03d
- 7     2.7+08  	d%02/t%04d/t%04d/t%04d
-
-*/
-
-/* a valid SkyRegion set must always start with the fullsky as the first entry, 
-   with the sequence of entries ordered primarily by depth, followed by parent 
-*/
-
-int SkyMakeNames (SkyRegion *db, SkyRegion *ref, int depth) {
-
-  int i, j, N, Ns, Ne, ns, ne;
-
-  if (db == NULL) return (FALSE);
-  if (depth == 0) {
-    if (db[0].depth != 0) return (FALSE);
-    strcpy (db[0].name, "fullsky");
-    Ns = db[0].childS;
-    Ne = db[0].childE;
-    for (i = Ns; i < Ne; i++) {
-      sprintf (db[i].name, "d%02d", i - 1);
-      if (!SkyMakeNames (db, &db[i], 2)) return (FALSE);
-      if (!SkyMakeNames (db, &db[i], 3)) return (FALSE);
-    }
-    return (TRUE);
-  }
-
-  if (ref == NULL) return (FALSE);
-  
-  if (depth == 2) {
-    if (!ref[0].child) return (TRUE);
-    Ns = ref[0].childS;
-    Ne = ref[0].childE;
-    N = 0;
-    for (i = Ns; i < Ne; i++, N++) {
-      sprintf (db[i].name, "%s/r%02d", ref[0].name, N);
-      if (!SkyMakeNames (db, &db[i], depth + 2)) return (FALSE);
-    }
-  }
-  
-  if (depth > 2) {
-    Ns = ref[0].childS;
-    Ne = ref[0].childE;
-    N = 0;
-    for (i = Ns; i < Ne; i++) {
-      if (!ref[0].child) continue;
-      ns = db[i].childS;
-      ne = db[i].childE;
-      for (j = ns; j < ne; j++, N++) {
-	if (depth % 2) {
-	  sprintf (db[j].name, "%s/t%03d", ref[0].name, N);
-	} else {				      			    
-	  sprintf (db[j].name, "%s/r%02d", ref[0].name, N);
-	}
-	if (!SkyMakeNames (db, &db[j], depth + 2)) return (FALSE);
-      }
-    }  
-  }
-}
-
-SkyRegion *SkyMakeRegions (int Nlevels, int *nlist) {
-
-  int Nlist, Nnext, Ncurr, i, j;
-  SkyRegion *list, *curr, *next;
-
-  Nlist = 0;
-  Nnext = 1;
-  Ncurr = 1;
-  ALLOCATE (list, SkyRegion, Ncurr);
-  ALLOCATE (curr, SkyRegion, Ncurr);
-
-  curr[0].Rmin =   0;
-  curr[0].Rmax = 360;
-  curr[0].Dmin = -90;
-  curr[0].Dmax =  90;
-  curr[0].depth = 0;
-  curr[0].object = FALSE;
-  curr[0].image = FALSE;
-  curr[0].child = FALSE;
-  curr[0].childS = 0;
-  curr[0].childE = 0;
-
-  for (i = 1; i < Nlevels; i++) {
-    next  = SkyDivideRegions (curr, &Nnext);
-    for (j = 0; j < Nnext; j++) {
-      next[j].depth = i;
-    }   
-    REALLOCATE (list, SkyRegion, Nlist + Ncurr);
-    memcpy (&list[Nlist], curr, Ncurr*sizeof(SkyRegion));
-    for (j = Nlist; j < Nlist + Ncurr; j++) {
-      list[j].childS += Nlist + Ncurr;
-      list[j].childE += Nlist + Ncurr;
-    }
-    Nlist += Ncurr;
-    free (curr);
-    curr = next;
-    Ncurr = Nnext;
-  }
-  REALLOCATE (list, SkyRegion, Nlist + Ncurr);
-  memcpy (&list[Nlist], curr, Ncurr*sizeof(SkyRegion));
-  Nlist += Ncurr;
-  free (curr);
-
-  list[0].object = TRUE;
-  list[0].image = TRUE;
-  *nlist = Nlist;
-  return (list);
-}
-
-SkyRegion *SkyDivideRegions (SkyRegion *parents, int *N) {
-
-  int i, Nchildren, Nparents, Np;
-  SkyRegion *children, *temp;
-  float *child, *index;
-
-  Nchildren = Nparents = *N;
-
-  /* copy input list to a new list, set child to be sequence number */
-  ALLOCATE (children, SkyRegion, Nchildren);
-  memcpy (children, parents, Nchildren*sizeof(SkyRegion));
-  for (i = 0; i < Nchildren; i++) {
-    children[i].childS = i;
-    parents[i].childS = i;
-  }
-
-  /* double the number of children, dividing only the largest in half each pass */
-  for (i = 0; i < 4; i++) {
-    temp = SkyDivideList (children, Nchildren);
-    free (children);
-    children = temp;
-    Nchildren *= 2;
-  }
-
-  /* sort children by childS (currently is parent entry) */
-  ALLOCATE (child, float, Nchildren);
-  ALLOCATE (index, float, Nchildren);
-  for (i = 0; i < Nchildren; i++) {
-    index[i] = i;
-    child[i] = children[i].childS;
-  }
-  fsortpair (child, index, Nchildren);
-  ALLOCATE (temp, SkyRegion, Nchildren);
-  for (i = 0; i < Nchildren; i++) {
-    temp[i] = children[(int)index[i]];
-  }
-  free (children);
-  free (child);
-  free (index);
-  children = temp;
-  
-  /* look for all matching values of childS, setup parent values of childS, childE */
-  Np = children[0].childS;
-  parents[Np].childS = 0;
-  parents[Np].child = TRUE;
-  for (i = 0; i < Nchildren; i++) {
-    if (children[i].childS != Np) {
-      parents[Np].childE = i;
-      Np = children[i].childS;
-      parents[Np].childS = i;
-      parents[Np].child = TRUE;
-    }
-    children[i].childS = 0;
-    children[i].childE = 0;
-    children[i].child = FALSE;
-  }
-  parents[Np].childE = i;
-  *N = Nchildren;
-  return (children);
-}
-
-/* always break the region with the largest area */
-SkyRegion *SkyDivideBiggest (SkyRegion *list, int *nlist) {
-
-  int i, N, Nlist;
-  float *area, *indx, dec;
-  SkyRegion *out, save;
-
-  Nlist = *nlist;
-  ALLOCATE (area, float, Nlist);
-  ALLOCATE (indx, float, Nlist);
-  for (i = 0; i < Nlist; i++) {
-    dec = 0.5*(list[i].Dmax + list[i].Dmin);
-    area[i] = (list[i].Rmax - list[i].Rmin)*(list[i].Dmax - list[i].Dmin)*cos(RAD_DEG*dec);
-    indx[i] = i;
-  }
-  fsortpair (area, indx, Nlist);
-
-  N = indx[Nlist - 1];
-  out = SkyDivide (&list[N]);
-  
-  REALLOCATE (list, SkyRegion, Nlist + 1);
-  list[N] = out[0];
-  list[Nlist] = out[1];
-
-  *nlist = Nlist + 1;
-  free (out);
-  free (area);
-  free (indx);
-  return (list);
-}
-
-SkyRegion *SkyDivide (SkyRegion *in) {
-
-  SkyRegion *out;
-  double RA, DEC, R_div, D_div;
-
-  ALLOCATE (out, SkyRegion, 2);
-
-  out[0] = in[0];
-  out[1] = in[0];
-
-  RA  = 0.5*(in[0].Rmin + in[0].Rmax);
-  DEC = 0.5*(in[0].Dmin + in[0].Dmax);
-  if ((DEC >= 90) || (DEC <= -90)) {
-    fprintf (stderr, "error in Dmin");
-    return (NULL);
-  }
- 
-  D_div = (in[0].Rmax - in[0].Rmin) * cos (RAD_DEG*DEC);
-  R_div = (in[0].Dmax - in[0].Dmin);
-  if (R_div < D_div) {
-    /* divide RA range */
-    out[0].Rmax = RA;
-    out[1].Rmin = RA;
-  } else {
-    out[0].Dmax = DEC;
-    out[1].Dmin = DEC;
-  }
-
-  return (out);
-}
-
-/* return a list with 2x as many entries, each split in two */
-SkyRegion *SkyDivideList (SkyRegion *in, int Nin) {
-
-  SkyRegion *out;
-  double RA, DEC, R_div, D_div;
-  int i;
-
-  ALLOCATE (out, SkyRegion, 2*Nin);
-
-  for (i = 0; i < Nin; i++) {
-    /* inherit properties from parent */
-    out[2*i + 0] = in[i];
-    out[2*i + 1] = in[i];
-
-    RA  = 0.5*(in[i].Rmin + in[i].Rmax);
-    DEC = 0.5*(in[i].Dmin + in[i].Dmax);
-    
-    /* split along longest axis */
-    D_div = (in[i].Rmax - in[i].Rmin) * cos (RAD_DEG*DEC);
-    R_div = (in[i].Dmax - in[i].Dmin);
-    if (R_div < D_div) {
-      out[2*i + 0].Rmax = RA;
-      out[2*i + 1].Rmin = RA;
-    } else {
-      out[2*i + 0].Dmax = DEC;
-      out[2*i + 1].Dmin = DEC;
-    }
-  }
-  return (out);
-}
