IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Apr 7, 2009, 4:50:25 PM (17 years ago)
Author:
Paul Price
Message:

Merging branches/pap from r23739 onto trunk. No conflicts, ppSub builds fine.

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/ppSub

  • trunk/ppSub/src

    • Property svn:ignore
      •  

        old new  
        1010stamp-h1
        1111ppSubKernel
         12ppSubErrorCodes.h
         13ppSubErrorCodes.c
  • trunk/ppSub/src/ppSubReadoutPhotometry.c

    r23688 r23740  
    2222#include "ppSub.h"
    2323
    24 bool ppSubReadoutPhotometry (pmConfig *config, ppSubData *data, const pmFPAview *view)
     24bool ppSubReadoutPhotometry(const char *name, pmConfig *config, ppSubData *data)
    2525{
    2626    psAssert(config, "Require configuration");
    27     psAssert(view, "Require view");
     27
     28    if (!data->photometry) {
     29        return false;
     30    }
    2831
    2932    // Look up recipe values
     
    3942    // The PSF (measured in ppSubMakePSF) is stored on the chip->analysis of PSPHOT.INPUT
    4043    // In order to use an incoming PSF, it must be stored on the chip->analysis of PSPHOT.PSF.LOAD
     44    pmFPAview *view = ppSubViewReadout(); // View to readout
    4145    pmChip *psfInputChip = pmFPAfileThisChip(config->files, view, "PSPHOT.INPUT"); // Chip with PSF
    4246    psAssert (psfInputChip, "should have been generated for ppSubMakePSF");
     
    4751        psErrorStackPrint(stderr, "No PSF available");
    4852        psWarning("No PSF available --- suspect bad data quality.");
    49         ppSubDataQuality(config, data, psErrorCodeLast(), PPSUB_FILES_PHOT);
     53        ppSubDataQuality(config, data, psErrorCodeLast(), PPSUB_FILES_PHOT_SUB | PPSUB_FILES_PHOT_INV);
    5054        return true;
    5155    }
     
    5862    // around the pointers so PSPHOT.INPUT corresponds to the output image; previously, it was
    5963    // equivalent to the minuend image.
    60     pmFPAfile *outputFile = psMetadataLookupPtr(&mdok, config->files, "PPSUB.OUTPUT"); // Output file
    61     pmReadout *outRO = pmFPAviewThisReadout(view, outputFile->fpa); // Readout with the sources
     64    pmReadout *inRO = pmFPAfileThisReadout(config->files, view, name); // Readout with image and sources
    6265
    63     // XXX possibly rename this to PPSUB.RESID?
    6466    pmFPAfile *photFile = psMetadataLookupPtr(&mdok, config->files, "PSPHOT.INPUT"); // Photometry file
    6567    pmReadout *photRO = pmFPAviewThisReadout(view, photFile->fpa); // Readout to photometer
     
    6870        photRO = pmReadoutAlloc(cell); // Output readout: subtraction
    6971    }
    70     photRO->image = psImageCopy(photRO->image, outRO->image, PS_TYPE_F32);
    71     if (outRO->variance) {
    72         photRO->variance = psImageCopy(photRO->variance, outRO->variance, PS_TYPE_F32);
     72    photRO->image = psImageCopy(photRO->image, inRO->image, PS_TYPE_F32);
     73    if (inRO->variance) {
     74        photRO->variance = psImageCopy(photRO->variance, inRO->variance, PS_TYPE_F32);
    7375    } else {
    7476        psFree(photRO->variance);
    7577        photRO->variance = NULL;
    7678    }
    77     if (outRO->mask) {
    78         photRO->mask = psImageCopy(photRO->mask, outRO->mask, PS_TYPE_IMAGE_MASK);
     79    if (inRO->mask) {
     80        photRO->mask = psImageCopy(photRO->mask, inRO->mask, PS_TYPE_IMAGE_MASK);
    7981    } else {
    8082        psFree(photRO->mask);
    8183        photRO->mask = NULL;
    8284    }
     85    psMetadataAddPtr(photRO->parent->parent->analysis, PS_LIST_TAIL, "PSPHOT.PSF",
     86                     PS_META_REPLACE | PS_DATA_UNKNOWN, "Point-spread function", data->psf);
     87
     88    psFree(photRO->analysis);
     89    photRO->analysis = psMetadataAlloc();
    8390
    8491    if (!psphotReadoutMinimal(config, view)) {
     
    8794        psErrorStackPrint(stderr, "Unable to perform photometry on image");
    8895        psWarning("Unable to perform photometry on image --- suspect bad data quality.");
    89         ppSubDataQuality(config, data, psErrorCodeLast(), PPSUB_FILES_PHOT);
     96        ppSubDataQuality(config, data, psErrorCodeLast(), PPSUB_FILES_PHOT_SUB | PPSUB_FILES_PHOT_INV);
    9097    }
    9198
    92     photRO->data_exists = true;
    93     photRO->parent->data_exists = true;
    94     photRO->parent->parent->data_exists = true;
     99    if (!data->quality && !psMetadataCopySingle(inRO->analysis, photRO->analysis, "PSPHOT.SOURCES")) {
     100        psError(PS_ERR_UNEXPECTED_NULL, false, "Unable to copy PSPHOT.SOURCES");
     101        return false;
     102    }
    95103
    96104    if (data->stats) {
    97105        psArray *sources = psMetadataLookupPtr(NULL, photRO->analysis, "PSPHOT.SOURCES"); // Sources
    98         psMetadataAddS32(data->stats, PS_LIST_TAIL, "NUM_SOURCES", 0, "Number of sources detected",
    99                          sources ? sources->n : 0);
    100         psMetadataAddF32(data->stats, PS_LIST_TAIL, "TIME_PHOT", 0, "Time to do photometry",
    101                          psTimerClear("PPSUB_PHOT"));
     106        bool mdok;
     107        int numSources = psMetadataLookupS32(&mdok, data->stats, "NUM_SOURCES"); // Number of sources
     108        numSources += sources ? sources->n : 0;
     109        psMetadataAddS32(data->stats, PS_LIST_TAIL, "NUM_SOURCES", PS_META_REPLACE,
     110                         "Total number of sources detected", numSources);
     111        float newTime = psTimerClear("PPSUB_PHOT"); // Time for photometry
     112        float oldTime = psMetadataLookupF32(&mdok, data->stats, "TIME_PHOT"); // Previous time for photometry
     113        psMetadataAddF32(data->stats, PS_LIST_TAIL, "TIME_PHOT", PS_META_REPLACE, "Time to do photometry",
     114                         isfinite(oldTime) ? oldTime + newTime : newTime);
    102115    }
    103116
Note: See TracChangeset for help on using the changeset viewer.