IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

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

updates relative to rel10_ifa_1

Location:
trunk/psModules/src/objects
Files:
29 added
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/psModules/src/objects/Makefile.am

    r5844 r6872  
    11noinst_LTLIBRARIES = libpsmoduleobjects.la
    22
    3 libpsmoduleobjects_la_CPPFLAGS = $(SRCINC) $(PSMODULE_CFLAGS)
     3libpsmoduleobjects_la_CPPFLAGS = $(SRCINC) $(PSMODULE_CFLAGS) -I../pslib/
    44libpsmoduleobjects_la_LDFLAGS  = -release $(PACKAGE_VERSION)
    55libpsmoduleobjects_la_SOURCES  = \
    6     pmObjects.c \
    7     pmPSF.c \
    8     pmPSFtry.c \
    9     pmModelGroup.c \
    10     psEllipse.c
     6     pmPeaks.c \
     7     pmMoments.c \
     8     pmModel.c \
     9     pmModelGroup.c \
     10     pmSource.c \
     11     pmSourceSky.c \
     12     pmSourceContour.c \
     13     pmSourceFitModel.c \
     14     pmSourcePhotometry.c \
     15     pmSourceIO.c \
     16     pmSourceIO_CMF.c \
     17     pmSourceIO_CMP.c \
     18     pmSourceIO_OBJ.c \
     19     pmSourceIO_SX.c \
     20     pmSourceIO_RAW.c \
     21     pmPSF.c \
     22     pmPSF_IO.c \
     23     pmPSFtry.c \
     24     pmGrowthCurve.c
    1125
    1226EXTRA_DIST = \
     
    1832psmoduleincludedir = $(includedir)
    1933psmoduleinclude_HEADERS = \
    20     pmObjects.h \
    21     pmPSF.h \
    22     pmPSFtry.h \
    23     pmModelGroup.h \
    24     psEllipse.h
     34     pmPeaks.h \
     35     pmMoments.h \
     36     pmModel.h \
     37     pmModelGroup.h \
     38     pmSource.h \
     39     pmSourceSky.h \
     40     pmSourceContour.h \
     41     pmSourceFitModel.h \
     42     pmSourcePhotometry.h \
     43     pmSourceIO.h \
     44     pmPSF.h \
     45     pmPSF_IO.h \
     46     pmPSFtry.h \
     47     pmGrowthCurve.h
  • trunk/psModules/src/objects/models/pmModel_PGAUSS.c

    r6511 r6872  
    2626
    2727    if (deriv != NULL) {
    28         // note difference from a pure gaussian: q = PAR[1]*r
     28        psF32 *dPAR = deriv->data.F32;
    2929        psF32 q = PAR[1]*r*r*t;
    30         deriv->data.F32[0] = +1.0;
    31         deriv->data.F32[1] = +r;
    32         deriv->data.F32[2] = q*(2.0*px*PAR[4] + PAR[6]*Y);
    33         deriv->data.F32[3] = q*(2.0*py*PAR[5] + PAR[6]*X);
    34         deriv->data.F32[4] = -2.0*q*px*X;
    35         deriv->data.F32[5] = -2.0*q*py*Y;
    36         deriv->data.F32[6] = -q*X*Y;
     30        dPAR[0] = +1.0;
     31        dPAR[1] = +r;
     32        dPAR[2] = q*(2.0*px*PAR[4] + PAR[6]*Y);
     33        dPAR[3] = q*(2.0*py*PAR[5] + PAR[6]*X);
     34        dPAR[4] = -2.0*q*px*X;
     35        dPAR[5] = -2.0*q*py*Y;
     36        dPAR[6] = -q*X*Y;
    3737    }
    3838    return(f);
     
    5050
    5151    beta_lim[0][0].data.F32[0] = 1000;
    52     beta_lim[0][0].data.F32[1] = 10000;
     52    beta_lim[0][0].data.F32[1] = 3e6;
    5353    beta_lim[0][0].data.F32[2] = 5;
    5454    beta_lim[0][0].data.F32[3] = 5;
     
    6666
    6767    params_max[0][0].data.F32[0] = 1e5;
    68     params_max[0][0].data.F32[1] = 1e6;
     68    params_max[0][0].data.F32[1] = 1e8;
    6969    params_max[0][0].data.F32[2] = 1e4;  // this should be set by image dimensions!
    7070    params_max[0][0].data.F32[3] = 1e4;  // this should be set by image dimensions!
     
    133133    params[5] = 1.2 / moments->Sy;
    134134    params[6] = 0.0;
     135
    135136    return(true);
    136137}
  • trunk/psModules/src/objects/models/pmModel_QGAUSS.c

    r6511 r6872  
    2626    psF32 py = PAR[5]*Y;
    2727    psF32 z  = 0.5*PS_SQR(px) + 0.5*PS_SQR(py) + PAR[6]*X*Y;
    28 
    29     psF32 r  = 1.0 / (1 + PAR[7]*z + pow(z, 2.25));
    30     psF32 f  = PAR[1]*r + PAR[0];
     28    psF32 zp = pow(z,1.25);
     29
     30    psF32 r  = 1.0 / (1 + PAR[7]*z + z*zp);
     31    // test: psF32 r  = 1.0 / (1 + PAR[7]*z + PS_SQR(z));
     32    psF32 r1 = PAR[1]*r;
     33    psF32 f  = r1 + PAR[0];
    3134
    3235    if (deriv != NULL) {
     36        psF32 *dPAR = deriv->data.F32;
     37
    3338        // note difference from a pure gaussian: q = params->data.F32[1]*r
    34         psF32 t = PAR[1]*r*r;
    35         psF32 q = t*(PAR[7] + 2.25*pow(z, 1.25));
    36 
    37         deriv->data.F32[0] = +1.0;
    38         deriv->data.F32[1] = +r;
    39         deriv->data.F32[2] = q*(2.0*px*PAR[4] + PAR[6]*Y);
    40         deriv->data.F32[3] = q*(2.0*py*PAR[5] + PAR[6]*X);
    41         deriv->data.F32[4] = -2.0*q*px*X;
    42         deriv->data.F32[5] = -2.0*q*py*Y;
    43         deriv->data.F32[6] = -q*X*Y;
    44         deriv->data.F32[7] = -t*z;
     39        psF32 t = r1*r;
     40        psF32 q = t*(PAR[7] + 2.25*zp);
     41        // test: psF32 q = t*(PAR[7] + 2*z);
     42
     43        dPAR[0] = +1.0;
     44        dPAR[1] = +r;
     45        dPAR[2] = q*(2.0*px*PAR[4] + PAR[6]*Y);
     46        dPAR[3] = q*(2.0*py*PAR[5] + PAR[6]*X);
     47        dPAR[4] = -2.0*q*px*X;
     48        dPAR[5] = -2.0*q*py*Y;
     49        dPAR[6] = -q*X*Y;
     50        dPAR[7] = -t*z;
    4551    }
    4652    return(f);
     
    5864
    5965    beta_lim[0][0].data.F32[0] = 1000;
    60     beta_lim[0][0].data.F32[1] = 10000;
     66    beta_lim[0][0].data.F32[1] = 3e6;
    6167    beta_lim[0][0].data.F32[2] = 5;
    6268    beta_lim[0][0].data.F32[3] = 5;
     
    7682
    7783    params_max[0][0].data.F32[0] = 1e5;
    78     params_max[0][0].data.F32[1] = 1e6;
     84    params_max[0][0].data.F32[1] = 1e8;
    7985    params_max[0][0].data.F32[2] = 1e4;  // this should be set by image dimensions!
    8086    params_max[0][0].data.F32[3] = 1e4;  // this should be set by image dimensions!
     
    102108    params[6] = 0.0;
    103109    params[7] = 1.0;
     110
    104111    return(true);
    105112}
     
    119126    // the area needs to be multiplied by the integral of f(z)
    120127    norm = 0.0;
    121     for (z = 0.005; z < 50; z += 0.01) {
     128    for (z = 0.05; z < 50; z += 0.1) {
    122129        f = 1.0 / (1 + PAR[7]*z + pow(z, 2.25));
     130        // test: f = 1.0 / (1 + PAR[7]*z + PS_SQR(z));
    123131        norm += f;
    124132    }
    125     norm *= 0.01;
     133    norm *= 0.1;
    126134
    127135    psF64 Flux = PAR[1] * Area * norm;
     
    150158
    151159    // we can do this much better with intelligent choices here
    152     for (z = 0.0; z < 20.0; z += dz) {
     160    for (z = 0.0; z < 30.0; z += dz) {
    153161        f = 1.0 / (1 + PAR[7]*z + pow(z, 2.25));
     162        // test: f = 1.0 / (1 + PAR[7]*z + PS_SQR(z));
    154163        if (f < limit)
    155164            break;
     
    201210    status &= ((dPAR[1]/PAR[1]) < 0.5);
    202211
    203     if (status)
    204         return true;
    205     return false;
    206 }
     212    if (!status)
     213        return false;
     214    return true;
     215}
  • trunk/psModules/src/objects/models/pmModel_RGAUSS.c

    r5257 r6872  
    117117    psVector *params = model->params;
    118118
    119     EllipseAxes axes;
    120     EllipseShape shape;
    121     EllipseMoments moments;
     119    psEllipseAxes axes;
     120    psEllipseShape shape;
     121    psEllipseMoments moments;
    122122
    123123    moments.x2 = PS_SQR(source->moments->Sx);
     
    125125    moments.xy = source->moments->Sxy;
    126126
    127     axes = EllipseMomentsToAxes(moments);
    128     shape = EllipseAxesToShape(axes);
     127    axes = psEllipseMomentsToAxes(moments);
     128    shape = psEllipseAxesToShape(axes);
    129129
    130130    params->data.F32[0] = source->moments->Sky;
  • trunk/psModules/src/objects/models/pmModel_SGAUSS.c

    r6511 r6872  
    1717
    1818# define SQ(A)((A)*(A))
    19 psF64 psImageEllipseContour (EllipseAxes axes, double xc, double yc, psImage *image);
     19psF64 psImageEllipseContour (psEllipseAxes axes, double xc, double yc, psImage *image);
    2020psF64 p_psImageGetElementF64(psImage *a, int i, int j);
    2121
     
    102102
    103103// measure the flux for the elliptical contour
    104 psF64 psImageEllipseContour (EllipseAxes axes, double xc, double yc, psImage *image)
     104psF64 psImageEllipseContour (psEllipseAxes axes, double xc, double yc, psImage *image)
    105105{
    106106
     
    149149    psF32     *params   = model->params->data.F32;
    150150
    151     EllipseAxes axes;
    152     EllipseShape shape;
    153     EllipseMoments moments;
     151    psEllipseAxes axes;
     152    psEllipseShape shape;
     153    psEllipseMoments moments;
    154154
    155155    moments.x2 = PS_SQR(sMoments->Sx);
     
    158158
    159159    // solve the math to go from Moments To Shape
    160     axes = EllipseMomentsToAxes(moments);
    161     shape = EllipseAxesToShape(axes);
     160    axes = psEllipseMomentsToAxes(moments);
     161    shape = psEllipseAxesToShape(axes);
    162162
    163163    params[0] = sMoments->Sky;
     
    199199    float f1, f2;
    200200
    201     EllipseAxes axes;
    202     EllipseShape shape;
    203     EllipseMoments moments;
     201    psEllipseAxes axes;
     202    psEllipseShape shape;
     203    psEllipseMoments moments;
    204204
    205205    moments.x2 = PS_SQR(sMoments->Sx);
     
    208208
    209209    // solve the math to go from Moments To Shape
    210     axes = EllipseMomentsToAxes(moments);
    211     shape = EllipseAxesToShape(axes);
     210    axes = psEllipseMomentsToAxes(moments);
     211    shape = psEllipseAxesToShape(axes);
    212212
    213213    params[0] = sMoments->Sky;
     
    265265psF64 pmModelRadius_SGAUSS  (const psVector *params, psF64 flux)
    266266{
    267     psF64 r, z, pr, f;
     267    psF64 r, z = 0.0, pr, f;
    268268    psF32 *PAR = params->data.F32;
    269269
    270     EllipseAxes axes;
    271     EllipseShape shape;
     270    psEllipseAxes axes;
     271    psEllipseShape shape;
    272272
    273273    if (flux <= 0)
     
    283283    shape.sxy = PAR[6];
    284284
    285     axes = EllipseShapeToAxes (shape);
     285    axes = psEllipseShapeToAxes (shape);
    286286    psF64 dr = 1.0 / axes.major;
    287287    psF64 limit = flux / PAR[1];
     
    327327    psF32 dP;
    328328    bool  status;
    329     EllipseAxes axes;
    330     EllipseShape shape;
     329    psEllipseAxes axes;
     330    psEllipseShape shape;
    331331
    332332    psF32 *PAR  = model->params->data.F32;
     
    337337    shape.sxy = PAR[6];
    338338
    339     axes = EllipseShapeToAxes (shape);
     339    axes = psEllipseShapeToAxes (shape);
    340340
    341341    dP = 0;
  • trunk/psModules/src/objects/models/pmModel_ZGAUSS.c

    r5257 r6872  
    8585    psF32 *PAR = params->data.F32;
    8686
    87     EllipseAxes axes;
    88     EllipseShape shape;
     87    psEllipseAxes axes;
     88    psEllipseShape shape;
    8989
    9090    if (flux <= 0)
     
    100100    shape.sxy = PAR[6];
    101101
    102     axes = EllipseShapeToAxes (shape);
     102    axes = psEllipseShapeToAxes (shape);
    103103    psF64 dr = 1.0 / axes.major;
    104104    psF64 limit = flux / PAR[1];
     
    124124    psVector *params = model->params;
    125125
    126     EllipseAxes axes;
    127     EllipseShape shape;
    128     EllipseMoments moments;
     126    psEllipseAxes axes;
     127    psEllipseShape shape;
     128    psEllipseMoments moments;
    129129
    130130    moments.x2 = PS_SQR(source->moments->Sx);
     
    132132    moments.xy = source->moments->Sxy;
    133133
    134     axes = EllipseMomentsToAxes(moments);
    135     shape = EllipseAxesToShape(axes);
     134    axes = psEllipseMomentsToAxes(moments);
     135    shape = psEllipseAxesToShape(axes);
    136136
    137137    params->data.F32[0] = source->moments->Sky;
  • trunk/psModules/src/objects/pmModelGroup.c

    r5844 r6872  
    1 # include "pmModelGroup.h"
    2 
     1/** @file  pmModelGroup.c
     2 *
     3 *  Functions to define and manipulate object model attributes
     4 *
     5 *  @author GLG, MHPCC
     6 *  @author EAM, IfA
     7 *
     8 *  @version $Revision: 1.3 $ $Name: not supported by cvs2svn $
     9 *  @date $Date: 2006-04-17 18:01:05 $
     10 *
     11 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     12 *
     13 */
     14
     15#include <stdio.h>
     16#include <math.h>
     17#include <string.h>
     18#include "pslib.h"
     19#include "psEllipse.h"
     20#include "pmHDU.h"
     21#include "pmFPA.h"
     22#include "pmPeaks.h"
     23#include "pmMoments.h"
     24#include "pmGrowthCurve.h"
     25#include "pmModel.h"
     26#include "pmPSF.h"
     27#include "pmSource.h"
     28#include "pmModelGroup.h"
     29
     30// XXX shouldn't these be defined for us in pslib.h ???
    331double hypot(double x, double y);
    432double sqrt (double x);
    533
    6 #include "psEllipse.h"
    734#include "models/pmModel_GAUSS.c"
    835#include "models/pmModel_PGAUSS.c"
     
    2552    if (modelGroup == NULL)
    2653        return;
    27     psFree (modelGroup);
    2854    return;
    2955}
     
    6086    }
    6187    Nmodels = Nnew;
     88    return;
     89}
     90
     91void pmModelGroupCleanup (void)
     92{
     93
     94    psFree (models);
    6295    return;
    6396}
     
    153186    return (models[type].name);
    154187}
     188
     189/******************************************************************************
     190    pmSourceModelGuess(source, model): This function allocates a new
     191    pmModel structure based on the given modelType specified in the argument list. 
     192    The corresponding pmModelGuess function is returned, and used to
     193    supply the values of the params array in the pmModel structure. 
     194     
     195    XXX: Many parameters are based on the src->moments structure, which is in
     196    image, not subImage coords.  Therefore, the calls to the model evaluation
     197    functions will be in image, not subImage coords.  Remember this.
     198*****************************************************************************/
     199pmModel *pmSourceModelGuess(pmSource *source,
     200                            pmModelType modelType)
     201{
     202    psTrace(__func__, 3, "---- %s() begin ----\n", __func__);
     203    PS_ASSERT_PTR_NON_NULL(source->moments, false);
     204    PS_ASSERT_PTR_NON_NULL(source->peak, false);
     205
     206    pmModel *model = pmModelAlloc(modelType);
     207
     208    pmModelGuessFunc modelGuessFunc = pmModelGuessFunc_GetFunction(modelType);
     209    modelGuessFunc(model, source);
     210    psTrace(__func__, 3, "---- %s() end ----\n", __func__);
     211    return(model);
     212}
     213
  • trunk/psModules/src/objects/pmModelGroup.h

    r5844 r6872  
    99 *  @author EAM, IfA
    1010 *
    11  *  @version $Revision: 1.2 $ $Name: not supported by cvs2svn $
    12  *  @date $Date: 2005-12-24 01:24:32 $
     11 *  @version $Revision: 1.3 $ $Name: not supported by cvs2svn $
     12 *  @date $Date: 2006-04-17 18:01:05 $
    1313 *
    1414 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
    1515 *
    1616 */
    17 #include "pmObjects.h"
    18 #include "pmPSF.h"
    19 /**
    20  *
    21  * This function returns the number of parameters used by the listed function.
    22  *
     17
     18# ifndef PM_MODEL_GROUP_H
     19# define PM_MODEL_GROUP_H
     20
     21//  This function is the model chi-square minimization function for this model.
     22typedef psMinimizeLMChi2Func pmModelFunc;
     23
     24// This function returns the integrated flux for the given model parameters.
     25typedef psF64 (*pmModelFlux)(const psVector *params);
     26
     27
     28// This function returns the radius at which the given model and parameters
     29// achieves the given flux.
     30typedef psF64 (*pmModelRadius)(const psVector *params, double flux);
     31
     32/*  This function sets the model parameter limits vectors for the given model
     33 */
     34typedef bool (*pmModelLimits)(psVector **beta_lim, psVector **params_min, psVector **params_max);
     35
     36/*  This function provides the model guess parameters based on the details of
     37 *   the given source.
     38 */
     39typedef bool (*pmModelGuessFunc)(pmModel *model, pmSource *source);
     40
     41
     42/*  This function constructs the PSF model for the given source based on the
     43 *  supplied psf and the EXT model for the object.
     44 */
     45typedef bool (*pmModelFromPSFFunc)(pmModel *modelPSF, pmModel *modelEXT, pmPSF *psf);
     46
     47/*  This function returns the success / failure status of the given model fit
     48 */
     49typedef bool (*pmModelFitStatusFunc)(pmModel *model);
     50
     51/* Every model instance belongs to a class of models, defined by the value of
     52 * the pmModelType type entry. Various functions need access to information about
     53 * each of the models. Some of this information varies from model to model, and
     54 * may depend on the current parameter values or other data quantities. In order
     55 * to keep the code from requiring the information about each model to be coded
     56 * into the low-level fitting routines, we define a collection of functions which
     57 * allow us to abstract this type of model-dependent information. These generic
     58 * functions take the model type and return the corresponding function pointer
     59 * for the specified model. Each model is defined by creating this collection of
     60 * specific functions, and placing them in a single file for each model. We
     61 * define the following structure to carry the collection of information about
     62 * the models.
     63 */
     64typedef struct
     65{
     66    char *name;
     67    int nParams;
     68    pmModelFunc          modelFunc;
     69    pmModelFlux          modelFlux;
     70    pmModelRadius        modelRadius;
     71    pmModelLimits        modelLimits;
     72    pmModelGuessFunc     modelGuessFunc;
     73    pmModelFromPSFFunc   modelFromPSFFunc;
     74    pmModelFitStatusFunc modelFitStatusFunc;
     75}
     76pmModelGroup;
     77
     78// allocate a pmModelGroup to hold nModels entries
     79pmModelGroup *pmModelGroupAlloc (int nModels);
     80
     81// initialize the internal (static) model group with the default models
     82void pmModelGroupInit (void);
     83
     84// free the internal (static) model group
     85void pmModelGroupCleanup (void);
     86
     87// add a new model to the internal (static) model group
     88void pmModelGroupAdd (pmModelGroup *model);
     89
     90/* This function returns the number of parameters used by the listed function.
    2391 */
    2492int pmModelParameterCount(
     
    2795
    2896
    29 /**
    30  *
    31  * This function returns the user-space model names for the specified model type.
    32  *
     97/* This function returns the user-space model names for the specified model type.
    3398 */
    3499char *pmModelGetType(
     
    46111);
    47112
    48 
    49 #ifndef PM_MODEL_GROUP_H
    50 #define PM_MODEL_GROUP_H
    51 
    52 /**
    53  *
    54  *  This function is the model chi-square minimization function for this model.
    55  *
    56  */
    57 typedef psMinimizeLMChi2Func pmModelFunc;
    58 
    59 
    60 /**
    61  *
    62  * This function returns the integrated flux for the given model parameters.
    63  */
    64 typedef psF64 (*pmModelFlux)(const psVector *params);
    65 
    66 
    67 /**
    68  *
    69  *  This function returns the radius at which the given model and parameters
    70  *  achieves the given flux.
    71  *
    72  */
    73 typedef psF64 (*pmModelRadius)(const psVector *params, double flux);
    74 
    75 /**
    76  *
    77  *  This function sets the model parameter limits vectors for the given model
    78  *
    79  */
    80 typedef bool (*pmModelLimits)(psVector **beta_lim, psVector **params_min, psVector **params_max);
    81 
    82 /**
    83  *
    84  *  This function provides the model guess parameters based on the details of
    85  *   the given source.
    86  *
    87  */
    88 typedef bool (*pmModelGuessFunc)(pmModel *model, pmSource *source);
    89 
    90 
    91 /**
    92  *
    93  *  This function constructs the PSF model for the given source based on the
    94  *  supplied psf and the FLT model for the object.
    95  *
    96  */
    97 typedef bool (*pmModelFromPSFFunc)(pmModel *modelPSF, pmModel *modelFLT, pmPSF *psf);
    98 
    99 /**
    100  *
    101  *  This function returns the success / failure status of the given model fit
    102  *
    103  */
    104 typedef bool (*pmModelFitStatusFunc)(pmModel *model);
    105 
    106113/**
    107114 *
     
    110117 *
    111118 */
    112 
    113119
    114120/**
     
    177183
    178184
     185/** pmSourceModelGuess()
     186 *
     187 * Convert available data to an initial guess for the given model. This
     188 * function allocates a pmModel entry for the pmSource structure based on the
     189 * provided model selection. The method of defining the model parameter guesses
     190 * are specified for each model below. The guess values are placed in the model
     191 * parameters. The function returns TRUE on success or FALSE on failure.
     192 *
     193 */
     194pmModel *pmSourceModelGuess(
     195    pmSource *source,   ///< The input pmSource
     196    pmModelType model   ///< The type of model to be created.
     197);
    179198
    180 
    181 /**
    182  *
    183  * Every model instance belongs to a class of models, defined by the value of
    184  * the pmModelType type entry. Various functions need access to information about
    185  * each of the models. Some of this information varies from model to model, and
    186  * may depend on the current parameter values or other data quantities. In order
    187  * to keep the code from requiring the information about each model to be coded
    188  * into the low-level fitting routines, we define a collection of functions which
    189  * allow us to abstract this type of model-dependent information. These generic
    190  * functions take the model type and return the corresponding function pointer
    191  * for the specified model. Each model is defined by creating this collection of
    192  * specific functions, and placing them in a single file for each model. We
    193  * define the following structure to carry the collection of information about
    194  * the models.
    195  *
    196  */
    197 typedef struct
    198 {
    199     char *name;
    200     int nParams;
    201     pmModelFunc          modelFunc;
    202     pmModelFlux          modelFlux;
    203     pmModelRadius        modelRadius;
    204     pmModelLimits        modelLimits;
    205     pmModelGuessFunc     modelGuessFunc;
    206     pmModelFromPSFFunc   modelFromPSFFunc;
    207     pmModelFitStatusFunc modelFitStatusFunc;
    208 }
    209 pmModelGroup;
    210 
    211 // allocate a pmModelGroup to hold nModels entries
    212 pmModelGroup *pmModelGroupAlloc (int nModels);
    213 
    214 // initialize the internal (static) model group with the default models
    215 void pmModelGroupInit (void);
    216 
    217 // add a new model to the internal (static) model group
    218 void pmModelGroupAdd (pmModelGroup *model);
    219 
    220 # endif
     199# endif /* PM_MODEL_GROUP_H */
  • trunk/psModules/src/objects/pmObjects.h

    r5844 r6872  
    1010 *  @author GLG, MHPCC
    1111 *
    12  *  @version $Revision: 1.5 $ $Name: not supported by cvs2svn $
    13  *  @date $Date: 2005-12-24 01:24:32 $
     12 *  @version $Revision: 1.6 $ $Name: not supported by cvs2svn $
     13 *  @date $Date: 2006-04-17 18:01:05 $
    1414 *
    1515 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    2727#include <math.h>
    2828#include "pslib.h"
    29 #include "pmAstrometry.h"
    30 /**
    31  * In the object analysis process, we will use specific mask values to mark the
    32  * image pixels. The following structure defines the relevant mask values.
    33  *
    34  * XXX: This is probably a bad solution: we will want to set mask values
    35  * outside of the PSPHOT code.  Perhaps we can set up a registered set of mask
    36  * values with specific meanings that other functions can add to or define?
    37  */
    38 typedef enum {
    39     PSPHOT_MASK_CLEAR     = 0x00,
    40     PSPHOT_MASK_INVALID   = 0x01,
    41     PSPHOT_MASK_SATURATED = 0x02,
    42     PSPHOT_MASK_MARKED    = 0x08,
    43 } psphotMaskValues;
    44 
    45 
    46 /** pmPeakType
    47  *
    48  *  A peak pixel may have several features which may be determined when the
    49  *  peak is found or measured. These are specified by the pmPeakType enum.
    50  *  PM_PEAK_LONE represents a single pixel which is higher than its 8 immediate
    51  *  neighbors.  The PM_PEAK_EDGE represents a peak pixel which touching the image
    52  *  edge. The PM_PEAK_FLAT represents a peak pixel which has more than a specific
    53  *  number of neighbors at the same value, within some tolarence:
    54  *
    55  */
    56 typedef enum {
    57     PM_PEAK_LONE,                       ///< Isolated peak.
    58     PM_PEAK_EDGE,                       ///< Peak on edge.
    59     PM_PEAK_FLAT,                       ///< Peak has equal-value neighbors.
    60     PM_PEAK_UNDEF                       ///< Undefined.
    61 } pmPeakType;
    62 
    63 
    64 /** pmPeak data structure
    65  *
    66  *  A source has the capacity for several types of measurements. The
    67  *  simplest measurement of a source is the location and flux of the peak pixel
    68  *  associated with the source:
    69  *
    70  */
    71 typedef struct
    72 {
    73     int x;                              ///< X-coordinate of peak pixel.
    74     int y;                              ///< Y-coordinate of peak pixel.
    75     float counts;                       ///< Value of peak pixel (above sky?).
    76     pmPeakType class;                   ///< Description of peak.
    77 }
    78 pmPeak;
    79 
    80 
    81 /** pmMoments data structure
    82  *
    83  * One of the simplest measurements which can be made quickly for an object
    84  * are the object moments. We specify a structure to carry the moment information
    85  * for a specific source:
    86  *
    87  */
    88 typedef struct
    89 {
    90     float x;    ///< X-coord of centroid.
    91     float y;    ///< Y-coord of centroid.
    92     float Sx;    ///< x-second moment.
    93     float Sy;    ///< y-second moment.
    94     float Sxy;    ///< xy cross moment.
    95     float Sum;    ///< Pixel sum above sky (background).
    96     float Peak;    ///< Peak counts above sky.
    97     float Sky;    ///< Sky level (background).
    98     float SN;    ///< approx signal-to-noise
    99     int nPixels;   ///< Number of pixels used.
    100 }
    101 pmMoments;
    102 
    103 
    104 /** pmPSFClump data structure
    105  *
    106  * A collection of object moment measurements can be used to determine
    107  * approximate object classes. The key to this analysis is the location and
    108  * statistics (in the second-moment plane,
    109  *
    110  */
    111 typedef struct
    112 {
    113     float X;
    114     float dX;
    115     float Y;
    116     float dY;
    117 }
    118 pmPSFClump;
    119 
    120 // type of model carried by the pmModel structure
    121 typedef int pmModelType;
    122 
    123 typedef enum {
    124     PM_MODEL_UNTRIED,               ///< model fit not yet attempted
    125     PM_MODEL_SUCCESS,               ///< model fit succeeded
    126     PM_MODEL_NONCONVERGE,           ///< model fit did not converge
    127     PM_MODEL_OFFIMAGE,              ///< model fit drove out of range
    128     PM_MODEL_BADARGS                ///< model fit called with invalid args
    129 } pmModelStatus;
    130 
    131 /** pmModel data structure
    132  *
    133  * Every source may have two types of models: a PSF model and a FLT (floating)
    134  * model. The PSF model represents the best fit of the image PSF to the specific
    135  * object. In this case, the PSF-dependent parameters are specified for the
    136  * object by the PSF, not by the fit. The FLT model represents the best fit of
    137  * the given model to the object, with all parameters floating in the fit.
    138  *
    139  */
    140 typedef struct
    141 {
    142     pmModelType type;   ///< Model to be used.
    143     psVector *params;   ///< Paramater values.
    144     psVector *dparams;   ///< Parameter errors.
    145     float chisq;   ///< Fit chi-squared.
    146     int nDOF;    ///< number of degrees of freedom
    147     int nIter;    ///< number of iterations to reach min
    148     int status;         ///< fit status
    149     float radius;   ///< fit radius actually used
    150 }
    151 pmModel;
    152 
    153 /** pmSourceType enumeration
    154  *
    155  * A given source may be identified as most-likely to be one of several source
    156  * types. The pmSource entry pmSourceType defines the current best-guess for this
    157  * source.
    158  *
    159  * XXX: The values given below are currently illustrative and will require
    160  * some modification as the source classification code is developed. (TBD)
    161  *
    162  */
    163 typedef enum {
    164     PM_SOURCE_DEFECT,                   ///< a cosmic-ray
    165     PM_SOURCE_SATURATED,                ///< random saturated pixels
    166 
    167     PM_SOURCE_SATSTAR,                  ///< a saturated star
    168     PM_SOURCE_PSFSTAR,                  ///< a PSF star
    169     PM_SOURCE_GOODSTAR,                 ///< a good-quality star
    170 
    171     PM_SOURCE_POOR_FIT_PSF,             ///< poor quality PSF fit
    172     PM_SOURCE_FAIL_FIT_PSF,             ///< failed to get a good PSF fit
    173     PM_SOURCE_FAINTSTAR,                ///< below S/N cutoff
    174 
    175     PM_SOURCE_GALAXY,                   ///< an extended object (galaxy)
    176     PM_SOURCE_FAINT_GALAXY,             ///< a galaxy below S/N cutoff
    177     PM_SOURCE_DROP_GALAXY,              ///< ?
    178     PM_SOURCE_FAIL_FIT_GAL,             ///< failed on the galaxy fit
    179     PM_SOURCE_POOR_FIT_GAL,             ///< poor quality galaxy fit
    180 
    181     PM_SOURCE_OTHER,                    ///< unidentified
    182 } pmSourceType;
    183 
    184 /** pmSource data structure
    185  *
    186  *  This source has the capacity for several types of measurements. The
    187  *  simplest measurement of a source is the location and flux of the peak pixel
    188  *  associated with the source:
    189  *
    190  */
    191 typedef struct
    192 {
    193     pmPeak *peak;   ///< Description of peak pixel.
    194     psImage *pixels;   ///< Rectangular region including object pixels.
    195     psImage *weight;   ///< Image variance.
    196     psImage *mask;   ///< Mask which marks pixels associated with objects.
    197     pmMoments *moments;   ///< Basic moments measure for the object.
    198     pmModel *modelPSF;   ///< PSF Model fit (parameters and type)
    199     pmModel *modelFLT;   ///< FLT (floating) Model fit (parameters and type).
    200     pmSourceType type;   ///< Best identification of object.
    201     float apMag;
    202     float fitMag;
    203 }
    204 pmSource;
    205 
    206 
    207 /** pmPeakAlloc()
    208  *
    209  *  @return pmPeak*    newly allocated pmPeak with all internal pointers set to NULL
    210  */
    211 pmPeak *pmPeakAlloc(
    212     int x,    ///< Row-coordinate in image space
    213     int y,    ///< Col-coordinate in image space
    214     float counts,   ///< The value of the peak pixel
    215     pmPeakType class   ///< The type of peak pixel
    216 );
    217 
    218 
    219 /** pmMomentsAlloc()
    220  *
    221  */
    222 pmMoments *pmMomentsAlloc();
    223 
    224 
    225 /** pmModelAlloc()
    226  *
    227  */
    228 pmModel *pmModelAlloc(pmModelType type);
    229 
    230 
    231 /** pmSourceAlloc()
    232  *
    233  */
    234 pmSource  *pmSourceAlloc();
    235 
    236 
    237 /** pmFindVectorPeaks()
    238  *
    239  * Find all local peaks in the given vector above the given threshold. A peak
    240  * is defined as any element with a value greater than its two neighbors and with
    241  * a value above the threshold. Two types of special cases must be addressed.
    242  * Equal value elements: If an element has the same value as the following
    243  * element, it is not considered a peak. If an element has the same value as the
    244  * preceding element (but not the following), then it is considered a peak. Note
    245  * that this rule (arbitrarily) identifies flat regions by their trailing edge.
    246  * Edge cases: At start of the vector, the element must be higher than its
    247  * neighbor. At the end of the vector, the element must be higher or equal to its
    248  * neighbor. These two rules again places the peak associated with a flat region
    249  * which touches the image edge at the image edge. The result of this function is
    250  * a vector containing the coordinates (element number) of the detected peaks
    251  * (type psU32).
    252  *
    253  */
    254 psVector *pmFindVectorPeaks(
    255     const psVector *vector,  ///< The input vector (float)
    256     float threshold   ///< Threshold above which to find a peak
    257 );
    258 
    259 
    260 /** pmFindImagePeaks()
    261  *
    262  * Find all local peaks in the given image above the given threshold. This
    263  * function should find all row peaks using pmFindVectorPeaks, then test each row
    264  * peak and exclude peaks which are not local peaks. A peak is a local peak if it
    265  * has a higher value than all 8 neighbors. If the peak has the same value as its
    266  * +y neighbor or +x neighbor, it is NOT a local peak. If any other neighbors
    267  * have an equal value, the peak is considered a valid peak. Note two points:
    268  * first, the +x neighbor condition is already enforced by pmFindVectorPeaks.
    269  * Second, these rules have the effect of making flat-topped regions have single
    270  * peaks at the (+x,+y) corner. When selecting the peaks, their type must also be
    271  * set. The result of this function is an array of pmPeak entries.
    272  *
    273  */
    274 psArray *pmFindImagePeaks(
    275     const psImage *image,  ///< The input image where peaks will be found (float)
    276     float threshold   ///< Threshold above which to find a peak
    277 );
    278 
    279 
    280 /** pmCullPeaks()
    281  *
    282  * Eliminate peaks from the psList that have a peak value above the given
    283  * maximum, or fall outside the valid region.
    284  *
    285  */
    286 psList *pmCullPeaks(
    287     psList *peaks,   ///< The psList of peaks to be culled
    288     float maxValue,   ///< Cull peaks above this value
    289     const psRegion valid                ///< Cull peaks otside this psRegion
    290 );
    291 
    292 
    293 /** pmPeaksSubset()
    294  *
    295  * Create a new peaks array, removing certain types of peaks from the input
    296  * array of peaks based on the given criteria. Peaks should be eliminated if they
    297  * have a peak value above the given maximum value limit or if the fall outside
    298  * the valid region.  The result of the function is a new array with a reduced
    299  * number of peaks.
    300  *
    301  */
    302 psArray *pmPeaksSubset(
    303     psArray *peaks,                     ///< Add comment.
    304     float maxvalue,                     ///< Add comment.
    305     const psRegion valid                ///< Add comment.
    306 );
    307 
    308 
    309 /** pmSourceDefinePixels()
    310  *
    311  * Define psImage subarrays for the source located at coordinates x,y on the
    312  * image set defined by readout. The pixels defined by this operation consist of
    313  * a square window (of full width 2Radius+1) centered on the pixel which contains
    314  * the given coordinate, in the frame of the readout. The window is defined to
    315  * have limits which are valid within the boundary of the readout image, thus if
    316  * the radius would fall outside the image pixels, the subimage is truncated to
    317  * only consist of valid pixels. If readout->mask or readout->weight are not
    318  * NULL, matching subimages are defined for those images as well. This function
    319  * fails if no valid pixels can be defined (x or y less than Radius, for
    320  * example). This function should be used to define a region of interest around a
    321  * source, including both source and sky pixels.
    322  *
    323  * XXX: must code this.
    324  *
    325  */
    326 // XXX: Uncommenting the pmReadout causes compile errors.
    327 bool pmSourceDefinePixels(
    328     pmSource *mySource,                 ///< Add comment.
    329     pmReadout *readout,                 ///< Add comment.
    330     psF32 x,                            ///< Add comment.
    331     psF32 y,                            ///< Add comment.
    332     psF32 Radius                        ///< Add comment.
    333 );
    334 
    335 
    336 /** pmSourceLocalSky()
    337  *
    338  * Measure the local sky in the vicinity of the given source. The Radius
    339  * defines the square aperture in which the moments will be measured. This
    340  * function assumes the source pixels have been defined, and that the value of
    341  * Radius here is smaller than the value of Radius used to define the pixels. The
    342  * annular region not contained within the radius defined here is used to measure
    343  * the local background in the vicinity of the source. The local background
    344  * measurement uses the specified statistic passed in via the statsOptions entry.
    345  * This function allocates the pmMoments structure. The resulting sky is used to
    346  * set the value of the pmMoments.sky element of the provided pmSource structure.
    347  *
    348  */
    349 bool pmSourceLocalSky(
    350     pmSource *source,   ///< The input image (float)
    351     psStatsOptions statsOptions, ///< The statistic used in calculating the background sky
    352     float Radius   ///< The inner radius of the square annulus to exclude
    353 );
    354 
    355 
    356 /** pmSourceMoments()
    357  *
    358  * Measure source moments for the given source, using the value of
    359  * source.moments.sky provided as the local background value and the peak
    360  * coordinates as the initial source location. The resulting moment values are
    361  * applied to the source.moments entry, and the source is returned. The moments
    362  * are measured within the given circular radius of the source.peak coordinates.
    363  * The return value indicates the success (TRUE) of the operation.
    364  *
    365  */
    366 bool pmSourceMoments(
    367     pmSource *source,   ///< The input pmSource for which moments will be computed
    368     float radius   ///< Use a circle of pixels around the peak
    369 );
    370 
    371 
    372 /** pmSourcePSFClump()
    373  *
    374  * We use the source moments to make an initial, approximate source
    375  * classification, and as part of the information needed to build a PSF model for
    376  * the image. As long as the PSF shape does not vary excessively across the
    377  * image, the sources which are represented by a PSF (the start) will have very
    378  * similar second moments. The function pmSourcePSFClump searches a collection of
    379  * sources with measured moments for a group with moments which are all very
    380  * similar. The function returns a pmPSFClump structure, representing the
    381  * centroid and size of the clump in the sigma_x, sigma_y second-moment plane.
    382  *
    383  * The goal is to identify and characterize the stellar clump within the
    384  * sigma_x, sigma_y second-moment plane.  To do this, an image is constructed to
    385  * represent this plane.  The units of sigma_x and sigma_y are in image pixels. A
    386  * pixel in this analysis image represents 0.1 pixels in the input image. The
    387  * dimensions of the image need only be 10 pixels. The peak pixel in this image
    388  * (above a threshold of half of the image maximum) is found. The coordinates of
    389  * this peak pixel represent the 2D mode of the sigma_x, sigma_y distribution.
    390  * The sources with sigma_x, sigma_y within 0.2 pixels of this value are then
    391  *  * used to calculate the median and standard deviation of the sigma_x, sigma_y
    392  * values. These resulting values are returned via the pmPSFClump structure.
    393  *
    394  * The return value indicates the success (TRUE) of the operation.
    395  *
    396  * XXX: Limit the S/N of the candidate sources (part of Metadata)? (TBD).
    397  * XXX: Save the clump parameters on the Metadata (TBD)
    398  *
    399  */
    400 pmPSFClump pmSourcePSFClump(
    401     psArray *source,   ///< The input pmSource
    402     psMetadata *metadata  ///< Contains classification parameters
    403 );
    404 
    405 
    406 /** pmSourceRoughClass()
    407  *
    408  * Based on the specified data values, make a guess at the source
    409  * classification. The sources are provides as a psArray of pmSource entries.
    410  * Definable parameters needed to make the classification are provided to the
    411  * routine with the psMetadata structure. The rules (in SDRS) refer to values which
    412  * can be extracted from the metadata using the given keywords. Except as noted,
    413  * the data type for these parameters are psF32.
    414  *
    415  */
    416 bool pmSourceRoughClass(
    417     psArray *source,   ///< The input pmSource
    418     psMetadata *metadata,  ///< Contains classification parameters
    419     pmPSFClump clump   ///< Statistics about the PSF clump
    420 );
    421 
    422 
    423 /** pmSourceModelGuess()
    424  *
    425  * Convert available data to an initial guess for the given model. This
    426  * function allocates a pmModel entry for the pmSource structure based on the
    427  * provided model selection. The method of defining the model parameter guesses
    428  * are specified for each model below. The guess values are placed in the model
    429  * parameters. The function returns TRUE on success or FALSE on failure.
    430  *
    431  */
    432 pmModel *pmSourceModelGuess(
    433     pmSource *source,   ///< The input pmSource
    434     pmModelType model   ///< The type of model to be created.
    435 );
    436 
    437 
    438 /** pmContourType
    439  *
    440  * Only one type is defined at present.
    441  *
    442  */
    443 typedef enum {
    444     PS_CONTOUR_CRUDE,
    445     PS_CONTOUR_UNKNOWN01,
    446     PS_CONTOUR_UNKNOWN02
    447 } pmContourType;
    448 
    449 
    450 /** pmSourceContour()
    451  *
    452  * Find points in a contour for the given source at the given level. If type
    453  * is PM_CONTOUR_CRUDE, the contour is found by starting at the source peak,
    454  * running along each pixel row until the level is crossed, then interpolating to
    455  * the level coordinate for that row. This is done for each row, with the
    456  * starting point determined by the midpoint of the previous row, until the
    457  * starting point has a value below the contour level. The returned contour
    458  * consists of two vectors giving the x and y coordinates of the contour levels.
    459  * This function may be used as part of the model guess inputs.  Other contour
    460  * types may be specified in the future for more refined contours (TBD)
    461  *
    462  */
    463 psArray *pmSourceContour(
    464     pmSource *source,   ///< The input pmSource
    465     const psImage *image,  ///< The input image (float) (this arg should be removed)
    466     float level,   ///< The level of the contour
    467     pmContourType mode   ///< Currently this must be PS_CONTOUR_CRUDE
    468 );
    469 
    470 
    471 /** pmSourceFitModel()
    472  *
    473  * Fit the requested model to the specified source. The starting guess for the
    474  * model is given by the input source.model parameter values. The pixels of
    475  * interest are specified by the source.pixelsand source.maskentries. This
    476  * function calls psMinimizeLMChi2() on the image data. The function returns TRUE
    477  * on success or FALSE on failure.
    478  *
    479  */
    480 bool pmSourceFitModel(
    481     pmSource *source,   ///< The input pmSource
    482     pmModel *model,   ///< model to be fitted
    483     const bool PSF   ///< Treat model as PSF or FLT?
    484 );
    485 
    486 
    487 /** pmModelFitStatus()
    488  *
    489  * This function wraps the call to the model-specific function returned by
    490  * pmModelFitStatusFunc_GetFunction.  The model-specific function examines the
    491  * model parameters, parameter errors, Chisq, S/N, and other parameters available
    492  * from model to decide if the particular fit was successful or not.
    493  *
    494  * XXX: Must code this.
    495  *
    496  */
    497 bool pmModelFitStatus(
    498     pmModel *model                      ///< Add comment.
    499 );
    500 
    501 
    502 /** pmSourceAddModel()
    503  *
    504  * Add the given source model flux to/from the provided image. The boolean
    505  * option center selects if the source is re-centered to the image center or if
    506  * it is placed at its centroid location. The boolean option sky selects if the
    507  * background sky is applied (TRUE) or not. The pixel range in the target image
    508  * is at most the pixel range specified by the source.pixels image. The success
    509  * status is returned.
    510  *
    511  */
    512 bool pmSourceAddModel(
    513     psImage *image,   ///< The output image (float)
    514     psImage *mask,   ///< The image pixel mask (valid == 0)
    515     pmModel *model,   ///< The input pmModel
    516     bool center,    ///< A boolean flag that determines whether pixels are centered
    517     bool sky        ///< A boolean flag that determines if the sky is subtracted
    518 );
    519 
    520 
    521 /** pmSourceSubModel()
    522  *
    523  * Subtract the given source model flux to/from the provided image. The
    524  * boolean option center selects if the source is re-centered to the image center
    525  * or if it is placed at its centroid location. The boolean option sky selects if
    526  * the background sky is applied (TRUE) or not. The pixel range in the target
    527  * image is at most the pixel range specified by the source.pixels image. The
    528  * success status is returned.
    529  *
    530  */
    531 bool pmSourceSubModel(
    532     psImage *image,   ///< The output image (float)
    533     psImage *mask,   ///< The image pixel mask (valid == 0)
    534     pmModel *model,   ///< The input pmModel
    535     bool center,    ///< A boolean flag that determines whether pixels are centered
    536     bool sky        ///< A boolean flag that determines if the sky is subtracted
    537 );
    538 
    539 
    540 /**
    541  *
    542  * The function returns both the magnitude of the fit, defined as -2.5log(flux),
    543  * where the flux is integrated under the model, theoretically from a radius of 0
    544  * to infinity. In practice, we integrate the model beyond 50sigma.  The aperture magnitude is
    545  * defined as -2.5log(flux) , where the flux is summed for all pixels which are
    546  * not excluded by the aperture mask. The model flux is calculated by calling the
    547  * model-specific function provided by pmModelFlux_GetFunction.
    548  *
    549  * XXX: must code this.
    550  *
    551  */
    552 bool pmSourcePhotometry(
    553     float *fitMag,                      ///< integrated fit magnitude
    554     float *obsMag,   ///< aperture flux magnitude
    555     pmModel *model,                     ///< model used for photometry
    556     psImage *image,                     ///< image pixels to be used
    557     psImage *mask                       ///< mask of pixels to ignore
    558 );
    559 
    56029
    56130/**
     
    56332 * This function converts the source classification into the closest available
    56433 * approximation to the Dophot classification scheme:
     34 * XXX EAM : fix this to use current source classification scheme
    56535 *
    56636 * PM_SOURCE_DEFECT: 8
     
    59868);
    59969
    600 /** pmSourceFitModel_v5()
    601  *
    602  * Fit the requested model to the specified source. The starting guess for the
    603  * model is given by the input source.model parameter values. The pixels of
    604  * interest are specified by the source.pixelsand source.maskentries. This
    605  * function calls psMinimizeLMChi2() on the image data. The function returns TRUE
    606  * on success or FALSE on failure.
    607  *
    608  */
    609 bool pmSourceFitModel_v5(
    610     pmSource *source,   ///< The input pmSource
    611     pmModel *model,   ///< model to be fitted
    612     const bool PSF   ///< Treat model as PSF or FLT?
    613 );
    614 
    615 
    616 /** pmSourceFitModel_v7()
    617  *
    618  * Fit the requested model to the specified source. The starting guess for the
    619  * model is given by the input source.model parameter values. The pixels of
    620  * interest are specified by the source.pixelsand source.maskentries. This
    621  * function calls psMinimizeLMChi2() on the image data. The function returns TRUE
    622  * on success or FALSE on failure.
    623  *
    624  */
    625 bool pmSourceFitModel_v7(
    626     pmSource *source,   ///< The input pmSource
    627     pmModel *model,   ///< model to be fitted
    628     const bool PSF   ///< Treat model as PSF or FLT?
    629 );
    630 
    631 
    632 /** pmSourcePhotometry()
    633  *
    634  * XXX: Need descriptions
    635  *
    636  */
    637 bool pmSourcePhotometry(
    638     float *fitMag,
    639     float *obsMag,
    640     pmModel *model,
    641     psImage *image,
    642     psImage *mask
    643 );
    644 
    645 /** pmModelEval()
    646  *
    647  *  XXX: Need descriptions
    648  *
    649  */
    650 psF32 pmModelEval(
    651     pmModel *model,
    652     psImage *image,
    653     psS32 col,
    654     psS32 row
    655 );
    65670
    65771#endif
  • trunk/psModules/src/objects/pmPSF.h

    r5255 r6872  
    66 *  @author EAM, IfA
    77 *
    8  *  @version $Revision: 1.1 $ $Name: not supported by cvs2svn $
    9  *  @date $Date: 2005-10-10 19:53:40 $
     8 *  @version $Revision: 1.2 $ $Name: not supported by cvs2svn $
     9 *  @date $Date: 2006-04-17 18:01:05 $
    1010 *
    1111 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    1515# ifndef PM_PSF_H
    1616# define PM_PSF_H
    17 
    1817
    1918/** pmPSF data structure
     
    3332    pmModelType type;   ///< PSF Model in use
    3433    psArray *params;   ///< Model parameters (psPolynomial2D)
    35     float chisq;   ///< PSF goodness statistic
    36     float ApResid;                      ///< ???
    37     float dApResid;                     ///< ???
    38     float skyBias;                      ///< ???
     34    psPolynomial1D *ChiTrend;  ///< Chisq vs flux fit (correction for systematic errors)
     35    psPolynomial4D *ApTrend;  ///< ApResid vs (x,y,rflux) (rflux = ten(0.4*mInst)
     36    pmGrowthCurve *growth;  ///< apMag vs Radius
     37    float ApResid;   ///< apMag - psfMag (for PSF stars)
     38    float dApResid;   ///< scatter of ApResid
     39    float skyBias;   ///< implied residual sky offset from ApResid fit
     40    float skySat;   ///< roll-over of ApResid fit
     41    float chisq;   ///< PSF goodness statistic (unused??)
    3942    int nPSFstars;   ///< number of stars used to measure PSF
     43    int nApResid;   ///< number of stars used to measure ApResid
     44    bool poissonErrors;
    4045}
    4146pmPSF;
    4247
     48typedef enum {
     49    PM_PSF_NONE,
     50    PM_PSF_CONSTANT,
     51    PM_PSF_SKYBIAS,
     52    PM_PSF_SKYSAT,
     53    PM_PSF_XY_LIN,
     54    PM_PSF_XY_QUAD,
     55    PM_PSF_SKY_XY_LIN,
     56    PM_PSF_SKYSAT_XY_LIN,
     57    PM_PSF_ALL
     58} pmPSF_ApTrendOptions;
    4359
    4460/**
     
    4864 */
    4965pmPSF *pmPSFAlloc(
    50     pmModelType type                    ///< Add comment
     66    pmModelType type,   // type of model for PSF
     67    bool poissonErrors   ///< use poissonian errors or not?
    5168);
    5269
     
    85102);
    86103
     104bool pmPSF_MaskApTrend (pmPSF *psf, pmPSF_ApTrendOptions option);
     105
    87106# endif
  • trunk/psModules/src/objects/pmPSFtry.h

    r5844 r6872  
    66 *  @author EAM, IfA
    77 *
    8  *  @version $Revision: 1.3 $ $Name: not supported by cvs2svn $
    9  *  @date $Date: 2005-12-24 01:24:32 $
     8 *  @version $Revision: 1.4 $ $Name: not supported by cvs2svn $
     9 *  @date $Date: 2006-04-17 18:01:05 $
    1010 *
    1111 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    1818
    1919/**
    20  *
     20 * 
    2121 * This structure contains a pointer to the collection of sources which will
    2222 * be used to test the PSF model form. It lists the pmModelType type of model
    2323 * being tests, and contains an element to store the resulting psf
    2424 * representation. In addition, this structure carries the complete collection of
    25  * FLT (floating parameter) and PSF (fixed parameter) model fits to each of the
    26  * sources modelFLT and modelPSF. It also contains a mask which is set by the
     25 * EXT (floating parameter) and PSF (fixed parameter) model fits to each of the
     26 * sources modelEXT and modelPSF. It also contains a mask which is set by the
    2727 * model fitting and psf fitting steps. For each model, the value of the quality
    2828 * metric is stored in the vector metric and the fitted instrumental magnitude is
     
    3838 * ultimate metric to intercompare multiple types of PSF models is the value of
    3939 * the aperture correction scatter.
    40  *
     40 * 
    4141 * XXX: There are many more members in the SDRS then in the prototype code.
    4242 * I stuck with the prototype code.
    43  *
    44  *
     43 * 
     44 * 
    4545 */
    4646typedef struct
     
    4848    pmPSF      *psf;                    ///< Add comment.
    4949    psArray    *sources;                ///< pointers to the original sources
    50     psArray    *modelFLT;               ///< model fits, floating parameters
     50    psArray    *modelEXT;               ///< model fits, floating parameters
    5151    psArray    *modelPSF;               ///< model fits, PSF parameters
    5252    psVector   *mask;                   ///< Add comment.
     
    5858
    5959/** pmPSFtryMaskValues
    60  *
     60 * 
    6161 * The following datatype defines the masks used by the pmPSFtry analysis to
    6262 * identify sources which should or should not be included in the analysis.
    63  *
     63 * 
    6464 */
    65 enum {
     65typedef enum {
    6666    PSFTRY_MASK_CLEAR    = 0x00,        ///< Add comment.
    6767    PSFTRY_MASK_OUTLIER  = 0x01,        ///< 1: outlier in psf polynomial fit (provided by psPolynomials)
    68     PSFTRY_MASK_FLT_FAIL = 0x02,        ///< 2: flt model failed to converge
     68    PSFTRY_MASK_EXT_FAIL = 0x02,        ///< 2: ext model failed to converge
    6969    PSFTRY_MASK_PSF_FAIL = 0x04,        ///< 3: psf model failed to converge
    7070    PSFTRY_MASK_BAD_PHOT = 0x08,        ///< 4: invalid source photometry
     
    7474
    7575/** pmPSFtryAlloc()
    76  *
     76 * 
    7777 * Allocate a pmPSFtry data structure.
    78  *
     78 * 
    7979 */
    8080pmPSFtry *pmPSFtryAlloc(
    8181    psArray *stars,                     ///< Add comment.
    82     char *modelName                     ///< Add comment.
     82    char *modelName,                     ///< Add comment.
     83    bool poissonErrors   // use poissonian or constant errors?
    8384);
    8485
    8586
    8687/** pmPSFtryModel()
    87  *
     88 * 
    8889 * This function takes the input collection of sources and performs a complete
    8990 * analysis to determine a PSF model of the given type (specified by model name).
    9091 * The result is a pmPSFtry with the results of the analysis.
    91  *
     92 * 
    9293 */
    9394pmPSFtry *pmPSFtryModel(
    9495    psArray *sources,                   ///< Add comment.
    9596    char *modelName,                    ///< Add comment.
    96     float radius                        ///< Add comment.
     97    float radius,                     ///< Add comment.
     98    bool poissonErrors   // use poissonian or constant errors?
    9799);
    98100
    99101
    100102/** pmPSFtryMetric()
    101  *
     103 * 
    102104 * This function is used to measure the PSF model metric for the set of
    103105 * results contained in the pmPSFtry structure.
    104  *
     106 * 
    105107 */
    106108bool pmPSFtryMetric(
Note: See TracChangeset for help on using the changeset viewer.