IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Feb 10, 2010, 7:36:29 PM (16 years ago)
Author:
eugene
Message:

updates from eam_branches/20091201 (substantially changes to the psphotReadout APIs to support future stack photometry; improvements to the CR masking code)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psphot/src/psphotReadoutMinimal.c

    r25755 r26894  
    11# include "psphotInternal.h"
    22
    3 // this badly-named function performs photometry assuming (a) a supplied PSF, (b)
    4 // background subtraction, (c) linear psf-model fits only.  it is currently only being
    5 // used by ppSub.
     3// this badly-named function performs photometry assuming (a) a supplied PSF, (b) background
     4// subtraction, (c) linear psf-model fits only, (d) a prior analysis has supplied the moments
     5// window parameters.  It is currently only being used by ppSub.
    66
    77// NOTE: ppSub needs to perform extended source analysis for comets and trails.
     
    1717    pmModelClassSetLimits(PM_MODEL_LIMITS_LAX);
    1818
    19     // select the current recipe
    20     psMetadata *recipe = psMetadataLookupPtr (NULL, config->recipes, PSPHOT_RECIPE);
    21     if (!recipe) {
    22         psError(PSPHOT_ERR_CONFIG, false, "missing recipe %s", PSPHOT_RECIPE);
    23         return false;
    24     }
    25 
    2619    // set the photcode for this image
    27     if (!psphotAddPhotcode(recipe, config, view, "PSPHOT.INPUT")) {
     20    if (!psphotAddPhotcode(config, view)) {
    2821        psError(PSPHOT_ERR_CONFIG, false, "trouble defining the photcode");
    2922        return false;
    3023    }
    3124
    32     // find the currently selected readout
    33     pmReadout  *readout = pmFPAfileThisReadout (config->files, view, "PSPHOT.INPUT");
    34     PS_ASSERT_PTR_NON_NULL (readout, false);
     25    // Generate the mask and weight images, including the user-defined analysis region of interest
     26    psphotSetMaskAndVariance (config, view);
    3527
    36     // Generate the mask and weight images, including the user-defined analysis region of interest
    37     psphotSetMaskAndVariance (config, readout, recipe);
    38 
    39     // display the image, weight, mask (ch 1,2,3)
    40     psphotVisualShowImage (readout);
    41 
    42     // load the psf model, if suppled.  FWHM_X,FWHM_Y,etc are saved in the recipe
    43     pmPSF *psf = psphotLoadPSF (config, view, recipe);
    44     if (!psf) {
     28    // load the psf model, if suppled.  FWHM_X,FWHM_Y,etc are saved on readout->analysis
     29    if (!psphotLoadPSF (config, view)) {
    4530      psError (PSPHOT_ERR_CONFIG, false, "missing psf model");
    46       return psphotReadoutCleanup (config, readout, recipe, NULL, NULL, NULL);
     31      return psphotReadoutCleanup (config, view);
    4732    }
    4833
    49     // find the detections (by peak and/or footprint) in the image.
    50     pmDetections *detections = pmDetectionsAlloc(); // New detections; allocated to ensure pass=2
    51     detections = psphotFindDetections(detections, readout, recipe);
    52     if (!detections) {
    53         psLogMsg ("psphot", 3, "unable to find detections in this image");
    54         return psphotReadoutCleanup (config, readout, recipe, detections, psf, NULL);
     34    // find the detections (by peak and/or footprint) in the image. (final pass)
     35    if (!psphotFindDetections(config, view, false)) {
     36        psError (PSPHOT_ERR_UNKNOWN, false, "failure in peak analysis");
     37        return psphotReadoutCleanup (config, view);
    5538    }
    5639
    57     // construct sources and measure basic stats
    58     psArray *sources = psphotSourceStats (config, readout, detections, true);
    59     if (!sources) return false;
     40    // construct sources and measure basic stats (saved on detections->newSources)
     41    if (!psphotSourceStats (config, view, false)) { // pass 1
     42        psError(PSPHOT_ERR_UNKNOWN, false, "failure to generate sources");
     43        return psphotReadoutCleanup (config, view);
     44    }
    6045
    6146    // find blended neighbors of very saturated stars
    62     // XXX merge this with Basic Deblend?
    63     psphotDeblendSatstars (readout, sources, recipe);
     47    psphotDeblendSatstars (config, view);
    6448
    6549    // mark blended peaks PS_SOURCE_BLEND
    66     if (!psphotBasicDeblend (sources, recipe)) {
     50    if (!psphotBasicDeblend (config, view)) {
    6751        psLogMsg ("psphot", 3, "failed on deblend analysis");
    68         return psphotReadoutCleanup (config, readout, recipe, detections, psf, sources);
     52        return psphotReadoutCleanup (config, view);
    6953    }
    7054
    7155    // classify sources based on moments, brightness (use supplied psf shape parameters)
    72     if (!psphotRoughClass (readout, sources, recipe, true)) {
     56    if (!psphotRoughClass (config, view)) {
    7357        psLogMsg ("psphot", 3, "failed to find a valid PSF clump for image");
    74         return psphotReadoutCleanup (config, readout, recipe, detections, psf, sources);
     58        return psphotReadoutCleanup (config, view);
    7559    }
    7660
    7761    // construct an initial model for each object
    78     psphotGuessModels (config, readout, sources, psf);
     62    psphotGuessModels (config, view);
     63
     64    // merge the newly selected sources into the existing list
     65    psphotMergeSources (config, view);
    7966
    8067    // linear PSF fit to source peaks
    81     psphotFitSourcesLinear (readout, sources, recipe, psf, FALSE);
    82 
    83     // We have to place these visualizations here because the models are not realized until
    84     // psphotGuessModels or fitted until psphotFitSourcesLinear.
    85     psphotVisualShowPSFStars (recipe, psf, sources);
    86     psphotVisualShowSatStars (recipe, psf, sources);
     68    psphotFitSourcesLinear (config, view, false);
    8769
    8870// XXX eventually, add the extended source fits here
    8971# if (0)
    9072    // measure source size for the remaining sources
    91     psphotSourceSize (config, readout, sources, recipe, 0);
     73    psphotSourceSize (config, view);
    9274
    93     psphotExtendedSourceAnalysis (readout, sources, recipe);
     75    psphotExtendedSourceAnalysis (config, view);
    9476
    95     psphotExtendedSourceFits (readout, sources, recipe);
     77    psphotExtendedSourceFits (config, view);
    9678# endif
    9779
    9880    // calculate source magnitudes
    99     psphotMagnitudes(config, readout, view, sources, psf);
     81    psphotMagnitudes(config, view);
    10082
    101     if (!psphotEfficiency(config, readout, view, psf, recipe, sources)) {
     83    // XXX ensure this is measured if the analysis succeeds (even if quality is low)
     84    if (!psphotEfficiency(config, view)) {
    10285        psErrorStackPrint(stderr, "Unable to determine detection efficiencies from fake sources");
    10386        psErrorClear();
     
    10588
    10689    // drop the references to the image pixels held by each source
    107     psphotSourceFreePixels (sources);
     90    psphotSourceFreePixels (config, view);
    10891
    10992    // create the exported-metadata and free local data
    110     return psphotReadoutCleanup(config, readout, recipe, detections, psf, sources);
     93    return psphotReadoutCleanup(config, view);
    11194}
Note: See TracChangeset for help on using the changeset viewer.