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
869e9a3f
Commit
869e9a3f
authored
Feb 25, 2023
by
Emmanuel Bertin
Browse files
Fix various CFITSIO issues.
parent
f579530e
Changes
9
Hide whitespace changes
Inline
Side-by-side
doc/src/conf.py
View file @
869e9a3f
...
...
@@ -81,7 +81,7 @@ language = None
# There are two options for replacing |today|: either, you set today to some
# non-false value, then it is used:
#
today
=
'
Fri Sep 16
202
2
'
today
=
'
Sat Feb 25
202
3
'
#
# Else, today_fmt is used as the format for a strftime call.
#
...
...
src/check.c
View file @
869e9a3f
...
...
@@ -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/field.c
View file @
869e9a3f
...
...
@@ -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: 2
3
/0
9
/202
0
* Last modified: 2
5
/0
2
/202
3
*
*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
...
...
@@ -70,25 +70,19 @@ picstruct *newfield(char *filename, int flags, int ext)
field
->
cat
=
cat
;
nok
=
0
;
tab
=
cat
->
tab
;
#ifdef HAVE_CFITSIO
if
(
tab
->
isTileCompressed
)
nok
++
;
#endif
if
(
tab
->
naxis
>=
2
if
((
tab
->
isTileCompressed
)
||
(
tab
->
naxis
>=
2
&&
strncmp
(
tab
->
xtension
,
"BINTABLE"
,
8
)
&&
strncmp
(
tab
->
xtension
,
"ASCTABLE"
,
8
))
&&
strncmp
(
tab
->
xtension
,
"ASCTABLE"
,
8
))
)
nok
++
;
ext2
=
ext
;
for
(
ntab
=
cat
->
ntab
;
ext2
--
&&
ntab
--
;)
{
tab
=
tab
->
nexttab
;
#ifdef HAVE_CFITSIO
if
(
tab
->
isTileCompressed
)
nok
++
;
#endif
if
(
tab
->
naxis
>=
2
&&
strncmp
(
tab
->
xtension
,
"BINTABLE"
,
8
)
&&
strncmp
(
tab
->
xtension
,
"ASCTABLE"
,
8
))
if
((
tab
->
isTileCompressed
)
||
(
tab
->
naxis
>=
2
&&
strncmp
(
tab
->
xtension
,
"BINTABLE"
,
8
)
&&
strncmp
(
tab
->
xtension
,
"ASCTABLE"
,
8
)))
nok
++
;
}
if
(
!
nok
)
...
...
src/fits/fitsbody.c
View file @
869e9a3f
...
...
@@ -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: 2
6
/0
8
/202
0
* Last modified: 2
5
/0
2
/202
3
*
*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
...
...
@@ -394,8 +394,8 @@ INPUT A pointer to the tab structure,
the number of elements to be read.
OUTPUT -.
NOTES .
AUTHOR E. Bertin (
IAP
)
VERSION 2
6
/0
8
/202
0
AUTHOR E. Bertin (
CFHT/IAP/CNRS/SorbonneU
)
VERSION 2
5
/0
2
/202
3
***/
void
read_body
(
tabstruct
*
tab
,
PIXTYPE
*
ptr
,
size_t
size
)
{
...
...
@@ -439,7 +439,7 @@ void read_body(tabstruct *tab, PIXTYPE *ptr, size_t size)
bufdata
=
(
char
*
)
bufdata0
;
#ifdef HAVE_CFITSIO
if
(
tab
->
isTileCompressed
)
if
(
tab
->
isTileCompressed
&&
tab
->
infptr
)
readTileCompressed
(
tab
,
spoonful
,
(
void
*
)
bufdata0
);
else
QFREAD
(
bufdata
,
spoonful
*
tab
->
bytepix
,
cat
->
file
,
cat
->
filename
);
...
...
src/fits/fitscat.c
View file @
869e9a3f
...
...
@@ -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: 2
6
/0
8
/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 **************************************************************
...
...
@@ -168,29 +170,33 @@ int close_cat(catstruct *cat)
}
#ifdef HAVE_CFITSIO
/****** close_cfitsio **************************************************************
Closes a file previously opened by 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
(
fitsfile
*
infptr
)
{
if
(
infptr
!=
NULL
)
{
int
status
=
0
;
fits_close_file
(
infptr
,
&
status
);
if
(
status
!=
0
)
{
fits_report_error
(
stderr
,
status
);
printf
(
"ERROR could not close FITS file with cfitsio
\n
"
);
}
else
{
//printf("Successfully closed FITS file with cfitsio\n")
;
infptr
==
NULL
;
}
}
else
{
//printf("ERROR no cfitsio file to close\n")
;
}
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
...
...
@@ -202,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
)
...
...
@@ -218,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
++
));
}
...
...
@@ -338,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
)
...
...
@@ -355,15 +365,7 @@ int map_cat(catstruct *cat)
#ifdef HAVE_CFITSIO
fitsfile
*
infptr
;
int
status
,
hdutype
,
hdunum
;
status
=
0
;
fits_open_file
(
&
infptr
,
cat
->
filename
,
READONLY
,
&
status
);
if
(
status
!=
0
)
{
fits_report_error
(
stderr
,
status
);
printf
(
"ERROR could not open FITS file with cfitsio: %s
\n
"
,
cat
->
filename
);
}
hdunum
=
1
;
int
any_tile_compressed
=
0
;
int
status
,
hdutype
,
hdunum
=
1
;
#endif // HAVE_CFITSIO
for
(
ntab
=
0
;
!
get_head
(
tab
);
ntab
++
)
...
...
@@ -375,31 +377,22 @@ int map_cat(catstruct *cat)
#ifdef HAVE_CFITSIO
if
(
tab
->
isTileCompressed
)
{
any_tile_compressed
=
1
;
tab
->
hdunum
=
hdunum
;
tab
->
infptr
=
infptr
;
status
=
0
;
fits_movabs_hdu
(
tab
->
infptr
,
tab
->
hdunum
,
&
hdutype
,
&
status
);
if
(
status
!=
0
)
printf
(
"ERROR could not move to hdu %d in file %s
\n
"
,
tab
->
hdunum
,
cat
->
filename
);
if
(
tab
->
tabsize
)
fseek
(
cat
->
file
,
infptr
->
Fptr
->
headstart
[
hdunum
],
SEEK_SET
);
}
// NOT tile-compressed
else
{
tab
->
infptr
=
NULL
;
if
(
tab
->
tabsize
)
QFSEEK
(
cat
->
file
,
PADTOTAL
(
tab
->
tabsize
),
SEEK_CUR
,
cat
->
filename
);
// 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
;
}
hdunum
++
;
#else
tab
->
hdunum
=
hdunum
++
;
#endif // HAVE_CFITSIO
if
(
tab
->
tabsize
)
QFSEEK
(
cat
->
file
,
PADTOTAL
(
tab
->
tabsize
),
SEEK_CUR
,
cat
->
filename
);
#endif // HAVE_CFITSIO
if
(
prevtab
)
{
...
...
@@ -414,12 +407,6 @@ int map_cat(catstruct *cat)
QFTELL
(
cat
->
file
,
tab
->
headpos
,
cat
->
filename
);
}
#ifdef HAVE_CFITSIO
// we will not need CFitsIO, so close CFitsIO file pointer now
if
(
!
any_tile_compressed
)
close_cfitsio
(
infptr
);
#endif
cat
->
ntab
=
ntab
;
free
(
tab
);
if
(
prevtab
)
...
...
src/fits/fitscat.h
View file @
869e9a3f
...
...
@@ -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: 2
6
/0
8
/202
0
* Last modified: 2
5
/0
2
/202
3
*
*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
...
...
@@ -155,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 ----------------------------------*/
...
...
@@ -195,12 +198,12 @@ 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' */
int
isTileCompressed
;
/* is this a tile compressed image? */
long
currentElement
;
/* tracks the current image pixel */
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
;
...
...
@@ -283,7 +286,7 @@ extern int about_cat(catstruct *cat, FILE *stream),
blank_keys
(
tabstruct
*
tab
),
close_cat
(
catstruct
*
cat
),
#ifdef HAVE_CFITSIO
close_cfitsio
(
fitsfile
*
infptr
),
close_cfitsio
(
catstruct
*
cat
),
#endif
copy_key
(
tabstruct
*
tabin
,
char
*
keyname
,
tabstruct
*
tabout
,
int
pos
),
...
...
@@ -329,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
),
...
...
src/fits/fitshead.c
View file @
869e9a3f
...
...
@@ -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,85 +100,92 @@ PURPOSE Read the current FITS header basic keywords.
INPUT pointer to catstruct.
OUTPUT -.
NOTES -.
AUTHOR E. Bertin (
IAP
)
VERSION
04/1
2/20
19
AUTHOR E. Bertin (
CFHT/IAP/SorbonneU
)
VERSION
25/0
2/20
23
***/
void
readbasic_head
(
tabstruct
*
tab
)
{
char
str
[
88
];
char
key
[
12
],
name
[
16
],
bitpix_key
[
16
],
naxis_key
[
16
],
*
filename
;
int
i
;
char
key
[
12
],
name
[
16
],
*
bitpix_key
,
*
naxis_key
,
*
filename
;
int
i
,
bitpix
,
bytepix
,
naxis
,
naxisn
;
KINGSIZE_T
tabsize
;
filename
=
(
tab
->
cat
?
tab
->
cat
->
filename
:
strcpy
(
name
,
"internal header"
));
strncpy
(
bitpix_key
,
"BITPIX "
,
9
);
strncpy
(
naxis_key
,
"NAXIS "
,
9
);
#ifdef HAVE_CFITSIO
tab
->
isTileCompressed
=
(
fitsread
(
tab
->
headbuf
,
"ZIMAGE "
,
str
,
H_STRING
,
T_STRING
)
==
RETURN_OK
)
?
1
:
0
;
if
(
tab
->
isTileCompressed
)
{
strncpy
(
bitpix_key
,
"ZBITPIX "
,
9
);
strncpy
(
naxis_key
,
"ZNAXIS "
,
9
);
}
#endif
if
(
fitsread
(
tab
->
headbuf
,
bitpix_key
,
&
tab
->
bitpix
,
H_INT
,
T_LONG
)
==
RETURN_ERROR
)
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_key
,
&
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
);
tab
->
bytepix
=
tab
->
bitpix
>
0
?
(
tab
->
bitpix
/
8
)
:
(
-
tab
->
bitpix
/
8
);
tabsize
=
0
;
if
(
tab
->
naxis
>
0
)
{
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
++
)
{
#ifdef HAVE_CFITSIO
if
(
tab
->
isTileCompressed
)
sprintf
(
key
,
"ZNAXIS%-2d"
,
i
+
1
);
else
#endif
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
);
/* 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
);
#ifdef HAVE_CFITSIO
// CFITSIO TODO HACK
if
(
tab
->
isTileCompressed
)
tab
->
pcount
=
0
;
#endif
/* 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
);
/*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*/
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
);
/* 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
);
tab
->
tabsize
=
tab
->
bytepix
*
tab
->
gcount
*
((
size_t
)
tab
->
pcount
+
tabsize
);
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
;
...
...
@@ -919,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/fitstab.c
View file @
869e9a3f
...
...
@@ -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/makeit.c
View file @
869e9a3f
...
...
@@ -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: 2
3
/0
9
/202
0
* Last modified: 2
5
/0
2
/202
3
*
*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
...
...
@@ -282,12 +282,9 @@ 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
))
#ifdef HAVE_CFITSIO
if
(
!
imatab
->
isTileCompressed
)
#endif
continue
;
continue
;
next
++
;
}
}
...
...
@@ -324,11 +321,8 @@ 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
)))
#ifdef HAVE_CFITSIO
if
(
!
imatab
->
isTileCompressed
)
#endif
continue
;
nok
++
;
...
...
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