IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Nov 7, 2006, 12:55:40 PM (20 years ago)
Author:
jhoblitt
Message:

move pmGrowthCurveGenerate() from pmGrowthCurve.c -> pmPSF.c

File:
1 edited

Legend:

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

    r9882 r9897  
    66 *  @author EAM, IfA
    77 *
    8  *  @version $Revision: 1.15 $ $Name: not supported by cvs2svn $
    9  *  @date $Date: 2006-11-07 09:08:59 $
     8 *  @version $Revision: 1.16 $ $Name: not supported by cvs2svn $
     9 *  @date $Date: 2006-11-07 22:55:40 $
    1010 *
    1111 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    3232#include "pmPSF.h"
    3333#include "pmModelGroup.h"
     34#include "pmSourcePhotometry.h"
     35#include "pmFPAMaskWeight.h"
     36#include "psVectorBracket.h"
    3437
    3538/*****************************************************************************/
     
    364367}
    365368
     369// we generate the growth curve for the center of the image with the specified psf model
     370bool pmGrowthCurveGenerate (pmReadout *readout, pmPSF *psf, bool ignore)
     371{
     372
     373    // bool status;
     374    float xc, yc, dx, dy;
     375    float fitMag, apMag;
     376    float radius;
     377
     378    // create template model
     379    pmModel *modelRef = pmModelAlloc(psf->type);
     380
     381    // use the center of the center pixel of the image
     382    xc = 0.5*readout->image->numCols + readout->image->col0 + 0.5;
     383    yc = 0.5*readout->image->numRows + readout->image->row0 + 0.5;
     384    dx = psf->growth->maxRadius + 1;
     385    dy = psf->growth->maxRadius + 1;
     386
     387    // assign the x and y coords to the image center
     388    // create an object with center intensity of 1000
     389    modelRef->params->data.F32[PM_PAR_SKY] = 0;
     390    modelRef->params->data.F32[PM_PAR_I0] = 1000;
     391    modelRef->params->data.F32[PM_PAR_XPOS] = xc;
     392    modelRef->params->data.F32[PM_PAR_YPOS] = yc;
     393
     394    // create modelPSF from this model
     395    pmModel *model = pmModelFromPSF (modelRef, psf);
     396
     397    // measure the fitMag for this model
     398    pmSourcePhotometryModel (&fitMag, model);
     399    psf->growth->fitMag = fitMag;
     400
     401    // generate working image for this source
     402    psRegion region = {xc - dx, xc + dx, yc - dy, yc + dy};
     403    psImage *view = psImageSubset (readout->image, region);
     404    psImage *image = psImageCopy (NULL, view, PS_TYPE_F32);
     405    psImage *mask = psImageCopy (NULL, view, PS_TYPE_U8);
     406
     407    psImageInit (image, 0.0);
     408    psImageInit (mask, 0);
     409
     410    // place the reference object in the image center
     411    // no need to mask the source here
     412    pmModelAdd (image, NULL, model, false, false);
     413
     414    // loop over a range of source fluxes
     415    // no need to interpolate since we have forced the object center
     416    // to 0.5, 0.5 above
     417    for (int i = 0; i < psf->growth->radius->n; i++) {
     418
     419        radius = psf->growth->radius->data.F32[i];
     420
     421        // mask the given aperture and measure the apMag
     422        psImageKeepCircle (mask, xc, yc, radius, "OR", PM_MASK_MARK);
     423        pmSourcePhotometryAper (&apMag, model, image, mask);
     424        psImageKeepCircle (mask, xc, yc, radius, "AND", PS_NOT_U8(PM_MASK_MARK));
     425
     426        // the 'ignore' mode is for testing
     427        if (ignore) {
     428            psf->growth->apMag->data.F32[i] = fitMag;
     429        } else {
     430            psf->growth->apMag->data.F32[i] = apMag;
     431        }
     432    }
     433
     434    psf->growth->apRef = psVectorInterpolate (psf->growth->radius, psf->growth->apMag, psf->growth->refRadius);
     435    psf->growth->apLoss = psf->growth->fitMag - psf->growth->apRef;
     436
     437    psLogMsg ("psphot.growth", 4, "GrowthCurve : apLoss : %f\n", psf->growth->apLoss);
     438
     439    psFree (view);
     440    psFree (image);
     441    psFree (mask);
     442    psFree (model);
     443    psFree (modelRef);
     444
     445    return true;
     446}
Note: See TracChangeset for help on using the changeset viewer.