IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 4954


Ignore:
Timestamp:
Sep 6, 2005, 5:33:01 PM (21 years ago)
Author:
eugene
Message:

psphot reorganization: merged in pmObjects code from psModule, modified to work with psLib 0.7.0

Location:
trunk/psphot
Files:
12 added
3 deleted
21 edited

Legend:

Unmodified
Added
Removed
  • trunk/psphot/Makefile

    r4946 r4954  
    1414
    1515INCS    =       $(IPSLIB)
    16 LIBS    =       -lpsmodule $(LPSLIB)
    17 CFLAGS  =       $(INCS) -std=c99
     16# LIBS  =       -lpsmodule $(LPSLIB)
     17LIBS    =       $(LPSLIB)
     18CFLAGS  =       $(INCS) -std=c99 -Wall -Werror
    1819LFLAGS  =       $(LIBS)
    1920
     
    3031$(SRC)/psphotMarkPSF.$(ARCH).o     \
    3132$(SRC)/psphotSubtractPSF.$(ARCH).o \
     33$(SRC)/psphotSortBySN.$(ARCH).o    \
    3234$(SRC)/pspsf.$(ARCH).o             \
    3335$(SRC)/psLibUtils.$(ARCH).o        \
     
    3941$(SRC)/psMinimize.$(ARCH).o        \
    4042$(SRC)/psImageData.$(ARCH).o       \
    41 $(SRC)/psphotSortBySN.$(ARCH).o
     43$(SRC)/psEllipse.$(ARCH).o         \
     44$(SRC)/pmModelInit.$(ARCH).o       \
     45$(SRC)/pmObjects_EAM.$(ARCH).o
    4246
    4347FITSOURCE = \
  • trunk/psphot/doc/notes.txt

    r4947 r4954  
    11
    22Notes on psphot
     3
     42005.09.06
     5
     6  I have built a working version of PSPhot using my own copy of the
     7  pmObjects.[ch] files.  I need to minimize the difference between the
     8  v0.7.0, v0.5.0, and my own version of pmObjects.c
     9
     10  changes v0.5.0 / v0.7.0 / EAM
     11  - changed all ps* to pm*
     12  - fixed naming for local static functions (eg modelFree not p_psModelFree)
     13  - dropped all hard-coded model names (vs v0.7.0)
     14  - using current psMemSetDellocator name
     15  - added noise image to pmSource
     16  - converted old asserts to new asserts (PS_.._CHECK..)
     17  - add return from error in pmFindImagePeaks
     18  - allow isItInThisRegion to have NULL region (true)
     19  - fixed subImages to correspond to region definition (end is
     20    exclusive) in LocalSky and SetPixelCircle
     21  - dropped old, redundant code in pmSourceLocalSky
     22  - fixed pmSourceMoments use of mask (0 is valid, not 1)
     23  - added pmSourceMoments validity tests (numPixels, Sum, centroid shift)
     24  - added correction for Sxy (XY/Sum - x*y)
     25  - added pmSourcePSFClump function (and pmPSFClump structure)
     26  - allow missing sources in pmSourcePSFClump (not all peaks yield
     27    sources)
     28  - moved pmSourceRoughClass metadata lookups out of inner loop
     29  - added saturated pixel test using pmImageCountPixelMask
     30  - various redefinitions of initial classes
     31  - dropped old, redundant code in pmSourceSetPixelsCircle
     32  - mask image set to type psU8 (was psF32)
     33  - abstract object model functions for pmSourceModelGuess
     34  - converted evalModel to a public function psModelEval, modified params
     35  - pmSourceFitModel operates on a specified model
     36  - pmSourceFitModel had option to apply/ignore PSF information
     37  - pmSourceFitModel calculates yErr
     38  - pmSourceFitModel calculates the covariance matrix
     39  - added paramMask to pmSourceFitModel
     40  - pmSourceFitModel_EAM uses covar to carry in beta and param
     41    limits...
     42  - pmSourceFitModel requires solution to stay within image
     43  - pmSourceFitModel calculates and saves chisq, nIter, nDOF
     44  - pmSourceFitModel uses GaussNewtonDelta for frozen params
     45  - added mask to pmSourceAdd, pmSourceSub
     46  - model abstractions in pmSourceAdd, pmSourceSub
     47  - fixed 'center' option in pmSourceAdd/Sub
     48
     49  - pmSourceFitModel calculates sqrt(var), psMinimize calculates sq(sqrt(var))
     50  - pmSourceContour is using the model flux, not the image flux
     51  - does psImageAlloc zero the image?  if so, drop init routine
     52    from pmSourcePSFClump
     53  - pmSourceRoughClass uses RDNOISE, GAIN to calculate SN: should use
     54    the source->noise image? part of pmSourceMoments?
     55  - pmSourceMoments_EAM uses macro for checkRegion
     56  - pmObjects_EAM.c uses some hardcoded mask values (LocalSky)
     57  - why does LocalSky_EAM not need subImageMask->col0 = subImage->col0??
     58  - psGetRowVectorFromImage should be in psLib (in psLibUtils)
     59  - pmSourceSetPixelsCircle and pmSourceLocalSky probably could use
     60    the psImageMaskRegion, etc functions.
     61  - pmSourceSetPixelsCircle uses a hard-coded mask value
     62  -
    363
    4642005.09.05
  • trunk/psphot/doc/psphot.txt

    r4115 r4954  
    11
    2 psphot is a stand-alone program which implements the Pan-STARRS IPP
    3 object detection and analysis functions for using with individual
    4 images. 
     2Defined APIs:
    53
     4pmMoments           *pmMomentsAlloc();
     5pmModel             *pmModelAlloc();
     6pmSource            *pmSourceAlloc();
     7psVector            *pmFindVectorPeaks()
     8psArray             *pmFindImagePeaks()
     9psList              *pmCullPeaks()
     10pmSource            *pmSourceLocalSky()
     11bool                 pmSourceMoments()
     12pmPSFClump           pmSourcePSFClump()
     13bool                 pmSourceRoughClass()
     14bool                 pmSourceSetPixelsCircle()
     15pmModel             *pmSourceModelGuess()
     16psArray             *pmSourceContour()
     17bool                 pmSourceFitModel()
     18bool                 pmSourceAddModel()
     19bool                 pmSourceSubModel()
     20int                  pmModelParameterCount ();
     21char                *pmModelGetType ();
     22pmModelType          pmModelSetType ();
     23pmModelFunc          pmModelFunc_GetFunction ();
     24pmModelFlux          pmModelFlux_GetFunction ();
     25pmModelRadius        pmModelRadius_GetFunction ();
     26pmModelLimits        pmModelLimits_GetFunction ();
     27pmModelGuessFunc     pmModelGuessFunc_GetFunction ();
     28pmModelFromPSFFunc   pmModelFromPSFFunc_GetFunction ();
     29pmModelFitStatusFunc pmModelFitStatusFunc_GetFunction ();
     30
     31model function abstractions:
     32  typedef psMinimizeLMChi2Func pmModelFunc;
     33  typedef psF64 (*pmModelFlux)(const psVector *params);
     34  typedef psF64 (*pmModelRadius)(const psVector *params, double flux);
     35  typedef bool (*pmModelLimits)(psVector **beta_lim, psVector **params_min, psVector **params_max);
     36  typedef bool (*pmModelGuessFunc)(pmModel *model, pmSource *source);
     37  typedef bool (*pmModelFromPSFFunc)(pmModel *modelPSF, pmModel *modelFLT, pmPSF *psf);
     38  typedef bool (*pmModelFitStatusFunc)(pmModel *model);
  • trunk/psphot/src/pmObjects_EAM.c

    r4950 r4954  
    66 *  @author EAM, IfA: significant modifications.
    77 *
    8  *  @version $Revision: 1.2 $ $Name: not supported by cvs2svn $
    9  *  @date $Date: 2005-09-06 08:05:08 $
     8 *  @version $Revision: 1.3 $ $Name: not supported by cvs2svn $
     9 *  @date $Date: 2005-09-07 03:33:01 $
    1010 *
    1111 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    6666pmModelAlloc(): Allocate the pmModel structure, along with its parameters,
    6767and initialize the type member.  Initialize the params to 0.0.
    68 XXX EAM: changing params and dparams to psVector
    69 XXX EAM: simplifying code with psModelParameterCount
     68XXX EAM: simplifying code with pmModelParameterCount
    7069*****************************************************************************/
    7170pmModel *pmModelAlloc(pmModelType type)
     
    7675    tmp->chisq = 0.0;
    7776    tmp->nIter = 0;
    78     psS32 Nparams = psModelParameterCount (type);
     77    psS32 Nparams = pmModelParameterCount (type);
    7978    if (Nparams == 0) {
    80         psError(PS_ERR_UNKNOWN, true, "Undefined psModelType");
     79        psError(PS_ERR_UNKNOWN, true, "Undefined pmModelType");
    8180        return(NULL);
    8281    }
     
    167166    //
    168167    if ((vector->data.F32[0] > vector->data.F32[1]) &&
    169             (vector->data.F32[0] > threshold)) {
     168        (vector->data.F32[0] > threshold)) {
    170169        count++;
    171170    }
     
    176175    for (psU32 i = 1; i < n-1 ; i++) {
    177176        if ((vector->data.F32[i] > vector->data.F32[i-1]) &&
    178                 (vector->data.F32[i] > vector->data.F32[i+1]) &&
    179                 (vector->data.F32[i] > threshold)) {
     177            (vector->data.F32[i] > vector->data.F32[i+1]) &&
     178            (vector->data.F32[i] > threshold)) {
    180179            count++;
    181180        }
     
    186185    //
    187186    if ((vector->data.F32[n-1] > vector->data.F32[n-2]) &&
    188             (vector->data.F32[n-1] > threshold)) {
     187        (vector->data.F32[n-1] > threshold)) {
    189188        count++;
    190189    }
     
    201200    //
    202201    if ((vector->data.F32[0] > vector->data.F32[1]) &&
    203             (vector->data.F32[0] > threshold)) {
     202        (vector->data.F32[0] > threshold)) {
    204203        tmpVector->data.U32[count++] = 0;
    205204    }
     
    210209    for (psU32 i = 1; i < (n-1) ; i++) {
    211210        if ((vector->data.F32[i] > vector->data.F32[i-1]) &&
    212                 (vector->data.F32[i] > vector->data.F32[i+1]) &&
    213                 (vector->data.F32[i] > threshold)) {
     211            (vector->data.F32[i] > vector->data.F32[i+1]) &&
     212            (vector->data.F32[i] > threshold)) {
    214213            tmpVector->data.U32[count++] = i;
    215214        }
     
    220219    //
    221220    if ((vector->data.F32[n-1] > vector->data.F32[n-2]) &&
    222             (vector->data.F32[n-1] > threshold)) {
     221        (vector->data.F32[n-1] > threshold)) {
    223222        tmpVector->data.U32[count++] = n-1;
    224223    }
     
    319318        if (col == 0) {
    320319            if ( (image->data.F32[row][col] >  image->data.F32[row][col+1]) &&
    321                     (image->data.F32[row][col] >  image->data.F32[row+1][col]) &&
    322                     (image->data.F32[row][col] >= image->data.F32[row+1][col+1])) {
     320                (image->data.F32[row][col] >  image->data.F32[row+1][col]) &&
     321                (image->data.F32[row][col] >= image->data.F32[row+1][col+1])) {
    323322
    324323                if (image->data.F32[row][col] > threshold) {
     
    328327        } else if (col < (image->numCols - 1)) {
    329328            if ( (image->data.F32[row][col] >= image->data.F32[row][col-1]) &&
    330                     (image->data.F32[row][col] >  image->data.F32[row][col+1]) &&
    331                     (image->data.F32[row][col] >= image->data.F32[row+1][col-1]) &&
    332                     (image->data.F32[row][col] >  image->data.F32[row+1][col]) &&
    333                     (image->data.F32[row][col] >= image->data.F32[row+1][col+1])) {
     329                (image->data.F32[row][col] >  image->data.F32[row][col+1]) &&
     330                (image->data.F32[row][col] >= image->data.F32[row+1][col-1]) &&
     331                (image->data.F32[row][col] >  image->data.F32[row+1][col]) &&
     332                (image->data.F32[row][col] >= image->data.F32[row+1][col+1])) {
    334333                if (image->data.F32[row][col] > threshold) {
    335334                    list = myListAddPeak(list, row, col, image->data.F32[row][col], PM_PEAK_EDGE);
     
    339338        } else if (col == (image->numCols - 1)) {
    340339            if ( (image->data.F32[row][col] >= image->data.F32[row][col-1]) &&
    341                     (image->data.F32[row][col] > image->data.F32[row+1][col]) &&
    342                     (image->data.F32[row][col] >= image->data.F32[row+1][col-1])) {
     340                (image->data.F32[row][col] > image->data.F32[row+1][col]) &&
     341                (image->data.F32[row][col] >= image->data.F32[row+1][col-1])) {
    343342                if (image->data.F32[row][col] > threshold) {
    344343                    list = myListAddPeak(list, row, col, image->data.F32[row][col], PM_PEAK_EDGE);
     
    375374                // If col==0, then we can not read col-1 pixels
    376375                if ((image->data.F32[row][col] >  image->data.F32[row-1][col]) &&
    377                         (image->data.F32[row][col] >= image->data.F32[row-1][col+1]) &&
    378                         (image->data.F32[row][col] >= image->data.F32[row][col+1]) &&
    379                         (image->data.F32[row][col] >= image->data.F32[row+1][col]) &&
    380                         (image->data.F32[row][col] >= image->data.F32[row+1][col+1])) {
     376                    (image->data.F32[row][col] >= image->data.F32[row-1][col+1]) &&
     377                    (image->data.F32[row][col] >= image->data.F32[row][col+1]) &&
     378                    (image->data.F32[row][col] >= image->data.F32[row+1][col]) &&
     379                    (image->data.F32[row][col] >= image->data.F32[row+1][col+1])) {
    381380                    myType = PM_PEAK_EDGE;
    382381                    list = myListAddPeak(list, row, col, image->data.F32[row][col], myType);
     
    385384                // This is an interior pixel
    386385                if ((image->data.F32[row][col] >= image->data.F32[row-1][col-1]) &&
    387                         (image->data.F32[row][col] >  image->data.F32[row-1][col]) &&
    388                         (image->data.F32[row][col] >= image->data.F32[row-1][col+1]) &&
    389                         (image->data.F32[row][col] > image->data.F32[row][col-1]) &&
    390                         (image->data.F32[row][col] >= image->data.F32[row][col+1]) &&
    391                         (image->data.F32[row][col] >= image->data.F32[row+1][col-1]) &&
    392                         (image->data.F32[row][col] >= image->data.F32[row+1][col]) &&
    393                         (image->data.F32[row][col] >= image->data.F32[row+1][col+1])) {
     386                    (image->data.F32[row][col] >  image->data.F32[row-1][col]) &&
     387                    (image->data.F32[row][col] >= image->data.F32[row-1][col+1]) &&
     388                    (image->data.F32[row][col] > image->data.F32[row][col-1]) &&
     389                    (image->data.F32[row][col] >= image->data.F32[row][col+1]) &&
     390                    (image->data.F32[row][col] >= image->data.F32[row+1][col-1]) &&
     391                    (image->data.F32[row][col] >= image->data.F32[row+1][col]) &&
     392                    (image->data.F32[row][col] >= image->data.F32[row+1][col+1])) {
    394393                    if (image->data.F32[row][col] > threshold) {
    395394                        if ((image->data.F32[row][col] > image->data.F32[row-1][col-1]) &&
    396                                 (image->data.F32[row][col] > image->data.F32[row-1][col]) &&
    397                                 (image->data.F32[row][col] > image->data.F32[row-1][col+1]) &&
    398                                 (image->data.F32[row][col] > image->data.F32[row][col-1]) &&
    399                                 (image->data.F32[row][col] > image->data.F32[row][col+1]) &&
    400                                 (image->data.F32[row][col] > image->data.F32[row+1][col-1]) &&
    401                                 (image->data.F32[row][col] > image->data.F32[row+1][col]) &&
    402                                 (image->data.F32[row][col] > image->data.F32[row+1][col+1])) {
     395                            (image->data.F32[row][col] > image->data.F32[row-1][col]) &&
     396                            (image->data.F32[row][col] > image->data.F32[row-1][col+1]) &&
     397                            (image->data.F32[row][col] > image->data.F32[row][col-1]) &&
     398                            (image->data.F32[row][col] > image->data.F32[row][col+1]) &&
     399                            (image->data.F32[row][col] > image->data.F32[row+1][col-1]) &&
     400                            (image->data.F32[row][col] > image->data.F32[row+1][col]) &&
     401                            (image->data.F32[row][col] > image->data.F32[row+1][col+1])) {
    403402                            myType = PM_PEAK_LONE;
    404403                        }
    405404
    406405                        if ((image->data.F32[row][col] == image->data.F32[row-1][col-1]) ||
    407                                 (image->data.F32[row][col] == image->data.F32[row-1][col]) ||
    408                                 (image->data.F32[row][col] == image->data.F32[row-1][col+1]) ||
    409                                 (image->data.F32[row][col] == image->data.F32[row][col-1]) ||
    410                                 (image->data.F32[row][col] == image->data.F32[row][col+1]) ||
    411                                 (image->data.F32[row][col] == image->data.F32[row+1][col-1]) ||
    412                                 (image->data.F32[row][col] == image->data.F32[row+1][col]) ||
    413                                 (image->data.F32[row][col] == image->data.F32[row+1][col+1])) {
     406                            (image->data.F32[row][col] == image->data.F32[row-1][col]) ||
     407                            (image->data.F32[row][col] == image->data.F32[row-1][col+1]) ||
     408                            (image->data.F32[row][col] == image->data.F32[row][col-1]) ||
     409                            (image->data.F32[row][col] == image->data.F32[row][col+1]) ||
     410                            (image->data.F32[row][col] == image->data.F32[row+1][col-1]) ||
     411                            (image->data.F32[row][col] == image->data.F32[row+1][col]) ||
     412                            (image->data.F32[row][col] == image->data.F32[row+1][col+1])) {
    414413                            myType = PM_PEAK_FLAT;
    415414                        }
     
    421420                // If col==numCols - 1, then we can not read col+1 pixels
    422421                if ((image->data.F32[row][col] >= image->data.F32[row-1][col-1]) &&
    423                         (image->data.F32[row][col] >  image->data.F32[row-1][col]) &&
    424                         (image->data.F32[row][col] > image->data.F32[row][col-1]) &&
    425                         (image->data.F32[row][col] >= image->data.F32[row][col+1]) &&
    426                         (image->data.F32[row][col] >= image->data.F32[row+1][col-1]) &&
    427                         (image->data.F32[row][col] >= image->data.F32[row+1][col])) {
     422                    (image->data.F32[row][col] >  image->data.F32[row-1][col]) &&
     423                    (image->data.F32[row][col] > image->data.F32[row][col-1]) &&
     424                    (image->data.F32[row][col] >= image->data.F32[row][col+1]) &&
     425                    (image->data.F32[row][col] >= image->data.F32[row+1][col-1]) &&
     426                    (image->data.F32[row][col] >= image->data.F32[row+1][col])) {
    428427                    myType = PM_PEAK_EDGE;
    429428                    list = myListAddPeak(list, row, col, image->data.F32[row][col], myType);
     
    448447        if (col == 0) {
    449448            if ( (image->data.F32[row][col] >  image->data.F32[row-1][col]) &&
    450                     (image->data.F32[row][col] >= image->data.F32[row-1][col+1]) &&
    451                     (image->data.F32[row][col] >  image->data.F32[row][col+1])) {
     449                (image->data.F32[row][col] >= image->data.F32[row-1][col+1]) &&
     450                (image->data.F32[row][col] >  image->data.F32[row][col+1])) {
    452451                if (image->data.F32[row][col] > threshold) {
    453452                    list = myListAddPeak(list, row, col, image->data.F32[row][col], PM_PEAK_EDGE);
     
    456455        } else if (col < (image->numCols - 1)) {
    457456            if ( (image->data.F32[row][col] >= image->data.F32[row-1][col-1]) &&
    458                     (image->data.F32[row][col] >  image->data.F32[row-1][col]) &&
    459                     (image->data.F32[row][col] >= image->data.F32[row-1][col+1]) &&
    460                     (image->data.F32[row][col] >  image->data.F32[row][col-1]) &&
    461                     (image->data.F32[row][col] >= image->data.F32[row][col+1])) {
     457                (image->data.F32[row][col] >  image->data.F32[row-1][col]) &&
     458                (image->data.F32[row][col] >= image->data.F32[row-1][col+1]) &&
     459                (image->data.F32[row][col] >  image->data.F32[row][col-1]) &&
     460                (image->data.F32[row][col] >= image->data.F32[row][col+1])) {
    462461                if (image->data.F32[row][col] > threshold) {
    463462                    list = myListAddPeak(list, row, col, image->data.F32[row][col], PM_PEAK_EDGE);
     
    467466        } else if (col == (image->numCols - 1)) {
    468467            if ( (image->data.F32[row][col] >= image->data.F32[row-1][col-1]) &&
    469                     (image->data.F32[row][col] >  image->data.F32[row-1][col]) &&
    470                     (image->data.F32[row][col] >  image->data.F32[row][col-1])) {
     468                (image->data.F32[row][col] >  image->data.F32[row-1][col]) &&
     469                (image->data.F32[row][col] >  image->data.F32[row][col-1])) {
    471470                if (image->data.F32[row][col] > threshold) {
    472471                    list = myListAddPeak(list, row, col, image->data.F32[row][col], PM_PEAK_EDGE);
     
    495494        (y >= valid->y0) &&
    496495        (y <= valid->y1)) {
    497       return(true);
     496        return(true);
    498497    }
    499498
     
    511510 
    512511XXX: changed API to create a NEW output psArray (should change name as well)
     512 
     513XXX: Do we free the psList elements of those culled peaks?
     514
     515XXX EAM : do we still need pmCullPeaks, or only pmPeaksSubset?
    513516*****************************************************************************/
    514517psList *pmCullPeaks(psList *peaks,
     
    517520{
    518521    PS_ASSERT_PTR_NON_NULL(peaks, NULL);
    519     //    PS_ASSERT_PTR_NON_NULL(valid, NULL);
    520522
    521523    psListElem *tmpListElem = (psListElem *) peaks->head;
     
    526528        pmPeak *tmpPeak = (pmPeak *) tmpListElem->data;
    527529        if ((tmpPeak->counts > maxValue) ||
    528                 ((valid != NULL) &&
    529                  (true == isItInThisRegion(valid, tmpPeak->x, tmpPeak->y)))) {
     530            ((valid != NULL) &&
     531             (true == isItInThisRegion(valid, tmpPeak->x, tmpPeak->y)))) {
    530532            psListRemoveData(peaks, (psPtr) tmpPeak);
    531533        }
     
    625627    // XXX EAM : I added this code to stay on the image. So did George
    626628    // XXX EAM : EndRow is *exclusive* of pixel region (ie, last pixel + 1)
     629    // XXX EAM : dropped the Annulus width (not needed)
     630    // XXX EAM : dropped off-boundary tests (not needed)
    627631    psS32 SubImageStartRow  = PS_MAX (0, SubImageCenterRow - outerRadiusS32);
    628632    psS32 SubImageEndRow    = PS_MIN (image->numRows, SubImageCenterRow + outerRadiusS32 + 1);
    629633    psS32 SubImageStartCol  = PS_MAX (0, SubImageCenterCol - outerRadiusS32);
    630634    psS32 SubImageEndCol    = PS_MIN (image->numCols, SubImageCenterCol + outerRadiusS32 + 1);
    631     // AnulusWidth == number of pixels width in the annulus.  We add one since
    632     // the pixels at the inner AND outher radius are included.
    633     // XXX EAM : not used : psS32 AnulusWidth = 1 + (outerRadiusS32 - innerRadiusS32);
    634     // Example: assume an outer/inner radius of 20/10.  Then the subimage
    635     // should have width/length of 40.  An 18-by-18 interior region will
    636     // be masked.
    637     //    printf("pmSourceLocalSky(): innerRadiusS32 is %d\n", innerRadiusS32);
    638     //    printf("pmSourceLocalSky(): outerRadiusS32 is %d\n", outerRadiusS32);
    639     //    printf("pmSourceLocalSky(): AnulusWidth is %d\n", AnulusWidth);
    640 
    641     // XXX EAM : these tests should not be needed: we can never hit this error because of above
    642     # if (1)
    643 
    644         if (SubImageStartRow < 0) {
    645             psError(PS_ERR_UNKNOWN, true, "Sub image startRow is outside image boundaries (%d).\n",
    646                     SubImageStartRow);
    647             return(NULL);
    648         }
    649     if (SubImageEndRow > image->numRows) {
    650         psError(PS_ERR_UNKNOWN, true, "Sub image endRow is outside image boundaries (%d).\n",
    651                 SubImageEndRow);
    652         return(NULL);
    653     }
    654     if (SubImageStartCol < 0) {
    655         psError(PS_ERR_UNKNOWN, true, "Sub image startCol is outside image boundaries (%d).\n",
    656                 SubImageStartCol);
    657         return(NULL);
    658     }
    659     if (SubImageEndCol > image->numCols) {
    660         psError(PS_ERR_UNKNOWN, true, "Sub image endCol is outside image boundaries (%d).\n",
    661                 SubImageEndCol);
    662         return(NULL);
    663     }
    664     # endif
    665 
    666635    //
    667636    // Grab a subimage of the original image of size (2 * outerRadius).
    668637    //
    669     // XXX: Must fix for new psImageSubset
    670     //    psImage *subImage = psImageSubset((psImage *) image,
    671     //                                      SubImageStartCol,
    672     //                                      SubImageStartRow,
    673     //                                      SubImageEndCol,
    674     //                                      SubImageEndRow);
    675     //    printf("pmSourceLocalSky: subimage width/length is (%d, %d)\n", subImage->numCols, subImage->numRows);
    676     psRegion tmpRegion = psRegionSet(SubImageStartCol,
    677                                      SubImageEndCol,
    678                                      SubImageStartRow,
    679                                      SubImageEndRow);
    680     psImage *subImage = psImageSubset((psImage *) image, tmpRegion);
    681     // XXX EAM : can merge these: psImageSubset (image, psRegionSet ());
     638    // XXX EAM : merged psImageSubset & psRegionSet
     639    // XXX EAM : cast for image is needed because of const (above)
     640    psImage *subImage = psImageSubset((psImage *) image, psRegionSet(SubImageStartCol,
     641                                                         SubImageEndCol,
     642                                                         SubImageStartRow,
     643                                                         SubImageEndRow));
    682644
    683645    psImage *subImageMask = psImageAlloc(subImage->numCols,
     
    685647                                         PS_TYPE_U8);
    686648    // XXX EAM : for consistency, mask needs col0,row0 set to match image
    687     subImageMask->col0 = subImage->col0;
    688     subImageMask->row0 = subImage->row0;
    689 
    690     //
    691     // Loop through the subimage mask, initialize mask to 1 (invalid pixel)
     649    // XXX EAM : CONFLICT between psLib and code requirement. FIX PSLIB!!!
     650    // subImageMask->col0 = subImage->col0;
     651    // subImageMask->row0 = subImage->row0;
     652    psAbort ("pmObjects", "must fix this error before psphot will work!!!\n");
     653
     654    //
     655    // Loop through the subimage mask, initialize mask to 0x01 (invalid pixel)
    692656    // XXX EAM : use PSPHOT_MASK_INVALID?
    693657    //
    694658    for (psS32 row = 0 ; row < subImageMask->numRows; row++) {
    695659        for (psS32 col = 0 ; col < subImageMask->numCols; col++) {
    696             subImageMask->data.U8[row][col] = 1;
     660            subImageMask->data.U8[row][col] = 0x01;
    697661        }
    698662    }
     
    702666    // XXX this uses a static mask value of 0
    703667    // XXX EAM : this was wrong: it masked the wrong pixels at the edge of the image
     668    // XXX EAM : this masks the pixels in the center region
     669    // XXX EAM : should we be using psImageMaskRegion ???
    704670    psS32 StartRow  = PS_MAX (0, SubImageCenterRow - subImageMask->row0 - innerRadiusS32);
    705671    psS32 EndRow    = PS_MIN (subImageMask->numRows, SubImageCenterRow - subImageMask->row0 + innerRadiusS32 + 1);
     
    712678    }
    713679
    714 
     680    // XXX EAM : make this trace information??
    715681    //    for (psS32 row = 0 ; row < subImage->numRows; row++) {
    716682    //        for (psS32 col = 0 ; col < subImage->numCols; col++) {
     
    800766XXX: mask values?
    801767*****************************************************************************/
    802 bool pmSourceMoments(psSource *source,
     768bool pmSourceMoments(pmSource *source,
    803769                     psF32 radius)
    804770{
     
    849815            psS32 imgColCoord = col + source->pixels->col0;
    850816            psS32 imgRowCoord = row + source->pixels->row0;
    851             if (CheckRadius(source->peak,
     817            if (checkRadius(source->peak,
    852818                            radius,
    853819                            imgColCoord,
     
    874840    // XXX EAM - the limit is a bit arbitrary.  make it user defined?
    875841    if ((numPixels < 3) || (Sum <= 0)) {
    876       psTrace (".psModules.pmSourceMoments", 5, "no valid pixels for source\n");
    877       return (false);
     842        psTrace (".psModules.pmSourceMoments", 5, "no valid pixels for source\n");
     843        return (false);
    878844    }
    879845
     
    890856    y = Y1/Sum;
    891857    if ((fabs(x) > radius) || (fabs(y) > radius)) {
    892       psTrace (".psModules.pmSourceMoments", 5,
    893               "large centroid swing; invalid peak %d, %d\n",
    894               source->peak->x, source->peak->y);
    895       return (false);
     858        psTrace (".psModules.pmSourceMoments", 5,
     859                "large centroid swing; invalid peak %d, %d\n",
     860                source->peak->x, source->peak->y);
     861        return (false);
    896862    }
    897863
     
    914880
    915881    return(true);
    916 
    917     // XXX EAM : the following code should be the same as above, but it is not very stable: ignore it
    918     # if (0)
    919         //
    920         // second loop: get the difference sums
    921         //
    922         X2 = Y2 = 0;
    923     for (psS32 row = 0; row < source->pixels->numRows ; row++) {
    924         for (psS32 col = 0; col < source->pixels->numCols ; col++) {
    925             if ((source->mask != NULL) && (source->mask->data.U8[row][col] != 0)) {
    926                 psS32 imgColCoord = col + source->pixels->col0;
    927                 psS32 imgRowCoord = row + source->pixels->row0;
    928                 if (checkRadius(source->peak,
    929                                 radius,
    930                                 imgColCoord,
    931                                 imgRowCoord)) {
    932                     psF32 xDiff = (psF32) (imgColCoord - source->peak->x);
    933                     psF32 yDiff = (psF32) (imgRowCoord - source->peak->y);
    934                     psF32 pDiff = source->pixels->data.F32[row][col] - sky;
    935 
    936                     Sum+= pDiff;
    937                     X2+= PS_SQR(xDiff - x) * pDiff;
    938                     Y2+= PS_SQR(yDiff - y) * pDiff;
    939                 }
    940             }
    941         }
    942     }
    943 
    944     //
    945     // second moment X = sqrt (X2/Sum)
    946     //
    947     source->moments->Sx = (X2/Sum);
    948     source->moments->Sy = (Y2/Sum);
    949     return(true);
    950     # endif
    951882}
    952883
     
    990921{
    991922
    992     # define NPIX 10
    993     # define SCALE 0.1
     923# define NPIX 10
     924# define SCALE 0.1
    994925
    995926    psArray *peaks  = NULL;
     
    997928    pmPSFClump psfClump = emptyClump;
    998929
    999     //    PS_PTR_CHECK_NULL(sources, emptyClump);
    1000     //    PS_PTR_CHECK_NULL(metadata, emptyClump);
     930    PS_ASSERT_PTR_NON_NULL(sources, emptyClump);
     931    PS_ASSERT_PTR_NON_NULL(metadata, emptyClump);
    1001932
    1002933    // find the sigmaX, sigmaY clump
     
    1010941        splane = psImageAlloc (NPIX/SCALE, NPIX/SCALE, PS_TYPE_F32);
    1011942        for (int i = 0; i < splane->numRows; i++) {
    1012           memset (splane->data.F32[i], 0, splane->numCols*sizeof(PS_TYPE_F32));
     943            memset (splane->data.F32[i], 0, splane->numCols*sizeof(PS_TYPE_F32));
    1013944        }
    1014945
     
    11391070
    11401071XXX: How can this function ever return FALSE?
     1072
     1073XXX EAM : add the saturated mask value to metadata
    11411074*****************************************************************************/
    11421075
     
    11781111        psF32 A  = 4 * M_PI * sigX * sigY;
    11791112        psF32 B  = tmpSrc->moments->Sky;
    1180         psF32 RT = PS_SQRT_F32(S + (A * B) + (A * PS_SQR(RDNOISE) / PS_SQRT_F32(GAIN)));
    1181         psF32 SN = (S * PS_SQRT_F32(GAIN) / RT);
     1113        psF32 RT = sqrt(S + (A * B) + (A * PS_SQR(RDNOISE) / sqrt(GAIN)));
     1114        psF32 SN = (S * sqrt(GAIN) / RT);
    11821115        tmpSrc->moments->SN = SN;
    11831116
    1184         // XXX EAM : can we use the value of SATIRATE if mask is NULL?
    1185         int Nsatpix = pmCountSatPixels (tmpSrc->mask);
     1117        // XXX EAM : can we use the value of SATURATE if mask is NULL?
     1118# define MASK_SATURATED 0x02
     1119        int Nsatpix = psImageCountPixelMask (tmpSrc->mask, MASK_SATURATED);
    11861120
    11871121        // saturated star (size consistent with PSF or larger)
     
    12531187}
    12541188
    1255 int pmCountSatPixels (psImage *image)
    1256 {
    1257     int Nsatpix = 0;
    1258  
    1259     for (int i = 0; i < image->numRows; i++) {
    1260         for (int j = 0; j < image->numCols; j++) {
    1261             if (image->data.U8[i][j] & 0x02) {
    1262                 Nsatpix ++;
    1263             }
    1264         }
    1265     }
    1266     return (Nsatpix);
    1267 }
    1268 
    12691189/******************************************************************************
    12701190pmSourceSetPixelsCircle(source, image, radius)
     
    12861206    PS_ASSERT_PTR_NON_NULL(source, false);
    12871207    PS_ASSERT_PTR_NON_NULL(source->moments, false);
    1288     // PS_ASSERT_PTR_NON_NULL(source->peak, false);
     1208    PS_ASSERT_PTR_NON_NULL(source->peak, false);
    12891209    PS_FLOAT_COMPARE(0.0, radius, false);
    12901210
     
    13051225    psS32 SubImageEndCol    = PS_MIN (image->numCols, SubImageCenterCol + radiusS32 + 1);
    13061226
    1307     // XXX EAM : this should not be needed: we can never hit this error
    1308     # if (1)
    1309 
    1310         if (SubImageStartRow < 0) {
    1311             psError(PS_ERR_UNKNOWN, true, "Sub image startRow is outside image boundaries (%d).\n",
    1312                     SubImageStartRow);
    1313             return(false);
    1314         }
    1315     if (SubImageEndRow > image->numRows) {
    1316         psError(PS_ERR_UNKNOWN, true, "Sub image endRow is outside image boundaries (%d).\n",
    1317                 SubImageEndRow);
    1318         return(false);
    1319     }
    1320     if (SubImageStartCol < 0) {
    1321         psError(PS_ERR_UNKNOWN, true, "Sub image startCol is outside image boundaries (%d).\n",
    1322                 SubImageStartCol);
    1323         return(false);
    1324     }
    1325     if (SubImageEndCol > image->numCols) {
    1326         psError(PS_ERR_UNKNOWN, true, "Sub image endCol is outside image boundaries (%d).\n",
    1327                 SubImageEndCol);
    1328         return(false);
    1329     }
    1330     # endif
    1331 
    13321227    // XXX: Must recycle image.
    13331228    // XXX EAM: this message reflects a programming error we know about.
     
    13381233        psFree(source->pixels);
    13391234    }
    1340     // XXX: Must fix this.  psImageSubset() has different parameters in latest CVS.
    1341     //    source->pixels = psImageSubset((psImage *) image,
    1342     //                                   SubImageStartCol,
    1343     //                                   SubImageStartRow,
    1344     //                                   SubImageEndCol,
    1345     //                                   SubImageEndRow);
    13461235    source->pixels = psImageSubset((psImage *) image, psRegionSet(SubImageStartCol,
    13471236                                                                  SubImageStartRow,
     
    13901279functions will be in image, not subImage coords.  Remember this.
    13911280*****************************************************************************/
    1392 psModel *pmSourceModelGuess(psSource *source,
    1393                             psModelType modelType)
    1394 {
    1395     PS_PTR_CHECK_NULL(source, false);
    1396     PS_PTR_CHECK_NULL(source->moments, false);
    1397     PS_PTR_CHECK_NULL(source->peak, false);
    1398 
    1399     psModel *model = psModelAlloc(modelType);
    1400 
    1401     psModelGuessFunc modelGuessFunc = psModelGuessFunc_GetFunction (modelType);
     1281pmModel *pmSourceModelGuess(pmSource *source,
     1282                            pmModelType modelType)
     1283{
     1284    PS_ASSERT_PTR_NON_NULL(source->moments, false);
     1285    PS_ASSERT_PTR_NON_NULL(source->peak, false);
     1286
     1287    pmModel *model = pmModelAlloc(modelType);
     1288
     1289    pmModelGuessFunc modelGuessFunc = pmModelGuessFunc_GetFunction (modelType);
    14021290    modelGuessFunc (model, source);
    14031291    return(model);
     
    14251313testing.  Try to reproduce that and debug.
    14261314*****************************************************************************/
    1427 static psF32 evalModel(pmSource *src,
    1428                        psU32 row,
    1429                        psU32 col)
    1430 {
    1431     PS_ASSERT_PTR_NON_NULL(src, false);
    1432     PS_ASSERT_PTR_NON_NULL(src->modelPSF, false);
    1433     PS_ASSERT_PTR_NON_NULL(src->modelPSF->params, false);
    1434 
    1435 XXX EAM : I've made this a public function
    1436 XXX EAM : this now uses a psModel as the input
    1437 XXX EAM : it was using src->type to find the model, not model->type
    1438 *****************************************************************************/
    1439 psF32 psModelEval(psModel *model, psImage *image, psS32 col, psS32 row)
    1440 {
    1441     PS_PTR_CHECK_NULL(image, false);
    1442     PS_PTR_CHECK_NULL(model, false);
    1443     PS_PTR_CHECK_NULL(model->params, false);
     1315
     1316// XXX EAM : I have made this a public function
     1317// XXX EAM : this now uses a pmModel as the input
     1318// XXX EAM : it was using src->type to find the model, not model->type
     1319psF32 pmModelEval(pmModel *model, psImage *image, psS32 col, psS32 row)
     1320{
     1321    PS_ASSERT_PTR_NON_NULL(image, false);
     1322    PS_ASSERT_PTR_NON_NULL(model, false);
     1323    PS_ASSERT_PTR_NON_NULL(model->params, false);
    14441324
    14451325    // Allocate the x coordinate structure and convert row/col to image space.
     
    14491329    x->data.F32[1] = (psF32) (row + image->row0);
    14501330    psF32 tmpF;
    1451     psModelFunc modelFunc;
    1452 
    1453     modelFunc = psModelFunc_GetFunction (model->type);
     1331    pmModelFunc modelFunc;
     1332
     1333    modelFunc = pmModelFunc_GetFunction (model->type);
    14541334    tmpF = modelFunc (NULL, model->params, x);
    14551335    psFree(x);
     
    14911371    }
    14921372
    1493     // XXX EAM : i changed this to match psModelEval above, but see
     1373    // XXX EAM : i changed this to match pmModelEval above, but see
    14941374    // XXX EAM   the note below in pmSourceContour
    1495     psF32 oldValue = psModelEval(source->modelFLT, source->pixels, subCol, subRow);
     1375    psF32 oldValue = pmModelEval(source->modelFLT, source->pixels, subCol, subRow);
    14961376    if (oldValue == level) {
    14971377        return(((psF32) (subCol + source->pixels->col0)));
     
    15141394
    15151395    while (subCol != lastColumn) {
    1516         psF32 newValue = psModelEval(source->modelFLT, source->pixels, subCol, subRow);
     1396        psF32 newValue = pmModelEval(source->modelFLT, source->pixels, subCol, subRow);
    15171397        if (oldValue == level) {
    15181398            return((psF32) (subCol + source->pixels->col0));
     
    16741554    //           tests below could be conditions (!NULL)
    16751555
    1676     psModelFunc modelFunc = psModelFunc_GetFunction (model->type);
     1556    pmModelFunc modelFunc = pmModelFunc_GetFunction (model->type);
    16771557
    16781558    psVector *params = model->params;
     
    16941574    }
    16951575    if (count <  nParams + 1) {
    1696       psTrace (".pmObjects.pmSourceFitModel", 4, "insufficient valid pixels\n");
    1697       return(false);
     1576        psTrace (".pmObjects.pmSourceFitModel", 4, "insufficient valid pixels\n");
     1577        return(false);
    16981578    }
    16991579
     
    17221602
    17231603    psMinimization *myMin = psMinimizationAlloc(PM_SOURCE_FIT_MODEL_NUM_ITERATIONS,
    1724                             PM_SOURCE_FIT_MODEL_TOLERANCE);
     1604                                                PM_SOURCE_FIT_MODEL_TOLERANCE);
    17251605
    17261606    // PSF model only fits first 4 parameters, FLT model fits all
    17271607    if (PSF) {
    1728       paramMask = psVectorAlloc (params->n, PS_TYPE_U8);
    1729       for (int i = 0; i < 4; i++) {
    1730         paramMask->data.U8[i] = 0;
    1731       }
    1732       for (int i = 4; i < paramMask->n; i++) {
    1733         paramMask->data.U8[i] = 1;
    1734       }
     1608        paramMask = psVectorAlloc (params->n, PS_TYPE_U8);
     1609        for (int i = 0; i < 4; i++) {
     1610            paramMask->data.U8[i] = 0;
     1611        }
     1612        for (int i = 4; i < paramMask->n; i++) {
     1613            paramMask->data.U8[i] = 1;
     1614        }
    17351615    }       
    17361616
     
    17821662bool p_pmSourceAddOrSubModel(psImage *image,
    17831663                             psImage *mask,
    1784                              psModel *model,
     1664                             pmModel *model,
    17851665                             bool center,
    17861666                             psS32 flag)
    17871667{
    17881668 
    1789   // XXX EAM : convert to ASSERTS
    1790   // PS_PTR_CHECK_NULL(model, false);
    1791   // PS_IMAGE_CHECK_NULL(image, false);
    1792   // PS_IMAGE_CHECK_TYPE(image, PS_TYPE_F32, false);
     1669    PS_ASSERT_PTR_NON_NULL(model, false);
     1670    PS_ASSERT_IMAGE_NON_NULL(image, false);
     1671    PS_ASSERT_IMAGE_TYPE(image, PS_TYPE_F32, false);
    17931672
    17941673    psVector *x = psVectorAlloc(2, PS_TYPE_F32);
    17951674    psVector *params = model->params;
    1796     psModelFunc modelFunc = psModelFunc_GetFunction (model->type);
     1675    pmModelFunc modelFunc = pmModelFunc_GetFunction (model->type);
    17971676    psS32 imageCol;
    17981677    psS32 imageRow;
     
    18421721bool pmSourceAddModel(psImage *image,
    18431722                      psImage *mask,
    1844                       psModel *model,
     1723                      pmModel *model,
    18451724                      bool center)
    18461725{
     
    18521731bool pmSourceSubModel(psImage *image,
    18531732                      psImage *mask,
    1854                       psModel *model,
     1733                      pmModel *model,
    18551734                      bool center)
    18561735{
  • trunk/psphot/src/pmObjects_EAM.h

    r4949 r4954  
    1 
     1/** @file  pmObjects.h
     2 *
     3 *  This file will ...
     4 *
     5 *  @author GLG, MHPCC
     6 *
     7 *  @version $Revision: 1.2 $ $Name: not supported by cvs2svn $
     8 *  @date $Date: 2005-09-07 03:33:01 $
     9 *
     10 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     11 *
     12 */
     13
     14#if !defined(PM_OBJECTS_H)
     15#define PM_OBJECTS_H
     16
     17#if HAVE_CONFIG_H
     18#include <config.h>
     19#endif
     20
     21#include<stdio.h>
     22#include<math.h>
     23#include "pslib.h"
     24
     25// XXX EAM : this function should be added to psLib
     26int          psImageCountPixelMask (psImage *mask, psU8 value);
     27
     28// XXX EAM : bug : missing from psLib/*.h
     29bool psMinimizeGaussNewtonDelta (psVector *delta,
     30                                 const psVector *params,
     31                                 const psVector *paramMask,
     32                                 const psArray  *x,
     33                                 const psVector *y,
     34                                 const psVector *yErr,
     35                                 psMinimizeLMChi2Func func);
     36
     37// XXX EAM : switch to psPoly when ready
     38psF64           Polynomial2DEval(const psPolynomial2D* myPoly, psF64 x, psF64 y);
     39
     40// XXX EAM : psEllipse needs to be be included in psLib
     41# include "psEllipse.h"
     42
     43/** pmPeakType
     44 *
     45 *  A peak pixel may have several features which may be determined when the
     46 *  peak is found or measured. These are specified by the pmPeakType enum.
     47 *  PM_PEAK_LONE represents a single pixel which is higher than its 8 immediate
     48 *  neighbors.  The PM_PEAK_EDGE represents a peak pixel which touching the image
     49 *  edge. The PM_PEAK_FLAT represents a peak pixel which has more than a specific
     50 *  number of neighbors at the same value, within some tolarence:
     51 *
     52 */
     53typedef enum {
     54    PM_PEAK_LONE,                       ///< Isolated peak.
     55    PM_PEAK_EDGE,                       ///< Peak on edge.
     56    PM_PEAK_FLAT,                       ///< Peak has equal-value neighbors.
     57    PM_PEAK_UNDEF                       ///< Undefined.
     58} pmPeakType;
     59
     60/** pmPeak data structure
     61 * 
     62 * 
     63 * 
     64 */
     65typedef struct
     66{
     67    int x;                              ///< X-coordinate of peak pixel.
     68    int y;                              ///< Y-coordinate of peak pixel.
     69    float counts;                       ///< Value of peak pixel (above sky?).
     70    pmPeakType class;                   ///< Description of peak.
     71}
     72pmPeak;
     73
     74/** pmMoments data structure
     75 * 
     76 * 
     77 * 
     78 */
     79typedef struct
     80{
     81    float x;                            ///< X-coord of centroid.
     82    float y;                            ///< Y-coord of centroid.
     83    float Sx;                           ///< x-second moment.
     84    float Sy;                           ///< y-second moment.
     85    float Sxy;                          ///< xy cross moment.
     86    float Sum;                          ///< Pixel sum above sky (background).
     87    float Peak;                         ///< Peak counts above sky.
     88    float Sky;                          ///< Sky level (background).
     89    float SN;                           ///< approx signal-to-noise
     90    int nPixels;                        ///< Number of pixels used.
     91} pmMoments;
     92
     93typedef int pmModelType;
     94
     95/** pmPSFClump data structure
     96 * 
     97 * 
     98 * 
     99 */
    2100typedef struct
    3101{
     
    8106} pmPSFClump;
    9107
    10 typedef struct
    11 {
    12     float x;                            ///< X-coord of centroid.
    13     float y;                            ///< Y-coord of centroid.
    14     float Sx;                           ///< x-second moment.
    15     float Sy;                           ///< y-second moment.
    16     float Sxy;                          ///< xy cross moment.
    17     float Sum;                          ///< Pixel sum above sky (background).
    18     float Peak;                         ///< Peak counts above sky.
    19     float Sky;                          ///< Sky level (background).
    20     float SN;
    21     int nPixels;                        ///< Number of pixels used.
    22 }
    23 pmMoments;
    24 
    25 typedef psS32 pmModelType;
    26 
    27 typedef struct
    28 {
    29     pmModelType type;       ///< Model to be used.
    30     psVector *params;       ///< Paramater values.
    31     psVector *dparams;      ///< Parameter errors.
    32     float radius;           ///< fit radius actually used
    33     float chisq;            ///< Fit chi-squared.
    34     int nDOF;             ///< number of degrees of freedom
    35     int nIter;            ///< number of iterations to reach min
     108/** pmModel data structure
     109 * 
     110 * 
     111 * 
     112 */
     113typedef struct
     114{
     115    pmModelType type;                   ///< Model to be used.
     116    psVector *params;                   ///< Paramater values.
     117    psVector *dparams;                  ///< Parameter errors.
     118    float chisq;                        ///< Fit chi-squared.
     119    int nDOF;                           ///< number of degrees of freedom
     120    int nIter;                          ///< number of iterations to reach min
     121    float radius;                       ///< fit radius actually used
    36122}
    37123pmModel;
    38124
     125/** pmSourceType enumeration
     126 * 
     127 * 
     128 * 
     129 */
    39130typedef enum {
    40131    PS_SOURCE_DEFECT,
     
    58149} pmSourceType;
    59150
    60 typedef struct
    61 {
    62     pmPeak *peak;           ///< Description of peak pixel.
    63     psImage *pixels;        ///< Rectangular region including object pixels.
    64     psImage *noise;         ///< Mask which marks pixels associated with objects.
    65     psImage *mask;          ///< Mask which marks pixels associated with objects.
    66     pmMoments *moments;     ///< Basic moments measure for the object.
    67     pmModel *modelPSF;      ///< PSF Model fit (parameters and type)
    68     pmModel *modelFLT;      ///< FLT Model fit (parameters and type).
    69     pmSourceType type;      ///< Best identification of object.
     151/** pmSource data structure
     152 * 
     153 *  This source has the capacity for several types of measurements. The
     154 *  simplest measurement of a source is the location and flux of the peak pixel
     155 *  associated with the source:
     156 * 
     157 */
     158typedef struct
     159{
     160    pmPeak *peak;                       ///< Description of peak pixel.
     161    psImage *pixels;                    ///< Rectangular region including object pixels.
     162    psImage *noise;                     ///< Mask which marks pixels associated with objects.
     163    psImage *mask;                      ///< Mask which marks pixels associated with objects.
     164    pmMoments *moments;                 ///< Basic moments measure for the object.
     165    pmModel *modelPSF;                  ///< PSF Model fit (parameters and type)
     166    pmModel *modelFLT;                  ///< FLT Model fit (parameters and type).
     167    pmSourceType type;                  ///< Best identification of object.
    70168}
    71169pmSource;
    72170
    73 // XXX EAM function to return pmModel
    74 typedef psMinimizeLMChi2Func pmModelFunc;
    75 typedef psF64 (*pmModelFlux)(const psVector *params);
    76 typedef bool  (*pmModelGuessFunc)(pmModel *model, pmSource *source);
    77 typedef bool  (*pmModelFromPSFFunc)(pmModel *modelPSF, pmModel *modelFLT, pmPSF *psf);
    78 typedef psF64 (*pmModelRadius)(const psVector *params, double flux);
    79 
    80 typedef bool  (*pmModelLimits)(psVector **beta_lim, psVector **params_min, psVector **params_max);
    81 typedef bool  (*pmModelFitStatusFunc)(pmModel *model);
    82 
    83 // XXX EAM structure to carry model options
    84 typedef struct {
    85   char *name;
    86   int nParams;
    87   pmModelFunc      modelFunc;
    88   pmModelFlux      modelFlux;
    89   pmModelRadius    modelRadius;
    90   pmModelLimits        modelLimits;
    91   pmModelGuessFunc modelGuessFunc;
    92   pmModelFromPSFFunc modelFromPSFFunc;
    93   pmModelFitStatusFunc modelFitStatusFunc;
    94 } pmModelGroup;
    95 
    96 // XXX EAM : strucures to define elliptical shape parameters
    97 typedef struct {
    98   double major;
    99   double minor;
    100   double theta;
    101 } EllipseAxes;
    102 
    103 typedef struct {
    104   double x2;
    105   double y2;
    106   double xy;
    107 } EllipseMoments;
    108 
    109 typedef struct {
    110   double sx;
    111   double sy;
    112   double sxy;
    113 } EllipseShape;
    114 
    115 EllipseAxes EllipseMomentsToAxes (EllipseMoments moments);
    116 EllipseShape EllipseAxesToShape (EllipseAxes axes);
    117 EllipseAxes EllipseShapeToAxes (EllipseShape shape);
     171/** pmPSF data structure
     172 * 
     173 * 
     174 * 
     175 */
     176typedef struct
     177{
     178    pmModelType type;                   ///< PSF Model in use
     179    psArray *params;                    ///< Model parameters (psPolynomial2D)
     180    float chisq;                        ///< PSF goodness statistic
     181    int nPSFstars;                      ///< number of stars used to measure PSF
     182}
     183pmPSF;
     184
     185pmPeak *pmPeakAlloc(
     186    int x,                              ///< Row-coordinate in image space
     187    int y,                              ///< Col-coordinate in image space
     188    float counts,                       ///< The value of the peak pixel
     189    pmPeakType class                    ///< The type of peak pixel
     190);
     191
     192pmMoments *pmMomentsAlloc();
     193pmModel *pmModelAlloc(pmModelType type);
     194pmSource  *pmSourceAlloc();
     195
     196/******************************************************************************
     197pmFindVectorPeaks(vector, threshold): Find all local peaks in the given vector
     198above the given threshold.  Returns a vector of type PS_TYPE_U32 containing
     199the location (x value) of all peaks.
     200*****************************************************************************/
     201psVector *pmFindVectorPeaks(
     202    const psVector *vector,             ///< The input vector (float)
     203    float threshold                     ///< Threshold above which to find a peak
     204);
     205
     206/******************************************************************************
     207pmFindImagePeaks(image, threshold): Find all local peaks in the given psImage
     208above the given threshold.  Returns a psList containing the location (x/y
     209value) of all peaks.
     210*****************************************************************************/
     211psArray *pmFindImagePeaks(
     212    const psImage *image,               ///< The input image where peaks will be found (float)
     213    float threshold                     ///< Threshold above which to find a peak
     214);
     215
     216/******************************************************************************
     217pmCullPeaks(peaks, maxValue, valid): eliminate peaks from the psList that have
     218a peak value above the given maximum, or fall outside the valid region.
     219*****************************************************************************/
     220psList *pmCullPeaks(
     221    psList *peaks,                      ///< The psList of peaks to be culled
     222    float maxValue,                     ///< Cull peaks above this value
     223    const psRegion *valid               ///< Cull peaks otside this psRegion
     224);
     225
     226/******************************************************************************
     227pmSource *pmSourceLocalSky(image, peak, innerRadius, outerRadius):
     228
     229*****************************************************************************/
     230pmSource *pmSourceLocalSky(
     231    const psImage *image,               ///< The input image (float)
     232    const pmPeak *peak,                 ///< The peak for which the pmSource struct is created.
     233    psStatsOptions statsOptions,        ///< The statistic used in calculating the background sky
     234    float innerRadius,                  ///< The inner radius of the suqare annulus for calculating sky
     235    float outerRadius                   ///< The outer radius of the suqare annulus for calculating sky
     236);
     237
     238/******************************************************************************
     239 *****************************************************************************/
     240bool pmSourceMoments(
     241    pmSource *source,                   ///< The input pmSource for which moments will be computed
     242    float radius                        ///< Use a circle of pixels around the peak
     243);
    118244
    119245/******************************************************************************
    120246pmSourcePSFClump(pmArray *source, psMetaDeta *metadata): find the source PSF clump
    121  *****************************************************************************/
    122 pmPSFClump pmSourcePSFClump(psArray *source, ///< The input psSource
    123                             psMetadata *metadata ///< Contains classification parameters
    124     );
     247*****************************************************************************/
     248pmPSFClump pmSourcePSFClump(
     249    psArray *source,                    ///< The input pmSource
     250    psMetadata *metadata                ///< Contains classification parameters
     251);
    125252
    126253/******************************************************************************
    127254pmSourceRoughClass(pmArray *source, psMetaDeta *metadata): make a guess at the
    128255source classification.
    129  *****************************************************************************/
    130 bool pmSourceRoughClass(psArray *source, ///< The input psSource
    131                             psMetadata *metadata, ///< Contains classification parameters
    132                             pmPSFClump clump ///< Statistics about the PSF clump
    133     );
    134 
    135 pmModel *pmSourceModelGuess(pmSource *source, ///< The input psSource
    136                                     pmModelType model ///< The type of model to be created.
    137     );
    138 
    139 // XXX EAM : added utility functions
    140 pmModelType        pmModelSetType (char *name);
    141 pmModelFunc        pmModelFunc_GetFunction (pmModelType type);
    142 pmModelFlux        pmModelFlux_GetFunction (pmModelType type);
    143 pmModelGuessFunc   pmModelGuessFunc_GetFunction (pmModelType type);
    144 pmModelFromPSFFunc pmModelFromPSFFunc_GetFunction (pmModelType type);
    145 pmModelRadius      pmModelRadius_GetFunction (pmModelType type);
    146 char                  *pmModelGetType (pmModelType type);
    147 psS32                  pmModelParameterCount (pmModelType type);
    148 pmModelLimits          pmModelLimits_GetFunction (pmModelType type);
    149 pmModelFitStatusFunc   pmModelFitStatusFunc_GetFunction (pmModelType type);
    150 int                    pmCountSatPixels (psImage *image);
    151 
    152 pmMoments *pmMomentsAlloc();
    153 pmModel *pmModelAlloc(pmModelType type);
    154 pmSource *pmSourceAlloc();
     256*****************************************************************************/
     257bool pmSourceRoughClass(
     258    psArray *source,                    ///< The input pmSource
     259    psMetadata *metadata,               ///< Contains classification parameters
     260    pmPSFClump clump                    ///< Statistics about the PSF clump
     261);
     262
     263/******************************************************************************
     264pmSourceSetPixelCircle(source, image, radius)
     265*****************************************************************************/
     266bool pmSourceSetPixelsCircle(
     267    pmSource *source,                   ///< The input pmSource
     268    const psImage *image,               ///< The input image (float)
     269    float radius                        ///< The radius of the circle
     270);
     271
     272/******************************************************************************
     273 *****************************************************************************/
     274pmModel *pmSourceModelGuess(
     275    pmSource *source,                   ///< The input pmSource
     276    pmModelType model                   ///< The type of model to be created.
     277);
     278
     279/******************************************************************************
     280 *****************************************************************************/
     281typedef enum {
     282    PS_CONTOUR_CRUDE,
     283} pmContourType;
     284
     285psArray *pmSourceContour(
     286    pmSource *source,                   ///< The input pmSource
     287    const psImage *image,               ///< The input image (float) (this arg should be removed)
     288    float level,                        ///< The level of the contour
     289    pmContourType mode                  ///< Currently this must be PS_CONTOUR_CRUDE
     290);
     291
     292/******************************************************************************
     293 *****************************************************************************/
     294bool pmSourceFitModel(
     295    pmSource *source,                   ///< The input pmSource
     296    pmModel *model,                     ///< model to be fitted
     297    const bool PSF                      ///< Treat model as PSF or FLT?
     298);
     299
     300/******************************************************************************
     301 *****************************************************************************/
     302bool pmSourceAddModel(
     303    psImage *image,                     ///< The output image (float)
     304    psImage *mask,                      ///< The image pixel mask (valid == 0)
     305    pmModel *model,                     ///< The input pmModel
     306    bool center                         ///< A boolean flag that determines whether pixels are centered
     307);
     308
     309/******************************************************************************
     310 *****************************************************************************/
     311bool pmSourceSubModel(
     312    psImage *image,                     ///< The output image (float)
     313    psImage *mask,                      ///< The image pixel mask (valid == 0)
     314    pmModel *model,                     ///< The input pmModel
     315    bool center                         ///< A boolean flag that determines whether pixels are centered
     316);
     317
     318/**
     319 *
     320 *  The object model functions are defined to allow for the flexible addition
     321 *  of new object models. Every object model, with parameters represented by
     322 *  pmModel, has an associated set of functions which provide necessary support
     323 *  operations. A set of abstract functions allow the programmer to select the
     324 *  approriate function or property for a specific named object model.
     325 *
     326 */
     327
     328/**
     329 *
     330 *  This function is the model chi-square minimization function for this model.
     331 *
     332 */
     333typedef psMinimizeLMChi2Func pmModelFunc;
     334
     335
     336/**
     337 *
     338 * This function returns the integrated flux for the given model parameters.
     339 */
     340typedef psF64 (*pmModelFlux)(const psVector *params);
     341
     342
     343/**
     344 *
     345 *  This function returns the radius at which the given model and parameters
     346 *  achieves the given flux.
     347 *
     348 */
     349typedef psF64 (*pmModelRadius)(const psVector *params, double flux);
     350
     351/**
     352 *
     353 *  This function sets the model parameter limits vectors for the given model
     354 *
     355 */
     356typedef bool (*pmModelLimits)(psVector **beta_lim, psVector **params_min, psVector **params_max);
     357
     358/**
     359 *
     360 *  This function provides the model guess parameters based on the details of
     361 *   the given source.
     362 *
     363 */
     364typedef bool (*pmModelGuessFunc)(pmModel *model, pmSource *source);
     365
     366
     367/**
     368 *
     369 *  This function constructs the PSF model for the given source based on the
     370 *  supplied psf and the FLT model for the object.
     371 *
     372 */
     373typedef bool (*pmModelFromPSFFunc)(pmModel *modelPSF, pmModel *modelFLT, pmPSF *psf);
     374
     375
     376/**
     377 *
     378 *  This function returns the success / failure status of the given model fit
     379 *
     380 */
     381typedef bool (*pmModelFitStatusFunc)(pmModel *model);
     382
     383/**
     384 *
     385 *  Each of the function types above has a corresponding function which returns
     386 *  the function given the model type:
     387 *
     388 */
     389pmModelFunc          pmModelFunc_GetFunction (pmModelType type);
     390pmModelFlux          pmModelFlux_GetFunction (pmModelType type);
     391pmModelRadius        pmModelRadius_GetFunction (pmModelType type);
     392pmModelLimits        pmModelLimits_GetFunction (pmModelType type);
     393pmModelGuessFunc     pmModelGuessFunc_GetFunction (pmModelType type);
     394pmModelFromPSFFunc   pmModelFromPSFFunc_GetFunction (pmModelType type);
     395pmModelFitStatusFunc pmModelFitStatusFunc_GetFunction (pmModelType type);
     396
     397// pmModelGroup utility functions
     398int                  pmModelParameterCount (pmModelType type);
     399char                *pmModelGetType (pmModelType type);
     400pmModelType          pmModelSetType (char *name);
     401
     402// structure to carry model group functions
     403typedef struct {
     404    char *name;
     405    int nParams;
     406    pmModelFunc          modelFunc;
     407    pmModelFlux          modelFlux;
     408    pmModelRadius        modelRadius;
     409    pmModelLimits        modelLimits;
     410    pmModelGuessFunc     modelGuessFunc;
     411    pmModelFromPSFFunc   modelFromPSFFunc;
     412    pmModelFitStatusFunc modelFitStatusFunc;
     413} pmModelGroup;
     414
     415#endif
  • trunk/psphot/src/pmPeaksSigmaLimit.c

    r4946 r4954  
    1616
    1717    psImage *smooth = psImageCopy (NULL, imdata->image, PS_TYPE_F32);
    18     psImageSmooth (smooth, SIGMA, NSIGMA);
     18    psImageSmooth_EAM (smooth, SIGMA, NSIGMA);
    1919    psLogMsg ("psphot", 4, "smooth: %f sec\n", psTimerMark ("psphot"));
    2020
  • trunk/psphot/src/pmSourceUtils.c

    r4949 r4954  
    77                          psF32 Radius)
    88{
    9     psRegion *srcRegion;
     9    psRegion srcRegion;
    1010
    1111    // Grab a subimage of the original image of size (2 * outerRadius).
    12     srcRegion = psRegionSquare (x, y, Radius);
    13     srcRegion = psRegionForImage (srcRegion, imdata->image, srcRegion);
     12    srcRegion = psRegionForSquare (x, y, Radius);
     13    srcRegion = psRegionForImage (imdata->image, &srcRegion);
    1414
    15     //  use these when psImageSubset is updated
    16     //  psImage *subImage = psImageSubset(imdata->image, srcRegion);
    17     //  psImage *subImageMask = psImageSubset(imdata->mask, srcRegion);
    18     //  psImage *subImageNoise = psImageSubset(imdata->noise, srcRegion);
     15    mySource->pixels = psImageSubset(imdata->image, srcRegion);
     16    mySource->noise  = psImageSubset(imdata->noise, srcRegion);
     17    mySource->mask   = psImageSubset(imdata->mask,  srcRegion);
    1918
    20     mySource->pixels = psImageSubset(imdata->image, srcRegion->x0, srcRegion->y0, srcRegion->x1, srcRegion->y1);
    21     mySource->noise  = psImageSubset(imdata->noise, srcRegion->x0, srcRegion->y0, srcRegion->x1, srcRegion->y1);
    22     mySource->mask   = psImageSubset(imdata->mask,  srcRegion->x0, srcRegion->y0, srcRegion->x1, srcRegion->y1);
    23 
    24     psFree (srcRegion);
    2519    return(mySource);
    2620}
  • trunk/psphot/src/psImageData.c

    r4946 r4954  
    2020    imdata->mask = mask;
    2121
    22     p_psMemSetDeallocator(imdata, (psFreeFcn) psImageDataFree);
     22    psMemSetDeallocator(imdata, (psFreeFunc) psImageDataFree);
    2323    return (imdata);
    2424}
  • trunk/psphot/src/psLibUtils.c

    r4946 r4954  
    1 # include "psphot.h"
     1# include <strings.h>  // for strncasecmp
     2# include <pslib.h>
     3
     4// XXX EAM : this is NOT included in the C99 headers ??
     5FILE *fdopen(int fildes, const char *mode);
    26
    37// XXX EAM : these utility functions should be added back into PSLib
     
    2933    if (timers == NULL) timers = psHashAlloc (16);
    3034
    31     start = psTimeGetTime (PS_TIME_UTC);
     35    start = psTimeGetNow (PS_TIME_UTC);
    3236    psHashAdd (timers, name, start);
    3337    psFree (start);
     
    4751    if (start == NULL) return (0);
    4852
    49     mark = psTimeGetTime (PS_TIME_UTC);
     53    mark = psTimeGetNow (PS_TIME_UTC);
    5054    delta = psTimeDelta (mark, start);
    5155    psFree (mark);
     
    5357
    5458    return (delta);
     59}
     60
     61// find the location of the specified argument
     62int psArgumentGet (int argc, char **argv, char *arg) {
     63
     64    int i;
     65
     66    for (i = 0; i < argc; i++) {
     67        if (!strcmp(argv[i], arg))
     68            return (i);
     69    }
     70 
     71    return ((int)NULL);
     72}
     73
     74// remove the specified argument (by location)
     75int psArgumentRemove (int N, int *argc, char **argv) {
     76
     77    int i;
     78
     79    if ((N != (int)NULL) && (N != 0)) {
     80        (*argc)--;
     81        for (i = N; i < *argc; i++) {
     82            argv[i] = argv[i+1];
     83        }
     84    }
     85
     86    return (N);
    5587}
    5688
     
    114146}
    115147
    116 // find the location of the specified argument
    117 int psArgumentGet (int argc, char **argv, char *arg) {
    118 
    119     int i;
    120 
    121     for (i = 0; i < argc; i++) {
    122         if (!strcmp(argv[i], arg))
    123             return (i);
    124     }
    125  
    126     return ((int)NULL);
    127 }
    128 
    129 // remove the specified argument (by location)
    130 int psArgumentRemove (int N, int *argc, char **argv) {
    131 
    132     int i;
    133 
    134     if ((N != (int)NULL) && (N != 0)) {
    135         (*argc)--;
    136         for (i = N; i < *argc; i++) {
    137             argv[i] = argv[i+1];
    138         }
    139     }
    140 
    141     return (N);
    142 }
    143 
    144148// alternate implementation of this function from pmObjects.c
     149// XXX EAM : move this to pmObjects_EAM.c
    145150psVector *psGetRowVectorFromImage(psImage *image,
    146151                                  psU32 row)
    147152{
    148     PS_IMAGE_CHECK_NULL(image, NULL);
    149     PS_IMAGE_CHECK_TYPE(image, PS_TYPE_F32, NULL);
     153    PS_ASSERT_IMAGE_NON_NULL(image, NULL);
     154    PS_ASSERT_IMAGE_TYPE(image, PS_TYPE_F32, NULL);
    150155
    151156    psVector *tmpVector = psVectorAlloc(image->numCols, PS_TYPE_F32);
     
    201206}
    202207
    203 void psImageSmooth (psImage *image, float sigma, float Nsigma) {
     208// XXX EAM : this is now in psLib
     209void psImageSmooth_EAM (psImage *image, float sigma, float Nsigma) {
    204210
    205211    int Nx, Ny, Npixel, Nrange;
     
    314320}           
    315321
     322// count number of pixels with given mask value
     323int psImageCountPixelMask (psImage *mask, psU8 value)
     324{
     325    int Npixels = 0;
     326 
     327    for (int i = 0; i < mask->numRows; i++) {
     328        for (int j = 0; j < mask->numCols; j++) {
     329            if (mask->data.U8[i][j] & value) {
     330                Npixels ++;
     331            }
     332        }
     333    }
     334    return (Npixels);
     335}
     336
    316337// define a square region centered on the given coordinate
     338// XXX EAM : this is now in psLib
     339# if (0)
    317340psRegion *psRegionSquare (psF32 x, psF32 y, psF32 radius) {
    318341    psRegion *region;
     
    321344    return (region);
    322345}
     346# endif
    323347
    324348// set actual region based on image parameters:
     
    327351//     frame, which means the negative values should subtract from Nx,Ny of
    328352//     the parent, not the child.  but, we don't carry the dimensions of the
    329 //     parent in the psImage container.  for now, us the child Nx,Ny
    330 // force range to be on this subimage
    331 // XXX EAM : this needs to be changes to use psRegion rather than psRegion*
     353//     parent in the psImage container.  for now, use the child Nx,Ny
     354//     force range to be on this subimage
     355// XXX EAM : this needs to be changed to use psRegion rather than psRegion*
     356// XXX EAM : this is now in psLib
     357# if (0)
    332358psRegion *psRegionForImage (psRegion *out, psImage *image, psRegion *in) {
    333359   
     
    356382    return (out);
    357383}
     384# endif
    358385
    359386// mask the area contained by the region
    360387// the region is defined wrt the parent image
     388// XXX EAM : this is now in psLib
     389# if (0)
    361390void psImageMaskRegion (psImage *image, psRegion *region, bool logical_and, int maskValue) {
    362391
     
    375404    }
    376405}
     406# endif
    377407
    378408// mask the area not contained by the region
    379409// the region is defined wrt the parent image
     410// XXX EAM : this is now in psLib
     411# if (0)
    380412void psImageKeepRegion (psImage *image, psRegion *region, bool logical_and, int maskValue) {
    381413
     
    396428    }
    397429}
     430# endif
    398431
    399432// mask the area contained by the region
    400433// the region is defined wrt the parent image
     434// XXX EAM : this is now in psLib
     435# if (0)
    401436void psImageMaskCircle (psImage *image, double x, double y, double radius, bool logical_and, int maskValue) {
    402437
     
    419454    }
    420455}
     456# endif
    421457
    422458// mask the area contained by the region
    423459// the region is defined wrt the parent image
     460// XXX EAM : this is now in psLib
     461# if (0)
    424462void psImageKeepCircle (psImage *image, double x, double y, double radius, bool logical_and, int maskValue) {
    425463
     
    442480    }
    443481}
     482# endif
    444483
    445484psVector *psVectorCreate (double lower, double upper, double delta, psElemType type) {
     
    455494  return (out);
    456495}
     496
     497// XXX EAM a utility function
     498bool p_psVectorPrintRow (int fd, psVector *a, char *name)
     499{
     500
     501    FILE *f;
     502    f = fdopen(fd, "a+");
     503    fprintf (f, "vector: %s\n", name);
     504
     505    for (int i = 0; i < a[0].n; i++) {
     506        fprintf (f, "%f  ", p_psVectorGetElementF64(a, i));
     507    }
     508    fprintf (f, "\n");
     509    fclose(f);
     510    return (true);
     511}
     512// XXX EAM is the use of fdopen here a good way to do this?
  • trunk/psphot/src/psLine.c

    r4946 r4954  
    1414  psLine *line;
    1515  line = psAlloc (sizeof(psLine));
    16   p_psMemSetDeallocator(line, (psFreeFcn) psLineFree);
     16  psMemSetDeallocator(line, (psFreeFunc) psLineFree);
    1717
    1818  line->Nline = 0;
  • trunk/psphot/src/psMinimize.c

    r4946 r4954  
    1313                            psMinimizeLMChi2Func func)
    1414{
    15     PS_PTR_CHECK_NULL(min, NULL);
    16     PS_VECTOR_CHECK_NULL(params, NULL);
    17     PS_VECTOR_CHECK_EMPTY(params, NULL);
    18     PS_PTR_CHECK_NULL(x, NULL);
    19     PS_VECTOR_CHECK_NULL(y, NULL);
    20     PS_VECTOR_CHECK_EMPTY(y, NULL);
    21     PS_VECTOR_CHECK_SIZE_EQUAL(x, y, NULL);
    22     PS_PTR_CHECK_NULL(func, NULL);
     15    // PS_PTR_CHECK_NULL(min, NULL);
     16    // PS_VECTOR_CHECK_NULL(params, NULL);
     17    // PS_VECTOR_CHECK_EMPTY(params, NULL);
     18    // PS_PTR_CHECK_NULL(x, NULL);
     19    // PS_VECTOR_CHECK_NULL(y, NULL);
     20    // PS_VECTOR_CHECK_EMPTY(y, NULL);
     21    // PS_VECTOR_CHECK_SIZE_EQUAL(x, y, NULL);
     22    // PS_PTR_CHECK_NULL(func, NULL);
    2323
    2424    // this function has test and current values for several things
  • trunk/psphot/src/psModulesUtils.c

    r4949 r4954  
    1111    psImage *image = source->pixels;
    1212    psImage *mask  = source->mask;
    13     psPeak *peak  = source->peak;
    14     psRegion *srcRegion;
    15 
    16     srcRegion = psRegionSquare (peak->x, peak->y, Radius);
    17     srcRegion = psRegionForImage (srcRegion, mask, srcRegion);
    18     psImageMaskRegion (mask, srcRegion, OR, 0x80);
    19 
     13    pmPeak *peak  = source->peak;
     14    psRegion srcRegion;
     15
     16    // XXX EAM : psRegionXXX funcs need value not ptr
     17
     18    srcRegion = psRegionForSquare (peak->x, peak->y, Radius);
     19    srcRegion = psRegionForImage (mask, &srcRegion);
     20
     21    psImageMaskRegion (mask, &srcRegion, "OR", PSPHOT_MASK_MARKED);
    2022    psStats *myStats = psStatsAlloc(statsOptions);
    2123    myStats = psImageStats(myStats, image, mask, 0xff);
    22     psImageMaskRegion (mask, srcRegion, AND, 0x7f);
     24    psImageMaskRegion (mask, &srcRegion, "AND", ~PSPHOT_MASK_MARKED);
    2325
    2426    psF64 tmpF64;
    2527    p_psGetStatValue(myStats, &tmpF64);
    26 
    2728    psFree (myStats);
    28     psFree (srcRegion);
    2929
    3030    if (isnan(tmpF64)) return (false);
     
    4040                             const bool PSF)
    4141{
    42     PS_PTR_CHECK_NULL(source, false);
    43     PS_PTR_CHECK_NULL(source->moments, false);
    44     PS_PTR_CHECK_NULL(source->peak, false);
    45     PS_PTR_CHECK_NULL(source->pixels, false);
    46     PS_PTR_CHECK_NULL(source->mask, false);
    47     PS_PTR_CHECK_NULL(source->noise, false);
     42    // PS_PTR_CHECK_NULL(source, false);
     43    // PS_PTR_CHECK_NULL(source->moments, false);
     44    // PS_PTR_CHECK_NULL(source->peak, false);
     45    // PS_PTR_CHECK_NULL(source->pixels, false);
     46    // PS_PTR_CHECK_NULL(source->mask, false);
     47    // PS_PTR_CHECK_NULL(source->noise, false);
    4848    psBool fitStatus = true;
    4949    psBool onPic     = true;
     
    188188 
    189189XXX: mask values?
     190
     191XXX EAM : this version clips input pixels on S/N
    190192*****************************************************************************/
    191193# define VALID_RADIUS(X,Y) (((R2) >= (PS_SQR(X) + PS_SQR(Y))) ? 1 : 0)
     
    194196                         psF32 radius)
    195197{
    196     PS_PTR_CHECK_NULL(source, NULL);
    197     PS_PTR_CHECK_NULL(source->peak, NULL);
    198     PS_PTR_CHECK_NULL(source->pixels, NULL);
    199     PS_PTR_CHECK_NULL(source->noise, NULL);
     198    // PS_PTR_CHECK_NULL(source, NULL);
     199    // PS_PTR_CHECK_NULL(source->peak, NULL);
     200    // PS_PTR_CHECK_NULL(source->pixels, NULL);
     201    // PS_PTR_CHECK_NULL(source->noise, NULL);
    200202    PS_FLOAT_COMPARE(0.0, radius, NULL);
    201203
  • trunk/psphot/src/psPolynomials.c

    r4901 r4954  
    11# include "psphot.h"
     2
     3// XXX EAM : this file defines alternate versions of the polynomial fitting
     4//           functions.  these differ from psLib v.0.5.0 in the definition
     5//           of nOrder (here we use nOrder in the mathematical sense, not
     6//           like IRAF.  ie, a linear function is of nOrder 1)
     7//           psLib v 0.7.0 should be in sync with out defintion of nOrder
     8//           If so, we can drop these functions and use the psLib versions.
    29
    310// write out the terms of the given 1D polynomial
     
    916}   
    1017
    11 psF32 Polynomial1DEval_EAM(psF32 x, const psPolynomial1D* myPoly)
     18psF64 Polynomial1DEval_EAM(psF64 x, const psPolynomial1D* myPoly)
    1219{
    1320    psS32 loop_x = 0;
    14     psF32 polySum = 0.0;
    15     psF32 xSum = 1.0;
     21    psF64 polySum = 0.0;
     22    psF64 xSum = 1.0;
    1623
    1724    for (loop_x = 0; loop_x < myPoly->n + 1; loop_x++) {
     
    2835                                       const psVector *x)
    2936{
    30     PS_POLY_CHECK_NULL(myPoly, NULL);
    31     PS_VECTOR_CHECK_NULL(x, NULL);
    32     PS_VECTOR_CHECK_TYPE(x, PS_TYPE_F64, NULL);
     37    // PS_POLY_CHECK_NULL(myPoly, NULL);
     38    // PS_VECTOR_CHECK_NULL(x, NULL);
     39    // PS_VECTOR_CHECK_TYPE(x, PS_TYPE_F64, NULL);
    3340
    3441    psVector *tmp;
     
    5663                                  psPolynomialType type)
    5764{
    58     PS_INT_CHECK_NON_NEGATIVE(nOrder, NULL);
     65    // PS_INT_CHECK_NON_NEGATIVE(nOrder, NULL);
    5966
    6067    psS32 i = 0;
     
    6572    newPoly->type = type;
    6673    newPoly->n = nOrder;
    67     newPoly->coeff = (psF32 *)psAlloc(nTerm * sizeof(psF32));
    68     newPoly->coeffErr = (psF32 *)psAlloc(nTerm * sizeof(psF32));
     74    newPoly->coeff = (psF64 *)psAlloc(nTerm * sizeof(psF64));
     75    newPoly->coeffErr = (psF64 *)psAlloc(nTerm * sizeof(psF64));
    6976    newPoly->mask = (psU8 *)psAlloc(nTerm * sizeof(psU8));
    7077    for (i = 0; i < nTerm; i++) {
     
    7380        newPoly->mask[i] = 0;
    7481    }
    75     p_psMemSetDeallocator(newPoly, (psFreeFcn) psPolynomial1DFree);
     82    psMemSetDeallocator(newPoly, (psFreeFunc) psPolynomial1DFree);
    7683    return(newPoly);
    7784}
     
    120127    // dump minutiae
    121128# ifndef PS_NO_TRACE
     129# if (0)
     130    // XXX EAM : change from FILE to fd breaks this code:
    122131    if (psTraceGetLevel (".psLib.dataManip.VectorFitPolynomial1DOrd") >= 5) {
    123132      FILE *f = psTraceGetDestination ();
     
    127136      }
    128137    }
     138# endif
    129139# endif
    130140     
     
    214224
    215225{
    216     PS_POLY_CHECK_NULL(myPoly, NULL);
    217     PS_VECTOR_CHECK_NULL(x, NULL);
    218     PS_VECTOR_CHECK_TYPE(x, PS_TYPE_F32, NULL);
    219     PS_VECTOR_CHECK_NULL(y, NULL);
    220     PS_VECTOR_CHECK_TYPE(y, PS_TYPE_F32, NULL);
     226    // PS_POLY_CHECK_NULL(myPoly, NULL);
     227    // PS_VECTOR_CHECK_NULL(x, NULL);
     228    // PS_VECTOR_CHECK_TYPE(x, PS_TYPE_F32, NULL);
     229    // PS_VECTOR_CHECK_NULL(y, NULL);
     230    // PS_VECTOR_CHECK_TYPE(y, PS_TYPE_F32, NULL);
    221231
    222232    psVector *tmp;
     
    246256
    247257{
    248     PS_POLY_CHECK_NULL(myPoly, NULL);
    249     PS_VECTOR_CHECK_NULL(x, NULL);
    250     PS_VECTOR_CHECK_TYPE(x, PS_TYPE_F64, NULL);
    251     PS_VECTOR_CHECK_NULL(y, NULL);
    252     PS_VECTOR_CHECK_TYPE(y, PS_TYPE_F64, NULL);
     258    // PS_POLY_CHECK_NULL(myPoly, NULL);
     259    // PS_VECTOR_CHECK_NULL(x, NULL);
     260    // PS_VECTOR_CHECK_TYPE(x, PS_TYPE_F64, NULL);
     261    // PS_VECTOR_CHECK_NULL(y, NULL);
     262    // PS_VECTOR_CHECK_TYPE(y, PS_TYPE_F64, NULL);
    253263
    254264    psVector *tmp;
     
    291301                                    psPolynomialType type)
    292302{
    293     PS_INT_CHECK_NON_NEGATIVE(nXorder, NULL);
    294     PS_INT_CHECK_NON_NEGATIVE(nYorder, NULL);
     303    // PS_INT_CHECK_NON_NEGATIVE(nXorder, NULL);
     304    // PS_INT_CHECK_NON_NEGATIVE(nYorder, NULL);
    295305
    296306    psS32 x = 0;
     
    305315    newPoly->nY = nYorder;
    306316
    307     newPoly->coeff = (psF32 **)psAlloc(nXterm * sizeof(psF32 *));
    308     newPoly->coeffErr = (psF32 **)psAlloc(nXterm * sizeof(psF32 *));
    309     newPoly->mask = (psU8 **)psAlloc(nXterm * sizeof(psU8 *));
     317    newPoly->coeff = (psF64 **)psAlloc(nXterm * sizeof(psF64 *));
     318    newPoly->coeffErr = (psF64 **)psAlloc(nXterm * sizeof(psF64 *));
     319    newPoly->mask = (char **)psAlloc(nXterm * sizeof(char *));
     320    // XXX EAM : this is an error in the definition of the polynomial mask
     321    //           (should be psU8 not char)
    310322    for (x = 0; x < nXterm; x++) {
    311         newPoly->coeff[x] = (psF32 *)psAlloc(nYterm * sizeof(psF32));
    312         newPoly->coeffErr[x] = (psF32 *)psAlloc(nYterm * sizeof(psF32));
    313         newPoly->mask[x] = (psU8 *)psAlloc(nYterm * sizeof(psU8));
     323        newPoly->coeff[x] = (psF64 *)psAlloc(nYterm * sizeof(psF64));
     324        newPoly->coeffErr[x] = (psF64 *)psAlloc(nYterm * sizeof(psF64));
     325        newPoly->mask[x] = (char *)psAlloc(nYterm * sizeof(char));
    314326    }
    315327    for (x = 0; x < nXterm; x++) {
     
    320332        }
    321333    }
    322     p_psMemSetDeallocator(newPoly, (psFreeFcn) psPolynomial2DFree);
     334    psMemSetDeallocator(newPoly, (psFreeFunc) psPolynomial2DFree);
    323335    return(newPoly);
    324336}
     
    510522                            const psVector* dz)
    511523{
    512     PS_VECTOR_CHECK_NULL(mask, NULL);
    513     PS_VECTOR_CHECK_NULL(x, NULL);
    514     PS_VECTOR_CHECK_NULL(y, NULL);
    515     PS_VECTOR_CHECK_NULL(z, NULL);
    516     PS_VECTOR_CHECK_NULL(dz, NULL);
     524    // PS_VECTOR_CHECK_NULL(mask, NULL);
     525    // PS_VECTOR_CHECK_NULL(x, NULL);
     526    // PS_VECTOR_CHECK_NULL(y, NULL);
     527    // PS_VECTOR_CHECK_NULL(z, NULL);
     528    // PS_VECTOR_CHECK_NULL(dz, NULL);
    517529
    518530    psVector *zFit   = NULL;
     
    548560// XXX EAM : VectorFitPolynomial2DOrd and Polynomial2DEvalVector require different types (F32 vs F64)
    549561
    550 # if (0) // moved to psLib
    551 // XXX EAM : this version uses myPoly->nX as Norder, not Nterms
    552 psF32 Polynomial2DEval(const psPolynomial2D* myPoly,
    553                        psF32 x,
    554                        psF32 y)
    555 {
    556     PS_POLY_CHECK_NULL(myPoly, NAN);
     562psF64 Polynomial2DEval(const psPolynomial2D* myPoly,
     563                       psF64 x,
     564                       psF64 y)
     565{
     566    // PS_POLY_CHECK_NULL(myPoly, NAN);
    557567
    558568    psS32 loop_x = 0;
    559569    psS32 loop_y = 0;
    560     psF32 polySum = 0.0;
    561     psF32 xSum = 1.0;
    562     psF32 ySum = 1.0;
     570    psF64 polySum = 0.0;
     571    psF64 xSum = 1.0;
     572    psF64 ySum = 1.0;
    563573
    564574    // XXX EAM : nX is order, not nTerms
     
    577587    return(polySum);
    578588}
    579 # endif
    580 
  • trunk/psphot/src/psphot.h

    r4949 r4954  
     1# include <stdio.h>
     2# include <strings.h>  // for strcasecmp
     3# include <unistd.h>   // for unlink
    14# include <pslib.h>
    2 // # include <pmObjects.h>
    3 // my additions and modifications:
    45# include "pmObjects_EAM.h"
    5 # include <string.h>
    6 # include <strings.h>
    7 # include <unistd.h>
    8 # include <stdlib.h>
    9 # include <math.h>
    10 
    11 // # define  M_PI 3.14159265358979323846264338328      /* pi */
    126
    137typedef struct {
    14   psImage *image;
    15   psImage *mask;
    16   psImage *noise;
    17   psMetadata *header;
     8    psImage *image;
     9    psImage *mask;
     10    psImage *noise;
     11    psMetadata *header;
    1812} psImageData;
    1913
    2014// data to test a given PSF model type
    2115typedef struct {
    22   pmModelType modelType;
    23   pmPSF      *psf;
    24   psArray    *sources;      // pointers to the original sources
    25   psArray    *modelFLT;     // model fits, floating parameters
    26   psArray    *modelPSF;     // model fits, PSF parameters
    27   psVector   *mask;
    28   psVector   *metric;
    29   psVector   *fitMag;
    30   float       ApResid;
    31   float       dApResid;
    32   float       skyBias;
     16    pmModelType modelType;
     17    pmPSF      *psf;
     18    psArray    *sources;      // pointers to the original sources
     19    psArray    *modelFLT;     // model fits, floating parameters
     20    psArray    *modelPSF;     // model fits, PSF parameters
     21    psVector   *mask;
     22    psVector   *metric;
     23    psVector   *fitMag;
     24    float       ApResid;
     25    float       dApResid;
     26    float       skyBias;
    3327} pmPSF_Test;
    3428
    3529// structure to carry a dynamic string
    3630typedef struct {
    37   int NLINE;
    38   int Nline;
    39   char *line;
     31    int NLINE;
     32    int Nline;
     33    char *line;
    4034} psLine;
    4135
     
    4337    PSPHOT_MASK_INVALID   = 0x01,
    4438    PSPHOT_MASK_SATURATED = 0x02,
    45     PSPHOT_MASK_KEEP      = 0x08,
     39    PSPHOT_MASK_MARKED    = 0x08,
    4640} MaskValues;
    47 
    48 // used by mask operations
    49 # define AND true
    50 # define OR false
    5141
    5242# define psMemCopy(A)(psMemIncrRefCounter((A)))
     
    116106psF32        pmConfigLookupF32 (bool *status, psMetadata *config, psMetadata *header, char *name);
    117107psVector    *psVectorCreate (double lower, double upper, double delta, psElemType type);
    118 //void       psImageMaskRegion (psImage *image, psRegion *region, bool logical_and, int maskValue);
    119 //void       psImageKeepRegion (psImage *image, psRegion *region, bool logical_and, int maskValue);
    120 //void       psImageMaskCircle (psImage *image, double x, double y, double radius, bool logical_and, int maskValue);
    121 //void       psImageKeepCircle (psImage *image, double x, double y, double radius, bool logical_and, int maskValue);
    122108psVector    *psGetRowVectorFromImage(psImage *image, psU32 row);
     109int          psImageCountPixelMask (psImage *mask, psU8 value);
    123110
    124111// basic image functions
    125112bool         psImageInit (psImage *image,...);
    126 //void       psImageSmooth (psImage *image, float sigma, float Nsigma);
    127 //psRegion    *psRegionForImage (psRegion *out, psImage *image, psRegion *in);
    128 psRegion    *psRegionSquare (psF32 x, psF32 y, psF32 radius);
     113void         psImageSmooth_EAM (psImage *image, float sigma, float Nsigma);
    129114int          psphotSaveImage (psMetadata *header, psImage *image, char *filename);
    130115
     
    135120
    136121// polynomial functions
    137 psF32           Polynomial2DEval(const psPolynomial2D* myPoly, psF32 x, psF32 y);
     122psF64           Polynomial2DEval(const psPolynomial2D* myPoly, psF64 x, psF64 y);
    138123psImage        *psBuildSums2D(psImage* sums,psF64 x,psF64 y,psS32 nXterm, psS32 nYterm);
    139124psPolynomial2D *VectorFitPolynomial2DOrd_EAM(psPolynomial2D* myPoly, psVector* mask, const psVector* x, const psVector* y, const psVector* z, const psVector* zErr);
     
    143128psPolynomial2D *RobustFit2D(psPolynomial2D* poly, psVector* mask, const psVector* x, const psVector* y, const psVector* z, const psVector* zErr);
    144129psVector       *Polynomial2DEvalVector(const psPolynomial2D *myPoly, const psVector *x,const psVector *y);
     130
    145131psVector       *psBuildSums1D(psVector* sums, psF64 x,psS32 nTerm);
    146132void            psPolynomial1DDump (psPolynomial1D *poly);
    147 psF32           Polynomial1DEval_EAM(psF32 x, const psPolynomial1D* myPoly);
     133psF64           Polynomial1DEval_EAM(psF64 x, const psPolynomial1D* myPoly);
    148134psVector       *Polynomial1DEvalVector_EAM(const psPolynomial1D *myPoly, const psVector *x);
    149135psPolynomial1D *Polynomial1DAlloc(psS32 nOrder, psPolynomialType type);
    150136psPolynomial1D *VectorFitPolynomial1DOrd_EAM(psPolynomial1D* myPoly, psVector* mask, const psVector* x, const psVector* y, const psVector* yErr);
    151137
    152 // fitsource
    153 bool            onesource (psImageData *imdata, psMetadata *config, char *modelName, float x, float y);
    154 psMetadata     *fs_args (int *argc, char **argv);
    155 int             fs_usage ();
    156 bool            DumpImage (psImage *image, char *filename);
     138// XXX EAM : bug : missing from psLib/*.h
     139bool psMinimizeGaussNewtonDelta (psVector *delta,
     140                                 const psVector *params,
     141                                 const psVector *paramMask,
     142                                 const psArray  *x,
     143                                 const psVector *y,
     144                                 const psVector *yErr,
     145                                 psMinimizeLMChi2Func func);
     146
     147// not included in the .h file?
     148bool p_psVectorPrint (
     149    int fd,                            ///< output file descriptor
     150    psVector *a,                       ///< vector to print
     151    char *name                         ///< name of vector (for title)
     152);
     153
     154bool p_psVectorPrintRow (int fd, psVector *a, char *name);
  • trunk/psphot/src/psphotApplyPSF.c

    r4949 r4954  
    6666
    6767        // fit PSF model (set/unset the pixel mask)
    68         psImageKeepCircle (source->mask, x, y, model->radius, "or", PSPHOT_MASK_KEEP);
     68        psImageKeepCircle (source->mask, x, y, model->radius, "OR", PSPHOT_MASK_MARKED);
    6969        status = pmSourceFitModel (source, model, true);
    70         psImageKeepCircle (source->mask, x, y, model->radius, "and", ~PSPHOT_MASK_KEEP);
     70        psImageKeepCircle (source->mask, x, y, model->radius, "AND", ~PSPHOT_MASK_MARKED);
    7171        if (!status || (model->params->data.F32[1] < 0)) {
    7272          psLogMsg ("psphot", 3, "PSF fit failed for %f, %f (%d iterations)\n", x, y, model->nIter);
  • trunk/psphot/src/psphotArguments.c

    r4946 r4954  
    4343  psMetadata *config = psMetadataAlloc ();
    4444  psMetadataAdd (config, PS_LIST_HEAD, "PSF_MODEL", PS_META_MULTI, "folder for psf model entries", NULL);
    45   config = psMetadataParseConfig (config, &Nfail, argv[3], FALSE);
     45  config = psMetadataConfigParse (config, &Nfail, argv[3], FALSE);
    4646  fprintf (stderr, "loaded config...\n");
    4747
  • trunk/psphot/src/psphotFitGalaxies.c

    r4949 r4954  
    5050
    5151        // recalculate the source moments using the larger galaxy moments radius
    52         status = pmSourceMoments (source, GAL_MOMENTS_RAD);
     52        // XXX EAM : 0.5.0 code used _EAM version
     53        // status = pmSourceMoments (source, GAL_MOMENTS_RAD);
     54        status = pmSourceMoments_EAM (source, GAL_MOMENTS_RAD);
    5355        if (!status) {
    5456          source->type = PS_SOURCE_DROP_GALAXY;  // better choice?
     
    7476
    7577        // fit FLT (not PSF) model (set/unset the pixel mask)
    76         psImageKeepCircle (source->mask, x, y, model->radius, OR, PSPHOT_MASK_KEEP);
     78        psImageKeepCircle (source->mask, x, y, model->radius, "OR", PSPHOT_MASK_MARKED);
     79        // XXX EAM : 0.5.0 code used _EAM version
     80        // status = pmSourceFitModel (source, model, false);
    7781        status = pmSourceFitModel (source, model, false);
    78         psImageKeepCircle (source->mask, x, y, model->radius, AND, ~PSPHOT_MASK_KEEP);
     82        psImageKeepCircle (source->mask, x, y, model->radius, "AND", ~PSPHOT_MASK_MARKED);
    7983        if (!status) {
    8084          // if the fit fails, we need to change the classification
  • trunk/psphot/src/psphotOutput.c

    r4949 r4954  
    372372
    373373// write the peaks to an output file
    374 bool psPeaksWriteText (psArray *sources, char *filename) {
     374bool pmPeaksWriteText (psArray *sources, char *filename) {
    375375
    376376    int i;
    377377    FILE *f;
    378     psPeak *peak;
     378    pmPeak *peak;
    379379       
    380380    f = fopen (filename, "w");
    381381    if (f == NULL) {
    382         psLogMsg ("psPeaksWriteText", 3, "can't open output file for peaks%s\n", filename);
    383         return false;
    384     }
    385 
    386     for (i = 0; i < sources->n; i++) {
    387         peak = (psPeak *) sources->data[i];
     382        psLogMsg ("pmPeaksWriteText", 3, "can't open output file for peaks%s\n", filename);
     383        return false;
     384    }
     385
     386    for (i = 0; i < sources->n; i++) {
     387        peak = (pmPeak *) sources->data[i];
    388388        if (peak == NULL) continue;
    389389        fprintf (f, "%5d %5d  %7.1f\n",
     
    638638    unlink (filename);
    639639    psFits *fits = psFitsAlloc (filename);
    640     psFitsWriteImage (fits, header, image, 0, NULL);
     640    psFitsWriteImage (fits, header, image, 0);
    641641    psFree (fits);
    642642    return (TRUE);
  • trunk/psphot/src/psphotSetup.c

    r4949 r4954  
    7575    psRegion keep = psRegionSet (XMIN, XMAX, YMIN, YMAX);
    7676    keep = psRegionForImage (image, &keep);
    77     psImageKeepRegion (mask, &keep, OR, PSPHOT_MASK_INVALID);
     77    psImageKeepRegion (mask, &keep, "OR", PSPHOT_MASK_INVALID);
    7878    // XXX EAM : psRegionForImage should not take psRegion *keep
    7979
  • trunk/psphot/src/psphotSourceStats.c

    r4949 r4954  
    3535
    3636        // measure basic source moments
    37         status = pmSourceMoments (source, RADIUS);
     37        // XXX EAM : choose between these two versions
     38        status = pmSourceMoments_EAM (source, RADIUS);
    3839        if (!status) {
    3940          psFree (source);
  • trunk/psphot/src/pspsf.c

    r4949 r4954  
    3131    }
    3232
    33     p_psMemSetDeallocator(psf, (psFreeFcn) pmPSFFree);
     33    psMemSetDeallocator(psf, (psFreeFunc) pmPSFFree);
    3434    return(psf);
    3535}
     
    7474    }   
    7575
    76     p_psMemSetDeallocator(test, (psFreeFcn) pmPSF_TestFree);
     76    psMemSetDeallocator(test, (psFreeFunc) pmPSF_TestFree);
    7777    return (test);
    7878}
     
    106106        // set temporary object mask and fit object
    107107        // fit model as FLT, not PSF
    108         psImageKeepCircle (source->mask, x, y, RADIUS, OR, 0x80);
     108        psImageKeepCircle (source->mask, x, y, RADIUS, "OR", PSPHOT_MASK_MARKED);
    109109        status = pmSourceFitModel (source, model, false);
    110         psImageKeepCircle (source->mask, x, y, RADIUS, AND, 0x7f);
     110        psImageKeepCircle (source->mask, x, y, RADIUS, "AND", ~PSPHOT_MASK_MARKED);
    111111
    112112        // exclude the poor fits
     
    142142        y = source->peak->y;
    143143
    144         psImageKeepCircle (source->mask, x, y, RADIUS, OR, 0x80);
     144        psImageKeepCircle (source->mask, x, y, RADIUS, "OR", PSPHOT_MASK_MARKED);
    145145        status = pmSourceFitModel (source, modelPSF, true);
    146146
     
    168168
    169169    next_source:
    170         psImageKeepCircle (source->mask, x, y, RADIUS, AND, 0x7f);
     170        psImageKeepCircle (source->mask, x, y, RADIUS, "AND", ~PSPHOT_MASK_MARKED);
    171171
    172172    }
Note: See TracChangeset for help on using the changeset viewer.