public software.sextractor

[/] [trunk/] [src/] [psf.h] - Blame information for rev 218

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 bertin
 /*
2
                                psf.h
3
 
4
*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5
*
6
*       Part of:        SExtractor
7
*
8 5 bertin
*       Authors:        E.BERTIN (IAP)
9
*                       P.DELORME (LAOG)
10 2 bertin
*
11
*       Contents:       Include file for psffit.c.
12
*
13 218 bertin
*       Last modify:    14/12/2009
14 2 bertin
*
15
*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
16
*/
17
 
18
/*----------------------------- Internal constants --------------------------*/
19
 
20
#define PSF_MAXSHIFT    20.0    /* Max shift from initial guess (pixels)*/
21
#define PSF_MINSHIFT    1e-3    /* Min shift from previous guess (pixels)*/
22
#define PSF_NITER       20      /* Maximum number of iterations in fit */
23
#define PSF_NA          3       /* Number of fitted parameters per component */
24 5 bertin
#define PSF_NTOT        (PSF_NA*PSF_NPSFMAX)    /* Number of fitted parameters*/
25
#define PSF_DOUBLETOT   ((PSF_NA+1)*PSF_NPSFMAX)/* Nb of fitted parameters */
26 2 bertin
#define PC_NITER        1       /* Maximum number of iterations in PC fit */
27
 
28
/* NOTES:
29
One must have:  PSF_MAXSHIFT > 0.0
30
                PSF_NPSF >= 1
31
                PSF_NITER >= 1
32
*/
33
 
34
/*--------------------------- structure definitions -------------------------*/
35
 
36
typedef struct code
37
  {
38
  float         *pc;
39
  float         **param;
40
  int           *parammod;
41
  int           ncode;
42
  int           nparam;
43
  }             codestruct;
44
 
45
typedef struct pc
46
  {
47
  char          name[MAXCHAR];  /* PC filename */
48
  int           npc;            /* Number of Principal Components */
49
  int           maskdim;        /* Dimensionality of the tabulated data */
50
  int           *masksize;      /* PC mask dimensions */
51
  int           masknpix;       /* Total number of involved PC pixels */
52
  float         *maskcomp;      /* Convolved pix data (principal components) */
53
  int           omaskdim;       /* Dimensionality of the tabulated data */
54
  int           *omasksize;     /* PC mask dimensions */
55
  int           omasknpix;      /* Total number of involved PC pixels */
56
  float         *omaskcomp;     /* Original pix data (principal components) */
57 206 bertin
  float         *maskcurr;      /* Current model */
58
  float         *mx2,*my2,*mxy; /* 2nd order moments for each component */
59
  float         *flux;          /* Flux of each component */
60
  float         *bt;            /* B/T for each component */
61 2 bertin
  codestruct    *code;
62
  }     pcstruct;
63
 
64 173 bertin
typedef struct psf
65 2 bertin
  {
66
  char          name[MAXCHAR];  /* Name of the file containing the PSF data */
67
  int           maskdim;        /* Dimensionality of the tabulated data */
68
  int           *masksize;      /* PSF mask dimensions */
69
  int           masknpix;       /* Total number of involved PSF pixels */
70
  float         *maskcomp;      /* Complete pix. data (PSF components) */
71 201 bertin
  float         *maskloc;       /* Local PSF */
72 2 bertin
  double        **context;      /* Contexts */
73
  t_type        *contexttyp;    /* Context types */
74
  char          **contextname;  /* Array of context key-names */
75
  double        *contextoffset; /* Offset to apply to context data */
76
  double        *contextscale;  /* Scaling to apply to context data */
77
  struct poly   *poly;          /* Polynom describing the PSF variations */
78
  pcstruct      *pc;            /* PC components */
79
  double        fwhm;           /* Typical PSF FWHM */
80
  float         pixstep;        /* PSF sampling step */
81
  }     psfstruct;
82
 
83
typedef struct
84
  {
85
  int           niter;          /* Number of iterations required */
86
  int           npsf;           /* Number of fitted stars for this detection */
87 218 bertin
  double        *x,*y;          /* Position derived from the PSF-fitting */
88 2 bertin
  float         *flux;          /* Flux derived from the PSF-fitting */
89 218 bertin
  float         *fluxerr;       /* Flux error estimated from the PSF-fitting */
90 2 bertin
  }     psfitstruct;
91
 
92
/*----------------------------- Global variables ----------------------------*/
93 5 bertin
psfstruct       *psf,*ppsf,*thepsf;
94
psfitstruct     *thepsfit,*ppsfit,*psfit;
95 2 bertin
PIXTYPE         *checkmask;
96
 
97
/*-------------------------------- functions --------------------------------*/
98 5 bertin
extern void     compute_pos(int *pnpsf,int *pconvflag,int *pnpsfflag,
99
                        double radmin2, double radmax2,double r2, double *sol,
100
                        double *flux , double *deltax,double *deltay,
101
                        double *pdx,double *pdy),
102
                compute_pos_phot(int *pnpsf,double *sol,double *flux),
103
                compute_poserr(int j,double *var,double *sol,obj2struct *obj2,
104 218 bertin
                        double *x2, double *y2,double *xy, int npsf),
105 5 bertin
                psf_build(psfstruct *psf),
106
                psf_end(psfstruct *psf, psfitstruct *psfit),
107 2 bertin
                psf_init(psfstruct *psf),
108 206 bertin
                svdfit(double *a, float *b, int m, int n, double *sol,
109 2 bertin
                        double *vmat, double *wmat),
110
                svdvar(double *vmat, double *wmat, int n, double *covmat);
111
 
112 206 bertin
extern double   *compute_gradient (float *weight,int width, int height,
113
                        float *masks, float *maskx, float *masky,
114 5 bertin
                        double *mat),
115 206 bertin
                *compute_gradient_phot(float *weight,int width, int height,
116
                        float *masks, double *pm);
117 5 bertin
 
118 2 bertin
extern psfstruct        *psf_load(char *filename);
119
 
120
extern void     pc_end(pcstruct *pc),
121 206 bertin
                pc_fit(psfstruct *psf, float *data, float *weight,
122
                int width, int height, int ix, int iy, float dx, float dy,
123 2 bertin
                int npc, float backrms),
124 5 bertin
                double_psf_fit(psfstruct *psf, picstruct *field,
125
                        picstruct *wfield, objstruct *obj,
126
                        psfstruct *dpsf, picstruct *dfield, picstruct *dwfield),
127 2 bertin
                psf_fit(psfstruct *psf, picstruct *field, picstruct *wfield,
128
                objstruct *obj),
129
                psf_readcontext(psfstruct *psf, picstruct *field);
130
 
131
extern pcstruct *pc_load(catstruct *cat);