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