IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jun 16, 2010, 5:30:27 PM (16 years ago)
Author:
watersc1
Message:

merge of stack association and warp/stack/diff jpegs

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/psphot

  • trunk/psphot/src/psphotReadout.c

    r28013 r28375  
    1414    // by the multiple threads, not the total time used by all threads.
    1515    psTimerStart ("psphotReadout");
    16 
     16    printf("%x %s\n",psErrorCodeLast(),psErrorCodeString(psErrorCodeLast()));
    1717    pmModelClassSetLimits(PM_MODEL_LIMITS_LAX);
    1818
     
    2626    char *breakPt = psMetadataLookupStr (NULL, recipe, "BREAK_POINT");
    2727    psAssert (breakPt, "configuration error: set BREAK_POINT");
    28 
     28    printf("%x %s\n",psErrorCodeLast(),psErrorCodeString(psErrorCodeLast()));
    2929    // set the photcode for this image
    3030    if (!psphotAddPhotcode (config, view, "PSPHOT.INPUT")) {
     
    3232        return false;
    3333    }
    34 
     34        printf("%x %s\n",psErrorCodeLast(),psErrorCodeString(psErrorCodeLast()));
    3535    // Generate the mask and weight images, including the user-defined analysis region of interest
    3636    if (!psphotSetMaskAndVariance (config, view, "PSPHOT.INPUT")) {
     
    4040        return psphotReadoutCleanup (config, view, "PSPHOT.INPUT");
    4141    }
    42 
     42        printf("%x %s\n",psErrorCodeLast(),psErrorCodeString(psErrorCodeLast()));
    4343    // generate a background model (median, smoothed image)
    4444    if (!psphotModelBackground (config, view, "PSPHOT.INPUT")) {
    4545        return psphotReadoutCleanup (config, view, "PSPHOT.INPUT");
    4646    }
     47            printf("%x %s\n",psErrorCodeLast(),psErrorCodeString(psErrorCodeLast()));
    4748    if (!psphotSubtractBackground (config, view, "PSPHOT.INPUT")) {
    4849        return psphotReadoutCleanup (config, view, "PSPHOT.INPUT");
     
    5152        return psphotReadoutCleanup (config, view, "PSPHOT.INPUT");
    5253    }
    53 
     54        printf("%x %s\n",psErrorCodeLast(),psErrorCodeString(psErrorCodeLast()));
    5455    // load the psf model, if suppled.  FWHM_X,FWHM_Y,etc are determined and saved on
    5556    // readout->analysis XXX this function currently only works with a single PSPHOT.INPUT
     
    5859        return psphotReadoutCleanup (config, view, "PSPHOT.INPUT");
    5960    }
    60 
     61        printf("%x %s\n",psErrorCodeLast(),psErrorCodeString(psErrorCodeLast()));
    6162    // find the detections (by peak and/or footprint) in the image.
    6263    if (!psphotFindDetections (config, view, "PSPHOT.INPUT", true)) { // pass 1
     
    6566        return psphotReadoutCleanup (config, view, "PSPHOT.INPUT");
    6667    }
    67 
     68        printf("%x %s\n",psErrorCodeLast(),psErrorCodeString(psErrorCodeLast()));
    6869    // construct sources and measure basic stats (saved on detections->newSources)
    6970    if (!psphotSourceStats (config, view, "PSPHOT.INPUT", true)) { // pass 1
     
    7475        return psphotReadoutCleanup (config, view, "PSPHOT.INPUT");
    7576    }
    76 
     77        printf("%x %s\n",psErrorCodeLast(),psErrorCodeString(psErrorCodeLast()));
    7778    // find blended neighbors of very saturated stars (detections->newSources)
    7879    if (!psphotDeblendSatstars (config, view, "PSPHOT.INPUT")) {
     
    8081        return psphotReadoutCleanup (config, view, "PSPHOT.INPUT");
    8182    }
    82 
     83        printf("%x %s\n",psErrorCodeLast(),psErrorCodeString(psErrorCodeLast()));
    8384    // mark blended peaks PS_SOURCE_BLEND (detections->newSources)
    8485    if (!psphotBasicDeblend (config, view, "PSPHOT.INPUT")) {
     
    8687        return psphotReadoutCleanup (config, view, "PSPHOT.INPUT");
    8788    }
    88 
     89        printf("%x %s\n",psErrorCodeLast(),psErrorCodeString(psErrorCodeLast()));
    8990    // classify sources based on moments, brightness.  if a PSF model has been loaded, the PSF
    9091    // clump defined for it is used not measured (detections->newSources)
     
    9394        return psphotReadoutCleanup (config, view, "PSPHOT.INPUT");
    9495    }
     96            printf("%x %s\n",psErrorCodeLast(),psErrorCodeString(psErrorCodeLast()));
    9597    // if we were not supplied a PSF model, determine the IQ stats here (detections->newSources)
    9698    if (!psphotImageQuality (config, view, "PSPHOT.INPUT")) { // pass 1
     
    101103        return psphotReadoutCleanup (config, view, "PSPHOT.INPUT");
    102104    }
    103 
     105        printf("%x %s\n",psErrorCodeLast(),psErrorCodeString(psErrorCodeLast()));
    104106    // use bright stellar objects to measure PSF if we were supplied a PSF for any input file,
    105107    // this step is skipped
     
    115117    // XXX fix this in the new multi-input context
    116118    // psphotLoadExtSources (config, view, "PSPHOT.INPUT"); // pass 1
    117 
     119        printf("%x %s\n",psErrorCodeLast(),psErrorCodeString(psErrorCodeLast()));
    118120    // construct an initial model for each object, set the radius to fitRadius, set circular
    119121    // fit mask (detections->newSources)
    120122    psphotGuessModels (config, view, "PSPHOT.INPUT"); // pass 1
    121 
     123        printf("%x %s\n",psErrorCodeLast(),psErrorCodeString(psErrorCodeLast()));
    122124    // merge the newly selected sources into the existing list
    123125    // NOTE: merge OLD and NEW
    124126    psphotMergeSources (config, view, "PSPHOT.INPUT");
    125 
     127        printf("%x %s\n",psErrorCodeLast(),psErrorCodeString(psErrorCodeLast()));
    126128    // linear PSF fit to source peaks, subtract the models from the image (in PSF mask)
    127129    psphotFitSourcesLinear (config, view, "PSPHOT.INPUT", false); // pass 1 (detections->allSources)
    128 
     130        printf("%x %s\n",psErrorCodeLast(),psErrorCodeString(psErrorCodeLast()));
    129131    // identify CRs and extended sources (only unmeasured sources are measured)
    130132    psphotSourceSize (config, view, "PSPHOT.INPUT", true); // pass 1 (detections->allSources)
     
    132134        goto finish;
    133135    }
    134 
     136        printf("%x %s\n",psErrorCodeLast(),psErrorCodeString(psErrorCodeLast()));
    135137    // non-linear PSF and EXT fit to brighter sources
    136138    // replace model flux, adjust mask as needed, fit, subtract the models (full stamp)
    137139    psphotBlendFit (config, view, "PSPHOT.INPUT"); // pass 1 (detections->allSources)
    138 
     140        printf("%x %s\n",psErrorCodeLast(),psErrorCodeString(psErrorCodeLast()));
    139141    // replace all sources
    140142    psphotReplaceAllSources (config, view, "PSPHOT.INPUT"); // pass 1 (detections->allSources)
    141 
     143        printf("%x %s\n",psErrorCodeLast(),psErrorCodeString(psErrorCodeLast()));
    142144    // linear fit to include all sources (subtract again)
    143145    // NOTE : apply to ALL sources (extended + psf)
    144146    psphotFitSourcesLinear (config, view, "PSPHOT.INPUT", true); // pass 2 (detections->allSources)
    145 
     147        printf("%x %s\n",psErrorCodeLast(),psErrorCodeString(psErrorCodeLast()));
    146148    // if we only do one pass, skip to extended source analysis
    147149    if (!strcasecmp (breakPt, "PASS1")) goto pass1finish;
    148 
     150        printf("%x %s\n",psErrorCodeLast(),psErrorCodeString(psErrorCodeLast()));
    149151    // NOTE: possibly re-measure background model here with objects subtracted / or masked
    150152
    151153    // add noise for subtracted objects
    152154    psphotAddNoise (config, view, "PSPHOT.INPUT"); // pass 1 (detections->allSources)
    153 
     155        printf("%x %s\n",psErrorCodeLast(),psErrorCodeString(psErrorCodeLast()));
    154156    // find fainter sources
    155157    // NOTE: finds new peaks and new footprints, OLD and FULL set are saved on detections
    156158    psphotFindDetections (config, view, "PSPHOT.INPUT", false); // pass 2 (detections->peaks, detections->footprints)
    157 
     159        printf("%x %s\n",psErrorCodeLast(),psErrorCodeString(psErrorCodeLast()));
    158160    // remove noise for subtracted objects (ie, return to normal noise level)
    159161    // NOTE: this needs to operate only on the OLD sources
    160162    psphotSubNoise (config, view, "PSPHOT.INPUT"); // pass 1 (detections->allSources)
    161 
     163        printf("%x %s\n",psErrorCodeLast(),psErrorCodeString(psErrorCodeLast()));
    162164    // define new sources based on only the new peaks
    163165    // NOTE: new sources are saved on detections->newSources
    164166    psphotSourceStats (config, view, "PSPHOT.INPUT", false); // pass 2 (detections->newSources)
    165 
     167        printf("%x %s\n",psErrorCodeLast(),psErrorCodeString(psErrorCodeLast()));
    166168    // set source type
    167169    // NOTE: apply only to detections->newSources
     
    170172        return psphotReadoutCleanup (config, view, "PSPHOT.INPUT");
    171173    }
    172 
     174        printf("%x %s\n",psErrorCodeLast(),psErrorCodeString(psErrorCodeLast()));
    173175    // create full input models, set the radius to fitRadius, set circular fit mask
    174176    // NOTE: apply only to detections->newSources
    175177    psphotGuessModels (config, view, "PSPHOT.INPUT"); // pass 2 (detections->newSources)
    176 
     178        printf("%x %s\n",psErrorCodeLast(),psErrorCodeString(psErrorCodeLast()));
    177179    // replace all sources so fit below applies to all at once
    178180    // NOTE: apply only to OLD sources (which have been subtracted)
    179181    psphotReplaceAllSources (config, view, "PSPHOT.INPUT"); // pass 2
    180 
     182        printf("%x %s\n",psErrorCodeLast(),psErrorCodeString(psErrorCodeLast()));
    181183    // merge the newly selected sources into the existing list
    182184    // NOTE: merge OLD and NEW
    183185    // XXX check on free of sources...
    184186    psphotMergeSources (config, view, "PSPHOT.INPUT"); // (detections->newSources + detections->allSources -> detections->allSources)
    185 
     187        printf("%x %s\n",psErrorCodeLast(),psErrorCodeString(psErrorCodeLast()));
    186188    // NOTE: apply to ALL sources
    187189    psphotFitSourcesLinear (config, view, "PSPHOT.INPUT", true); // pass 3 (detections->allSources)
    188 
     190        printf("%x %s\n",psErrorCodeLast(),psErrorCodeString(psErrorCodeLast()));
    189191pass1finish:
    190192
     
    192194    // NOTE: applies only to NEW (unmeasured) sources
    193195    psphotSourceSize (config, view, "PSPHOT.INPUT", false); // pass 2 (detections->allSources)
    194 
     196        printf("%x %s\n",psErrorCodeLast(),psErrorCodeString(psErrorCodeLast()));
    195197    psphotExtendedSourceAnalysis (config, view, "PSPHOT.INPUT"); // pass 1 (detections->allSources)
    196198    psphotExtendedSourceFits (config, view, "PSPHOT.INPUT"); // pass 1 (detections->allSources)
    197 
     199        printf("%x %s\n",psErrorCodeLast(),psErrorCodeString(psErrorCodeLast()));
    198200finish:
    199201
    200202    // plot positive sources
    201203    // psphotSourcePlots (readout, sources, recipe);
    202 
     204        printf("%x %s\n",psErrorCodeLast(),psErrorCodeString(psErrorCodeLast()));
    203205    // measure aperture photometry corrections
    204206    if (!psphotApResid (config, view, "PSPHOT.INPUT")) { // pass 1 (detections->allSources)
     
    206208        return psphotReadoutCleanup (config, view, "PSPHOT.INPUT");
    207209    }
    208 
     210        printf("%x %s\n",psErrorCodeLast(),psErrorCodeString(psErrorCodeLast()));
    209211    // calculate source magnitudes
    210     psphotMagnitudes(config, view, "PSPHOT.INPUT"); // pass 1 (detections->allSources)
    211 
     212    if (!psphotMagnitudes(config, view, "PSPHOT.INPUT")) { // pass 1 (detections->allSources)
     213      psErrorStackPrint(stderr, "Unable to do magnitudes.");
     214        psErrorClear();
     215    }     
    212216    if (!psphotEfficiency(config, view, "PSPHOT.INPUT")) { // pass 1
    213217        psErrorStackPrint(stderr, "Unable to determine detection efficiencies from fake sources");
     
    219223
    220224    // replace background in residual image
    221     psphotSkyReplace (config, view, "PSPHOT.INPUT"); // pass 1
    222 
     225    if (!psphotSkyReplace (config, view, "PSPHOT.INPUT")) { // pass 1
     226      psErrorStackPrint(stderr, "Unable to replace sky");
     227      psErrorClear();
     228
     229/*       psLogMsg("psphot", 3, "failed on psphotSkyReplace"); */
     230/*       return(psphotReadoutCleanup(config, view, "PSPHOT.INPUT")); */
     231    }
    223232    // drop the references to the image pixels held by each source
    224     psphotSourceFreePixels (config, view, "PSPHOT.INPUT"); // pass 1
    225 
     233    if (!psphotSourceFreePixels (config, view, "PSPHOT.INPUT")) { // pass 1
     234      psErrorStackPrint(stderr, "Unable to free source pixels");
     235      psErrorClear();
     236
     237/*       psLogMsg ("psphot", 3, "failed on psphotSourceFreePixels"); */
     238/*       return(psphotReadoutCleanup(config, view, "PSPHOT.INPUT")); */
     239    }
    226240    // create the exported-metadata and free local data
    227241    return psphotReadoutCleanup(config, view, "PSPHOT.INPUT");
Note: See TracChangeset for help on using the changeset viewer.