IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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
Note: See TracChangeset for help on using the changeset viewer.