IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Sep 15, 2009, 4:02:42 PM (17 years ago)
Author:
eugene
Message:

updates from trunk

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/20090715/magic/remove/src/streaksio.c

    r25022 r25406  
    1212// Assumptions about the file structure of non-raw files
    1313// The 'image' for each file (image, mask weight) is contained in the first
    14 // extension. 
     14// extension.
    1515
    1616
     
    625625        streaksExit("", PS_EXIT_DATA_ERROR);
    626626    }
    627  
     627
    628628    bool status;
    629629    in->extname = psMetadataLookupStr(&status, in->header, "EXTNAME");
     
    654654            streaksExit("", PS_EXIT_DATA_ERROR);
    655655        }
    656         psImage *image = (psImage *) (in->imagecube->data[0]);
     656
     657        // Ensure input is of the expected type
     658        psDataType expected = isMask ? PS_TYPE_IMAGE_MASK : PS_TYPE_F32; // Expected type for image
     659        for (int i = 0; i < in->imagecube->n; i++) {
     660            psImage *image = in->imagecube->data[i]; // Image of interest
     661            if (image->type.type != expected) {
     662                psImage *temp = psImageCopy(NULL, image, expected);
     663                psFree(image);
     664                in->imagecube->data[i] = temp;
     665            }
     666        }
    657667    }
    658668    setDataExtent(stage, in, (stage == IPP_STAGE_RAW) && !isMask);
     
    671681    sfile->fits->options = psFitsOptionsAlloc();
    672682    sfile->fits->options->scaling = PS_FITS_SCALE_MANUAL;
     683    sfile->fits->options->fuzz = false;
    673684    sfile->fits->options->bitpix = bitpix;
    674685    sfile->fits->options->bscale = bscale;
     
    925936replicateOutputs(streakFiles *sfiles)
    926937{
    927     bool status = false;
    928 
    929938    if (!replicate(sfiles->outImage, sfiles->inImage)) {
    930939        psError(PM_ERR_SYS, false, "failed to replicate outImage.");
     
    973982
    974983        if (!nebSwap(server, in->name, out->name)) {
    975             psError(PM_ERR_SYS, true, "failed to swap files for: %s.",
     984            psError(PM_ERR_SYS, true, "failed to swap files for %s: %s.",
    976985                in->name, nebErr(server));
    977986            return false;
     
    10971106setMaskedToNAN(streakFiles *sfiles, psU32 maskMask, bool printCounts)
    10981107{
    1099         int maskedPixels = 0;
    1100         int nandPixels = 0;
    1101         int nandWeights = 0;
     1108        long maskedPixels = 0;
     1109        long nandPixels = 0;
     1110        long nandWeights = 0;
    11021111
    11031112        psImage *image = sfiles->outImage->image;
     
    11171126                // these gets are not necessary, we could just set the pixels to nan
    11181127                // but I want to get the counts
    1119                 double imageVal  = psImageGet(image, x, y);
     1128                double imageVal  = image->data.F32[y][x];
    11201129                psU32 maskVal;
    11211130                if (sfiles->stage == IPP_STAGE_RAW) {
    1122                     int xChip, yChip;
     1131                    unsigned int xChip, yChip;
    11231132                    cellToChipInt(&xChip, &yChip, sfiles->astrom, x, y);
    1124                     maskVal = psImageGet(mask, xChip, yChip);
     1133                    maskVal = mask->data.PS_TYPE_IMAGE_MASK_DATA[yChip][xChip];
    11251134                } else {
    1126                     maskVal = psImageGet(mask, x, y);
     1135                    maskVal = mask->data.PS_TYPE_IMAGE_MASK_DATA[y][x];
    11271136                }
    11281137                if (maskVal & maskMask) {
     
    11301139                    if (!isExciseValue(imageVal, sfiles->inImage->exciseValue)) {
    11311140                        ++nandPixels;
    1132                         psImageSet(image, x, y, exciseValue);
     1141                        image->data.F32[y][x] = exciseValue;
    11331142                    }
    11341143                    if (weight) {
    1135                         double weightVal = weight ? psImageGet(weight, x, y) : 0;
     1144                        double weightVal = weight ? weight->data.F32[y][x] : 0;
    11361145                        if (!isnan(weightVal)) {
    11371146                            ++nandWeights;
    1138                             psImageSet(weight, x, y, NAN);
     1147                            weight->data.F32[y][x] = NAN;
    11391148                        }
    11401149                    }
     
    11441153        if (printCounts) {
    11451154            psLogMsg(sfiles->program_name, PS_LOG_INFO, "time to NAN mask pixels: %f\n", psTimerClear("NAN_MASKED"));
    1146             int totalPixels = image->numRows * image->numCols;
     1155            long totalPixels = image->numRows * image->numCols;
    11471156            psLogMsg(sfiles->program_name, PS_LOG_INFO, "pixels:        %10ld\n", totalPixels);
    11481157            psLogMsg(sfiles->program_name, PS_LOG_INFO, "masked pixels: %10ld %4.2f%%\n", maskedPixels, 100. * maskedPixels / totalPixels);
     
    12151224        if (SFILE_IS_IMAGE(in)) {
    12161225            // Turn off compression (code adapted from pmFPAWrite)
    1217 #ifdef SAVE_AND_RESTORE_COMPRESSION
    12181226            int bitpix = out->fits->options ? out->fits->options->bitpix : 0; // Desired bits per pixel
    12191227            psFitsCompression *compress = psFitsCompressionGet(out->fits); // Current compression options
    1220 #endif
    12211228            if (!psFitsSetCompression(out->fits, PS_FITS_COMPRESS_NONE, NULL, 0, 0, 0)) {
    12221229                psError(PM_ERR_UNKNOWN, false, "failed to turn off compression for extension %d\n", extnum);
    12231230                streaksExit("", PS_EXIT_UNKNOWN_ERROR);
    12241231            }
    1225 #ifdef SAVE_AND_RESTORE_COMPRESSION
    12261232            if (out->fits->options) {
    12271233                out->fits->options->bitpix = 0;
     
    12381244                streaksExit("", PS_EXIT_UNKNOWN_ERROR);
    12391245            }
    1240 #endif
    12411246        } else {
    12421247            copyTable(out, in, extnum);
Note: See TracChangeset for help on using the changeset viewer.