IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jun 13, 2011, 3:52:49 PM (15 years ago)
Author:
watersc1
Message:

asinh scaling. Both writing and reading seem to function as expected, so I'm calling it done.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/czw_branch/20110406/psLib/src/fits/psFitsImage.c

    r31618 r31621  
    164164    else if (isfinite(bsoften)) {
    165165      info->is_asinh = true;
     166      info->is_logscaled = false;
    166167    }
    167168    else {
     
    510511    }
    511512    else if (info->is_asinh) {
    512       double bsoften;
     513      double bsoften,boffset;
    513514      int status;
    514515      status = 0;
    515516      fits_read_key_dbl(fits->fd, "BSOFTEN", &bsoften, NULL, &status);
    516       psImage *newImage = psFitsScaleFromDisk(outImage,0.0,bsoften);
     517      fits_read_key_dbl(fits->fd, "BOFFSET", &boffset, NULL, &status);
     518      psImage *newImage = psFitsScaleFromDisk(outImage,boffset,bsoften);
    517519      psFree (outImage);
    518520      outImage = newImage;
     
    724726    if (options&&(!((options->scaling == PS_FITS_SCALE_LOG_RANGE)||
    725727                    (options->scaling == PS_FITS_SCALE_LOG_MANUAL)||
    726                    (options->scaling == PS_FITS_SCALE_LOG_STDEV_POSITIVE)||
    727                    (options->scaling == PS_FITS_SCALE_LOG_STDEV_NEGATIVE)||
    728                    (options->scaling == PS_FITS_SCALE_LOG_STDEV_BOTH)))) {
     728                    (options->scaling == PS_FITS_SCALE_LOG_STDEV_POSITIVE)||
     729                    (options->scaling == PS_FITS_SCALE_LOG_STDEV_NEGATIVE)||
     730                    (options->scaling == PS_FITS_SCALE_LOG_STDEV_BOTH)||
     731                    (options->scaling == PS_FITS_SCALE_ASINH_RANGE)||
     732                    (options->scaling == PS_FITS_SCALE_ASINH_MANUAL)||
     733                    (options->scaling == PS_FITS_SCALE_ASINH_STDEV_POSITIVE)||
     734                    (options->scaling == PS_FITS_SCALE_ASINH_STDEV_NEGATIVE)||
     735                    (options->scaling == PS_FITS_SCALE_ASINH_STDEV_BOTH)))) {
    729736      if (psMetadataLookup(header,"BOFFSET")) {
    730737        psMetadataRemoveKey(header,"BOFFSET");
     738      }
     739    }   
     740    // Remove any BSOFTENvalues that exist in the header if we are not using that scaling anymore
     741    if (options&&(!((options->scaling == PS_FITS_SCALE_ASINH_RANGE)||
     742                    (options->scaling == PS_FITS_SCALE_ASINH_MANUAL)||
     743                    (options->scaling == PS_FITS_SCALE_ASINH_STDEV_POSITIVE)||
     744                    (options->scaling == PS_FITS_SCALE_ASINH_STDEV_NEGATIVE)||
     745                    (options->scaling == PS_FITS_SCALE_ASINH_STDEV_BOTH)))) {
     746      if (psMetadataLookup(header,"BSOFTEN")) {
     747        psMetadataRemoveKey(header,"BSOFTEN");
    731748      }
    732749    }   
     
    757774                             "Scaling: TRUE = BZERO + BSCALE * 10**(DISK) + BOFFSET)", &status);
    758775        }       
     776        if (options&&(((options->scaling == PS_FITS_SCALE_ASINH_RANGE)||
     777                       (options->scaling == PS_FITS_SCALE_ASINH_MANUAL)||
     778                       (options->scaling == PS_FITS_SCALE_ASINH_STDEV_POSITIVE)||
     779                       (options->scaling == PS_FITS_SCALE_ASINH_STDEV_NEGATIVE)||
     780                       (options->scaling == PS_FITS_SCALE_ASINH_STDEV_BOTH)))) {
     781          fits_write_key_dbl(fits->fd, "BOFFSET", boffset, 12,
     782                             "Scaling: NORM = DISK + BOFFSET", &status);
     783          fits_write_key_dbl(fits->fd, "BSOFTEN", bsoften, 12,
     784                             "Scaling: TRUE = 2 * BSOFTEN * sinh(NORM/a)",&status);
     785
     786
     787        }       
     788
    759789        if (psFitsError(status, true, "Could not write BSCALE/BZERO headers to file.")) {
    760790            success = false;
Note: See TracChangeset for help on using the changeset viewer.