IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jun 7, 2007, 10:43:25 AM (19 years ago)
Author:
magnier
Message:

adding code to handle extreme cases of exptime <= 0.0

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psModules/src/detrend/pmShutterCorrection.c

    r12988 r13700  
    653653    }
    654654    float exptime = psMetadataLookupF32(NULL, cell->concepts, "CELL.EXPOSURE"); // Exposure time
    655     if (!isfinite(exptime) || exptime < 0.0) {
     655    if (!isfinite(exptime)) {
    656656        psError(PS_ERR_BAD_PARAMETER_VALUE, true, "Bad exposure time: %f.\n", exptime);
    657657        return false;
     
    678678    }
    679679    psImage *image = readout->image;    // Image to correct
    680     for (int y = 0; y < image->numRows; y++) {
    681         for (int x = 0; x < image->numCols; x++) {
    682             image->data.F32[y][x] *= exptime / (exptime + shutterImage->data.F32[y][x]);
    683         }
     680
     681    if (exptime <= 0.0) {
     682        // In the extreme case that we have exptime <= 0.0, we correct the image to
     683        // counts-per-second, rather than counts in the nominal exposure time
     684        for (int y = 0; y < image->numRows; y++) {
     685            for (int x = 0; x < image->numCols; x++) {
     686                image->data.F32[y][x] *= 1.0 / (exptime + shutterImage->data.F32[y][x]);
     687            }
     688        }
     689        psMetadataAddF32 (cell->concepts, PS_LIST_TAIL, "CELL.EXPOSURE", PS_META_REPLACE, "exposure time re-normalized to 1.0", 1.0); // Exposure time
     690        psString line = NULL;
     691        psStringAppend (&line, "extreme exposure time %f, re-normalized to 1.0", exptime);
     692        psMetadataAddStr(hdu->header, PS_LIST_TAIL, "HISTORY", PS_META_DUPLICATE_OK, line, "");
     693        psFree (line);
     694    } else {
     695        for (int y = 0; y < image->numRows; y++) {
     696            for (int x = 0; x < image->numCols; x++) {
     697                image->data.F32[y][x] *= exptime / (exptime + shutterImage->data.F32[y][x]);
     698            }
     699        }
    684700    }
    685701    psFree(shutterImage);
Note: See TracChangeset for help on using the changeset viewer.