IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
May 26, 2009, 1:59:32 PM (17 years ago)
Author:
beaumont
Message:

merged with trunk

Location:
branches/cnb_branches/cnb_branch_20090301
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/cnb_branches/cnb_branch_20090301

  • branches/cnb_branches/cnb_branch_20090301/magic/remove/src/streaksio.c

    r21481 r24244  
    66static void streakFilesFree(streakFiles *sf);
    77static void freeImages(streakFiles *);
     8static void setExciseValue(sFile *in);
    89
    910static nebServer *ourNebServer = NULL;
     
    1213// if remove is true the calling program is streaksremove and the recovery files are outputs
    1314// if false the recovery files are inputs
    14 streakFiles *openFiles(pmConfig *config, bool remove)
     15streakFiles *openFiles(pmConfig *config, bool remove, char *program_name)
    1516{
    1617    bool status;
     
    2021
    2122    sf->config = config;
     23    sf->program_name = basename(program_name);
    2224
    2325    // error checking is done by sFileOpen. If a file can't be opened we just exit
     
    471473    sf->inImage->numCols = readout->image->numCols;
    472474    sf->inImage->numRows = readout->image->numRows;
     475    setExciseValue(sf->inImage);
    473476}
    474477
     
    545548            streaksExit("", PS_EXIT_DATA_ERROR);
    546549        }
    547         if (in->image->type.type == PS_TYPE_U16) {
    548             in->exciseValue = 65535;
    549             psMetadataAddU16(in->header, PS_LIST_TAIL, "BLANK", 0, "", 65535);
    550             psMetadataAddU16(in->header, PS_LIST_TAIL, "ZBLANK", 0, "", 65535);
    551         } else {
    552             in->exciseValue = NAN;
    553         }
     550        setExciseValue(in);
    554551    }  else {
    555552        if (stage != IPP_STAGE_RAW) {
     
    613610
    614611#ifdef STREAKS_COMPRESS_OUTPUT
     612    // Paul says that I should be able to leave this blank
     613    bitpix = 0;
    615614    setFitsOptions(out, bitpix, bscale, bzero);
    616615    setFitsOptions(rec, bitpix, bscale, bzero);
     
    916915deleteFile(sFile *sfile)
    917916{
    918 
    919917    if (sfile->inNebulous) {
    920918        nebServer *server = getNebServer(NULL);
     
    970968
    971969void
    972 setMaskedToNAN(streakFiles *sfiles, psU8 maskMask, bool printCounts)
     970setMaskedToNAN(streakFiles *sfiles, psU32 maskMask, bool printCounts)
    973971{
    974972        int maskedPixels = 0;
     
    993991                // but I want to get the counts
    994992                double imageVal  = psImageGet(image, x, y);
    995                 psU8 maskVal;
     993                psU32 maskVal;
    996994                if (sfiles->stage == IPP_STAGE_RAW) {
    997995                    int xChip, yChip;
     
    10181016        }
    10191017        if (printCounts) {
    1020             printf("time to NAN mask pixels: %f\n", psTimerClear("NAN_MASKED"));
     1018            psLogMsg(sfiles->program_name, PS_LOG_INFO, "time to NAN mask pixels: %f\n", psTimerClear("NAN_MASKED"));
    10211019            int totalPixels = image->numRows * image->numCols;
    1022             printf("pixels:        %10ld\n", totalPixels);
    1023             printf("masked pixels: %10ld %4.2f%%\n", maskedPixels, 100. * maskedPixels / totalPixels);
    1024             printf("nand pixels:   %10ld %4.2f%%\n", nandPixels, 100. * nandPixels / totalPixels);
     1020            psLogMsg(sfiles->program_name, PS_LOG_INFO, "pixels:        %10ld\n", totalPixels);
     1021            psLogMsg(sfiles->program_name, PS_LOG_INFO, "masked pixels: %10ld %4.2f%%\n", maskedPixels, 100. * maskedPixels / totalPixels);
     1022            psLogMsg(sfiles->program_name, PS_LOG_INFO, "nand pixels:   %10ld %4.2f%%\n", nandPixels, 100. * nandPixels / totalPixels);
    10251023            if (weight) {
    1026                 printf("nand weights:  %10ld %4.2f%%\n", nandWeights, 100. * nandWeights / totalPixels);
     1024                psLogMsg(sfiles->program_name, PS_LOG_INFO, "nand weights:  %10ld %4.2f%%\n", nandWeights, 100. * nandWeights / totalPixels);
    10271025            }
    10281026        }
     
    10351033    ourNebServer = NULL;
    10361034}
     1035static void
     1036setExciseValue(sFile *in)
     1037{
     1038    if (in->image->type.type == PS_TYPE_U16) {
     1039        in->exciseValue = 65535;
     1040        psMetadataAddU16(in->header, PS_LIST_TAIL, "BLANK", 0, "", 65535);
     1041        psMetadataAddU16(in->header, PS_LIST_TAIL, "ZBLANK", 0, "", 65535);
     1042    } else {
     1043        in->exciseValue = NAN;
     1044    }
     1045}
     1046
     1047void
     1048strkGetMaskValues(streakFiles *sfiles, psU32 *maskStreak, psU32 *maskMask)
     1049{
     1050    if (sfiles->inMask && sfiles->inMask->header) {
     1051        if (!pmConfigMaskReadHeader(sfiles->config, sfiles->inMask->header)) {
     1052            streaksExit("failed to read mask values from file", PS_EXIT_CONFIG_ERROR);
     1053        }
     1054    }
     1055
     1056    bool status;
     1057    psMetadata *masks = psMetadataLookupMetadata(&status, sfiles->config->recipes, "MASKS");
     1058    if (!status) {
     1059        psError(PM_ERR_CONFIG, false, "failed to lookup MASKS in recipes\n");
     1060        streaksExit("", PS_EXIT_CONFIG_ERROR);
     1061    }
     1062    *maskStreak = psMetadataLookupU32(&status, masks, "STREAK");
     1063    if (!status) {
     1064        psError(PM_ERR_CONFIG, false, "failed to lookup mask value for STREAK in recipes\n");
     1065        streaksExit("", PS_EXIT_CONFIG_ERROR);
     1066    }
     1067
     1068    // optionally setting pixels with any mask bits execpt CONV.POOR to NAN
     1069    // check old name first
     1070    psU32 convPoor = (double) psMetadataLookupU32(&status, masks, "POOR.WARP");
     1071    if (!status) {
     1072        convPoor = (double) psMetadataLookupU32(&status, masks, "CONV.POOR");
     1073        if (!status) {
     1074            psError(PM_ERR_CONFIG, false, "failed to lookup mask value for CONV.POOR in recipes\n");
     1075            streaksExit("", PS_EXIT_CONFIG_ERROR);
     1076        }
     1077    }
     1078    *maskMask = ~convPoor;
     1079}
Note: See TracChangeset for help on using the changeset viewer.