Index: /branches/eam_branches/20090715/Ohana/src/opihi/dvo/skycoverage.c
===================================================================
--- /branches/eam_branches/20090715/Ohana/src/opihi/dvo/skycoverage.c	(revision 25635)
+++ /branches/eam_branches/20090715/Ohana/src/opihi/dvo/skycoverage.c	(revision 25636)
@@ -16,4 +16,6 @@
   Coords coords;
   int typehash;
+  int PhotcodeSelect;
+  PhotCode *PhotcodeValue;
 
   WITH_MOSAIC = FALSE;
@@ -43,4 +45,18 @@
     remove_argument (N, &argc, argv);
     ByName = TRUE;
+  }
+
+  PhotcodeValue = NULL;
+  PhotcodeSelect = FALSE;
+  if ((N = get_argument (argc, argv, "-photcode"))) {
+    if (!InitPhotcodes ()) return (FALSE);
+    PhotcodeSelect = TRUE;
+    remove_argument (N, &argc, argv);
+    PhotcodeValue = GetPhotcodebyName (argv[N]);
+    if (PhotcodeValue == NULL) {
+      gprint (GP_ERR, "photcode not found in photcode table\n");
+      return (FALSE);
+    }
+    remove_argument (N, &argc, argv);
   }
 
@@ -85,5 +101,6 @@
  
   if (argc != 4) {
-    gprint (GP_ERR, "USAGE: skycoverage (buffer) (pixscale) (Npts) [-time start range] [-name name]\n");
+    gprint (GP_ERR, "USAGE: skycoverage (buffer) (pixscale) (Npts)\n");
+    gprint (GP_ERR, "  options: [-time start range] [-trange start stop] [-name name] [-photcode name] [+mosaic] [-mosaic] [-ra-center RA]\n");
     gprint (GP_ERR, "       (buffer) saves bitmapped AIT plot\n");
     gprint (GP_ERR, "       (pixscale) specifies the pixel size in degrees\n");
@@ -128,6 +145,6 @@
     for (xs = 0; xs < Nx; xs++) {
       status = XY_to_RD (&r, &d, (double)(xs), (double)(ys), &coords);
-      status &= (r > 0);
-      status &= (r < 360);
+      status &= (r >= 0);
+      status &= (r <= 360);
       if (status) {
 	V[ys*Nx + xs] = 2;
@@ -141,4 +158,13 @@
     if (ByName && strcmp (name, image[i].name)) continue;
     if (TimeSelect && ((image[i].tzero < tzero) || (image[i].tzero+image[i].trate*image[i].NY > tzero + trange))) continue;
+
+    if (PhotcodeSelect) {
+      if (PhotcodeValue[0].type == PHOT_DEP) {
+	if (PhotcodeValue[0].code != image[i].photcode) continue;
+      } else {
+	if (PhotcodeValue[0].code != GetPhotcodeEquivCodebyCode (image[i].photcode)) continue;
+      }
+    }
+
     if (!FindMosaicForImage (image, Nimage, i)) continue;
 
@@ -167,4 +193,6 @@
 	XY_to_RD (&r, &d, Xi, Yi, &image[i].coords);
 	r = ohana_normalize_angle (r);
+	if (r - RaCenter > +180.0) r -= 360.0;
+	if (r - RaCenter < -180.0) r += 360.0;
 	status = RD_to_XY (&Xs, &Ys, r, d, &coords);
 	if (Xs < 0) continue;
