IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 16672


Ignore:
Timestamp:
Feb 26, 2008, 2:35:41 PM (18 years ago)
Author:
Paul Price
Message:

Trying to make the scaling of floating-point images a bit more robust. We don't want a write dying because it can't determine a suitable BSCALE and BZERO --- we need to save the write somehow, anyhow! So, if in doubt, use 1 and 0.

Location:
trunk/psLib/src/fits
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/src/fits/psFitsImage.c

    r16185 r16672  
    77 *  @author Robert DeSonia, MHPCC
    88 *
    9  *  @version $Revision: 1.24 $ $Name: not supported by cvs2svn $
    10  *  @date $Date: 2008-01-23 03:08:03 $
     9 *  @version $Revision: 1.25 $ $Name: not supported by cvs2svn $
     10 *  @date $Date: 2008-02-27 00:35:41 $
    1111 *
    1212 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    285285            // Choose an appropriate BSCALE and BZERO
    286286            if (!psFitsScaleDetermine(bscale, bzero, image, fits)) {
    287                 psError(PS_ERR_UNKNOWN, false, "Unable to determine BSCALE and BZERO for image.");
    288                 return NULL;
     287                // We can't have the write dying for this reason --- try to save it somehow!
     288                psWarning("Unable to determine BSCALE and BZERO for image --- setting to 1.0, 0.0");
     289                psErrorStackClear();
    289290            }
    290291        } else {
  • trunk/psLib/src/fits/psFitsScale.c

    r16197 r16672  
    288288        for (int y = 0; y < numRows; y++) { \
    289289            for (int x = 0; x < numCols; x++) { \
    290                 ps##INTYPE value = ((IN)->data.INTYPE[y][x] - zero) * scale; \
    291                 if (options->fuzz) { \
    292                    /* Add random factor [0,1): adds a variance of 1/12, */ \
    293                    /* but preserves the expectation value */ \
    294                     value += psRandomUniform(rng); \
     290                ps##INTYPE value = (IN)->data.INTYPE[y][x]; \
     291                if (!isfinite(value)) { \
     292                    /* This choice of "max" for non-finite pixels is mainly cosmetic --- it has to be */ \
     293                    /* something, and "min" would produce holes in the cores of bright stars. */ \
     294                    (OUT)->data.OUTTYPE[y][x] = max; \
     295                } else { \
     296                    value = (value - zero) * scale; \
     297                    if (options->fuzz) { \
     298                       /* Add random factor [0,1): adds a variance of 1/12, */ \
     299                       /* but preserves the expectation value */ \
     300                        value += psRandomUniform(rng); \
     301                    } \
     302                    /* Check for underflow and overflow */ \
     303                    (OUT)->data.OUTTYPE[y][x] = (value < min ? min : (value > max ? max : value)); \
    295304                } \
    296                 /* Check for underflow and overflow */ \
    297                 (OUT)->data.OUTTYPE[y][x] = (value < min ? min : (value > max ? max : value)); \
    298305            } \
    299306        } \
Note: See TracChangeset for help on using the changeset viewer.