Index: branches/czw_branch/20101203/psLib/src/fits/psFitsScale.c
===================================================================
--- branches/czw_branch/20101203/psLib/src/fits/psFitsScale.c	(revision 30119)
+++ branches/czw_branch/20101203/psLib/src/fits/psFitsScale.c	(revision 30255)
@@ -213,4 +213,5 @@
     switch (options->scaling) {
       case PS_FITS_SCALE_STDEV_POSITIVE:
+      case PS_FITS_SCALE_LOG_STDEV_POSITIVE:
         // Put (mean - N sigma) at the lowest possible value: predominantly positive images
         imageVal = mean - options->stdevNum * stdev;
@@ -218,4 +219,5 @@
         break;
       case PS_FITS_SCALE_STDEV_NEGATIVE:
+      case PS_FITS_SCALE_LOG_STDEV_NEGATIVE:
         // Put (mean + N sigma) at the highest possible value: predominantly negative images
         imageVal = mean + options->stdevNum * stdev;
@@ -223,4 +225,5 @@
         break;
       case PS_FITS_SCALE_STDEV_BOTH:
+      case PS_FITS_SCALE_LOG_STDEV_BOTH:
         // Put mean right in the middle: images with an equal abundance of positive and negative values
         imageVal = mean;
@@ -263,5 +266,5 @@
 	for (int x = 0; x < numCols; x++) {
 	  psF32 value = image->data.F32[y][x];
-	  if (!isfinite(value)) {
+	  if (isfinite(value)) {
 	    if (value < offset) {
 	      offset = value;
@@ -275,5 +278,5 @@
 	for (int x = 0; x < numCols; x++) {
 	  psF64 value = image->data.F64[y][x];
-	  if (!isfinite(value)) {
+	  if (isfinite(value)) {
 	    if (value < offset) {
 	      offset = value;
@@ -289,7 +292,7 @@
     }
     // We only need to offset images that go negative.
-    if (offset > 0.0) {
-      offset = 0.0;
-    }
+/*     if (offset > 0.0) { */
+/*       offset = 0.0; */
+/*     } */
     // Write offset to header
     // How?
@@ -300,4 +303,7 @@
       for (int y = 0; y < numRows; y++) {
 	for (int x = 0; x < numCols; x++) {
+	  if (x == 2331 && y == 2843) {
+	    fprintf(stderr,"psFS32: %d %d %g %g %g\n",x,y,offset,image->data.F32[y][x],log10(image->data.F32[y][x] - offset));
+	  }
 	  image->data.F32[y][x] = (log10( image->data.F32[y][x] - offset));
 	}
@@ -307,4 +313,5 @@
 	for (int y = 0; y < numRows; y++) {
 	  for (int x = 0; x < numCols; x++) {
+	    //	    fprintf(stderr,"psFS64: %d %d %g %g %g\n",x,y,offset,image->data.F64[y][x],log10(image->data.F64[y][x] - offset));
 	    image->data.F64[y][x] = (log10( image->data.F64[y][x] - offset));
 	  }
@@ -704,4 +711,8 @@
     if (strcasecmp(string, "STDEV_NEGATIVE") == 0) return PS_FITS_SCALE_STDEV_NEGATIVE;
     if (strcasecmp(string, "STDEV_BOTH") == 0)     return PS_FITS_SCALE_STDEV_BOTH;
+    if (strcasecmp(string, "LOG_RANGE") == 0)      return PS_FITS_SCALE_LOG_RANGE;
+    if (strcasecmp(string, "LOG_STDEV_POSITIVE") == 0) return PS_FITS_SCALE_LOG_STDEV_POSITIVE;
+    if (strcasecmp(string, "LOG_STDEV_NEGATIVE") == 0) return PS_FITS_SCALE_LOG_STDEV_NEGATIVE;
+    if (strcasecmp(string, "LOG_STDEV_BOTH") == 0) return PS_FITS_SCALE_LOG_STDEV_BOTH;
     if (strcasecmp(string, "MANUAL") == 0)         return PS_FITS_SCALE_MANUAL;
 
Index: branches/czw_branch/20101203/psModules/src/camera/pmFPAfileDefine.c
===================================================================
--- branches/czw_branch/20101203/psModules/src/camera/pmFPAfileDefine.c	(revision 30119)
+++ branches/czw_branch/20101203/psModules/src/camera/pmFPAfileDefine.c	(revision 30255)
@@ -282,8 +282,11 @@
               case PS_FITS_SCALE_NONE:
               case PS_FITS_SCALE_RANGE:
+	      case PS_FITS_SCALE_LOG_RANGE:
                 // No options required
                 break;
               case PS_FITS_SCALE_STDEV_POSITIVE:
               case PS_FITS_SCALE_STDEV_NEGATIVE:
+	      case PS_FITS_SCALE_LOG_STDEV_POSITIVE:
+  	      case PS_FITS_SCALE_LOG_STDEV_NEGATIVE:
                 options->stdevNum = parseOptionFloat(scheme, "STDEV.NUM", source); // Padding to edge
                 if (!isfinite(options->stdevNum)) {
@@ -295,4 +298,5 @@
                 // Flow through
               case PS_FITS_SCALE_STDEV_BOTH:
+	      case PS_FITS_SCALE_LOG_STDEV_BOTH:
                 options->stdevBits = parseOptionInt(scheme, "STDEV.BITS", source, 0); // Bits for stdev
                 if (options->stdevBits <= 0) {
