IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 29936


Ignore:
Timestamp:
Dec 5, 2010, 9:42:25 PM (15 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:
6 deleted
50 edited
1 copied

Legend:

Unmodified
Added
Removed
  • trunk/psphot

  • trunk/psphot/src/Makefile.am

    r29004 r29936  
    103103        psphotCleanup.c
    104104
    105 
    106 
    107 # # psphot analysis of the detectability of specified positions
    108 # psphotDetect_SOURCES =            \
    109 #         psphotDetect.c            \
    110 #       psphotDetectArguments.c   \
    111 #       psphotDetectParseCamera.c \
    112 #       psphotDetectImageLoop.c   \
    113 #       psphotDetectReadout.c     \
    114 #       psphotMosaicChip.c        \
    115 #       psphotCleanup.c
    116 
    117105# psphotTest_SOURCES = \
    118106#         psphotTest.c
     
    137125        psphotReadoutFindPSF.c         \
    138126        psphotReadoutKnownSources.c    \
     127        psphotReadoutForcedKnownSources.c    \
    139128        psphotReadoutMinimal.c         \
    140129        psphotModelBackground.c        \
  • trunk/psphot/src/psphot.h

    r29608 r29936  
    2424bool            psphotModelTest (pmConfig *config, const pmFPAview *view, psMetadata *recipe);
    2525bool            psphotInit (void);
    26 bool            psphotReadout (pmConfig *config, const pmFPAview *view);
    27 bool            psphotReadoutFindPSF(pmConfig *config, const pmFPAview *view, psArray *inSources);
    28 bool            psphotReadoutKnownSources(pmConfig *config, const pmFPAview *view, psArray *inSources);
    29 bool            psphotReadoutMinimal(pmConfig *config, const pmFPAview *view);
     26bool            psphotReadout (pmConfig *config, const pmFPAview *view, const char *filerule);
     27bool            psphotReadoutFindPSF(pmConfig *config, const pmFPAview *view, const char *filerule, psArray *inSources);
     28bool            psphotReadoutKnownSources(pmConfig *config, const pmFPAview *view, const char *filerule, psArray *inSources);
     29bool            psphotReadoutForcedKnownSources(pmConfig *config, const pmFPAview *view, const char *filerule, psArray *inSources);
     30bool            psphotReadoutMinimal(pmConfig *config, const pmFPAview *view, const char *filerule);
    3031
    3132bool            psphotReadoutCleanup (pmConfig *config, const pmFPAview *view, const char *filerule);
     
    219220bool            psphotFitSummary (void);
    220221
    221 bool            psphotLoadPSF (pmConfig *config, const pmFPAview *view);
     222bool            psphotLoadPSF (pmConfig *config, const pmFPAview *view, const char *filerule);
    222223bool            psphotLoadPSFReadout (pmConfig *config, const pmFPAview *view, const char *outFilename, const char *inFilename, int index);
    223224
     
    304305pmConfig *psphotForcedArguments(int argc, char **argv);
    305306bool psphotForcedImageLoop (pmConfig *config);
    306 bool psphotForcedReadout(pmConfig *config, const pmFPAview *view);
     307bool psphotForcedReadout(pmConfig *config, const pmFPAview *view, const char *filerule);
    307308
    308309pmConfig *psphotMakePSFArguments(int argc, char **argv);
    309310bool psphotMakePSFImageLoop (pmConfig *config);
    310 bool psphotMakePSFReadout(pmConfig *config, const pmFPAview *view);
     311bool psphotMakePSFReadout(pmConfig *config, const pmFPAview *view, const char *filerule);
     312
     313int psphotFileruleCount(const pmConfig *config, const char *filerule);
     314
     315bool psphotAddKnownSources (pmConfig *config, const pmFPAview *view, const char *filerule, psArray *inSources);
     316
    311317
    312318/**** psphotStack prototypes ****/
     
    432438pmModel *psphotFitPCM (pmReadout *readout, pmSource *source, pmSourceFitOptions *fitOptions, pmModelType modelType, psImageMaskType maskVal, psImageMaskType markVal, int psfSize);
    433439
     440bool psphotCleanInputs (pmConfig *config, const pmFPAview *view, const char *filerule);
     441
    434442#endif
  • trunk/psphot/src/psphotAddNoise.c

    r29004 r29936  
    1818    psAssert (recipe, "missing recipe?");
    1919
    20     int num = psMetadataLookupS32 (&status, config->arguments, "PSPHOT.INPUT.NUM");
    21     psAssert (status, "programming error: must define PSPHOT.INPUT.NUM");
     20    int num = psphotFileruleCount(config, filerule);
    2221
    2322    // loop over the available readouts
  • trunk/psphot/src/psphotApResid.c

    r29548 r29936  
    1313    psAssert (recipe, "missing recipe?");
    1414
    15     int num = psMetadataLookupS32 (&status, config->arguments, "PSPHOT.INPUT.NUM");
    16     psAssert (status, "programming error: must define PSPHOT.INPUT.NUM");
     15    int num = psphotFileruleCount(config, filerule);
    1716
    1817    // skip the chisq image (optionally?)
     
    7271    if (!measureAptrend) {
    7372        // save nan values since these were not calculated
    74         psMetadataAdd (readout->analysis, PS_LIST_TAIL, "APMIFIT",  PS_DATA_F32 | PS_META_REPLACE, "aperture residual",   NAN);
    75         psMetadataAdd (readout->analysis, PS_LIST_TAIL, "DAPMIFIT", PS_DATA_F32 | PS_META_REPLACE, "ap residual scatter", NAN);
    76         psMetadataAdd (readout->analysis, PS_LIST_TAIL, "NAPMIFIT", PS_DATA_S32 | PS_META_REPLACE, "number of apresid stars", 0);
    77         psMetadataAdd (readout->analysis, PS_LIST_TAIL, "APLOSS",   PS_DATA_F32 | PS_META_REPLACE, "aperture loss (mag)", NAN);
     73        psMetadataAddF32 (readout->analysis, PS_LIST_TAIL, "APMIFIT", PS_META_REPLACE, "aperture residual",   NAN);
     74        psMetadataAddF32 (readout->analysis, PS_LIST_TAIL, "DAPMIFIT", PS_META_REPLACE, "ap residual scatter", NAN);
     75        psMetadataAddS32 (readout->analysis, PS_LIST_TAIL, "NAPMIFIT", PS_META_REPLACE, "number of apresid stars", 0);
     76        psMetadataAddF32 (readout->analysis, PS_LIST_TAIL, "APLOSS",  PS_META_REPLACE, "aperture loss (mag)", NAN);
    7877        return true;
    7978    }
     
    325324
    326325    // save results for later output
    327     psMetadataAdd (readout->analysis, PS_LIST_TAIL, "APMIFIT",  PS_DATA_F32 | PS_META_REPLACE, "aperture residual",   psf->ApResid);
    328     psMetadataAdd (readout->analysis, PS_LIST_TAIL, "DAPMIFIT", PS_DATA_F32 | PS_META_REPLACE, "ap residual scatter", psf->dApResid);
    329     psMetadataAdd (readout->analysis, PS_LIST_TAIL, "NAPMIFIT", PS_DATA_S32 | PS_META_REPLACE, "number of apresid stars", psf->nApResid);
    330     psMetadataAdd (readout->analysis, PS_LIST_TAIL, "APLOSS",   PS_DATA_F32 | PS_META_REPLACE, "aperture loss (mag)", psf->growth ? psf->growth->apLoss : NAN);
     326    psMetadataAddF32 (readout->analysis, PS_LIST_TAIL, "APMIFIT", PS_META_REPLACE, "aperture residual",   psf->ApResid);
     327    psMetadataAddF32 (readout->analysis, PS_LIST_TAIL, "DAPMIFIT", PS_META_REPLACE, "ap residual scatter", psf->dApResid);
     328    psMetadataAddS32 (readout->analysis, PS_LIST_TAIL, "NAPMIFIT", PS_META_REPLACE, "number of apresid stars", psf->nApResid);
     329    psMetadataAddF32 (readout->analysis, PS_LIST_TAIL, "APLOSS",  PS_META_REPLACE, "aperture loss (mag)", psf->growth ? psf->growth->apLoss : NAN);
    331330
    332331    psLogMsg ("psphot.apresid", PS_LOG_DETAIL, "aperture residual: %f +/- %f\n", psf->ApResid, psf->dApResid);
     
    345344escape:
    346345    // save nan values since these were not calculated
    347     psMetadataAdd (readout->analysis, PS_LIST_TAIL, "APMIFIT",  PS_DATA_F32 | PS_META_REPLACE, "aperture residual",   NAN);
    348     psMetadataAdd (readout->analysis, PS_LIST_TAIL, "DAPMIFIT", PS_DATA_F32 | PS_META_REPLACE, "ap residual scatter", NAN);
    349     psMetadataAdd (readout->analysis, PS_LIST_TAIL, "NAPMIFIT", PS_DATA_S32 | PS_META_REPLACE, "number of apresid stars", 0);
    350     psMetadataAdd (readout->analysis, PS_LIST_TAIL, "APLOSS",   PS_DATA_F32 | PS_META_REPLACE, "aperture loss (mag)", NAN);
     346    psMetadataAddF32 (readout->analysis, PS_LIST_TAIL, "APMIFIT", PS_META_REPLACE, "aperture residual",   NAN);
     347    psMetadataAddF32 (readout->analysis, PS_LIST_TAIL, "DAPMIFIT", PS_META_REPLACE, "ap residual scatter", NAN);
     348    psMetadataAddS32 (readout->analysis, PS_LIST_TAIL, "NAPMIFIT", PS_META_REPLACE, "number of apresid stars", 0);
     349    psMetadataAddF32 (readout->analysis, PS_LIST_TAIL, "APLOSS",  PS_META_REPLACE, "aperture loss (mag)", NAN);
    351350
    352351    psFree (xPos);
  • trunk/psphot/src/psphotBasicDeblend.c

    r28013 r29936  
    44bool psphotBasicDeblend (pmConfig *config, const pmFPAview *view, const char *filerule)
    55{
    6     bool status = true;
    7 
    8     int num = psMetadataLookupS32 (&status, config->arguments, "PSPHOT.INPUT.NUM");
    9     psAssert (status, "programming error: must define PSPHOT.INPUT.NUM");
     6    int num = psphotFileruleCount(config, filerule);
    107
    118    // loop over the available readouts
  • trunk/psphot/src/psphotBlendFit.c

    r29017 r29936  
    1010    psAssert (recipe, "missing recipe?");
    1111
    12     int num = psMetadataLookupS32 (&status, config->arguments, "PSPHOT.INPUT.NUM");
    13     psAssert (status, "programming error: must define PSPHOT.INPUT.NUM");
     12    int num = psphotFileruleCount(config, filerule);
    1413
    1514    // loop over the available readouts
  • trunk/psphot/src/psphotChoosePSF.c

    r29004 r29936  
    1010    psAssert (recipe, "missing recipe?");
    1111
    12     int num = psMetadataLookupS32 (&status, config->arguments, "PSPHOT.INPUT.NUM");
    13     psAssert (status, "programming error: must define PSPHOT.INPUT.NUM");
     12    int num = psphotFileruleCount(config, filerule);
    1413
    1514    // skip the chisq image (optionally?)
  • trunk/psphot/src/psphotDeblendSatstars.c

    r29606 r29936  
    44bool psphotDeblendSatstars (pmConfig *config, const pmFPAview *view, const char *filerule)
    55{
    6     bool status = true;
    7 
    8     int num = psMetadataLookupS32 (&status, config->arguments, "PSPHOT.INPUT.NUM");
    9     psAssert (status, "programming error: must define PSPHOT.INPUT.NUM");
     6    int num = psphotFileruleCount(config, filerule);
    107
    118    // loop over the available readouts
  • trunk/psphot/src/psphotEfficiency.c

    r29902 r29936  
    164164    psAssert (recipe, "missing recipe?");
    165165
    166     int num = psMetadataLookupS32 (&status, config->arguments, "PSPHOT.INPUT.NUM");
    167     psAssert (status, "programming error: must define PSPHOT.INPUT.NUM");
     166    int num = psphotFileruleCount(config, filerule);
    168167
    169168    // skip the chisq image (optionally?)
  • trunk/psphot/src/psphotExtendedSourceAnalysis.c

    r29027 r29936  
    2222    }
    2323
    24     int num = psMetadataLookupS32 (&status, config->arguments, "PSPHOT.INPUT.NUM");
    25     psAssert (status, "programming error: must define PSPHOT.INPUT.NUM");
     24    int num = psphotFileruleCount(config, filerule);
    2625
    2726    // loop over the available readouts
  • trunk/psphot/src/psphotExtendedSourceAnalysisByObject.c

    r29548 r29936  
    4141
    4242    // number of images used to define sources
    43     int nImages = psMetadataLookupS32 (&status, config->arguments, "PSPHOT.INPUT.NUM");
    44     psAssert (status, "programming error: must define PSPHOT.INPUT.NUM");
     43    int nImages = psphotFileruleCount(config, filerule);
    4544
    4645    // generate look-up arrays for readouts
  • trunk/psphot/src/psphotExtendedSourceFits.c

    r29548 r29936  
    1616    }
    1717
    18     int num = psMetadataLookupS32 (&status, config->arguments, "PSPHOT.INPUT.NUM");
    19     psAssert (status, "programming error: must define PSPHOT.INPUT.NUM");
     18    int num = psphotFileruleCount(config, filerule);
    2019
    2120    // loop over the available readouts
  • trunk/psphot/src/psphotFindDetections.c

    r29548 r29936  
    1212    psAssert (recipe, "missing recipe?");
    1313
    14     int num = psMetadataLookupS32 (&status, config->arguments, "PSPHOT.INPUT.NUM");
    15     psAssert (status, "programming error: must define PSPHOT.INPUT.NUM");
     14    int num = psphotFileruleCount(config, filerule);
    1615
    1716    // loop over the available readouts
  • trunk/psphot/src/psphotFitSourcesLinear.c

    r29548 r29936  
    2121    assert (recipe);
    2222
    23     int num = psMetadataLookupS32 (&status, config->arguments, "PSPHOT.INPUT.NUM");
    24     psAssert (status, "programming error: must define PSPHOT.INPUT.NUM");
     23    int num = psphotFileruleCount(config, filerule);
    2524
    2625    // loop over the available readouts
  • trunk/psphot/src/psphotForcedImageLoop.c

    r25981 r29936  
    8484
    8585                // run the actual photometry analysis on this chip/cell/readout
    86                 if (!psphotForcedReadout (config, view)) {
     86                if (!psphotForcedReadout (config, view, "PSPHOT.INPUT")) {
    8787                    psError(psErrorCodeLast(), false, "failure in psphotReadout for chip %d, cell %d, readout %d\n", view->chip, view->cell, view->readout);
    8888                    psFree (view);
  • trunk/psphot/src/psphotForcedReadout.c

    r28013 r29936  
    11# include "psphotInternal.h"
    22
    3 bool psphotForcedReadout(pmConfig *config, const pmFPAview *view) {
     3bool psphotForcedReadout(pmConfig *config, const pmFPAview *view, const char *filerule) {
    44
    55    // measure the total elapsed time in psphotReadout.  XXX the current threading plan
     
    2020
    2121    // set the photcode for this image
    22     if (!psphotAddPhotcode (config, view, "PSPHOT.INPUT")) {
     22    if (!psphotAddPhotcode (config, view, filerule)) {
    2323        psError (PSPHOT_ERR_CONFIG, false, "trouble defining the photcode");
    2424        return false;
     
    3030
    3131    // Generate the mask and weight images, including the user-defined analysis region of interest
    32     psphotSetMaskAndVariance (config, view, "PSPHOT.INPUT");
     32    psphotSetMaskAndVariance (config, view, filerule);
    3333    if (!strcasecmp (breakPt, "NOTHING")) {
    34         return psphotReadoutCleanup (config, view, "PSPHOT.INPUT");
     34        return psphotReadoutCleanup (config, view, filerule);
    3535    }
    3636
    3737    // generate a background model (median, smoothed image)
    38     if (!psphotModelBackground (config, view, "PSPHOT.INPUT")) {
    39         return psphotReadoutCleanup (config, view, "PSPHOT.INPUT");
     38    if (!psphotModelBackground (config, view, filerule)) {
     39        return psphotReadoutCleanup (config, view, filerule);
    4040    }
    41     if (!psphotSubtractBackground (config, view, "PSPHOT.INPUT")) {
    42         return psphotReadoutCleanup (config, view, "PSPHOT.INPUT");
     41    if (!psphotSubtractBackground (config, view, filerule)) {
     42        return psphotReadoutCleanup (config, view, filerule);
    4343    }
    4444    if (!strcasecmp (breakPt, "BACKMDL")) {
    45         return psphotReadoutCleanup (config, view, "PSPHOT.INPUT");
     45        return psphotReadoutCleanup (config, view, filerule);
    4646    }
    4747
    48     if (!psphotLoadPSF (config, view)) {
     48    if (!psphotLoadPSF (config, view, filerule)) {
    4949        // this only happens if we had a programming error in psphotLoadPSF
    5050        psError (PSPHOT_ERR_UNKNOWN, false, "error loading psf model");
    51         return psphotReadoutCleanup (config, view, "PSPHOT.INPUT");
     51        return psphotReadoutCleanup (config, view, filerule);
    5252    }
    5353
    5454    // include externally-supplied sources
    55     psphotLoadExtSources (config, view, "PSPHOT.INPUT");
     55    psphotLoadExtSources (config, view, filerule);
    5656
    5757    // construct an initial model for each object, set the radius to fitRadius, set circular fit mask
    58     psphotGuessModels (config, view, "PSPHOT.INPUT");
     58    psphotGuessModels (config, view, filerule);
    5959
    6060    // merge the newly selected sources into the existing list
    6161    // NOTE: merge OLD and NEW
    62     psphotMergeSources (config, view, "PSPHOT.INPUT");
     62    psphotMergeSources (config, view, filerule);
    6363
    6464    // linear PSF fit to source peaks, subtract the models from the image (in PSF mask)
    65     psphotFitSourcesLinear (config, view, "PSPHOT.INPUT", false);
     65    psphotFitSourcesLinear (config, view, filerule, false);
    6666
    6767    // identify CRs and extended sources
     
    7171
    7272    // calculate source magnitudes
    73     psphotMagnitudes(config, view, "PSPHOT.INPUT");
     73    psphotMagnitudes(config, view, filerule);
    7474
    7575    // XXX do I want to do this?
     
    8080
    8181    // replace background in residual image
    82     psphotSkyReplace (config, view, "PSPHOT.INPUT");
     82    psphotSkyReplace (config, view, filerule);
    8383
    8484    // drop the references to the image pixels held by each source
    85     psphotSourceFreePixels (config, view, "PSPHOT.INPUT");
     85    psphotSourceFreePixels (config, view, filerule);
    8686
    8787    // create the exported-metadata and free local data
    88     return psphotReadoutCleanup (config, view, "PSPHOT.INPUT");
     88    return psphotReadoutCleanup (config, view, filerule);
    8989}
  • trunk/psphot/src/psphotGuessModels.c

    r29605 r29936  
    1212    bool status = true;
    1313
    14     int num = psMetadataLookupS32 (&status, config->arguments, "PSPHOT.INPUT.NUM");
    15     psAssert (status, "programming error: must define PSPHOT.INPUT.NUM");
     14    int num = psphotFileruleCount(config, filerule);
    1615
    1716    // skip the chisq image (optionally?)
  • trunk/psphot/src/psphotImageLoop.c

    r29548 r29936  
    109109
    110110                // run the actual photometry analysis on this chip/cell/readout
    111                 if (!psphotReadout (config, view)) {
     111                if (!psphotReadout (config, view, "PSPHOT.INPUT")) {
    112112                    psError(psErrorCodeLast(), false, "failure in psphotReadout for chip %d, cell %d, readout %d\n", view->chip, view->cell, view->readout);
    113113                    psFree (view);
  • trunk/psphot/src/psphotImageQuality.c

    r28013 r29936  
    1313    psAssert (recipe, "missing recipe?");
    1414
    15     int num = psMetadataLookupS32 (&status, config->arguments, "PSPHOT.INPUT.NUM");
    16     psAssert (status, "programming error: must define PSPHOT.INPUT.NUM");
     15    int num = psphotFileruleCount(config, filerule);
    1716
    1817    // skip the chisq image (optionally?)
     
    9998        // r^2 sin(2t) = r^2 2 cos t sin t = 2 x y
    10099
    101         // r^2 cos(3t) = r^2 cos^3 t - r^2 3 cos t sin^2 t = (x^3 - 3 x y^2) / r
    102         // r^2 sin(3t) = r^2 3 cos^2 t sin t - sin^3 t = (3 x^2 y - y^3) / r
    103 
    104         // r^2 cos(4t) = r^2 cos^4 t - r^2 6 cos^2 t sin^2 t + r^2 sin^4 t = (x^4 - 6 x^2 y^2 + y^4) / r^2
    105         // r^2 sin(4t) = r^2 4 cos^3 t sin t - 4 sin^3 t cos t = (4 x^3 y - 4 y^3 x) / r^2
     100        // r^3 cos(3t) = r^3 cos^3 t - r^2 3 cos t sin^2 t = (x^3 - 3 x y^2)
     101        // r^3 sin(3t) = r^3 3 cos^2 t sin t - sin^3 t = (3 x^2 y - y^3)
     102
     103        // r^4 cos(4t) = r^4 cos^4 t - r^2 6 cos^2 t sin^2 t + r^2 sin^4 t = (x^4 - 6 x^2 y^2 + y^4)
     104        // r^4 sin(4t) = r^4 4 cos^3 t sin t - 4 sin^3 t cos t = (4 x^3 y - 4 y^3 x)
    106105
    107106        num++;
  • trunk/psphot/src/psphotLoadPSF.c

    r26894 r29936  
    66
    77// XXX for now (2010.01.27), the supporting programs do not define multiple PSPHOT.PSF.LOAD
    8 // files to go with multiple PSPHOT.INPUT files.  as a result, the implementation below is
     8// files to go with multiple input files.  as a result, the implementation below is
    99// currently going to work for the case of a single input file, but will fail if we try with a
    1010// stack of images.
     
    5959}
    6060
    61 bool psphotLoadPSF (pmConfig *config, const pmFPAview *view) {
     61// PSPHOT.PSF.LOAD vs input file -- see note at top
     62bool psphotLoadPSF (pmConfig *config, const pmFPAview *view, const char *filerule) {
    6263
    63     bool status = false;
    64 
    65     // XXX PSPHOT.PSF.LOAD vs PSPHOT.INPUT -- see note at top
    66     int num = psMetadataLookupS32 (&status, config->arguments, "PSPHOT.INPUT.NUM");
    67     psAssert (status, "programming error: must define PSPHOT.INPUT.NUM");
     64    int num = psphotFileruleCount(config, filerule);
    6865
    6966    // loop over the available readouts
     
    7168
    7269        // Generate the mask and weight images, including the user-defined analysis region of interest
    73         if (!psphotLoadPSFReadout (config, view, "PSPHOT.INPUT", "PSPHOT.PSF.LOAD", i)) {
     70        if (!psphotLoadPSFReadout (config, view, filerule, "PSPHOT.PSF.LOAD", i)) {
    7471            psError (PSPHOT_ERR_CONFIG, false, "failed to load PSF model for PSPHOT.PSF.LOAD entry %d", i);
    7572            return false;
  • trunk/psphot/src/psphotMagnitudes.c

    r29004 r29936  
    99    psAssert (recipe, "missing recipe?");
    1010
    11     int num = psMetadataLookupS32 (&status, config->arguments, "PSPHOT.INPUT.NUM");
    12     psAssert (status, "programming error: must define PSPHOT.INPUT.NUM");
     11    int num = psphotFileruleCount(config, filerule);
    1312
    1413    // skip the chisq image (optionally?)
  • trunk/psphot/src/psphotMakePSFImageLoop.c

    r25982 r29936  
    8484
    8585                // run the actual photometry analysis on this chip/cell/readout
    86                 if (!psphotMakePSFReadout (config, view)) {
     86                if (!psphotMakePSFReadout (config, view, "PSPHOT.INPUT")) {
    8787                    psError(psErrorCodeLast(), false, "failure in psphotReadout for chip %d, cell %d, readout %d\n", view->chip, view->cell, view->readout);
    8888                    psFree (view);
  • trunk/psphot/src/psphotMakePSFReadout.c

    r28013 r29936  
    11# include "psphotInternal.h"
    22
    3 bool psphotMakePSFReadout(pmConfig *config, const pmFPAview *view) {
     3bool psphotMakePSFReadout(pmConfig *config, const pmFPAview *view, const char *filerule) {
    44
    55    // measure the total elapsed time in psphotReadout.  XXX the current threading plan
     
    1919
    2020    // set the photcode for this image
    21     if (!psphotAddPhotcode (config, view, "PSPHOT.INPUT")) {
     21    if (!psphotAddPhotcode (config, view, filerule)) {
    2222        psError (PSPHOT_ERR_CONFIG, false, "trouble defining the photcode");
    2323        return false;
     
    2929
    3030    // Generate the mask and weight images, including the user-defined analysis region of interest
    31     psphotSetMaskAndVariance (config, view, "PSPHOT.INPUT");
     31    psphotSetMaskAndVariance (config, view, filerule);
    3232    if (!strcasecmp (breakPt, "NOTHING")) {
    33         return psphotReadoutCleanup (config, view, "PSPHOT.INPUT");
     33        return psphotReadoutCleanup (config, view, filerule);
    3434    }
    3535
    3636    // generate a background model (median, smoothed image)
    37     if (!psphotModelBackground (config, view, "PSPHOT.INPUT")) {
    38         return psphotReadoutCleanup (config, view, "PSPHOT.INPUT");
     37    if (!psphotModelBackground (config, view, filerule)) {
     38        return psphotReadoutCleanup (config, view, filerule);
    3939    }
    40     if (!psphotSubtractBackground (config, view, "PSPHOT.INPUT")) {
    41         return psphotReadoutCleanup (config, view, "PSPHOT.INPUT");
     40    if (!psphotSubtractBackground (config, view, filerule)) {
     41        return psphotReadoutCleanup (config, view, filerule);
    4242    }
    4343    if (!strcasecmp (breakPt, "BACKMDL")) {
    44         return psphotReadoutCleanup (config, view, "PSPHOT.INPUT");
     44        return psphotReadoutCleanup (config, view, filerule);
    4545    }
    4646
    47     psphotLoadExtSources (config, view, "PSPHOT.INPUT");
     47    psphotLoadExtSources (config, view, filerule);
    4848
    4949    // If sources have been supplied, then these should be used to measure the PSF include
     
    5353    // a text file have no valid SN values, but psphotChoosePSF needs to select the top
    5454    // PSF_MAX_NSTARS to generate the PSF.
    55     if (!psphotCheckExtSources (config, view, "PSPHOT.INPUT")) {
     55    if (!psphotCheckExtSources (config, view, filerule)) {
    5656        psLogMsg ("psphot", 3, "failure to select possible PSF sources (external or internal)");
    57         return psphotReadoutCleanup (config, view, "PSPHOT.INPUT");
     57        return psphotReadoutCleanup (config, view, filerule);
    5858    }
    5959
    6060    // Use bright stellar objects to measure PSF. If we do not have enough stars to generate
    6161    // the PSF, build one from the SEEING guess and model class
    62     if (!psphotChoosePSF (config, view, "PSPHOT.INPUT")) {
     62    if (!psphotChoosePSF (config, view, filerule)) {
    6363        psLogMsg ("psphot", 3, "failure to construct a psf model");
    64         return psphotReadoutCleanup (config, view, "PSPHOT.INPUT");
     64        return psphotReadoutCleanup (config, view, filerule);
    6565    }
    6666
    6767    // measure aperture photometry corrections
    6868# if 0
    69     if (!psphotApResid (config, view, "PSPHOT.INPUT")) {
     69    if (!psphotApResid (config, view, filerule)) {
    7070        psLogMsg ("psphot", 3, "failed on psphotApResid");
    71         return psphotReadoutCleanup (config, view, "PSPHOT.INPUT");
     71        return psphotReadoutCleanup (config, view, filerule);
    7272    }
    7373# endif
    7474
    75     return psphotReadoutCleanup (config, view, "PSPHOT.INPUT");
     75    return psphotReadoutCleanup (config, view, filerule);
    7676}
  • trunk/psphot/src/psphotMaskReadout.c

    r28013 r29936  
    99    psAssert (recipe, "missing recipe?");
    1010
    11     int num = psMetadataLookupS32 (&status, config->arguments, "PSPHOT.INPUT.NUM");
    12     psAssert (status, "programming error: must define PSPHOT.INPUT.NUM");
     11    int num = psphotFileruleCount(config, filerule);
    1312
    1413    // loop over the available readouts
     
    1716        // Generate the mask and weight images, including the user-defined analysis region of interest
    1817        if (!psphotSetMaskAndVarianceReadout (config, view, filerule, i, recipe)) {
    19             psError (PSPHOT_ERR_CONFIG, false, "failed to generate mask for PSPHOT.INPUT entry %d", i);
     18            psError (PSPHOT_ERR_CONFIG, false, "failed to generate mask for %s entry %d", filerule, i);
    2019            return false;
    2120        }
  • trunk/psphot/src/psphotMergeSources.c

    r28013 r29936  
    88bool psphotMergeSources (pmConfig *config, const pmFPAview *view, const char *filerule)
    99{
    10     bool status = true;
    11 
    12     int num = psMetadataLookupS32 (&status, config->arguments, "PSPHOT.INPUT.NUM");
    13     psAssert (status, "programming error: must define PSPHOT.INPUT.NUM");
     10    int num = psphotFileruleCount(config, filerule);
    1411
    1512    // loop over the available readouts
     
    7067// XXX This function needs to be updated to loop over set of input files.  At the moment, we
    7168// only expect a single entry for PSPHOT.INPUT.CMF and PSPHOT.SOURCES.TEXT, so we can only
    72 // associate input sources with a single entry for PSPHOT.INPUT
     69// associate input sources with a single entry for the filerule
    7370bool psphotLoadExtSources (pmConfig *config, const pmFPAview *view, const char *filerule) {
    7471
     
    166163}
    167164
     165// copy the known sources (as external) to the detection list of the given filerule
     166bool psphotAddKnownSources (pmConfig *config, const pmFPAview *view, const char *filerule, psArray *inSources) {
     167
     168    bool status = false;
     169
     170    // select the appropriate recipe information
     171    psMetadata *recipe  = psMetadataLookupPtr (&status, config->recipes, PSPHOT_RECIPE);
     172    psAssert (recipe, "missing recipe?");
     173
     174    // determine properties (sky, moments) of initial sources
     175    float OUTER = psMetadataLookupF32 (&status, recipe, "SKY_OUTER_RADIUS");
     176    psAssert (status, "missing SKY_OUTER_RADIUS in recipe?");
     177
     178    // XXX this seems like an arbitrary number...
     179    OUTER = PS_MAX(OUTER, 20.0); // XXX Guarantee that we can encompass the max moments radius
     180
     181    // find the currently selected readout
     182    pmFPAfile *file = pmFPAfileSelectSingle(config->files, filerule, 0); // File of interest
     183    psAssert (file, "missing file?");
     184
     185    pmReadout *readout = pmFPAviewThisReadout(view, file->fpa);
     186    psAssert (readout, "missing readout?");
     187
     188    pmDetections *detections = psMetadataLookupPtr (&status, readout->analysis, "PSPHOT.DETECTIONS");
     189    if (!detections) {
     190        detections = pmDetectionsAlloc();
     191        detections->newSources = psArrayAllocEmpty (100);
     192        // save detections on the readout->analysis
     193        if (!psMetadataAddPtr (readout->analysis, PS_LIST_TAIL, "PSPHOT.DETECTIONS", PS_META_REPLACE | PS_DATA_UNKNOWN, "psphot detections", detections)) {
     194            psError (PSPHOT_ERR_CONFIG, false, "problem saving detections on readout");
     195            return false;
     196        }
     197    } else {
     198        psMemIncrRefCounter(detections); // so we can free the detections below
     199    }
     200
     201    // copy the sources from inSources to the new detection structure
     202    for (int i = 0; i < inSources->n; i++) {
     203      pmSource *inSource = inSources->data[i];
     204
     205      pmSource *newSource = pmSourceCopy(inSource);
     206      newSource->mode |= PM_SOURCE_MODE_EXTERNAL;
     207     
     208      // drop the loaded source modelPSF
     209      psFree (newSource->modelPSF);
     210      // source->modelPSF = NULL;  check this!
     211
     212      // drop the references to the original image pixels:
     213      pmSourceFreePixels (newSource);
     214
     215      // allocate image, weight, mask for the new image for each peak (square of radius OUTER)
     216      pmSourceDefinePixels (newSource, readout, newSource->peak->x, newSource->peak->y, OUTER);
     217
     218      newSource->imageID = 0;
     219      // XXX reset the source ID? raised questions about the meaning of this ID...
     220      // P_PM_SOURCE_SET_ID(source, i);
     221
     222      psArrayAdd (detections->newSources, 100, newSource);
     223    }
     224    psLogMsg ("psphot", 3, "%ld known sources supplied", detections->newSources->n);
     225
     226    psFree (detections);
     227    return true;
     228}
     229
    168230// extract the input sources corresponding to this readout
    169231// XXX this function needs to be updated to work with the new context of psphot inputs
     
    405467    bool status = true;
    406468
    407     int num = psMetadataLookupS32 (&status, config->arguments, "PSPHOT.INPUT.NUM");
    408     psAssert (status, "programming error: must define PSPHOT.INPUT.NUM");
     469    int num = psphotFileruleCount(config, ruleSrc);
    409470
    410471    // skip the chisq image because it is a duplicate of the detection version
  • trunk/psphot/src/psphotModelBackground.c

    r28013 r29936  
    383383}
    384384
    385 // XXX supply filename or keep PSPHOT.INPUT fixed?
    386385bool psphotModelBackground (pmConfig *config, const pmFPAview *view, const char *filerule)
    387386{
    388     bool status = false;
    389 
    390     int num = psMetadataLookupS32 (&status, config->arguments, "PSPHOT.INPUT.NUM");
    391     psAssert (status, "programming error: must define PSPHOT.INPUT.NUM");
     387    int num = psphotFileruleCount(config, filerule);
    392388
    393389    // loop over the available readouts
    394390    for (int i = 0; i < num; i++) {
    395391        if (!psphotModelBackgroundReadoutFileIndex(config, view, filerule, i)) {
    396             psError (PSPHOT_ERR_CONFIG, false, "failed to model background for PSPHOT.INPUT entry %d", i);
     392            psError (PSPHOT_ERR_CONFIG, false, "failed to model background for %s entry %d", filerule, i);
    397393            return false;
    398394        }
  • trunk/psphot/src/psphotOutput.c

    r29902 r29936  
    11# include "psphotInternal.h"
     2
     3// convert filerule to filerule.NUM and look up in the config->arguments metadata
     4int psphotFileruleCount(const pmConfig *config, const char *filerule) {
     5
     6    bool status = false;
     7
     8    psString name = NULL;
     9    psStringAppend(&name, "%s.NUM", filerule);
     10    int num = psMetadataLookupS32 (&status, config->arguments, name);
     11    if (!status) {
     12      // we only explicitly define (filerule.NUM) if we have more than 1
     13      num = 1;
     14    }
     15    psFree (name);
     16    return num;
     17}
    218
    319pmReadout *psphotSelectBackground (pmConfig *config,
     
    6379    fclose (f);
    6480    return true;
    65 }
    66 
    67 // XXX replace this with a call to a pmConfig function (pmConfigDump...)
    68 bool psphotDumpConfig (pmConfig *config) {
    69 
    70   psMetadataConfigWrite (config->user, "user.md");
    71   psMetadataConfigWrite (config->camera, "camera.md");
    72   psMetadataConfigWrite (config->recipes, "recipes.md");
    73   psMetadataConfigWrite (config->arguments, "arguments.md");
    74   psMetadataConfigWrite (config->files, "files.md");
    75   return true;
    7681}
    7782
     
    126131}
    127132
     133bool psphotCleanInputsReadout (pmConfig *config, const pmFPAview *view, const char *filerule, int index);
     134bool psphotCleanInputs (pmConfig *config, const pmFPAview *view, const char *filerule) {
     135
     136    int num = psphotFileruleCount(config, filerule);
     137
     138    // loop over the available readouts
     139    for (int i = 0; i < num; i++) {
     140        if (!psphotCleanInputsReadout (config, view, filerule, i)) {
     141          psError (PSPHOT_ERR_CONFIG, false, "failed to clean inputs for %s entry %d", filerule, i);
     142            return false;
     143        }
     144    }
     145    return true;
     146}
     147
     148bool psphotCleanInputsReadout (pmConfig *config, const pmFPAview *view, const char *filerule, int index) {
     149
     150    pmFPAfile *file = pmFPAfileSelectSingle(config->files, filerule, index); // File of interest
     151    PS_ASSERT (file, false);
     152
     153    pmReadout  *readout = pmFPAviewThisReadout (view, file->fpa);
     154
     155    // XXX anything else to remove?
     156    if (psMetadataLookup(readout->analysis, "PSPHOT.DETECTIONS")) {
     157        psMetadataRemoveKey(readout->analysis, "PSPHOT.DETECTIONS");
     158    }
     159
     160    return true;
     161}
     162
    128163bool psphotAddPhotcode (pmConfig *config, const pmFPAview *view, const char *filerule) {
    129164
    130     bool status = false;
    131 
    132     int num = psMetadataLookupS32 (&status, config->arguments, "PSPHOT.INPUT.NUM");
    133     psAssert (status, "programming error: must define PSPHOT.INPUT.NUM");
     165    int num = psphotFileruleCount(config, filerule);
    134166
    135167    // loop over the available readouts
    136168    for (int i = 0; i < num; i++) {
    137169        if (!psphotAddPhotcodeReadout (config, view, filerule, i)) {
    138             psError (PSPHOT_ERR_CONFIG, false, "failed to add photcode to PSPHOT.INPUT entry %d", i);
     170          psError (PSPHOT_ERR_CONFIG, false, "failed to add photcode to %s entry %d", filerule, i);
    139171            return false;
    140172        }
     
    357389    // XXX need alternative output function
    358390    // psMetadata *psfData = pmPSFtoMetadata (NULL, try->psf);
    359     // psMetadataConfigWrite (psfData, "psfmodel.dat");
     391    // psMetadataConfigWrite (psfData, "psfmodel.dat", NULL);
    360392    psLogMsg ("psphot.choosePSF", PS_LOG_INFO, "wrote out psf-subtracted image, psf data, exiting\n");
    361393
  • trunk/psphot/src/psphotParseCamera.c

    r26894 r29936  
    3939        return NULL;
    4040    }
    41     // specify the number of psphot input images
    42     psMetadataAddS32 (config->arguments, PS_LIST_TAIL, "PSPHOT.INPUT.NUM", PS_META_REPLACE, "number of inputs", 1);
    4341
    4442    // define the additional input/output files associated with psphot
  • trunk/psphot/src/psphotRadialApertures.c

    r28013 r29936  
    1818    }
    1919
    20     int num = psMetadataLookupS32 (&status, config->arguments, "PSPHOT.INPUT.NUM");
    21     psAssert (status, "programming error: must define PSPHOT.INPUT.NUM");
     20    int num = psphotFileruleCount(config, filerule);
    2221
    2322    // loop over the available readouts
  • trunk/psphot/src/psphotRadialAperturesByObject.c

    r28013 r29936  
    2121
    2222    // number of images used to define sources
    23     int nImages = psMetadataLookupS32 (&status, config->arguments, "PSPHOT.INPUT.NUM");
    24     psAssert (status, "programming error: must define PSPHOT.INPUT.NUM");
     23    int nImages = psphotFileruleCount(config, filerule);
    2524
    2625    // radMax stores the upper bounds of the annuli
  • trunk/psphot/src/psphotRadiusChecks.c

    r29004 r29936  
    135135    EXT_FIT_MAX_RADIUS = psMetadataLookupF32 (&status, recipe, "EXT_FIT_MAX_RADIUS");
    136136
    137     float skyMean  = psMetadataLookupF32 (&status, readout->analysis, "SKY_MEAN");
    138137    float skyStdev = psMetadataLookupF32 (&status, readout->analysis, "SKY_STDEV");
    139 
    140     fprintf (stderr, "sky: %f +/- %f\n", skyMean, skyStdev);
    141138
    142139    EXT_FIT_SKY_SIG = skyStdev;
  • 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}
  • trunk/psphot/src/psphotReadoutCleanup.c

    r28013 r29936  
    1919    psAssert (recipe, "missing recipe?");
    2020
    21     int num = psMetadataLookupS32 (&status, config->arguments, "PSPHOT.INPUT.NUM");
    22     psAssert (status, "programming error: must define PSPHOT.INPUT.NUM");
     21    int num = psphotFileruleCount(config, filerule);
    2322
    2423    // loop over the available readouts
  • trunk/psphot/src/psphotReadoutFindPSF.c

    r28013 r29936  
    33// in this psphotReadout-variant, we are only trying to determine the PSF given an existing set
    44// of input source positions to use as initial PSF stars.
    5 bool psphotReadoutFindPSF(pmConfig *config, const pmFPAview *view, psArray *inSources) {
     5bool psphotReadoutFindPSF(pmConfig *config, const pmFPAview *view, const char *filerule, psArray *inSources) {
    66
    77    psTimerStart ("psphotReadout");
    88
    9     // set the photcode for the PSPHOT.INPUT
    10     if (!psphotAddPhotcode(config, view, "PSPHOT.INPUT")) {
     9    // set the photcode for the input
     10    if (!psphotAddPhotcode(config, view, filerule)) {
    1111        psError(PSPHOT_ERR_CONFIG, false, "trouble defining the photcode");
    1212        return false;
     
    1414
    1515    // Generate the mask and variance images, including the user-defined analysis region of interest
    16     psphotSetMaskAndVariance (config, view, "PSPHOT.INPUT");
     16    psphotSetMaskAndVariance (config, view, filerule);
    1717
    1818    // Note that in this implementation, we do NOT model the background and we do not
    1919    // attempt to detect the sources in the image
    2020
    21     // include externally-supplied sources (supplied as PSPHOT.INPUT.CMF)
    22     // XXX we assume a single set of input sources is supplied
    23     if (!psphotDetectionsFromSources (config, view, "PSPHOT.INPUT", inSources)) {
     21    // include the externally-supplied sources (inSources)
     22    // (we assume a single set of input sources is supplied)
     23    if (!psphotDetectionsFromSources (config, view, filerule, inSources)) {
    2424        psError(PSPHOT_ERR_ARGUMENTS, true, "Can't find PSF stars");
    25         return psphotReadoutCleanup (config, view, "PSPHOT.INPUT");
     25        return psphotReadoutCleanup (config, view, filerule);
    2626    }
    2727
    2828    // construct detections->newSources and measure basic stats (moments, local sky)
    29     if (!psphotSourceStats(config, view, "PSPHOT.INPUT", true)) {
     29    if (!psphotSourceStats(config, view, filerule, true)) {
    3030        psError(PSPHOT_ERR_UNKNOWN, false, "failure to generate sources");
    3131        return false;
     
    3333
    3434    // peak flux is wrong : use the peak measured in the moments analysis:
    35     if (!psphotRepairLoadedSources(config, view, "PSPHOT.INPUT")) {
     35    if (!psphotRepairLoadedSources(config, view, filerule)) {
    3636        psError(PSPHOT_ERR_UNKNOWN, false, "failure to repair sources");
    3737        return false;
     
    3939
    4040    // classify sources based on moments, brightness (psf is not known)
    41     if (!psphotRoughClass (config, view, "PSPHOT.INPUT")) {
     41    if (!psphotRoughClass (config, view, filerule)) {
    4242        psError (PSPHOT_ERR_UNKNOWN, false, "failed to determine rough source class");
    43         return psphotReadoutCleanup (config, view, "PSPHOT.INPUT");
     43        return psphotReadoutCleanup (config, view, filerule);
    4444    }
    4545
    46     if (!psphotImageQuality (config, view, "PSPHOT.INPUT")) {
     46    if (!psphotImageQuality (config, view, filerule)) {
    4747        psError (PSPHOT_ERR_UNKNOWN, false, "failed to measure image quality");
    48         return psphotReadoutCleanup (config, view, "PSPHOT.INPUT");
     48        return psphotReadoutCleanup (config, view, filerule);
    4949    }
    5050
    51     if (!psphotChoosePSF(config, view, "PSPHOT.INPUT")) {
     51    if (!psphotChoosePSF(config, view, filerule)) {
    5252        psError(PSPHOT_ERR_PSF, false, "Failed to construct a psf model");
    53         return psphotReadoutCleanup (config, view, "PSPHOT.INPUT");
     53        return psphotReadoutCleanup (config, view, filerule);
    5454    }
    5555
     
    5959    // fits from that analysis, or run the linear PSF fit for all objects currently in hand
    6060    // construct an initial model for each object, set the radius to fitRadius, set circular fit mask
    61     psphotGuessModels (config, view, "PSPHOT.INPUT");
     61    psphotGuessModels (config, view, filerule);
    6262# endif
    6363
    6464    // merge the newly selected sources into the existing list
    6565    // NOTE: merge OLD and NEW
    66     psphotMergeSources (config, view, "PSPHOT.INPUT");
     66    psphotMergeSources (config, view, filerule);
    6767
    6868# if 0
    6969    // measure aperture photometry corrections
    70     if (!psphotApResid (config, view, "PSPHOT.INPUT")) {
     70    if (!psphotApResid (config, view, filerule)) {
    7171        psLogMsg ("psphot", 3, "failed on psphotApResid");
    72         return psphotReadoutCleanup (config, view, "PSPHOT.INPUT");
     72        return psphotReadoutCleanup (config, view, filerule);
    7373    }
    7474# endif
    7575
    7676    // drop the references to the image pixels held by each source
    77     psphotSourceFreePixels(config, view, "PSPHOT.INPUT");
     77    psphotSourceFreePixels(config, view, filerule);
    7878
    7979    // create the exported-metadata and free local data
    80     return psphotReadoutCleanup (config, view, "PSPHOT.INPUT");
     80    return psphotReadoutCleanup (config, view, filerule);
    8181}
  • trunk/psphot/src/psphotReadoutKnownSources.c

    r28013 r29936  
    33// in this psphotReadout-variant, we are only measuring the photometry for known sources, using
    44// a PSF generated for this observation from those sources
    5 bool psphotReadoutKnownSources(pmConfig *config, const pmFPAview *view, psArray *inSources) {
     5bool psphotReadoutKnownSources(pmConfig *config, const pmFPAview *view, const char *filerule, psArray *inSources) {
    66
    77    psTimerStart ("psphotReadout");
    88
    99    // set the photcode for this image
    10     if (!psphotAddPhotcode(config, view, "PSPHOT.INPUT")) {
     10    if (!psphotAddPhotcode(config, view, filerule)) {
    1111        psError(PSPHOT_ERR_CONFIG, false, "trouble defining the photcode");
    1212        return false;
     
    1414
    1515    // Generate the mask and weight images, including the user-defined analysis region of interest
    16     psphotSetMaskAndVariance (config, view, "PSPHOT.INPUT");
     16    psphotSetMaskAndVariance (config, view, filerule);
    1717
    1818    // Note that in this implementation, we do NOT model the background and we do not
     
    2020
    2121    // include externally-supplied sources (supplied as PSPHOT.INPUT.CMF)
    22     if (!psphotDetectionsFromSources (config, view, "PSPHOT.INPUT", inSources)) {
     22    if (!psphotDetectionsFromSources (config, view, filerule, inSources)) {
    2323        psError(PSPHOT_ERR_ARGUMENTS, true, "Can't find PSF stars");
    24         return psphotReadoutCleanup (config, view, "PSPHOT.INPUT");
     24        return psphotReadoutCleanup (config, view, filerule);
    2525    }
    2626
    2727    // construct sources and measure basic stats
    28     if (!psphotSourceStats (config, view, "PSPHOT.INPUT", true)) {
     28    if (!psphotSourceStats (config, view, filerule, true)) {
    2929        psError(PSPHOT_ERR_UNKNOWN, false, "failure to generate sources");
    3030        return false;
     
    3232
    3333    // peak flux is wrong : use the peak measured in the moments analysis:
    34     if (!psphotRepairLoadedSources(config, view, "PSPHOT.INPUT")) {
     34    if (!psphotRepairLoadedSources(config, view, filerule)) {
    3535        psError(PSPHOT_ERR_UNKNOWN, false, "failure to repair sources");
    3636        return false;
     
    3838
    3939    // classify sources based on moments, brightness (psf is not known)
    40     if (!psphotRoughClass (config, view, "PSPHOT.INPUT")) {
     40    if (!psphotRoughClass (config, view, filerule)) {
    4141        psError (PSPHOT_ERR_UNKNOWN, false, "failed to determine rough source class");
    42         return psphotReadoutCleanup (config, view, "PSPHOT.INPUT");
     42        return psphotReadoutCleanup (config, view, filerule);
    4343    }
    4444
    45     if (!psphotChoosePSF (config, view, "PSPHOT.INPUT")) {
     45    if (!psphotChoosePSF (config, view, filerule)) {
    4646        psError(PSPHOT_ERR_PSF, false, "Failed to construct a psf model");
    47         return psphotReadoutCleanup (config, view, "PSPHOT.INPUT");
     47        return psphotReadoutCleanup (config, view, filerule);
    4848    }
    4949
    5050    // construct an initial model for each object
    51     psphotGuessModels (config, view, "PSPHOT.INPUT");
     51    psphotGuessModels (config, view, filerule);
    5252
    5353    // merge the newly selected sources into the existing list
    5454    // NOTE: merge OLD and NEW
    55     psphotMergeSources (config, view, "PSPHOT.INPUT");
     55    psphotMergeSources (config, view, filerule);
    5656
    5757    // linear PSF fit to source peaks
    58     psphotFitSourcesLinear (config, view, "PSPHOT.INPUT", false);
     58    psphotFitSourcesLinear (config, view, filerule, false);
    5959
    6060    // measure aperture photometry corrections
    61     if (!psphotApResid (config, view, "PSPHOT.INPUT")) {
     61    if (!psphotApResid (config, view, filerule)) {
    6262        psLogMsg ("psphot", 3, "failed on psphotApResid");
    63         return psphotReadoutCleanup (config, view, "PSPHOT.INPUT");
     63        return psphotReadoutCleanup (config, view, filerule);
    6464    }
    6565
    6666    // calculate source magnitudes
    67     psphotMagnitudes(config, view, "PSPHOT.INPUT");
     67    psphotMagnitudes(config, view, filerule);
    6868
    6969    // drop the references to the image pixels held by each source
    70     psphotSourceFreePixels (config, view, "PSPHOT.INPUT");
     70    psphotSourceFreePixels (config, view, filerule);
    7171
    7272    // create the exported-metadata and free local data
    73     return psphotReadoutCleanup (config, view, "PSPHOT.INPUT");
     73    return psphotReadoutCleanup (config, view, filerule);
    7474}
  • trunk/psphot/src/psphotReadoutMinimal.c

    r28013 r29936  
    77// NOTE: ppSub needs to perform extended source analysis for comets and trails.
    88
    9 bool psphotReadoutMinimal(pmConfig *config, const pmFPAview *view) {
     9bool psphotReadoutMinimal(pmConfig *config, const pmFPAview *view, const char *filerule) {
    1010
    1111    // measure the total elapsed time in psphotReadout.  XXX the current threading plan
     
    1818
    1919    // set the photcode for this image
    20     if (!psphotAddPhotcode(config, view, "PSPHOT.INPUT")) {
     20    if (!psphotAddPhotcode(config, view, filerule)) {
    2121        psError(PSPHOT_ERR_CONFIG, false, "trouble defining the photcode");
    2222        return false;
     
    2424
    2525    // Generate the mask and weight images, including the user-defined analysis region of interest
    26     psphotSetMaskAndVariance (config, view, "PSPHOT.INPUT");
     26    psphotSetMaskAndVariance (config, view, filerule);
    2727
    2828    // load the psf model, if suppled.  FWHM_X,FWHM_Y,etc are saved on readout->analysis
    29     if (!psphotLoadPSF (config, view)) {
     29    if (!psphotLoadPSF (config, view, filerule)) {
    3030      psError (PSPHOT_ERR_CONFIG, false, "missing psf model");
    31       return psphotReadoutCleanup (config, view, "PSPHOT.INPUT");
     31      return psphotReadoutCleanup (config, view, filerule);
    3232    }
    3333
    3434    // find the detections (by peak and/or footprint) in the image. (final pass)
    35     if (!psphotFindDetections(config, view, "PSPHOT.INPUT", false)) {
     35    if (!psphotFindDetections(config, view, filerule, false)) {
    3636        psError (PSPHOT_ERR_UNKNOWN, false, "failure in peak analysis");
    37         return psphotReadoutCleanup (config, view, "PSPHOT.INPUT");
     37        return psphotReadoutCleanup (config, view, filerule);
    3838    }
    3939
    4040    // construct sources and measure basic stats (saved on detections->newSources)
    41     if (!psphotSourceStats (config, view, "PSPHOT.INPUT", false)) { // pass 1
     41    if (!psphotSourceStats (config, view, filerule, false)) { // pass 1
    4242        psError(PSPHOT_ERR_UNKNOWN, false, "failure to generate sources");
    43         return psphotReadoutCleanup (config, view, "PSPHOT.INPUT");
     43        return psphotReadoutCleanup (config, view, filerule);
    4444    }
    4545
    4646    // find blended neighbors of very saturated stars
    47     psphotDeblendSatstars (config, view, "PSPHOT.INPUT");
     47    psphotDeblendSatstars (config, view, filerule);
    4848
    4949    // mark blended peaks PS_SOURCE_BLEND
    50     if (!psphotBasicDeblend (config, view, "PSPHOT.INPUT")) {
     50    if (!psphotBasicDeblend (config, view, filerule)) {
    5151        psLogMsg ("psphot", 3, "failed on deblend analysis");
    52         return psphotReadoutCleanup (config, view, "PSPHOT.INPUT");
     52        return psphotReadoutCleanup (config, view, filerule);
    5353    }
    5454
    5555    // classify sources based on moments, brightness (use supplied psf shape parameters)
    56     if (!psphotRoughClass (config, view, "PSPHOT.INPUT")) {
     56    if (!psphotRoughClass (config, view, filerule)) {
    5757        psLogMsg ("psphot", 3, "failed to find a valid PSF clump for image");
    58         return psphotReadoutCleanup (config, view, "PSPHOT.INPUT");
     58        return psphotReadoutCleanup (config, view, filerule);
    5959    }
    6060
    6161    // construct an initial model for each object
    62     psphotGuessModels (config, view, "PSPHOT.INPUT");
     62    psphotGuessModels (config, view, filerule);
    6363
    6464    // merge the newly selected sources into the existing list
    65     psphotMergeSources (config, view, "PSPHOT.INPUT");
     65    psphotMergeSources (config, view, filerule);
    6666
    6767    // linear PSF fit to source peaks
    68     psphotFitSourcesLinear (config, view, "PSPHOT.INPUT", false);
     68    psphotFitSourcesLinear (config, view, filerule, false);
    6969
    7070// XXX eventually, add the extended source fits here
    7171# if (0)
    7272    // measure source size for the remaining sources
    73     psphotSourceSize (config, view, "PSPHOT.INPUT");
     73    psphotSourceSize (config, view, filerule);
    7474
    75     psphotExtendedSourceAnalysis (config, view, "PSPHOT.INPUT");
     75    psphotExtendedSourceAnalysis (config, view, filerule);
    7676
    77     psphotExtendedSourceFits (config, view, "PSPHOT.INPUT");
     77    psphotExtendedSourceFits (config, view, filerule);
    7878# endif
    7979
    8080    // calculate source magnitudes
    81     psphotMagnitudes(config, view, "PSPHOT.INPUT");
     81    psphotMagnitudes(config, view, filerule);
    8282
    8383    // XXX ensure this is measured if the analysis succeeds (even if quality is low)
    84     if (!psphotEfficiency(config, view, "PSPHOT.INPUT")) {
     84    if (!psphotEfficiency(config, view, filerule)) {
    8585        psErrorStackPrint(stderr, "Unable to determine detection efficiencies from fake sources");
    8686        psErrorClear();
     
    8888
    8989    // drop the references to the image pixels held by each source
    90     psphotSourceFreePixels (config, view, "PSPHOT.INPUT");
     90    psphotSourceFreePixels (config, view, filerule);
    9191
    9292    // create the exported-metadata and free local data
    93     return psphotReadoutCleanup (config, view, "PSPHOT.INPUT");
     93    return psphotReadoutCleanup (config, view, filerule);
    9494}
  • trunk/psphot/src/psphotReplaceUnfit.c

    r28013 r29936  
    3131    psAssert (recipe, "missing recipe?");
    3232
    33     int num = psMetadataLookupS32 (&status, config->arguments, "PSPHOT.INPUT.NUM");
    34     psAssert (status, "programming error: must define PSPHOT.INPUT.NUM");
     33    int num = psphotFileruleCount(config, filerule);
    3534
    3635    // loop over the available readouts
    3736    for (int i = 0; i < num; i++) {
    3837        if (!psphotReplaceAllSourcesReadout (config, view, filerule, i, recipe)) {
    39             psError (PSPHOT_ERR_CONFIG, false, "failed to replace all sources for PSPHOT.INPUT entry %d", i);
     38            psError (PSPHOT_ERR_CONFIG, false, "failed to replace all sources for %s entry %d", filerule, i);
    4039            return false;
    4140        }
  • trunk/psphot/src/psphotRoughClass.c

    r28425 r29936  
    1616    psAssert (recipe, "missing recipe?");
    1717
    18     int num = psMetadataLookupS32 (&status, config->arguments, "PSPHOT.INPUT.NUM");
    19     psAssert (status, "programming error: must define PSPHOT.INPUT.NUM");
     18    int num = psphotFileruleCount(config, filerule);
    2019
    2120    // skip the chisq image (optionally?)
  • trunk/psphot/src/psphotSkyReplace.c

    r28013 r29936  
    55    bool status = true;
    66
    7     int num = psMetadataLookupS32 (&status, config->arguments, "PSPHOT.INPUT.NUM");
    8     psAssert (status, "programming error: must define PSPHOT.INPUT.NUM");
     7    int num = psphotFileruleCount(config, filerule);
    98
    109    // skip the chisq image (optionally?)
  • trunk/psphot/src/psphotSourceFreePixels.c

    r28013 r29936  
    33bool psphotSourceFreePixels (pmConfig *config, const pmFPAview *view, const char *filerule)
    44{
    5     bool status = true;
    6 
    7     int num = psMetadataLookupS32 (&status, config->arguments, "PSPHOT.INPUT.NUM");
    8     psAssert (status, "programming error: must define PSPHOT.INPUT.NUM");
     5    int num = psphotFileruleCount(config, filerule);
    96
    107    // loop over the available readouts
  • trunk/psphot/src/psphotSourceMatch.c

    r29548 r29936  
    66psArray *psphotMatchSources (pmConfig *config, const pmFPAview *view, const char *filerule)
    77{
    8     bool status = true;
    9 
    108    psArray *objects = psArrayAllocEmpty(100);
    119
    12     int num = psMetadataLookupS32 (&status, config->arguments, "PSPHOT.INPUT.NUM");
    13     psAssert (status, "programming error: must define PSPHOT.INPUT.NUM");
     10    int num = psphotFileruleCount(config, filerule);
    1411
    1512    // loop over the available readouts
    1613    for (int i = 0; i < num; i++) {
    1714        if (!psphotMatchSourcesReadout (objects, config, view, filerule, i)) {
    18             psError (PSPHOT_ERR_CONFIG, false, "failed to merge sources for PSPHOT.INPUT entry %d", i);
     15            psError (PSPHOT_ERR_CONFIG, false, "failed to merge sources for %s entry %d", filerule, i);
    1916            psFree (objects);
    2017            return NULL;
     
    162159    psAssert (status, "missing SKY_OUTER_RADIUS in recipe?");
    163160
    164     int nImages = psMetadataLookupS32 (&status, config->arguments, "PSPHOT.INPUT.NUM");
    165     psAssert (status, "programming error: must define PSPHOT.INPUT.NUM");
     161    int nImages = psphotFileruleCount(config, filerule);
    166162
    167163    // generate look-up arrays for detections and readouts
  • trunk/psphot/src/psphotSourceSize.c

    r29610 r29936  
    4949    psAssert (recipe, "missing recipe?");
    5050
    51     int num = psMetadataLookupS32 (&status, config->arguments, "PSPHOT.INPUT.NUM");
    52     psAssert (status, "programming error: must define PSPHOT.INPUT.NUM");
     51    int num = psphotFileruleCount(config, filerule);
    5352
    5453    // skip the chisq image (optionally?)
     
    6059        if (i == chisqNum) continue; // skip chisq image
    6160        if (!psphotSourceSizeReadout (config, view, filerule, i, recipe, getPSFsize)) {
    62             psError (PSPHOT_ERR_CONFIG, false, "failed on source size analysis for PSPHOT.INPUT entry %d", i);
     61            psError (PSPHOT_ERR_CONFIG, false, "failed on source size analysis for %s entry %d", filerule, i);
    6362            return false;
    6463        }
  • trunk/psphot/src/psphotSourceStats.c

    r29604 r29936  
    1414    psAssert (recipe, "missing recipe?");
    1515
    16     int num = psMetadataLookupS32 (&status, config->arguments, "PSPHOT.INPUT.NUM");
    17     psAssert (status, "programming error: must define PSPHOT.INPUT.NUM");
     16    int num = psphotFileruleCount(config, filerule);
    1817
    1918    // skip the chisq image (optionally?)
  • trunk/psphot/src/psphotStackChisqImage.c

    r28013 r29936  
    88bool psphotStackChisqImage (pmConfig *config, const pmFPAview *view, const char *ruleDet, const char *ruleCnv)
    99{
    10     bool status = false;
    11 
    1210    psTimerStart ("psphot.chisq.image");
    1311
     
    1715    pmReadout *chiReadout = NULL;
    1816
    19     int num = psMetadataLookupS32 (&status, config->arguments, "PSPHOT.INPUT.NUM");
    20     psAssert (status, "programming error: must define PSPHOT.INPUT.NUM");
     17    int num = psphotFileruleCount(config, "PSPHOT.INPUT");
    2118
    2219    // loop over the available readouts
     
    2825        }
    2926    }
    30 
    31     num = psMetadataLookupS32 (&status, config->arguments, "PSPHOT.INPUT.NUM");
    32     psAssert (status, "programming error: must define PSPHOT.INPUT.NUM");
    3327
    3428    psMetadataAddS32(config->arguments, PS_LIST_TAIL, "PSPHOT.CHISQ.NUM", PS_META_REPLACE, "", num);
     
    125119    psAssert (status, "programming error: must define PSPHOT.CHISQ.NUM");
    126120
    127     int inputNum = psMetadataLookupS32 (&status, config->arguments, "PSPHOT.INPUT.NUM");
    128     psAssert (status, "programming error: must define PSPHOT.INPUT.NUM");
     121    int inputNum = psphotFileruleCount(config, "PSPHOT.INPUT");
    129122
    130123    pmFPAfileRemoveSingle (config->files, filerule, chisqNum);
  • trunk/psphot/src/psphotStackImageLoop.c

    r28013 r29936  
    105105bool GetAstrometryFPA (pmConfig *config, pmFPAview *view) {
    106106
    107     bool status = false;
    108 
    109107    bool foundAstrometry = false;
    110108    bool bilevelAstrometry = false;
    111109
    112     int num = psMetadataLookupS32 (&status, config->arguments, "PSPHOT.INPUT.NUM");
    113     psAssert (status, "programming error: must define PSPHOT.INPUT.NUM");
     110    int num = psphotFileruleCount(config, "PSPHOT.INPUT");
    114111
    115112    // loop over the available readouts
     
    158155bool GetAstrometryChip (pmConfig *config, pmFPAview *view, bool bilevelAstrometry) {
    159156
    160     bool status = false;
    161 
    162     int num = psMetadataLookupS32 (&status, config->arguments, "PSPHOT.INPUT.NUM");
    163     psAssert (status, "programming error: must define PSPHOT.INPUT.NUM");
     157    int num = psphotFileruleCount(config, "PSPHOT.INPUT");
    164158
    165159    // loop over the available readouts
     
    220214bool SetAstrometryFPA (pmConfig *config, pmFPAview *view, bool bilevelAstrometry) {
    221215
    222     bool status = false;
    223 
    224216    if (!bilevelAstrometry) return true;
    225217
    226     int num = psMetadataLookupS32 (&status, config->arguments, "PSPHOT.INPUT.NUM");
    227     psAssert (status, "programming error: must define PSPHOT.INPUT.NUM");
     218    int num = psphotFileruleCount(config, "PSPHOT.INPUT");
    228219
    229220    // loop over the available readouts
  • trunk/psphot/src/psphotStackMatchPSFs.c

    r29548 r29936  
    88    psAssert(recipe, "We've thrown an error on this before.");
    99
    10     int num = psMetadataLookupS32 (&status, config->arguments, "PSPHOT.INPUT.NUM");
    11     psAssert (status, "programming error: must define PSPHOT.INPUT.NUM");
     10    int num = psphotFileruleCount(config, "PSPHOT.INPUT");
    1211
    1312    // 'options' carries info needed to perform the stack matching
  • trunk/psphot/src/psphotStackReadout.c

    r29548 r29936  
    5252    // load the psf model, if suppled.  FWHM_X,FWHM_Y,etc are determined and saved on
    5353    // readout->analysis XXX this function currently only works with a single PSPHOT.INPUT
    54     if (!psphotLoadPSF (config, view)) {
     54    if (!psphotLoadPSF (config, view, STACK_RAW)) {
    5555        psError (PSPHOT_ERR_UNKNOWN, false, "error loading psf model");
    5656        return psphotReadoutCleanup (config, view, STACK_OUT);
  • trunk/psphot/src/psphotSubtractBackground.c

    r28013 r29936  
    132132    psAssert (recipe, "missing recipe?");
    133133
    134     int num = psMetadataLookupS32 (&status, config->arguments, "PSPHOT.INPUT.NUM");
    135     psAssert (status, "programming error: must define PSPHOT.INPUT.NUM");
     134    int num = psphotFileruleCount(config, filerule);
    136135
    137136    // loop over the available readouts
    138137    for (int i = 0; i < num; i++) {
    139138        if (!psphotSubtractBackgroundReadout (config, view, filerule, i, recipe)) {
    140             psError (PSPHOT_ERR_CONFIG, false, "failed to subtract background for PSPHOT.INPUT entry %d", i);
     139            psError (PSPHOT_ERR_CONFIG, false, "failed to subtract background for %s entry %d", filerule, i);
    141140            return false;
    142141        }
  • trunk/psphot/src/psphotTest.c

    r28405 r29936  
    137137    psMetadataItem *mdi;
    138138
    139     psMetadataConfigWrite (header, argv[2]);
     139    psMetadataConfigWrite (header, argv[2], NULL);
    140140
    141141    // attempt to write image with NAXIS = 0
Note: See TracChangeset for help on using the changeset viewer.