public software.sextractor

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

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

Line No. Rev Author Line
1 233 bertin
/*
2
*                               psf.h
3 2 bertin
*
4 233 bertin
* Include file for psf.c.
5 2 bertin
*
6 233 bertin
*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7 2 bertin
*
8 233 bertin
*       This file part of:      SExtractor
9 2 bertin
*
10 233 bertin
*       Copyright:              (C) 1998-2010 IAP/CNRS/UPMC
11 2 bertin
*
12 233 bertin
*       Author:                 Emmanuel Bertin (IAP)
13
*
14
*       License:                GNU General Public License
15
*
16
*       SExtractor is free software: you can redistribute it and/or modify
17
*       it under the terms of the GNU General Public License as published by
18
*       the Free Software Foundation, either version 3 of the License, or
19
*       (at your option) any later version.
20
*       SExtractor is distributed in the hope that it will be useful,
21
*       but WITHOUT ANY WARRANTY; without even the implied warranty of
22
*       MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
23
*       GNU General Public License for more details.
24
*       You should have received a copy of the GNU General Public License
25
*       along with SExtractor. If not, see <http://www.gnu.org/licenses/>.
26
*
27
*       Last modified:          11/10/2010
28
*
29
*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
30 2 bertin
 
31
/*----------------------------- Internal constants --------------------------*/
32
 
33
#define PSF_MAXSHIFT    20.0    /* Max shift from initial guess (pixels)*/
34
#define PSF_MINSHIFT    1e-3    /* Min shift from previous guess (pixels)*/
35
#define PSF_NITER       20      /* Maximum number of iterations in fit */
36
#define PSF_NA          3       /* Number of fitted parameters per component */
37 5 bertin
#define PSF_NTOT        (PSF_NA*PSF_NPSFMAX)    /* Number of fitted parameters*/
38
#define PSF_DOUBLETOT   ((PSF_NA+1)*PSF_NPSFMAX)/* Nb of fitted parameters */
39 2 bertin
#define PC_NITER        1       /* Maximum number of iterations in PC fit */
40
 
41
/* NOTES:
42
One must have:  PSF_MAXSHIFT > 0.0
43
                PSF_NPSF >= 1
44
                PSF_NITER >= 1
45
*/
46
 
47
/*--------------------------- structure definitions -------------------------*/
48
 
49
typedef struct code
50
  {
51
  float         *pc;
52
  float         **param;
53
  int           *parammod;
54
  int           ncode;
55
  int           nparam;
56
  }             codestruct;
57
 
58
typedef struct pc
59
  {
60
  char          name[MAXCHAR];  /* PC filename */
61
  int           npc;            /* Number of Principal Components */
62
  int           maskdim;        /* Dimensionality of the tabulated data */
63
  int           *masksize;      /* PC mask dimensions */
64
  int           masknpix;       /* Total number of involved PC pixels */
65
  float         *maskcomp;      /* Convolved pix data (principal components) */
66
  int           omaskdim;       /* Dimensionality of the tabulated data */
67
  int           *omasksize;     /* PC mask dimensions */
68
  int           omasknpix;      /* Total number of involved PC pixels */
69
  float         *omaskcomp;     /* Original pix data (principal components) */
70 206 bertin
  float         *maskcurr;      /* Current model */
71
  float         *mx2,*my2,*mxy; /* 2nd order moments for each component */
72
  float         *flux;          /* Flux of each component */
73
  float         *bt;            /* B/T for each component */
74 2 bertin
  codestruct    *code;
75
  }     pcstruct;
76
 
77 173 bertin
typedef struct psf
78 2 bertin
  {
79
  char          name[MAXCHAR];  /* Name of the file containing the PSF data */
80
  int           maskdim;        /* Dimensionality of the tabulated data */
81
  int           *masksize;      /* PSF mask dimensions */
82
  int           masknpix;       /* Total number of involved PSF pixels */
83
  float         *maskcomp;      /* Complete pix. data (PSF components) */
84 201 bertin
  float         *maskloc;       /* Local PSF */
85 2 bertin
  double        **context;      /* Contexts */
86
  t_type        *contexttyp;    /* Context types */
87
  char          **contextname;  /* Array of context key-names */
88
  double        *contextoffset; /* Offset to apply to context data */
89
  double        *contextscale;  /* Scaling to apply to context data */
90
  struct poly   *poly;          /* Polynom describing the PSF variations */
91
  pcstruct      *pc;            /* PC components */
92
  double        fwhm;           /* Typical PSF FWHM */
93
  float         pixstep;        /* PSF sampling step */
94 221 bertin
  int           build_flag;     /* Set if the current PSF has been computed */
95 2 bertin
  }     psfstruct;
96
 
97
typedef struct
98
  {
99
  int           niter;          /* Number of iterations required */
100
  int           npsf;           /* Number of fitted stars for this detection */
101 218 bertin
  double        *x,*y;          /* Position derived from the PSF-fitting */
102 2 bertin
  float         *flux;          /* Flux derived from the PSF-fitting */
103 218 bertin
  float         *fluxerr;       /* Flux error estimated from the PSF-fitting */
104 2 bertin
  }     psfitstruct;
105
 
106
/*----------------------------- Global variables ----------------------------*/
107 5 bertin
psfstruct       *psf,*ppsf,*thepsf;
108
psfitstruct     *thepsfit,*ppsfit,*psfit;
109 2 bertin
PIXTYPE         *checkmask;
110
 
111
/*-------------------------------- functions --------------------------------*/
112 5 bertin
extern void     compute_pos(int *pnpsf,int *pconvflag,int *pnpsfflag,
113
                        double radmin2, double radmax2,double r2, double *sol,
114
                        double *flux , double *deltax,double *deltay,
115
                        double *pdx,double *pdy),
116
                compute_pos_phot(int *pnpsf,double *sol,double *flux),
117
                compute_poserr(int j,double *var,double *sol,obj2struct *obj2,
118 218 bertin
                        double *x2, double *y2,double *xy, int npsf),
119 5 bertin
                psf_build(psfstruct *psf),
120
                psf_end(psfstruct *psf, psfitstruct *psfit),
121 2 bertin
                psf_init(psfstruct *psf),
122 206 bertin
                svdfit(double *a, float *b, int m, int n, double *sol,
123 2 bertin
                        double *vmat, double *wmat),
124
                svdvar(double *vmat, double *wmat, int n, double *covmat);
125
 
126 206 bertin
extern double   *compute_gradient (float *weight,int width, int height,
127
                        float *masks, float *maskx, float *masky,
128 5 bertin
                        double *mat),
129 206 bertin
                *compute_gradient_phot(float *weight,int width, int height,
130 221 bertin
                        float *masks, double *pm),
131
                psf_fwhm(psfstruct *psf);
132 5 bertin
 
133 2 bertin
extern psfstruct        *psf_load(char *filename);
134
 
135
extern void     pc_end(pcstruct *pc),
136 206 bertin
                pc_fit(psfstruct *psf, float *data, float *weight,
137
                int width, int height, int ix, int iy, float dx, float dy,
138 2 bertin
                int npc, float backrms),
139 5 bertin
                double_psf_fit(psfstruct *psf, picstruct *field,
140
                        picstruct *wfield, objstruct *obj,
141
                        psfstruct *dpsf, picstruct *dfield, picstruct *dwfield),
142 2 bertin
                psf_fit(psfstruct *psf, picstruct *field, picstruct *wfield,
143
                objstruct *obj),
144
                psf_readcontext(psfstruct *psf, picstruct *field);
145
 
146
extern pcstruct *pc_load(catstruct *cat);
147 221 bertin