IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jun 8, 2011, 2:41:13 PM (15 years ago)
Author:
watersc1
Message:

compilable version of updated stack code (doesn't correctly reject) and asinh scaling (completely untested).

File:
1 edited

Legend:

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

    r31606 r31618  
    5555    int psDatatype;                     // psLib data type
    5656    bool is_logscaled;                  // is this image log scaled using BOFFSET?
     57    bool is_asinh;                      // is this image asinh scaled using BSOFTEN?
    5758} p_psFitsReadInfo;
    5859
     
    129130
    130131    // Check scale and zero
    131     double bscale = 0.0, bzero = 0.0, boffset = NAN;    // Scale and zero point
     132    double bscale = 0.0, bzero = 0.0, boffset = NAN, bsoften = NAN;    // Scale and zero point
    132133    if (fits_read_key_dbl(fits->fd, "BSCALE", &bscale, NULL, &status) && status != KEY_NO_EXIST) {
    133134        psFitsError(status, true, "Unable to read header.");
     
    153154      info->is_logscaled = false;
    154155    }
     156    status = 0;
     157    if (fits_read_key_dbl(fits->fd, "BSOFTEN", &bsoften, NULL, &status) && status != KEY_NO_EXIST) {
     158        psFitsError(status, true, "Unable to read header.");
     159        goto bad;
     160    }
     161    if (status == KEY_NO_EXIST) {
     162      info->is_asinh = false;
     163    }
     164    else if (isfinite(bsoften)) {
     165      info->is_asinh = true;
     166    }
     167    else {
     168      info->is_asinh = false;
     169    }
     170
    155171    status = 0;
    156172
     
    262278                                          double *bzero, // Zero point applied
    263279                                          double *boffset, // Log offset applied
     280                                          double *bsoften, // asinh offset applied
    264281                                          long *blank, // Blank value (integer data)
    265282                                          psFitsFloat *floatType, // Type of custom floating-point
     
    275292    psAssert(bzero, "impossible");
    276293    psAssert(boffset, "impossible");
     294    psAssert(bsoften, "impossible");
    277295    psAssert(floatType, "impossible");
    278296    psAssert(fits, "impossible");
     
    322340        if (newScaleZero) {
    323341            // Choose an appropriate BSCALE and BZERO
    324           if (!psFitsScaleDetermine(bscale, bzero, boffset, blank, image, mask, maskVal, fits)) {
     342          if (!psFitsScaleDetermine(bscale, bzero, boffset, bsoften, blank, image, mask, maskVal, fits)) {
    325343                // We can't have the write dying for this reason --- try to save it somehow!
    326344                psWarning("Unable to determine BSCALE and BZERO for image --- refusing to quantise.");
     
    348366        }
    349367
    350         return psFitsScaleForDisk(image, fits, *bscale, *bzero, *boffset, rng);
     368        return psFitsScaleForDisk(image, fits, *bscale, *bzero, *boffset, *bsoften, rng);
    351369    }
    352370
     
    487505      status = 0;
    488506      fits_read_key_dbl(fits->fd, "BOFFSET", &boffset, NULL, &status);
    489       psImage *newImage = psFitsScaleFromDisk(outImage,boffset);
     507      psImage *newImage = psFitsScaleFromDisk(outImage,boffset,0.0);
     508      psFree (outImage);
     509      outImage = newImage;
     510    }
     511    else if (info->is_asinh) {
     512      double bsoften;
     513      int status;
     514      status = 0;
     515      fits_read_key_dbl(fits->fd, "BSOFTEN", &bsoften, NULL, &status);
     516      psImage *newImage = psFitsScaleFromDisk(outImage,0.0,bsoften);
    490517      psFree (outImage);
    491518      outImage = newImage;
     
    602629    double bscale = NAN, bzero = NAN;   // Scale and zero point to put in header
    603630    double boffset = NAN;               // Log offset to put into header.
     631    double bsoften = NAN;               // Asinh softening parameter to put into header
    604632    long blank = 0;                     // Blank (undefined) value for image
    605633    psFitsFloat floatType;              // Custom floating-point convention type
    606     psImage *diskImage = imageToDiskRepresentation(&bscale, &bzero, &boffset, &blank, &floatType, fits, image,
     634    psImage *diskImage = imageToDiskRepresentation(&bscale, &bzero, &boffset, &bsoften, &blank, &floatType, fits, image,
    607635                                                   mask, maskVal, NULL, true); // Image to write out
    608636    if (!diskImage) {
     
    831859    double bscale = NAN, bzero = NAN;   // Scale and zero point to put in header
    832860    double boffset = NAN;               // Log offset to put in header
     861    double bsoften = NAN;               // Asinh softening parameter to put in header
    833862    long blank = 0;                     // Blank (undefined) value for image
    834863    psFitsFloat floatType;              // Custom floating-point convention type
    835     psImage *diskImage = imageToDiskRepresentation(&bscale, &bzero, &boffset, &blank, &floatType, fits, input,
     864    psImage *diskImage = imageToDiskRepresentation(&bscale, &bzero, &boffset, &bsoften, &blank, &floatType, fits, input,
    836865                                                   mask, maskVal, NULL, false); // Image to write out
    837866    if (!diskImage) {
Note: See TracChangeset for help on using the changeset viewer.