public software.sextractor

[/] [trunk/] [src/] [define.h] - Diff between revs 235 and 241

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

Rev 235 Rev 241
/*
/*
*                               define.h
*                               define.h
*
*
* Global definitions
* Global definitions
*
*
*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
*
*
*       This file part of:      SExtractor
*       This file part of:      SExtractor
*
*
*       Copyright:              (C) 1993-2010 Emmanuel Bertin -- IAP/CNRS/UPMC
*       Copyright:              (C) 1993-2011 Emmanuel Bertin -- IAP/CNRS/UPMC
*
*
*       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:          09/01/2011
*
*
*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
 
 
/* Check if we are using a configure script here */
/* Check if we are using a configure script here */
#ifndef HAVE_CONFIG_H
#ifndef HAVE_CONFIG_H
#define         VERSION         "2.x"
#define         VERSION         "2.x"
#define         DATE            "2009-03-31"
#define         DATE            "2009-03-31"
#define         THREADS_NMAX    16              /* max. number of threads */
#define         THREADS_NMAX    16              /* max. number of threads */
#endif
#endif
 
 
/*------------------------ what, who, when and where ------------------------*/
/*------------------------ what, who, when and where ------------------------*/
 
 
#define         BANNER          "SExtractor"
#define         BANNER          "SExtractor"
#define         MYVERSION       VERSION
#define         MYVERSION       VERSION
#define         EXECUTABLE      "sex"
#define         EXECUTABLE      "sex"
#define         COPYRIGHT       "2010 IAP/CNRS/UPMC"
#define         COPYRIGHT       "2011 IAP/CNRS/UPMC"
#define         DISCLAIMER      BANNER " comes with ABSOLUTELY NO WARRANTY\n" \
#define         DISCLAIMER      BANNER " comes with ABSOLUTELY NO WARRANTY\n" \
                "You may redistribute copies of " BANNER "\n" \
                "You may redistribute copies of " BANNER "\n" \
                "under the terms of the GNU General Public License."
                "under the terms of the GNU General Public License."
#define         AUTHORS         "Emmanuel BERTIN <bertin@iap.fr>"
#define         AUTHORS         "Emmanuel BERTIN <bertin@iap.fr>"
#define         WEBSITE         "http://astromatic.net/software/sextractor"
#define         WEBSITE         "http://astromatic.net/software/sextractor"
#define         INSTITUTE       "IAP  http://www.iap.fr"
#define         INSTITUTE       "IAP  http://www.iap.fr"
 
 
/*--------------------------- Internal constants ----------------------------*/
/*--------------------------- Internal constants ----------------------------*/
 
 
#define BIG                     1e+30           /* a huge number */
#define BIG                     1e+30           /* a huge number */
#define LESSBIG                 1e+25           /* a somewhat smaller number */
#define LESSBIG                 1e+25           /* a somewhat smaller number */
#define DATA_BUFSIZE            262144          /* data buffer size */
#define DATA_BUFSIZE            262144          /* data buffer size */
#define MARGIN_SCALE            2.0             /* Margin / object height */ 
#define MARGIN_SCALE            2.0             /* Margin / object height */ 
#define MARGIN_OFFSET           4.0             /* Margin offset (pixels) */ 
#define MARGIN_OFFSET           4.0             /* Margin offset (pixels) */ 
#define MAXCHAR                 512             /* max. number of characters */
#define MAXCHAR                 512             /* max. number of characters */
#define MAXCHARL                16384           /* max.nb of chars in strlist*/
#define MAXCHARL                16384           /* max.nb of chars in strlist*/
#define MAXDEBAREA              3               /* max. area for deblending */
#define MAXDEBAREA              3               /* max. area for deblending */
#define MAXFLAG                 4               /* max. # of FLAG-images */
#define MAXFLAG                 4               /* max. # of FLAG-images */
#define MAXIMAGE                2               /* max. # of input images */
#define MAXIMAGE                2               /* max. # of input images */
#define MAXNAPER                32              /* max. number of apertures */
#define MAXNAPER                32              /* max. number of apertures */
#define MAXNASSOC               32              /* max. number of assoc. */
#define MAXNASSOC               32              /* max. number of assoc. */
#define MAXPICSIZE              1048576         /* max. image size */
#define MAXPICSIZE              1048576         /* max. image size */
#define NISO                    8               /* number of isophotes */
#define NISO                    8               /* number of isophotes */
#define OUTPUT                  stderr          /* where all msgs are sent */
#define OUTPUT                  stderr          /* where all msgs are sent */
#define PSF_NPSFMAX             9               /* Max number of fitted PSFs */
#define PSF_NPSFMAX             9               /* Max number of fitted PSFs */
 
 
#define DEG                     (PI/180.0)      /* 1 deg in radians */
#define DEG                     (PI/180.0)      /* 1 deg in radians */
#ifndef PI
#ifndef PI
#define PI                      3.1415926535898 /* never met before? */
#define PI                      3.1415926535898 /* never met before? */
#endif
#endif
 
 
/* NOTES:
/* NOTES:
 *
 *
 *One must have:        BIG < the biggest element a float can store
 *One must have:        BIG < the biggest element a float can store
 *                      DATA_BUFSIZE >= 2880 with DATA_BUFSIZE%8 = 0
 *                      DATA_BUFSIZE >= 2880 with DATA_BUFSIZE%8 = 0
 *                      MAXCHAR >= 16
 *                      MAXCHAR >= 16
 *                      1 <= MAXCHECK <= MAXLIST (see prefs.h)
 *                      1 <= MAXCHECK <= MAXLIST (see prefs.h)
 *                      1 <= MAXDEBAREA (see prefs.c & extract.c)
 *                      1 <= MAXDEBAREA (see prefs.c & extract.c)
 *                      1 <= MAXFLAG <= MAXLIST (see prefs.h)
 *                      1 <= MAXFLAG <= MAXLIST (see prefs.h)
 *                      1 <= MAXIMAGE <= MAXLIST (see prefs.h)
 *                      1 <= MAXIMAGE <= MAXLIST (see prefs.h)
 *                      1 <= MAXNAPER <= MAXLIST (see prefs.h)
 *                      1 <= MAXNAPER <= MAXLIST (see prefs.h)
 *                      1 <= MAXNASSOC <= MAXLIST (see prefs.h)
 *                      1 <= MAXNASSOC <= MAXLIST (see prefs.h)
 *                      MAXPICSIZE > size of any image!!
 *                      MAXPICSIZE > size of any image!!
 *                      NISO = 8 (otherwise need to change prefs.h)
 *                      NISO = 8 (otherwise need to change prefs.h)
 *                      1 <= PSF_NPSFMAX
 *                      1 <= PSF_NPSFMAX
*/
*/
 
 
/*---- Set defines according to machine's specificities and customizing -----*/
/*---- Set defines according to machine's specificities and customizing -----*/
 
 
#if _LARGEFILE_SOURCE
#if _LARGEFILE_SOURCE
#define FSEEKO  fseeko
#define FSEEKO  fseeko
#define FTELLO  ftello
#define FTELLO  ftello
#else
#else
#define FSEEKO  fseek
#define FSEEKO  fseek
#define FTELLO  ftell
#define FTELLO  ftell
#endif
#endif
/*--------------------- in case of missing constants ------------------------*/
/*--------------------- in case of missing constants ------------------------*/
 
 
#ifndef         SEEK_SET
#ifndef         SEEK_SET
#define         SEEK_SET        0
#define         SEEK_SET        0
#endif
#endif
#ifndef         SEEK_CUR
#ifndef         SEEK_CUR
#define         SEEK_CUR        1
#define         SEEK_CUR        1
#endif
#endif
 
 
#ifndef EXIT_SUCCESS
#ifndef EXIT_SUCCESS
#define EXIT_SUCCESS            0
#define EXIT_SUCCESS            0
#endif
#endif
#ifndef EXIT_FAILURE
#ifndef EXIT_FAILURE
#define EXIT_FAILURE            -1
#define EXIT_FAILURE            -1
#endif
#endif
 
 
/*---------------------------- return messages ------------------------------*/
/*---------------------------- return messages ------------------------------*/
 
 
#define         RETURN_OK               0
#define         RETURN_OK               0
#define         RETURN_ERROR            (-1)
#define         RETURN_ERROR            (-1)
#define         RETURN_FATAL_ERROR      (-2)
#define         RETURN_FATAL_ERROR      (-2)
 
 
/*------------------- a few definitions to read FITS parameters ------------*/
/*------------------- a few definitions to read FITS parameters ------------*/
 
 
#define FBSIZE  2880L   /* size (in bytes) of one FITS block */
#define FBSIZE  2880L   /* size (in bytes) of one FITS block */
 
 
#define FITSTOF(k, def) \
#define FITSTOF(k, def) \
                        (st[0]=0,((point = fitsnfind(buf, k, n))? \
                        (st[0]=0,((point = fitsnfind(buf, k, n))? \
                                 fixexponent(point), \
                                 fixexponent(point), \
                                atof(strncat(st, &point[10], 70)) \
                                atof(strncat(st, &point[10], 70)) \
                                :(def)))
                                :(def)))
 
 
#define FITSTOI(k, def) \
#define FITSTOI(k, def) \
                        (st[0]=0,(point = fitsnfind(buf, k, n))? \
                        (st[0]=0,(point = fitsnfind(buf, k, n))? \
                                 atoi(strncat(st, &point[10], 70)) \
                                 atoi(strncat(st, &point[10], 70)) \
                                :(def))
                                :(def))
 
 
#define FITSTOS(k, str, def) \
#define FITSTOS(k, str, def) \
                { if (fitsread(buf,k,str,H_STRING,T_STRING)!= RETURN_OK) \
                { if (fitsread(buf,k,str,H_STRING,T_STRING)!= RETURN_OK) \
                    strcpy(str, (def)); \
                    strcpy(str, (def)); \
                }
                }
 
 
/*------------------------------- Other Macros -----------------------------*/
/*------------------------------- Other Macros -----------------------------*/
 
 
#define DEXP(x) exp(2.30258509299*(x))  /* 10^x */
#define DEXP(x) exp(2.30258509299*(x))  /* 10^x */
 
#define DEXPF(x)        expf(2.30258509299f*(x))        /* 10^x */
 
 
#define QFREAD(ptr, size, afile, fname) \
#define QFREAD(ptr, size, afile, fname) \
                if (fread(ptr, (size_t)(size), (size_t)1, afile)!=1) \
                if (fread(ptr, (size_t)(size), (size_t)1, afile)!=1) \
                  error(EXIT_FAILURE, "*Error* while reading ", fname)
                  error(EXIT_FAILURE, "*Error* while reading ", fname)
 
 
#define QFWRITE(ptr, size, afile, fname) \
#define QFWRITE(ptr, size, afile, fname) \
                if (fwrite(ptr, (size_t)(size), (size_t)1, afile)!=1) \
                if (fwrite(ptr, (size_t)(size), (size_t)1, afile)!=1) \
                  error(EXIT_FAILURE, "*Error* while writing ", fname)
                  error(EXIT_FAILURE, "*Error* while writing ", fname)
 
 
#define QFSEEK(afile, offset, pos, fname) \
#define QFSEEK(afile, offset, pos, fname) \
                if (FSEEKO(afile, (offset), pos)) \
                if (FSEEKO(afile, (offset), pos)) \
                  error(EXIT_FAILURE,"*Error*: file positioning failed in ", \
                  error(EXIT_FAILURE,"*Error*: file positioning failed in ", \
                        fname)
                        fname)
 
 
#define QFTELL(afile, pos, fname) \
#define QFTELL(afile, pos, fname) \
                if ((pos=FTELLO(afile))==-1) \
                if ((pos=FTELLO(afile))==-1) \
                  error(EXIT_FAILURE,"*Error*: file position unknown in ", \
                  error(EXIT_FAILURE,"*Error*: file position unknown in ", \
                        fname)
                        fname)
 
 
#define QCALLOC(ptr, typ, nel) \
#define QCALLOC(ptr, typ, nel) \
                {if (!(ptr = (typ *)calloc((size_t)(nel),sizeof(typ)))) \
                {if (!(ptr = (typ *)calloc((size_t)(nel),sizeof(typ)))) \
                  error(EXIT_FAILURE, "Not enough memory for ", \
                  error(EXIT_FAILURE, "Not enough memory for ", \
                        #ptr " (" #nel " elements) !");;}
                        #ptr " (" #nel " elements) !");;}
 
 
#define QMALLOC(ptr, typ, nel) \
#define QMALLOC(ptr, typ, nel) \
                {if (!(ptr = (typ *)malloc((size_t)(nel)*sizeof(typ)))) \
                {if (!(ptr = (typ *)malloc((size_t)(nel)*sizeof(typ)))) \
                  error(EXIT_FAILURE, "Not enough memory for ", \
                  error(EXIT_FAILURE, "Not enough memory for ", \
                        #ptr " (" #nel " elements) !");;}
                        #ptr " (" #nel " elements) !");;}
 
 
#define QMALLOC16(ptr, typ, nel) \
#define QMALLOC16(ptr, typ, nel) \
                {if (posix_memalign((void **)&ptr, 16, (size_t)(nel)*sizeof(typ))) \
                {if (posix_memalign((void **)&ptr, 16, (size_t)(nel)*sizeof(typ))) \
                  error(EXIT_FAILURE, "Not enough memory for ", \
                  error(EXIT_FAILURE, "Not enough memory for ", \
                        #ptr " (" #nel " elements) !");;}
                        #ptr " (" #nel " elements) !");;}
 
 
#define QFREE(ptr) \
#define QFREE(ptr) \
                {free(ptr); \
                {free(ptr); \
                ptr = NULL;}
                ptr = NULL;}
 
 
#define QREALLOC(ptr, typ, nel) \
#define QREALLOC(ptr, typ, nel) \
                {if (!(ptr = (typ *)realloc(ptr, (size_t)(nel)*sizeof(typ)))) \
                {if (!(ptr = (typ *)realloc(ptr, (size_t)(nel)*sizeof(typ)))) \
                   error(EXIT_FAILURE, "Not enough memory for ", \
                   error(EXIT_FAILURE, "Not enough memory for ", \
                        #ptr " (" #nel " elements) !");;}
                        #ptr " (" #nel " elements) !");;}
 
 
#define QMEMCPY(ptrin, ptrout, typ, nel) \
#define QMEMCPY(ptrin, ptrout, typ, nel) \
                {if (ptrin) \
                {if (ptrin) \
                  {if (!(ptrout = (typ *)malloc((size_t)(nel)*sizeof(typ)))) \
                  {if (!(ptrout = (typ *)malloc((size_t)(nel)*sizeof(typ)))) \
                    error(EXIT_FAILURE, "Not enough memory for ", \
                    error(EXIT_FAILURE, "Not enough memory for ", \
                        #ptrout " (" #nel " elements) !"); \
                        #ptrout " (" #nel " elements) !"); \
                   memcpy(ptrout, ptrin, (size_t)(nel)*sizeof(typ));};}
                   memcpy(ptrout, ptrin, (size_t)(nel)*sizeof(typ));};}
 
 
#define RINT(x) (int)(floor(x+0.5))
#define RINT(x) (int)(floor(x+0.5))
 
 
#define PIX(pic, x, y)  pic->strip[(((int)y)%pic->stripheight) \
#define PIX(pic, x, y)  pic->strip[(((int)y)%pic->stripheight) \
                                *pic->width +(int)x]
                                *pic->width +(int)x]
 
 
#define NPRINTF         if (prefs.verbose_type == NORM \
#define NPRINTF         if (prefs.verbose_type == NORM \
                                || prefs.verbose_type==WARN) fprintf
                                || prefs.verbose_type==WARN) fprintf
 
 
#define NFPRINTF(w,x)   {if (prefs.verbose_type==NORM \
#define NFPRINTF(w,x)   {if (prefs.verbose_type==NORM \
                                || prefs.verbose_type==WARN) \
                                || prefs.verbose_type==WARN) \
                                fprintf(w, "\33[1M> %s\n\33[1A",x); \
                                fprintf(w, "\33[1M> %s\n\33[1A",x); \
                        else if (prefs.verbose_type == FULL) \
                        else if (prefs.verbose_type == FULL) \
                                fprintf(w, "%s.\n", x);}
                                fprintf(w, "%s.\n", x);}
 
 
#define QPRINTF         if (prefs.verbose_type != QUIET)        fprintf
#define QPRINTF         if (prefs.verbose_type != QUIET)        fprintf
 
 
#define FPRINTF         if (prefs.verbose_type == FULL) fprintf
#define FPRINTF         if (prefs.verbose_type == FULL) fprintf
 
 
#define QWARNING        if (prefs.verbose_type==WARN \
#define QWARNING        if (prefs.verbose_type==WARN \
                                || prefs.verbose_type==FULL)    warning
                                || prefs.verbose_type==FULL)    warning
 
 
#define FLAG(x)         (*((char *)&flag##x))
#define FLAG(x)         (*((char *)&flag##x))
 
 
#define VECFLAG(x)      (*((char *)flag##x))
#define VECFLAG(x)      (*((char *)flag##x))