IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Dec 5, 2010, 9:42:25 PM (16 years ago)
Author:
eugene
Message:

psphotReadout* API modification to accept a filerule name; wrap lookup of filerule.NUM values in a function (missing = 1); drop deprecated psphotDetect and related; add function to cleanup input pmFPAfile; use psMetadataAddF32 instead of psMetadataAdd (... PS_DATA_F32); add psphotReadoutForcedKnownSources.c; add psphotAddKnownSources

Location:
trunk/psphot
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/psphot

  • trunk/psphot/src/psphotReadout.c

    r29004 r29936  
    99}
    1010
    11 bool psphotReadout(pmConfig *config, const pmFPAview *view) {
     11bool psphotReadout(pmConfig *config, const pmFPAview *view, const char *filerule) {
    1212
    1313    // measure the total elapsed time in psphotReadout.  dtime is the elapsed time used jointly
     
    2727    psAssert (breakPt, "configuration error: set BREAK_POINT");
    2828
     29    // remove cruft from the input analysis structure
     30    if (!psphotCleanInputs (config, view, filerule)) {
     31        psError (PSPHOT_ERR_PROG, false, "trouble setting up the inputs");
     32        return false;
     33    }
     34
    2935    // set the photcode for this image
    30     if (!psphotAddPhotcode (config, view, "PSPHOT.INPUT")) {
     36    if (!psphotAddPhotcode (config, view, filerule)) {
    3137        psError (PSPHOT_ERR_CONFIG, false, "trouble defining the photcode");
    3238        return false;
     
    3440
    3541    // Generate the mask and weight images, including the user-defined analysis region of interest
    36     if (!psphotSetMaskAndVariance (config, view, "PSPHOT.INPUT")) {
    37         return psphotReadoutCleanup(config, view, "PSPHOT.INPUT");
     42    if (!psphotSetMaskAndVariance (config, view, filerule)) {
     43        return psphotReadoutCleanup(config, view, filerule);
    3844    }
    3945    if (!strcasecmp (breakPt, "NOTHING")) {
    40         return psphotReadoutCleanup (config, view, "PSPHOT.INPUT");
     46        return psphotReadoutCleanup (config, view, filerule);
    4147    }
    4248
    4349    // generate a background model (median, smoothed image)
    44     if (!psphotModelBackground (config, view, "PSPHOT.INPUT")) {
    45         return psphotReadoutCleanup (config, view, "PSPHOT.INPUT");
    46     }
    47 
    48     if (!psphotSubtractBackground (config, view, "PSPHOT.INPUT")) {
    49         return psphotReadoutCleanup (config, view, "PSPHOT.INPUT");
     50    if (!psphotModelBackground (config, view, filerule)) {
     51        return psphotReadoutCleanup (config, view, filerule);
     52    }
     53
     54    if (!psphotSubtractBackground (config, view, filerule)) {
     55        return psphotReadoutCleanup (config, view, filerule);
    5056    }
    5157    if (!strcasecmp (breakPt, "BACKMDL")) {
    52         return psphotReadoutCleanup (config, view, "PSPHOT.INPUT");
     58        return psphotReadoutCleanup (config, view, filerule);
    5359    }
    5460
    5561    // load the psf model, if suppled.  FWHM_MAJ,FWHM_MIN,etc are determined and saved on
    56     // readout->analysis. XXX Note: this function currently only works with a single
    57     // PSPHOT.INPUT
    58     if (!psphotLoadPSF (config, view)) { // ??? need to supply 2 ?
     62    // readout->analysis. NOTE: this function currently only loads from PSPHOT.PSF.LOAD
     63    if (!psphotLoadPSF (config, view, filerule)) { // ??? need to supply 2 ?
    5964        psError (PSPHOT_ERR_UNKNOWN, false, "error loading psf model");
    60         return psphotReadoutCleanup (config, view, "PSPHOT.INPUT");
     65        return psphotReadoutCleanup (config, view, filerule);
    6166    }
    6267
    6368    // find the detections (by peak and/or footprint) in the image.
    64     if (!psphotFindDetections (config, view, "PSPHOT.INPUT", true)) { // pass 1
     69    if (!psphotFindDetections (config, view, filerule, true)) { // pass 1
    6570        // this only happens if we had an error in psphotFindDetections
    6671        psError (PSPHOT_ERR_UNKNOWN, false, "failure in peak analysis");
    67         return psphotReadoutCleanup (config, view, "PSPHOT.INPUT");
     72        return psphotReadoutCleanup (config, view, filerule);
    6873    }
    6974
    7075    // construct sources and measure basic stats (saved on detections->newSources)
    71     if (!psphotSourceStats (config, view, "PSPHOT.INPUT", true)) { // pass 1
     76    if (!psphotSourceStats (config, view, filerule, true)) { // pass 1
    7277        psError(PSPHOT_ERR_UNKNOWN, false, "failure to generate sources");
    73         return psphotReadoutCleanup (config, view, "PSPHOT.INPUT");
     78        return psphotReadoutCleanup (config, view, filerule);
    7479    }
    7580    if (!strcasecmp (breakPt, "PEAKS")) {
    76         return psphotReadoutCleanup (config, view, "PSPHOT.INPUT");
     81        return psphotReadoutCleanup (config, view, filerule);
    7782    }
    7883
    7984    // find blended neighbors of very saturated stars (detections->newSources)
    80     if (!psphotDeblendSatstars (config, view, "PSPHOT.INPUT")) {
     85    if (!psphotDeblendSatstars (config, view, filerule)) {
    8186        psError (PSPHOT_ERR_UNKNOWN, false, "failed on satstar deblend analysis");
    82         return psphotReadoutCleanup (config, view, "PSPHOT.INPUT");
     87        return psphotReadoutCleanup (config, view, filerule);
    8388    }
    8489
    8590    // mark blended peaks PS_SOURCE_BLEND (detections->newSources)
    86     if (!psphotBasicDeblend (config, view, "PSPHOT.INPUT")) {
     91    if (!psphotBasicDeblend (config, view, filerule)) {
    8792        psError (PSPHOT_ERR_UNKNOWN, false, "failed on deblend analysis");
    88         return psphotReadoutCleanup (config, view, "PSPHOT.INPUT");
     93        return psphotReadoutCleanup (config, view, filerule);
    8994    }
    9095
    9196    // classify sources based on moments, brightness.  if a PSF model has been loaded, the PSF
    9297    // clump defined for it is used not measured (detections->newSources)
    93     if (!psphotRoughClass (config, view, "PSPHOT.INPUT")) { // pass 1
     98    if (!psphotRoughClass (config, view, filerule)) { // pass 1
    9499        psError (PSPHOT_ERR_UNKNOWN, false, "failed to determine rough classifications");
    95         return psphotReadoutCleanup (config, view, "PSPHOT.INPUT");
     100        return psphotReadoutCleanup (config, view, filerule);
    96101    }
    97102
    98103    // if we were not supplied a PSF model, determine the IQ stats here (detections->newSources)
    99     if (!psphotImageQuality (config, view, "PSPHOT.INPUT")) { // pass 1
     104    if (!psphotImageQuality (config, view, filerule)) { // pass 1
    100105        psError (PSPHOT_ERR_UNKNOWN, false, "failed to measure image quality");
    101         return psphotReadoutCleanup (config, view, "PSPHOT.INPUT");
     106        return psphotReadoutCleanup (config, view, filerule);
    102107    }
    103108    if (!strcasecmp (breakPt, "MOMENTS")) {
    104         return psphotReadoutCleanup (config, view, "PSPHOT.INPUT");
     109        return psphotReadoutCleanup (config, view, filerule);
    105110    }
    106111
    107112    // use bright stellar objects to measure PSF if we were supplied a PSF for any input file,
    108113    // this step is skipped
    109     if (!psphotChoosePSF (config, view, "PSPHOT.INPUT")) { // pass 1
     114    if (!psphotChoosePSF (config, view, filerule)) { // pass 1
    110115        psLogMsg ("psphot", 3, "failure to construct a psf model");
    111         return psphotReadoutCleanup (config, view, "PSPHOT.INPUT");
     116        return psphotReadoutCleanup (config, view, filerule);
    112117    }
    113118    if (!strcasecmp (breakPt, "PSFMODEL")) {
    114         return psphotReadoutCleanup (config, view, "PSPHOT.INPUT");
     119        return psphotReadoutCleanup (config, view, filerule);
    115120    }
    116121
    117122    // include externally-supplied sources
    118123    // XXX fix this in the new multi-input context
    119     // psphotLoadExtSources (config, view, "PSPHOT.INPUT"); // pass 1
     124    // psphotLoadExtSources (config, view, filerule); // pass 1
    120125
    121126    // construct an initial model for each object, set the radius to fitRadius, set circular
    122127    // fit mask (detections->newSources)
    123     psphotGuessModels (config, view, "PSPHOT.INPUT"); // pass 1
     128    psphotGuessModels (config, view, filerule); // pass 1
    124129
    125130    // merge the newly selected sources into the existing list
    126131    // NOTE: merge OLD and NEW
    127     psphotMergeSources (config, view, "PSPHOT.INPUT");
     132    psphotMergeSources (config, view, filerule);
    128133
    129134    // linear PSF fit to source peaks, subtract the models from the image (in PSF mask)
    130     psphotFitSourcesLinear (config, view, "PSPHOT.INPUT", false); // pass 1 (detections->allSources)
     135    psphotFitSourcesLinear (config, view, filerule, false); // pass 1 (detections->allSources)
    131136
    132137    // identify CRs and extended sources (only unmeasured sources are measured)
    133     psphotSourceSize (config, view, "PSPHOT.INPUT", true); // pass 1 (detections->allSources)
     138    psphotSourceSize (config, view, filerule, true); // pass 1 (detections->allSources)
    134139    if (!strcasecmp (breakPt, "ENSEMBLE")) {
    135140        goto finish;
     
    138143    // non-linear PSF and EXT fit to brighter sources
    139144    // replace model flux, adjust mask as needed, fit, subtract the models (full stamp)
    140     psphotBlendFit (config, view, "PSPHOT.INPUT"); // pass 1 (detections->allSources)
     145    psphotBlendFit (config, view, filerule); // pass 1 (detections->allSources)
    141146
    142147    // replace all sources
    143     psphotReplaceAllSources (config, view, "PSPHOT.INPUT"); // pass 1 (detections->allSources)
     148    psphotReplaceAllSources (config, view, filerule); // pass 1 (detections->allSources)
    144149
    145150    // linear fit to include all sources (subtract again)
    146151    // NOTE : apply to ALL sources (extended + psf)
    147     psphotFitSourcesLinear (config, view, "PSPHOT.INPUT", true); // pass 2 (detections->allSources)
     152    psphotFitSourcesLinear (config, view, filerule, true); // pass 2 (detections->allSources)
    148153
    149154    // if we only do one pass, skip to extended source analysis
     
    153158
    154159    // add noise for subtracted objects
    155     psphotAddNoise (config, view, "PSPHOT.INPUT"); // pass 1 (detections->allSources)
     160    psphotAddNoise (config, view, filerule); // pass 1 (detections->allSources)
    156161
    157162    // find fainter sources
    158163    // NOTE: finds new peaks and new footprints, OLD and FULL set are saved on detections
    159     psphotFindDetections (config, view, "PSPHOT.INPUT", false); // pass 2 (detections->peaks, detections->footprints)
     164    psphotFindDetections (config, view, filerule, false); // pass 2 (detections->peaks, detections->footprints)
    160165
    161166    // remove noise for subtracted objects (ie, return to normal noise level)
    162167    // NOTE: this needs to operate only on the OLD sources
    163     psphotSubNoise (config, view, "PSPHOT.INPUT"); // pass 1 (detections->allSources)
     168    psphotSubNoise (config, view, filerule); // pass 1 (detections->allSources)
    164169
    165170    // define new sources based on only the new peaks
    166171    // NOTE: new sources are saved on detections->newSources
    167     psphotSourceStats (config, view, "PSPHOT.INPUT", false); // pass 2 (detections->newSources)
     172    psphotSourceStats (config, view, filerule, false); // pass 2 (detections->newSources)
    168173
    169174    // set source type
    170175    // NOTE: apply only to detections->newSources
    171     if (!psphotRoughClass (config, view, "PSPHOT.INPUT")) { // pass 2 (detections->newSources)
     176    if (!psphotRoughClass (config, view, filerule)) { // pass 2 (detections->newSources)
    172177        psLogMsg ("psphot", 3, "failed to find a valid PSF clump for image");
    173         return psphotReadoutCleanup (config, view, "PSPHOT.INPUT");
     178        return psphotReadoutCleanup (config, view, filerule);
    174179    }
    175180
    176181    // create full input models, set the radius to fitRadius, set circular fit mask
    177182    // NOTE: apply only to detections->newSources
    178     psphotGuessModels (config, view, "PSPHOT.INPUT"); // pass 2 (detections->newSources)
     183    psphotGuessModels (config, view, filerule); // pass 2 (detections->newSources)
    179184
    180185    // replace all sources so fit below applies to all at once
    181186    // NOTE: apply only to OLD sources (which have been subtracted)
    182     psphotReplaceAllSources (config, view, "PSPHOT.INPUT"); // pass 2
     187    psphotReplaceAllSources (config, view, filerule); // pass 2
    183188
    184189    // merge the newly selected sources into the existing list
    185190    // NOTE: merge OLD and NEW
    186191    // XXX check on free of sources...
    187     psphotMergeSources (config, view, "PSPHOT.INPUT"); // (detections->newSources + detections->allSources -> detections->allSources)
     192    psphotMergeSources (config, view, filerule); // (detections->newSources + detections->allSources -> detections->allSources)
    188193
    189194    // NOTE: apply to ALL sources
    190     psphotFitSourcesLinear (config, view, "PSPHOT.INPUT", true); // pass 3 (detections->allSources)
     195    psphotFitSourcesLinear (config, view, filerule, true); // pass 3 (detections->allSources)
    191196
    192197pass1finish:
     
    194199    // measure source size for the remaining sources
    195200    // NOTE: applies only to NEW (unmeasured) sources
    196     psphotSourceSize (config, view, "PSPHOT.INPUT", false); // pass 2 (detections->allSources)
    197 
    198     psphotExtendedSourceAnalysis (config, view, "PSPHOT.INPUT"); // pass 1 (detections->allSources)
    199     psphotExtendedSourceFits (config, view, "PSPHOT.INPUT"); // pass 1 (detections->allSources)
     201    psphotSourceSize (config, view, filerule, false); // pass 2 (detections->allSources)
     202
     203    psphotExtendedSourceAnalysis (config, view, filerule); // pass 1 (detections->allSources)
     204    psphotExtendedSourceFits (config, view, filerule); // pass 1 (detections->allSources)
    200205
    201206finish:
     
    205210
    206211    // measure aperture photometry corrections
    207     if (!psphotApResid (config, view, "PSPHOT.INPUT")) { // pass 1 (detections->allSources)
     212    if (!psphotApResid (config, view, filerule)) { // pass 1 (detections->allSources)
    208213        psLogMsg ("psphot", 3, "failed on psphotApResid");
    209         return psphotReadoutCleanup (config, view, "PSPHOT.INPUT");
     214        return psphotReadoutCleanup (config, view, filerule);
    210215    }
    211216
    212217    // calculate source magnitudes
    213     if (!psphotMagnitudes(config, view, "PSPHOT.INPUT")) { // pass 1 (detections->allSources)
     218    if (!psphotMagnitudes(config, view, filerule)) { // pass 1 (detections->allSources)
    214219      psErrorStackPrint(stderr, "Unable to do magnitudes.");
    215220        psErrorClear();
    216221    }
    217     if (!psphotEfficiency(config, view, "PSPHOT.INPUT")) { // pass 1
     222    if (!psphotEfficiency(config, view, filerule)) { // pass 1
    218223        psErrorStackPrint(stderr, "Unable to determine detection efficiencies from fake sources");
    219224        psErrorClear();
     
    224229
    225230    // replace background in residual image
    226     if (!psphotSkyReplace (config, view, "PSPHOT.INPUT")) { // pass 1
     231    if (!psphotSkyReplace (config, view, filerule)) { // pass 1
    227232      psErrorStackPrint(stderr, "Unable to replace sky");
    228233      psErrorClear();
    229234
    230235/*       psLogMsg("psphot", 3, "failed on psphotSkyReplace"); */
    231 /*       return(psphotReadoutCleanup(config, view, "PSPHOT.INPUT")); */
     236/*       return(psphotReadoutCleanup(config, view, filerule)); */
    232237    }
    233238    // drop the references to the image pixels held by each source
    234     if (!psphotSourceFreePixels (config, view, "PSPHOT.INPUT")) { // pass 1
     239    if (!psphotSourceFreePixels (config, view, filerule)) { // pass 1
    235240      psErrorStackPrint(stderr, "Unable to free source pixels");
    236241      psErrorClear();
    237242
    238243/*       psLogMsg ("psphot", 3, "failed on psphotSourceFreePixels"); */
    239 /*       return(psphotReadoutCleanup(config, view, "PSPHOT.INPUT")); */
     244/*       return(psphotReadoutCleanup(config, view, filerule)); */
    240245    }
    241246    // create the exported-metadata and free local data
    242     return psphotReadoutCleanup(config, view, "PSPHOT.INPUT");
     247    return psphotReadoutCleanup(config, view, filerule);
    243248}
Note: See TracChangeset for help on using the changeset viewer.