public software.sextractor

[/] [trunk/] [src/] [psf.h] - Diff between revs 233 and 235

Go to most recent revision | Only display areas with differences | Details | Blame | View Log

Rev 233 Rev 235
/*
/*
*                               psf.h
*                               psf.h
*
*
* Include file for psf.c.
* Include file for psf.c.
*
*
*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
*
*
*       This file part of:      SExtractor
*       This file part of:      SExtractor
*
*
*       Copyright:              (C) 1998-2010 IAP/CNRS/UPMC
*       Copyright:              (C) 1998-2010 Emmanuel Bertin -- IAP/CNRS/UPMC
*
 
*       Author:                 Emmanuel Bertin (IAP)
 
*
*
*       License:                GNU General Public License
*       License:                GNU General Public License
*
*
*       SExtractor is free software: you can redistribute it and/or modify
*       SExtractor is free software: you can redistribute it and/or modify
*       it under the terms of the GNU General Public License as published by
*       it under the terms of the GNU General Public License as published by
*       the Free Software Foundation, either version 3 of the License, or
*       the Free Software Foundation, either version 3 of the License, or
*       (at your option) any later version.
*       (at your option) any later version.
*       SExtractor is distributed in the hope that it will be useful,
*       SExtractor is distributed in the hope that it will be useful,
*       but WITHOUT ANY WARRANTY; without even the implied warranty of
*       but WITHOUT ANY WARRANTY; without even the implied warranty of
*       MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
*       MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
*       GNU General Public License for more details.
*       GNU General Public License for more details.
*       You should have received a copy of the GNU General Public License
*       You should have received a copy of the GNU General Public License
*       along with SExtractor. If not, see <http://www.gnu.org/licenses/>.
*       along with SExtractor. If not, see <http://www.gnu.org/licenses/>.
*
*
*       Last modified:          11/10/2010
*       Last modified:          11/10/2010
*
*
*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
 
 
/*----------------------------- Internal constants --------------------------*/
/*----------------------------- Internal constants --------------------------*/
 
 
#define PSF_MAXSHIFT    20.0    /* Max shift from initial guess (pixels)*/
#define PSF_MAXSHIFT    20.0    /* Max shift from initial guess (pixels)*/
#define PSF_MINSHIFT    1e-3    /* Min shift from previous guess (pixels)*/
#define PSF_MINSHIFT    1e-3    /* Min shift from previous guess (pixels)*/
#define PSF_NITER       20      /* Maximum number of iterations in fit */
#define PSF_NITER       20      /* Maximum number of iterations in fit */
#define PSF_NA          3       /* Number of fitted parameters per component */
#define PSF_NA          3       /* Number of fitted parameters per component */
#define PSF_NTOT        (PSF_NA*PSF_NPSFMAX)    /* Number of fitted parameters*/
#define PSF_NTOT        (PSF_NA*PSF_NPSFMAX)    /* Number of fitted parameters*/
#define PSF_DOUBLETOT   ((PSF_NA+1)*PSF_NPSFMAX)/* Nb of fitted parameters */
#define PSF_DOUBLETOT   ((PSF_NA+1)*PSF_NPSFMAX)/* Nb of fitted parameters */
#define PC_NITER        1       /* Maximum number of iterations in PC fit */
#define PC_NITER        1       /* Maximum number of iterations in PC fit */
 
 
/* NOTES:
/* NOTES:
One must have:  PSF_MAXSHIFT > 0.0
One must have:  PSF_MAXSHIFT > 0.0
                PSF_NPSF >= 1
                PSF_NPSF >= 1
                PSF_NITER >= 1
                PSF_NITER >= 1
*/
*/
 
 
/*--------------------------- structure definitions -------------------------*/
/*--------------------------- structure definitions -------------------------*/
 
 
typedef struct code
typedef struct code
  {
  {
  float         *pc;
  float         *pc;
  float         **param;
  float         **param;
  int           *parammod;
  int           *parammod;
  int           ncode;
  int           ncode;
  int           nparam;
  int           nparam;
  }             codestruct;
  }             codestruct;
 
 
typedef struct pc
typedef struct pc
  {
  {
  char          name[MAXCHAR];  /* PC filename */
  char          name[MAXCHAR];  /* PC filename */
  int           npc;            /* Number of Principal Components */
  int           npc;            /* Number of Principal Components */
  int           maskdim;        /* Dimensionality of the tabulated data */
  int           maskdim;        /* Dimensionality of the tabulated data */
  int           *masksize;      /* PC mask dimensions */
  int           *masksize;      /* PC mask dimensions */
  int           masknpix;       /* Total number of involved PC pixels */
  int           masknpix;       /* Total number of involved PC pixels */
  float         *maskcomp;      /* Convolved pix data (principal components) */
  float         *maskcomp;      /* Convolved pix data (principal components) */
  int           omaskdim;       /* Dimensionality of the tabulated data */
  int           omaskdim;       /* Dimensionality of the tabulated data */
  int           *omasksize;     /* PC mask dimensions */
  int           *omasksize;     /* PC mask dimensions */
  int           omasknpix;      /* Total number of involved PC pixels */
  int           omasknpix;      /* Total number of involved PC pixels */
  float         *omaskcomp;     /* Original pix data (principal components) */
  float         *omaskcomp;     /* Original pix data (principal components) */
  float         *maskcurr;      /* Current model */
  float         *maskcurr;      /* Current model */
  float         *mx2,*my2,*mxy; /* 2nd order moments for each component */
  float         *mx2,*my2,*mxy; /* 2nd order moments for each component */
  float         *flux;          /* Flux of each component */
  float         *flux;          /* Flux of each component */
  float         *bt;            /* B/T for each component */
  float         *bt;            /* B/T for each component */
  codestruct    *code;
  codestruct    *code;
  }     pcstruct;
  }     pcstruct;
 
 
typedef struct psf
typedef struct psf
  {
  {
  char          name[MAXCHAR];  /* Name of the file containing the PSF data */
  char          name[MAXCHAR];  /* Name of the file containing the PSF data */
  int           maskdim;        /* Dimensionality of the tabulated data */
  int           maskdim;        /* Dimensionality of the tabulated data */
  int           *masksize;      /* PSF mask dimensions */
  int           *masksize;      /* PSF mask dimensions */
  int           masknpix;       /* Total number of involved PSF pixels */
  int           masknpix;       /* Total number of involved PSF pixels */
  float         *maskcomp;      /* Complete pix. data (PSF components) */
  float         *maskcomp;      /* Complete pix. data (PSF components) */
  float         *maskloc;       /* Local PSF */
  float         *maskloc;       /* Local PSF */
  double        **context;      /* Contexts */
  double        **context;      /* Contexts */
  t_type        *contexttyp;    /* Context types */
  t_type        *contexttyp;    /* Context types */
  char          **contextname;  /* Array of context key-names */
  char          **contextname;  /* Array of context key-names */
  double        *contextoffset; /* Offset to apply to context data */
  double        *contextoffset; /* Offset to apply to context data */
  double        *contextscale;  /* Scaling to apply to context data */
  double        *contextscale;  /* Scaling to apply to context data */
  struct poly   *poly;          /* Polynom describing the PSF variations */
  struct poly   *poly;          /* Polynom describing the PSF variations */
  pcstruct      *pc;            /* PC components */
  pcstruct      *pc;            /* PC components */
  double        fwhm;           /* Typical PSF FWHM */
  double        fwhm;           /* Typical PSF FWHM */
  float         pixstep;        /* PSF sampling step */
  float         pixstep;        /* PSF sampling step */
  int           build_flag;     /* Set if the current PSF has been computed */
  int           build_flag;     /* Set if the current PSF has been computed */
  }     psfstruct;
  }     psfstruct;
 
 
typedef struct
typedef struct
  {
  {
  int           niter;          /* Number of iterations required */
  int           niter;          /* Number of iterations required */
  int           npsf;           /* Number of fitted stars for this detection */
  int           npsf;           /* Number of fitted stars for this detection */
  double        *x,*y;          /* Position derived from the PSF-fitting */
  double        *x,*y;          /* Position derived from the PSF-fitting */
  float         *flux;          /* Flux derived from the PSF-fitting */
  float         *flux;          /* Flux derived from the PSF-fitting */
  float         *fluxerr;       /* Flux error estimated from the PSF-fitting */
  float         *fluxerr;       /* Flux error estimated from the PSF-fitting */
  }     psfitstruct;
  }     psfitstruct;
 
 
/*----------------------------- Global variables ----------------------------*/
/*----------------------------- Global variables ----------------------------*/
psfstruct       *psf,*ppsf,*thepsf;
psfstruct       *psf,*ppsf,*thepsf;
psfitstruct     *thepsfit,*ppsfit,*psfit;
psfitstruct     *thepsfit,*ppsfit,*psfit;
PIXTYPE         *checkmask;
PIXTYPE         *checkmask;
 
 
/*-------------------------------- functions --------------------------------*/
/*-------------------------------- functions --------------------------------*/
extern void     compute_pos(int *pnpsf,int *pconvflag,int *pnpsfflag,
extern void     compute_pos(int *pnpsf,int *pconvflag,int *pnpsfflag,
                        double radmin2, double radmax2,double r2, double *sol,
                        double radmin2, double radmax2,double r2, double *sol,
                        double *flux , double *deltax,double *deltay,
                        double *flux , double *deltax,double *deltay,
                        double *pdx,double *pdy),
                        double *pdx,double *pdy),
                compute_pos_phot(int *pnpsf,double *sol,double *flux),
                compute_pos_phot(int *pnpsf,double *sol,double *flux),
                compute_poserr(int j,double *var,double *sol,obj2struct *obj2,
                compute_poserr(int j,double *var,double *sol,obj2struct *obj2,
                        double *x2, double *y2,double *xy, int npsf),
                        double *x2, double *y2,double *xy, int npsf),
                psf_build(psfstruct *psf),
                psf_build(psfstruct *psf),
                psf_end(psfstruct *psf, psfitstruct *psfit),
                psf_end(psfstruct *psf, psfitstruct *psfit),
                psf_init(psfstruct *psf),
                psf_init(psfstruct *psf),
                svdfit(double *a, float *b, int m, int n, double *sol,
                svdfit(double *a, float *b, int m, int n, double *sol,
                        double *vmat, double *wmat),
                        double *vmat, double *wmat),
                svdvar(double *vmat, double *wmat, int n, double *covmat);
                svdvar(double *vmat, double *wmat, int n, double *covmat);
 
 
extern double   *compute_gradient (float *weight,int width, int height,
extern double   *compute_gradient (float *weight,int width, int height,
                        float *masks, float *maskx, float *masky,
                        float *masks, float *maskx, float *masky,
                        double *mat),
                        double *mat),
                *compute_gradient_phot(float *weight,int width, int height,
                *compute_gradient_phot(float *weight,int width, int height,
                        float *masks, double *pm),
                        float *masks, double *pm),
                psf_fwhm(psfstruct *psf);
                psf_fwhm(psfstruct *psf);
 
 
extern psfstruct        *psf_load(char *filename);
extern psfstruct        *psf_load(char *filename);
 
 
extern void     pc_end(pcstruct *pc),
extern void     pc_end(pcstruct *pc),
                pc_fit(psfstruct *psf, float *data, float *weight,
                pc_fit(psfstruct *psf, float *data, float *weight,
                int width, int height, int ix, int iy, float dx, float dy,
                int width, int height, int ix, int iy, float dx, float dy,
                int npc, float backrms),
                int npc, float backrms),
                double_psf_fit(psfstruct *psf, picstruct *field,
                double_psf_fit(psfstruct *psf, picstruct *field,
                        picstruct *wfield, objstruct *obj,
                        picstruct *wfield, objstruct *obj,
                        psfstruct *dpsf, picstruct *dfield, picstruct *dwfield),
                        psfstruct *dpsf, picstruct *dfield, picstruct *dwfield),
                psf_fit(psfstruct *psf, picstruct *field, picstruct *wfield,
                psf_fit(psfstruct *psf, picstruct *field, picstruct *wfield,
                objstruct *obj),
                objstruct *obj),
                psf_readcontext(psfstruct *psf, picstruct *field);
                psf_readcontext(psfstruct *psf, picstruct *field);
 
 
extern pcstruct *pc_load(catstruct *cat);
extern pcstruct *pc_load(catstruct *cat);