IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Aug 7, 2009, 12:45:24 PM (17 years ago)
Author:
eugene
Message:

update from mainline

Location:
branches/eam_branches/20090715
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/20090715

  • branches/eam_branches/20090715/magic/remove/src/streaksremove.c

    r24716 r25022  
    1313static bool readAndCopyToOutput(streakFiles *sf, bool exciseAll);
    1414static void exciseNonWarpedPixels(streakFiles *sfiles, double newMaskValue);
    15 static bool warpedPixel(streakFiles *sfiles, PixelPos *cellCoord);
     15static bool warpedPixel(streakFiles *sfiles, int x, int y);
    1616static void excisePixel(streakFiles *sfiles, unsigned int x, unsigned int y, bool streak, double newMaskValue);
    1717static void writeImages(streakFiles *sf, bool exciseImageCube);
     
    146146                }
    147147
    148                 totalStreakPixels +=  psArrayLength(pixels);
    149148
    150149                psTimerStart("REMOVE_STREAKS");
    151150
    152                 // for each pixel covered by the streak
    153                 for (int i = 0; i < psArrayLength (pixels); ++i) {
    154                     PixelPos *pixelPos = psArrayGet (pixels, i);
    155 
    156                     // if this pixel was not part of the warp, skip because it has already been
    157                     // excised (unless we weren't asked to check)
    158                     if (!checkNonWarpedPixels || warpedPixel(sfiles, pixelPos)) {
    159 
    160                         excisePixel(sfiles, pixelPos->x, pixelPos->y, true, maskStreak);
    161 
    162                     } else {
    163                         // This pixel was not included in any warp and has thus already excised
    164                         // by exciseNonWarpedPixels
     151                for (int y=0 ; y < sfiles->inImage->numRows; y++) {
     152                    for (int x = 0; x < sfiles->inImage->numCols; x++) {
     153                        if (psImageGet(pixels, x, y)) {
     154                            ++totalStreakPixels;
     155                            if (!checkNonWarpedPixels || warpedPixel(sfiles, x, y)) {
     156
     157                                excisePixel(sfiles, x, y, true, maskStreak);
     158
     159                            } else {
     160                                // This pixel was not included in any warp and has thus already excised
     161                                // by exciseNonWarpedPixels
     162                            }
     163                        }
    165164                    }
    166165                }
     
    178177                exciseImageCube = true;
    179178            }
    180             psArrayElementsFree (pixels);
    181179            psFree(pixels);
    182180        }
     
    198196    } while (streakFilesNextExtension(sfiles));
    199197
     198
    200199    psFree(streaks);
    201200
    202201    psLogMsg("streaksremove", PS_LOG_INFO, "pixels: %ld streak pixels: %ld %4.2f%%\n", totalPixels, totalStreakPixels, 100. * totalStreakPixels / totalPixels);
     202
     203    // check the weight and mask files for extra extensions that might be in files
     204    // (covariance matrix for example)
     205    copyExtraExtensions(sfiles);
    203206
    204207    // all done close the files. This is where the files are written so it can take a long time.
     
    751754
    752755static bool
    753 warpedPixel(streakFiles *sfiles, PixelPos *cellCoord)
     756warpedPixel(streakFiles *sfiles, int x, int y)
    754757{
    755758    PixelPos chipCoord;
     
    762765    // we clip so that the streak calculation code doesn't have to
    763766    // clipping here insures that we don't touch the overscan regions
    764     if ((cellCoord->x < 0) || (cellCoord->x >= sfiles->inImage->numCols) ||
    765         (cellCoord->y < 0) || (cellCoord->y >= sfiles->inImage->numRows)) {
     767    if ((x < 0) || (x >= sfiles->inImage->numCols) ||
     768        (y < 0) || (y >= sfiles->inImage->numRows)) {
    766769        return false;
    767770    }
    768771
    769     cellToChipInt(&chipCoord.x, &chipCoord.y, sfiles->astrom, cellCoord->x, cellCoord->y);
     772    cellToChipInt(&chipCoord.x, &chipCoord.y, sfiles->astrom, x, y);
    770773
    771774    if (chipCoord.x < 0 || chipCoord.x >= sfiles->warpedPixels->numCols) {
     
    834837    }
    835838
    836     printf("Censored %d sources\n", numCensored);
    837 
    838839    // get rid of unused elements (don't know if this is necessary)
    839840    psArrayRealloc(outTable, j);
    840841
    841842    addDestreakKeyword(in->header);
    842     if (! psFitsWriteTable(out->fits, in->header, outTable, extname)) {
    843         psError(PS_ERR_IO, false, "failed to write table to %s", out->resolved_name);
    844         streaksExit("", PS_EXIT_DATA_ERROR);
     843    if (psArrayLength(outTable) > 0) {
     844        printf("Censored %d sources\n", numCensored);
     845        if (! psFitsWriteTable(out->fits, in->header, outTable, extname)) {
     846            psError(PS_ERR_IO, false, "failed to write table to %s", out->resolved_name);
     847            streaksExit("", PS_EXIT_DATA_ERROR);
     848        }
     849    } else {
     850        printf("Censored ALL %d sources\n", numCensored);
     851        if (! psFitsWriteTableEmpty(out->fits, in->header, inTable->data[0], extname)) {
     852            psError(PS_ERR_IO, false, "failed to write empty table to %s", out->resolved_name);
     853            streaksExit("", PS_EXIT_DATA_ERROR);
     854        }
    845855    }
    846856
Note: See TracChangeset for help on using the changeset viewer.