IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Dec 3, 2010, 2:28:34 AM (16 years ago)
Author:
eugene
Message:

modify psphotReadout and equivalent to accept a filerule argument (allow filerules other than PSPHOT.INPUT)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20101103/psphot/src/psphotReadout.c

    r29004 r29904  
    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
     
    2828
    2929    // set the photcode for this image
    30     if (!psphotAddPhotcode (config, view, "PSPHOT.INPUT")) {
     30    if (!psphotAddPhotcode (config, view, filerule)) {
    3131        psError (PSPHOT_ERR_CONFIG, false, "trouble defining the photcode");
    3232        return false;
     
    3434
    3535    // 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");
     36    if (!psphotSetMaskAndVariance (config, view, filerule)) {
     37        return psphotReadoutCleanup(config, view, filerule);
    3838    }
    3939    if (!strcasecmp (breakPt, "NOTHING")) {
    40         return psphotReadoutCleanup (config, view, "PSPHOT.INPUT");
     40        return psphotReadoutCleanup (config, view, filerule);
    4141    }
    4242
    4343    // 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");
     44    if (!psphotModelBackground (config, view, filerule)) {
     45        return psphotReadoutCleanup (config, view, filerule);
     46    }
     47
     48    if (!psphotSubtractBackground (config, view, filerule)) {
     49        return psphotReadoutCleanup (config, view, filerule);
    5050    }
    5151    if (!strcasecmp (breakPt, "BACKMDL")) {
    52         return psphotReadoutCleanup (config, view, "PSPHOT.INPUT");
     52        return psphotReadoutCleanup (config, view, filerule);
    5353    }
    5454
    5555    // 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 ?
     56    // readout->analysis. NOTE: this function currently only loads from PSPHOT.PSF.LOAD
     57    if (!psphotLoadPSF (config, view, filerule)) { // ??? need to supply 2 ?
    5958        psError (PSPHOT_ERR_UNKNOWN, false, "error loading psf model");
    60         return psphotReadoutCleanup (config, view, "PSPHOT.INPUT");
     59        return psphotReadoutCleanup (config, view, filerule);
    6160    }
    6261
    6362    // find the detections (by peak and/or footprint) in the image.
    64     if (!psphotFindDetections (config, view, "PSPHOT.INPUT", true)) { // pass 1
     63    if (!psphotFindDetections (config, view, filerule, true)) { // pass 1
    6564        // this only happens if we had an error in psphotFindDetections
    6665        psError (PSPHOT_ERR_UNKNOWN, false, "failure in peak analysis");
    67         return psphotReadoutCleanup (config, view, "PSPHOT.INPUT");
     66        return psphotReadoutCleanup (config, view, filerule);
    6867    }
    6968
    7069    // construct sources and measure basic stats (saved on detections->newSources)
    71     if (!psphotSourceStats (config, view, "PSPHOT.INPUT", true)) { // pass 1
     70    if (!psphotSourceStats (config, view, filerule, true)) { // pass 1
    7271        psError(PSPHOT_ERR_UNKNOWN, false, "failure to generate sources");
    73         return psphotReadoutCleanup (config, view, "PSPHOT.INPUT");
     72        return psphotReadoutCleanup (config, view, filerule);
    7473    }
    7574    if (!strcasecmp (breakPt, "PEAKS")) {
    76         return psphotReadoutCleanup (config, view, "PSPHOT.INPUT");
     75        return psphotReadoutCleanup (config, view, filerule);
    7776    }
    7877
    7978    // find blended neighbors of very saturated stars (detections->newSources)
    80     if (!psphotDeblendSatstars (config, view, "PSPHOT.INPUT")) {
     79    if (!psphotDeblendSatstars (config, view, filerule)) {
    8180        psError (PSPHOT_ERR_UNKNOWN, false, "failed on satstar deblend analysis");
    82         return psphotReadoutCleanup (config, view, "PSPHOT.INPUT");
     81        return psphotReadoutCleanup (config, view, filerule);
    8382    }
    8483
    8584    // mark blended peaks PS_SOURCE_BLEND (detections->newSources)
    86     if (!psphotBasicDeblend (config, view, "PSPHOT.INPUT")) {
     85    if (!psphotBasicDeblend (config, view, filerule)) {
    8786        psError (PSPHOT_ERR_UNKNOWN, false, "failed on deblend analysis");
    88         return psphotReadoutCleanup (config, view, "PSPHOT.INPUT");
     87        return psphotReadoutCleanup (config, view, filerule);
    8988    }
    9089
    9190    // classify sources based on moments, brightness.  if a PSF model has been loaded, the PSF
    9291    // clump defined for it is used not measured (detections->newSources)
    93     if (!psphotRoughClass (config, view, "PSPHOT.INPUT")) { // pass 1
     92    if (!psphotRoughClass (config, view, filerule)) { // pass 1
    9493        psError (PSPHOT_ERR_UNKNOWN, false, "failed to determine rough classifications");
    95         return psphotReadoutCleanup (config, view, "PSPHOT.INPUT");
     94        return psphotReadoutCleanup (config, view, filerule);
    9695    }
    9796
    9897    // if we were not supplied a PSF model, determine the IQ stats here (detections->newSources)
    99     if (!psphotImageQuality (config, view, "PSPHOT.INPUT")) { // pass 1
     98    if (!psphotImageQuality (config, view, filerule)) { // pass 1
    10099        psError (PSPHOT_ERR_UNKNOWN, false, "failed to measure image quality");
    101         return psphotReadoutCleanup (config, view, "PSPHOT.INPUT");
     100        return psphotReadoutCleanup (config, view, filerule);
    102101    }
    103102    if (!strcasecmp (breakPt, "MOMENTS")) {
    104         return psphotReadoutCleanup (config, view, "PSPHOT.INPUT");
     103        return psphotReadoutCleanup (config, view, filerule);
    105104    }
    106105
    107106    // use bright stellar objects to measure PSF if we were supplied a PSF for any input file,
    108107    // this step is skipped
    109     if (!psphotChoosePSF (config, view, "PSPHOT.INPUT")) { // pass 1
     108    if (!psphotChoosePSF (config, view, filerule)) { // pass 1
    110109        psLogMsg ("psphot", 3, "failure to construct a psf model");
    111         return psphotReadoutCleanup (config, view, "PSPHOT.INPUT");
     110        return psphotReadoutCleanup (config, view, filerule);
    112111    }
    113112    if (!strcasecmp (breakPt, "PSFMODEL")) {
    114         return psphotReadoutCleanup (config, view, "PSPHOT.INPUT");
     113        return psphotReadoutCleanup (config, view, filerule);
    115114    }
    116115
    117116    // include externally-supplied sources
    118117    // XXX fix this in the new multi-input context
    119     // psphotLoadExtSources (config, view, "PSPHOT.INPUT"); // pass 1
     118    // psphotLoadExtSources (config, view, filerule); // pass 1
    120119
    121120    // construct an initial model for each object, set the radius to fitRadius, set circular
    122121    // fit mask (detections->newSources)
    123     psphotGuessModels (config, view, "PSPHOT.INPUT"); // pass 1
     122    psphotGuessModels (config, view, filerule); // pass 1
    124123
    125124    // merge the newly selected sources into the existing list
    126125    // NOTE: merge OLD and NEW
    127     psphotMergeSources (config, view, "PSPHOT.INPUT");
     126    psphotMergeSources (config, view, filerule);
    128127
    129128    // 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)
     129    psphotFitSourcesLinear (config, view, filerule, false); // pass 1 (detections->allSources)
    131130
    132131    // identify CRs and extended sources (only unmeasured sources are measured)
    133     psphotSourceSize (config, view, "PSPHOT.INPUT", true); // pass 1 (detections->allSources)
     132    psphotSourceSize (config, view, filerule, true); // pass 1 (detections->allSources)
    134133    if (!strcasecmp (breakPt, "ENSEMBLE")) {
    135134        goto finish;
     
    138137    // non-linear PSF and EXT fit to brighter sources
    139138    // replace model flux, adjust mask as needed, fit, subtract the models (full stamp)
    140     psphotBlendFit (config, view, "PSPHOT.INPUT"); // pass 1 (detections->allSources)
     139    psphotBlendFit (config, view, filerule); // pass 1 (detections->allSources)
    141140
    142141    // replace all sources
    143     psphotReplaceAllSources (config, view, "PSPHOT.INPUT"); // pass 1 (detections->allSources)
     142    psphotReplaceAllSources (config, view, filerule); // pass 1 (detections->allSources)
    144143
    145144    // linear fit to include all sources (subtract again)
    146145    // NOTE : apply to ALL sources (extended + psf)
    147     psphotFitSourcesLinear (config, view, "PSPHOT.INPUT", true); // pass 2 (detections->allSources)
     146    psphotFitSourcesLinear (config, view, filerule, true); // pass 2 (detections->allSources)
    148147
    149148    // if we only do one pass, skip to extended source analysis
     
    153152
    154153    // add noise for subtracted objects
    155     psphotAddNoise (config, view, "PSPHOT.INPUT"); // pass 1 (detections->allSources)
     154    psphotAddNoise (config, view, filerule); // pass 1 (detections->allSources)
    156155
    157156    // find fainter sources
    158157    // 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)
     158    psphotFindDetections (config, view, filerule, false); // pass 2 (detections->peaks, detections->footprints)
    160159
    161160    // remove noise for subtracted objects (ie, return to normal noise level)
    162161    // NOTE: this needs to operate only on the OLD sources
    163     psphotSubNoise (config, view, "PSPHOT.INPUT"); // pass 1 (detections->allSources)
     162    psphotSubNoise (config, view, filerule); // pass 1 (detections->allSources)
    164163
    165164    // define new sources based on only the new peaks
    166165    // NOTE: new sources are saved on detections->newSources
    167     psphotSourceStats (config, view, "PSPHOT.INPUT", false); // pass 2 (detections->newSources)
     166    psphotSourceStats (config, view, filerule, false); // pass 2 (detections->newSources)
    168167
    169168    // set source type
    170169    // NOTE: apply only to detections->newSources
    171     if (!psphotRoughClass (config, view, "PSPHOT.INPUT")) { // pass 2 (detections->newSources)
     170    if (!psphotRoughClass (config, view, filerule)) { // pass 2 (detections->newSources)
    172171        psLogMsg ("psphot", 3, "failed to find a valid PSF clump for image");
    173         return psphotReadoutCleanup (config, view, "PSPHOT.INPUT");
     172        return psphotReadoutCleanup (config, view, filerule);
    174173    }
    175174
    176175    // create full input models, set the radius to fitRadius, set circular fit mask
    177176    // NOTE: apply only to detections->newSources
    178     psphotGuessModels (config, view, "PSPHOT.INPUT"); // pass 2 (detections->newSources)
     177    psphotGuessModels (config, view, filerule); // pass 2 (detections->newSources)
    179178
    180179    // replace all sources so fit below applies to all at once
    181180    // NOTE: apply only to OLD sources (which have been subtracted)
    182     psphotReplaceAllSources (config, view, "PSPHOT.INPUT"); // pass 2
     181    psphotReplaceAllSources (config, view, filerule); // pass 2
    183182
    184183    // merge the newly selected sources into the existing list
    185184    // NOTE: merge OLD and NEW
    186185    // XXX check on free of sources...
    187     psphotMergeSources (config, view, "PSPHOT.INPUT"); // (detections->newSources + detections->allSources -> detections->allSources)
     186    psphotMergeSources (config, view, filerule); // (detections->newSources + detections->allSources -> detections->allSources)
    188187
    189188    // NOTE: apply to ALL sources
    190     psphotFitSourcesLinear (config, view, "PSPHOT.INPUT", true); // pass 3 (detections->allSources)
     189    psphotFitSourcesLinear (config, view, filerule, true); // pass 3 (detections->allSources)
    191190
    192191pass1finish:
     
    194193    // measure source size for the remaining sources
    195194    // 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)
     195    psphotSourceSize (config, view, filerule, false); // pass 2 (detections->allSources)
     196
     197    psphotExtendedSourceAnalysis (config, view, filerule); // pass 1 (detections->allSources)
     198    psphotExtendedSourceFits (config, view, filerule); // pass 1 (detections->allSources)
    200199
    201200finish:
     
    205204
    206205    // measure aperture photometry corrections
    207     if (!psphotApResid (config, view, "PSPHOT.INPUT")) { // pass 1 (detections->allSources)
     206    if (!psphotApResid (config, view, filerule)) { // pass 1 (detections->allSources)
    208207        psLogMsg ("psphot", 3, "failed on psphotApResid");
    209         return psphotReadoutCleanup (config, view, "PSPHOT.INPUT");
     208        return psphotReadoutCleanup (config, view, filerule);
    210209    }
    211210
    212211    // calculate source magnitudes
    213     if (!psphotMagnitudes(config, view, "PSPHOT.INPUT")) { // pass 1 (detections->allSources)
     212    if (!psphotMagnitudes(config, view, filerule)) { // pass 1 (detections->allSources)
    214213      psErrorStackPrint(stderr, "Unable to do magnitudes.");
    215214        psErrorClear();
    216215    }
    217     if (!psphotEfficiency(config, view, "PSPHOT.INPUT")) { // pass 1
     216    if (!psphotEfficiency(config, view, filerule)) { // pass 1
    218217        psErrorStackPrint(stderr, "Unable to determine detection efficiencies from fake sources");
    219218        psErrorClear();
     
    224223
    225224    // replace background in residual image
    226     if (!psphotSkyReplace (config, view, "PSPHOT.INPUT")) { // pass 1
     225    if (!psphotSkyReplace (config, view, filerule)) { // pass 1
    227226      psErrorStackPrint(stderr, "Unable to replace sky");
    228227      psErrorClear();
    229228
    230229/*       psLogMsg("psphot", 3, "failed on psphotSkyReplace"); */
    231 /*       return(psphotReadoutCleanup(config, view, "PSPHOT.INPUT")); */
     230/*       return(psphotReadoutCleanup(config, view, filerule)); */
    232231    }
    233232    // drop the references to the image pixels held by each source
    234     if (!psphotSourceFreePixels (config, view, "PSPHOT.INPUT")) { // pass 1
     233    if (!psphotSourceFreePixels (config, view, filerule)) { // pass 1
    235234      psErrorStackPrint(stderr, "Unable to free source pixels");
    236235      psErrorClear();
    237236
    238237/*       psLogMsg ("psphot", 3, "failed on psphotSourceFreePixels"); */
    239 /*       return(psphotReadoutCleanup(config, view, "PSPHOT.INPUT")); */
     238/*       return(psphotReadoutCleanup(config, view, filerule)); */
    240239    }
    241240    // create the exported-metadata and free local data
    242     return psphotReadoutCleanup(config, view, "PSPHOT.INPUT");
     241    return psphotReadoutCleanup(config, view, filerule);
    243242}
Note: See TracChangeset for help on using the changeset viewer.