IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 24286


Ignore:
Timestamp:
Jun 1, 2009, 11:43:02 AM (17 years ago)
Author:
bills
Message:

Fix compression by looking up the compression type in the input header
and setting it to the output. In the process of doing this competely localized
the setting of compression parameters in copyFitsOptions, so three times as
many lines are deleted by this delta as added.

Location:
trunk/magic/remove/src
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/magic/remove/src/Makefile.simple

    r23910 r24286  
    2828    streaksrelease.o
    2929
    30 # STREAKSFLAGS=-DSTREAKS_COMPRESS_OUTPUT=1
     30STREAKSFLAGS=-DSTREAKS_COMPRESS_OUTPUT=1
    3131OPTFLAGS= -g -O2
    3232OPTFLAGS= -g
  • trunk/magic/remove/src/streaksio.c

    r24283 r24286  
    602602
    603603static void
    604 setFitsOptions(sFile *sfile, int bitpix, float bscale, float bzero)
     604setFitsOptions(sFile *sfile, int bitpix, float bscale, float bzero, psFitsCompressionType compType,
     605    psVector *tiles)
    605606{
    606607    if (!sfile) {
     
    615616    sfile->fits->options->bscale = bscale;
    616617    sfile->fits->options->bzero = bzero;
    617 }
    618 
    619 void
    620 copyFitsOptions(sFile *out, sFile *rec, sFile *in)
    621 {
     618
     619    psFitsSetCompression(sfile->fits, compType, tiles, 8, 0, 0);
     620}
     621
     622void
     623copyFitsOptions(sFile *out, sFile *rec, sFile *in, psVector *tiles)
     624{
     625    bool mdok;
     626    psString compTypeStr = psMetadataLookupStr(&mdok, in->header, "ZCMPTYPE");
     627    psFitsCompressionType compType = psFitsCompressionTypeFromString(compTypeStr);
     628    if (compType == PS_FITS_COMPRESS_NONE) {
     629        return;
     630    }
    622631    // Get current BITPIX, BSCALE, BZERO, EXTNAME
    623632    // Probably not necessary to look the numerical values up in this
     
    646655
    647656#ifdef STREAKS_COMPRESS_OUTPUT
    648     // Paul says that I should be able to leave this blank
    649     bitpix = 0;
    650     setFitsOptions(out, bitpix, bscale, bzero);
    651     setFitsOptions(rec, bitpix, bscale, bzero);
     657    // printf("%d %f %f\n", bitpix, bscale, bzero);
     658    setFitsOptions(out, bitpix, bscale, bzero, compType, tiles);
     659    setFitsOptions(rec, bitpix, bscale, bzero, compType, tiles);
    652660#endif
    653661}
  • trunk/magic/remove/src/streaksio.h

    r24283 r24286  
    1414void copyPHU(streakFiles *sfiles, bool remove);
    1515void copyTable(sFile *out, sFile *in, int extnum);
    16 void copyFitsOptions(sFile *out, sFile *rec, sFile *in);
     16void copyFitsOptions(sFile *out, sFile *rec, sFile *in, psVector *tiles);
    1717void setupImageRefs(sFile *out, sFile *recoveryOut, sFile *in, int extnum, bool exciseAll);
    1818void strkGetMaskValues(streakFiles *sfiles, psU32 *maskStreak, psU32 *maskMask);
  • trunk/magic/remove/src/streaksrelease.c

    r23965 r24286  
    275275
    276276    // set up the compression parameters
    277 #ifdef STREAKS_COMPRESS_OUTPUT
    278     // compression of the image pixels is disabled for now. Some consortium members
    279     // have problems reading them
    280     copyFitsOptions(sf->outImage, sf->recImage, sf->inImage);
    281 
    282     // XXX: TODO: can we derive these values from the input header?
    283     // psFitsCompressionGet(sf->inImage->image) gives compression none
    284     // perhaps we should just use the definition of COMP_IMG in the configuration
    285     psFitsSetCompression(sf->outImage->fits, PS_FITS_COMPRESS_RICE, sf->tiles, 8, 0, 0);
    286     if (sf->recImage) {
    287         psFitsSetCompression(sf->recImage->fits, PS_FITS_COMPRESS_RICE, sf->tiles, 8, 0, 0);
    288     }
    289 #endif
     277    copyFitsOptions(sf->outImage, sf->recImage, sf->inImage, sf->tiles);
    290278
    291279    if (sf->inMask) {
     
    306294            }
    307295
    308 #ifdef STREAKS_COMPRESS_OUTPUT
    309             // XXX: see note above
    310             copyFitsOptions(sf->outMask, sf->recMask, sf->inMask);
    311             psFitsSetCompression(sf->outMask->fits, PS_FITS_COMPRESS_PLIO, sf->tiles, 8, 0, 0);
    312             if (sf->recMask) {
    313                 psFitsSetCompression(sf->recMask->fits, PS_FITS_COMPRESS_PLIO, sf->tiles, 8, 0, 0);
    314             }
     296            copyFitsOptions(sf->outMask, sf->recMask, sf->inMask, sf->tiles);
    315297            if (sf->outChMask) {
    316                 copyFitsOptions(sf->outChMask, sf->recChMask, sf->inMask);
     298                copyFitsOptions(sf->outChMask, sf->recChMask, sf->inMask, sf->tiles);
    317299                psFitsSetCompression(sf->outChMask->fits, PS_FITS_COMPRESS_PLIO, sf->tiles, 8, 0, 0);
    318300                if (sf->recChMask) {
     
    320302                }
    321303            }
    322 #endif
    323304        }
    324305    }
     
    332313        setupImageRefs(sf->outWeight, sf->recWeight, sf->inWeight, sf->extnum, exciseAll);
    333314
    334 #ifdef STREAKS_COMPRESS_OUTPUT
    335         copyFitsOptions(sf->outWeight, sf->recWeight, sf->inWeight);
    336         // XXX: see note above
    337         psFitsSetCompression(sf->outWeight->fits, PS_FITS_COMPRESS_RICE, sf->tiles, 8, 0, 0);
    338         if (sf->recWeight) {
    339             psFitsSetCompression(sf->recWeight->fits, PS_FITS_COMPRESS_RICE, sf->tiles, 8, 0, 0);
    340         }
    341 #endif
     315        copyFitsOptions(sf->outWeight, sf->recWeight, sf->inWeight, sf->tiles);
    342316    }
    343317    // and for raw images, create sub images that represent the actual image
  • trunk/magic/remove/src/streaksremove.c

    r24283 r24286  
    569569
    570570    // set up the compression parameters
    571 #ifdef STREAKS_COMPRESS_OUTPUT
    572     // compression of the image pixels is disabled for now. Some consortium members
    573     // have problems reading them
    574     copyFitsOptions(sf->outImage, sf->recImage, sf->inImage);
    575 
    576     // XXX: TODO: can we derive these values from the input header?
    577     // psFitsCompressionGet(sf->inImage->image) gives compression none
    578     // perhaps we should just use the definition of COMP_IMG in the configuration
    579     psFitsSetCompression(sf->outImage->fits, PS_FITS_COMPRESS_RICE, sf->tiles, 8, 0, 0);
    580     if (sf->recImage) {
    581         psFitsSetCompression(sf->recImage->fits, PS_FITS_COMPRESS_RICE, sf->tiles, 8, 0, 0);
    582     }
    583 #endif
     571    copyFitsOptions(sf->outImage, sf->recImage, sf->inImage, sf->tiles);
    584572
    585573    if (sf->inMask) {
     
    605593            }
    606594
    607 #ifdef STREAKS_COMPRESS_OUTPUT
    608             // XXX: see note above
    609             copyFitsOptions(sf->outMask, sf->recMask, sf->inMask);
    610             psFitsSetCompression(sf->outMask->fits, PS_FITS_COMPRESS_PLIO, sf->tiles, 8, 0, 0);
    611             if (sf->recMask) {
    612                 psFitsSetCompression(sf->recMask->fits, PS_FITS_COMPRESS_PLIO, sf->tiles, 8, 0, 0);
    613             }
     595            copyFitsOptions(sf->outMask, sf->recMask, sf->inMask, sf->tiles);
    614596            if (sf->outChMask) {
    615                 copyFitsOptions(sf->outChMask, sf->recChMask, sf->inMask);
    616                 psFitsSetCompression(sf->outChMask->fits, PS_FITS_COMPRESS_PLIO, sf->tiles, 8, 0, 0);
    617                 if (sf->recChMask) {
    618                     psFitsSetCompression(sf->recChMask->fits, PS_FITS_COMPRESS_PLIO, sf->tiles, 8, 0, 0);
    619                 }
    620             }
    621 #endif
     597                copyFitsOptions(sf->outChMask, sf->recChMask, sf->inMask, sf->tiles);
     598            }
    622599        }
    623600    }
     
    636613        setupImageRefs(sf->outWeight, sf->recWeight, sf->inWeight, sf->extnum, exciseAll);
    637614
    638 #ifdef STREAKS_COMPRESS_OUTPUT
    639         copyFitsOptions(sf->outWeight, sf->recWeight, sf->inWeight);
    640         // XXX: see note above
    641         psFitsSetCompression(sf->outWeight->fits, PS_FITS_COMPRESS_RICE, sf->tiles, 8, 0, 0);
    642         if (sf->recWeight) {
    643             psFitsSetCompression(sf->recWeight->fits, PS_FITS_COMPRESS_RICE, sf->tiles, 8, 0, 0);
    644         }
    645 #endif
    646     }
    647     // and for raw images, create sub images that represent the actual image
    648     // area (no overscan)
     615        copyFitsOptions(sf->outWeight, sf->recWeight, sf->inWeight, sf->tiles);
     616    }
    649617
    650618    return true;
  • trunk/magic/remove/src/streaksreplace.c

    r23965 r24286  
    344344
    345345    // set up the compression parameters
    346 #ifdef STREAKS_COMPRESS_OUTPUT
    347     // compression of the image pixels is disabled for now. Some consortium members
    348     // have problems reading compressed images.
    349     copyFitsOptions(sf->outImage, sf->recImage, sf->inImage);
    350 
    351     // XXX: TODO: can we derive these values from the input header?
    352     // psFitsCompressionGet(sf->inImage->image) gives compression none
    353     // perhaps we should just use the definition of COMP_IMG in the configuration
    354     psFitsSetCompression(sf->outImage->fits, PS_FITS_COMPRESS_RICE, sf->tiles, 8, 0, 0);
    355 #endif
     346    copyFitsOptions(sf->outImage, sf->recImage, sf->inImage, sf->tiles);
     347
    356348    if (sf->inMask) {
    357349        readImage(sf->inMask, sf->extnum, sf->stage, true);
     
    362354        setupImageRefs(sf->outMask, NULL, sf->inMask, sf->extnum, false);
    363355
    364         // XXX: see note above
    365         copyFitsOptions(sf->outMask, NULL, sf->inMask);
    366         psFitsSetCompression(sf->outMask->fits, PS_FITS_COMPRESS_PLIO, sf->tiles, 8, 0, 0);
     356        copyFitsOptions(sf->outMask, NULL, sf->inMask, sf->tiles);
    367357    }
    368358
     
    374364        setupImageRefs(sf->outMask, NULL, sf->inMask, sf->extnum, false);
    375365
    376         copyFitsOptions(sf->outWeight, NULL, sf->inWeight);
    377         // XXX: see note above
    378         psFitsSetCompression(sf->outWeight->fits, PS_FITS_COMPRESS_RICE, sf->tiles, 8, 0, 0);
     366        copyFitsOptions(sf->outWeight, NULL, sf->inWeight, sf->tiles);
    379367    }
    380368
Note: See TracChangeset for help on using the changeset viewer.