IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 6715


Ignore:
Timestamp:
Mar 27, 2006, 4:31:17 PM (20 years ago)
Author:
eugene
Message:

substantial work on the pmFPAfile,view concepts

Location:
trunk/psphot/src
Files:
2 added
6 deleted
29 edited

Legend:

Unmodified
Added
Removed
  • trunk/psphot/src/Makefile.am

    r6571 r6715  
    1616        psphotArguments.c       \
    1717        psphotParseCamera.c     \
    18         testPSphotLoop.c        \
    19         psphotMaskCell.c        \
     18        psphotImageLoop.c       \
     19        psphotMaskReadout.c     \
    2020        psphotReadout.c         \
    2121        psphotImageMedian.c     \
     
    3333        psphotEvalPSF.c         \
    3434        psphotEvalFLT.c         \
    35         psphotSourceFits.c     
     35        psphotSourceFits.c      \
     36        psphotRadiusChecks.c    \
     37        psphotSortBySN.c        \
     38        psphotOutput.c          \
     39        psphotGrowthCurve.c     \
     40        psphotFakeSources.c     \
     41        psphotCleanup.c         
    3642
    37 junk =  psphotGrowthCurve.c     \
    38         psphotCleanup.c         \
    39         psphotSortBySN.c        \
    40         psphotDefinePixels.c    \
    41         psphotRadiusChecks.c    \
    42         psModulesUtils.c        \
     43junk =  psphotDefinePixels.c    \
    4344        pmSourceContour.c       \
    4445        pmModelFitSet.c         \
     
    4748
    4849noinst_HEADERS =                \
    49         psLibUtils.h            \
    50         psModulesUtils.h        \
    51         psphot.h                \
    52         psSparse.h
     50        psphot.h               
    5351
    5452clean-local:
     
    5856        etags `find . -name \*.[ch] -print`
    5957
    60 
    6158#       psphotFullFit.c         
    6259#       psphotApplyPSF.c       
    6360#       psphotFitGalaxies.c
    64 #       psphotImageStats.c     
    65 #       psphotImageBackground.c
    66 #       psphotOutput.c         
    6761#       psphotLoadPixels.c     
  • trunk/psphot/src/psphot.c

    r6571 r6715  
    33// XXX need a better structure for handling optional sequences
    44int main (int argc, char **argv) {
     5
     6    // headtest (argc, argv);
    57
    68    psTimerStart ("complete");
  • trunk/psphot/src/psphot.h

    r6571 r6715  
    33# include <unistd.h>   // for unlink
    44# include <pslib.h>
    5 # include <pmObjects.h>
     5# include <psmodules.h>
     6
     7# if (0)
     8# include <psLine.h>
     9# include <psSparse.h>
     10# include <psEllipse.h>
     11# include <psAdditionals.h>
     12# include <pmConfig.h>
     13# include <pmHDU.h>
     14# include <pmHDUUtils.h>
     15# include <pmFPA.h>
     16# include <pmFPAview.h>
     17# include <pmFPAfile.h>
     18# include <pmFPARead.h>
     19# include <pmFPAConstruct.h>
     20# include <pmMaskBadPixels.h>
     21# include <pmConcepts.h>
     22
     23# include <pmPeaks.h>
     24# include <pmMoments.h>
     25# include <pmModel.h>
     26# include <pmSource.h>
     27# include <pmSourceIO.h>
     28# include <pmSourceSky.h>
     29# include <pmSourceFitModel.h>
     30# include <pmSourceFitSet.h>
     31# include <pmSourceContour.h>
    632# include <pmGrowthCurve.h>
    7 # include <pmConfig.h>
    8 # include <pmFPARead.h>
    933# include <pmPSF.h>
    1034# include <pmPSFtry.h>
    1135# include <pmModelGroup.h>
    12 // # include "psLibUtils.h"
    13 // # include "psModulesUtils.h"
    14 // # include "psSparse.h"
    15 # include "pmFPAConstruct.h"
    16 # include "pmConcepts.h"
     36# include <pmSourcePhotometry.h>
     37# endif
    1738
    1839# define PSPHOT_RECIPE "PSPHOT"
     
    2647
    2748bool            psphotModelTest (pmReadout *readout, psMetadata *arguments, psMetadata *recipe);
    28 bool            psphotReadout (pmReadout *readout, psMetadata *config);
     49bool            psphotReadout (pmConfig *config, pmFPAview *view);
    2950void            psphotCleanup (void);
    3051
    31 // bool            ppImageLoadPixels (ppFile *input, psDB *db, int chipNum, int cellNum);
     52psArray        *psphotFakeSources ();
     53int             psphotSaveImage (psMetadata *header, psImage *image, char *filename);
    3254
    3355// psphotReadout functions
    34 psStats        *psphotImageStats (pmReadout *readout, psMetadata *config);
    35 psPolynomial2D *psphotImageBackground (pmReadout *readout, psMetadata *config, psStats *sky);
     56bool            psphotImageMedian (pmConfig *config, pmFPAview *view);
    3657psArray        *psphotFindPeaks (pmReadout *readout, psMetadata *config);
    3758psArray        *psphotSourceStats (pmReadout *readout, psMetadata *config, psArray *allpeaks);
    3859bool            psphotRoughClass (psArray *sources, psMetadata *config);
    3960bool            psphotBasicDeblend (psArray *sources, psMetadata *config);
    40 pmPSF          *psphotChoosePSF (psMetadata *config, psArray *sources);
    41 void            psphotOutput (pmReadout *readout, psMetadata *arguments);
    42 psImage        *psphotImageMedian (pmReadout *readout, psMetadata *config);
    43 
    44 // optional object analysis steps
    45 bool            psphotEnsemblePSF (pmReadout *readout, psMetadata *config, psArray *sources, pmPSF *psf, bool final);
    46 bool            psphotBlendFit (pmReadout *readout, psMetadata *config, psArray *sources, pmPSF *psf);
     61pmPSF          *psphotChoosePSF (psArray *sources, psMetadata *config);
     62bool            psphotEnsemblePSF (pmReadout *readout, psArray *sources, psMetadata *config, pmPSF *psf, bool final);
     63bool            psphotBlendFit (pmReadout *readout, psArray *sources, psMetadata *config, pmPSF *psf);
    4764bool            psphotReplaceUnfit (psArray *sources);
    4865bool            psphotApResid (pmReadout *readout, psArray *sources, psMetadata *config, pmPSF *psf);
     66bool            psphotMagnitudes (psArray *sources, psMetadata *config, pmPSF *psf);
     67bool            psphotSkyReplace (pmConfig *config, pmFPAview *view);
    4968
    5069// basic support functions
     
    5473bool            psphotGrowthCurve (pmReadout *readout, pmPSF *psf);
    5574void            psphotTestArguments (int *argc, char **argv);
    56 bool            psphotMaskCell (pmCell *cell, psMetadata *recipe);
     75bool            psphotMaskReadout (pmReadout *readout, psMetadata *recipe);
    5776bool            psphotBackgroundNames (psMetadata *arguments);
    58 bool            psphotSkyReplace (pmReadout *readout, psImage *background);
    5977
    6078// functions to set the correct source pixels
     
    6684
    6785// output functions
    68 # if (0)
    69 bool            pmSourcesWriteSX   (psArray *sources, char *filename);
    70 bool            pmSourcesWriteOBJ  (psArray *sources, char *filename);
    71 bool            pmSourcesWriteCMP  (psArray *sources, char *filename, psMetadata *header);
    72 bool            pmSourcesWriteCMF  (psArray *sources, char *filename, psMetadata *header);
    73 bool            pmSourcesWriteText (psArray *sources, char *filename);
    74 
    75 bool            pmModelWritePSFs (psArray *sources, char *filename);
    76 bool            pmModelWriteEXTs (psArray *sources, char *filename);
    77 bool            pmModelWriteNULLs (psArray *sources, char *filename);
    78 bool            pmPeaksWriteText (psArray *sources, char *filename);
    79 bool            pmMomentsWriteText (psArray *sources, char *filename);
    80 
    81 bool            psphotSamplePSFs (pmPSF *psf, psImage *image, char *output);
    8286bool            psphotDumpMoments (psMetadata *config, psArray *sources);
    83 int             psphotSaveImage (psMetadata *header, psImage *image, char *filename);
    8487bool            psphotUpdateHeader (psMetadata *header, psMetadata *config);
    85 # endif
    86 
    87 // void            psphotOutputPrep (ppFile *file, ppConfig *config);
    88 // void            psphotOutputCleanup (void);
    89 
    90 bool            psphotMagnitudes (psMetadata *config, psArray *sources, pmPSF *psf);
    9188
    9289// PSF / DBL / EXT evaluation functions
     
    106103// XXX these can probably be dropped:
    107104
     105// functions to support simultaneous multi-source fitting
     106bool            psphotFitSet (pmSource *oneSrc, pmModel *oneModel, char *fitset, bool PSF);
     107
     108# if (0)
     109
     110pmHDU          *pmHDUFromReadout (pmReadout *readout);
     111bool            psRegionIsNaN (psRegion region);
     112bool            pmReadoutSetWeights(pmReadout *readout);
     113
     114// bicubic interpolation
     115psPolynomial2D *psImageBicubeFit (psImage *image, int x, int y);
     116psPlane         psImageBicubeMin (psPolynomial2D *poly);
     117
     118bool            psImageJpegColormap (char *name);
     119bool            psImageJpeg (psImage *image, char *filename, float zero, float scale);
     120
     121bool            pmSourceFitSet (pmSource *source, psArray *modelSet, const bool PSF);
     122psF32           pmModelFitSet (psVector *deriv, const psVector *params, const psVector *x);
     123bool            pmModelFitSetInit (pmModelType type);
     124void            pmModelFitSetClear (void);
     125
    108126// optional mode for clip fit?
    109127psPolynomial4D *psVectorChiClipFitPolynomial4D(
     
    119137    const psVector *t);
    120138
    121 // functions to support simultaneous multi-source fitting
    122 bool            psphotFitSet (pmSource *oneSrc, pmModel *oneModel, char *fitset, bool PSF);
    123 bool            pmSourceFitSet (pmSource *source, psArray *modelSet, const bool PSF);
    124 psF32           pmModelFitSet (psVector *deriv, const psVector *params, const psVector *x);
    125 bool            pmModelFitSetInit (pmModelType type);
    126 void            pmModelFitSetClear (void);
     139# endif
    127140
    128 // bicubic interpolation
    129 psPolynomial2D *psImageBicubeFit (psImage *image, int x, int y);
    130 psPlane         psImageBicubeMin (psPolynomial2D *poly);
     141# if (0)
     142bool            psphotSamplePSFs (pmPSF *psf, psImage *image, char *output);
     143int             psphotSaveImage (psMetadata *header, psImage *image, char *filename);
    131144
    132 bool psImageJpegColormap (char *name);
    133 bool psImageJpeg (psImage *image, char *filename, float zero, float scale);
     145bool            pmSourcesWriteSX   (psArray *sources, char *filename);
     146bool            pmSourcesWriteOBJ  (psArray *sources, char *filename);
     147bool            pmSourcesWriteCMP  (psArray *sources, char *filename, psMetadata *header);
     148bool            pmSourcesWriteCMF  (psArray *sources, char *filename, psMetadata *header);
     149bool            pmSourcesWriteText (psArray *sources, char *filename);
     150bool            pmPeaksWriteText (psArray *sources, char *filename);
    134151
     152bool            pmModelWritePSFs (psArray *sources, char *filename);
     153bool            pmModelWriteEXTs (psArray *sources, char *filename);
     154bool            pmModelWriteNULLs (psArray *sources, char *filename);
     155bool            pmMomentsWriteText (psArray *sources, char *filename);
     156# endif
    135157
    136158// XXX deprecate
     
    142164// float           pmSourceCrossWeight (pmSource *Mi, pmSource *Mj);
    143165// psArray        *pmSourceContour_EAM (psImage *image, int x, int y, float threshold);
     166// psStats        *psphotImageStats (pmReadout *readout, psMetadata *config);
     167// psPolynomial2D *psphotImageBackground (pmReadout *readout, psMetadata *config, psStats *sky);
     168// void            psphotOutput (pmReadout *readout, psMetadata *arguments);
     169
     170// void            psphotOutputPrep (ppFile *file, ppConfig *config);
     171// void            psphotOutputCleanup (void);
     172
     173// bool            ppImageLoadPixels (ppFile *input, psDB *db, int chipNum, int cellNum);
     174
  • trunk/psphot/src/psphotApResid.c

    r6495 r6715  
    3030    Npsf = 0;
    3131
    32     // select all good PM_SOURCE_STAR entries
     32    // select all good PM_SOURCE_TYPE_STAR entries
    3333    for (int i = 0; i < sources->n; i++) {
    3434        source = sources->data[i];
    3535
    36         if (source->type != PM_SOURCE_STAR) continue;
    37         if (source->mode &  PM_SOURCE_SATSTAR) continue;
    38         if (source->mode &  PM_SOURCE_BLEND) continue;
    39         if (source->mode &  PM_SOURCE_FAIL) continue;
    40         if (source->mode &  PM_SOURCE_POOR) continue;
     36        if (source->type != PM_SOURCE_TYPE_STAR) continue;
     37        if (source->mode &  PM_SOURCE_MODE_SATSTAR) continue;
     38        if (source->mode &  PM_SOURCE_MODE_BLEND) continue;
     39        if (source->mode &  PM_SOURCE_MODE_FAIL) continue;
     40        if (source->mode &  PM_SOURCE_MODE_POOR) continue;
    4141
    4242        // XXX tune independently?
     
    5151        yPos->data.F64[Npsf] = model->params->data.F32[3];
    5252
    53         flux->data.F64[Npsf] = pow(10.0, -0.4*source->fitMag);
     53        flux->data.F64[Npsf] = pow(10.0, -0.4*source->psfMag);
    5454        r2rflux->data.F64[Npsf] = PS_SQR(model->radius) / flux->data.F64[Npsf];
    5555       
    56         apResid->data.F64[Npsf] = source->apMag + pmGrowthCurveCorrect (psf->growth, model->radius) - source->fitMag ;
     56        apResid->data.F64[Npsf] = source->apMag + pmGrowthCurveCorrect (psf->growth, model->radius) - source->psfMag;
    5757
    5858        // XXX sanity clip?
  • trunk/psphot/src/psphotApplyPSF.c

    r6056 r6715  
    2020
    2121        // skip non-astronomical objects (very likely defects)
    22         if (source->mode  & PM_SOURCE_BLEND) continue;
    23         if (source->type == PM_SOURCE_DEFECT) continue;
    24         if (source->type == PM_SOURCE_SATURATED) continue;
     22        if (source->mode  & PM_SOURCE_MODE_BLEND) continue;
     23        if (source->type == PM_SOURCE_TYPE_DEFECT) continue;
     24        if (source->type == PM_SOURCE_TYPE_SATURATED) continue;
    2525
    2626        // use the source moments, etc to guess basic model parameters
     
    4949        // check if model fit is acceptable
    5050        if (psphotEvalPSF (source, source->modelPSF)) {
    51             pmSourceSubModel (source->pixels, source->mask, source->modelPSF, false, false);
    52             source->mode |=  PM_SOURCE_SUBTRACTED;
    53             source->mode &= ~PM_SOURCE_TEMPSUB;
     51            pmModelSub (source->pixels, source->mask, source->modelPSF, false, false);
     52            source->mode |=  PM_SOURCE_MODE_SUBTRACTED;
     53            source->mode &= ~PM_SOURCE_MODE_TEMPSUB;
    5454            Nsub ++;
    5555        }
  • trunk/psphot/src/psphotArguments.c

    r6571 r6715  
    22# include <glob.h>
    33
    4 static void usage (void);
     4static void usage (void) {
     5    fprintf (stderr, "USAGE: psphot [-file image(s)] [-list imagelist] (output)\n");
     6    exit (2);
     7}
    58
    69pmConfig *psphotArguments (int *argc, char **argv) {
     
    99102
    100103    // load config data from default locations
    101     pmConfig *config = pmConfigRead(argc, argv, PSPHOT_RECIPE);
     104    pmConfig *config = pmConfigRead(argc, argv);
    102105
    103106    // Storage for other command-line arguments
     
    105108
    106109    // save these recipe options until we have loaded the options
    107     psMetadataAddPtr (config->arguments, PS_LIST_TAIL, "PSPHOT.OPTIONS",  PS_META_REPLACE, "", options);
     110    psMetadataAddPtr (config->arguments, PS_LIST_TAIL, "PSPHOT.OPTIONS",  PS_DATA_METADATA, "", options);
     111    psFree (options);
    108112
    109113    // chip selection is used to limit chips to be processed
    110114    if ((N = psArgumentGet (*argc, argv, "-chip"))) {
    111115        psArgumentRemove (N, argc, argv);
    112         psMetadataAddStr (config->arguments, PS_LIST_TAIL, "CHIP_SELECTION", PS_META_REPLACE, "", argv[N]);
     116        psMetadataAddStr (config->arguments, PS_LIST_TAIL, "CHIP_SELECTION", PS_DATA_STRING, "", psStringCopy(argv[N]));
    113117        psArgumentRemove (N, argc, argv);
    114118    }
     
    116120    // we load all input files onto a psArray, to be parsed later
    117121    psArray *input = psArrayAlloc (16);
     122    input->n = 0;
    118123
    119124    // load the list of filenames the supplied file (may be a glob: "file*.fits")
     
    126131            char *filename = psStringCopy (globList.gl_pathv[i]);
    127132            psArrayAdd (input, 16, filename);
     133            psFree (filename);
    128134        }
    129135        psArgumentRemove (N, argc, argv);
     
    150156                filename = psStringCopy (word);
    151157                psArrayAdd (input, 16, filename);
     158                psFree (filename);
    152159                break;
    153160              default:
     
    162169
    163170    // input list gets places as an array on the config->arguements list
    164     psMetadataAddPtr (config->arguments, PS_LIST_TAIL, "INPUT",  PS_META_REPLACE, "", input);
     171    psMetadataAddPtr (config->arguments, PS_LIST_TAIL, "INPUT",  PS_DATA_ARRAY, "", input);
     172    psFree (input);
    165173
    166174    if (*argc != 2) usage ();
    167175
    168     // input and output positions are fixed
    169     psMetadataAddStr (config->arguments, PS_LIST_TAIL, "OUTPUT", PS_META_REPLACE, "", argv[1]);
     176    // output position is fixed
     177    psMetadataAddStr (config->arguments, PS_LIST_TAIL, "OUTPUT", 0, "", argv[1]);
    170178
    171179    psTrace(__func__, 1, "Done with psphotArguments...\n");
    172180    return (config);
    173181}
    174 
    175 static void usage (void) {
    176     fprintf (stderr, "USAGE: psphot [-file image(s)] [-list imagelist] (output)\n");
    177     exit (2);
    178 }
  • trunk/psphot/src/psphotBasicDeblend.c

    r6481 r6715  
    3737        source = sources->data[N];
    3838
    39         if (source->mode & PM_SOURCE_BLEND) continue;
     39        if (source->mode & PM_SOURCE_MODE_BLEND) continue;
    4040
    4141        // temporary array for overlapping objects we find
     
    8989
    9090        // generate a basic contour (set of x,y coordinates at-or-below flux level)
    91         psArray *contour = pmSourceContour_EAM (source->pixels, source->peak->x, source->peak->y, threshold);
     91        psArray *contour = pmSourceContour (source->pixels, source->peak->x, source->peak->y, threshold);
    9292        if (contour == NULL) {
    9393            psFree (overlap);
     
    110110                if (xv->data.F32[j+1] < testSource->peak->x) break;
    111111
    112                 testSource->mode |= PM_SOURCE_BLEND;
     112                testSource->mode |= PM_SOURCE_MODE_BLEND;
    113113
    114114                // add this to the list of source->blends
  • trunk/psphot/src/psphotBlendFit.c

    r6495 r6715  
    22
    33// XXX I don't like this name
    4 bool psphotBlendFit (pmReadout *readout, psMetadata *config, psArray *sources, pmPSF *psf) {
     4bool psphotBlendFit (pmReadout *readout, psArray *sources, psMetadata *config, pmPSF *psf) {
    55
    66    int Nfit = 0;
     
    2828
    2929        // skip non-astronomical objects (very likely defects)
    30         if (source->mode &  PM_SOURCE_BLEND) continue;
    31         if (source->type == PM_SOURCE_DEFECT) continue;
    32         if (source->type == PM_SOURCE_SATURATED) continue;
     30        if (source->mode &  PM_SOURCE_MODE_BLEND) continue;
     31        if (source->type == PM_SOURCE_TYPE_DEFECT) continue;
     32        if (source->type == PM_SOURCE_TYPE_SATURATED) continue;
    3333
    3434        // limit selection to some SN limit
     
    4545
    4646        // replace object in image
    47         pmSourceAddModel (source->pixels, source->mask, source->modelPSF, false, false);
     47        pmModelAdd (source->pixels, source->mask, source->modelPSF, false, false);
    4848        Nfit ++;
    4949
     
    5757
    5858        // re-subtract PSF for object, leave local sky
    59         pmSourceSubModel (source->pixels, source->mask, source->modelPSF, false, false);
    60         source->mode |= PM_SOURCE_SUBTRACTED;
    61         source->mode |= PM_SOURCE_TEMPSUB;
     59        pmModelSub (source->pixels, source->mask, source->modelPSF, false, false);
     60        source->mode |= PM_SOURCE_MODE_SUBTRACTED;
     61        source->mode |= PM_SOURCE_MODE_TEMPSUB;
    6262    }
    6363
  • trunk/psphot/src/psphotChoosePSF.c

    r6571 r6715  
    3434    for (int i = 0; (i < sources->n) && (stars->n < NSTARS); i++) {
    3535        pmSource *source = sources->data[i];
    36         if (source->mode & PM_SOURCE_PSFSTAR) psArrayAdd (stars, 200, source);
     36        if (source->mode & PM_SOURCE_MODE_PSFSTAR) psArrayAdd (stars, 200, source);
    3737    }
    3838    psLogMsg ("psphot.pspsf", 4, "selected candidate %d PSF objects\n", stars->n);
     
    9090        pmSource *source = try->sources->data[i];
    9191        if (try->mask->data.U8[i] & PSFTRY_MASK_EXT_FAIL) {
    92             source->mode &= ~PM_SOURCE_PSFSTAR;
     92            source->mode &= ~PM_SOURCE_MODE_PSFSTAR;
    9393        }
    9494    }
  • trunk/psphot/src/psphotCleanup.c

    r6571 r6715  
    66    psMemCheckCorruption (true);
    77    pmModelGroupCleanup ();
    8     psphotOutputCleanup ();
     8//    psphotOutputCleanup ();
    99    psTimeFinalize ();
    1010    pmConceptsDone ();
    11     fprintf (stderr, "found %d leaks at %s\n", psMemCheckLeaks (0, NULL, NULL, false), "psphot");
     11    fprintf (stderr, "found %d leaks at %s\n", psMemCheckLeaks (0, NULL, stdout, false), "psphot");
    1212    return;
    1313}
  • trunk/psphot/src/psphotEnsemblePSF.c

    r6571 r6715  
    4444        // skip non-astronomical objects (very likely defects)
    4545        // XXX EAM : should we try these anyway?
    46         if (inSource->type == PM_SOURCE_DEFECT) continue;
    47         if (inSource->type == PM_SOURCE_SATURATED) continue;
     46        if (inSource->type == PM_SOURCE_TYPE_DEFECT) continue;
     47        if (inSource->type == PM_SOURCE_TYPE_SATURATED) continue;
    4848        if (final) {
    49             if (inSource->mode &  PM_SOURCE_SUBTRACTED) continue;
     49            if (inSource->mode &  PM_SOURCE_MODE_SUBTRACTED) continue;
    5050        } else {
    51             if (inSource->mode &  PM_SOURCE_BLEND) continue;
     51            if (inSource->mode &  PM_SOURCE_MODE_BLEND) continue;
    5252        }
    5353
     
    6161        // really saturated stars should be re-measured for a better centroid
    6262        // XXX EAM : move this to a 'clear satstar function'
    63         if (inSource->mode &  PM_SOURCE_SATSTAR) {
     63        if (inSource->mode &  PM_SOURCE_MODE_SATSTAR) {
    6464            status = pmSourceMoments (inSource, INNER_RADIUS);
    6565        }
     
    6868        // use the source moments, etc to guess basic model parameters
    6969        pmModel *modelEXT = pmSourceModelGuess (inSource, psf->type);
    70         if (inSource->mode &  PM_SOURCE_SATSTAR) {
     70        if (inSource->mode &  PM_SOURCE_MODE_SATSTAR) {
    7171            modelEXT->params->data.F32[2] = inSource->moments->x;
    7272            modelEXT->params->data.F32[3] = inSource->moments->y;
     
    118118        // fill in the model pixel values
    119119        psImageInit (flux, 0.0);
    120         psImageKeepCircle (mask, x, y, model->radius, "OR", PSPHOT_MASK_MARKED);
    121         pmSourceAddModel (flux, mask, model, false, false);
     120        psImageKeepCircle (mask, x, y, model->radius, "OR", PM_SOURCE_MASK_MARKED);
     121        pmModelAdd (flux, mask, model, false, false);
    122122
    123123        // calculate nDOF (nPix - 1)
    124         // int Nmaskpix = psImageCountPixelMask (mask, allArray, PSPHOT_MASK_SATURATED);
     124        // int Nmaskpix = psImageCountPixelMask (mask, allArray, PM_SOURCE_MASK_SATURATED);
    125125        // model->nDOF  = mask->numCols*mask->numRows - Nmaskpix - 1;
    126126
     
    195195
    196196        // subtract object
    197         pmSourceSubModel (Fi->pixels, Fi->mask, Fi->modelPSF, false, false);
    198         Fi->mode |= PM_SOURCE_SUBTRACTED;
    199         if (!final) Fi->mode |= PM_SOURCE_TEMPSUB;
     197        pmModelSub (Fi->pixels, Fi->mask, Fi->modelPSF, false, false);
     198        Fi->mode |= PM_SOURCE_MODE_SUBTRACTED;
     199        if (!final) Fi->mode |= PM_SOURCE_MODE_TEMPSUB;
    200200    }
    201201
     
    209209        y = model->params->data.F32[3];
    210210
    211         psImageKeepCircle (Fi->mask, x, y, model->radius, "OR", PSPHOT_MASK_MARKED);
     211        psImageKeepCircle (Fi->mask, x, y, model->radius, "OR", PM_SOURCE_MASK_MARKED);
    212212        pmSourceChisq (model, Fi->pixels, Fi->mask, Fi->weight);
    213         psImageKeepCircle (Fi->mask, x, y, model->radius, "AND", ~PSPHOT_MASK_MARKED);
     213        psImageKeepCircle (Fi->mask, x, y, model->radius, "AND", ~PM_SOURCE_MASK_MARKED);
    214214    }
    215215
  • trunk/psphot/src/psphotEvalFLT.c

    r5993 r6715  
    77    // do we actually have a valid EXT model?
    88    if (model == NULL) {
    9         source->mode &= ~PM_SOURCE_FITTED;
     9        source->mode &= ~PM_SOURCE_MODE_FITTED;
    1010        return false;
    1111    }
     
    1616        break;
    1717      case PM_MODEL_UNTRIED:
    18         source->mode &= ~PM_SOURCE_FITTED;
     18        source->mode &= ~PM_SOURCE_MODE_FITTED;
    1919        return false;
    2020      case PM_MODEL_BADARGS:
     
    2323      default:
    2424        psLogMsg ("psphot", 5, "EXT fail fit\n");
    25         source->mode |= PM_SOURCE_FAIL;
     25        source->mode |= PM_SOURCE_MODE_FAIL;
    2626        return false;
    2727    }
    2828
    2929    // unless we prove otherwise, this object is extended
    30     source->type = PM_SOURCE_EXTENDED;
     30    source->type = PM_SOURCE_TYPE_EXTENDED;
    3131
    3232    // the following source->mode information pertains to modelEXT:
    33     source->mode |= PM_SOURCE_EXTMODEL;
     33    source->mode |= PM_SOURCE_MODE_EXTMODEL;
    3434
    3535    // if the object has a fitted peak below 0, the fit did not converge cleanly
    3636    if (model->params->data.F32[1] <= 0) {
    37         source->mode |= PM_SOURCE_FAIL;
     37        source->mode |= PM_SOURCE_MODE_FAIL;
    3838        return false;
    3939    }
     
    4444    // poor-quality fit; only keep if nothing else works...
    4545    psLogMsg ("psphot", 5, "EXT poor fit\n");
    46     source->mode |= PM_SOURCE_POOR;
     46    source->mode |= PM_SOURCE_MODE_POOR;
    4747    return false;
    4848}       
  • trunk/psphot/src/psphotEvalPSF.c

    r5993 r6715  
    5454    // do we actually have a valid PSF model?
    5555    if (model == NULL) {
    56         source->mode &= ~PM_SOURCE_FITTED;
     56        source->mode &= ~PM_SOURCE_MODE_FITTED;
    5757        return false;
    5858    }
     
    6363        break;
    6464      case PM_MODEL_UNTRIED:
    65         source->mode &= ~PM_SOURCE_FITTED;
     65        source->mode &= ~PM_SOURCE_MODE_FITTED;
    6666        return false;
    6767      case PM_MODEL_BADARGS:
     
    6969      case PM_MODEL_OFFIMAGE:
    7070      default:
    71         source->mode |= PM_SOURCE_FAIL;
     71        source->mode |= PM_SOURCE_MODE_FAIL;
    7272        return false;
    7373    }
    7474
    7575    // unless we prove otherwise, this object is a star.
    76     source->type = PM_SOURCE_STAR;
     76    source->type = PM_SOURCE_TYPE_STAR;
    7777
    7878    // the following source->mode information pertains to modelPSF:
    79     source->mode |= PM_SOURCE_PSFMODEL;
     79    source->mode |= PM_SOURCE_MODE_PSFMODEL;
    8080
    8181    // if the object has fitted peak above saturation, label as SATSTAR
     
    8484    // XXX no extended object can saturate and stay extended...
    8585    if (model->params->data.F32[1] >= SATURATION) {
    86         if (source->mode & PM_SOURCE_PSFSTAR) {
     86        if (source->mode & PM_SOURCE_MODE_PSFSTAR) {
    8787            psLogMsg ("psphot", 5, "PSFSTAR marked SATSTAR\n");
    8888        }
    89         source->mode |=  PM_SOURCE_SATSTAR;
     89        source->mode |=  PM_SOURCE_MODE_SATSTAR;
    9090        return true;
    9191    }
     
    9393    // if the object has a fitted peak below 0, the fit did not converge cleanly
    9494    if (model->params->data.F32[1] <= 0) {
    95         source->mode |= PM_SOURCE_FAIL;
     95        source->mode |= PM_SOURCE_MODE_FAIL;
    9696        return false;
    9797    }
     
    9999    // if the source was predicted to be a SATSTAR, but it fitted below saturation,
    100100    // make a note to the user
    101     if (source->mode & PM_SOURCE_SATSTAR) {
     101    if (source->mode & PM_SOURCE_MODE_SATSTAR) {
    102102        psLogMsg ("psphot", 5, "SATSTAR marked normal (fitted peak below saturation)\n");
    103         source->mode &= ~PM_SOURCE_SATSTAR;
     103        source->mode &= ~PM_SOURCE_MODE_SATSTAR;
    104104    }
    105105
     
    115115    nSy = dSY / hypot (MIN_DS, 1 / (SY * SN));
    116116
    117     // assign PM_SOURCE_GOODSTAR to bright objects within PSF region of dparams[]
     117    // assign PM_SOURCE_MODE_GOODSTAR to bright objects within PSF region of dparams[]
    118118    keep = TRUE;
    119119    keep &= (fabs(nSx) < PSF_SHAPE_NSIGMA);
     
    124124
    125125    // this source is not a star, warn if it was a PSFSTAR
    126     if (source->mode & PM_SOURCE_PSFSTAR) {
     126    if (source->mode & PM_SOURCE_MODE_PSFSTAR) {
    127127        psLogMsg ("psphot", 5, "PSFSTAR demoted based on fit quality   (%f, %f  :  %f %f %f %f)\n",
    128128                  model->params->data.F32[2], model->params->data.F32[3], nSx, nSy, SN, Chi);
     
    134134    // object appears to be small, suspected defect
    135135    if ((nSx <= -PSF_SHAPE_NSIGMA) || (nSy <= -PSF_SHAPE_NSIGMA)) {
    136         source->type = PM_SOURCE_DEFECT;
     136        source->type = PM_SOURCE_TYPE_DEFECT;
    137137        return false;
    138138    }
     
    140140    // object appears to be large, suspected extended source
    141141    if ((nSx >= PSF_SHAPE_NSIGMA) || (nSy >= PSF_SHAPE_NSIGMA)) {
    142         source->type = PM_SOURCE_EXTENDED;
     142        source->type = PM_SOURCE_TYPE_EXTENDED;
    143143        return false;
    144144    }
    145145
    146146    // poor-quality fit; only keep if nothing else works...
    147     source->mode |= PM_SOURCE_POOR;
     147    source->mode |= PM_SOURCE_MODE_POOR;
    148148    return false;
    149149}       
     
    155155    // do we actually have a valid PSF model?
    156156    if (model == NULL) {
    157         source->mode &= ~PM_SOURCE_FITTED;
     157        source->mode &= ~PM_SOURCE_MODE_FITTED;
    158158        return false;
    159159    }
     
    164164        break;
    165165      case PM_MODEL_UNTRIED:
    166         source->mode &= ~PM_SOURCE_FITTED;
     166        source->mode &= ~PM_SOURCE_MODE_FITTED;
    167167        return false;
    168168      case PM_MODEL_BADARGS:
     
    170170      case PM_MODEL_OFFIMAGE:
    171171      default:
    172         source->mode |= PM_SOURCE_FAIL;
     172        source->mode |= PM_SOURCE_MODE_FAIL;
    173173        return false;
    174174    }
    175175
    176176    // unless we prove otherwise, this object is a star.
    177     source->type = PM_SOURCE_STAR;
     177    source->type = PM_SOURCE_TYPE_STAR;
    178178
    179179    // the following source->mode information pertains to modelPSF:
    180     source->mode |= PM_SOURCE_PSFMODEL;
     180    source->mode |= PM_SOURCE_MODE_PSFMODEL;
    181181
    182182    // if the object has fitted peak above saturation, label as SATSTAR
     
    185185    // XXX no extended object can saturate and stay extended...
    186186    if (model->params->data.F32[1] >= SATURATION) {
    187         if (source->mode & PM_SOURCE_PSFSTAR) {
     187        if (source->mode & PM_SOURCE_MODE_PSFSTAR) {
    188188            psLogMsg ("psphot", 5, "PSFSTAR marked SATSTAR\n");
    189189        }
    190         source->mode |=  PM_SOURCE_SATSTAR;
     190        source->mode |=  PM_SOURCE_MODE_SATSTAR;
    191191        return true;
    192192    }
     
    194194    // if the object has a fitted peak below 0, the fit did not converge cleanly
    195195    if (model->params->data.F32[1] <= 0) {
    196         source->mode |= PM_SOURCE_FAIL;
     196        source->mode |= PM_SOURCE_MODE_FAIL;
    197197        return false;
    198198    }
     
    200200    // if the source was predicted to be a SATSTAR, but it fitted below saturation,
    201201    // make a note to the user
    202     if (source->mode & PM_SOURCE_SATSTAR) {
     202    if (source->mode & PM_SOURCE_MODE_SATSTAR) {
    203203        psLogMsg ("psphot", 5, "SATSTAR marked normal (fitted peak below saturation)\n");
    204         source->mode &= ~PM_SOURCE_SATSTAR;
     204        source->mode &= ~PM_SOURCE_MODE_SATSTAR;
    205205    }
    206206    return true;
  • trunk/psphot/src/psphotFitGalaxies.c

    r6379 r6715  
    2323
    2424        // only fit suspected extended sources
    25         if (source->type != PM_SOURCE_EXTENDED) continue;
    26         if (source->mode  & PM_SOURCE_BLEND) continue;
     25        if (source->type != PM_SOURCE_TYPE_EXTENDED) continue;
     26        if (source->mode  & PM_SOURCE_MODE_BLEND) continue;
    2727
    2828        // skip possible extended sources below fit threshold
     
    3232        status = pmSourceMoments (source, EXT_MOMENTS_RAD);
    3333        if (!status) {
    34           source->mode |= PM_SOURCE_FAIL;  // better choice?
     34          source->mode |= PM_SOURCE_MODE_FAIL;  // better choice?
    3535          continue;
    3636        }
     
    4646
    4747        // fit EXT (not PSF) model (set/unset the pixel mask)
    48         psImageKeepCircle (source->mask, x, y, model->radius, "OR", PSPHOT_MASK_MARKED);
     48        psImageKeepCircle (source->mask, x, y, model->radius, "OR", PM_SOURCE_MASK_MARKED);
    4949        pmSourceFitModel (source, model, false);
    50         psImageKeepCircle (source->mask, x, y, model->radius, "AND", ~PSPHOT_MASK_MARKED);
     50        psImageKeepCircle (source->mask, x, y, model->radius, "AND", ~PM_SOURCE_MASK_MARKED);
    5151
    5252        Niter += model[0].nIter;
     
    5555        // check if model fit is acceptable
    5656        if (pmModelFitStatus (model)) {
    57             pmSourceSubModel (source->pixels, source->mask, model, false, false);
    58             source->mode |=  PM_SOURCE_SUBTRACTED;
    59             source->mode &= ~PM_SOURCE_TEMPSUB;
     57            pmModelSub (source->pixels, source->mask, model, false, false);
     58            source->mode |=  PM_SOURCE_MODE_SUBTRACTED;
     59            source->mode &= ~PM_SOURCE_MODE_TEMPSUB;
    6060            Nsub ++;
    6161        }
  • trunk/psphot/src/psphotFitSet.c

    r6571 r6715  
    3232    for (int i = 0; i < modelSet->n; i++) {
    3333        pmModel *model = modelSet->data[i];
    34         pmSourceSubModel (source->pixels, source->mask, model, false, false);
     34        pmModelSub (source->pixels, source->mask, model, false, false);
    3535   
    3636        fprintf (stderr, "output parameters (obj %d):\n", i);
  • trunk/psphot/src/psphotFullFit.c

    r6379 r6715  
    3232        // skip non-astronomical objects (very likely defects)
    3333        // XXX EAM : should we try these anyway?
    34         if (source->mode &  PM_SOURCE_BLEND) continue;
    35         if (source->type == PM_SOURCE_DEFECT) continue;
    36         if (source->type == PM_SOURCE_SATURATED) continue;
     34        if (source->mode &  PM_SOURCE_MODE_BLEND) continue;
     35        if (source->type == PM_SOURCE_TYPE_DEFECT) continue;
     36        if (source->type == PM_SOURCE_TYPE_SATURATED) continue;
    3737
    3838        // save the PSF model from the Ensemble fit
     
    4343
    4444        // replace object in image
    45         pmSourceAddModel (source->pixels, source->mask, modelPSF, false, false);
    46         source->mode &= ~PM_SOURCE_SUBTRACTED;
     45        pmModelAdd (source->pixels, source->mask, modelPSF, false, false);
     46        source->mode &= ~PM_SOURCE_MODE_SUBTRACTED;
    4747
    4848        psphotCheckRadiusPSF (readout, source, modelPSF);
     
    5252
    5353        // fit PSF model (set/unset the pixel mask)
    54         psImageKeepCircle (source->mask, x, y, modelPSF->radius, "OR", PSPHOT_MASK_MARKED);
     54        psImageKeepCircle (source->mask, x, y, modelPSF->radius, "OR", PM_SOURCE_MASK_MARKED);
    5555        pmSourceFitModel (source, modelPSF, true);
    56         psImageKeepCircle (source->mask, x, y, modelPSF->radius, "AND", ~PSPHOT_MASK_MARKED);
     56        psImageKeepCircle (source->mask, x, y, modelPSF->radius, "AND", ~PM_SOURCE_MASK_MARKED);
    5757
    5858        // track model evaluations
     
    6262        // does the PSF model succeed?
    6363        if (psphotEvalPSF (source, source->modelPSF)) {
    64             pmSourceSubModel (source->pixels, source->mask, source->modelPSF, false, false);
    65             source->mode |=  PM_SOURCE_SUBTRACTED;
    66             source->mode &= ~PM_SOURCE_TEMPSUB;
     64            pmModelSub (source->pixels, source->mask, source->modelPSF, false, false);
     65            source->mode |=  PM_SOURCE_MODE_SUBTRACTED;
     66            source->mode &= ~PM_SOURCE_MODE_TEMPSUB;
    6767            psFree (LIN);
    6868            Nsub ++;
     
    8282
    8383        // skip the source if we don't think it is extended
    84         if (source->type != PM_SOURCE_EXTENDED) goto subLINEAR;
     84        if (source->type != PM_SOURCE_TYPE_EXTENDED) goto subLINEAR;
    8585        if (source->moments->SN < EXT_MIN_SN) goto subLINEAR;
    8686
     
    101101
    102102        // fit EXT (not PSF) model (set/unset the pixel mask)
    103         psImageKeepCircle (source->mask, x, y, modelEXT->radius, "OR", PSPHOT_MASK_MARKED);
     103        psImageKeepCircle (source->mask, x, y, modelEXT->radius, "OR", PM_SOURCE_MASK_MARKED);
    104104        pmSourceFitModel (source, modelEXT, false);
    105         psImageKeepCircle (source->mask, x, y, modelEXT->radius, "AND", ~PSPHOT_MASK_MARKED);
     105        psImageKeepCircle (source->mask, x, y, modelEXT->radius, "AND", ~PM_SOURCE_MASK_MARKED);
    106106
    107107        // track model evaluations
     
    111111        // does the EXT model succeed?
    112112        if (psphotEvalEXT (source, source->modelEXT)) {
    113             pmSourceSubModel (source->pixels, source->mask, source->modelEXT, false, false);
    114             source->mode |=  PM_SOURCE_SUBTRACTED;
    115             source->mode &= ~PM_SOURCE_TEMPSUB;
     113            pmModelSub (source->pixels, source->mask, source->modelEXT, false, false);
     114            source->mode |=  PM_SOURCE_MODE_SUBTRACTED;
     115            source->mode &= ~PM_SOURCE_MODE_TEMPSUB;
    116116            psFree (LIN);
    117117            Nsub ++;
     
    123123        psFree (source->modelPSF);
    124124        source->modelPSF = LIN;
    125         pmSourceSubModel (source->pixels, source->mask, source->modelPSF, false, false);
    126         source->mode |= PM_SOURCE_SUBTRACTED;
    127         source->mode |= PM_SOURCE_TEMPSUB;
     125        pmModelSub (source->pixels, source->mask, source->modelPSF, false, false);
     126        source->mode |= PM_SOURCE_MODE_SUBTRACTED;
     127        source->mode |= PM_SOURCE_MODE_TEMPSUB;
    128128        Nsub ++;
    129129    }
  • trunk/psphot/src/psphotGrowthCurve.c

    r6379 r6715  
    1616
    1717    // use center of the image
    18     xc = 0.5*(readout->image->numCols + readout->image->col0);
    19     yc = 0.5*(readout->image->numRows + readout->image->row0);
     18    xc = 0.5*readout->image->numCols + readout->image->col0;
     19    yc = 0.5*readout->image->numRows + readout->image->row0;
    2020    dx = psf->growth->maxRadius + 1;
    2121    dy = psf->growth->maxRadius + 1;
     
    4545        radius = psf->growth->radius->data.F32[i];
    4646
    47         psImageKeepCircle (mask, xc, yc, radius, "OR", PSPHOT_MASK_MARKED);
     47        psImageKeepCircle (mask, xc, yc, radius, "OR", PM_SOURCE_MASK_MARKED);
    4848
    49         pmSourceAddModel (image, mask, model, false, false);
     49        pmModelAdd (image, mask, model, false, false);
    5050
    51         pmSourcePhotometry (&fitMag, &apMag, model, image, mask);
     51        pmSourcePhotometryAper (&apMag, model, image, mask);
    5252
    53         psImageKeepCircle (mask, xc, yc, radius, "AND", ~PSPHOT_MASK_MARKED);
     53        psImageKeepCircle (mask, xc, yc, radius, "AND", ~PM_SOURCE_MASK_MARKED);
    5454
    5555        psf->growth->apMag->data.F32[i] = apMag;
    5656    }
     57    pmSourcePhotometryModel (&fitMag, model);
    5758    psf->growth->fitMag = fitMag;
    5859
  • trunk/psphot/src/psphotImageLoop.c

    r6522 r6715  
    11# include "psphot.h"
    22
    3 bool psphotImageLoop (psphotData *data, ppConfig *config) {
     3// XXX where do we load optional mask and weight input images?
    44
    5     pmFPA *fpa = data->input->fpa;
     5bool psphotImageLoop (pmConfig *config) {
    66
    7     psphotDataIO (data, config, -1, -1);
     7    bool status;
     8    pmChip *chip;
     9    pmCell *cell;
     10    pmReadout *readout;
    811
    9     for (int i = 0; i < fpa->chips->n; i++) {
    10         pmChip *chip = fpa->chips->data[i]; // Chip of interest in input image
     12    pmFPAfile *input = psMetadataLookupPtr (&status, config->files, "PSPHOT.INPUT");
     13    if (!status) {
     14        psErrorStackPrint(stderr, "Can't find input data!\n");
     15        exit(EXIT_FAILURE);
     16    }
    1117
    12         psLogMsg ("psphot", 4, "Chip %d: %x %x\n", i, chip->exists, chip->process);
     18    pmFPAview *view = pmFPAviewAlloc (0);
     19
     20    // files associated with the science image
     21    pmFPAfileIOChecks (config->files, view, PM_FPA_BEFORE);
     22
     23    while ((chip = pmFPAviewNextChip (view, input->fpa, 1)) != NULL) {
     24        psLogMsg ("psphot", 4, "Chip %d: %x %x\n", view->chip, chip->file_exists, chip->process);
    1325        if (! chip->process) { continue; }
     26        if (! chip->file_exists) { continue; }
     27        pmFPAfileIOChecks (config->files, view, PM_FPA_BEFORE);
    1428
    15         psphotDataIO (data, config, i, -1);
    16 
    17         for (int j = 0; j < chip->cells->n; j++) {
    18             pmCell *cell = chip->cells->data[j]; // Cell of interest in input image
    19 
    20             psLogMsg ("psphot", 4, "Cell %d: %x %x\n", j, cell->exists, cell->process);
     29        while ((cell = pmFPAviewNextCell (view, input->fpa, 1)) != NULL) {
     30            continue;
     31            psLogMsg ("psphot", 4, "Cell %d: %x %x\n", view->cell, cell->file_exists, cell->process);
    2132            if (! cell->process) { continue; }
    22 
    23             psphotDataIO (data, config, i, j);
    24 
    25             // XXX optional mask and weight input image should be loaded here?
    26             // this sets the weight map and basic mask applying CELL.BAD and CELL.SATURATION
    27             pmCellSetWeights(cell);
    28 
    29             // I have a valid mask, now mask in the analysis region of interest
    30             pmCellSetMask (cell, config->recipe);
     33            if (! cell->file_exists) { continue; }
     34            pmFPAfileIOChecks (config->files, view, PM_FPA_BEFORE);
    3135
    3236            // process each of the readouts
    33             for (int k = 0; k < cell->readouts->n; k++) {
    34                 pmReadout *readout = cell->readouts->data[k]; // Readout of interest in input image
     37            while ((readout = pmFPAviewNextReadout (view, input->fpa, 1)) != NULL) {
     38                pmFPAfileIOChecks (config->files, view, PM_FPA_BEFORE);
     39                if (! readout->data_exists) { continue; }
    3540
    3641                // run a single-model test if desired
    37                 psphotModelTest (readout, config->arguments, config->recipe);
     42                // XXX move this to psphotReadout??
     43                // psphotModelTest (readout, recipe);
    3844
    3945                // run the actual photometry analysis
    40                 psphotReadout (readout, data, config);
     46                psphotReadout (config, view);
    4147
    42                 // XXX what do we do if we have multiple readouts?
    43                 psphotOutput (readout, data, config);
     48                pmFPAfileIOChecks (config->files, view, PM_FPA_AFTER);
     49
     50                // write out the desired output dataset(s)
     51                // psphotOutput (view, recipe);
    4452            }
    45         }
     53            pmFPAfileIOChecks (config->files, view, PM_FPA_AFTER);
     54        }
     55        pmFPAfileIOChecks (config->files, view, PM_FPA_AFTER);
    4656    }
    47     psphotOutputClose (data);
     57    pmFPAfileIOChecks (config->files, view, PM_FPA_AFTER);
     58
     59    psFree (view);
    4860    return true;
    4961}
     62
     63// I/O files related to psphot:
     64// PSPHOT.INPUT   : input image file(s)
     65// PSPHOT.RESID   : residual image
     66// PSPHOT.OUTPUT  : output object tables (object)
     67
     68// PSPHOT.BACKSUB : background subtracted image
     69// PSPHOT.BACKGND : background model (full-scale image?)
     70// PSPHOT.BACKMDL : background model (binned image?)
     71// PSPHOT.PSF     : sample PSF images
     72
     73
     74/**
     75
     76filename | pmFPAfile  | pmFPA  | pmFPAview
     77chip00.f | PSPHOT.IN  | input  | view
     78chip01.f | PSPHOT.IN  | input  | view
     79chip02.f | PSPHOT.IN  | input  | view
     80chip03.f | PSPHOT.IN  | input  | view
     81
     82out00.f  | PSPHOT.OUT | input  | view
     83out01.f  | PSPHOT.OUT | input  | view
     84out02.f  | PSPHOT.OUT | input  | view
     85out03.f  | PSPHOT.OUT | input  | view
     86
     87obj00.f  | PSPHOT.OBJ | input  | view
     88obj01.f  | PSPHOT.OBJ | input  | view
     89obj02.f  | PSPHOT.OBJ | input  | view
     90obj03.f  | PSPHOT.OBJ | input  | view
     91
     92bin00.f  | PSPHOT.BIN | binned | view
     93bin01.f  | PSPHOT.BIN | binned | view
     94bin02.f  | PSPHOT.BIN | binned | view
     95bin03.f  | PSPHOT.BIN | binned | view
     96
     97mosaic.f | PSPHOT.MOS | mosaic | view
     98
     99**/
  • trunk/psphot/src/psphotImageMedian.c

    r6571 r6715  
    1111// generate the median in NxN boxes, clipping heavily
    1212// linear interpolation to generate full-scale model
    13 psImage *psphotImageMedian (psMetadata *config, pmFPAview *view)
     13bool psphotImageMedian (pmConfig *config, pmFPAview *view)
    1414{
    1515    bool status;
     
    2121    // find the currently selected readout
    2222    psMetadata *recipe  = psMetadataLookupPtr (&status, config->recipes, "PSPHOT");
    23     pmFPA *input = psMetadataLookupPtr (&status, config->files, "PSPHOT.INPUT");
    24     pmReadout  *readout = pmFPAviewThisReadout (view, input);
     23    pmFPAfile  *input  = psMetadataLookupPtr (&status, config->files, "PSPHOT.INPUT");
     24    pmReadout  *readout = pmFPAviewThisReadout (view, input->fpa);
    2525
    2626    psImage *image = readout->image;
     
    2828
    2929    rnd = psRandomAlloc (PS_RANDOM_TAUS, 0);
    30     MAX_SAMPLE_PIXELS = psMetadataLookupF32 (&status, config, "IMSTATS_NPIX");
     30    MAX_SAMPLE_PIXELS = psMetadataLookupF32 (&status, recipe, "IMSTATS_NPIX");
    3131    if (!status) MAX_SAMPLE_PIXELS = 1000;
    3232
     
    3636
    3737    // scaling factor
    38     int DX = psMetadataLookupS32 (&status, config, "BACKGROUND_XBIN");
     38    int DX = psMetadataLookupS32 (&status, recipe, "BACKGROUND_XBIN");
    3939    if (!status) {DX = 64;}
    40     int DY = psMetadataLookupS32 (&status, config, "BACKGROUND_YBIN");
     40    int DY = psMetadataLookupS32 (&status, recipe, "BACKGROUND_YBIN");
    4141    if (!status) {DY = 64;}
    4242
     
    7979
    8080    // select background pixels, from output background file, or create
    81     background = pmFPAfileReadoutImage (config->files, view, "PSPHOT.BACKGND", Nx, Ny, PS_TYPE_F32);
     81    psImage *background = pmFPAfileReadoutImage (config->files, view, "PSPHOT.BACKGND", Nx, Ny, PS_TYPE_F32);
    8282
    8383    // XXX this code skips the initial pixels
     
    212212
    213213    // back-sub image pixels, from output background file (don't create if not requested)
    214     backSub = pmFPAfileReadoutImage (config->files, view, "PSPHOT.BACKSUB", 0, 0, PS_TYPE_F32);
     214    psImage *backSub = pmFPAfileReadoutImage (config->files, view, "PSPHOT.BACKSUB", 0, 0, PS_TYPE_F32);
    215215
    216216    // subtract the background model
  • trunk/psphot/src/psphotMagnitudes.c

    r6571 r6715  
    11# include "psphot.h"
    22
    3 bool psphotMagnitudes (psMetadata *config, psArray *sources, pmPSF *psf) {
     3bool psphotMagnitudes (psArray *sources, psMetadata *config, pmPSF *psf) {
    44
    55    bool status;
  • trunk/psphot/src/psphotModelTest.c

    r6571 r6715  
    8484    pmSource *source = pmSourceAlloc();
    8585    source->peak = pmPeakAlloc (xObj, yObj, 0, 0);
    86     psphotDefinePixels (source, readout, xObj, yObj, OUTER);
     86    pmSourceDefinePixels (source, readout, xObj, yObj, OUTER);
    8787
    8888    // find the local sky
     
    170170
    171171    // subtract object, leave local sky
    172     pmSourceSubModel (source->pixels, source->mask, model, false, false);
     172    pmModelSub (source->pixels, source->mask, model, false, false);
    173173   
    174174    fprintf (stderr, "output parameters: \n");
  • trunk/psphot/src/psphotOutput.c

    r6571 r6715  
    11# include "psphot.h"
    22
     3# if (0)
    34// output functions: we have several fixed modes (sx, obj, cmp)
    45void psphotOutput (pmReadout *readout, psMetadata *arguments) {
     
    2122}
    2223
    23 int psphotSaveImage (psMetadata *header, psImage *image, char *filename) {
    24 
    25     psFits *fits = psFitsOpen (filename, "w");
    26     psFitsWriteImage (fits, NULL, image, 0);
    27     psFitsClose (fits);
    28     return (TRUE);
    29 }
    30 
    3124psImage *pmModelPSFatXY (psImage *image, pmModel *modelEXT, pmPSF *psf, int x, int y, int dx, int dy) {
    3225
     
    3831    modelEXT->params->data.F32[3] = y;
    3932    pmModel *modelPSF = pmModelFromPSF (modelEXT, psf);
    40     pmSourceAddModel (sample, NULL, modelPSF, false, false);
     33    pmModelAdd (sample, NULL, modelPSF, false, false);
    4134    psFree (modelPSF);
    4235    return (sample);
     
    6962    psFitsWriteImage (fits, NULL, sample, 0);
    7063
     64    psFitsClose (fits);
     65    return (TRUE);
     66}
     67# endif
     68
     69int psphotSaveImage (psMetadata *header, psImage *image, char *filename) {
     70
     71    psFits *fits = psFitsOpen (filename, "w");
     72    psFitsWriteImage (fits, NULL, image, 0, NULL);
    7173    psFitsClose (fits);
    7274    return (TRUE);
  • trunk/psphot/src/psphotParseCamera.c

    r6571 r6715  
    11# include "psphot.h"
    2 
    3 # define METADATA_ADD_DEFAULT(CONFIG, TYPE, NAME, VALUE, COMMENT)\
    4     { psMetadataItem *ITEM; \
    5       ITEM = psMetadataLookup (CONFIG, NAME); \
    6       if (ITEM == NULL) { \
    7         psMetadataAdd##TYPE (CONFIG, PS_LIST_TAIL, NAME, 0, COMMENT, VALUE); \
    8       } }
    92
    103bool psphotParseCamera (pmConfig *config) {
    114
     5    bool status;
     6    psFits *fits = NULL;
     7    psMetadata *phu = NULL;
     8    psMetadata *format = NULL;
     9
    1210    // psphot is supplied with a list of input images (may be only one image)
    13     psArray *infiles = psMetadataLookupPtr(NULL, config->arguments, "INPUT");
     11    psArray *infiles = psMetadataLookupPtr(&status, config->arguments, "INPUT");
     12    if (!status) psAbort (__func__, "missing INPUT entry");
    1413    if (infiles->n < 1) psAbort (__func__, "empty input list");
    1514
    1615    // if no camera has been specified, use the first image as a template for the rest.
    1716    if (config->camera == NULL) {
    18         psFits *fits = psFitsOpen (infiles->data[0], "r");
    19         psMetadata *phu = psFitsReadHeader (NULL, fits);
    20         config->camera = pmConfigCameraFromHeader (config->site, phu);
     17        fits = psFitsOpen (infiles->data[0], "r");
     18        phu = psFitsReadHeader (NULL, fits);
     19        format = pmConfigCameraFormatFromHeader (config, phu);
    2120        psFitsClose (fits);
    22         psFree (phu);
    2321    }
    2422    // There's no point in continuing if we can't recognize what we've got
     
    2826    }
    2927
    30     // XXX place the "data" element on the pmConfig structure?
     28    // files
    3129    config->files = psMetadataAlloc ();
    3230
    3331    // build the template fpa, set up the basic view
    34     pmFPA *input = pmFPAConstruct (camera);
     32    // XXX : 216 leaks in pmFPAConstruct / psFree (input)
     33    pmFPA *input = pmFPAConstruct (config->camera);
    3534
    3635    // assign the I/O files (potentially) needed by psphot
    37     pmFPAfile *file = pmFPAfileDefine (config->files, camera, input, "PSPHOT.INPUT");
     36    // the output file is just a view to the file on config->files
     37    pmFPAfile *file = pmFPAfileDefine (config->files, format, input, "PSPHOT.INPUT");
     38    if (!file) {
     39        exit(EXIT_FAILURE);
     40    }
    3841
    39     pmFPAview *view = pmFPAviewAlloc (input, config->camera, 0);
    4042    for (int i = 0; i < infiles->n; i++) {
    41         // XXX save the phu from above?
    42         psFits *fits = psFitsOpen (infiles->data[i], "r");
    43         psMetadata *phu = psFitsReadHeader (NULL, fits);
    44         pmConfigValidateCamera (config->camera, phu);
     43        if (phu == NULL) {
     44            fits = psFitsOpen (infiles->data[i], "r");
     45            phu = psFitsReadHeader (NULL, fits);
     46            pmConfigValidateCameraFormat (format, phu);
     47            psFitsClose (fits);
     48        }
    4549
    4650        // set the view to the corresponding entry for this phu
    47         // XXX should I save the phu data at the appropriate location in the fpa?
    48         pmFPAsetView (view, phu);
     51        pmFPAview *view = pmFPAAddSource (input, phu, format);
    4952
    5053        // XXX is this the correct psMD to save the filename?
    51         name = pmFPAviewNameFromRule (file->filextra, view);
     54        char *name = pmFPAfileNameFromRule (file->filextra, file, view);
    5255        psMetadataAddStr (file->names, PS_LIST_TAIL, name, 0, "", infiles->data[i]);
     56
     57        psFree (view);
     58        psFree (name);
     59        psFree (phu);
     60        phu = NULL;
    5361    }
    54     pmFPAfileDefine (config->files, camera, input, "PSPHOT.OUTPUT");
    55     pmFPAfileDefine (config->files, camera, input, "PSPHOT.RESID");
    56     pmFPAfileDefine (config->files, camera, input, "PSPHOT.PSF_INPUT");
    57     pmFPAfileDefine (config->files, camera, input, "PSPHOT.PSF_OUTPUT");
     62
     63    pmFPAfileDefine (config->files, format, input, "PSPHOT.OUTPUT");
     64
     65    // pmFPAfileDefine (config->files, format, input, "PSPHOT.RESID");
     66    // pmFPAfileDefine (config->files, format, input, "PSPHOT.PSF_INPUT");
     67    // pmFPAfileDefine (config->files, format, input, "PSPHOT.PSF_OUTPUT");
    5868
    5969    // build the template fpa, set up the basic view
    6070    // supply the backgnd with a different camera?
    61     pmFPAfileDefine (config->files, camera, NULL, "PSPHOT.BACKSUB");
    62     pmFPAfileDefine (config->files, camera, NULL, "PSPHOT.BACKGND");
    63     pmFPAfileDefine (config->files, camera, NULL, "PSPHOT.BACKMDL");
    64     pmFPAfileDefine (config->files, camera, NULL, "PSPHOT.PSF_SAMPLE");
     71    // allow alternate format?
     72    // pmFPAfileConstruct (config->files, format, config->camera, "PSPHOT.BACKSUB");
     73    // pmFPAfileConstruct (config->files, format, config->camera, "PSPHOT.BACKGND");
     74    // pmFPAfileConstruct (config->files, format, config->camera, "PSPHOT.BACKMDL");
     75    // pmFPAfileConstruct (config->files, format, config->camera, "PSPHOT.PSF_SAMPLE");
     76
     77    // psphot is supplied with the output name
     78    char *output = psMetadataLookupPtr(&status, config->arguments, "OUTPUT");
     79    file = psMetadataLookupPtr (&status, config->files, "PSPHOT.OUTPUT");
     80    if (!status) psAbort (__func__, "missing OUTPUT entry");
     81    psMetadataAddStr (file->names, PS_LIST_TAIL, "OUTPUT", 0, "", output);
    6582
    6683    // recipe override values (command-line options):
    67     psMetadata *options = psMetadataLookupPtr (status, config->arguments, "PSPHOT.OPTIONS");
    68     psMetadata *recipe = psMetadataLookupPtr (status, config->recipes, "PSPHOT");
     84    psMetadata *options = psMetadataLookupPtr (&status, config->arguments, "PSPHOT.OPTIONS");
     85    psMetadata *recipe = psMetadataLookupPtr (&status, config->recipes, "PSPHOT");
    6986    psMetadataIterator *iter = psMetadataIteratorAlloc (options, PS_LIST_HEAD, NULL);
    70     while ((psMetadataItem *item = psMetadataGetAndIncrement (iter)) != NULL) {
     87    psMetadataItem *item = NULL;
     88    while ((item = psMetadataGetAndIncrement (iter)) != NULL) {
    7189        psMetadataAddItem (recipe, item, PS_LIST_TAIL, PS_META_REPLACE);
    7290    }
     
    7492
    7593    // set default recipe values here
    76     // XXX this needs re-thinking...
    77     METADATA_ADD_DEFAULT (recipe, Str, "FITMODE",     "NONE", "");
    78     METADATA_ADD_DEFAULT (recipe, Str, "PHOTCODE",    "NONE", "");
    79     METADATA_ADD_DEFAULT (recipe, Str, "BREAK_POINT", "NONE", "");
     94    psMetadataAddStr (recipe, PS_LIST_TAIL, "FITMODE", PS_META_NO_REPLACE, "default fitting mode", "NONE");
     95    psMetadataAddStr (recipe, PS_LIST_TAIL, "PHOTCODE", PS_META_NO_REPLACE, "default photcode", "NONE");
     96    psMetadataAddStr (recipe, PS_LIST_TAIL, "BREAK_POINT", PS_META_NO_REPLACE, "default break point", "NONE");
    8097
    8198    // Chip selection: if we are using a single chip, select it for each FPA
    8299    // Chip numbers to work on: -chip 1,2,3,5,8,10
     100    # if (0)
    83101    char *chips = psMetadataLookupStr(NULL, config->arguments, "CHIP_SELECTIONS");
    84102    if (chips != NULL) {
     
    102120        }
    103121    }
     122    # endif
     123
     124    psFree (input);
     125    psFree (format);
     126
    104127    psTrace(__func__, 1, "Done with psphotParseCamera...\n");
    105128    return true;
  • trunk/psphot/src/psphotRadiusChecks.c

    r6481 r6715  
    2626    if (isnan(model->radius)) psAbort ("apply_psf_model", "error in radius");
    2727       
    28     if (source->mode &  PM_SOURCE_SATSTAR) {
     28    if (source->mode &  PM_SOURCE_MODE_SATSTAR) {
    2929        model->radius *= 2;
    3030    }
    3131
    32     bool status = psphotRedefinePixels (source, readout, model->params->data.F32[2], model->params->data.F32[3], model->radius);
     32    bool status = pmSourceRedefinePixels (source, readout, model->params->data.F32[2], model->params->data.F32[3], model->radius);
    3333    return status;
    3434}
     
    4343    if (isnan(model->radius)) psAbort ("apply_psf_model", "error in radius");
    4444       
    45     if (source->mode &  PM_SOURCE_SATSTAR) {
     45    if (source->mode &  PM_SOURCE_MODE_SATSTAR) {
    4646        model->radius *= 2;
    4747    }
    4848
    49     bool status = psphotRedefinePixels (source, readout, model->params->data.F32[2], model->params->data.F32[3], model->radius);
     49    bool status = pmSourceRedefinePixels (source, readout, model->params->data.F32[2], model->params->data.F32[3], model->radius);
    5050    return status;
    5151}
     
    7777
    7878    // redefine the pixels if needed
    79     bool status = psphotRedefinePixels (source, readout, model->params->data.F32[2], model->params->data.F32[3], model->radius);
     79    bool status = pmSourceRedefinePixels (source, readout, model->params->data.F32[2], model->params->data.F32[3], model->radius);
    8080    return status;
    8181}
  • trunk/psphot/src/psphotReadout.c

    r6571 r6715  
    1212    // find the currently selected readout
    1313    psMetadata *recipe  = psMetadataLookupPtr (&status, config->recipes, "PSPHOT");
    14     pmFPA *input = psMetadataLookupPtr (&status, config->files, "PSPHOT.INPUT");
    15     pmReadout  *readout = pmFPAviewThisReadout (view, input);
     14    pmFPAfile  *input   = psMetadataLookupPtr (&status, config->files, "PSPHOT.INPUT");
     15    pmReadout  *readout = pmFPAviewThisReadout (view, input->fpa);
     16
     17    sources = psphotFakeSources();
     18    status = psMetadataAdd (readout->analysis, PS_LIST_TAIL, "PSPHOT.SOURCES",   PS_DATA_ARRAY,   "psphot sources", sources);
     19    psFree (sources);
     20    return true;
     21
     22    // XXX does this need to invoke I/O?
     23    pmReadoutSetWeights (readout);
     24
     25    // I have a valid mask, now mask in the analysis region of interest
     26    psphotMaskReadout (readout, recipe);
    1627
    1728    // generate a background model (median, smoothed image)
     
    5869    // update the header with stats results
    5970    // XXX need to do this conditionally?
    60     psMetadata *header = pmReadoutGetHeader (readout);
    61     psphotUpdateHeader (header, config);
     71    // XXX psMetadata *header = pmReadoutGetHeader (readout);
     72    // XXX psphotUpdateHeader (header, config);
    6273
    6374    // XXX make this an option?
     
    99110    }
    100111
     112
     113
     114    psphotSaveImage (NULL, readout->image,  "pixels.fits");
     115    psphotSaveImage (NULL, readout->weight, "weight.fits");
     116    psphotSaveImage (NULL, readout->mask,   "mask.fits");
     117    exit (1);
     118
    101119# endif
  • trunk/psphot/src/psphotReplaceUnfit.c

    r5993 r6715  
    1010      source = sources->data[i];
    1111
    12         if (!(source->mode & PM_SOURCE_TEMPSUB)) continue;
     12        if (!(source->mode & PM_SOURCE_MODE_TEMPSUB)) continue;
    1313        if (source->modelPSF == NULL) continue;
    1414
    15         pmSourceAddModel (source->pixels, source->mask, source->modelPSF, false, false);
    16         source->mode &= ~PM_SOURCE_SUBTRACTED;
    17         source->mode &= ~PM_SOURCE_TEMPSUB;
     15        pmModelAdd (source->pixels, source->mask, source->modelPSF, false, false);
     16        source->mode &= ~PM_SOURCE_MODE_SUBTRACTED;
     17        source->mode &= ~PM_SOURCE_MODE_TEMPSUB;
    1818    }
    1919    psLogMsg ("psphot.replace", 3, "replace unfitted models: %f sec (%d objects)\n", psTimerMark ("psphot"), sources->n);
  • trunk/psphot/src/psphotSkyReplace.c

    r6571 r6715  
    22
    33// in order to  successfully replace the sky, we must define a corresponding file...
    4 bool psphotSkyReplace (psMetadata *config, pmFPAview *view) {
     4bool psphotSkyReplace (pmConfig *config, pmFPAview *view) {
     5
     6    bool status;
    57
    68    // find the currently selected readout
    7     psMetadata *recipe  = psMetadataLookupPtr (&status, config->recipes, "PSPHOT");
    8     pmFPA *input = psMetadataLookupPtr (&status, config->files, "PSPHOT.INPUT");
    9     pmReadout  *readout = pmFPAviewThisReadout (view, input);
     9    //  psMetadata *recipe  = psMetadataLookupPtr (&status, config->recipes, "PSPHOT");
     10    pmFPAfile *input  = psMetadataLookupPtr (&status, config->files, "PSPHOT.INPUT");
     11    pmReadout *readout = pmFPAviewThisReadout (view, input->fpa);
    1012
    1113    // select the corresponding images
     
    1416
    1517    // select background pixels, from output background file, or create
    16     background = pmFPAfileReadoutImage (config->files, view, "PSPHOT.BACKGND", 0, 0, PS_TYPE_F32);
     18    psImage *background = pmFPAfileReadoutImage (config->files, view, "PSPHOT.BACKGND", 0, 0, PS_TYPE_F32);
    1719    if (background == NULL) {
    1820        return false;
  • trunk/psphot/src/psphotSourceFits.c

    r6481 r6715  
    11# include "psphot.h"
    2 # include "psEllipse.h"
    32
    43// given a source with an existing modelPSF, attempt a full PSF fit, subtract if successful
     
    1817
    1918    // fit PSF model (set/unset the pixel mask)
    20     psImageKeepCircle (source->mask, x, y, PSF->radius, "OR", PSPHOT_MASK_MARKED);
     19    psImageKeepCircle (source->mask, x, y, PSF->radius, "OR", PM_SOURCE_MASK_MARKED);
    2120    pmSourceFitModel (source, PSF, true);
    22     psImageKeepCircle (source->mask, x, y, PSF->radius, "AND", ~PSPHOT_MASK_MARKED);
     21    psImageKeepCircle (source->mask, x, y, PSF->radius, "AND", ~PM_SOURCE_MASK_MARKED);
    2322
    2423    // does the PSF model succeed?
     
    2928
    3029    psTrace ("psphot.blend", 5, "fitted as PSF\n");
    31     pmSourceSubModel (source->pixels, source->mask, PSF, false, false);
     30    pmModelSub (source->pixels, source->mask, PSF, false, false);
    3231
    3332    // free old model, save new model
     
    3534    source->modelPSF = PSF;
    3635
    37     source->mode |=  PM_SOURCE_SUBTRACTED;
    38     source->mode &= ~PM_SOURCE_TEMPSUB;
     36    source->mode |=  PM_SOURCE_MODE_SUBTRACTED;
     37    source->mode &= ~PM_SOURCE_MODE_TEMPSUB;
    3938    return true;
    4039}
     
    6766
    6867    // skip the source if we don't think it is extended
    69     if (source->type == PM_SOURCE_UNKNOWN) return false;
    70     if (source->type == PM_SOURCE_DEFECT) return false;
    71     if (source->type == PM_SOURCE_SATURATED) return false;
     68    if (source->type == PM_SOURCE_TYPE_UNKNOWN) return false;
     69    if (source->type == PM_SOURCE_TYPE_DEFECT) return false;
     70    if (source->type == PM_SOURCE_TYPE_SATURATED) return false;
    7271    if (source->moments->SN < EXT_MIN_SN) return false;
    7372
     
    110109    // sub EXT
    111110    psFree (DBL);
    112     pmSourceSubModel (source->pixels, source->mask, EXT, false, false);
     111    pmModelSub (source->pixels, source->mask, EXT, false, false);
    113112    psTrace ("psphot.blend", 5, "blob as EXT: %f %f\n", EXT->params->data.F32[2], EXT->params->data.F32[3]);
    114113
    115114    // save new model
    116115    source->modelEXT = EXT;
    117     source->mode |=  PM_SOURCE_SUBTRACTED;
    118     source->mode &= ~PM_SOURCE_TEMPSUB;
     116    source->mode |=  PM_SOURCE_MODE_SUBTRACTED;
     117    source->mode &= ~PM_SOURCE_MODE_TEMPSUB;
    119118    return true;
    120119
     
    122121    // sub DLB
    123122    psFree (EXT);
    124     pmSourceSubModel (source->pixels, source->mask, (pmModel *) DBL->data[0], false, false);
    125     pmSourceSubModel (source->pixels, source->mask, (pmModel *) DBL->data[1], false, false);
     123    pmModelSub (source->pixels, source->mask, (pmModel *) DBL->data[0], false, false);
     124    pmModelSub (source->pixels, source->mask, (pmModel *) DBL->data[1], false, false);
    126125    psTrace ("psphot.blend", 5, "blob as DBL: %f %f\n", ONE->params->data.F32[2], ONE->params->data.F32[3]);
    127126
     
    129128    psFree (source->modelPSF);
    130129    source->modelPSF = psMemCopy (DBL->data[0]);
    131     source->mode    |= PM_SOURCE_SUBTRACTED;
    132     source->mode    |= PM_SOURCE_PAIR;
    133     source->mode    &= ~PM_SOURCE_TEMPSUB;
     130    source->mode    |= PM_SOURCE_MODE_SUBTRACTED;
     131    source->mode    |= PM_SOURCE_MODE_PAIR;
     132    source->mode    &= ~PM_SOURCE_MODE_TEMPSUB;
    134133
    135134    // copy most data from the primary source (modelEXT, blends stay NULL)
     
    155154    pmModel *DBL;
    156155    pmModel *PSF;
    157     EllipseAxes axes;
    158     EllipseMoments moments;
     156    psEllipseAxes axes;
     157    psEllipseMoments moments;
    159158    psArray *modelSet;
    160159   
     
    163162    moments.y2 = source->moments->Sy;
    164163    moments.xy = source->moments->Sxy;
    165     axes = EllipseMomentsToAxes (moments);
     164    axes = psEllipseMomentsToAxes (moments);
    166165
    167166    dx = 2 * cos (axes.theta);
     
    190189
    191190    // fit EXT (not PSF) model (set/unset the pixel mask)
    192     psImageKeepCircle (source->mask, x, y, PSF->radius, "OR", PSPHOT_MASK_MARKED);
     191    psImageKeepCircle (source->mask, x, y, PSF->radius, "OR", PM_SOURCE_MASK_MARKED);
    193192    pmSourceFitSet (source, modelSet, true);
    194     psImageKeepCircle (source->mask, x, y, PSF->radius, "AND", ~PSPHOT_MASK_MARKED);
     193    psImageKeepCircle (source->mask, x, y, PSF->radius, "AND", ~PM_SOURCE_MASK_MARKED);
    195194
    196195    return (modelSet);
     
    210209
    211210    // fit EXT (not PSF) model (set/unset the pixel mask)
    212     psImageKeepCircle (source->mask, x, y, EXT->radius, "OR", PSPHOT_MASK_MARKED);
     211    psImageKeepCircle (source->mask, x, y, EXT->radius, "OR", PM_SOURCE_MASK_MARKED);
    213212    pmSourceFitModel (source, EXT, false);
    214     psImageKeepCircle (source->mask, x, y, EXT->radius, "AND", ~PSPHOT_MASK_MARKED);
     213    psImageKeepCircle (source->mask, x, y, EXT->radius, "AND", ~PM_SOURCE_MASK_MARKED);
    215214
    216215    return (EXT);
     
    222221
    223222    // if this source is not a possible blend, just fit as PSF
    224     if ((source->blends == NULL) || (source->mode & PM_SOURCE_SATSTAR)) {
     223    if ((source->blends == NULL) || (source->mode & PM_SOURCE_MODE_SATSTAR)) {
    225224        bool status = psphotFitPSF (readout, source);
    226225        return status;
     
    273272
    274273    // fit PSF model (set/unset the pixel mask)
    275     psImageKeepCircle (source->mask, x, y, PSF->radius, "OR", PSPHOT_MASK_MARKED);
     274    psImageKeepCircle (source->mask, x, y, PSF->radius, "OR", PM_SOURCE_MASK_MARKED);
    276275    pmSourceFitSet (source, modelSet, true);
    277     psImageKeepCircle (source->mask, x, y, PSF->radius, "AND", ~PSPHOT_MASK_MARKED);
     276    psImageKeepCircle (source->mask, x, y, PSF->radius, "AND", ~PM_SOURCE_MASK_MARKED);
    278277
    279278    // evaluate the blend objects, subtract if good, free otherwise
     
    291290
    292291        psTrace ("psphot.blend", 5, "fitted blend as PSF\n");
    293         pmSourceSubModel (source->pixels, source->mask, model, false, false);
    294         src->mode |=  PM_SOURCE_SUBTRACTED;
    295         src->mode &= ~PM_SOURCE_TEMPSUB;
     292        pmModelSub (source->pixels, source->mask, model, false, false);
     293        src->mode |=  PM_SOURCE_MODE_SUBTRACTED;
     294        src->mode &= ~PM_SOURCE_MODE_TEMPSUB;
    296295    }
    297296    psFree (modelSet);
     
    305304
    306305    psTrace ("psphot.blend", 5, "fitted primary as PSF\n");
    307     pmSourceSubModel (source->pixels, source->mask, PSF, false, false);
     306    pmModelSub (source->pixels, source->mask, PSF, false, false);
    308307    psFree (source->modelPSF);
    309308    source->modelPSF = PSF;
    310     source->mode |=  PM_SOURCE_SUBTRACTED;
    311     source->mode &= ~PM_SOURCE_TEMPSUB;
    312     return true;
    313 }
     309    source->mode |=  PM_SOURCE_MODE_SUBTRACTED;
     310    source->mode &= ~PM_SOURCE_MODE_TEMPSUB;
     311    return true;
     312}
  • trunk/psphot/src/psphotSourceStats.c

    r6495 r6715  
    2525
    2626        // allocate image, weight, mask arrays for each peak (square of radius OUTER)
    27         psphotDefinePixels (source, readout, source->peak->x, source->peak->y, OUTER);
     27        pmSourceDefinePixels (source, readout, source->peak->x, source->peak->y, OUTER);
    2828
    2929        // XXX skip faint sources?
Note: See TracChangeset for help on using the changeset viewer.