IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 21085


Ignore:
Timestamp:
Jan 4, 2009, 12:32:32 PM (17 years ago)
Author:
bills
Message:

When destreaking chip stage images, use replace the mask from the chip
stage with the mask from the camera stage, destreaking them both.
Added program to prepare images for release by insuring that all masked
pixels are set to NAN

Location:
trunk
Files:
1 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/ippScripts/scripts/magic_destreak.pl

    r20941 r21085  
    176176my $image = $uri;
    177177
    178 my ($mask, $weight, $astrom);
     178my ($mask, $ch_mask, $weight, $astrom);
    179179
    180180if ($stage eq "raw") {
    181181    $astrom = $ipprc->filename("PSASTRO.OUTPUT", $cam_path_base);
    182182} elsif ($stage eq "chip") {
    183     $mask   = $ipprc->filename("PPIMAGE.CHIP.MASK", $path_base, $class_id);
     183    # we use the mask output from the camera stage for input and replace
     184    # the output of the chip stage with that mask as well.
     185    $mask   = $ipprc->filename("PSASTRO.OUTPUT.MASK", $cam_path_base, $class_id);
     186    $ch_mask= $ipprc->filename("PPIMAGE.CHIP.MASK", $path_base, $class_id);
    184187    $weight = $ipprc->filename("PPIMAGE.CHIP.WEIGHT", $path_base, $class_id);
    185188    $astrom = $ipprc->filename("PSASTRO.OUTPUT", $cam_path_base);
     
    198201    $command .= " -astrom $astrom" if defined $astrom;
    199202    $command .= " -mask $mask" if defined $mask;
     203    $command .= " -chip_mask $ch_mask" if defined $ch_mask;
    200204    $command .= " -weight $weight" if defined $weight;
    201205    $command .= " -skycelllist $skycell_list" if defined $skycell_list;
  • trunk/magic/remove/src/Makefile.simple

    r20844 r21085  
    1616    Line.o
    1717
    18 REPLACE_OBJECTS=    \
     18REPLACE_OBJECTS=      \
    1919    ${COMMON_OBJECTS} \
    2020    streaksreplace.o
    2121
    22 COMPARE_OBJECTS=    \
     22COMPARE_OBJECTS=      \
    2323    ${COMMON_OBJECTS} \
    2424    streakscompare.o
    2525
     26RELEASE_OBJECTS=      \
     27    ${COMMON_OBJECTS} \
     28    streaksrelease.o
     29
    2630STREAKSFLAGS=-DSTREAKS_COMPRESS_OUTPUT=1
    2731OPTFLAGS= -g
     32#CFLAGS=`psmodules-config --cflags` -std=gnu99 ${OPTFLAGS} ${STREAKSFLAGS}
    2833CFLAGS=`psmodules-config --cflags` -std=gnu99 ${OPTFLAGS}
    2934LDFLAGS=`psmodules-config --libs`
    3035
    31 PROGRAMS= streaksremove streaksreplace streakscompare
     36PROGRAMS= streaksremove streaksreplace streakscompare streaksrelease
    3237
    3338all:    ${PROGRAMS}
     
    3944streakscompare:  ${COMPARE_OBJECTS}
    4045
     46streaksrelease:  ${RELEASE_OBJECTS}
     47
    4148install:        ${PROGRAMS}
    4249        install -t  $(PSCONFDIR)/$(PSCONFIG)/bin streaksremove
    4350        install -t  $(PSCONFDIR)/$(PSCONFIG)/bin streaksreplace
    4451        install -t  $(PSCONFDIR)/$(PSCONFIG)/bin streakscompare
     52        install -t  $(PSCONFDIR)/$(PSCONFIG)/bin streaksrelease
    4553
    4654clean:
  • trunk/magic/remove/src/streaksio.c

    r20845 r21085  
    55static nebServer *ourNebServer = NULL;
    66
     7// open the files required for streaks procesing.
     8// if remove is true the calling program is streaksremove and the recovery files are outputs
     9// if false the recovery files are inputs
    710streakFiles *openFiles(pmConfig *config, bool remove)
    811{
     
    3033
    3134    if (remove) {
     35        // XXX: the recovery file should be required if stage is raw and the replace flag is set
     36        // that is if the input raw image is to be destroyed
    3237        sf->recImage = sFileOpen(config, stage, "RECOVERY", inputBasename, false);
    3338    } else {
     
    4550        }
    4651    }
     52    // If we're in streaksremove and operating on a chip stage image
     53    // if we are passed a mask it is camera stage mask and we also
     54    // need to destreak the chip level mask file as well
     55    if (remove && sf->inMask && (stage == IPP_STAGE_CHIP)) {
     56        sf->inChMask = sFileOpen(config, stage, "INPUT.CHMASK", NULL, true);
     57        inputBasename = basename(sf->inChMask->name);
     58        sf->outChMask = sFileOpen(config, stage, "OUTPUT", inputBasename, true);
     59        sf->recChMask = sFileOpen(config, stage, "RECOVERY", inputBasename, false);
     60    }
     61
    4762    sf->inWeight = sFileOpen(config, stage, "INPUT.WEIGHT", NULL, false);
    4863    if (sf->inWeight) {
     
    421436    // XXX: This function assumes that it is only used for a single
    422437    // chip single cell FPA (i.e. a skycell)
     438    assert(sf->inImage->pmfile->fpa->chips->n == 1);
     439
    423440    pmFPAview *view = sf->view;
    424     assert(view->chip == 0);
     441    if (view) {
     442        // The view was allocated and the chip set by setupAstrometry()
     443        assert(view->chip == 0);
     444    } else {
     445        sf->view = pmFPAviewAlloc(0);
     446        view = sf->view;
     447        sf->chip = pmFPAviewNextChip(view, sf->inImage->pmfile->fpa, 1);
     448        assert(sf->chip != NULL);
     449    }
    425450    view->cell = 0;
    426451    sf->cell =  pmFPAviewThisCell(view, sf->inImage->pmfile->fpa);
     
    747772        closeImage(sf->recMask);
    748773    }
     774    if (sf->inChMask) {
     775        closeImage(sf->inChMask);
     776        closeImage(sf->outChMask);
     777        closeImage(sf->recChMask);
     778    }
    749779    if (sf->inWeight) {
    750780        closeImage(sf->inWeight);
  • trunk/magic/remove/src/streaksremove.c

    r21042 r21085  
    8585    int totalStreakPixels = 0;
    8686
    87     // Iterate through each component of the input (only one except for raw stage)
     87    // Iterate through each component of the input (there is only one except for raw images)
    8888    do {
    8989        bool exciseImageCube = false;
     
    223223    fprintf(stderr, "\t-remove: remove the original image after processing (requires -replace)\n");
    224224    fprintf(stderr, "\t-keepnonwarped: do not exise pixels that were not part of difference processing\n");
    225     fprintf(stderr, "\t-transparent val: instead of setting exicsed pixel to NAN add val\n");
     225    fprintf(stderr, "\t-transparent val: instead of setting excicsed pixel to NAN add val\n");
     226    fprintf(stderr, "\t-chip_mask MASK.fits: name of mask for chip stage (camera stage mask is passed tih -mask)\n");
    226227
    227228    exit(2);
     
    333334        psArgumentRemove(argnum, &argc, argv);
    334335        bool nebulousMask = IN_NEBULOUS(argv[argnum]);
     336        // This isn't a strict requirement if stage == IPP_STAGE_CHIP
    335337        if (nebulousMask != nebulousImage) {
    336338            psError(PS_ERR_UNKNOWN, true, "mask image must be %snebulous path with %s image path\n",
     
    340342        psMetadataAddStr(config->arguments, PS_LIST_TAIL, "INPUT.MASK", 0,
    341343                "name of input mask image", argv[argnum]);
     344        psArgumentRemove(argnum, &argc, argv);
     345    }
     346
     347    if ((argnum = psArgumentGet(argc, argv, "-chip_mask"))) {
     348        if (stage != IPP_STAGE_CHIP) {
     349            psError(PS_ERR_UNKNOWN, true, "-chip_mask only allowed at chip stage");
     350            usage();
     351        }
     352        psArgumentRemove(argnum, &argc, argv);
     353        bool nebulousMask = IN_NEBULOUS(argv[argnum]);
     354        if (nebulousMask != nebulousImage) {
     355            psError(PS_ERR_UNKNOWN, true, "chip mask image must be %snebulous path with %s image path\n",
     356                nebulousImage ? "" : "non ", nebulousImage ? "nebulous" : "regular");
     357            usage();
     358        }
     359        psMetadataAddStr(config->arguments, PS_LIST_TAIL, "INPUT.CHMASK", 0,
     360                "name of input chip mask image", argv[argnum]);
    342361        psArgumentRemove(argnum, &argc, argv);
    343362    }
     
    429448        streaksExit("", PS_EXIT_UNKNOWN_ERROR);
    430449    }
     450    // For the chip level files, copy the WCS from the astrometry file to the header
     451    // XXX: do we want to do this for raw images as well?
    431452    if (sf->stage == IPP_STAGE_CHIP) {
    432         // For the chip level files, copy the WCS from the astrometry file to the header
    433453        if (!sf->bilevelAstrometry) {
    434454            updateAstrometry = true;
     
    481501            pmAstromWriteWCS(sf->outMask->header, sf->inAstrom->fpa, sf->chip, 0.001);
    482502        }
    483 
    484503        setupImageRefs(sf->outMask, sf->recMask, sf->inMask, sf->extnum, exciseAll);
     504        if (sf->outChMask) {
     505            sf->outChMask->header = (psMetadata *) psMemIncrRefCounter(sf->outMask->header);
     506            sf->outChMask->image = (psImage *) psMemIncrRefCounter(sf->outMask->image);
     507            if (sf->recChMask) {
     508                sf->recChMask->header = (psMetadata *) psMemIncrRefCounter(sf->recMask->header);
     509                sf->recChMask->image = (psImage *) psMemIncrRefCounter(sf->recMask->image);
     510            }
     511        }
    485512
    486513#ifdef STREAKS_COMPRESS_OUTPUT
     
    490517        if (sf->recMask) {
    491518            psFitsSetCompression(sf->recMask->fits, PS_FITS_COMPRESS_PLIO, sf->tiles, 8, 0, 0);
     519        }
     520        if (sf->outChMask) {
     521            copyFitsOptions(sf->outChMask, sf->recChMask, sf->inMask);
     522            psFitsSetCompression(sf->outChMask->fits, PS_FITS_COMPRESS_PLIO, sf->tiles, 8, 0, 0);
     523            if (sf->recChMask) {
     524                psFitsSetCompression(sf->recChMask->fits, PS_FITS_COMPRESS_PLIO, sf->tiles, 8, 0, 0);
     525            }
    492526        }
    493527#endif
     
    567601        writeImage(sf->outMask, extname, sf->extnum);
    568602        writeImage(sf->recMask, extname, sf->extnum);
     603        if (sf->stage == IPP_STAGE_CHIP) {
     604            writeImage(sf->outChMask, extname, sf->extnum);
     605            writeImage(sf->recChMask, extname, sf->extnum);
     606        }
    569607    }
    570608    if (sf->outWeight) {
  • trunk/magic/remove/src/streaksremove.h

    r20816 r21085  
    5454    sFile *recMask;
    5555    sFile *recWeight;
     56    sFile *inChMask;    // for chip stage input mask is camera mask and output goes to both chip and cam masks
     57    sFile *outChMask;
     58    sFile *recChMask;
    5659    psString class_id;
    5760    pmFPAfile  *inAstrom;
Note: See TracChangeset for help on using the changeset viewer.