IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 30871


Ignore:
Timestamp:
Mar 10, 2011, 5:31:06 PM (15 years ago)
Author:
eugene
Message:

propagate the header information to the output files in the psphotStack context

Location:
branches/eam_branches/ipp-20110213/psphot/src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20110213/psphot/src/psphotDeblendSatstars.c

    r29936 r30871  
    8686        // XXX filter? if (source->mode & PM_SOURCE_MODE_SATSTAR) continue;
    8787        if (source->mode & PM_SOURCE_MODE_BLEND) continue;
    88         if (source->peak->flux < SATURATION) continue;
     88        if (source->peak->flux < SAT_TEST_LEVEL) continue;
    8989
    9090        // save these for reference below
  • branches/eam_branches/ipp-20110213/psphot/src/psphotStackImageLoop.c

    r30776 r30871  
    11# include "psphotStandAlone.h"
    2 #define WCS_NONLIN_TOL 0.001            // Non-linear tolerance for header WCS
    32
    43# define ESCAPE(MESSAGE) {                              \
     
    87    }
    98
    10 bool GetAstrometryFPA (pmConfig *config, pmFPAview *view);
    11 bool SetAstrometryFPA (pmConfig *config, pmFPAview *view, bool bilevelAstrometry);
    12 bool GetAstrometryChip (pmConfig *config, pmFPAview *view, bool bilevelAstrometry);
     9// XXX this implementation is not smart about multi-level astrometry headers
     10bool UpdateHeadersForFPA (pmConfig *config, pmFPAview *view);
     11bool UpdateHeadersForChip (pmConfig *config, pmFPAview *view);
    1312
    1413bool psphotStackImageLoop (pmConfig *config) {
     
    3433    // XXX for now, just load the full set of images up front
    3534    if (!pmFPAfileIOChecks (config, view, PM_FPA_BEFORE)) ESCAPE ("failed input for fpa in psphot.");
    36 
    37     bool bilevelAstrometry = GetAstrometryFPA(config, view);
    3835
    3936    // for psphot, we force data to be read at the chip level
     
    8380        }
    8481
    85         GetAstrometryChip(config, view, bilevelAstrometry);
     82        UpdateHeadersForChip(config, view);
    8683
    8784        // save output which is saved at the chip level
     
    9087    psMemDump("doneloop");
    9188
    92     SetAstrometryFPA(config, view, bilevelAstrometry);
    93    
     89    UpdateHeadersForFPA(config, view);
     90
    9491    // save output which is saved at the fpa level
    9592    if (!pmFPAfileIOChecks (config, view, PM_FPA_AFTER)) ESCAPE ("failed ouput for FPA in psphot.");
     
    104101}
    105102
    106 /*
    107    the easiest way to implement this is to assume we can pre-load the full set of images up front.
    108    with 5 filters and 6000^2 (image, mask, var = 10 byte per pixel), we need 1.8GB, which is not too bad.
    109 */
    110 
    111 # define UPDATE_HEADER 1
    112 
    113 bool GetAstrometryFPA (pmConfig *config, pmFPAview *view) {
    114 
    115     bool foundAstrometry = false;
    116     bool bilevelAstrometry = false;
     103bool UpdateHeadersForChip (pmConfig *config, pmFPAview *view) {
    117104
    118105    int num = psphotFileruleCount(config, "PSPHOT.INPUT");
     
    130117        psAssert (input, "missing input file");
    131118
    132         // find the FPA phu
    133         pmHDU *phu = pmFPAviewThisPHU(view, input->fpa);
    134         if (!phu) {
    135             psWarning("Unable to read bilevel mosaic astrometry for input FPA entry %d", i);
    136             continue;
     119        // just copy the input headers to the output headers, then update version info
     120        pmChip *inChip = pmFPAviewThisChip(view, input->fpa); ///< Chip in the input
     121        pmHDU *inHDU = pmFPAviewThisHDU (view, input->fpa);
     122
     123        pmChip *outChip = pmFPAviewThisChip(view, output->fpa); ///< Chip in the output
     124        pmHDU *outHDU = pmFPAviewThisHDU (view, output->fpa);
     125        if (!outHDU) {
     126            pmFPAAddSourceFromView(output->fpa, view, output->format);
     127            outHDU = pmFPAviewThisHDU (view, output->fpa);
     128            psAssert (outHDU, "failed to make HDU");
    137129        }
    138 
    139         char *ctype = psMetadataLookupStr(NULL, phu->header, "CTYPE1");
    140         if (!ctype) {
    141             psWarning("Error in WCS keywords for input FPA entry %d", i);
    142             continue;
     130        if (!outHDU->header) {
     131            outHDU->header = psMetadataCopy(NULL, inHDU->header);
    143132        }
    144 
    145         if (!foundAstrometry) {
    146             bilevelAstrometry = !strcmp (&ctype[4], "-DIS");
    147         } else {
    148             if (bilevelAstrometry != !strcmp (&ctype[4], "-DIS")) {
    149                 psAbort("astrometry type mis-match");
    150             }
    151         }
    152 
    153         if (bilevelAstrometry) {
    154             // update the output structures
    155             if (!pmAstromReadBilevelMosaic(output->fpa, phu->header)) {
    156                 psWarning("Unable to read bilevel mosaic astrometry for input FPA.");
    157             }
    158         }
     133        outChip->toFPA = psMemIncrRefCounter(inChip->toFPA);
     134        outChip->fromFPA = psMemIncrRefCounter(inChip->fromFPA);
    159135    }
    160     return bilevelAstrometry;
     136    return true;
    161137}
    162138
    163 bool GetAstrometryChip (pmConfig *config, pmFPAview *view, bool bilevelAstrometry) {
     139bool UpdateHeadersForFPA (pmConfig *config, pmFPAview *view) {
    164140
    165141    int num = psphotFileruleCount(config, "PSPHOT.INPUT");
     
    177153        psAssert (input, "missing input file");
    178154
    179         // Need to update the output for astrometry.  Read WCS data from the corresponding
    180         // header and save in the output fpa
    181         pmHDU *inHDU = pmFPAviewThisHDU (view, input->fpa);
    182         pmChip *outChip = pmFPAviewThisChip(view, output->fpa); ///< Chip in the output
     155        output->fpa->toTPA = psMemIncrRefCounter(input->fpa->toTPA);
     156        output->fpa->fromTPA = psMemIncrRefCounter(input->fpa->fromTPA);
     157        output->fpa->toSky = psMemIncrRefCounter(input->fpa->toSky);
    183158
    184         pmHDU *outHDU = pmFPAviewThisHDU (view, output->fpa);
    185         if (!outHDU) {
    186             pmFPAAddSourceFromView(output->fpa, view, output->format);
    187             outHDU = pmFPAviewThisHDU (view, output->fpa);
    188             psAssert (outHDU, "failed to make HDU");
    189         }
    190         if (!outHDU->header) {
    191           outHDU->header = psMetadataAlloc();
    192         }
     159        pmConceptsCopyFPA(output->fpa, input->fpa, true, true);
    193160
    194         if (bilevelAstrometry) {
    195             if (!pmAstromReadBilevelChip (outChip, inHDU->header)) {
    196                 psWarning("Unable to read bilevel chip astrometry for input FPA.");
    197                 continue;
    198             }
    199             if (!pmAstromWriteBilevelChip(outHDU->header, outChip, WCS_NONLIN_TOL)) {
    200                 psWarning("Unable to generate WCS header.");
    201                 continue;
    202             }
    203         } else {
    204             // we use a default FPA pixel scale of 1.0
    205             if (!pmAstromReadWCS (output->fpa, outChip, inHDU->header, 1.0)) {
    206                 psWarning("Unable to read WCS astrometry for input FPA.");
    207                 continue;
    208             }
    209             if (!pmAstromWriteWCS(outHDU->header, output->fpa, outChip, WCS_NONLIN_TOL)) {
    210                 psWarning("Unable to generate WCS header.");
    211                 continue;
    212             }
    213         }
     161        // XXX TEST
     162        // pmFPASetFileStatus(output->fpa, true);
     163        // pmFPASetDataStatus(output->fpa, true);
     164        // pmChip *chip = output->fpa->chips->data[0];
     165        // pmCell *cell = chip->cells->data[0];
     166        // pmReadout *readout = cell->readouts->data[0];
    214167    }
    215 
    216168    return true;
    217169}
    218170
    219 bool SetAstrometryFPA (pmConfig *config, pmFPAview *view, bool bilevelAstrometry) {
     171/*
     172   the easiest way to implement this is to assume we can pre-load the full set of images up front.
     173   with 5 filters and 6000^2 (image, mask, var = 10 byte per pixel), we need 1.8GB, which is not too bad.
     174*/
    220175
    221     if (!bilevelAstrometry) return true;
    222 
    223     int num = psphotFileruleCount(config, "PSPHOT.INPUT");
    224 
    225     // loop over the available readouts
    226     for (int i = 0; i < num; i++) {
    227 
    228         // find the currently selected readout
    229         pmFPAfile *output = pmFPAfileSelectSingle(config->files, "PSPHOT.STACK.OUTPUT.IMAGE", i); // File of interest
    230         psAssert (output, "missing file?");
    231 
    232         pmHDU *PHU = pmFPAviewThisPHU(view, output->fpa);
    233         if (!PHU) {
    234             pmFPAAddSourceFromView(output->fpa, view, output->format);
    235             PHU = pmFPAviewThisPHU (view, output->fpa);
    236             psAssert (PHU, "failed to make PHU");
    237         }
    238         if (!PHU->header) {
    239           PHU->header = psMetadataAlloc();
    240         }
    241 
    242         if (!pmAstromWriteBilevelMosaic(PHU->header, output->fpa, WCS_NONLIN_TOL)) {
    243             psWarning("Unable to generate WCS header.");
    244         }
    245     }
    246 
    247     return true;
    248 }
  • branches/eam_branches/ipp-20110213/psphot/src/psphotStackMatchPSFs.c

    r30624 r30871  
    9292    }
    9393
     94    // copy the header data from Src to Out
     95    // pmHDU *hduSrc = pmHDUFromReadout(readoutSrc);
     96    // psAssert (hduSrc, "input missing hdu?");
     97
     98
    9499    // set NAN pixels to 'SAT'
    95100    psImageMaskType maskSat = pmConfigMaskGet("SAT", config);
Note: See TracChangeset for help on using the changeset viewer.