IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Feb 11, 2011, 4:29:48 PM (15 years ago)
Author:
watersc1
Message:

Trying to merge back into trunk.

Location:
branches/czw_branch/20101203
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/czw_branch/20101203

  • branches/czw_branch/20101203/magic/remove/src/streaksremove.c

    r29806 r30586  
    9393        // Raw files have a phu and multiple extensions, one per chip
    9494        // Since this is a raw file, copy it's PHU to output files
    95         copyPHU(sfiles, true);
     95        copyPHU(sfiles, true, true);
    9696
    9797        // advance to the first image extension
     
    275275    psLogMsg("streaksremove", PS_LOG_INFO, "time to run streaksremove: %f\n", total_time);
    276276
    277     if (sfiles->statsFile) {
    278         const char *statsMDC = psMetadataConfigFormat(sfiles->stats);
    279         if (!statsMDC || strlen(statsMDC) == 0) {
    280             psError(PS_ERR_IO, false, "Unable to get statistics MDC file.\n");
    281         } else {
    282             fprintf(sfiles->statsFile, "%s", statsMDC);
    283             psFree(statsMDC);
    284             fclose(sfiles->statsFile);
    285             sfiles->statsFile = NULL;
    286             psFree(sfiles->stats);
    287             sfiles->stats = NULL;
    288         }
    289     }
     277    psString statsFileName= psMetadataLookupStr(&status, config->arguments, "STATS");
     278
     279    if (statsFileName) {
     280    // Write out
     281        psString resolved = pmConfigConvertFilename(statsFileName, config, true, true); // Resolved filename
     282        if (!resolved) {
     283            psError(psErrorCodeLast(), false, "Unable to resolve statistics file name");
     284            return false;
     285        }
     286        if (!psMetadataConfigWrite(sfiles->stats, resolved, NULL)) {
     287            psError(psErrorCodeLast(), false, "Unable to serialize stats metadata.\n");
     288            psFree(resolved);
     289            return false;
     290        }
     291        psFree(resolved);
     292    }
     293
    290294    // all done. Clean up to look for memory leaks.
    291295
     
    613617        addRecoveryKeyword(sf->recImage->header);
    614618    }
    615     addDestreakKeyword(sf->outImage->header);
     619    addDestreakKeyword(sf->outImage->header, true);
    616620
    617621    if (!SFILE_IS_IMAGE(sf->inImage)) {
     
    639643                addRecoveryKeyword(sf->recMask->header);
    640644            }
    641             addDestreakKeyword(sf->outMask->header);
     645            addDestreakKeyword(sf->outMask->header, true);
    642646            // Note: we don't excise the mask pixels even if exciseAll is true.
    643647            setupImageRefs(sf->outMask, sf->recMask, sf->inMask, sf->extnum, false);
     
    671675            addRecoveryKeyword(sf->recWeight->header);
    672676        }
    673         addDestreakKeyword(sf->outWeight->header);
     677        addDestreakKeyword(sf->outWeight->header, true);
    674678        setupImageRefs(sf->outWeight, sf->recWeight, sf->inWeight, sf->extnum, exciseAll);
    675679
     
    767771            }
    768772        }
    769     } else {
     773    } else if (sfiles->inImage->image->type.type == PS_TYPE_F32) {
    770774        float imageValue  = sfiles->inImage->image->data.F32[y][x];
    771775        if (sfiles->recImage && !isExciseValue(imageValue, sfiles->inImage->exciseValue) ) {
     
    783787            }
    784788        }
     789    } else {
     790        // We could handle F64 but I don't think we ever get them.
     791        // Should catch this earlier
     792        psError(PS_ERR_IO, true, "unexpected image type %x found", sfiles->inImage->image->type.type );
     793        streaksExit("", PS_EXIT_PROG_ERROR);
    785794    }
    786795
    787796    if (sfiles->outWeight) {
    788         if (sfiles->recWeight) {
    789             sfiles->recWeight->image->data.F32[y][x] = sfiles->inWeight->image->data.F32[y][x];
    790         }
    791797        // Assume that weight images are always a floating point type
    792         sfiles->outWeight->image->data.F32[y][x] = NAN;
     798        if (sfiles->inWeight->image->type.type == PS_TYPE_F32) {
     799            if (sfiles->recWeight) {
     800                sfiles->recWeight->image->data.F32[y][x] = sfiles->inWeight->image->data.F32[y][x];
     801            }
     802            sfiles->outWeight->image->data.F32[y][x] = NAN;
     803        } else if (sfiles->inWeight->image->type.type == PS_TYPE_F64) {
     804            if (sfiles->recWeight) {
     805                sfiles->recWeight->image->data.F64[y][x] = sfiles->inWeight->image->data.F64[y][x];
     806            }
     807            sfiles->outWeight->image->data.F64[y][x] = NAN;
     808        } else {
     809            // Should catch this earlier
     810            psError(PS_ERR_IO, true, "unexpected weight image type %x found", sfiles->inWeight->image->type.type );
     811            streaksExit("", PS_EXIT_PROG_ERROR);
     812        }
    793813    }
    794814    if (sfiles->outMask) {
     
    912932            streaksExit("", PS_EXIT_DATA_ERROR);
    913933        }
    914         addDestreakKeyword(header);
     934        addDestreakKeyword(header, true);
    915935
    916936        if (!psFitsWriteBlank(out->fits, header, extname)) {
     
    973993        psArrayRealloc(outTable, j);
    974994
    975         addDestreakKeyword(header);
     995        addDestreakKeyword(header, true);
    976996        if (psArrayLength(outTable) > 0) {
    977997            printf("Censored %d sources\n", numCensored);
Note: See TracChangeset for help on using the changeset viewer.