IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jul 30, 2009, 5:20:29 PM (17 years ago)
Author:
watersc1
Message:

Finished up my edits to the detrend cleanup, and some changes to my
copy of burntool and the pslib astrometry. Detrend cleanup has not
been tested yet. That's up next.

Location:
branches/czw_branch/cleanup
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • branches/czw_branch/cleanup

  • branches/czw_branch/cleanup/magic/remove/src

    • Property svn:ignore
      •  

        old new  
         1isdestreaked
        12streaksremove
        23streaksreplace
  • branches/czw_branch/cleanup/magic/remove/src/Makefile.simple

    r24556 r24951  
    3737STREAKSFLAGS=-DSTREAKS_COMPRESS_OUTPUT=1
    3838OPTFLAGS= -g -O2
    39 OPTFLAGS= -g
     39#OPTFLAGS= -g
    4040CFLAGS=`psmodules-config --cflags` -std=gnu99 ${OPTFLAGS} ${STREAKSFLAGS}
    4141#CFLAGS=`psmodules-config --cflags` -std=gnu99 ${OPTFLAGS}
  • branches/czw_branch/cleanup/magic/remove/src/isdestreaked.c

    r24556 r24951  
    2121        psErrorStackPrint(stderr, "");
    2222        exit(PS_EXIT_DATA_ERROR);
    23         return false;
    2423    }
    2524
     
    2827        psError(PS_ERR_IO, false, "failed to read header for: %s", fileName);
    2928        psErrorStackPrint(stderr, "");
    30         return false;
     29        exit(PS_EXIT_DATA_ERROR);
    3130    }
    3231
     
    3433    bool isDestreaked = psMetadataLookupBool(&mdok, header, "PSDESTRK");
    3534    if (mdok && isDestreaked) {
     35        printf("%s is a destreaked file\n", fileName);
    3636        exit(0);
    3737    } else {
     38        printf("%s is not a destreaked file\n", fileName);
    3839        exit(42);
    3940    }
  • branches/czw_branch/cleanup/magic/remove/src/streaksastrom.c

    r24382 r24951  
    377377}
    378378
    379 void
     379bool
    380380linearizeTransforms(strkAstrom *astrom)
    381381{
    382382    if (!pmAstromLinearizeTransforms((pmFPA *) astrom->fpa, (pmChip *) astrom->chip)) {
    383         streaksExit("linear fit to astrometry failed\n", PS_EXIT_UNKNOWN_ERROR);
    384     }
    385 }
     383        // streaksExit("linear fit to astrometry failed\n", PS_EXIT_UNKNOWN_ERROR);
     384        psError(PS_ERR_UNKNOWN, false, "linear fit to astrometry failed ignoring");
     385        return false;
     386    }
     387    return true;
     388}
  • branches/czw_branch/cleanup/magic/remove/src/streaksastrom.h

    r24382 r24951  
    3030extern bool skyToCell(strkPt *, strkAstrom *astrom, double ra, double dec);
    3131extern bool cellToSky(strkPt *, strkAstrom *astrom, double x, double y);
    32 extern void linearizeTransforms(strkAstrom *astrom);
     32extern bool linearizeTransforms(strkAstrom *astrom);
    3333
    3434extern bool SkyToLocal(strkPt *outPt, strkAstrom *astrom, double ra, double dec);
  • branches/czw_branch/cleanup/magic/remove/src/streaksio.c

    r24691 r24951  
    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.
     
    6671    // if we are passed a mask it is camera stage mask and we also
    6772    // need to destreak the chip level mask file as well
     73    // If it doesn't exist, we didn't have a camera mask
    6874    if (remove && sf->inMask && (stage == IPP_STAGE_CHIP)) {
    69         sf->inChMask = sFileOpen(config, stage, "INPUT.CHMASK", NULL, true);
    70         inputBasename = basename(sf->inChMask->name);
    71         sf->outChMask = sFileOpen(config, stage, "OUTPUT", inputBasename, true);
    72         sf->recChMask = sFileOpen(config, stage, "RECOVERY", inputBasename, false);
     75        sf->inChMask = sFileOpen(config, stage, "INPUT.CHMASK", NULL, false);
     76        if (sf->inChMask) {
     77            inputBasename = basename(sf->inChMask->name);
     78            sf->outChMask = sFileOpen(config, stage, "OUTPUT", inputBasename, true);
     79            sf->recChMask = sFileOpen(config, stage, "RECOVERY", inputBasename, false);
     80        }
    7381    }
    7482
     
    282290        // copy header from fpu
    283291        sfile->header = (psMetadata*) psMemIncrRefCounter(sfile->pmfile->fpa->hdu->header);
     292
     293        sfile->nHDU = psFitsGetSize(sfile->pmfile->fits);
    284294
    285295        return sfile;
     
    11951205    *maskMask = ~convPoor;
    11961206}
     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}
  • branches/czw_branch/cleanup/magic/remove/src/streaksio.h

    r24556 r24951  
    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);
  • branches/czw_branch/cleanup/magic/remove/src/streaksrelease.c

    r24381 r24951  
    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");
  • branches/czw_branch/cleanup/magic/remove/src/streaksremove.c

    r24691 r24951  
    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.
     
    483488    if (sf->bilevelAstrometry) {
    484489
    485         linearizeTransforms(sf->astrom);
     490        if (!linearizeTransforms(sf->astrom)) {
     491            // fit failed, leave the astrometry unchanged
     492            return;
     493        }
    486494
    487495        if (!pmAstromWriteWCS(sf->outImage->header, sf->inAstrom->fpa, sf->chip, 0.001)) {
Note: See TracChangeset for help on using the changeset viewer.