IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Nov 10, 2008, 4:45:16 PM (17 years ago)
Author:
bills
Message:

various changes, mostly half implemented features

File:
1 edited

Legend:

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

    r20580 r20671  
    2323    psFree(sfile);
    2424}
     25
     26// TODO: get these by reading the recipe
     27#define MASK_STREAK   0x20
     28#define MASK_BAD_WARP 0x10
     29
     30
    2531
    2632// getNebServer()
     
    498504        return NULL;
    499505    }
     506
     507    bool gotReplace = false;
     508    if ((argnum = psArgumentGet(argc, argv, "-replace"))) {
     509        gotReplace = true;
     510        psArgumentRemove(argnum, &argc, argv);
     511        psMetadataAddBool(config->arguments, PS_LIST_TAIL, "REPLACE", 0, "replace input files",
     512            true);
     513    }
    500514   
    501515   
     
    540554        psArgumentRemove(argnum, &argc, argv);
    541555        bool nebulousTmp = IN_NEBULOUS(argv[argnum]);
    542         if (nebulousTmp != nebulousImage) {
    543             psError(PS_ERR_UNKNOWN, true, "tmproot must have %snebulous path with %s image path\n",
     556        if (gotReplace && (nebulousTmp != nebulousImage)) {
     557            psError(PS_ERR_UNKNOWN, true, "tmproot must have %snebulous path with %s image path with -replace\n",
    544558                nebulousImage ? "" : "non ", nebulousImage ? "nebulous" : "regular");
    545559            return NULL;
     
    562576        psError(PS_ERR_UNKNOWN, true, "-recovery is required for -stage raw\n");
    563577        return NULL;
    564     }
    565     bool gotReplace = false;
    566     if ((argnum = psArgumentGet(argc, argv, "-replace"))) {
    567         gotReplace = true;
    568         psArgumentRemove(argnum, &argc, argv);
    569         psMetadataAddBool(config->arguments, PS_LIST_TAIL, "REPLACE", 0, "replace input files",
    570             true);
    571578    }
    572579    if ((argnum = psArgumentGet(argc, argv, "-remove"))) {
     
    721728
    722729    sf->inImage->image = (psImage*) psMemIncrRefCounter(readout->image);
     730    sf->inImage->numCols = readout->image->numCols;
     731    sf->inImage->numRows = readout->image->numRows;
    723732}
    724733
     
    921930
    922931    // set up the compression parameters
    923     copyFitsOptions(sf->outImage, sf->recImage, sf->inImage);
     932//    copyFitsOptions(sf->outImage, sf->recImage, sf->inImage);
    924933
    925934    // XXX: TODO: can we derive these values from the input header?
    926935    // psFitsCompressionGet(sf->inImage->image) gives compression none
    927936    // perhaps we should just use the definition of COMP_IMG in the configuration
    928     psFitsSetCompression(sf->outImage->fits, PS_FITS_COMPRESS_RICE, sf->tiles, 8, 0, 0);
     937//    psFitsSetCompression(sf->outImage->fits, PS_FITS_COMPRESS_RICE, sf->tiles, 8, 0, 0);
    929938    psFitsSetCompression(sf->recImage->fits, PS_FITS_COMPRESS_RICE, sf->tiles, 8, 0, 0);
    930939
     
    12511260    double imageValue  = psImageGet (sfiles->inImage->image,  x, y);
    12521261    psImageSet (sfiles->recImage->image,  x, y, imageValue);
     1262
     1263#define ACTUALLY_MASK_PIXEL
     1264#ifdef ACTUALLY_MASK_PIXEL
    12531265    psImageSet (sfiles->outImage->image,  x, y, NAN);
     1266#else
     1267    if (newMaskValue == MASK_BAD_WARP) {
     1268        psImageSet (sfiles->outImage->image,  x, y, NAN);
     1269    } else {
     1270        // as a visualization aid don't mask the pixel, just reduce it in intensity a bit
     1271        psImageSet (sfiles->outImage->image,  x, y, imageValue - 50);
     1272    }
     1273#endif
    12541274
    12551275    // TODO:
     
    13331353}
    13341354
     1355bool
     1356streakEndOnComponent(streak *streak, double r_min, double r_max, double d_min, double d_max)
     1357{
     1358    if ((streak->ra1  >= r_min) && (streak->ra1  <= r_max) &&
     1359        (streak->dec1 >= d_min) && (streak->dec1 <= d_max)) {
     1360        return true;
     1361    }
     1362    if ((streak->ra2  >= r_min) && (streak->ra2  <= r_max) &&
     1363        (streak->dec2 >= d_min) && (streak->dec2 <= d_max)) {
     1364        return true;
     1365    }
     1366    return false;
     1367}
     1368
     1369
     1370Streaks *
     1371restrictStreaksToComponent(streakFiles *sfiles, Streaks *streaks)
     1372{
     1373    Streaks *out = psAlloc(sizeof(Streaks));
     1374
     1375    strkPt ll, ur;
     1376    cellToSky(&ll, sfiles->astrom, 0, 0);
     1377    cellToSky(&ur, sfiles->astrom, sfiles->inImage->numCols-1, sfiles->inImage->numRows-1);
     1378
     1379    double r_min, r_max, d_min, d_max;
     1380    if (ll.x < ur.x) {
     1381        r_min = ll.x; r_max = ur.x;
     1382    } else {
     1383        r_min = ur.x; r_max = ll.x;
     1384    }
     1385    if (ll.y < ur.y) {
     1386        d_min = ll.y; d_max = ur.y;
     1387    } else {
     1388        d_min = ur.y; d_max = ll.y;
     1389    }
     1390
     1391    out->list = psAlloc(streaks->size * sizeof(streak));
     1392    int j=0;
     1393    for (int i=0 ; i<streaks->size; i++) {
     1394        if (streakEndOnComponent(&streaks->list[i], r_min, r_max, d_min, d_max)) {
     1395            out->list[j++] = streaks->list[i];
     1396        }
     1397           
     1398    }
     1399    out->size = j;
     1400    return out;
     1401}
     1402
    13351403int
    13361404main(int argc, char *argv[])
     
    13591427    streakFiles *sfiles = openFiles(config);
    13601428
    1361     if (CHIP_LEVEL_INPUT(sfiles->stage)) {
     1429    bool status;
     1430    bool checkWarpedPixels = ! psMetadataLookupBool(&status, config->arguments, "INCLUDE_NON_WARPED");
     1431    if (checkWarpedPixels) {
    13621432        // From ICD:
    13631433        // In the raw and detrended images, the pixels which were not
     
    13941464        // Identify pixels to mask because of streaks
    13951465
     1466#ifdef notyet
     1467        Streaks *componentStreaks = NULL;
     1468        Streaks *streaksToProcess;
     1469
     1470        bool only_component_streaks = false; // XXX flesh this out and make it an option
     1471        if (only_component_streaks) {
     1472            componentStreaks = restrictStreaksToComponent(sfiles, streaks);
     1473            streaksToProcess = componentStreaks;
     1474        } else {
     1475            streaksToProcess = streaks;
     1476        }
     1477
     1478        pixels = streak_on_component (streaksToProcess, sfiles->astrom,
     1479                                      sfiles->inImage->numCols, sfiles->inImage->numRows);
     1480        if (componentStreaks) {
     1481            psFree(componentStreaks);
     1482        }
     1483#else
    13961484        pixels = streak_on_component (streaks, sfiles->astrom,
    13971485                                      sfiles->inImage->numCols, sfiles->inImage->numRows);
     1486#endif
    13981487        // XXX:
    13991488        //
     
    14011490        // in a config somewhere?  Not sure how to properly set the maskValue.
    14021491        // WES just pick some numbers
    1403 #define MASK_STREAK     42
    1404 #define MASK_NOT_WARPED 51
    1405 
    1406         exciseNonWarpedPixels(sfiles, MASK_NOT_WARPED);
     1492
     1493        if (checkWarpedPixels) {
     1494            exciseNonWarpedPixels(sfiles, MASK_BAD_WARP);
     1495        }
    14071496
    14081497        if (sfiles->inImage->image) {
     
    14101499                pixelPos = psArrayGet (pixels, i);
    14111500
    1412                 if (warpedPixel(sfiles, pixelPos)) {
     1501                if (!checkWarpedPixels || warpedPixel(sfiles, pixelPos)) {
    14131502
    14141503                    excisePixel(sfiles, pixelPos->x, pixelPos->y, MASK_STREAK);
     
    14431532    }
    14441533
    1445     bool status;
    14461534    if (psMetadataLookupBool(&status, config->arguments, "REPLACE")) {
    14471535        //     swap the instances for the input and output
Note: See TracChangeset for help on using the changeset viewer.