IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Apr 17, 2006, 8:10:08 AM (20 years ago)
Author:
magnier
Message:

fixed up conflicts

File:
1 edited

Legend:

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

    r6511 r6873  
    66 *  @author EAM, IfA
    77 *
    8  *  @version $Revision: 1.5 $ $Name: not supported by cvs2svn $
    9  *  @date $Date: 2006-03-04 01:01:33 $
     8 *  @version $Revision: 1.6 $ $Name: not supported by cvs2svn $
     9 *  @date $Date: 2006-04-17 18:10:08 $
    1010 *
    1111 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    1818
    1919#include <pslib.h>
    20 #include "pmObjects.h"
     20#include "pmHDU.h"
     21#include "pmFPA.h"
     22#include "pmPeaks.h"
     23#include "pmMoments.h"
     24#include "pmModel.h"
     25#include "pmSource.h"
     26#include "pmGrowthCurve.h"
    2127#include "pmPSF.h"
    2228#include "pmModelGroup.h"
     
    5763        return;
    5864
     65    psFree (psf->ApTrend);
     66    psFree (psf->growth);
    5967    psFree (psf->params);
    6068    return;
     
    6977 X-center
    7078 Y-center
    71  ???: Sky background value?
    72  ???: Zo?
     79 Sky background value
     80 Object Normalization
    7381 *****************************************************************************/
    74 pmPSF *pmPSFAlloc (pmModelType type)
     82pmPSF *pmPSFAlloc (pmModelType type, bool poissonErrors)
    7583{
    7684    int Nparams;
     
    8391    psf->dApResid = 0.0;
    8492    psf->skyBias  = 0.0;
     93    psf->skySat   = 0.0;
     94    psf->poissonErrors = poissonErrors;
     95
     96    // the ApTrend components are (x, y, r2rflux, flux)
     97    psf->ApTrend = psPolynomial4DAlloc (PS_POLYNOMIAL_ORD, 2, 2, 1, 1);
     98    pmPSF_MaskApTrend (psf, PM_PSF_SKYBIAS);
     99
     100    if (psf->poissonErrors) {
     101        psf->ChiTrend = psPolynomial1DAlloc (PS_POLYNOMIAL_ORD, 1);
     102    } else {
     103        psf->ChiTrend = psPolynomial1DAlloc (PS_POLYNOMIAL_ORD, 2);
     104    }
     105
     106    // don't define a growth curve : user needs to choose radius bins
     107    psf->growth = NULL;
    85108
    86109    Nparams = pmModelParameterCount (type);
     
    94117    for (int i = 0; i < psf->params->n; i++) {
    95118        // XXX EAM : make this a user-defined value?
    96         psf->params->data[i] = psPolynomial2DAlloc(1, 1, PS_POLYNOMIAL_ORD);
     119        psf->params->data[i] = psPolynomial2DAlloc(PS_POLYNOMIAL_ORD, 1, 1);
    97120    }
    98121
     
    174197
    175198/*****************************************************************************
    176 pmModelFromPSF (*modelFLT, *psf):  use the model position parameters to
     199pmModelFromPSF (*modelEXT, *psf):  use the model position parameters to
    177200construct a realization of the PSF model at the object coordinates
    178201 *****************************************************************************/
    179 pmModel *pmModelFromPSF (pmModel *modelFLT, pmPSF *psf)
    180 {
    181 
    182     // need to define the relationship between the modelFLT and modelPSF ?
     202pmModel *pmModelFromPSF (pmModel *modelEXT, pmPSF *psf)
     203{
     204
     205    // need to define the relationship between the modelEXT and modelPSF ?
    183206
    184207    // find function used to set the model parameters
     
    189212
    190213    // set model parameters for this source based on PSF information
    191     modelFromPSFFunc (modelPSF, modelFLT, psf);
     214    modelFromPSFFunc (modelPSF, modelEXT, psf);
    192215
    193216    return (modelPSF);
    194217}
     218
     219// zero and mask out all terms:
     220static bool maskAllTerms (psPolynomial4D *trend)
     221{
     222
     223    for (int i = 0; i < trend->nX + 1; i++) {
     224        for (int j = 0; j < trend->nY + 1; j++) {
     225            for (int k = 0; k < trend->nZ + 1; k++) {
     226                for (int m = 0; m < trend->nT + 1; m++) {
     227                    trend->mask[i][j][k][m] = 1;  // mask coeff
     228                    trend->coeff[i][j][k][m] = 0;  // zero coeff
     229                }
     230            }
     231        }
     232    }
     233    return true;
     234}
     235
     236/***********************************************
     237 * this function masks the psf.ApTrend polynomial
     238 * to enable the specific subset of the coefficients
     239 **********************************************/
     240bool pmPSF_MaskApTrend (pmPSF *psf, pmPSF_ApTrendOptions option)
     241{
     242
     243    switch (option) {
     244    case PM_PSF_NONE:
     245        maskAllTerms (psf->ApTrend);
     246        return true;
     247
     248    case PM_PSF_CONSTANT:
     249        maskAllTerms (psf->ApTrend);
     250        psf->ApTrend->mask[0][0][0][0] = 0;  // unmask constant
     251        return true;
     252
     253    case PM_PSF_SKYBIAS:
     254        maskAllTerms (psf->ApTrend);
     255        psf->ApTrend->mask[0][0][0][0] = 0;  // unmask constant
     256        psf->ApTrend->mask[0][0][1][0] = 0;  // unmask skybias
     257        return true;
     258
     259    case PM_PSF_SKYSAT:
     260        maskAllTerms (psf->ApTrend);
     261        psf->ApTrend->mask[0][0][0][0] = 0;  // unmask constant
     262        psf->ApTrend->mask[0][0][1][0] = 0;  // unmask skybias
     263        psf->ApTrend->mask[0][0][0][1] = 0;  // unmask skybias
     264        return true;
     265
     266    case PM_PSF_XY_LIN:
     267        maskAllTerms (psf->ApTrend);
     268        psf->ApTrend->mask[0][0][0][0] = 0;  // unmask constant
     269        psf->ApTrend->mask[1][0][0][0] = 0;  // unmask x
     270        psf->ApTrend->mask[0][1][0][0] = 0;  // unmask y
     271        return true;
     272
     273    case PM_PSF_XY_QUAD:
     274        maskAllTerms (psf->ApTrend);
     275        psf->ApTrend->mask[0][0][0][0] = 0;  // unmask constant
     276        psf->ApTrend->mask[1][0][0][0] = 0;  // unmask x
     277        psf->ApTrend->mask[2][0][0][0] = 0;  // unmask x^2
     278        psf->ApTrend->mask[1][1][0][0] = 0;  // unmask x y
     279        psf->ApTrend->mask[0][1][0][0] = 0;  // unmask y
     280        psf->ApTrend->mask[0][2][0][0] = 0;  // unmask y^2
     281        return true;
     282
     283    case PM_PSF_SKY_XY_LIN:
     284        maskAllTerms (psf->ApTrend);
     285        psf->ApTrend->mask[0][0][0][0] = 0;  // unmask constant
     286        psf->ApTrend->mask[1][0][0][0] = 0;  // unmask x
     287        psf->ApTrend->mask[0][1][0][0] = 0;  // unmask y
     288        psf->ApTrend->mask[0][0][1][0] = 0;  // unmask skybias
     289        return true;
     290
     291    case PM_PSF_SKYSAT_XY_LIN:
     292        maskAllTerms (psf->ApTrend);
     293        psf->ApTrend->mask[0][0][0][0] = 0;  // unmask constant
     294        psf->ApTrend->mask[1][0][0][0] = 0;  // unmask x
     295        psf->ApTrend->mask[0][1][0][0] = 0;  // unmask y
     296        psf->ApTrend->mask[0][0][1][0] = 0;  // unmask skybias
     297        psf->ApTrend->mask[0][0][0][1] = 0;  // unmask skysat
     298        return true;
     299
     300    case PM_PSF_ALL:
     301    default:
     302        maskAllTerms (psf->ApTrend);
     303        psf->ApTrend->mask[0][0][0][0] = 0;  // unmask constant
     304        psf->ApTrend->mask[0][0][1][0] = 0;  // unmask skybias
     305        psf->ApTrend->mask[0][0][0][1] = 0;  // unmask skysat
     306
     307        psf->ApTrend->mask[1][0][0][0] = 0;  // unmask x
     308        psf->ApTrend->mask[2][0][0][0] = 0;  // unmask x^2
     309        psf->ApTrend->mask[1][1][0][0] = 0;  // unmask x y
     310        psf->ApTrend->mask[0][1][0][0] = 0;  // unmask y
     311        psf->ApTrend->mask[0][2][0][0] = 0;  // unmask y^2
     312        return true;
     313    }
     314    return false;
     315}
Note: See TracChangeset for help on using the changeset viewer.