IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
May 3, 2010, 8:41:49 AM (16 years ago)
Author:
eugene
Message:

updates from trunk

Location:
branches/tap_branches
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • branches/tap_branches

  • branches/tap_branches/magic

    • Property svn:ignore
      •  

        old new  
        11magic
        22ssa-core-cpp
        3 Makefile
        43Makefile.bak
  • branches/tap_branches/magic/remove

    • Property svn:ignore set to
      configure
      Makefile.in
      Doxyfile
      config.log
      depcomp
      config.status
      config.guess
      ltmain.sh
      config.sub
      autom4te.cache
      libtool
      missing
      Makefile
      aclocal.m4
      install-sh

  • branches/tap_branches/magic/remove/src

    • Property svn:ignore
      •  

        old new  
        44streakscompare
        55streaksrelease
        6 makefile
         6Makefile
         7Makefile.in
         8config.h
         9.deps
         10streaksVersionDefinitions.h
         11config.h.in
         12stamp-h1
  • branches/tap_branches/magic/remove/src/streaksio.c

    r25469 r27838  
    121121    sf->transparentStreaks = psMetadataLookupF64(&status, config->arguments, "TRANSPARENT_STREAKS");
    122122
     123    sf->stats = psMetadataAlloc();
     124    psString statsFileName= psMetadataLookupStr(&status, config->arguments, "STATS");
     125    if (statsFileName) {
     126        sf->statsFile = fopen(statsFileName, "w");
     127        if (!sf->statsFile) {
     128            psError(PS_ERR_IO, true, "failed to open stats file %s", statsFileName);
     129            streaksExit("", PS_EXIT_CONFIG_ERROR);
     130        }
     131    }
     132
    123133    return sf;
    124134}
     
    128138{
    129139    freeImages(sf);
    130     psFree(sf->warpedPixels);
     140    psFree(sf->diffedPixels);
    131141    psFree(sf->tiles);
    132142    psFree(sf->view);
     
    800810        return;
    801811    }
     812    streaksVersionHeaderFull(sfile->header);
     813
    802814    if (!psFitsWriteImage(sfile->fits, sfile->header, sfile->image, 0, extname)) {
    803815        psError(PS_ERR_IO, false, "failed to write image to %s extnum: %d",
     
    817829        return;
    818830    }
     831    streaksVersionHeaderFull(sfile->header);
    819832    if (!psFitsWriteImageCube(sfile->fits, sfile->header, imagecube, extname)) {
    820833        psError(PS_ERR_IO, false, "failed to write image to %s extnum: %d",
     
    851864    sfile->header = NULL;
    852865    psFree(sfile->image);
    853     sfile->header = NULL;
     866    sfile->image = NULL;
    854867    psFree(sfile->imagecube);
    855     sfile->header = NULL;
     868    sfile->imagecube = NULL;
    856869}
    857870
     
    859872closeImages(streakFiles *sf)
    860873{
     874    if (sf->stage == IPP_STAGE_RAW) {
     875        if (sf->view) {
     876            sf->view->readout = -1;
     877            pmFPAfileIOChecks(sf->config, sf->view, PM_FPA_AFTER);
     878            sf->view->cell = -1;
     879            pmFPAfileIOChecks(sf->config, sf->view, PM_FPA_AFTER);
     880            sf->view->chip = -1;
     881            pmFPAfileIOChecks(sf->config, sf->view, PM_FPA_AFTER);
     882        }
     883    }
    861884    closeImage(sf->inImage);
    862885    closeImage(sf->outImage);
     
    913936    bool free_user_copies = true;
    914937    if (user_copies == NULL) {
    915         user_copies = "2";
    916         free_user_copies = false;
     938        // input does not have replication requested
     939        return true;
    917940    }
    918941    if (!nebSetXattr(server, outFile->name, "user.copies", user_copies,  NEB_REPLACE)) {
     
    920943        return false;
    921944    }
    922     if (!nebReplicate(server, outFile->name, "any", NULL)) {
     945    if (!nebReplicate(server, outFile->name, NULL, NULL)) {
    923946        psError(PM_ERR_UNKNOWN, true, "nebReplicate failed for %s\n%s", outFile->name, nebErr(server));
    924947        return false;
     
    11111134
    11121135        psImage *image = sfiles->outImage->image;
     1136        int imageType = image->type.type;
     1137        double exciseValue = sfiles->inImage->exciseValue;
     1138
    11131139        psImage *mask = sfiles->inMask->image;
    11141140        psImage *weight = NULL;
     1141        int weightType = 0;
     1142        double weightExciseValue = NAN;
    11151143        if (sfiles->outWeight) {
    11161144            weight = sfiles->outWeight->image;
    1117         }
    1118         double exciseValue = sfiles->inImage->exciseValue;
     1145            weightType = weight->type.type;
     1146            weightExciseValue = sfiles->inWeight->exciseValue;
     1147        }
    11191148
    11201149        if (printCounts) {
     
    11261155                // these gets are not necessary, we could just set the pixels to nan
    11271156                // but I want to get the counts
    1128                 double imageVal  = image->data.F32[y][x];
    1129                 psU32 maskVal;
     1157                double imageVal = 0; // avoid compiler warning
     1158                if (imageType == PS_TYPE_F32) {
     1159                    imageVal  = image->data.F32[y][x];
     1160                } else if (imageType == PS_TYPE_S16) {
     1161                    imageVal = image->data.S16[y][x];
     1162                } else if (imageType == PS_TYPE_U16) {
     1163                    imageVal = image->data.U16[y][x];
     1164                } else {
     1165                    psError(PS_ERR_PROGRAMMING, true, "unexpected image type found: %d\n",
     1166                                imageType);
     1167                    streaksExit("", PS_EXIT_PROG_ERROR);
     1168                }
     1169                psU32 maskVal = 0;
    11301170                if (sfiles->stage == IPP_STAGE_RAW) {
    11311171                    unsigned int xChip, yChip;
     
    11371177                if (maskVal & maskMask) {
    11381178                    ++maskedPixels;
    1139                     if (!isExciseValue(imageVal, sfiles->inImage->exciseValue)) {
     1179                    if (!isExciseValue(imageVal, exciseValue)) {
    11401180                        ++nandPixels;
    1141                         image->data.F32[y][x] = exciseValue;
     1181                        if (imageType == PS_TYPE_F32) {
     1182                            image->data.F32[y][x] = exciseValue;
     1183                        } else if (imageType == PS_TYPE_S16) {
     1184                            image->data.S16[y][x] = exciseValue;
     1185                        } else if (imageType == PS_TYPE_U16) {
     1186                            image->data.U16[y][x] = exciseValue;
     1187                        } else {
     1188                            psError(PS_ERR_PROGRAMMING, true, "unexpected image type found: %d\n",
     1189                                imageType);
     1190                            streaksExit("", PS_EXIT_PROG_ERROR);
     1191                        }
    11421192                    }
    11431193                    if (weight) {
    1144                         double weightVal = weight ? weight->data.F32[y][x] : 0;
    1145                         if (!isnan(weightVal)) {
    1146                             ++nandWeights;
    1147                             weight->data.F32[y][x] = NAN;
     1194                        if (weightType == PS_TYPE_F32) {
     1195                            double weightVal = weight->data.F32[y][x];
     1196                            if (!isnan(weightVal)) {
     1197                                ++nandWeights;
     1198                                weight->data.F32[y][x] = NAN;
     1199                            }
     1200                        } else if(weightType == PS_TYPE_S16) {
     1201                            double weightVal = weight->data.S16[y][x];
     1202                            if (!isExciseValue(weightVal, weightExciseValue)) {
     1203                                ++nandWeights;
     1204                                image->data.S16[y][x] = weightExciseValue;
     1205                            }
     1206                        } else if (weightType == PS_TYPE_U16) {
     1207                            double weightVal = weight->data.U16[y][x];
     1208                            if (!isExciseValue(weightVal, weightExciseValue)) {
     1209                                ++nandWeights;
     1210                                image->data.U16[y][x] = weightExciseValue;
     1211                            }
     1212                        } else {
     1213                            psError(PS_ERR_PROGRAMMING, true, "unexpected image type found: %d\n",
     1214                                    weightType);
     1215                                streaksExit("", PS_EXIT_PROG_ERROR);
    11481216                        }
    11491217                    }
     
    11761244        psMetadataAddU16(in->header, PS_LIST_TAIL, "BLANK", 0, "", 65535);
    11771245        psMetadataAddU16(in->header, PS_LIST_TAIL, "ZBLANK", 0, "", 65535);
    1178     } else {
     1246    } else if (in->image->type.type == PS_TYPE_S16) {
     1247        in->exciseValue = 32767;
     1248        psMetadataAddU16(in->header, PS_LIST_TAIL, "BLANK", 0, "", 32767);
     1249        psMetadataAddU16(in->header, PS_LIST_TAIL, "ZBLANK", 0, "", 32767);
     1250    } else if (in->image->type.type == PS_TYPE_F32) {
    11791251        in->exciseValue = NAN;
    1180     }
    1181 }
    1182 
    1183 void
    1184 strkGetMaskValues(streakFiles *sfiles, psU32 *maskStreak, psU32 *maskMask)
    1185 {
     1252    } else {
     1253        psError(PS_ERR_PROGRAMMING, true, "unexpected image type found: %d\n", in->image->type.type);
     1254        streaksExit("", PS_EXIT_PROG_ERROR);
     1255    }
     1256}
     1257
     1258// Get the mask values that we need.
     1259// If an input mask file is provided get them from there.
     1260// Otherwise get them from the recipe MASKS
     1261void
     1262strkGetMaskValues(streakFiles *sfiles)
     1263{
     1264    if (sfiles->maskStreak) {
     1265        // already done
     1266        return;
     1267    }
    11861268    if (sfiles->inMask && sfiles->inMask->header) {
    11871269        if (!pmConfigMaskReadHeader(sfiles->config, sfiles->inMask->header)) {
     
    11961278        streaksExit("", PS_EXIT_CONFIG_ERROR);
    11971279    }
    1198     *maskStreak = psMetadataLookupU32(&status, masks, "STREAK");
     1280    sfiles->maskStreak = psMetadataLookupU32(&status, masks, "STREAK");
    11991281    if (!status) {
    12001282        psError(PM_ERR_CONFIG, false, "failed to lookup mask value for STREAK in recipes\n");
     
    12121294        }
    12131295    }
    1214     *maskMask = ~convPoor;
     1296    sfiles->maskMask = ~convPoor;
    12151297}
    12161298
Note: See TracChangeset for help on using the changeset viewer.