IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Feb 5, 2010, 1:38:43 PM (16 years ago)
Author:
eugene
Message:

updates to psphot APIs to enable stack photometry

Location:
branches/eam_branches/20091201/psphot
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/20091201/psphot

  • branches/eam_branches/20091201/psphot/src/psphotReadoutMinimal.c

    r26648 r26788  
    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
    2720    if (!psphotAddPhotcode(config, view)) {
     
    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, view, 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) {
     34    // find the detections (by peak and/or footprint) in the image. (final pass)
     35    if (!psphotFindDetections(config, view, false)) {
    5336        psError (PSPHOT_ERR_UNKNOWN, false, "failure in peak analysis");
    54         return psphotReadoutCleanup (config, readout, recipe, detections, psf, NULL);
     37        return psphotReadoutCleanup (config, view);
    5538    }
    56 #if 0
    57     if (!detections->peaks->n) {
    58         psLogMsg ("psphot", 3, "unable to find detections in this image");
    59         return psphotReadoutCleanup (config, readout, recipe, detections, psf, NULL);
     39
     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);
    6044    }
    61 #endif
    6245
    63     // construct sources and measure basic stats
    64     psArray *sources = psphotSourceStats (config, readout, detections, false);
    65     if (!sources) return false;
     46    // find blended neighbors of very saturated stars
     47    psphotDeblendSatstars (config, view);
    6648
    67     // Do the efficiency before everything else, to ensure it's done
    68     if (!psphotEfficiency(config, readout, view, psf, recipe, sources)) {
     49    // mark blended peaks PS_SOURCE_BLEND
     50    if (!psphotBasicDeblend (config, view)) {
     51        psLogMsg ("psphot", 3, "failed on deblend analysis");
     52        return psphotReadoutCleanup (config, view);
     53    }
     54
     55    // classify sources based on moments, brightness (use supplied psf shape parameters)
     56    if (!psphotRoughClass (config, view)) {
     57        psLogMsg ("psphot", 3, "failed to find a valid PSF clump for image");
     58        return psphotReadoutCleanup (config, view);
     59    }
     60
     61    // construct an initial model for each object
     62    psphotGuessModels (config, view);
     63
     64    // linear PSF fit to source peaks
     65    psphotFitSourcesLinear (config, view, false);
     66
     67// XXX eventually, add the extended source fits here
     68# if (0)
     69    // measure source size for the remaining sources
     70    psphotSourceSize (config, view);
     71
     72    psphotExtendedSourceAnalysis (config, view);
     73
     74    psphotExtendedSourceFits (config, view);
     75# endif
     76
     77    // calculate source magnitudes
     78    psphotMagnitudes(config, view);
     79
     80    // XXX ensure this is measured if the analysis succeeds (even if quality is low)
     81    if (!psphotEfficiency(config, view)) {
    6982        psErrorStackPrint(stderr, "Unable to determine detection efficiencies from fake sources");
    7083        psErrorClear();
    7184    }
    7285
    73     if (detections->peaks->n == 0 || sources->n == 0) {
    74         psLogMsg ("psphot", 3, "unable to find detections in this image");
    75         return psphotReadoutCleanup (config, readout, recipe, detections, psf, NULL);
    76     }
    77 
    78 
    79 
    80     // find blended neighbors of very saturated stars
    81     // XXX merge this with Basic Deblend?
    82     psphotDeblendSatstars (readout, sources, recipe);
    83 
    84     // mark blended peaks PS_SOURCE_BLEND
    85     if (!psphotBasicDeblend (sources, recipe)) {
    86         psLogMsg ("psphot", 3, "failed on deblend analysis");
    87         return psphotReadoutCleanup (config, readout, recipe, detections, psf, sources);
    88     }
    89 
    90     // classify sources based on moments, brightness (use supplied psf shape parameters)
    91     if (!psphotRoughClass (readout, sources, recipe, true)) {
    92         psLogMsg ("psphot", 3, "failed to find a valid PSF clump for image");
    93         return psphotReadoutCleanup (config, readout, recipe, detections, psf, sources);
    94     }
    95 
    96     // construct an initial model for each object
    97     psphotGuessModels (config, readout, sources, psf);
    98 
    99     // linear PSF fit to source peaks
    100     psphotFitSourcesLinear (readout, sources, recipe, psf, FALSE);
    101 
    102     // We have to place these visualizations here because the models are not realized until
    103     // psphotGuessModels or fitted until psphotFitSourcesLinear.
    104     psphotVisualShowPSFStars (recipe, psf, sources);
    105     psphotVisualShowSatStars (recipe, psf, sources);
    106 
    107 // XXX eventually, add the extended source fits here
    108 # if (0)
    109     // measure source size for the remaining sources
    110     psphotSourceSize (config, readout, sources, recipe, 0);
    111 
    112     psphotExtendedSourceAnalysis (readout, sources, recipe);
    113 
    114     psphotExtendedSourceFits (readout, sources, recipe);
    115 # endif
    116 
    117     // calculate source magnitudes
    118     psphotMagnitudes(config, readout, view, sources, psf);
    119 
    12086    // drop the references to the image pixels held by each source
    121     psphotSourceFreePixels (sources);
     87    psphotSourceFreePixels (config, view);
    12288
    12389    // create the exported-metadata and free local data
    124     return psphotReadoutCleanup(config, readout, recipe, detections, psf, sources);
     90    return psphotReadoutCleanup(config, view);
    12591}
Note: See TracChangeset for help on using the changeset viewer.