IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 6862


Ignore:
Timestamp:
Apr 14, 2006, 11:58:44 AM (20 years ago)
Author:
eugene
Message:

renamed config to recipe in lower-level functions, added pixel weights to pmSource, other cleanups

Location:
trunk/psphot/src
Files:
3 deleted
20 edited

Legend:

Unmodified
Added
Removed
  • trunk/psphot/src/psphot.c

    r6851 r6862  
    11# include "psphot.h"
    22
    3 // XXX need a better structure for handling optional sequences
    43int main (int argc, char **argv) {
    54
  • trunk/psphot/src/psphot.h

    r6851 r6862  
    2323// psphotReadout functions
    2424bool            psphotImageMedian (pmConfig *config, pmFPAview *view);
    25 psArray        *psphotFindPeaks (pmReadout *readout, psMetadata *config);
    26 psArray        *psphotSourceStats (pmReadout *readout, psMetadata *config, psArray *allpeaks);
    27 bool            psphotRoughClass (psArray *sources, psMetadata *config);
    28 bool            psphotBasicDeblend (psArray *sources, psMetadata *config);
    29 pmPSF          *psphotChoosePSF (psArray *sources, psMetadata *config);
    30 bool            psphotEnsemblePSF (pmReadout *readout, psArray *sources, psMetadata *config, pmPSF *psf, bool final);
    31 bool            psphotBlendFit (pmReadout *readout, psArray *sources, psMetadata *config, pmPSF *psf);
     25psArray        *psphotFindPeaks (pmReadout *readout, psMetadata *recipe);
     26psArray        *psphotSourceStats (pmReadout *readout, psMetadata *recipe, psArray *allpeaks);
     27bool            psphotRoughClass (psArray *sources, psMetadata *recipe);
     28bool            psphotBasicDeblend (psArray *sources, psMetadata *recipe);
     29pmPSF          *psphotChoosePSF (pmReadout *readout, psArray *sources, psMetadata *recipe);
     30bool            psphotPSFstats (pmReadout *readout, psMetadata *recipe, pmPSF *psf);
     31bool            psphotEnsemblePSF (pmReadout *readout, psArray *sources, psMetadata *recipe, pmPSF *psf, bool final);
     32bool            psphotBlendFit (pmReadout *readout, psArray *sources, psMetadata *recipe, pmPSF *psf);
    3233bool            psphotReplaceUnfit (psArray *sources);
    33 bool            psphotApResid (pmReadout *readout, psArray *sources, psMetadata *config, pmPSF *psf);
    34 bool            psphotMagnitudes (psArray *sources, psMetadata *config, pmPSF *psf);
     34bool            psphotApResid (pmReadout *readout, psArray *sources, psMetadata *recipe, pmPSF *psf);
     35bool            psphotMagnitudes (psArray *sources, psMetadata *recipe, pmPSF *psf);
    3536bool            psphotSkyReplace (pmConfig *config, pmFPAview *view);
    3637
     
    4243void            psphotTestArguments (int *argc, char **argv);
    4344bool            psphotMaskReadout (pmReadout *readout, psMetadata *recipe);
    44 bool            psphotBackgroundNames (psMetadata *arguments);
     45// bool            psphotBackgroundNames (psMetadata *arguments);
    4546
    4647// functions to set the correct source pixels
    47 bool            psphotInitRadiusPSF (psMetadata *config, pmModelType type);
     48bool            psphotInitRadiusPSF (psMetadata *recipe, pmModelType type);
    4849bool            psphotCheckRadiusPSF (pmReadout *readout, pmSource *source, pmModel *model);
    4950bool            psphotCheckRadiusPSFBlend (pmReadout *readout, pmSource *source, pmModel *model, float dR);
    50 bool            psphotInitRadiusEXT (psMetadata *config, pmModelType type);
     51bool            psphotInitRadiusEXT (psMetadata *recipe, pmModelType type);
    5152bool            psphotCheckRadiusEXT (pmReadout *readout, pmSource *source, pmModel *model);
    5253
    5354// output functions
    54 bool            psphotDumpMoments (psMetadata *config, psArray *sources);
    55 psMetadata     *psphotDefineHeader (psMetadata *config);
    56 bool            psphotWeightBias (pmReadout *readout, psArray *sources, psMetadata *config, pmPSF *psf);
     55bool            psphotDumpMoments (psMetadata *recipe, psArray *sources);
     56psMetadata     *psphotDefineHeader (psMetadata *recipe);
     57bool            psphotWeightBias (pmReadout *readout, psArray *sources, psMetadata *recipe, pmPSF *psf);
    5758
    5859// PSF / DBL / EXT evaluation functions
     
    6263
    6364//  functions to support the source fitting process
    64 bool            psphotInitLimitsPSF (psMetadata *config);
    65 bool            psphotInitLimitsEXT (psMetadata *config);
     65bool            psphotInitLimitsPSF (psMetadata *recipe);
     66bool            psphotInitLimitsEXT (psMetadata *recipe);
    6667bool            psphotFitBlend (pmReadout *readout, pmSource *source, pmPSF *psf);
    6768bool            psphotFitBlob (pmReadout *readout, pmSource *source, psArray *sources, pmPSF *psf);
     
    7374bool            psphotFitSet (pmSource *oneSrc, pmModel *oneModel, char *fitset, pmSourceFitMode mode);
    7475
    75 // XXX these can probably be dropped:
    76 
    77 # if (0)
    78 
    79 pmHDU          *pmHDUFromReadout (pmReadout *readout);
    80 bool            psRegionIsNaN (psRegion region);
    81 bool            pmReadoutSetWeights(pmReadout *readout);
    82 
    83 // bicubic interpolation
    84 psPolynomial2D *psImageBicubeFit (psImage *image, int x, int y);
    85 psPlane         psImageBicubeMin (psPolynomial2D *poly);
    86 
    87 bool            psImageJpegColormap (char *name);
    88 bool            psImageJpeg (psImage *image, char *filename, float zero, float scale);
    89 
    90 bool            pmSourceFitSet (pmSource *source, psArray *modelSet, const bool PSF);
    91 psF32           pmModelFitSet (psVector *deriv, const psVector *params, const psVector *x);
    92 bool            pmModelFitSetInit (pmModelType type);
    93 void            pmModelFitSetClear (void);
    94 
    95 // optional mode for clip fit?
    96 psPolynomial4D *psVectorChiClipFitPolynomial4D(
    97     psPolynomial4D *poly,
    98     psStats *stats,
    99     const psVector *mask,
    100     psMaskType maskValue,
    101     const psVector *f,
    102     const psVector *fErr,
    103     const psVector *x,
    104     const psVector *y,
    105     const psVector *z,
    106     const psVector *t);
    107 
    108 # endif
    109 
    110 # if (0)
    111 bool            psphotSamplePSFs (pmPSF *psf, psImage *image, char *output);
    112 int             psphotSaveImage (psMetadata *header, psImage *image, char *filename);
    113 
    114 bool            pmSourcesWriteSX   (psArray *sources, char *filename);
    115 bool            pmSourcesWriteOBJ  (psArray *sources, char *filename);
    116 bool            pmSourcesWriteCMP  (psArray *sources, char *filename, psMetadata *header);
    117 bool            pmSourcesWriteCMF  (psArray *sources, char *filename, psMetadata *header);
    118 bool            pmSourcesWriteText (psArray *sources, char *filename);
    119 bool            pmPeaksWriteText (psArray *sources, char *filename);
    120 
    121 bool            pmModelWritePSFs (psArray *sources, char *filename);
    122 bool            pmModelWriteEXTs (psArray *sources, char *filename);
    123 bool            pmModelWriteNULLs (psArray *sources, char *filename);
    124 bool            pmMomentsWriteText (psArray *sources, char *filename);
    125 # endif
    126 
    127 // XXX deprecate
    128 
    129 // char           *psphotNameSubstitute (char *input, char *replace, char *key);
    130 // char           *psphotSplitName (psMetadata *header);
    131 // pmModel        *pmSourceMagnitudes (pmSource *source, pmPSF *psf, float apRadius);
    132 // float           pmSourceCrossProduct (pmSource *Mi, pmSource *Mj);
    133 // float           pmSourceCrossWeight (pmSource *Mi, pmSource *Mj);
    134 // psArray        *pmSourceContour_EAM (psImage *image, int x, int y, float threshold);
    135 // psStats        *psphotImageStats (pmReadout *readout, psMetadata *config);
    136 // psPolynomial2D *psphotImageBackground (pmReadout *readout, psMetadata *config, psStats *sky);
    137 // void            psphotOutput (pmReadout *readout, psMetadata *arguments);
    138 
    139 // void            psphotOutputPrep (ppFile *file, ppConfig *config);
    140 // void            psphotOutputCleanup (void);
    141 
    142 // bool            ppImageLoadPixels (ppFile *input, psDB *db, int chipNum, int cellNum);
    143 
  • trunk/psphot/src/psphotApResid.c

    r6753 r6862  
    33
    44// measure the aperture residual statistics
    5 bool psphotApResid (pmReadout *readout, psArray *sources, psMetadata *config, pmPSF *psf) {
     5bool psphotApResid (pmReadout *readout, psArray *sources, psMetadata *recipe, pmPSF *psf) {
    66
    77    int Npsf;
     
    1313
    1414    // S/N limit to perform full non-linear fits
    15     float FIT_SN_LIM = psMetadataLookupF32 (&status, config, "FULL_FIT_SN_LIM");
     15    float FIT_SN_LIM = psMetadataLookupF32 (&status, recipe, "FULL_FIT_SN_LIM");
    1616
    1717    // measure the aperture loss as a function of radius for PSF
    18     float REF_RADIUS = psMetadataLookupF32 (&status, config, "PSF_REF_RADIUS");
     18    float REF_RADIUS = psMetadataLookupF32 (&status, recipe, "PSF_REF_RADIUS");
    1919    psf->growth = pmGrowthCurveAlloc (3.0, 50.0, REF_RADIUS);
    2020    psphotGrowthCurve (readout, psf);
     
    7676
    7777    // APTREND options : NONE SKYBIAS XY_LIN XY_QUAD SKY_XY_LIN FULL
    78     char *ApTrendOption = psMetadataLookupPtr (&status, config, "APTREND");
     78    char *ApTrendOption = psMetadataLookupPtr (&status, recipe, "APTREND");
    7979    if (!status) ApTrendOption = DEFAULT_OPTION;
    8080
     
    208208    psVector *fit   = psPolynomial4DEvalVector (psf->ApTrend, xPos, yPos, r2rflux, flux);
    209209    psVector *resid = (psVector *) psBinaryOp (NULL, (void *) apResid, "-", (void *) fit);
    210 
    211 # if (1)
    212     FILE *fout = fopen ("resid.dat", "w");
    213     for (int i = 0; i < resid->n; i++) {
    214         fprintf (fout, "%d %f %f %f %f  %f %f %f %f %d\n",
    215                  i,
    216                  (float) psVectorGet(xPos, i), (float) psVectorGet(yPos, i), (float) psVectorGet(r2rflux, i), (float) psVectorGet(flux, i),
    217                  (float) psVectorGet(apResid, i), (float) psVectorGet(fit, i), (float) psVectorGet(resid, i), (float) psVectorGet(dMag, i),
    218                  mask->data.U8[i]);
    219     }
    220     fclose (fout);
    221 # endif
    222210
    223211    // measure scatter for sources with dMag < 0.01 (S/N = 100)
     
    240228
    241229    // save results for later output
    242     psMetadataAdd (config, PS_LIST_TAIL, "SKYBIAS",  PS_DATA_F32 | PS_META_REPLACE, "aperture sky bias",   psf->skyBias);
    243     psMetadataAdd (config, PS_LIST_TAIL, "SKYSAT",   PS_DATA_F32 | PS_META_REPLACE, "aperture sky bias",   psf->skySat);
    244     psMetadataAdd (config, PS_LIST_TAIL, "APMIFIT",  PS_DATA_F32 | PS_META_REPLACE, "aperture residual",   psf->ApResid);
    245     psMetadataAdd (config, PS_LIST_TAIL, "DAPMIFIT", PS_DATA_F32 | PS_META_REPLACE, "ap residual scatter", psf->dApResid);
    246     psMetadataAdd (config, PS_LIST_TAIL, "APLOSS",   PS_DATA_F32 | PS_META_REPLACE, "ap residual scatter", psf->growth->apLoss);
    247     psMetadataAdd (config, PS_LIST_TAIL, "NAPMIFIT", PS_DATA_S32 | PS_META_REPLACE, "ap residual scatter", psf->nApResid);
     230    psMetadataAdd (recipe, PS_LIST_TAIL, "SKYBIAS",  PS_DATA_F32 | PS_META_REPLACE, "aperture sky bias",   psf->skyBias);
     231    psMetadataAdd (recipe, PS_LIST_TAIL, "SKYSAT",   PS_DATA_F32 | PS_META_REPLACE, "aperture sky bias",   psf->skySat);
     232    psMetadataAdd (recipe, PS_LIST_TAIL, "APMIFIT",  PS_DATA_F32 | PS_META_REPLACE, "aperture residual",   psf->ApResid);
     233    psMetadataAdd (recipe, PS_LIST_TAIL, "DAPMIFIT", PS_DATA_F32 | PS_META_REPLACE, "ap residual scatter", psf->dApResid);
     234    psMetadataAdd (recipe, PS_LIST_TAIL, "APLOSS",   PS_DATA_F32 | PS_META_REPLACE, "ap residual scatter", psf->growth->apLoss);
     235    psMetadataAdd (recipe, PS_LIST_TAIL, "NAPMIFIT", PS_DATA_S32 | PS_META_REPLACE, "ap residual scatter", psf->nApResid);
    248236
    249237    psLogMsg ("psphot.apresid", 3, "measure full-frame aperture residual: %f sec\n", psTimerMark ("psphot"));
  • trunk/psphot/src/psphotBasicDeblend.c

    r6715 r6862  
    22
    33// 2006.02.07 : no leaks
    4 bool psphotBasicDeblend (psArray *sources, psMetadata *config) {
     4bool psphotBasicDeblend (psArray *sources, psMetadata *recipe) {
    55
    66    int N;
     
    1313    psTimerStart ("psphot");
    1414
    15     float FRACTION = psMetadataLookupF32 (&status, config, "DEBLEND_PEAK_FRACTION");
     15    float FRACTION = psMetadataLookupF32 (&status, recipe, "DEBLEND_PEAK_FRACTION");
    1616    if (!status) FRACTION = 0.25;
    1717
    18     float NSIGMA   = psMetadataLookupF32 (&status, config, "DEBLEND_SKY_NSIGMA");
     18    float NSIGMA   = psMetadataLookupF32 (&status, recipe, "DEBLEND_SKY_NSIGMA");
    1919    if (!status) NSIGMA = 5.0;
    2020
     
    129129    psLogMsg ("psphot.deblend", 3, "identified %d blended objects (%f sec)\n", Nblend, psTimerMark ("psphot"));
    130130
    131     char *breakPt = psMetadataLookupStr (&status, config, "BREAK_POINT");
     131    char *breakPt = psMetadataLookupStr (&status, recipe, "BREAK_POINT");
    132132    if (!strcasecmp (breakPt, "DEBLEND")) exit (0);
    133133
  • trunk/psphot/src/psphotBlendFit.c

    r6851 r6862  
    22
    33// XXX I don't like this name
    4 bool psphotBlendFit (pmReadout *readout, psArray *sources, psMetadata *config, pmPSF *psf) {
     4bool psphotBlendFit (pmReadout *readout, psArray *sources, psMetadata *recipe, pmPSF *psf) {
    55
    66    int Nfit = 0;
     
    1313   
    1414    // S/N limit to perform full non-linear fits
    15     float FIT_SN_LIM = psMetadataLookupF32 (&status, config, "FULL_FIT_SN_LIM");
     15    float FIT_SN_LIM = psMetadataLookupF32 (&status, recipe, "FULL_FIT_SN_LIM");
    1616
    17     psphotInitLimitsPSF (config);
    18     psphotInitLimitsEXT (config);
    19     psphotInitRadiusPSF (config, psf->type);
     17    psphotInitLimitsPSF (recipe);
     18    psphotInitLimitsEXT (recipe);
     19    psphotInitRadiusPSF (recipe, psf->type);
    2020
    2121    // option to limit analysis to a specific region
    22     char *region = psMetadataLookupStr (&status, config, "ANALYSIS_REGION");
     22    char *region = psMetadataLookupStr (&status, recipe, "ANALYSIS_REGION");
    2323    psRegion AnalysisRegion = psRegionForImage (readout->image, psRegionFromString (region));
    2424    if (psRegionIsNaN (AnalysisRegion)) psAbort ("psphot", "analysis region mis-defined");
  • trunk/psphot/src/psphotChoosePSF.c

    r6851 r6862  
    11# include "psphot.h"
    22
    3 // 2006.02.07 : no leaks!
    43// try PSF models and select best option
    5 pmPSF *psphotChoosePSF (psArray *sources, psMetadata *config) {
     4pmPSF *psphotChoosePSF (pmReadout *readout, psArray *sources, psMetadata *recipe) {
    65
    76    bool            status;
    87    char           *modelName;
    9     pmPSFtry       *try   = NULL;
     8    pmPSF          *psf = NULL;
     9    pmPSFtry       *try = NULL;
    1010    psArray        *stars = NULL;
    1111
     
    1313
    1414    // check if a PSF model is supplied by the user
    15     char *psfFile = psMetadataLookupStr (&status, config, "PSF_INPUT_FILE");
    16     if (status) {
    17         int Nfail;
    18         psMetadata *psfData = psMetadataConfigParse (NULL, &Nfail, psfFile, FALSE);
    19         pmPSF *psf = pmPSFfromMD (psfData);
    20         return psf;
    21     }
     15    psf = psMetadataLookupPtr (&status, readout->analysis, "PSPHOT.PSF");
     16    if (psf != NULL) return psf;
    2217
    2318    // examine PSF sources in S/N order (brightest first)
     
    2520
    2621    // array to store candidate PSF stars
    27     int NSTARS = psMetadataLookupS32 (&status, config, "PSF_MAX_NSTARS");
     22    int NSTARS = psMetadataLookupS32 (&status, recipe, "PSF_MAX_NSTARS");
    2823    if (!status) NSTARS = PS_MIN (sources->n, 200);
    2924
    3025    // use poissonian errors or local-sky errors
    31     bool POISSON_ERRORS = psMetadataLookupBool (&status, config, "POISSON_ERRORS");
     26    bool POISSON_ERRORS = psMetadataLookupBool (&status, recipe, "POISSON_ERRORS");
    3227    if (!status) POISSON_ERRORS = true;
    3328    pmSourceFitModelInit (15, 0.1, POISSON_ERRORS);
     
    4540    // get the fixed PSF fit radius
    4641    // XXX EAM : check that PSF_FIT_RADIUS < SKY_OUTER_RADIUS
    47     float RADIUS = psMetadataLookupF32 (&status, config, "PSF_FIT_RADIUS");
     42    float RADIUS = psMetadataLookupF32 (&status, recipe, "PSF_FIT_RADIUS");
    4843
    4944    // get the list pointers for the PSF_MODEL entries
    5045    psList *list = NULL;
    51     psMetadataItem *mdi = psMetadataLookup (config, "PSF_MODEL");
     46    psMetadataItem *mdi = psMetadataLookup (recipe, "PSF_MODEL");
    5247    if (mdi == NULL) psAbort ("psphotChoosePSF", "missing PSF_MODEL selection");
    5348
     
    10095
    10196    // save only the best model;
    102     pmPSF *psf = psMemCopy(try->psf);
     97    psf = psMemCopy(try->psf);
    10398    psFree (models);
    10499
    105     psMetadataAdd (config, PS_LIST_TAIL, "NPSFSTAR", PS_DATA_S32 | PS_META_REPLACE, "number of stars used to make PSF", psf->nPSFstars);
     100    psMetadataAdd (recipe, PS_LIST_TAIL, "NPSFSTAR", PS_DATA_S32 | PS_META_REPLACE, "number of stars used to make PSF", psf->nPSFstars);
    106101
    107102    modelName = pmModelGetType (psf->type);
     
    109104    psLogMsg ("psphot.pspsf", 3, "selected psf model %s, ApResid: %f +/- %f\n", modelName, psf->ApResid, psf->dApResid);
    110105
    111     char *breakPt = psMetadataLookupStr (&status, config, "BREAK_POINT");
     106    char *breakPt = psMetadataLookupStr (&status, recipe, "BREAK_POINT");
    112107    if (!strcasecmp (breakPt, "PSFFIT")) exit (0);
    113108
    114109    return (psf);
    115110}
     111
     112bool psphotPSFstats (pmReadout *readout, psMetadata *recipe, pmPSF *psf) {
     113
     114    psEllipseShape shape;
     115    psEllipseAxes axes;
     116
     117    psImage *image = readout->image;
     118
     119    pmModel *modelEXT = pmModelAlloc (psf->type);
     120
     121    // make a model with unit central intensity at the image center
     122    modelEXT->params->data.F32[0] = 0;
     123    modelEXT->params->data.F32[1] = 1;
     124    modelEXT->params->data.F32[2] = 0.5*image->numCols;
     125    modelEXT->params->data.F32[3] = 0.5*image->numRows;
     126
     127    // construct a PSF model at this coordinate
     128    pmModel *modelPSF = pmModelFromPSF (modelEXT, psf);
     129
     130    // get the correct model-radius function
     131    pmModelRadius modelRadiusFunc = pmModelRadius_GetFunction (psf->type);
     132
     133    // get the model full-width at half-max
     134    psF64 FWHM_X = 2*modelRadiusFunc (modelPSF->params, 0.5);
     135   
     136    shape.sx  = modelPSF->params->data.F32[4];
     137    shape.sy  = modelPSF->params->data.F32[5];
     138    shape.sxy = modelPSF->params->data.F32[6];
     139    axes = psEllipseShapeToAxes (shape);
     140
     141    psF64 FWHM_Y = FWHM_X * (axes.minor / axes.major);
     142
     143    psMetadataAdd (recipe, PS_LIST_TAIL, "FWHM_X", PS_DATA_F32 | PS_META_REPLACE, "PSF FWHM Major axis", FWHM_X);
     144    psMetadataAdd (recipe, PS_LIST_TAIL, "FWHM_Y", PS_DATA_F32 | PS_META_REPLACE, "PSF FWHM Minor axis", FWHM_Y);
     145    psMetadataAdd (recipe, PS_LIST_TAIL, "ANGLE",  PS_DATA_F32 | PS_META_REPLACE, "PSF angle",           axes.theta);
     146   
     147    return true;
     148}
  • trunk/psphot/src/psphotEnsemblePSF.c

    r6753 r6862  
    44// 2006.02.07 : no leaks!
    55// fit all reasonable sources with the linear PSF model
    6 bool psphotEnsemblePSF (pmReadout *readout, psArray *sources, psMetadata *config, pmPSF *psf, bool final) {
     6bool psphotEnsemblePSF (pmReadout *readout, psArray *sources, psMetadata *recipe, pmPSF *psf, bool final) {
    77
    88    bool  status;
     
    2121    // radius for source moments if star is saturated
    2222    // XXX we already do this in psphotSourceStats, is it still needed?
    23     float INNER_RADIUS     = psMetadataLookupF32 (&status, config, "SKY_INNER_RADIUS");
     23    float INNER_RADIUS     = psMetadataLookupF32 (&status, recipe, "SKY_INNER_RADIUS");
    2424
    2525    // setup the PSF fit details
    26     psphotInitRadiusPSF (config, psf->type);
     26    psphotInitRadiusPSF (recipe, psf->type);
    2727
    2828    // pre-calculate all model pixels
     
    3333
    3434    // option to limit analysis to a specific region
    35     char *region = psMetadataLookupStr (&status, config, "ANALYSIS_REGION");
     35    char *region = psMetadataLookupStr (&status, recipe, "ANALYSIS_REGION");
    3636    psRegion AnalysisRegion = psRegionFromString (region);
    3737    AnalysisRegion = psRegionForImage (readout->image, AnalysisRegion);
  • trunk/psphot/src/psphotEvalPSF.c

    r6851 r6862  
    3131static float PSF_SHAPE_NSIGMA;
    3232
    33 bool psphotInitLimitsPSF (psMetadata *config) {
     33bool psphotInitLimitsPSF (psMetadata *recipe) {
    3434
    3535    bool status;
    3636
    3737    // we may set this differently here from the value used to mark likely saturated stars
    38     SATURATION       = psMetadataLookupF32 (&status, config, "SATURATION");
    39     PSF_MIN_SN       = psMetadataLookupF32 (&status, config, "PSF_MIN_SN");
    40     PSF_MAX_CHI      = psMetadataLookupF32 (&status, config, "PSF_MAX_CHI");
    41     PSF_SHAPE_NSIGMA = psMetadataLookupF32 (&status, config, "PSF_SHAPE_NSIGMA");
     38    SATURATION       = psMetadataLookupF32 (&status, recipe, "SATURATION");
     39    PSF_MIN_SN       = psMetadataLookupF32 (&status, recipe, "PSF_MIN_SN");
     40    PSF_MAX_CHI      = psMetadataLookupF32 (&status, recipe, "PSF_MAX_CHI");
     41    PSF_SHAPE_NSIGMA = psMetadataLookupF32 (&status, recipe, "PSF_SHAPE_NSIGMA");
    4242
    4343    return true;
  • trunk/psphot/src/psphotFindPeaks.c

    r6495 r6862  
    22
    33// 2006.02.02 : no leaks
    4 psArray *psphotFindPeaks (pmReadout *readout, psMetadata *config) {
     4psArray *psphotFindPeaks (pmReadout *readout, psMetadata *recipe) {
    55
    66    bool  status = false;
     
    1212    psTimerStart ("psphot");
    1313
    14     SIGMA  = psMetadataLookupF32 (&status, config, "PEAKS_SMOOTH_SIGMA");
    15     NSIGMA = psMetadataLookupF32 (&status, config, "PEAKS_SMOOTH_NSIGMA");
     14    SIGMA  = psMetadataLookupF32 (&status, recipe, "PEAKS_SMOOTH_SIGMA");
     15    NSIGMA = psMetadataLookupF32 (&status, recipe, "PEAKS_SMOOTH_NSIGMA");
    1616
    1717    psImage *smooth_im = psImageCopy (NULL, readout->image, PS_TYPE_F32);
     
    3737
    3838    // set peak threshold
    39     NSIGMA = psMetadataLookupF32 (&status, config, "PEAKS_NSIGMA_LIMIT");
     39    NSIGMA = psMetadataLookupF32 (&status, recipe, "PEAKS_NSIGMA_LIMIT");
    4040    // threshold = NSIGMA*sky->sampleStdev + sky->sampleMean;
    4141    threshold = PS_SQR(NSIGMA);
     
    4949
    5050    // optional dump of all peak data
    51     char *output = psMetadataLookupStr (&status, config, "PEAKS_OUTPUT_FILE");
     51    char *output = psMetadataLookupStr (&status, recipe, "PEAKS_OUTPUT_FILE");
    5252    if (status && (output != NULL) && (output[0])) {
    5353        pmPeaksWriteText (peaks, output);
     
    5555    psLogMsg ("psphot", 3, "%d peaks: %f sec\n", peaks->n, psTimerMark ("psphot"));
    5656
    57     char *breakPt = psMetadataLookupStr (&status, config, "BREAK_POINT");
     57    char *breakPt = psMetadataLookupStr (&status, recipe, "BREAK_POINT");
    5858    if (!strcasecmp (breakPt, "PEAKS")) exit (0);
    5959
  • trunk/psphot/src/psphotImageLoop.c

    r6727 r6862  
    22
    33// XXX where do we load optional mask and weight input images?
    4 
    54bool psphotImageLoop (pmConfig *config) {
    65
     
    2322    while ((chip = pmFPAviewNextChip (view, input->fpa, 1)) != NULL) {
    2423        psLogMsg ("psphot", 4, "Chip %d: %x %x\n", view->chip, chip->file_exists, chip->process);
    25         if (! chip->process) { continue; }
    26         if (! chip->file_exists) { continue; }
     24        if (! chip->process || ! chip->file_exists) { continue; }
    2725        pmFPAfileIOChecks (config->files, view, PM_FPA_BEFORE);
    2826
    2927        while ((cell = pmFPAviewNextCell (view, input->fpa, 1)) != NULL) {
    3028            psLogMsg ("psphot", 4, "Cell %d: %x %x\n", view->cell, cell->file_exists, cell->process);
    31             if (! cell->process) { continue; }
    32             if (! cell->file_exists) { continue; }
     29            if (! cell->process || ! cell->file_exists) { continue; }
    3330            pmFPAfileIOChecks (config->files, view, PM_FPA_BEFORE);
    3431
     
    6360// PSPHOT.PSF     : sample PSF images
    6461
    65 
    66 /**
    67 
    68 filename | pmFPAfile  | pmFPA  | pmFPAview
    69 chip00.f | PSPHOT.IN  | input  | view
    70 chip01.f | PSPHOT.IN  | input  | view
    71 chip02.f | PSPHOT.IN  | input  | view
    72 chip03.f | PSPHOT.IN  | input  | view
    73 
    74 out00.f  | PSPHOT.OUT | input  | view
    75 out01.f  | PSPHOT.OUT | input  | view
    76 out02.f  | PSPHOT.OUT | input  | view
    77 out03.f  | PSPHOT.OUT | input  | view
    78 
    79 obj00.f  | PSPHOT.OBJ | input  | view
    80 obj01.f  | PSPHOT.OBJ | input  | view
    81 obj02.f  | PSPHOT.OBJ | input  | view
    82 obj03.f  | PSPHOT.OBJ | input  | view
    83 
    84 bin00.f  | PSPHOT.BIN | binned | view
    85 bin01.f  | PSPHOT.BIN | binned | view
    86 bin02.f  | PSPHOT.BIN | binned | view
    87 bin03.f  | PSPHOT.BIN | binned | view
    88 
    89 mosaic.f | PSPHOT.MOS | mosaic | view
    90 
    91 **/
  • trunk/psphot/src/psphotImageMedian.c

    r6851 r6862  
    3333
    3434    // scaling factor
    35     int DX = psMetadataLookupS32 (&status, recipe, "BACKGROUND_XBIN");
    36     if (!status) {DX = 64;}
    37     int DY = psMetadataLookupS32 (&status, recipe, "BACKGROUND_YBIN");
    38     if (!status) {DY = 64;}
     35    int DX = psMetadataLookupS32 (&status, recipe, "BACKGROUND.XBIN");
     36    int DY = psMetadataLookupS32 (&status, recipe, "BACKGROUND.YBIN");
    3937
    4038    // overhang : we will balance this evenly
     
    6967
    7068            // XXX the value of the upper and lower cuts probably should be studied...
    71             modelData[iy][ix] = psImageClippedStats (subset, submask, 0xff, 0.25, 0.75) + SKY_BIAS;
     69            psStats *stats = psImageClippedStats (subset, submask, 0xff, 0.25, 0.75);
     70            modelData[iy][ix] = stats->robustMedian + SKY_BIAS;
    7271
     72            psFree (stats);
    7373            psFree (subset);
    7474            psFree (submask);
     
    8282    psLogMsg ("psphot", 3, "build median image: %f sec\n", psTimerMark ("psphot"));
    8383
    84     // XXX temporarily until we get the pmFPAfile output finished
    85     psphotSaveImage (NULL, model->image, "model.fits");
     84    // measure background stats and save for later output
     85    psStats *stats = psStatsAlloc (PS_STAT_SAMPLE_MEAN | PS_STAT_SAMPLE_STDEV | PS_STAT_MIN | PS_STAT_MAX);
     86    stats = psImageStats (stats, model->image, NULL, 0);
     87    psMetadataAdd (recipe, PS_LIST_TAIL, "SKY_MEAN", PS_DATA_F32 | PS_META_REPLACE, "sky model mean",          stats->sampleMean);
     88    psMetadataAdd (recipe, PS_LIST_TAIL, "SKY_STDV", PS_DATA_F32 | PS_META_REPLACE, "sky model stdev",         stats->sampleStdev);
     89    psMetadataAdd (recipe, PS_LIST_TAIL, "SKY_MAX",  PS_DATA_F32 | PS_META_REPLACE, "sky model maximum value", stats->max);
     90    psMetadataAdd (recipe, PS_LIST_TAIL, "SKY_MIN",  PS_DATA_F32 | PS_META_REPLACE, "sky model minimum value", stats->min);
     91    psMetadataAdd (recipe, PS_LIST_TAIL, "SKY_NX",   PS_DATA_S32 | PS_META_REPLACE, "sky model size (x)",      nx);
     92    psMetadataAdd (recipe, PS_LIST_TAIL, "SKY_NY",   PS_DATA_S32 | PS_META_REPLACE, "sky model size (y)",      ny);
     93    psFree (stats);
    8694
    8795    // select background pixels, from output background file, or create
     
    8997    if (background == NULL) {
    9098        background = pmFPAfileCreateInternal (config->files, "PSPHOT.BACKGND", Nx, Ny, PS_TYPE_F32);
    91     } else {
    92         // replace the supplied image data with an image of the desired size
    93         // XXX should not have to do this: it should be allocated correctly
    94         // psImageRecycle (background->image, Nx, Ny, PS_TYPE_F32);
    95     }
    96 
     99    }
    97100    psF32 **backData = background->image->data.F32;
    98101
     
    100103    psImageUnbin (background->image, model->image, DX, DY, dx, dy);
    101104    psLogMsg ("psphot", 3, "build resampled image: %f sec\n", psTimerMark ("psphot"));
    102 
    103     // XXX temporarily until we get the pmFPAfile output finished...
    104     psphotSaveImage (NULL, background->image, "back.fits");
    105105
    106106    // back-sub image pixels, from output background file (don't create if not requested)
  • trunk/psphot/src/psphotMagnitudes.c

    r6753 r6862  
    11# include "psphot.h"
    22
    3 bool psphotMagnitudes (psArray *sources, psMetadata *config, pmPSF *psf) {
     3bool psphotMagnitudes (psArray *sources, psMetadata *recipe, pmPSF *psf) {
    44
    55    psTimerStart ("psphot");
     
    1313    return true;
    1414}
     15
     16// XXX add in a measurement of the bright and faint completeness values
     17// XXX push these into the recipe
  • trunk/psphot/src/psphotOutput.c

    r6727 r6862  
    11# include "psphot.h"
     2
     3int psphotSaveImage (psMetadata *header, psImage *image, char *filename) {
     4
     5    psFits *fits = psFitsOpen (filename, "w");
     6    psFitsWriteImage (fits, NULL, image, 0, NULL);
     7    psFitsClose (fits);
     8    return (TRUE);
     9}
     10
     11bool psphotDumpMoments (psMetadata *recipe, psArray *sources) {
     12
     13    bool status;
     14
     15    // optional dump of all rough source data
     16    char *output = psMetadataLookupStr (&status, recipe, "MOMENTS_OUTPUT_FILE");
     17    if (!status) return false;
     18    if (output == NULL) return false;
     19    if (output[0] == 0) return false;
     20
     21    pmMomentsWriteText (sources, output);
     22    return true;
     23}
     24
     25// these values are saved in an output header stub - they are added to either the
     26// PHU header (CMP) or the MEF table header (CMF)
     27psMetadata *psphotDefineHeader (psMetadata *recipe) {
     28
     29    psMetadata *header = psMetadataAlloc ();
     30
     31    // write necessary information to output header
     32    psMetadataItemTransfer (header, recipe, "ZERO_PT");
     33    psMetadataItemTransfer (header, recipe, "PHOTCODE");
     34
     35    psMetadataItemTransfer (header, recipe, "APMIFIT");
     36    psMetadataItemTransfer (header, recipe, "DAPMIFIT");
     37    psMetadataItemTransfer (header, recipe, "NAPMIFIT");
     38    psMetadataItemTransfer (header, recipe, "SKYBIAS");
     39    psMetadataItemTransfer (header, recipe, "SKYSAT");
     40   
     41    // PSF model parameters (shape values for image center)
     42    psMetadataItemTransfer (header, recipe, "NPSFSTAR");
     43    psMetadataItemTransfer (header, recipe, "APLOSS");
     44    psMetadataItemTransfer (header, recipe, "FWHM_X");
     45    psMetadataItemTransfer (header, recipe, "FWHM_Y");
     46    psMetadataItemTransfer (header, recipe, "ANGLE");
     47
     48    // XXX these need to be defined from elsewhere
     49    psMetadataAdd (header, PS_LIST_TAIL, "FSATUR",   PS_DATA_F32 | PS_META_REPLACE, "SATURATION MAG",      0.0);
     50    psMetadataAdd (header, PS_LIST_TAIL, "FLIMIT",   PS_DATA_F32 | PS_META_REPLACE, "COMPLETENESS MAG",    0.0);
     51
     52    // sky background model statistics
     53    psMetadataItemTransfer (header, recipe, "SKY_MEAN");
     54    psMetadataItemTransfer (header, recipe, "SKY_STDV");
     55    psMetadataItemTransfer (header, recipe, "SKY_MIN");
     56    psMetadataItemTransfer (header, recipe, "SKY_MAX");
     57    psMetadataItemTransfer (header, recipe, "SKY_NX");
     58    psMetadataItemTransfer (header, recipe, "SKY_NY");
     59
     60    return header;
     61}
    262
    363# if (0)
     
    66126}
    67127# endif
    68 
    69 int psphotSaveImage (psMetadata *header, psImage *image, char *filename) {
    70 
    71     psFits *fits = psFitsOpen (filename, "w");
    72     psFitsWriteImage (fits, NULL, image, 0, NULL);
    73     psFitsClose (fits);
    74     return (TRUE);
    75 }
    76 
    77 bool psphotDumpMoments (psMetadata *config, psArray *sources) {
    78 
    79     bool status;
    80 
    81     // optional dump of all rough source data
    82     char *output = psMetadataLookupStr (&status, config, "MOMENTS_OUTPUT_FILE");
    83     if (!status) return false;
    84     if (output == NULL) return false;
    85     if (output[0] == 0) return false;
    86 
    87     pmMomentsWriteText (sources, output);
    88     return true;
    89 }
    90 
    91 // these values are saved in an output header stub - they are added to either the
    92 // PHU header (CMP) or the MEF table header (CMF)
    93 psMetadata *psphotDefineHeader (psMetadata *recipe) {
    94 
    95     psMetadata *header = psMetadataAlloc ();
    96 
    97     // write necessary information to output header
    98     psMetadataItemTransfer (header, recipe, "ZERO_PT");
    99     psMetadataItemTransfer (header, recipe, "PHOTCODE");
    100 
    101     psMetadataItemTransfer (header, recipe, "APMIFIT");
    102     psMetadataItemTransfer (header, recipe, "DAPMIFIT");
    103     psMetadataItemTransfer (header, recipe, "NAPMIFIT");
    104     psMetadataItemTransfer (header, recipe, "SKYBIAS");
    105     psMetadataItemTransfer (header, recipe, "SKYSAT");
    106    
    107     psMetadataItemTransfer (header, recipe, "NPSFSTAR");
    108     psMetadataItemTransfer (header, recipe, "APLOSS");
    109 
    110     // XXX these need to be defined from elsewhere
    111     psMetadataAdd (header, PS_LIST_TAIL, "FWHM_X",   PS_DATA_F32 | PS_META_REPLACE, "PSF FWHM X",          0.0);
    112     psMetadataAdd (header, PS_LIST_TAIL, "FWHM_Y",   PS_DATA_F32 | PS_META_REPLACE, "PSF FWHM Y",          0.0);
    113     psMetadataAdd (header, PS_LIST_TAIL, "ANGLE",    PS_DATA_F32 | PS_META_REPLACE, "PSF ANGLE",           0.0);
    114     psMetadataAdd (header, PS_LIST_TAIL, "FSATUR",   PS_DATA_F32 | PS_META_REPLACE, "SATURATION MAG",      0.0);
    115     psMetadataAdd (header, PS_LIST_TAIL, "FLIMIT",   PS_DATA_F32 | PS_META_REPLACE, "COMPLETENESS MAG",    0.0);
    116 
    117     return header;
    118 }
  • trunk/psphot/src/psphotParseCamera.c

    r6851 r6862  
    11# include "psphot.h"
    22
     3// define the needed / desired I/O files
    34bool psphotParseCamera (pmConfig *config) {
    45
    5     bool status;
     6    bool status = false;
    67
    7     status = false;
    88    pmFPAfile *input = pmFPAfileFromArgs (&status, config, "PSPHOT.INPUT", "INPUT");
    9     if (!status) {
    10         psAbort (__func__, "missing INPUT entry");
    11     }
     9    if (!status) { psAbort (__func__, "missing INPUT entry"); }
    1210
    13     // recipe override values (command-line options):
     11    // select recipe options supplied on command line
     12    psMetadata *recipe  = psMetadataLookupPtr (&status, config->recipes,   "PSPHOT");
    1413    psMetadata *options = psMetadataLookupPtr (&status, config->arguments, "PSPHOT.OPTIONS");
    15     psMetadata *recipe = psMetadataLookupPtr (&status, config->recipes, "PSPHOT");
    16     psMetadataIterator *iter = psMetadataIteratorAlloc (options, PS_LIST_HEAD, NULL);
    17     psMetadataItem *item = NULL;
    18     while ((item = psMetadataGetAndIncrement (iter)) != NULL) {
    19         psMetadataAddItem (recipe, item, PS_LIST_TAIL, PS_META_REPLACE);
    20     }
    21     psFree (iter);
     14    psMetadataCopy (recipe, options);
     15
     16    // set default recipe values here
     17    psMetadataAddStr (recipe, PS_LIST_TAIL, "FITMODE",         PS_META_NO_REPLACE, "default fitting mode", "NONE");
     18    psMetadataAddStr (recipe, PS_LIST_TAIL, "PHOTCODE",        PS_META_NO_REPLACE, "default photcode",     "NONE");
     19    psMetadataAddStr (recipe, PS_LIST_TAIL, "BREAK_POINT",     PS_META_NO_REPLACE, "default break point",  "NONE");
     20    psMetadataAddF32 (recipe, PS_LIST_TAIL, "ZERO_PT",         PS_META_NO_REPLACE, "default zero point",    25.00);
     21    psMetadataAddS32 (recipe, PS_LIST_TAIL, "BACKGROUND.XBIN", PS_META_NO_REPLACE, "default binning",          64);
     22    psMetadataAddS32 (recipe, PS_LIST_TAIL, "BACKGROUND.YBIN", PS_META_NO_REPLACE, "default binning",          64);
    2223
    2324    // these calls bind the I/O handle to the specified fpa
    2425    pmFPAfileDefine (config->files, config->camera, input->fpa, "PSPHOT.OUTPUT");
    25     pmFPAfileDefine (config->files, config->camera, input->fpa, "PSPHOT.RESID");
    2626
    27     // pmFPAfileDefine (config->files, format, input, "PSPHOT.PSF_INPUT");
    28     // pmFPAfileDefine (config->files, format, input, "PSPHOT.PSF_OUTPUT");
     27    // optionally save the residual image
     28    if (psMetadataLookupBool(NULL, recipe, "SAVE.RESID")) {
     29        pmFPAfileDefine (config->files, config->camera, input->fpa, "PSPHOT.RESID");
     30    }
     31
     32    int DX = psMetadataLookupS32 (&status, recipe, "BACKGROUND.XBIN");
     33    int DY = psMetadataLookupS32 (&status, recipe, "BACKGROUND.YBIN");
    2934
    3035    // these calls construct a new fpa for the I/O handle
    31     int DX = psMetadataLookupS32 (&status, recipe, "BACKGROUND_XBIN");
    32     if (!status) {DX = 64;}
    33     int DY = psMetadataLookupS32 (&status, recipe, "BACKGROUND_YBIN");
    34     if (!status) {DY = 64;}
    35     pmFPAfileFromFPA (config, input->fpa, DX, DY, "PSPHOT.BACKMDL");
    36     pmFPAfileFromFPA (config, input->fpa,  1,  1, "PSPHOT.BACKGND");
    37     pmFPAfileFromFPA (config, input->fpa,  1,  1, "PSPHOT.BACKSUB");
     36
     37    // optionally save the background model (small FITS image)
     38    if (psMetadataLookupBool(NULL, recipe, "SAVE.BACKMDL")) {
     39        pmFPAfileFromFPA (config, input->fpa, DX, DY, "PSPHOT.BACKMDL");
     40    }
     41    // optionally save the full background image
     42    if (psMetadataLookupBool(NULL, recipe, "SAVE.BACKGND")) {
     43        pmFPAfileFromFPA (config, input->fpa,  1,  1, "PSPHOT.BACKGND");
     44    }
     45    // optionally save the background-subtracted image
     46    if (psMetadataLookupBool(NULL, recipe, "SAVE.BACKSUB")) {
     47        pmFPAfileFromFPA (config, input->fpa,  1,  1, "PSPHOT.BACKSUB");
     48    }
     49    // optionally save the PSF Model
     50    if (psMetadataLookupBool(NULL, recipe, "SAVE.PSF")) {
     51        pmFPAfileDefine (config->files, config->camera, input->fpa, "PSPHOT.PSF.SAVE");
     52    }
     53    // optionally load the PSF Model
     54    if (psMetadataLookupBool(NULL, recipe, "LOAD.PSF")) {
     55        pmFPAfileDefine (config->files, config->camera, input->fpa, "PSPHOT.PSF.LOAD");
     56    }
    3857
    3958    // pmFPAfileConstruct (config->files, format, config->camera, "PSPHOT.PSF_SAMPLE");
    4059
    41     // psphot is supplied with the output name
    42     // this needs to be better: supply to all output (WRITE) files?
     60    // supply the output name (from cmd-line) to all output (WRITE) files
    4361    char *output = psMetadataLookupPtr(&status, config->arguments, "OUTPUT");
    4462    pmFPAfileAddFileNames (config->files, "OUTPUT", output, PM_FPA_MODE_WRITE);
    4563
    46     // set default recipe values here
    47     psMetadataAddStr (recipe, PS_LIST_TAIL, "FITMODE", PS_META_NO_REPLACE, "default fitting mode", "NONE");
    48     psMetadataAddStr (recipe, PS_LIST_TAIL, "PHOTCODE", PS_META_NO_REPLACE, "default photcode", "NONE");
    49     psMetadataAddStr (recipe, PS_LIST_TAIL, "BREAK_POINT", PS_META_NO_REPLACE, "default break point", "NONE");
    50     psMetadataAddF32 (recipe, PS_LIST_TAIL, "ZERO_PT", PS_META_NO_REPLACE, "default zero point", 25.00);
    51 
    52     // Chip selection: if we are using a single chip, select it for each FPA
    53     // Chip numbers to work on: -chip 1,2,3,5,8,10
    54     # if (0)
    55     char *chips = psMetadataLookupStr(NULL, config->arguments, "CHIP_SELECTIONS");
    56     if (chips != NULL) {
    57         char *p = chips;
    58         while (strlen(p)) {
    59             char *q = strchr (p, ',');
    60             if (q == NULL) {
    61                 q = p + strlen(p);
    62             } else {
    63                 *q = 0;
    64                 q = q + 1;
    65             }
    66             int chipNum = atoi(p);
    67             // XXX EAM : extend this to allow an array of selected chips (by name)
    68             if (! pmFPASelectChip(input->fpa, chipNum)) {
     64    // Chip selection: turn on only the chips specified
     65    char *chipLine = psMetadataLookupStr(NULL, config->arguments, "CHIP_SELECTIONS");
     66    psArray *chips = psStringSplitArray (chipLine, ",");
     67    if (chips->n > 0) {
     68        pmFPASelectChip (input->fpa, -1, true); // deselect all chips
     69        for (int i = 0; i < chips->n; i++) {
     70            int chipNum = atoi(chips->data[i]);
     71            if (! pmFPASelectChip(input->fpa, chipNum, false)) {
    6972                psErrorStackPrint(stderr, "Chip number %d doesn't exist in camera.\n", chipNum);
    7073                exit(EXIT_FAILURE);
    7174            }
    72             psLogMsg("psphot", PS_LOG_INFO, "Operating only on chip %d\n", chipNum);
    73             p = q;
    7475        }
    7576    }
    76     # endif
    7777
    7878    psTrace(__func__, 1, "Done with psphotParseCamera...\n");
  • trunk/psphot/src/psphotRadiusChecks.c

    r6753 r6862  
    66static pmModelRadius modelRadiusPSF;
    77
    8 bool psphotInitRadiusPSF (psMetadata *config, pmModelType type) {
     8bool psphotInitRadiusPSF (psMetadata *recipe, pmModelType type) {
    99
    1010    bool status;
    1111
    12     PSF_FIT_NSIGMA   = psMetadataLookupF32 (&status, config, "PSF_FIT_NSIGMA");
    13     PSF_FIT_PADDING  = psMetadataLookupF32 (&status, config, "PSF_FIT_PADDING");
     12    PSF_FIT_NSIGMA   = psMetadataLookupF32 (&status, recipe, "PSF_FIT_NSIGMA");
     13    PSF_FIT_PADDING  = psMetadataLookupF32 (&status, recipe, "PSF_FIT_PADDING");
    1414
    1515    // this function specifies the radius at this the model hits the given flux
     
    5656static pmModelRadius modelRadiusEXT;
    5757
    58 bool psphotInitRadiusEXT (psMetadata *config, pmModelType type) {
     58bool psphotInitRadiusEXT (psMetadata *recipe, pmModelType type) {
    5959
    6060    bool status;
    6161
    62     EXT_FIT_NSIGMA   = psMetadataLookupF32 (&status, config, "EXT_FIT_NSIGMA");
    63     EXT_FIT_PADDING  = psMetadataLookupF32 (&status, config, "EXT_FIT_PADDING");
     62    EXT_FIT_NSIGMA   = psMetadataLookupF32 (&status, recipe, "EXT_FIT_NSIGMA");
     63    EXT_FIT_PADDING  = psMetadataLookupF32 (&status, recipe, "EXT_FIT_PADDING");
    6464
    6565    // this function specifies the radius at this the model hits the given flux
  • trunk/psphot/src/psphotReadout.c

    r6851 r6862  
    11# include "psphot.h"
    22
    3 // XXX 2006.03.28 : no leaks!
    43bool psphotReadout (pmConfig *config, pmFPAview *view) {
    54
     
    1817    // XXX move this input the psphotImageLoop level?
    1918    pmReadoutSetWeights (readout);
    20     psphotSaveImage (NULL, readout->weight, "weight.fits");
    2119
    2220    // I have a valid mask, now mask in the analysis region of interest
     
    4442
    4543    // use bright stellar objects to measure PSF
    46     psf = psphotChoosePSF (sources, recipe);
     44    psf = psphotChoosePSF (readout, sources, recipe);
     45    psphotPSFstats (readout, recipe, psf);
    4746
    4847    // linear PSF fit to peaks
     
    5251    psphotBlendFit (readout, sources, recipe, psf);
    5352
     53    // XXX this was an attempt to measure bias due to the weighting.
    5454    // psphotWeightBias (readout, sources, recipe, psf);
    5555
     
    9191    return true;
    9292}
    93 
    94 # if (0)
    95 fprintf (stderr, "making fake sources\n");
    96 sources = psphotFakeSources ();
    97 psMetadata *tmp = psMetadataAlloc ();
    98 status = psMetadataAdd (readout->analysis, PS_LIST_TAIL, "PSPHOT.SOURCES", PS_DATA_ARRAY,    "psphot sources", sources);
    99 status = psMetadataAdd (readout->analysis, PS_LIST_TAIL, "PSPHOT.HEADER",  PS_DATA_METADATA, "header stats", tmp);
    100 psFree (sources);
    101 psFree (tmp);
    102 return true;
    103 # endif
  • trunk/psphot/src/psphotRoughClass.c

    r6379 r6862  
    22
    33// 2006.02.02 : no leaks
    4 bool psphotRoughClass (psArray *sources, psMetadata *config) {
     4bool psphotRoughClass (psArray *sources, psMetadata *recipe) {
    55
    66    bool status;
    77    pmPSFClump   psfClump;
    88
    9     psfClump = pmSourcePSFClump (sources, config);
     9    psfClump = pmSourcePSFClump (sources, recipe);
    1010
    1111    // group into STAR, COSMIC, EXTENDED, SATURATED, etc.
    12     pmSourceRoughClass (sources, config, psfClump);
     12    pmSourceRoughClass (sources, recipe, psfClump);
    1313
    1414    // optional printout of source moments only
    15     psphotDumpMoments (config, sources);
     15    psphotDumpMoments (recipe, sources);
    1616
    17     char *breakPt = psMetadataLookupStr (&status, config, "BREAK_POINT");
     17    char *breakPt = psMetadataLookupStr (&status, recipe, "BREAK_POINT");
    1818    if (!strcasecmp (breakPt, "CLASS")) exit (0);
    1919
  • trunk/psphot/src/psphotSourceFits.c

    r6851 r6862  
    5050static pmModelType modelTypeEXT;
    5151
    52 bool psphotInitLimitsEXT (psMetadata *config) {
     52bool psphotInitLimitsEXT (psMetadata *recipe) {
    5353
    5454    bool status;
    5555
    5656    // extended source model parameters
    57     EXT_MIN_SN       = psMetadataLookupF32 (&status, config, "EXT_MIN_SN");
    58     EXT_MOMENTS_RAD  = psMetadataLookupF32 (&status, config, "EXT_MOMENTS_RADIUS");
     57    EXT_MIN_SN       = psMetadataLookupF32 (&status, recipe, "EXT_MIN_SN");
     58    EXT_MOMENTS_RAD  = psMetadataLookupF32 (&status, recipe, "EXT_MOMENTS_RADIUS");
    5959
    6060    // extended source model descriptions
    61     char *modelNameEXT = psMetadataLookupStr (&status, config, "EXT_MODEL");
     61    char *modelNameEXT = psMetadataLookupStr (&status, recipe, "EXT_MODEL");
    6262    modelTypeEXT = pmModelSetType (modelNameEXT);
    63     psphotInitRadiusEXT (config, modelTypeEXT);
     63    psphotInitRadiusEXT (recipe, modelTypeEXT);
    6464
    6565    return true;
  • trunk/psphot/src/psphotSourceStats.c

    r6715 r6862  
    22
    33// 2006.02.02 : no leaks
    4 psArray *psphotSourceStats (pmReadout *readout, psMetadata *config, psArray *peaks)
     4psArray *psphotSourceStats (pmReadout *readout, psMetadata *recipe, psArray *peaks)
    55{
    66    bool     status  = false;
     
    1111
    1212    // determine properties (sky, moments) of initial sources
    13     float INNER    = psMetadataLookupF32 (&status, config, "SKY_INNER_RADIUS");
    14     float OUTER    = psMetadataLookupF32 (&status, config, "SKY_OUTER_RADIUS");
    15     float RADIUS   = psMetadataLookupF32 (&status, config, "PSF_MOMENTS_RADIUS");
     13    float INNER    = psMetadataLookupF32 (&status, recipe, "SKY_INNER_RADIUS");
     14    float OUTER    = psMetadataLookupF32 (&status, recipe, "SKY_OUTER_RADIUS");
     15    float RADIUS   = psMetadataLookupF32 (&status, recipe, "PSF_MOMENTS_RADIUS");
    1616
    1717    sources = psArrayAlloc (peaks->n);
     
    7272    psLogMsg ("psphot", 3, "%d moments: %f sec\n", sources->n, psTimerMark ("psphot"));
    7373
    74     char *breakPt = psMetadataLookupStr (&status, config, "BREAK_POINT");
     74    char *breakPt = psMetadataLookupStr (&status, recipe, "BREAK_POINT");
    7575    if (!strcasecmp (breakPt, "STATS")) exit (0);
    7676
  • trunk/psphot/src/psphotWeightBias.c

    r6851 r6862  
    55// only allow the normalization to vary
    66// XXX eventually, we should be able to do this with linear fitting...
    7 bool psphotWeightBias (pmReadout *readout, psArray *sources, psMetadata *config, pmPSF *psf) {
     7bool psphotWeightBias (pmReadout *readout, psArray *sources, psMetadata *recipe, pmPSF *psf) {
    88
    99    int Nfit = 0;
     
    2121   
    2222    // option to limit analysis to a specific region
    23     char *region = psMetadataLookupStr (&status, config, "ANALYSIS_REGION");
     23    char *region = psMetadataLookupStr (&status, recipe, "ANALYSIS_REGION");
    2424    psRegion AnalysisRegion = psRegionForImage (readout->image, psRegionFromString (region));
    2525    if (psRegionIsNaN (AnalysisRegion)) psAbort ("psphot", "analysis region mis-defined");
Note: See TracChangeset for help on using the changeset viewer.