IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 24853


Ignore:
Timestamp:
Jul 20, 2009, 8:27:16 AM (17 years ago)
Author:
bills
Message:

Check for extra extensions following the pixels and if found copy
to the output files

Location:
trunk/magic/remove/src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/magic/remove/src/streaksio.c

    r24728 r24853  
    99
    1010static nebServer *ourNebServer = NULL;
     11
     12// Assumptions about the file structure of non-raw files
     13// The 'image' for each file (image, mask weight) is contained in the first
     14// extension.
     15
    1116
    1217// open the files required for streaks procesing.
     
    285290        // copy header from fpu
    286291        sfile->header = (psMetadata*) psMemIncrRefCounter(sfile->pmfile->fpa->hdu->header);
     292
     293        sfile->nHDU = psFitsGetSize(sfile->pmfile->fits);
    287294
    288295        return sfile;
     
    11981205    *maskMask = ~convPoor;
    11991206}
     1207
     1208static void
     1209doCopyExtraExtensions(streakFiles *sf, sFile *in, sFile *out)
     1210{
     1211    for (int extnum = sf->extnum; extnum < in->nHDU; extnum++) {
     1212        moveExt(in, extnum);
     1213        readImage(in, extnum, sf->stage, false);
     1214
     1215        if (SFILE_IS_IMAGE(in)) {
     1216            // Turn off compression (code adapted from pmFPAWrite)
     1217#ifdef SAVE_AND_RESTORE_COMPRESSION
     1218            int bitpix = out->fits->options ? out->fits->options->bitpix : 0; // Desired bits per pixel
     1219            psFitsCompression *compress = psFitsCompressionGet(out->fits); // Current compression options
     1220#endif
     1221            if (!psFitsSetCompression(out->fits, PS_FITS_COMPRESS_NONE, NULL, 0, 0, 0)) {
     1222                psError(PM_ERR_UNKNOWN, false, "failed to turn off compression for extension %d\n", extnum);
     1223                streaksExit("", PS_EXIT_UNKNOWN_ERROR);
     1224            }
     1225#ifdef SAVE_AND_RESTORE_COMPRESSION
     1226            if (out->fits->options) {
     1227                out->fits->options->bitpix = 0;
     1228            }
     1229            if (!psFitsWriteImage(out->fits, in->header, in->image, 0, in->extname)) {
     1230                psError(PM_ERR_UNKNOWN, false, "failed to write image for extension %d\n", extnum);
     1231                streaksExit("", PS_EXIT_UNKNOWN_ERROR);
     1232            }
     1233            if (out->fits->options) {
     1234                out->fits->options->bitpix = bitpix;
     1235            }
     1236            if (!psFitsCompressionApply(out->fits, compress)) {
     1237                psError(PM_ERR_UNKNOWN, false, "failed to rest compression image for extension %d\n", extnum);
     1238                streaksExit("", PS_EXIT_UNKNOWN_ERROR);
     1239            }
     1240#endif
     1241        } else {
     1242            copyTable(out, in, extnum);
     1243        }
     1244    }
     1245}
     1246
     1247void
     1248copyExtraExtensions(streakFiles *sf)
     1249{
     1250    // XXX: Bad assumption, the begining of the mask and weight files have the same structure as the image
     1251    // So we are currently at the image portion
     1252    sf->extnum = sf->inImage->nHDU;
     1253
     1254    if (sf->inWeight && sf->outWeight) {
     1255        doCopyExtraExtensions(sf, sf->inWeight, sf->outWeight);
     1256    }
     1257    if (sf->inMask && sf->outMask) {
     1258        doCopyExtraExtensions(sf, sf->inMask, sf->outMask);
     1259    }
     1260    if (sf->inChMask && sf->outChMask) {
     1261        doCopyExtraExtensions(sf, sf->inChMask, sf->outChMask);
     1262    }
     1263}
  • trunk/magic/remove/src/streaksio.h

    r24556 r24853  
    1717void setupImageRefs(sFile *out, sFile *recoveryOut, sFile *in, int extnum, bool exciseAll);
    1818void strkGetMaskValues(streakFiles *sfiles, psU32 *maskStreak, psU32 *maskMask);
     19void copyExtraExtensions(streakFiles *sfiles);
    1920
    2021void writeImage(sFile *sfile, psString extname, int extnum);
  • trunk/magic/remove/src/streaksrelease.c

    r24381 r24853  
    6767        printf("time to process component %d: %f\n", sfiles->extnum, psTimerClear("PROCESS_COMPONENT"));
    6868    } while (streakFilesNextExtension(sfiles));
     69
     70    // check the weight and mask files for extra extensions that might be in files
     71    // (covariance matrix for example)
     72    copyExtraExtensions(sfiles);
     73
     74
    6975
    7076    psTimerStart("CLOSE_IMAGES");
  • trunk/magic/remove/src/streaksremove.c

    r24716 r24853  
    198198    } while (streakFilesNextExtension(sfiles));
    199199
     200
    200201    psFree(streaks);
    201202
    202203    psLogMsg("streaksremove", PS_LOG_INFO, "pixels: %ld streak pixels: %ld %4.2f%%\n", totalPixels, totalStreakPixels, 100. * totalStreakPixels / totalPixels);
     204
     205    // check the weight and mask files for extra extensions that might be in files
     206    // (covariance matrix for example)
     207    copyExtraExtensions(sfiles);
    203208
    204209    // all done close the files. This is where the files are written so it can take a long time.
Note: See TracChangeset for help on using the changeset viewer.