Index: trunk/Ohana/src/libdvo/src/dvo_catalog.c
===================================================================
--- trunk/Ohana/src/libdvo/src/dvo_catalog.c	(revision 8392)
+++ trunk/Ohana/src/libdvo/src/dvo_catalog.c	(revision 8394)
@@ -161,4 +161,5 @@
 // returns FALSE if a catalog could not be opened
 // returns TRUE if the catalog was empty
+// XXX allow stdout as destination (don't lock)
 enum {DVO_OPEN_NONE, DVO_OPEN_READ, DVO_OPEN_WRITE, DVO_OPEN_UPDATE);
 int dvo_catalog_open (Catalog *catalog, SkyRegion *region, int VERBOSE, char *iomode) {
@@ -203,5 +204,5 @@
   case 2:
     if (DVO_OPEN_READ || DVO_OPEN_UPDATE) return (TRUE);
-    dvo_catalog_create (region, catalog, Nsecfilt); /* fills in new header info */
+    dvo_catalog_create (region, catalog); /* fills in new header info */
     if (VERBOSE) fprintf (stderr, "creating new file %s\n", catalog[0].filename);
     break;
Index: trunk/Ohana/src/libdvo/src/dvo_catalog_create.c
===================================================================
--- trunk/Ohana/src/libdvo/src/dvo_catalog_create.c	(revision 8392)
+++ trunk/Ohana/src/libdvo/src/dvo_catalog_create.c	(revision 8394)
@@ -8,5 +8,5 @@
 // catalog[0].catformat (used by dvo_catalog_save)
 // catalog[0].lockmode
-void dvo_catalog_create (SkyRegion *region, Catalog *catalog, int Nsecfilt) {
+void dvo_catalog_create (SkyRegion *region, Catalog *catalog) {
 
   int length;
@@ -89,8 +89,10 @@
 
   /* write RA,DEC range in header */
-  gfits_modify (&catalog[0].header, "RA0",  "%lf", 1, region[0].Rmin);
-  gfits_modify (&catalog[0].header, "DEC0", "%lf", 1, region[0].Dmin);
-  gfits_modify (&catalog[0].header, "RA1",  "%lf", 1, region[0].Rmax);
-  gfits_modify (&catalog[0].header, "DEC1", "%lf", 1, region[0].Dmax);
+  if (region) {
+    gfits_modify (&catalog[0].header, "RA0",  "%lf", 1, region[0].Rmin);
+    gfits_modify (&catalog[0].header, "DEC0", "%lf", 1, region[0].Dmin);
+    gfits_modify (&catalog[0].header, "RA1",  "%lf", 1, region[0].Rmax);
+    gfits_modify (&catalog[0].header, "DEC1", "%lf", 1, region[0].Dmax);
+  }
 
   /* write creation date in header */
@@ -105,5 +107,4 @@
   ALLOCATE (catalog[0].missing, Missing, 1);
   ALLOCATE (catalog[0].secfilt, SecFilt, 1);
-  catalog[0].Nsecfilt = Nsecfilt;
 
   /* setup secondary filters to match photcodes:
@@ -113,2 +114,26 @@
 }
   
+int dvo_catalog_set_range (Catalog *catalog) {
+
+  int i;
+  double Rmin, Rmax, Dmin, Dmax;
+
+  /* determine RA,DEC range */
+  Rmin = 360.0;
+  Rmax =   0.0;
+  Dmin = +90.0;
+  Dmax = -90.0;
+  for (i = 0; i < catalog[0].Naverage; i++) {
+    Rmin = MIN (Rmin, catalog[0].average[i].R);
+    Rmax = MAX (Rmax, catalog[0].average[i].R);
+    Dmin = MIN (Dmin, catalog[0].average[i].D);
+    Dmax = MAX (Dmax, catalog[0].average[i].D);
+  }
+
+  /* write RA,DEC range in header */
+  gfits_modify (&catalog[0].header, "RA0",  "%lf", 1, Rmin);
+  gfits_modify (&catalog[0].header, "DEC0", "%lf", 1, Dmin);
+  gfits_modify (&catalog[0].header, "RA1",  "%lf", 1, Rmax);
+  gfits_modify (&catalog[0].header, "DEC1", "%lf", 1, Dmax);
+
+}
