IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Mar 29, 2010, 3:55:49 PM (16 years ago)
Author:
eugene
Message:

update merges from trunk

Location:
branches/eam_branches/20100225
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/20100225

  • branches/eam_branches/20100225/magic/remove/src/streaksio.c

    r26983 r27517  
    811811    }
    812812    streaksVersionHeaderFull(sfile->header);
     813
    813814    if (!psFitsWriteImage(sfile->fits, sfile->header, sfile->image, 0, extname)) {
    814815        psError(PS_ERR_IO, false, "failed to write image to %s extnum: %d",
     
    871872closeImages(streakFiles *sf)
    872873{
     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    }
    873884    closeImage(sf->inImage);
    874885    closeImage(sf->outImage);
     
    11231134
    11241135        psImage *image = sfiles->outImage->image;
     1136        int imageType = image->type.type;
     1137        double exciseValue = sfiles->inImage->exciseValue;
     1138
    11251139        psImage *mask = sfiles->inMask->image;
    11261140        psImage *weight = NULL;
     1141        int weightType = 0;
     1142        double weightExciseValue = NAN;
    11271143        if (sfiles->outWeight) {
    11281144            weight = sfiles->outWeight->image;
    1129         }
    1130         double exciseValue = sfiles->inImage->exciseValue;
     1145            weightType = weight->type.type;
     1146            weightExciseValue = sfiles->inWeight->exciseValue;
     1147        }
    11311148
    11321149        if (printCounts) {
     
    11381155                // these gets are not necessary, we could just set the pixels to nan
    11391156                // but I want to get the counts
    1140                 double imageVal  = image->data.F32[y][x];
    1141                 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;
    11421170                if (sfiles->stage == IPP_STAGE_RAW) {
    11431171                    unsigned int xChip, yChip;
     
    11491177                if (maskVal & maskMask) {
    11501178                    ++maskedPixels;
    1151                     if (!isExciseValue(imageVal, sfiles->inImage->exciseValue)) {
     1179                    if (!isExciseValue(imageVal, exciseValue)) {
    11521180                        ++nandPixels;
    1153                         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                        }
    11541192                    }
    11551193                    if (weight) {
    1156                         double weightVal = weight ? weight->data.F32[y][x] : 0;
    1157                         if (!isnan(weightVal)) {
    1158                             ++nandWeights;
    1159                             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);
    11601216                        }
    11611217                    }
     
    11881244        psMetadataAddU16(in->header, PS_LIST_TAIL, "BLANK", 0, "", 65535);
    11891245        psMetadataAddU16(in->header, PS_LIST_TAIL, "ZBLANK", 0, "", 65535);
    1190     } 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) {
    11911251        in->exciseValue = NAN;
     1252    } else {
     1253        psError(PS_ERR_PROGRAMMING, true, "unexpected image type found: %d\n", in->image->type.type);
     1254        streaksExit("", PS_EXIT_PROG_ERROR);
    11921255    }
    11931256}
Note: See TracChangeset for help on using the changeset viewer.