IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 37932 for trunk


Ignore:
Timestamp:
Feb 24, 2015, 5:52:57 PM (11 years ago)
Author:
eugene
Message:

merge change from ipp-20150115 : do not re-measure psf stats on cleanup for psphotReadoutMinimal

Location:
trunk/psphot
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/psphot

  • trunk/psphot/src/psphot.h

    r37767 r37932  
    4545bool            psphotReadoutCleanup (pmConfig *config, const pmFPAview *view, const char *filerule);
    4646bool            psphotReadoutCleanupReadout (pmConfig *config, const pmFPAview *view, const char *filerule, int index, psMetadata *recipe);
     47bool            psphotReadoutCleanupMinimal (pmConfig *config, const pmFPAview *view, const char *filerule);
     48bool            psphotReadoutCleanupReadoutMinimal (pmConfig *config, const pmFPAview *view, const char *filerule, int index, psMetadata *recipe);
    4749
    4850bool            psphotDefineFiles (pmConfig *config, pmFPAfile *input);
  • trunk/psphot/src/psphotReadoutCleanup.c

    r37767 r37932  
    111111    return true;
    112112}
     113
     114// for now, let's store the detections on the readout->analysis for each readout
     115bool psphotReadoutCleanupMinimal (pmConfig *config, const pmFPAview *view, const char *filerule)
     116{
     117    bool status = true;
     118
     119    // remove internal pmFPAfiles, if created
     120    if (psErrorCodeLast() == (psErrorCode) PSPHOT_ERR_DATA) {
     121        psErrorStackPrint(stderr, "Error in the psphot readout analysis");
     122        psErrorClear();
     123    }
     124    if (psErrorCodeLast() != PS_ERR_NONE) {
     125        return false;
     126    }
     127
     128    // select the appropriate recipe information
     129    psMetadata *recipe  = psMetadataLookupPtr (&status, config->recipes, PSPHOT_RECIPE);
     130    psAssert (recipe, "missing recipe?");
     131
     132    int num = psphotFileruleCount(config, filerule);
     133
     134    // loop over the available readouts
     135    for (int i = 0; i < num; i++) {
     136        if (!psphotReadoutCleanupReadoutMinimal (config, view, filerule, i, recipe)) {
     137            psError (PSPHOT_ERR_CONFIG, false, "failed on psphotReadoutCleanupMinimal for %s entry %d", filerule, i);
     138            return false;
     139        }
     140    }
     141
     142    // XXX move this to top of loop?
     143    pmKapaClose ();
     144
     145    return true;
     146}
     147
     148// psphotReadoutCleanupMinimal is called on exit from psphotReadoutMinimal.  If the last raised error is
     149// not a DATA error, then there was a serious problem.  Only in this case, or if the fail
     150// on the stats measurement, do we return false
     151bool psphotReadoutCleanupReadoutMinimal (pmConfig *config, const pmFPAview *view, const char *filerule, int index, psMetadata *recipe) {
     152
     153    bool status = true;
     154
     155    // find the currently selected readout
     156    pmFPAfile *file = pmFPAfileSelectSingle(config->files, filerule, index); // File of interest
     157    psAssert (file, "missing file?");
     158
     159    pmReadout *readout = pmFPAviewThisReadout(view, file->fpa);
     160    psAssert (readout, "missing readout?");
     161
     162    // when psphotReadoutCleanupMinimal is called, these are not necessarily defined
     163    pmPSF        *psf        = psMetadataLookupPtr (&status, readout->analysis, "PSPHOT.PSF");
     164    pmDetections *detections = psMetadataLookupPtr (&status, readout->analysis, "PSPHOT.DETECTIONS");
     165    psArray      *sources    = detections ? detections->allSources : NULL;
     166    // XXX where do we free these, in here (psMetadataRemove?)
     167
     168    // create an output header with stats results currently saved on readout->analysis
     169    psMetadata *header = psphotDefineHeader (readout->analysis);
     170
     171    // write NSTARS to the image header
     172    psphotSetHeaderNstars (header, sources);
     173
     174    // save the results of the analysis
     175    // this should happen way up stream (when needed?)
     176    psMetadataAdd (readout->analysis, PS_LIST_TAIL, "PSPHOT.HEADER",  PS_DATA_METADATA | PS_META_REPLACE, "header stats", header);
     177
     178    if (psf) {
     179        // XXX this seems a little silly : we saved the psf on readout->analysis above, but now
     180        // we are moving it to chip->analysis.
     181        // save the psf for possible output.  if there was already an entry, it was loaded from external sources
     182        // the new one may have been updated or modified, so replace the existing entry.  We
     183        // are required to save it on the chip, but this will cause problems if we ever want to
     184        // run psphot on an unmosaiced image
     185        pmCell *cell = readout->parent;
     186        pmChip *chip = cell->parent;
     187        psMetadataAdd (chip->analysis, PS_LIST_TAIL, "PSPHOT.PSF", PS_DATA_UNKNOWN | PS_META_REPLACE,  "psphot psf", psf);
     188    }
     189
     190    if (psErrorCodeLast() != PS_ERR_NONE) {
     191        psErrorStackPrint(stderr, "unexpected remaining errors");
     192        abort();
     193    }
     194
     195    psFree (header);
     196    return true;
     197}
  • trunk/psphot/src/psphotReadoutMinimal.c

    r34317 r37932  
    112112
    113113    // create the exported-metadata and free local data
    114     return psphotReadoutCleanup (config, view, filerule);
     114    return psphotReadoutCleanupMinimal (config, view, filerule);
    115115}
Note: See TracChangeset for help on using the changeset viewer.