IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 21092


Ignore:
Timestamp:
Jan 8, 2009, 2:01:33 PM (17 years ago)
Author:
Paul Price
Message:

Attempt to fix exposure time in output: ppStackSourcesTransparency now returns the total exposure time (since it calculates it, and corrects all the photometry to correspond to that exposure time), and ppStackLoop applies it to the output.

Location:
trunk/ppStack/src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/ppStack/src/ppStack.h

    r20995 r21092  
    154154/// Calculate transparency differences between images
    155155///
    156 /// Corrects the source PSF photometry to a common system
    157 bool ppStackSourcesTransparency(const psArray *sourceLists, // Sources for each input
    158                                 const pmFPAview *view, // View to readout
    159                                 const pmConfig *config // Configuration
     156/// Corrects the source PSF photometry to a common system.  Return the sum of the exposure times.
     157float ppStackSourcesTransparency(const psArray *sourceLists, // Sources for each input
     158                                 const pmFPAview *view, // View to readout
     159                                 const pmConfig *config // Configuration
    160160    );
    161161
  • trunk/ppStack/src/ppStackLoop.c

    r20997 r21092  
    254254    psArray *sourceLists = psArrayAlloc(num); // Individual lists of sources for matching
    255255    pmPSF *targetPSF = NULL;            // Target PSF
     256    float sumExposure = NAN;            // Sum of exposure times
    256257    if (psMetadataLookupBool(NULL, config->arguments, "HAVE.PSF")) {
    257258        pmFPAfileActivate(config->files, false, NULL);
     
    348349
    349350        // Zero point calibration
    350         if (!ppStackSourcesTransparency(sourceLists, view, config)) {
     351        sumExposure = ppStackSourcesTransparency(sourceLists, view, config);
     352        if (!isfinite(sumExposure) || sumExposure <= 0) {
    351353            psError(PS_ERR_UNKNOWN, false, "Unable to calculate transparency differences");
    352354            psFree(sourceLists);
     
    407409    psVector *weightings = psVectorAlloc(num, PS_TYPE_F32); // Combination weightings for images (1/noise^2)
    408410    psVectorInit(weightings, NAN);
     411    psList *fpaList = psListAlloc(NULL); // List of input FPAs, for concept averaging
     412    psList *cellList = psListAlloc(NULL); // List of input cells, for concept averaging
    409413    for (int i = 0; i < num; i++) {
    410414        psTrace("ppStack", 2, "Convolving input %d of %d to target PSF....\n", i, num);
     
    475479        writeImage(weightNames->data[i], hdu->header, readout->weight, config);
    476480
    477         cells->data[i] = psMemIncrRefCounter(readout->parent);
     481        pmCell *inCell = readout->parent; // Input cell
     482
     483        psListAdd(cellList, PS_LIST_TAIL, inCell);
     484        psListAdd(fpaList, PS_LIST_TAIL, inCell->parent->parent);
     485
     486        cells->data[i] = psMemIncrRefCounter(inCell);
    478487        if (!filesIterateUp(config)) {
    479488            return false;
     
    496505        return false;
    497506    }
     507
     508
     509    // Update concepts for output
     510    {
     511        pmFPAview view;                 // View for output
     512        view.chip = view.cell = view.readout = 0;
     513        pmCell *outCell = pmFPAfileThisCell(config->files, &view, "PPSTACK.OUTPUT"); // Output cell
     514        pmFPA *outFPA = outCell->parent->parent; // Output FPA
     515        pmConceptsAverageFPAs(outFPA, fpaList);
     516        pmConceptsAverageCells(outCell, cellList, NULL, NULL, true);
     517        psFree(fpaList);
     518        psFree(cellList);
     519
     520        // Update the value of a concept
     521#define UPDATE_CONCEPT(SOURCE, NAME, VALUE) { \
     522            psMetadataItem *item = psMetadataLookup(SOURCE->concepts, NAME); \
     523            psAssert(item, "Concept should be present"); \
     524            psAssert(item->type == PS_TYPE_F32, "Concept should be F32"); \
     525            item->data.F32 = VALUE; \
     526        }
     527
     528        UPDATE_CONCEPT(outFPA,  "FPA.EXPOSURE",  sumExposure);
     529        UPDATE_CONCEPT(outCell, "CELL.EXPOSURE", sumExposure);
     530        UPDATE_CONCEPT(outCell, "CELL.DARKTIME", NAN);
     531    }
     532
    498533
    499534    // Reject images out-of-hand on the basis of their match chi^2
     
    626661            return false;
    627662        }
    628 
    629         psList *fpaList = psListAlloc(NULL); // List of input FPAs, for concept averaging
    630         psList *cellList = psListAlloc(NULL); // List of input cells, for concept averaging
    631         for (int i = 0; i < num; i++) {
    632             pmCell *inCell = cells->data[i]; // Input cell
    633             if (!inCell) {
    634                 exptimes->data.F32[i] = 0.0;
    635                 continue;
    636             }
    637             exptimes->data.F32[i] = psMetadataLookupF32(NULL, inCell->concepts, "CELL.EXPOSURE");
    638             psListAdd(cellList, PS_LIST_TAIL, inCell);
    639             psListAdd(fpaList, PS_LIST_TAIL, inCell->parent->parent);
    640         }
    641 
    642         // Copy concepts
    643         pmChip *outChip = outCell->parent;  // Output chip
    644         pmFPA *outFPA = outChip->parent;    // Output FPA
    645         pmConceptsAverageFPAs(outFPA, fpaList);
    646         pmConceptsAverageCells(outCell, cellList, NULL, NULL, true);
    647         psFree(fpaList);
    648         psFree(cellList);
    649663
    650664        psFree(cells);
     
    977991    // Close up
    978992    bool wcsDone = false;           // Have we done the WCS?
    979     float totExposure = 0.0;            // Total exposure time
    980993    for (int i = 0; i < num; i++) {
    981994        if (inputMask->data.U8[i]) {
    982995            continue;
    983996        }
    984         totExposure += exptimes->data.F32[i];
    985997
    986998        ppStackThread *thread = stack->threads->data[0]; // Representative stack
  • trunk/ppStack/src/ppStackSources.c

    r21016 r21092  
    1010
    1111
    12 bool ppStackSourcesTransparency(const psArray *sourceLists, const pmFPAview *view, const pmConfig *config)
     12float ppStackSourcesTransparency(const psArray *sourceLists, const pmFPAview *view, const pmConfig *config)
    1313{
    14     PS_ASSERT_ARRAY_NON_NULL(sourceLists, false);
    15     PS_ASSERT_PTR_NON_NULL(view, false);
    16     PS_ASSERT_PTR_NON_NULL(config, false);
     14    PS_ASSERT_ARRAY_NON_NULL(sourceLists, NAN);
     15    PS_ASSERT_PTR_NON_NULL(view, NAN);
     16    PS_ASSERT_PTR_NON_NULL(config, NAN);
    1717
    1818#ifdef TESTING
     
    4646    if (!airmassZP) {
    4747        psError(PS_ERR_UNKNOWN, false, "Unable to find ZP.AIRMASS in recipe.");
    48         return false;
     48        return NAN;
    4949    }
    5050
     
    6969                    exptime, airmass, expFilter);
    7070            psFree(zp);
    71             return false;
     71            return NAN;
    7272        }
    7373
     
    7979                        "Unable to find airmass term (ZP.AIRMASS) for filter %s", filter);
    8080                psFree(zp);
    81                 return false;
     81                return NAN;
    8282            }
    8383        } else if (strcmp(filter, expFilter) != 0) {
    8484            psError(PS_ERR_BAD_PARAMETER_VALUE, false, "Filters don't match: %s vs %s", filter, expFilter);
    8585            psFree(zp);
    86             return false;
     86            return NAN;
    8787        }
    8888
     
    9595        psError(PS_ERR_UNKNOWN, false, "Unable to match sources");
    9696        psFree(zp);
    97         return false;
     97        return NAN;
    9898    }
    9999    psVector *trans = pmSourceMatchRelphot(matches, zp, iter, tol, starLimit, transIter, transRej,
     
    128128    if (!trans) {
    129129        psError(PS_ERR_UNKNOWN, false, "Unable to measure transparencies");
    130         return false;
     130        return NAN;
    131131    }
    132132
     
    158158            psError(PS_ERR_UNKNOWN, false, "Unable to match sources");
    159159            psFree(zp);
    160             return false;
     160            return NAN;
    161161        }
    162162        psVector *trans = pmSourceMatchRelphot(matches, zp, iter, tol, starLimit, transIter, transRej,
     
    165165    }
    166166#endif
    167     return true;
     167
     168    return sumExpTime;
    168169}
Note: See TracChangeset for help on using the changeset viewer.