IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Nov 25, 2008, 5:24:53 PM (17 years ago)
Author:
bills
Message:

correct handling of compression parameters when it's turned on or
off

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/magic/remove/src/streaksremove.c

    r20817 r20844  
    406406    if (sf->stage == IPP_STAGE_CHIP) {
    407407        // For the chip level files, copy the WCS from the astrometry file to the header
    408         updateAstrometry = true;
    409         if (!pmAstromWriteWCS(sf->inImage->header, sf->inAstrom->fpa, sf->chip, 0.001)) {
    410             psError(PS_ERR_UNKNOWN, false, "failed to update astrometry for extension %d", sf->extnum);
    411             streaksExit("", PS_EXIT_UNKNOWN_ERROR);
     408        if (!sf->bilevelAstrometry) {
     409            updateAstrometry = true;
     410            if (!pmAstromWriteWCS(sf->inImage->header, sf->inAstrom->fpa, sf->chip, 0.001)) {
     411                psError(PS_ERR_UNKNOWN, false, "failed to update astrometry for extension %d", sf->extnum);
     412                streaksExit("", PS_EXIT_UNKNOWN_ERROR);
     413            }
    412414        }
    413415    }
     
    447449    if (sf->inMask) {
    448450        readImage(sf->inMask, sf->extnum, sf->stage);
    449         if (updateAstrometry) {
    450             pmAstromWriteWCS(sf->outMask->header, sf->inAstrom->fpa, sf->chip, 0.001);
    451         }
    452451        sf->outMask->header = (psMetadata*) psMemIncrRefCounter(sf->inMask->header);
    453452        if (sf->recMask) {
    454453            sf->recMask->header = (psMetadata*) psMemIncrRefCounter(sf->inMask->header);
    455454        }
     455        if (updateAstrometry) {
     456            pmAstromWriteWCS(sf->outMask->header, sf->inAstrom->fpa, sf->chip, 0.001);
     457        }
    456458
    457459        setupImageRefs(sf->outMask, sf->recMask, sf->inMask, sf->extnum, exciseAll);
    458460
     461#ifdef STREAKS_COMPRESS_OUTPUT
    459462        // XXX: see note above
    460463        copyFitsOptions(sf->outMask, sf->recMask, sf->inMask);
    461464        psFitsSetCompression(sf->outMask->fits, PS_FITS_COMPRESS_PLIO, sf->tiles, 8, 0, 0);
    462         psFitsSetCompression(sf->recMask->fits, PS_FITS_COMPRESS_PLIO, sf->tiles, 8, 0, 0);
     465        if (sf->recMask) {
     466            psFitsSetCompression(sf->recMask->fits, PS_FITS_COMPRESS_PLIO, sf->tiles, 8, 0, 0);
     467        }
     468#endif
    463469    }
    464470
    465471    if (sf->inWeight) {
    466472        readImage(sf->inWeight, sf->extnum, sf->stage);
    467         if (updateAstrometry) {
    468             pmAstromWriteWCS(sf->inWeight->header, sf->inAstrom->fpa, sf->chip, 0.001);
    469         }
    470473        sf->outWeight->header = (psMetadata*) psMemIncrRefCounter(sf->inWeight->header);
    471474        if (sf->recWeight) {
    472475            sf->recWeight->header = (psMetadata*) psMemIncrRefCounter(sf->inWeight->header);
    473476        }
    474         setupImageRefs(sf->outMask, sf->recMask, sf->inMask, sf->extnum, exciseAll);
    475 
     477        if (updateAstrometry) {
     478            pmAstromWriteWCS(sf->inWeight->header, sf->inAstrom->fpa, sf->chip, 0.001);
     479        }
     480        setupImageRefs(sf->outWeight, sf->recWeight, sf->inWeight, sf->extnum, exciseAll);
     481
     482#ifdef STREAKS_COMPRESS_OUTPUT
    476483        copyFitsOptions(sf->outWeight, sf->recWeight, sf->inWeight);
    477484        // XXX: see note above
    478485        psFitsSetCompression(sf->outWeight->fits, PS_FITS_COMPRESS_RICE, sf->tiles, 8, 0, 0);
    479         psFitsSetCompression(sf->recWeight->fits, PS_FITS_COMPRESS_RICE, sf->tiles, 8, 0, 0);
    480     }
    481 
     486        if (sf->recWeight) {
     487            psFitsSetCompression(sf->recWeight->fits, PS_FITS_COMPRESS_RICE, sf->tiles, 8, 0, 0);
     488        }
     489#endif
     490    }
    482491    // and for raw images, create sub images that represent the actual image
    483492    // area (no overscan)
     
    611620
    612621    if (sfiles->inWeight) {
    613         double weightValue = psImageGet (sfiles->inWeight->image, x, y);
    614         psImageSet (sfiles->recWeight->image, x, y, weightValue);
     622        if (sfiles->recWeight) {
     623            double weightValue = psImageGet (sfiles->inWeight->image, x, y);
     624            psImageSet (sfiles->recWeight->image, x, y, weightValue);
     625        }
    615626        psImageSet (sfiles->outWeight->image, x, y, NAN);
    616627    }
    617628    if (sfiles->inMask) {
    618         double maskValue   = psImageGet (sfiles->inMask->image,   x, y);
    619         psImageSet (sfiles->recMask->image,   x, y, maskValue);
     629        if (sfiles->recMask) {
     630            double maskValue   = psImageGet (sfiles->inMask->image,   x, y);
     631            psImageSet (sfiles->recMask->image,   x, y, maskValue);
     632        }
    620633        psImageSet (sfiles->outMask->image,   x, y, newMaskValue);
    621634    }
Note: See TracChangeset for help on using the changeset viewer.