IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 9879


Ignore:
Timestamp:
Nov 6, 2006, 11:04:08 PM (20 years ago)
Author:
magnier
Message:

moved psphotGrowthCurve to pmGrowthCurveGenerate

Location:
trunk/psModules/src/objects
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/psModules/src/objects/pmGrowthCurve.c

    r9730 r9879  
    55 *  @author EAM, IfA
    66 *
    7  *  @version $Revision: 1.6 $ $Name: not supported by cvs2svn $
    8  *  @date $Date: 2006-10-24 22:55:05 $
     7 *  @version $Revision: 1.7 $ $Name: not supported by cvs2svn $
     8 *  @date $Date: 2006-11-07 09:04:08 $
    99 *
    1010 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    1717
    1818#include <pslib.h>
     19#include "pmFPA.h"
     20#include "pmFPAMaskWeight.h"
     21#include "pmPeaks.h"
     22#include "pmMoments.h"
     23#include "pmModel.h"
     24#include "pmSource.h"
    1925#include "pmGrowthCurve.h"
     26#include "pmPSF.h"
    2027#include "psVectorBracket.h"
     28#include "pmSourcePhotometry.h"
    2129
    2230static void pmGrowthCurveFree (pmGrowthCurve *growth)
     
    5765}
    5866
     67// we generate the growth curve for the center of the image with the specified psf model
     68bool pmGrowthCurveGenerate (pmReadout *readout, pmPSF *psf, bool ignore)
     69{
     70
     71    // bool status;
     72    float xc, yc, dx, dy;
     73    float fitMag, apMag;
     74    float radius;
     75
     76    // create template model
     77    pmModel *modelRef = pmModelAlloc(psf->type);
     78
     79    // use the center of the center pixel of the image
     80    xc = 0.5*readout->image->numCols + readout->image->col0 + 0.5;
     81    yc = 0.5*readout->image->numRows + readout->image->row0 + 0.5;
     82    dx = psf->growth->maxRadius + 1;
     83    dy = psf->growth->maxRadius + 1;
     84
     85    // assign the x and y coords to the image center
     86    // create an object with center intensity of 1000
     87    modelRef->params->data.F32[PM_PAR_SKY] = 0;
     88    modelRef->params->data.F32[PM_PAR_I0] = 1000;
     89    modelRef->params->data.F32[PM_PAR_XPOS] = xc;
     90    modelRef->params->data.F32[PM_PAR_YPOS] = yc;
     91
     92    // create modelPSF from this model
     93    pmModel *model = pmModelFromPSF (modelRef, psf);
     94
     95    // measure the fitMag for this model
     96    pmSourcePhotometryModel (&fitMag, model);
     97    psf->growth->fitMag = fitMag;
     98
     99    // generate working image for this source
     100    psRegion region = {xc - dx, xc + dx, yc - dy, yc + dy};
     101    psImage *view = psImageSubset (readout->image, region);
     102    psImage *image = psImageCopy (NULL, view, PS_TYPE_F32);
     103    psImage *mask = psImageCopy (NULL, view, PS_TYPE_U8);
     104
     105    psImageInit (image, 0.0);
     106    psImageInit (mask, 0);
     107
     108    // place the reference object in the image center
     109    // no need to mask the source here
     110    pmModelAdd (image, NULL, model, false, false);
     111
     112    // loop over a range of source fluxes
     113    // no need to interpolate since we have forced the object center
     114    // to 0.5, 0.5 above
     115    for (int i = 0; i < psf->growth->radius->n; i++) {
     116
     117        radius = psf->growth->radius->data.F32[i];
     118
     119        // mask the given aperture and measure the apMag
     120        psImageKeepCircle (mask, xc, yc, radius, "OR", PM_MASK_MARK);
     121        pmSourcePhotometryAper (&apMag, model, image, mask);
     122        psImageKeepCircle (mask, xc, yc, radius, "AND", PS_NOT_U8(PM_MASK_MARK));
     123
     124        // the 'ignore' mode is for testing
     125        if (ignore) {
     126            psf->growth->apMag->data.F32[i] = fitMag;
     127        } else {
     128            psf->growth->apMag->data.F32[i] = apMag;
     129        }
     130    }
     131
     132    psf->growth->apRef = psVectorInterpolate (psf->growth->radius, psf->growth->apMag, psf->growth->refRadius);
     133    psf->growth->apLoss = psf->growth->fitMag - psf->growth->apRef;
     134
     135    psLogMsg ("psphot.growth", 4, "GrowthCurve : apLoss : %f\n", psf->growth->apLoss);
     136
     137    psFree (view);
     138    psFree (image);
     139    psFree (mask);
     140    psFree (model);
     141    psFree (modelRef);
     142
     143    return true;
     144}
  • trunk/psModules/src/objects/pmGrowthCurve.h

    r9296 r9879  
    1717pmGrowthCurve *pmGrowthCurveAlloc (psF32 minRadius, psF32 maxRadius, psF32 refRadius);
    1818psF32 pmGrowthCurveCorrect (pmGrowthCurve *growth, psF32 radius);
     19bool pmGrowthCurveGenerate (pmReadout *readout, pmPSF *psf, bool ignore);
    1920
    2021# endif /* PM_GROWTH_CURVE_H */
Note: See TracChangeset for help on using the changeset viewer.