Index: trunk/Ohana/src/relphot/include/relphot.h
===================================================================
--- trunk/Ohana/src/relphot/include/relphot.h	(revision 39641)
+++ trunk/Ohana/src/relphot/include/relphot.h	(revision 39642)
@@ -355,4 +355,5 @@
 char *UserCatalog;
 
+int USE_ALL_IMAGES;
 int USE_BASIC_CHECK;
 int USE_FULL_OVERLAP;
@@ -437,5 +438,5 @@
 Catalog      *load_catalogs_parallel PROTO((SkyList *sky, int *Ncatalog, char *syncfile));
 
-int           load_images         PROTO((FITS_DB *db, SkyList *skylist, SkyRegion *region, int unlockImages));
+int           load_images         PROTO((FITS_DB *db, SkyList *skylist, SkyRegion *region, int unlockImages, int UseAllImages));
 Image        *select_images       PROTO((SkyList *skylist, Image *timage, off_t Ntimage, char *inSubset, off_t **LineNumber, off_t *Nimage, SkyRegion *region));
 
Index: trunk/Ohana/src/relphot/src/ImageOps.c
===================================================================
--- trunk/Ohana/src/relphot/src/ImageOps.c	(revision 39641)
+++ trunk/Ohana/src/relphot/src/ImageOps.c	(revision 39642)
@@ -615,5 +615,5 @@
 void setMcal (Catalog *catalog, int PoorImages, FlatCorrectionTable *flatcorr) {
 
-  off_t i, j, m, c, n, N, Nmax;
+  off_t i, j, m, c, n, Nmax;
   int mark, bad, Nfew, Nbad, Nmos, Nrel, Ngrid, Nsys;
   float Msys, Mrel, Mmos, Mgrid, Mflat;
@@ -787,5 +787,5 @@
     if (PLOTSTUFF) {
       fprintf (stderr, "Mcal for : %s : %7.4f %7.4f\n", image[i].name, image[i].Mcal, image[i].dMcal);
-      plot_setMcal (refStars->flxlist, N, &stats, CLOUD_TOLERANCE);
+      plot_setMcal (refStars->flxlist, Nref, &stats, CLOUD_TOLERANCE);
     }
 
Index: trunk/Ohana/src/relphot/src/args.c
===================================================================
--- trunk/Ohana/src/relphot/src/args.c	(revision 39641)
+++ trunk/Ohana/src/relphot/src/args.c	(revision 39642)
@@ -56,4 +56,13 @@
     UserCatalog = strcreate (argv[N]);
     remove_argument (N, &argc, argv);
+  }
+
+  // If we are looking at the whole sky (or whole relevant sky), use the full image table
+  // -- this save substantial memory.  this could be automatic if the skyregion covers
+  // more than 2pi.
+  USE_ALL_IMAGES = FALSE;
+  if ((N = get_argument (argc, argv, "-use-all-images"))) {
+    remove_argument (N, &argc, argv);
+    USE_ALL_IMAGES = TRUE;
   }
 
@@ -603,4 +612,10 @@
   }
 
+  USE_ALL_IMAGES = FALSE;
+  if ((N = get_argument (argc, argv, "-use-all-images"))) {
+    remove_argument (N, &argc, argv);
+    USE_ALL_IMAGES = TRUE;
+  }
+
   USE_BASIC_CHECK = FALSE;
   if ((N = get_argument (argc, argv, "-basic-image-search"))) {
Index: trunk/Ohana/src/relphot/src/load_images.c
===================================================================
--- trunk/Ohana/src/relphot/src/load_images.c	(revision 39641)
+++ trunk/Ohana/src/relphot/src/load_images.c	(revision 39642)
@@ -5,5 +5,5 @@
 // This function generates a subset of the images based on selections.  Input db has already
 // been loaded with the raw fits table data
-int load_images (FITS_DB *db, SkyList *skylist, SkyRegion *region, int unlockImages) {
+int load_images (FITS_DB *db, SkyList *skylist, SkyRegion *region, int unlockImages, int UseAllImages) {
 
   Image     *image, *subset;
@@ -31,11 +31,26 @@
 
   // select the images which overlap the selected sky regions
-  // 'subset' points to a new copy of the data (different from 'image')
-  subset = select_images (skylist, image, Nimage, inSubset, &LineNumber, &Nsubset, region);
-  MARKTIME("selected %d overlapping images: %f sec\n", (int) Nsubset, dtime);
+  // 'subset' points to a new copy of the data (different from 'image') if a subset is selected
+  if (UseAllImages) {
+    ALLOCATE (LineNumber, off_t, Nimage);
+    for (off_t i = 0; i < Nimage; i++) {
+      LineNumber[i] = i;
+      inSubset[i] = TRUE;
+    }
+    subset  = image;
+    Nsubset = Nimage;
+  } else {
+    subset = select_images (skylist, image, Nimage, inSubset, &LineNumber, &Nsubset, region);
+    MARKTIME("selected %d overlapping images: %f sec\n", (int) Nsubset, dtime);
 
-  if (Nimage == 0) {
-    fprintf (stderr, "no images selected for analysis : problem with region or photcode?\n");
-    exit (4);
+    if (Nimage == 0) {
+      fprintf (stderr, "no images selected for analysis : problem with region or photcode?\n");
+      exit (4);
+    }
+
+    if (Nsubset == Nimage) {
+      free (subset);
+      subset = image;
+    }
   }
 
Index: trunk/Ohana/src/relphot/src/relphot_images.c
===================================================================
--- trunk/Ohana/src/relphot/src/relphot_images.c	(revision 39641)
+++ trunk/Ohana/src/relphot/src/relphot_images.c	(revision 39642)
@@ -39,5 +39,5 @@
 
   /* load regions and images based on specified sky patch and/or catalog */
-  load_images (&db, skylist, &UserPatch, FALSE);
+  load_images (&db, skylist, &UserPatch, FALSE, USE_ALL_IMAGES);
   MARKTIME("-- load images: %f sec\n", dtime);
 
Index: trunk/Ohana/src/relphot/src/relphot_objects.c
===================================================================
--- trunk/Ohana/src/relphot/src/relphot_objects.c	(revision 39641)
+++ trunk/Ohana/src/relphot/src/relphot_objects.c	(revision 39642)
@@ -38,5 +38,5 @@
 
   /* load regions and images based on specified sky patch (default depth) */
-  load_images (&db, skylist, &UserPatch, TRUE);
+  load_images (&db, skylist, &UserPatch, TRUE, USE_ALL_IMAGES);
   MARKTIME("loaded images: %f sec\n", dtime);
 
@@ -249,4 +249,5 @@
     if (SYNTH_ZERO_POINTS) { strextend (&command, "-synthphot-zpts %s", SYNTH_ZERO_POINTS); }
     if (USE_BASIC_CHECK)   { strextend (&command, "-basic-image-search"); }
+    if (USE_ALL_IMAGES)    { strextend (&command, "-use-all-images"); }
 
     if (!(STAGES & STAGE_CHIP))  { strextend (&command, "-skip-chip"); }
