public software.sextractor

[/] [trunk/] [src/] [define.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
*                               define.h
3 2 bertin
*
4 233 bertin
* Global definitions
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) 1993,1998-2010 IAP/CNRS/UPMC
11
*                               (C) 1994,1997 ESO
12
*                               (C) 1995,1996 Sterrewacht Leiden
13 2 bertin
*
14 233 bertin
*       Author:                 Emmanuel Bertin (IAP)
15
*
16
*       License:                GNU General Public License
17
*
18
*       SExtractor is free software: you can redistribute it and/or modify
19
*       it under the terms of the GNU General Public License as published by
20
*       the Free Software Foundation, either version 3 of the License, or
21
*       (at your option) any later version.
22
*       SExtractor is distributed in the hope that it will be useful,
23
*       but WITHOUT ANY WARRANTY; without even the implied warranty of
24
*       MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
25
*       GNU General Public License for more details.
26
*       You should have received a copy of the GNU General Public License
27
*       along with SExtractor. If not, see <http://www.gnu.org/licenses/>.
28
*
29
*       Last modified:          11/10/2010
30
*
31
*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
32 2 bertin
 
33
/* Check if we are using a configure script here */
34
#ifndef HAVE_CONFIG_H
35
#define         VERSION         "2.x"
36 182 bertin
#define         DATE            "2009-03-31"
37 8 bertin
#define         THREADS_NMAX    16              /* max. number of threads */
38 2 bertin
#endif
39
 
40
/*------------------------ what, who, when and where ------------------------*/
41
 
42
#define         BANNER          "SExtractor"
43
#define         MYVERSION       VERSION
44 173 bertin
#define         EXECUTABLE      "sex"
45 233 bertin
#define         COPYRIGHT       "1993-2010 IAP/CNRS/UPMC"
46
#define         DISCLAIMER      BANNER " comes with ABSOLUTELY NO WARRANTY\n" \
47
                "You may redistribute copies of " BANNER "\n" \
48
                "under the terms of the GNU General Public License."
49
#define         AUTHORS         "Emmanuel BERTIN <bertin@iap.fr>"
50 227 bertin
#define         WEBSITE         "http://astromatic.net/software/sextractor"
51 182 bertin
#define         INSTITUTE       "IAP  http://www.iap.fr"
52 2 bertin
 
53
/*--------------------------- Internal constants ----------------------------*/
54
 
55
#define BIG                     1e+30           /* a huge number */
56 4 bertin
#define LESSBIG                 1e+25           /* a somewhat smaller number */
57 2 bertin
#define DATA_BUFSIZE            262144          /* data buffer size */
58
#define MARGIN_SCALE            2.0             /* Margin / object height */ 
59 213 bertin
#define MARGIN_OFFSET           4.0             /* Margin offset (pixels) */ 
60 2 bertin
#define MAXCHAR                 512             /* max. number of characters */
61 15 bertin
#define MAXCHARL                16384           /* max.nb of chars in strlist*/
62 2 bertin
#define MAXDEBAREA              3               /* max. area for deblending */
63
#define MAXFLAG                 4               /* max. # of FLAG-images */
64
#define MAXIMAGE                2               /* max. # of input images */
65
#define MAXNAPER                32              /* max. number of apertures */
66
#define MAXNASSOC               32              /* max. number of assoc. */
67
#define MAXPICSIZE              1048576         /* max. image size */
68
#define NISO                    8               /* number of isophotes */
69 173 bertin
#define OUTPUT                  stderr          /* where all msgs are sent */
70 5 bertin
#define PSF_NPSFMAX             9               /* Max number of fitted PSFs */
71 2 bertin
 
72 173 bertin
#define DEG                     (PI/180.0)      /* 1 deg in radians */
73 2 bertin
#ifndef PI
74
#define PI                      3.1415926535898 /* never met before? */
75
#endif
76
 
77
/* NOTES:
78
 *
79
 *One must have:        BIG < the biggest element a float can store
80
 *                      DATA_BUFSIZE >= 2880 with DATA_BUFSIZE%8 = 0
81
 *                      MAXCHAR >= 16
82
 *                      1 <= MAXCHECK <= MAXLIST (see prefs.h)
83
 *                      1 <= MAXDEBAREA (see prefs.c & extract.c)
84
 *                      1 <= MAXFLAG <= MAXLIST (see prefs.h)
85
 *                      1 <= MAXIMAGE <= MAXLIST (see prefs.h)
86
 *                      1 <= MAXNAPER <= MAXLIST (see prefs.h)
87
 *                      1 <= MAXNASSOC <= MAXLIST (see prefs.h)
88
 *                      MAXPICSIZE > size of any image!!
89
 *                      NISO = 8 (otherwise need to change prefs.h)
90
 *                      1 <= PSF_NPSFMAX
91
*/
92
 
93
/*---- Set defines according to machine's specificities and customizing -----*/
94
 
95
#if _LARGEFILE_SOURCE
96
#define FSEEKO  fseeko
97
#define FTELLO  ftello
98
#else
99
#define FSEEKO  fseek
100
#define FTELLO  ftell
101
#endif
102
/*--------------------- in case of missing constants ------------------------*/
103
 
104
#ifndef         SEEK_SET
105
#define         SEEK_SET        0
106
#endif
107
#ifndef         SEEK_CUR
108
#define         SEEK_CUR        1
109
#endif
110
 
111
#ifndef EXIT_SUCCESS
112
#define EXIT_SUCCESS            0
113
#endif
114
#ifndef EXIT_FAILURE
115
#define EXIT_FAILURE            -1
116
#endif
117
 
118
/*---------------------------- return messages ------------------------------*/
119
 
120
#define         RETURN_OK               0
121
#define         RETURN_ERROR            (-1)
122
#define         RETURN_FATAL_ERROR      (-2)
123
 
124
/*------------------- a few definitions to read FITS parameters ------------*/
125
 
126
#define FBSIZE  2880L   /* size (in bytes) of one FITS block */
127
 
128
#define FITSTOF(k, def) \
129
                        (st[0]=0,((point = fitsnfind(buf, k, n))? \
130
                                 fixexponent(point), \
131
                                atof(strncat(st, &point[10], 70)) \
132
                                :(def)))
133
 
134
#define FITSTOI(k, def) \
135
                        (st[0]=0,(point = fitsnfind(buf, k, n))? \
136
                                 atoi(strncat(st, &point[10], 70)) \
137
                                :(def))
138
 
139
#define FITSTOS(k, str, def) \
140
                { if (fitsread(buf,k,str,H_STRING,T_STRING)!= RETURN_OK) \
141
                    strcpy(str, (def)); \
142
                }
143
 
144
/*------------------------------- Other Macros -----------------------------*/
145
 
146
#define DEXP(x) exp(2.30258509299*(x))  /* 10^x */
147
 
148
#define QFREAD(ptr, size, afile, fname) \
149
                if (fread(ptr, (size_t)(size), (size_t)1, afile)!=1) \
150
                  error(EXIT_FAILURE, "*Error* while reading ", fname)
151
 
152
#define QFWRITE(ptr, size, afile, fname) \
153
                if (fwrite(ptr, (size_t)(size), (size_t)1, afile)!=1) \
154
                  error(EXIT_FAILURE, "*Error* while writing ", fname)
155
 
156
#define QFSEEK(afile, offset, pos, fname) \
157
                if (FSEEKO(afile, (offset), pos)) \
158
                  error(EXIT_FAILURE,"*Error*: file positioning failed in ", \
159
                        fname)
160
 
161
#define QFTELL(afile, pos, fname) \
162
                if ((pos=FTELLO(afile))==-1) \
163
                  error(EXIT_FAILURE,"*Error*: file position unknown in ", \
164
                        fname)
165
 
166
#define QCALLOC(ptr, typ, nel) \
167
                {if (!(ptr = (typ *)calloc((size_t)(nel),sizeof(typ)))) \
168
                  error(EXIT_FAILURE, "Not enough memory for ", \
169
                        #ptr " (" #nel " elements) !");;}
170
 
171
#define QMALLOC(ptr, typ, nel) \
172
                {if (!(ptr = (typ *)malloc((size_t)(nel)*sizeof(typ)))) \
173
                  error(EXIT_FAILURE, "Not enough memory for ", \
174
                        #ptr " (" #nel " elements) !");;}
175
 
176 211 bertin
#define QMALLOC16(ptr, typ, nel) \
177
                {if (posix_memalign((void **)&ptr, 16, (size_t)(nel)*sizeof(typ))) \
178
                  error(EXIT_FAILURE, "Not enough memory for ", \
179
                        #ptr " (" #nel " elements) !");;}
180
 
181 2 bertin
#define QFREE(ptr) \
182
                {free(ptr); \
183
                ptr = NULL;}
184
 
185
#define QREALLOC(ptr, typ, nel) \
186
                {if (!(ptr = (typ *)realloc(ptr, (size_t)(nel)*sizeof(typ)))) \
187
                   error(EXIT_FAILURE, "Not enough memory for ", \
188
                        #ptr " (" #nel " elements) !");;}
189
 
190
#define QMEMCPY(ptrin, ptrout, typ, nel) \
191
                {if (ptrin) \
192
                  {if (!(ptrout = (typ *)malloc((size_t)(nel)*sizeof(typ)))) \
193
                    error(EXIT_FAILURE, "Not enough memory for ", \
194
                        #ptrout " (" #nel " elements) !"); \
195
                   memcpy(ptrout, ptrin, (size_t)(nel)*sizeof(typ));};}
196
 
197
#define RINT(x) (int)(floor(x+0.5))
198
 
199
#define PIX(pic, x, y)  pic->strip[(((int)y)%pic->stripheight) \
200
                                *pic->width +(int)x]
201
 
202
#define NPRINTF         if (prefs.verbose_type == NORM \
203
                                || prefs.verbose_type==WARN) fprintf
204
 
205
#define NFPRINTF(w,x)   {if (prefs.verbose_type==NORM \
206
                                || prefs.verbose_type==WARN) \
207
                                fprintf(w, "\33[1M> %s\n\33[1A",x); \
208
                        else if (prefs.verbose_type == FULL) \
209
                                fprintf(w, "%s.\n", x);}
210
 
211
#define QPRINTF         if (prefs.verbose_type != QUIET)        fprintf
212
 
213
#define FPRINTF         if (prefs.verbose_type == FULL) fprintf
214
 
215
#define QWARNING        if (prefs.verbose_type==WARN \
216
                                || prefs.verbose_type==FULL)    warning
217
 
218
#define FLAG(x)         (*((char *)&flag##x))
219
 
220
#define VECFLAG(x)      (*((char *)flag##x))