Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
csst-pipeline
msc
sextractor
Commits
08c0ebe3
Unverified
Commit
08c0ebe3
authored
Mar 09, 2023
by
Emmanuel Bertin
Committed by
GitHub
Mar 09, 2023
Browse files
Merge pull request #47 from astromatic/develop
Develop
parents
9689a1c4
f7c10f46
Changes
45
Hide whitespace changes
Inline
Side-by-side
m4/acx_pthread.m4
View file @
08c0ebe3
...
...
@@ -7,7 +7,7 @@ dnl %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
dnl
dnl This file part of: AstrOmatic software
dnl
dnl Copyright: (C) 2002-20
10
Emmanuel Bertin -- IAP/CNRS/
UPMC
dnl Copyright: (C) 2002-20
22
Emmanuel Bertin -- IAP/CNRS/
SorbonneU
dnl (C) 2001 Steven G. Johnson (original version)
dnl
dnl Licenses: GPL (this version)
...
...
@@ -25,7 +25,7 @@ dnl You should have received a copy of the GNU General Public License
dnl along with AstrOmatic software.
dnl If not, see <http://www.gnu.org/licenses/>.
dnl
dnl Last modified:
09/10
/20
10
dnl Last modified:
15/09
/20
22
dnl
dnl %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
dnl
...
...
@@ -88,7 +88,7 @@ if test x"$PTHREAD_LIBS$PTHREAD_CFLAGS" != x; then
save_LIBS="$LIBS"
LIBS="$PTHREAD_LIBS $LIBS"
AC_MSG_CHECKING([for pthread_join in LIBS=$PTHREAD_LIBS with CFLAGS=$PTHREAD_CFLAGS])
AC_
TRY_
LINK_
FUNC(
pthread_join, acx_pthread_ok=yes)
AC_LINK_
IFELSE([AC_LANG_CALL([],
pthread_join
)]
, acx_pthread_ok=yes)
AC_MSG_RESULT($acx_pthread_ok)
if test x"$acx_pthread_ok" = xno; then
PTHREAD_LIBS=""
...
...
@@ -170,10 +170,10 @@ for flag in $acx_pthread_flags; do
# pthread_cleanup_push because it is one of the few pthread
# functions on Solaris that doesn't have a non-functional libc stub.
# We try pthread_create on general principles.
AC_
TRY_
LINK([#include <pthread.h>],
AC_LINK
_IFELSE([AC_LANG_CALL
([#include <pthread.h>],
[pthread_t th; pthread_join(th, 0);
pthread_attr_init(0); pthread_cleanup_push(0, 0);
pthread_create(0,0,0,0); pthread_cleanup_pop(0); ],
pthread_create(0,0,0,0); pthread_cleanup_pop(0);
])
],
[acx_pthread_ok=yes])
LIBS="$save_LIBS"
...
...
@@ -199,12 +199,12 @@ if test "x$acx_pthread_ok" = xyes; then
# Detect AIX lossage: threads are created detached by default
# and the JOINABLE attribute has a nonstandard name (UNDETACHED).
AC_MSG_CHECKING([for joinable pthread attribute])
AC_
TRY_
LINK([#include <pthread.h>],
[int attr=PTHREAD_CREATE_JOINABLE;],
AC_LINK
_IFELSE([AC_LANG_CALL
([#include <pthread.h>],
[int attr=PTHREAD_CREATE_JOINABLE;]
)]
,
ok=PTHREAD_CREATE_JOINABLE, ok=unknown)
if test x"$ok" = xunknown; then
AC_
TRY_
LINK([#include <pthread.h>],
[int attr=PTHREAD_CREATE_UNDETACHED;],
AC_LINK
_IFELSE([AC_LANG_CALL
([#include <pthread.h>],
[int attr=PTHREAD_CREATE_UNDETACHED;]
)]
,
ok=PTHREAD_CREATE_UNDETACHED, ok=unknown)
fi
if test x"$ok" != xPTHREAD_CREATE_JOINABLE; then
...
...
sextractor.spec.in
View file @
08c0ebe3
...
...
@@ -7,7 +7,7 @@
#
# This file part of: SExtractor
#
# Copyright: (C) 2002-202
0
IAP/CNRS/SorbonneU
# Copyright: (C) 2002-202
2
IAP/CNRS/SorbonneU
#
# License: GNU General Public License
#
...
...
@@ -22,7 +22,7 @@
# You should have received a copy of the GNU General Public License
# along with SExtractor. If not, see <http://www.gnu.org/licenses/>.
#
# Last modified:
02
/0
1
/202
0
# Last modified:
15
/0
9
/202
2
#
#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
...
...
@@ -44,6 +44,7 @@ BuildRoot: %{_tmppath}/%{name}-buildroot
BuildRequires: pkgconfig
BuildRequires: fftw-devel >= 3.1
BuildRequires: atlas-devel >= 3.6.0
BuildRequires: cfitsio-devel >= 3.30
%description
Extract catalogs of sources from astronomical images
...
...
src/analyse.c
View file @
08c0ebe3
...
...
@@ -280,8 +280,7 @@ void examineiso(picstruct *field, picstruct *dfield, objstruct *obj,
emy2
/=
flux2
;
/* variance of ym */
emxy
/=
flux2
;
/* covariance */
/*-- Handle fully correlated profile
s (which cause a singularity...) */
/*-- Handle fully correlated profiles (which cause a singularity...) */
esum
*=
0
.
08333
/
flux2
;
if
(
obj
->
singuflag
&&
(
emx2
*
emy2
-
emxy
*
emxy
)
<
esum
*
esum
)
{
...
...
@@ -718,10 +717,10 @@ void endobject(picstruct *field, picstruct *dfield, picstruct *wfield,
dgeo_copy
(
dgeofield
,
outobj2
.
vignet_dgeox
,
outobj2
.
vignet_dgeoy
,
prefs
.
vignet_dgeoxsize
[
0
],
prefs
.
vignet_dgeoxsize
[
1
],
ix
,
iy
);
else
{
if
(
FLAG
(
obj2
.
vignet_dgeox
))
if
(
FLAG
(
obj2
.
vignet_dgeox
))
dgeo_copy
(
dgeofield
,
outobj2
.
vignet_dgeox
,
NULL
,
prefs
.
vignet_dgeoxsize
[
0
],
prefs
.
vignet_dgeoxsize
[
1
],
ix
,
iy
);
if
(
FLAG
(
obj2
.
vignet_dgeoy
))
if
(
FLAG
(
obj2
.
vignet_dgeoy
))
dgeo_copy
(
dgeofield
,
NULL
,
outobj2
.
vignet_dgeoy
,
prefs
.
vignet_dgeoysize
[
0
],
prefs
.
vignet_dgeoysize
[
1
],
ix
,
iy
);
}
...
...
src/back.c
View file @
08c0ebe3
...
...
@@ -7,7 +7,7 @@
*
* This file part of: SExtractor
*
* Copyright: (C) 1993-20
14 Emmanuel Bertin --
IAP/CNRS/
UPMC
* Copyright: (C) 1993-20
20
IAP/CNRS/
SorbonneU
*
* License: GNU General Public License
*
...
...
@@ -22,7 +22,7 @@
* You should have received a copy of the GNU General Public License
* along with SExtractor. If not, see <http://www.gnu.org/licenses/>.
*
* Last modified:
17
/0
6
/20
14
* Last modified:
23
/0
9
/20
20
*
*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
...
...
@@ -52,8 +52,10 @@ void makeback(picstruct *field, picstruct *wfield, int wscale_flag)
{
backstruct
*
backmesh
,
*
wbackmesh
,
*
bm
,
*
wbm
;
tabstruct
*
tab
,
*
wtab
;
PIXTYPE
*
buf
,
*
wbuf
,
*
buft
,
*
wbuft
;
OFF_T
fcurpos
,
wfcurpos
,
wfcurpos2
,
fcurpos2
,
bufshift
,
jumpsize
;
OFF_T2
fcurpos
,
wfcurpos
,
wfcurpos2
,
fcurpos2
,
bufshift
,
jumpsize
;
OFF_T2
currentElement
,
wcurrentElement
,
currentElement2
,
wcurrentElement2
;
size_t
bufsize
,
bufsize2
,
size
,
meshsize
;
int
i
,
j
,
k
,
m
,
n
,
step
,
nlines
,
...
...
@@ -65,7 +67,11 @@ void makeback(picstruct *field, picstruct *wfield, int wscale_flag)
/* If the weight-map is not an external one, no stats are needed for it */
if
(
wfield
&&
wfield
->
flags
&
(
INTERP_FIELD
|
BACKRMS_FIELD
))
wfield
=
NULL
;
tab
=
field
->
tab
;
if
(
wfield
)
wtab
=
wfield
->
tab
;
else
wtab
=
NULL
;
/* to avoid gcc -Wall warnings */
w
=
field
->
width
;
bw
=
field
->
backw
;
bh
=
field
->
backh
;
...
...
@@ -83,12 +89,20 @@ void makeback(picstruct *field, picstruct *wfield, int wscale_flag)
wfcurpos
=
wfcurpos2
=
0
;
/* to avoid gcc -Wall warnings */
QFTELL
(
field
->
file
,
fcurpos
,
field
->
filename
);
if
(
wfield
)
#ifdef HAVE_CFITSIO
currentElement
=
(
tab
->
currentElement
==
0
)
?
1
:
tab
->
currentElement
;
#endif
if
(
wfield
)
{
QFTELL
(
wfield
->
file
,
wfcurpos
,
wfield
->
filename
);
#ifdef HAVE_CFITSIO
wcurrentElement
=
(
wtab
->
currentElement
==
0
)
?
1
:
wtab
->
currentElement
;
#endif
}
/* Allocate a correct amount of memory to store pixels */
bufsize
=
(
OFF_T
)
w
*
bh
;
bufsize
=
(
OFF_T
2
)
w
*
bh
;
meshsize
=
(
size_t
)
bufsize
;
nlines
=
0
;
if
(
bufsize
>
(
size_t
)
BACK_BUFSIZE
)
...
...
@@ -96,8 +110,8 @@ void makeback(picstruct *field, picstruct *wfield, int wscale_flag)
nlines
=
BACK_BUFSIZE
/
w
;
step
=
(
field
->
backh
-
1
)
/
nlines
+
1
;
bufsize
=
(
size_t
)(
nlines
=
field
->
backh
/
step
)
*
w
;
bufshift
=
(
step
/
2
)
*
(
OFF_T
)
w
;
jumpsize
=
(
step
-
1
)
*
(
OFF_T
)
w
;
bufshift
=
(
step
/
2
)
*
(
OFF_T
2
)
w
;
jumpsize
=
(
step
-
1
)
*
(
OFF_T
2
)
w
;
}
else
bufshift
=
jumpsize
=
0
;
/* to avoid gcc -Wall warnings */
...
...
@@ -172,16 +186,23 @@ void makeback(picstruct *field, picstruct *wfield, int wscale_flag)
{
/*---- Image size too big, we have to skip a few data !*/
QFTELL
(
field
->
file
,
fcurpos2
,
field
->
filename
);
if
(
wfield
)
#ifdef HAVE_CFITSIO
currentElement2
=
(
tab
->
currentElement
==
0
)
?
1
:
tab
->
currentElement
;
#endif
if
(
wfield
){
QFTELL
(
wfield
->
file
,
wfcurpos2
,
wfield
->
filename
);
#ifdef HAVE_CFITSIO
wcurrentElement2
=
(
wtab
->
currentElement
==
0
)
?
1
:
wtab
->
currentElement
;
#endif
}
if
(
j
==
ny
-
1
&&
(
n
=
field
->
height
%
field
->
backh
))
{
meshsize
=
n
*
(
size_t
)
w
;
nlines
=
BACK_BUFSIZE
/
w
;
step
=
(
n
-
1
)
/
nlines
+
1
;
bufsize
=
(
nlines
=
n
/
step
)
*
(
size_t
)
w
;
bufshift
=
(
step
/
2
)
*
(
OFF_T
)
w
;
jumpsize
=
(
step
-
1
)
*
(
OFF_T
)
w
;
bufshift
=
(
step
/
2
)
*
(
OFF_T
2
)
w
;
jumpsize
=
(
step
-
1
)
*
(
OFF_T
2
)
w
;
free
(
buf
);
QMALLOC
(
buf
,
PIXTYPE
,
bufsize
);
/* pixel buffer */
if
(
wfield
)
...
...
@@ -192,35 +213,52 @@ void makeback(picstruct *field, picstruct *wfield, int wscale_flag)
}
/*---- Read and skip, read and skip, etc... */
QFSEEK
(
field
->
file
,
bufshift
*
(
OFF_T
)
field
->
bytepix
,
SEEK_CUR
,
QFSEEK
(
field
->
file
,
bufshift
*
(
OFF_T
2
)
field
->
bytepix
,
SEEK_CUR
,
field
->
filename
);
#ifdef HAVE_CFITSIO
tab
->
currentElement
+=
bufshift
;
#endif
buft
=
buf
;
for
(
i
=
nlines
;
i
--
;
buft
+=
w
)
{
read_body
(
field
->
tab
,
buft
,
w
);
if
(
i
)
QFSEEK
(
field
->
file
,
jumpsize
*
(
OFF_T
)
field
->
bytepix
,
SEEK_CUR
,
if
(
i
)
{
QFSEEK
(
field
->
file
,
jumpsize
*
(
OFF_T
2
)
field
->
bytepix
,
SEEK_CUR
,
field
->
filename
);
#ifdef HAVE_CFITSIO
tab
->
currentElement
+=
jumpsize
;
#endif
}
}
if
(
wfield
)
{
/*------ Read and skip, read and skip, etc... now on the weight-map */
QFSEEK
(
wfield
->
file
,
bufshift
*
(
OFF_T
)
wfield
->
bytepix
,
SEEK_CUR
,
QFSEEK
(
wfield
->
file
,
bufshift
*
(
OFF_T
2
)
wfield
->
bytepix
,
SEEK_CUR
,
wfield
->
filename
);
#ifdef HAVE_CFITSIO
wtab
->
currentElement
+=
bufshift
;
#endif
wbuft
=
wbuf
;
for
(
i
=
nlines
;
i
--
;
wbuft
+=
w
)
{
read_body
(
wfield
->
tab
,
wbuft
,
w
);
weight_to_var
(
wfield
,
wbuft
,
w
);
if
(
i
)
QFSEEK
(
wfield
->
file
,
jumpsize
*
(
OFF_T
)
wfield
->
bytepix
,
SEEK_CUR
,
if
(
i
)
{
QFSEEK
(
wfield
->
file
,
jumpsize
*
(
OFF_T
2
)
wfield
->
bytepix
,
SEEK_CUR
,
wfield
->
filename
);
#ifdef HAVE_CFITSIO
wtab
->
currentElement
+=
jumpsize
;
#endif
}
}
}
backstat
(
backmesh
,
wbackmesh
,
buf
,
wbuf
,
bufsize
,
nx
,
w
,
bw
,
wfield
?
wfield
->
weight_thresh
:
0
.
0
);
QFSEEK
(
field
->
file
,
fcurpos2
,
SEEK_SET
,
field
->
filename
);
#ifdef HAVE_CFITSIO
tab
->
currentElement
=
currentElement2
;
#endif
bm
=
backmesh
;
for
(
m
=
nx
;
m
--
;
bm
++
)
if
(
bm
->
mean
<=
-
BIG
)
...
...
@@ -230,6 +268,9 @@ void makeback(picstruct *field, picstruct *wfield, int wscale_flag)
if
(
wfield
)
{
QFSEEK
(
wfield
->
file
,
wfcurpos2
,
SEEK_SET
,
wfield
->
filename
);
#ifdef HAVE_CFITSIO
wtab
->
currentElement
=
wcurrentElement2
;
#endif
wbm
=
wbackmesh
;
for
(
m
=
nx
;
m
--
;
wbm
++
)
if
(
wbm
->
mean
<=
-
BIG
)
...
...
@@ -284,8 +325,15 @@ void makeback(picstruct *field, picstruct *wfield, int wscale_flag)
/* Go back to the original position */
QFSEEK
(
field
->
file
,
fcurpos
,
SEEK_SET
,
field
->
filename
);
if
(
wfield
)
#ifdef HAVE_CFITSIO
tab
->
currentElement
=
currentElement
;
#endif
if
(
wfield
)
{
QFSEEK
(
wfield
->
file
,
wfcurpos
,
SEEK_SET
,
wfield
->
filename
);
#ifdef HAVE_CFITSIO
wfield
->
tab
->
currentElement
=
wcurrentElement
;
#endif
}
/* Median-filter and check suitability of the background map */
NFPRINTF
(
OUTPUT
,
"Filtering background map(s)"
);
...
...
@@ -625,7 +673,7 @@ float backguess(backstruct *bkg, float *mean, float *sigma)
{
LONG
*
histo
,
*
hilow
,
*
hihigh
,
*
histot
;
unsigned
long
lowsum
,
highsum
,
sum
;
double
ftemp
,
mea
,
sig
,
sig1
,
med
,
dpix
;
double
ftemp
,
mea
,
meafac
,
sig
,
sig1
,
med
,
medfac
,
dpix
;
int
i
,
n
,
lcut
,
hcut
,
nlevelsm1
,
pix
;
/* Leave here if the mesh is already classified as `bad' */
...
...
@@ -641,6 +689,8 @@ float backguess(backstruct *bkg, float *mean, float *sigma)
sig
=
10
.
0
*
nlevelsm1
;
sig1
=
1
.
0
;
medfac
=
prefs
.
back_pearson
;
meafac
=
prefs
.
back_pearson
-
1
.
0
;
mea
=
med
=
bkg
->
mean
;
for
(
n
=
100
;
n
--
&&
(
sig
>=
0
.
1
)
&&
(
fabs
(
sig
/
sig1
-
1
.
0
)
>
EPS
);)
{
...
...
@@ -677,7 +727,7 @@ float backguess(backstruct *bkg, float *mean, float *sigma)
*
mean
=
fabs
(
sig
)
>
0
.
0
?
(
fabs
(
bkg
->
sigma
/
(
sig
*
bkg
->
qscale
)
-
1
)
<
0
.
0
?
bkg
->
qzero
+
mea
*
bkg
->
qscale
:
(
fabs
((
mea
-
med
)
/
sig
)
<
0
.
3
?
bkg
->
qzero
+
(
2
.
5
*
med
-
1
.
5
*
mea
)
*
bkg
->
qscale
bkg
->
qzero
+
(
medfac
*
med
-
meafac
*
mea
)
*
bkg
->
qscale
:
bkg
->
qzero
+
med
*
bkg
->
qscale
))
:
bkg
->
qzero
+
mea
*
bkg
->
qscale
;
...
...
src/catout.c
View file @
08c0ebe3
...
...
@@ -7,7 +7,7 @@
*
* This file part of: SExtractor
*
* Copyright: (C) 1993-202
0
IAP/CNRS/SorbonneU
* Copyright: (C) 1993-202
3 CFHT/
IAP/CNRS/SorbonneU
*
* License: GNU General Public License
*
...
...
@@ -22,7 +22,7 @@
* You should have received a copy of the GNU General Public License
* along with SExtractor. If not, see <http://www.gnu.org/licenses/>.
*
* Last modified:
15
/0
7
/202
0
* Last modified:
26
/0
2
/202
3
*
*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
...
...
@@ -1059,7 +1059,7 @@ void reendcat()
{
keystruct
*
key
;
tabstruct
*
tab
;
OFF_T
pos
;
OFF_T
2
pos
;
char
*
head
;
switch
(
prefs
.
cat_type
)
...
...
@@ -1086,6 +1086,7 @@ void reendcat()
QFTELL
(
fitscat
->
file
,
pos
,
fitscat
->
filename
);
QFSEEK
(
fitscat
->
file
,
tab
->
headpos
,
SEEK_SET
,
fitscat
->
filename
);
save_tab
(
fitscat
,
tab
);
remove_tab
(
fitscat
,
"LDAC_IMHEAD"
,
0
);
QFSEEK
(
fitscat
->
file
,
pos
,
SEEK_SET
,
fitscat
->
filename
);
break
;
...
...
@@ -1127,4 +1128,3 @@ void zerocat(void)
}
src/check.c
View file @
08c0ebe3
...
...
@@ -7,7 +7,7 @@
*
* This file part of: SExtractor
*
* Copyright: (C) 1993-20
1
3
Emmanuel Bertin -- IAP/CNRS/UPMC
* Copyright: (C) 1993-20
2
3
CFHT/IAP/CNRS/SorbonneU
*
* License: GNU General Public License
*
...
...
@@ -22,7 +22,7 @@
* You should have received a copy of the GNU General Public License
* along with SExtractor. If not, see <http://www.gnu.org/licenses/>.
*
* Last modified: 2
3
/0
9
/20
1
3
* Last modified: 2
5
/0
2
/20
2
3
*
*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
...
...
@@ -406,6 +406,7 @@ void reinitcheck(picstruct *field, checkstruct *check)
remove_tabs
(
cat
);
copy_tab_fromptr
(
field
->
tab
,
cat
,
0
);
tab
=
cat
->
tab
;
decomp_head
(
tab
);
tab
->
cat
=
cat
;
if
(
check
->
next
<=
1
)
prim_head
(
tab
);
...
...
src/define.h
View file @
08c0ebe3
...
...
@@ -7,7 +7,7 @@
*
* This file part of: SExtractor
*
* Copyright: (C) 1993-20
15
Emmanuel Bertin -- IAP/CNRS/
UPMC
* Copyright: (C) 1993-20
22
Emmanuel Bertin -- IAP/CNRS/
SorbonneU
*
* License: GNU General Public License
*
...
...
@@ -22,7 +22,7 @@
* You should have received a copy of the GNU General Public License
* along with SExtractor. If not, see <http://www.gnu.org/licenses/>.
*
* Last modified:
11
/0
3
/20
15
* Last modified:
07
/0
9
/20
22
*
*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
...
...
@@ -167,7 +167,7 @@
#define QCALLOC(ptr, typ, nel) \
{if (!(ptr = (typ *)calloc((size_t)(nel),sizeof(typ)))) \
{ \
sprintf(gstr, #ptr " (" #nel "=%
ll
d elements) " \
sprintf(gstr, #ptr " (" #nel "=%
z
d elements) " \
"at line %d in module " __FILE__ " !", \
(size_t)(nel)*sizeof(typ), __LINE__); \
error(EXIT_FAILURE, "Could not allocate memory for ", gstr);\
...
...
@@ -177,7 +177,7 @@
#define QMALLOC(ptr, typ, nel) \
{if (!(ptr = (typ *)malloc((size_t)(nel)*sizeof(typ)))) \
{ \
sprintf(gstr, #ptr " (" #nel "=%
ll
d elements) " \
sprintf(gstr, #ptr " (" #nel "=%
z
d elements) " \
"at line %d in module " __FILE__ " !", \
(size_t)(nel)*sizeof(typ), __LINE__); \
error(EXIT_FAILURE, "Could not allocate memory for ", gstr);\
...
...
@@ -187,7 +187,7 @@
#define QMALLOC16(ptr, typ, nel) \
{if (posix_memalign((void **)&ptr, 16, (size_t)(nel)*sizeof(typ))) \
{ \
sprintf(gstr, #ptr " (" #nel "=%
ll
d elements) " \
sprintf(gstr, #ptr " (" #nel "=%
z
d elements) " \
"at line %d in module " __FILE__ " !", \
(size_t)(nel)*sizeof(typ), __LINE__); \
error(EXIT_FAILURE, "Could not allocate memory for ", gstr);\
...
...
@@ -197,7 +197,7 @@
#define QREALLOC(ptr, typ, nel) \
{if (!(ptr = (typ *)realloc(ptr, (size_t)(nel)*sizeof(typ))))\
{ \
sprintf(gstr, #ptr " (" #nel "=%
ll
d elements) " \
sprintf(gstr, #ptr " (" #nel "=%
z
d elements) " \
"at line %d in module " __FILE__ " !", \
(size_t)(nel)*sizeof(typ), __LINE__); \
error(EXIT_FAILURE, "Could not allocate memory for ", gstr);\
...
...
@@ -208,7 +208,7 @@
{if (ptrin) \
{if (!(ptrout = (typ *)malloc((size_t)(nel)*sizeof(typ)))) \
{ \
sprintf(gstr, #ptrout " (" #nel "=%
ll
d elements) " \
sprintf(gstr, #ptrout " (" #nel "=%
z
d elements) " \
"at line %d in module " __FILE__ " !", \
(size_t)(nel)*sizeof(typ), __LINE__); \
error(EXIT_FAILURE,"Could not allocate memory for ",gstr);\
...
...
src/fft.h
View file @
08c0ebe3
...
...
@@ -7,7 +7,7 @@
*
* This file part of: SExtractor
*
* Copyright: (C) 2007-20
17
IAP/CNRS/
UPMC
* Copyright: (C) 2007-20
22
IAP/CNRS/
SorbonneU
*
* License: GNU General Public License
*
...
...
@@ -22,7 +22,7 @@
* You should have received a copy of the GNU General Public License
* along with SExtractor. If not, see <http://www.gnu.org/licenses/>.
*
* Last modified:
19
/0
6
/20
17
* Last modified:
07
/0
9
/20
22
*
*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
...
...
@@ -40,7 +40,7 @@
#define QFFTWF_MALLOC(ptr, typ, nel) \
{if (!(ptr = (typ *)fftwf_malloc((size_t)(nel)*sizeof(typ)))) \
{ \
sprintf(gstr, #ptr " (" #nel "=%
ll
d elements) " \
sprintf(gstr, #ptr " (" #nel "=%
z
d elements) " \
"at line %d in module " __FILE__ " !", \
(size_t)(nel)*sizeof(typ), __LINE__); \
error(EXIT_FAILURE, "Could not allocate memory for ", gstr);\
...
...
src/field.c
View file @
08c0ebe3
...
...
@@ -7,7 +7,7 @@
*
* This file part of: SExtractor
*
* Copyright: (C) 1993-20
12 Emmanuel Bertin -- IAP/CNRS/UPMC
* Copyright: (C) 1993-20
23 CFHT/IAP/CNRS/SorbonneU
*
* License: GNU General Public License
*
...
...
@@ -22,7 +22,7 @@
* You should have received a copy of the GNU General Public License
* along with SExtractor. If not, see <http://www.gnu.org/licenses/>.
*
* Last modified:
1
2/0
7
/20
1
2
* Last modified: 2
5
/0
2
/202
3
*
*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
...
...
@@ -70,21 +70,41 @@ picstruct *newfield(char *filename, int flags, int ext)
field
->
cat
=
cat
;
nok
=
0
;
tab
=
cat
->
tab
;
#ifdef HAVE_CFITSIO
if
((
tab
->
isTileCompressed
)
||
(
tab
->
naxis
>=
2
&&
strncmp
(
tab
->
xtension
,
"BINTABLE"
,
8
)
&&
strncmp
(
tab
->
xtension
,
"ASCTABLE"
,
8
)))
#else
if
(
tab
->
isTileCompressed
)
warning
(
BANNER
" has been compiled without CFITSIO support: "
"compressed image skipped in "
,
filename
);
if
(
tab
->
naxis
>=
2
&&
strncmp
(
tab
->
xtension
,
"BINTABLE"
,
8
)
&&
strncmp
(
tab
->
xtension
,
"ASCTABLE"
,
8
))
#endif
nok
++
;
ext2
=
ext
;
for
(
ntab
=
cat
->
ntab
;
ext2
--
&&
ntab
--
;)
{
tab
=
tab
->
nexttab
;
#ifdef HAVE_CFITSIO
if
((
tab
->
isTileCompressed
)
||
(
tab
->
naxis
>=
2
&&
strncmp
(
tab
->
xtension
,
"BINTABLE"
,
8
)
&&
strncmp
(
tab
->
xtension
,
"ASCTABLE"
,
8
)))
#else
if
(
tab
->
isTileCompressed
)
warning
(
BANNER
" has been compiled without CFITSIO support: "
"compressed image skipped in "
,
filename
);
if
(
tab
->
naxis
>=
2
&&
strncmp
(
tab
->
xtension
,
"BINTABLE"
,
8
)
&&
strncmp
(
tab
->
xtension
,
"ASCTABLE"
,
8
))
&&
strncmp
(
tab
->
xtension
,
"BINTABLE"
,
8
)
&&
strncmp
(
tab
->
xtension
,
"ASCTABLE"
,
8
))
#endif
nok
++
;
}
if
(
!
nok
)
error
(
EXIT_FAILURE
,
"Not a valid FITS image in "
,
filename
);
error
(
EXIT_FAILURE
,
"Not a valid FITS image in "
,
filename
);
field
->
tab
=
tab
;
if
(
ntab
<
0
)
...
...
src/fits/fitsbody.c
View file @
08c0ebe3
...
...
@@ -7,7 +7,7 @@
*
* This file part of: AstrOmatic FITS/LDAC library
*
* Copyright: (C) 1995-20
10
IAP/CNRS/SorbonneU
* Copyright: (C) 1995-20
23 CFHT/
IAP/CNRS/SorbonneU
*
* License: GNU General Public License
*
...
...
@@ -23,7 +23,7 @@
* along with AstrOmatic software.
* If not, see <http://www.gnu.org/licenses/>.
*
* Last modified:
11
/02/202
0
* Last modified:
25
/02/202
3
*
*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
...
...
@@ -43,6 +43,10 @@
#include
"fitscat_defs.h"
#include
"fitscat.h"
#ifdef HAVE_CFITSIO
#include CFITSIO_H
#endif
size_t
body_maxram
=
BODY_DEFRAM
,
body_maxvram
=
BODY_DEFVRAM
,
body_ramleft
,
body_vramleft
,
body_ramflag
;
...
...
@@ -60,7 +64,7 @@ INPUT Table (tab) structure.
OUTPUT Pointer to the mapped data if OK, or NULL otherwise.
NOTES The file pointer must be positioned at the beginning of the data.
AUTHOR E. Bertin (IAP)
VERSION 0
5/05
/20
0
1
VERSION 0
2/10
/201
7
***/
PIXTYPE
*
alloc_body
(
tabstruct
*
tab
,
void
(
*
func
)(
PIXTYPE
*
ptr
,
int
npix
))
{
...
...
@@ -85,7 +89,11 @@ PIXTYPE *alloc_body(tabstruct *tab, void (*func)(PIXTYPE *ptr, int npix))
tab
->
extname
);
/* Decide if the data will go in physical memory or on swap-space */
#ifdef HAVE_CFITSIO
npix
=
tab
->
naxisn
[
0
]
*
tab
->
naxisn
[
1
];
#else
npix
=
tab
->
tabsize
/
tab
->
bytepix
;
#endif
size
=
npix
*
sizeof
(
PIXTYPE
);
if
(
size
<
body_ramleft
)
{
...
...
@@ -93,6 +101,9 @@ PIXTYPE *alloc_body(tabstruct *tab, void (*func)(PIXTYPE *ptr, int npix))
if
((
tab
->
bodybuf
=
malloc
(
size
)))
{
QFSEEK
(
tab
->
cat
->
file
,
tab
->
bodypos
,
SEEK_SET
,
tab
->
cat
->
filename
);
#ifdef HAVE_CFITSIO
tab
->
currentElement
=
1
;
#endif
read_body
(
tab
,
(
PIXTYPE
*
)
tab
->
bodybuf
,
npix
);
/*---- Apply pixel processing */
if
(
func
)
...
...
@@ -120,6 +131,9 @@ PIXTYPE *alloc_body(tabstruct *tab, void (*func)(PIXTYPE *ptr, int npix))
if
(
!
spoonful
)
spoonful
=
DATA_BUFSIZE
;
QFSEEK
(
tab
->
cat
->
file
,
tab
->
bodypos
,
SEEK_SET
,
tab
->
cat
->
filename
);
#ifdef HAVE_CFITSIO
tab
->
currentElement
=
1
;
#endif
read_body
(
tab
,
buffer
,
spoonful
/
sizeof
(
PIXTYPE
));
/*-- Apply pixel processing */
if
(
func
)
...
...
@@ -159,7 +173,7 @@ INPUT Table (tab) structure.
OUTPUT Pointer to the mapped data if OK, or NULL otherwise.
NOTES The file pointer must be positioned at the beginning of the data.
AUTHOR E. Bertin (IAP)
VERSION
30/01
/201
2
VERSION
02/10
/201
7
***/
FLAGTYPE
*
alloc_ibody
(
tabstruct
*
tab
,
void
(
*
func
)(
FLAGTYPE
*
ptr
,
int
npix
))
...
...
@@ -193,6 +207,9 @@ FLAGTYPE *alloc_ibody(tabstruct *tab,
if
((
tab
->
bodybuf
=
malloc
(
size
)))
{
QFSEEK
(
tab
->
cat
->
file
,
tab
->
bodypos
,
SEEK_SET
,
tab
->
cat
->
filename
);
#ifdef HAVE_CFITSIO
tab
->
currentElement
=
1
;
#endif
read_ibody
(
tab
,
(
FLAGTYPE
*
)
tab
->
bodybuf
,
npix
);
/*---- Apply pixel processing */
if
(
func
)
...
...
@@ -220,6 +237,9 @@ FLAGTYPE *alloc_ibody(tabstruct *tab,
if
(
!
spoonful
)
spoonful
=
DATA_BUFSIZE
;
QFSEEK
(
tab
->
cat
->
file
,
tab
->
bodypos
,
SEEK_SET
,
tab
->
cat
->
filename
);
#ifdef HAVE_CFITSIO
tab
->
currentElement
=
1
;
#endif
read_ibody
(
tab
,
buffer
,
spoonful
/
sizeof
(
FLAGTYPE
));
/*-- Apply pixel processing */
if
(
func
)
...
...
@@ -294,6 +314,77 @@ void free_body(tabstruct *tab)
return
;
}
#ifdef HAVE_CFITSIO
/******* readTileCompressed ***************************************************
*
* Function to read a chunk of a tile-compressed FITS image
*
***/
void
readTileCompressed
(
tabstruct
*
tab
,
size_t
spoonful
,
void
*
bufdata0
)
{
int
status
,
hdutype
;
// first of all, move to correct HDU
status
=
0
;
fits_movabs_hdu
(
tab
->
infptr
,
tab
->
hdunum
,
&
hdutype
,
&
status
);
if
(
status
!=
0
)
{
printf
(
"Error moving to HDU %d
\n
"
,
tab
->
hdunum
);
fits_report_error
(
stderr
,
status
);
}
// pixels count from 1
if
(
!
tab
->
currentElement
)
tab
->
currentElement
=
1
;
// now read section of image
int
datatype
;
switch
(
tab
->
bitpix
){
case
BYTE_IMG
:
datatype
=
TBYTE
;
break
;
case
SHORT_IMG
:
datatype
=
TSHORT
;
break
;
case
LONG_IMG
:
datatype
=
TLONG
;
break
;
case
FLOAT_IMG
:
datatype
=
TFLOAT
;
break
;
case
DOUBLE_IMG
:
datatype
=
TDOUBLE
;
break
;
default:
datatype
=
TFLOAT
;
break
;
}
int
anynul
;
double
bscale
=
1
.
0
,
bzero
=
0
.
0
,
nulval
=
0
.;
// turn off any scaling so that we copy raw pixel values
status
=
0
;
fits_set_bscale
(
tab
->
infptr
,
bscale
,
bzero
,
&
status
);
// now read the image
status
=
0
;
fits_read_img
(
tab
->
infptr
,
datatype
,
tab
->
currentElement
,
spoonful
,
&
nulval
,
bufdata0
,
&
anynul
,
&
status
);
// report reading error
if
(
status
)
{
printf
(
"CFITSIO ERROR reading start=%d end=%d absolute end=%d
\n
"
,
tab
->
currentElement
,
(
tab
->
currentElement
+
spoonful
),
(
tab
->
naxisn
[
0
]
*
tab
->
naxisn
[
1
]));
fits_report_error
(
stderr
,
status
);
}
// update file 'pointer'
tab
->
currentElement
+=
spoonful
;
}
#endif // HAVE_CFITSIO
/******* read_body ************************************************************
PROTO read_body(tabstruct *tab, PIXTYPE *ptr, long size)
...
...
@@ -303,8 +394,8 @@ INPUT A pointer to the tab structure,
the number of elements to be read.
OUTPUT -.
NOTES .
AUTHOR E. Bertin (
IAP
)
VERSION
11
/02/202
0
AUTHOR E. Bertin (
CFHT/IAP/CNRS/SorbonneU
)
VERSION
25
/02/202
3
***/
void
read_body
(
tabstruct
*
tab
,
PIXTYPE
*
ptr
,
size_t
size
)
{
...
...
@@ -323,15 +414,15 @@ void read_body(tabstruct *tab, PIXTYPE *ptr, size_t size)
int
curval
,
dval
,
blankflag
,
bswapflag
,
ival
,
iblank
;
size_t
i
,
bowl
,
spoonful
,
npix
;
PIXTYPE
bs
,
bz
;
double
bs
,
bz
;
/* a NULL cat structure indicates that no data can be read */
if
(
!
(
cat
=
tab
->
cat
))
return
;
bs
=
(
PIXTYPE
)
tab
->
bscale
;
bz
=
(
PIXTYPE
)
tab
->
bzero
;
bs
=
tab
->
bscale
;
bz
=
tab
->
bzero
;
blankflag
=
tab
->
blankflag
;
bswapflag
=
*
((
char
*
)
&
ashort
);
// Byte-swapping flag
...
...
@@ -346,7 +437,15 @@ void read_body(tabstruct *tab, PIXTYPE *ptr, size_t size)
if
(
spoonful
>
size
)
spoonful
=
size
;
bufdata
=
(
char
*
)
bufdata0
;
#ifdef HAVE_CFITSIO
if
(
tab
->
isTileCompressed
&&
tab
->
infptr
)
readTileCompressed
(
tab
,
spoonful
,
(
void
*
)
bufdata0
);
else
QFREAD
(
bufdata
,
spoonful
*
tab
->
bytepix
,
cat
->
file
,
cat
->
filename
);
#else
QFREAD
(
bufdata
,
spoonful
*
tab
->
bytepix
,
cat
->
file
,
cat
->
filename
);
#endif // HAVE_CFITSIO
switch
(
tab
->
bitpix
)
{
case
BP_BYTE
:
...
...
@@ -383,7 +482,11 @@ void read_body(tabstruct *tab, PIXTYPE *ptr, size_t size)
break
;
case
BP_SHORT
:
#ifdef HAVE_CFITSIO
if
(
!
tab
->
isTileCompressed
&&
bswapflag
)
#else
if
(
bswapflag
)
#endif
swapbytes
(
bufdata
,
2
,
spoonful
);
if
(
blankflag
)
{
...
...
@@ -418,7 +521,11 @@ void read_body(tabstruct *tab, PIXTYPE *ptr, size_t size)
break
;
case
BP_LONG
:
#ifdef HAVE_CFITSIO
if
(
!
tab
->
isTileCompressed
&&
bswapflag
)
#else
if
(
bswapflag
)
#endif
swapbytes
(
bufdata
,
4
,
spoonful
);
if
(
blankflag
)
{
...
...
@@ -454,7 +561,11 @@ void read_body(tabstruct *tab, PIXTYPE *ptr, size_t size)
#ifdef HAVE_LONG_LONG_INT
case
BP_LONGLONG
:
#ifdef HAVE_CFITSIO
if
(
!
tab
->
isTileCompressed
&&
bswapflag
)
#else
if
(
bswapflag
)
#endif
swapbytes
(
bufdata
,
8
,
spoonful
);
if
(
blankflag
)
{
...
...
@@ -489,7 +600,11 @@ void read_body(tabstruct *tab, PIXTYPE *ptr, size_t size)
break
;
#endif
case
BP_FLOAT
:
#ifdef HAVE_CFITSIO
if
(
!
tab
->
isTileCompressed
&&
bswapflag
)
#else
if
(
bswapflag
)
#endif
swapbytes
(
bufdata
,
4
,
spoonful
);
#pragma ivdep
for
(
i
=
spoonful
;
i
--
;
bufdata
+=
sizeof
(
float
))
...
...
@@ -499,7 +614,12 @@ void read_body(tabstruct *tab, PIXTYPE *ptr, size_t size)
case
BP_DOUBLE
:
if
(
bswapflag
)
{
#ifdef HAVE_CFITSIO
if
(
!
tab
->
isTileCompressed
)
swapbytes
(
bufdata
,
8
,
spoonful
);
#else
swapbytes
(
bufdata
,
8
,
spoonful
);
#endif
#pragma ivdep
for
(
i
=
spoonful
;
i
--
;
bufdata
+=
sizeof
(
double
))
*
(
ptr
++
)
=
((
0x7ff00000
&
*
(
unsigned
int
*
)(
bufdata
+
4
))
...
...
@@ -632,7 +752,7 @@ INPUT A pointer to the tab structure,
OUTPUT -.
NOTES .
AUTHOR E. Bertin (IAP)
VERSION
11
/0
2
/2020
VERSION
26
/0
8
/2020
***/
void
read_ibody
(
tabstruct
*
tab
,
FLAGTYPE
*
ptr
,
size_t
size
)
{
...
...
@@ -660,7 +780,15 @@ void read_ibody(tabstruct *tab, FLAGTYPE *ptr, size_t size)
if
(
spoonful
>
size
)
spoonful
=
size
;
bufdata
=
(
char
*
)
bufdata0
;
#ifdef HAVE_CFITSIO
if
(
tab
->
isTileCompressed
)
readTileCompressed
(
tab
,
spoonful
,
(
void
*
)
bufdata0
);
else
QFREAD
(
bufdata
,
spoonful
*
tab
->
bytepix
,
cat
->
file
,
cat
->
filename
);
#else
QFREAD
(
bufdata
,
spoonful
*
tab
->
bytepix
,
cat
->
file
,
cat
->
filename
);
#endif
switch
(
tab
->
bitpix
)
{
case
BP_BYTE
:
...
...
@@ -670,7 +798,11 @@ void read_ibody(tabstruct *tab, FLAGTYPE *ptr, size_t size)
break
;
case
BP_SHORT
:
#ifdef HAVE_CFITSIO
if
(
!
tab
->
isTileCompressed
&&
bswapflag
)
#else
if
(
bswapflag
)
#endif
swapbytes
(
bufdata
,
2
,
spoonful
);
#pragma ivdep
for
(
i
=
spoonful
;
i
--
;
bufdata
+=
sizeof
(
unsigned
short
))
...
...
@@ -678,7 +810,11 @@ void read_ibody(tabstruct *tab, FLAGTYPE *ptr, size_t size)
break
;
case
BP_LONG
:
#ifdef HAVE_CFITSIO
if
(
!
tab
->
isTileCompressed
&&
bswapflag
)
#else
if
(
bswapflag
)
#endif
swapbytes
(
bufdata
,
4
,
spoonful
);
#pragma ivdep
for
(
i
=
spoonful
;
i
--
;
bufdata
+=
sizeof
(
unsigned
int
))
...
...
@@ -687,7 +823,11 @@ void read_ibody(tabstruct *tab, FLAGTYPE *ptr, size_t size)
#ifdef HAVE_LONG_LONG_INT
case
BP_LONGLONG
:
#ifdef HAVE_CFITSIO
if
(
!
tab
->
isTileCompressed
&&
bswapflag
)
#else
if
(
bswapflag
)
#endif
swapbytes
(
bufdata
,
8
,
spoonful
);
#pragma ivdep
for
(
i
=
spoonful
;
i
--
;
bufdata
+=
sizeof
(
ULONGLONG
))
...
...
@@ -815,7 +955,7 @@ INPUT A pointer to the tab structure,
OUTPUT -.
NOTES .
AUTHOR E. Bertin (IAP)
VERSION
11
/0
2
/2020
VERSION
26
/0
8
/2020
***/
void
write_body
(
tabstruct
*
tab
,
PIXTYPE
*
ptr
,
size_t
size
)
{
...
...
@@ -931,7 +1071,12 @@ void write_body(tabstruct *tab, PIXTYPE *ptr, size_t size)
#pragma ivdep
for
(
i
=
spoonful
;
i
--
;)
*
(
bufdata
++
)
=
(
*
(
ptr
++
)
-
bz
)
/
bs
;
#ifdef HAVE_CFITSIO
if
(
!
tab
->
infptr
&&
bswapflag
)
#else
if
(
bswapflag
)
#endif
swapbytes
(
cbufdata0
,
4
,
spoonful
);
}
break
;
...
...
@@ -952,7 +1097,61 @@ void write_body(tabstruct *tab, PIXTYPE *ptr, size_t size)
"read_body()"
);
break
;
}
#ifdef HAVE_CFITSIO
// if cfitsio output file has been set up, then proceed to write
if
(
tab
->
infptr
)
{
// now read section of image
int
datatype
;
switch
(
tab
->
bitpix
)
{
case
BYTE_IMG
:
datatype
=
TBYTE
;
break
;
case
SHORT_IMG
:
datatype
=
TSHORT
;
break
;
case
LONG_IMG
:
datatype
=
TLONG
;
break
;
case
FLOAT_IMG
:
datatype
=
TFLOAT
;
break
;
case
DOUBLE_IMG
:
datatype
=
TDOUBLE
;
break
;
default:
datatype
=
TFLOAT
;
break
;
}
// turn off any scaling so that we copy the raw pixel values
double
*
array
,
bscale
=
1
.
0
,
bzero
=
0
.
0
,
nulval
=
0
.
0
;
int
status
=
0
;
fits_set_bscale
(
tab
->
infptr
,
bscale
,
bzero
,
&
status
);
status
=
0
;
fits_write_img
(
tab
->
infptr
,
datatype
,
tab
->
currentElement
,
spoonful
,
cbufdata0
,
&
status
);
if
(
status
)
{
printf
(
"CFITSIO ERROR writing start=%d end=%d absolute end=%d
\n
"
,
tab
->
currentElement
,
(
tab
->
currentElement
+
spoonful
),
(
tab
->
naxisn
[
0
]
*
tab
->
naxisn
[
1
]));
fits_report_error
(
stderr
,
status
);
}
tab
->
currentElement
=
tab
->
currentElement
+
spoonful
;
}
else
// otherwise, continue with usual AstrOmatic fits writing routine
QFWRITE
(
cbufdata0
,
spoonful
*
tab
->
bytepix
,
cat
->
file
,
cat
->
filename
);
#else
QFWRITE
(
cbufdata0
,
spoonful
*
tab
->
bytepix
,
cat
->
file
,
cat
->
filename
);
#endif // HAVE_CFITSIO
}
break
;
...
...
src/fits/fitscat.c
View file @
08c0ebe3
...
...
@@ -7,7 +7,7 @@
*
* This file part of: AstrOmatic FITS/LDAC library
*
* Copyright: (C) 1995-202
0
IAP/CNRS/SorbonneU
* Copyright: (C) 1995-202
3 CFHT/
IAP/CNRS/SorbonneU
*
* License: GNU General Public License
*
...
...
@@ -23,7 +23,7 @@
* along with AstrOmatic software.
* If not, see <http://www.gnu.org/licenses/>.
*
* Last modified:
1
5/0
7
/202
0
* Last modified:
2
5/0
2
/202
3
*
*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
...
...
@@ -42,6 +42,8 @@
#include
"fitscat_defs.h"
#include
"fitscat.h"
extern
float
*
fits_rand_value
;
char
fits_str
[
MAXCHAR
];
/****** about_cat **************************************************************
...
...
@@ -167,6 +169,37 @@ int close_cat(catstruct *cat)
return
RETURN_OK
;
}
#ifdef HAVE_CFITSIO
/****** close_cfitsio **********************************************************
PROTO int close_cfitsio(fitsfile **infptr)
PURPOSE Close a file previously opened by cfitsio
INPUT fitsfile structure.
OUTPUT RETURN_OK if everything went as expected (exit in error otherwise).
NOTES the fitsfile pointer is set to NULL;
AUTHOR E. Bertin (CFHT/IAP/CNRS/SorbonneU)
VERSION 25/02/2023
***/
int
close_cfitsio
(
catstruct
*
cat
)
{
if
((
cat
)
&&
(
cat
->
infptr
))
{
int
status
=
0
;
fits_close_file
(
cat
->
infptr
,
&
status
);
if
(
status
!=
0
)
{
fits_report_error
(
stderr
,
status
);
error
(
EXIT_FAILURE
,
"Could not close FITS file with cfitsio: "
,
cat
->
filename
);
}
else
{
// Successfully closed FITS file with cfitsio
cat
->
infptr
==
NULL
;
// Free random seed in CFITSIO.
QFREE
(
fits_rand_value
);
}
}
else
return
RETURN_ERROR
;
return
RETURN_OK
;
}
#endif // HAVE_CFITSIO
/****** free_cat ***************************************************************
PROTO void free_cat(catstruct **cat, int ncat)
...
...
@@ -175,8 +208,8 @@ INPUT Pointer to a catalog structure,
Number of catalogs.
OUTPUT -.
NOTES Unallocated pointers should have been put to NULL.
AUTHOR E. Bertin (
IAP & Leiden observatory
)
VERSION
0
5/
1
2/20
09
AUTHOR E. Bertin (
CFHT/IAP/CNRS/SorbonneU
)
VERSION
2
5/
0
2/20
23
***/
void
free_cat
(
catstruct
**
cat
,
int
ncat
)
...
...
@@ -191,6 +224,10 @@ void free_cat(catstruct **cat, int ncat)
if
((
*
thecat
)
->
file
)
close_cat
(
*
thecat
);
remove_tabs
(
*
thecat
);
#ifdef HAVE_CFITSIO
// Free resources allocated for CFITSIO
close_cfitsio
(
*
thecat
);
#endif
free
(
*
(
thecat
++
));
}
...
...
@@ -311,8 +348,8 @@ PURPOSE Explores the whole FITS file
INPUT catalog structure.
OUTPUT RETURN_OK if at least one table was found, RETURN_ERROR otherwise.
NOTES Memory space for the array of fits structures is reallocated.
AUTHOR E. Bertin (
IAP & Leiden observatory
)
VERSION
14/1
2/20
0
2
AUTHOR E. Bertin (
CFHT/IAP/CNRS/SorbonneU
)
VERSION
25/0
2/202
3
***/
int
map_cat
(
catstruct
*
cat
)
...
...
@@ -325,14 +362,38 @@ int map_cat(catstruct *cat)
QCALLOC
(
tab
,
tabstruct
,
1
);
tab
->
cat
=
cat
;
QFTELL
(
cat
->
file
,
tab
->
headpos
,
cat
->
filename
);
#ifdef HAVE_CFITSIO
fitsfile
*
infptr
;
int
status
,
hdutype
,
hdunum
=
1
;
#endif // HAVE_CFITSIO
for
(
ntab
=
0
;
!
get_head
(
tab
);
ntab
++
)
{
readbasic_head
(
tab
);
readbintabparam_head
(
tab
);
QFTELL
(
cat
->
file
,
tab
->
bodypos
,
cat
->
filename
);
tab
->
nseg
=
tab
->
seg
=
1
;
#ifdef HAVE_CFITSIO
if
(
tab
->
isTileCompressed
)
{
// Trigger CFITSIO file opening
status
=
0
;
if
(
!
cat
->
infptr
)
{
fits_open_file
(
&
cat
->
infptr
,
cat
->
filename
,
READONLY
,
&
status
);
if
(
status
!=
0
)
{
fits_report_error
(
stderr
,
status
);
error
(
EXIT_FAILURE
,
"Could not open FITS file with cfitsio: %s
\n
"
,
cat
->
filename
);
}
}
tab
->
infptr
=
cat
->
infptr
;
}
tab
->
hdunum
=
hdunum
++
;
#endif // HAVE_CFITSIO
if
(
tab
->
tabsize
)
QFSEEK
(
cat
->
file
,
PADTOTAL
(
tab
->
tabsize
),
SEEK_CUR
,
cat
->
filename
);
if
(
prevtab
)
{
tab
->
prevtab
=
prevtab
;
...
...
src/fits/fitscat.h
View file @
08c0ebe3
...
...
@@ -7,7 +7,7 @@
*
* This file part of: AstrOmatic FITS/LDAC library
*
* Copyright: (C) 1995-202
0
IAP/CNRS/SorbonneU
* Copyright: (C) 1995-202
3 CFHT/
IAP/CNRS/SorbonneU
*
* License: GNU General Public License
*
...
...
@@ -23,7 +23,7 @@
* along with AstrOmatic software.
* If not, see <http://www.gnu.org/licenses/>.
*
* Last modified:
11
/02/202
0
* Last modified:
25
/02/202
3
*
*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
...
...
@@ -36,6 +36,10 @@
#include
<sys/types.h>
#endif
#ifdef HAVE_CFITSIO
#include CFITSIO_H
#endif
#define MAXCHARS 256
/* max. number of characters */
#define WARNING_NMAX 1000
/* max. number of recorded warnings */
...
...
@@ -107,10 +111,11 @@ typedef long long SLONGLONG;
typedef
union
{
int
l
[
2
];}
SLONGLONG
;
#endif
#if defined(_FILE_OFFSET_BITS) && !defined(OFF_T)
#define OFF_T off_t
// CFITSIO changed OFF_T to OFF_T2 due to clash with cfitsio lib
#if defined(_FILE_OFFSET_BITS) && !defined(OFF_T2)
#define OFF_T2 off_t
#else
#define OFF_T long
#define OFF_T
2
long
#endif
/*------------------------------- constants ---------------------------------*/
...
...
@@ -150,6 +155,9 @@ typedef struct structcat
struct
structtab
*
tab
;
/* pointer to the first table */
int
ntab
;
/* number of tables included */
access_type_t
access_type
;
/* READ_ONLY or WRITE_ONLY */
#ifdef HAVE_CFITSIO
fitsfile
*
infptr
;
/* a cfitsio pointer to the file */
#endif
}
catstruct
;
/*-------------------------------- table ----------------------------------*/
...
...
@@ -180,8 +188,8 @@ typedef struct structtab
char
*
headbuf
;
/* buffer containing the header */
int
headnblock
;
/* number of FITS blocks */
char
*
bodybuf
;
/* buffer containing the body */
OFF_T
bodypos
;
/* position of the body in the file */
OFF_T
headpos
;
/* position of the head in the file */
OFF_T
2
bodypos
;
/* position of the body in the file */
OFF_T
2
headpos
;
/* position of the head in the file */
struct
structcat
*
cat
;
/* (original) parent catalog */
struct
structtab
*
prevtab
,
*
nexttab
;
/* previous and next tab in chain */
int
seg
;
/* segment position */
...
...
@@ -190,7 +198,13 @@ typedef struct structtab
int
nkey
;
/* number of keys */
int
swapflag
;
/* mapped to a swap file ? */
char
swapname
[
MAXCHARS
];
/* name of the swapfile */
unsigned
int
bodysum
;
/* Checksum of the FITS body */
unsigned
int
bodysum
;
/* Checksum of the FITS body */
int
isTileCompressed
;
/* is this a tile compressed image? */
#ifdef HAVE_CFITSIO
fitsfile
*
infptr
;
/* a cfitsio pointer to the file */
int
hdunum
;
/* FITS HDU number for this 'table' */
long
currentElement
;
/* tracks the current image pixel */
#endif
}
tabstruct
;
...
...
@@ -218,8 +232,8 @@ extern void add_cleanupfilename(char *filename),
encode_checksum
(
unsigned
int
sum
,
char
*
str
),
end_readobj
(
tabstruct
*
keytab
,
tabstruct
*
tab
,
char
*
buf
),
end_writeobj
(
catstruct
*
cat
,
tabstruct
*
tab
,
char
*
buf
),
error
(
int
,
char
*
,
char
*
),
error_installfunc
(
void
(
*
func
)(
char
*
msg1
,
char
*
msg2
)),
error
(
int
code
,
const
char
*
msg1
,
const
char
*
msg2
),
error_installfunc
(
void
(
*
func
)(
const
char
*
msg1
,
const
char
*
msg2
)),
fixexponent
(
char
*
s
),
free_body
(
tabstruct
*
tab
),
free_cat
(
catstruct
**
cat
,
int
ncat
),
...
...
@@ -271,6 +285,9 @@ extern int about_cat(catstruct *cat, FILE *stream),
add_tab
(
tabstruct
*
tab
,
catstruct
*
cat
,
int
pos
),
blank_keys
(
tabstruct
*
tab
),
close_cat
(
catstruct
*
cat
),
#ifdef HAVE_CFITSIO
close_cfitsio
(
catstruct
*
cat
),
#endif
copy_key
(
tabstruct
*
tabin
,
char
*
keyname
,
tabstruct
*
tabout
,
int
pos
),
copy_tab
(
catstruct
*
catin
,
char
*
tabname
,
int
seg
,
...
...
@@ -315,6 +332,7 @@ extern int about_cat(catstruct *cat, FILE *stream),
tformof
(
char
*
str
,
t_type
ttype
,
int
n
),
tsizeof
(
char
*
str
),
update_head
(
tabstruct
*
tab
),
decomp_head
(
tabstruct
*
tab
),
update_tab
(
tabstruct
*
tab
),
verify_checksum
(
tabstruct
*
tab
),
write_obj
(
tabstruct
*
tab
,
char
*
buf
),
...
...
@@ -328,8 +346,4 @@ extern FLAGTYPE *alloc_ibody(tabstruct *tab,
extern
t_type
ttypeof
(
char
*
str
);
extern
void
error
(
int
,
char
*
,
char
*
),
swapbytes
(
void
*
ptr
,
int
nb
,
int
n
),
warning
(
char
*
msg1
,
char
*
msg2
);
#endif
src/fits/fitshead.c
View file @
08c0ebe3
...
...
@@ -7,7 +7,7 @@
*
* This file part of: AstrOmatic FITS/LDAC library
*
* Copyright: (C) 1995-202
2
IAP/CNRS/SorbonneU
* Copyright: (C) 1995-202
3 CFHT/
IAP/CNRS/SorbonneU
*
* License: GNU General Public License
*
...
...
@@ -23,7 +23,7 @@
* along with AstrOmatic software.
* If not, see <http://www.gnu.org/licenses/>.
*
* Last modified:
11
/0
3
/202
2
* Last modified:
25
/0
2
/202
3
*
*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
...
...
@@ -100,64 +100,92 @@ PURPOSE Read the current FITS header basic keywords.
INPUT pointer to catstruct.
OUTPUT -.
NOTES -.
AUTHOR E. Bertin (
IAP
)
VERSION
03
/0
6
/20
1
2
AUTHOR E. Bertin (
CFHT/IAP/SorbonneU
)
VERSION
25
/0
2
/202
3
***/
void
readbasic_head
(
tabstruct
*
tab
)
{
char
str
[
88
];
char
key
[
12
],
name
[
16
],
*
filename
;
int
i
;
*
bitpix_key
,
*
naxis_key
,
*
filename
;
int
i
,
bitpix
,
bytepix
,
naxis
,
naxisn
;
KINGSIZE_T
tabsize
;
filename
=
(
tab
->
cat
?
tab
->
cat
->
filename
:
strcpy
(
name
,
"internal header"
));
if
(
fitsread
(
tab
->
headbuf
,
"BITPIX "
,
&
tab
->
bitpix
,
H_INT
,
T_LONG
)
==
RETURN_ERROR
)
error
(
EXIT_FAILURE
,
"*Error*: Corrupted FITS header in "
,
filename
);
tab
->
isTileCompressed
=
(
fitsread
(
tab
->
headbuf
,
"ZIMAGE "
,
str
,
H_STRING
,
T_STRING
)
==
RETURN_OK
)
?
1
:
0
;
tab
->
bytepix
=
tab
->
bitpix
>
0
?
(
tab
->
bitpix
/
8
)
:
(
-
tab
->
bitpix
/
8
);
if
(
fitsread
(
tab
->
headbuf
,
tab
->
isTileCompressed
?
"ZBITPIX "
:
"BITPIX "
,
&
tab
->
bitpix
,
H_INT
,
T_LONG
)
==
RETURN_ERROR
)
error
(
EXIT_FAILURE
,
"*Error*: Corrupted FITS header in "
,
filename
);
if
(
fitsread
(
tab
->
headbuf
,
"NAXIS "
,
&
tab
->
naxis
,
H_INT
,
T_LONG
)
==
RETURN_ERROR
)
if
(
fitsread
(
tab
->
headbuf
,
tab
->
isTileCompressed
?
"ZNAXIS "
:
"NAXIS "
,
&
tab
->
naxis
,
H_INT
,
T_LONG
)
==
RETURN_ERROR
)
error
(
EXIT_FAILURE
,
"*Error*: Corrupted FITS header in "
,
filename
);
tabsize
=
0
;
if
(
tab
->
naxis
>
0
)
{
tab
->
bytepix
=
tab
->
bitpix
>
0
?
(
tab
->
bitpix
/
8
)
:
(
-
tab
->
bitpix
/
8
);
if
(
tab
->
naxis
>
0
)
{
QFREE
(
tab
->
naxisn
);
QMALLOC
(
tab
->
naxisn
,
int
,
tab
->
naxis
);
/*--get the size of the array*/
tabsize
=
1
;
for
(
i
=
0
;
i
<
tab
->
naxis
&&
i
<
999
;
i
++
)
{
sprintf
(
key
,
"NAXIS%-3d"
,
i
+
1
);
for
(
i
=
0
;
i
<
tab
->
naxis
&&
i
<
999
;
i
++
)
{
sprintf
(
key
,
tab
->
isTileCompressed
?
"ZNAXIS%-2d"
:
"NAXIS%-3d"
,
i
+
1
);
if
(
fitsread
(
tab
->
headbuf
,
key
,
&
tab
->
naxisn
[
i
],
H_INT
,
T_LONG
)
==
RETURN_ERROR
)
error
(
EXIT_FAILURE
,
"*Error*: incoherent FITS header in "
,
filename
);
tabsize
*=
tab
->
naxisn
[
i
];
}
error
(
EXIT_FAILURE
,
"*Error*: inconsistent FITS header in "
,
filename
);
}
}
/*random groups parameters (optional)*/
tab
->
pcount
=
0
;
fitsread
(
tab
->
headbuf
,
"PCOUNT "
,
&
tab
->
pcount
,
H_INT
,
T_LONG
);
tab
->
gcount
=
1
;
fitsread
(
tab
->
headbuf
,
"GCOUNT "
,
&
tab
->
gcount
,
H_INT
,
T_LONG
);
/*number of fields (only for tables)*/
tab
->
tfields
=
0
;
fitsread
(
tab
->
headbuf
,
"TFIELDS "
,
&
tab
->
tfields
,
H_INT
,
T_LONG
);
/*in case of a non-primary header*/
/* In case of a non-primary header*/
tab
->
xtension
[
0
]
=
(
char
)
'\0'
;
fitsread
(
tab
->
headbuf
,
"XTENSION"
,
tab
->
xtension
,
H_STRING
,
T_STRING
);
tab
->
extname
[
0
]
=
(
char
)
'\0'
;
fitsread
(
tab
->
headbuf
,
"EXTNAME "
,
tab
->
extname
,
H_STRING
,
T_STRING
);
tab
->
tabsize
=
tab
->
bytepix
*
tab
->
gcount
*
((
size_t
)
tab
->
pcount
+
tabsize
);
/* Number of fields (only for tables)*/
tab
->
tfields
=
0
;
fitsread
(
tab
->
headbuf
,
"TFIELDS "
,
&
tab
->
tfields
,
H_INT
,
T_LONG
);
/* Random groups parameters (optional)*/
tab
->
gcount
=
1
;
fitsread
(
tab
->
headbuf
,
"GCOUNT "
,
&
tab
->
gcount
,
H_INT
,
T_LONG
);
tab
->
pcount
=
0
;
fitsread
(
tab
->
headbuf
,
"PCOUNT "
,
&
tab
->
pcount
,
H_INT
,
T_LONG
);
/* Compute extension body size in bytes */
if
(
tab
->
isTileCompressed
)
{
if
(
fitsread
(
tab
->
headbuf
,
"BITPIX "
,
&
bitpix
,
H_INT
,
T_LONG
)
==
RETURN_ERROR
)
error
(
EXIT_FAILURE
,
"*Error*: Corrupted FITS header in "
,
filename
);
bytepix
=
bitpix
>
0
?
(
bitpix
/
8
)
:
(
-
bitpix
/
8
);
if
(
fitsread
(
tab
->
headbuf
,
"NAXIS "
,
&
naxis
,
H_INT
,
T_LONG
)
==
RETURN_ERROR
)
error
(
EXIT_FAILURE
,
"*Error*: Corrupted FITS header in "
,
filename
);
if
((
naxis
))
{
tabsize
=
1
;
for
(
i
=
0
;
i
<
naxis
&&
i
<
999
;
i
++
)
{
naxisn
=
1
;
sprintf
(
key
,
"NAXIS%-3d"
,
i
+
1
);
if
(
fitsread
(
tab
->
headbuf
,
key
,
&
naxisn
,
H_INT
,
T_LONG
)
==
RETURN_ERROR
)
error
(
EXIT_FAILURE
,
"*Error*: inconsistent FITS header in "
,
filename
);
tabsize
*=
naxisn
;
}
}
else
tabsize
=
0
;
}
else
{
bytepix
=
tab
->
bytepix
;
if
((
tab
->
naxis
))
{
tabsize
=
1
;
for
(
i
=
0
;
i
<
tab
->
naxis
&&
i
<
999
;
i
++
)
tabsize
*=
tab
->
naxisn
[
i
];
}
else
tabsize
=
0
;
}
tab
->
tabsize
=
bytepix
*
tab
->
gcount
*
((
size_t
)
tab
->
pcount
+
tabsize
);
/* Scaling parameters for basic FITS integer arrays */
tab
->
bscale
=
1
.
0
;
...
...
@@ -284,7 +312,12 @@ int readbintabparam_head(tabstruct *tab)
key
->
htype
=
H_STRING
;
break
;
default:
#ifdef HAVE_CFITSIO
// CFITSIO TODO dodgy
key
->
ttype
=
T_FLOAT
;
#else
error
(
EXIT_FAILURE
,
"*Error*: Unknown TFORM in "
,
cat
->
filename
);
#endif
}
/*--handle the special case of multimensional arrays*/
...
...
@@ -893,3 +926,49 @@ char *printftotdisp(char *cprintf, char *str)
return
str
;
}
/****** decomp_head ***********************************************************
PROTO int decomp_head(tabstruct *tab)
PURPOSE Update a FITS header so that it now matches uncompressed data format.
INPUT Table structure.
OUTPUT RETURN_OK if tab is a compressed binary table,
or RETURN_ERROR otherwise.
NOTES The headbuf pointer in the tabstruct might be reallocated.
AUTHOR E. Bertin (CFHT/IAP/CNRS/SorbonneU)
VERSION 25/02/2023
***/
int
decomp_head
(
tabstruct
*
tab
)
{
#ifdef HAVE_CFITSIO
/* Update XTENSION, the extension type */
if
(
tab
->
isTileCompressed
&&
*
tab
->
xtension
)
{
strcpy
(
tab
->
xtension
,
"IMAGE"
);
addkeywordto_head
(
tab
,
"XTENSION"
,
"EXTENSION TYPE"
);
fitswrite
(
tab
->
headbuf
,
"XTENSION"
,
tab
->
xtension
,
H_STRING
,
T_STRING
);
addkeywordto_head
(
tab
,
"PCOUNT "
,
"required keyword; must = 0"
);
addkeywordto_head
(
tab
,
"GCOUNT "
,
"required keyword; must = 1"
);
tab
->
pcount
=
0
;
tab
->
gcount
=
1
;
fitswrite
(
tab
->
headbuf
,
"PCOUNT "
,
&
tab
->
pcount
,
H_INT
,
T_LONG
);
fitswrite
(
tab
->
headbuf
,
"GCOUNT "
,
&
tab
->
gcount
,
H_INT
,
T_LONG
);
tab
->
isTileCompressed
=
0
;
/*-- Remove all compression-related keywords */
removekeywordfrom_head
(
tab
,
"TFIELDS?"
);
removekeywordfrom_head
(
tab
,
"TTYPE???"
);
removekeywordfrom_head
(
tab
,
"TFORM???"
);
removekeywordfrom_head
(
tab
,
"ZIMAGE??"
);
removekeywordfrom_head
(
tab
,
"ZBITPIX?"
);
removekeywordfrom_head
(
tab
,
"ZNAXIS??"
);
removekeywordfrom_head
(
tab
,
"ZTILE???"
);
removekeywordfrom_head
(
tab
,
"ZCMPTYPE"
);
removekeywordfrom_head
(
tab
,
"ZNAME???"
);
removekeywordfrom_head
(
tab
,
"ZVAL????"
);
update_head
(
tab
);
return
RETURN_OK
;
}
else
#endif
return
RETURN_ERROR
;
}
src/fits/fitskey.c
View file @
08c0ebe3
...
...
@@ -991,7 +991,7 @@ void show_keys(tabstruct *tab, char **keynames, keystruct **keys, int nkeys,
if
(
kflag
)
free
(
keys
);
if
(
o_type
==
SHOW_SKYCAT
)
fprintf
(
stream
,
skycattail
,
1
.
0
);
fprintf
(
stream
,
"%s"
,
skycattail
);
return
;
}
src/fits/fitsmisc.c
View file @
08c0ebe3
...
...
@@ -23,7 +23,7 @@
* along with AstrOmatic software.
* If not, see <http://www.gnu.org/licenses/>.
*
* Last modified: 0
9
/1
0
/201
0
* Last modified:
2
0/1
1
/201
3
*
*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
...
...
@@ -40,7 +40,7 @@
#include
"fitscat_defs.h"
#include
"fitscat.h"
static
void
(
*
errorfunc
)(
char
*
msg1
,
char
*
msg2
)
=
NULL
;
static
void
(
*
errorfunc
)(
const
char
*
msg1
,
const
char
*
msg2
)
=
NULL
;
static
char
warning_historystr
[
WARNING_NMAX
][
192
]
=
{
""
};
static
int
nwarning
=
0
,
nwarning_history
=
0
,
nerror
=
0
;
...
...
@@ -48,7 +48,7 @@ static int nwarning = 0, nwarning_history = 0, nerror = 0;
/*
I hope it will never be used!
*/
void
error
(
int
num
,
char
*
msg1
,
char
*
msg2
)
void
error
(
int
num
,
const
char
*
msg1
,
const
char
*
msg2
)
{
fprintf
(
stderr
,
"
\n
> %s%s
\n\n
"
,
msg1
,
msg2
);
if
(
num
&&
errorfunc
&&
!
nerror
)
...
...
@@ -64,7 +64,7 @@ void error(int num, char *msg1, char *msg2)
/*
I hope it will never be used!
*/
void
error_installfunc
(
void
(
*
func
)(
char
*
msg1
,
char
*
msg2
))
void
error_installfunc
(
void
(
*
func
)(
const
char
*
msg1
,
const
char
*
msg2
))
{
if
(
func
)
errorfunc
=
func
;
...
...
src/fits/fitstab.c
View file @
08c0ebe3
...
...
@@ -7,7 +7,7 @@
*
* This file part of: AstrOmatic FITS/LDAC library
*
* Copyright: (C) 1995-20
10 Emmanuel Bertin -- IAP/CNRS/UPMC
* Copyright: (C) 1995-20
23 CFHT/IAP/CNRS/SorbonneU
*
* License: GNU General Public License
*
...
...
@@ -23,7 +23,7 @@
* along with AstrOmatic software.
* If not, see <http://www.gnu.org/licenses/>.
*
* Last modified:
11
/0
9
/20
1
2
* Last modified:
25
/0
2
/202
3
*
*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
...
...
@@ -35,6 +35,10 @@
#include
<stdlib.h>
#include
<string.h>
#ifdef HAVE_CFITSIO
#include CFITSIO_H
#endif
#include
"fitscat_defs.h"
#include
"fitscat.h"
...
...
@@ -270,8 +274,8 @@ INPUT Pointer to the original catalog,
Position (1= first after the primary HDU, <=0 = at the end)
OUTPUT -.
NOTES -.
AUTHOR E. Bertin (IAP
& Leiden observatory
)
VERSION 2
2
/0
6
/20
01
AUTHOR E. Bertin (IAP
/SorbonneU
)
VERSION 2
5
/0
2
/20
23
***/
void
copy_tab_fromptr
(
tabstruct
*
tabin
,
catstruct
*
catout
,
int
pos
)
...
...
@@ -318,6 +322,11 @@ void copy_tab_fromptr(tabstruct *tabin, catstruct *catout, int pos)
prevtab
->
nexttab
=
nexttab
;
nexttab
->
prevtab
=
prevtab
;
#ifdef HAVE_CFITSIO
// Do not copy CFitsIO file pointer
tabout
->
infptr
=
NULL
;
#endif
return
;
}
...
...
@@ -396,8 +405,8 @@ PURPOSE Free memory associated to a table pointer.
INPUT Pointer to the table.
OUTPUT -.
NOTES -.
AUTHOR E. Bertin (
IAP & Leiden observatory
)
VERSION 2
8
/02/20
00
AUTHOR E. Bertin (
CFHT/IAP/CNRS/SorbonneU
)
VERSION 2
5
/02/20
23
***/
void
free_tab
(
tabstruct
*
tab
)
...
...
src/fits/fitswrite.c
View file @
08c0ebe3
...
...
@@ -23,7 +23,7 @@
* along with AstrOmatic software.
* If not, see <http://www.gnu.org/licenses/>.
*
* Last modified:
11
/0
2
/2020
* Last modified:
26
/0
8
/2020
*
*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
...
...
@@ -359,13 +359,13 @@ INPUT catalog structure,
OUTPUT -.
NOTES -.
AUTHOR E. Bertin (IAP & Leiden observatory)
VERSION
26/09/2004
VERSION
03/12/2019
***/
void
end_writeobj
(
catstruct
*
cat
,
tabstruct
*
tab
,
char
*
buf
)
{
keystruct
*
key
;
OFF_T
pos
;
OFF_T
2
pos
;
int
k
;
/* Make the table parameters reflect its content*/
...
...
src/globals.h
View file @
08c0ebe3
...
...
@@ -22,7 +22,7 @@
* You should have received a copy of the GNU General Public License
* along with SExtractor. If not, see <http://www.gnu.org/licenses/>.
*
* Last modified:
15
/0
7
/2020
* Last modified:
23
/0
9
/2020
*
*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
...
...
@@ -82,7 +82,7 @@ extern void alloccatparams(void),
updateparamflags
(
void
),
useprefs
(
void
),
writecat
(
int
,
objliststruct
*
),
write_error
(
char
*
msg1
,
char
*
msg2
),
write_error
(
const
char
*
msg1
,
const
char
*
msg2
),
write_vo_fields
(
FILE
*
file
),
zerocat
(
void
);
...
...
src/header.c
View file @
08c0ebe3
...
...
@@ -22,7 +22,7 @@
* You should have received a copy of the GNU General Public License
* along with SExtractor. If not, see <http://www.gnu.org/licenses/>.
*
* Last modified:
12/07
/20
1
2
* Last modified:
07/09
/20
2
2
*
*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
...
...
@@ -49,7 +49,7 @@ INPUT Name of the ASCII file,
OUTPUT RETURN_OK if the file was found, RETURN_ERROR otherwise.
NOTES -.
AUTHOR E. Bertin (IAP)
VERSION
12/07
/20
1
2
VERSION
07/09
/20
2
2
***/
int
read_aschead
(
char
*
filename
,
int
frameno
,
tabstruct
*
tab
)
{
...
...
@@ -63,7 +63,7 @@ int read_aschead(char *filename, int frameno, tabstruct *tab)
{
/*- Skip previous ENDs in multi-FITS extension headers */
for
(
i
=
frameno
-
1
;
i
--
;)
while
(
fgets
(
str
,
MAXCHAR
,
file
)
while
(
fgets
(
str
,
88
,
file
)
&&
strncmp
(
str
,
"END "
,
4
)
&&
strncmp
(
str
,
"END
\n
"
,
4
));
memset
(
str
,
' '
,
80
);
...
...
src/makeit.c
View file @
08c0ebe3
...
...
@@ -7,7 +7,7 @@
*
* This file part of: SExtractor
*
* Copyright: (C) 1993-202
0
IAP/CNRS/SorbonneU
* Copyright: (C) 1993-202
3 CFHT/
IAP/CNRS/SorbonneU
*
* License: GNU General Public License
*
...
...
@@ -22,7 +22,7 @@
* You should have received a copy of the GNU General Public License
* along with SExtractor. If not, see <http://www.gnu.org/licenses/>.
*
* Last modified:
15/07/2020
* Last modified:
07/03/2023
*
*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
...
...
@@ -43,7 +43,9 @@
#include
"assoc.h"
#include
"back.h"
#include
"check.h"
#ifdef USE_MODEL
#include
"fft.h"
#endif
#include
"field.h"
#include
"filter.h"
#include
"growth.h"
...
...
@@ -280,7 +282,7 @@ void makeit()
{
/*---- Check for the next valid image extension */
if
((
imatab
->
naxis
<
2
)
||
!
strncmp
(
imatab
->
xtension
,
"BINTABLE"
,
8
)
||
!
(
imatab
->
isTileCompressed
||
strncmp
(
imatab
->
xtension
,
"BINTABLE"
,
8
)
)
||
!
strncmp
(
imatab
->
xtension
,
"ASCTABLE"
,
8
))
continue
;
next
++
;
...
...
@@ -319,10 +321,9 @@ void makeit()
{
/*-- Check for the next valid image extension */
if
(
!
forcextflag
&&
((
imatab
->
naxis
<
2
)
||
!
strncmp
(
imatab
->
xtension
,
"BINTABLE"
,
8
)
||
!
(
imatab
->
isTileCompressed
||
strncmp
(
imatab
->
xtension
,
"BINTABLE"
,
8
)
)
||
!
strncmp
(
imatab
->
xtension
,
"ASCTABLE"
,
8
)))
continue
;
nok
++
;
/*-- Initial time measurement*/
...
...
@@ -706,8 +707,8 @@ INPUT Filename character string.
OUTPUT Extension number, or RETURN_ERROR if nos extension specified.
NOTES The bracket and its extension number are removed from the filename if
found.
AUTHOR E. Bertin (IAP)
VERSION 0
8/10
/20
07
AUTHOR E. Bertin (
CFHT/
IAP)
VERSION 0
7/03
/20
23
***/
static
int
selectext
(
char
*
filename
)
{
...
...
@@ -720,6 +721,7 @@ static int selectext(char *filename)
if
((
bracr
=
strrchr
(
bracl
+
1
,
']'
)))
*
bracr
=
'\0'
;
next
=
strtol
(
bracl
+
1
,
NULL
,
0
);
return
next
;
}
...
...
@@ -735,9 +737,9 @@ INPUT a character string,
OUTPUT RETURN_OK if everything went fine, RETURN_ERROR otherwise.
NOTES -.
AUTHOR E. Bertin (IAP)
VERSION
14
/0
7
/200
6
VERSION
23
/0
9
/20
2
0
***/
void
write_error
(
char
*
msg1
,
char
*
msg2
)
void
write_error
(
const
char
*
msg1
,
const
char
*
msg2
)
{
char
error
[
MAXCHAR
];
...
...
Prev
1
2
3
Next
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment