Commit 019377bd authored by Emmanuel Bertin's avatar Emmanuel Bertin
Browse files

Link with CFITSIO is now the default.

parent b2cfd631
......@@ -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/02/2020
# Last modified: 23/09/2020
#
#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
......@@ -31,7 +31,7 @@ define([AC_CACHE_LOAD],)
define([AC_CACHE_SAVE],)
# This is your standard AstrOmatic source code...
AC_INIT(SExtractor, 2.25.2, [astromatic@astromatic.net],
AC_INIT(SExtractor, 2.27.0, [astromatic@astromatic.net],
sextractor, [http://astromatic.net/software/sextractor])
AC_CONFIG_MACRO_DIR([m4])
AC_CONFIG_AUX_DIR(autoconf)
......@@ -182,18 +182,22 @@ AC_ARG_WITH(openblas-incdir,
[Provide an alternative path to the OpenBLAS header directory])])
# Provide special option for CFITSIO
AC_MSG_CHECKING([whether CFITSIO support is enabled])
AC_MSG_CHECKING([whether CFITSIO support should be disabled (default=enabled)])
AC_ARG_ENABLE(cfitsio,
[AS_HELP_STRING([--enable-cfitsio],
[Enable support for compressed FITS files through the CFITSIO library (default = no)])],
AC_MSG_RESULT([yes]),
[AS_HELP_STRING([--disable-cfitsio],
[Disable support for compressed FITS files through the CFITSIO library (default=enabled)])],
if test "$enable_cfitsio" = "no"; then
AC_MSG_RESULT([yes])
else
AC_MSG_RESULT([no])
fi,
AC_MSG_RESULT([no]))
AC_ARG_WITH(cfitsio-libdir,
[AS_HELP_STRING([--with-cfitsio-libdir=<CFITSIO library path>],
[Provide an alternative path to the CFITSIO library])])
AC_ARG_WITH(cfitsio-incdir,
[AS_HELP_STRING([--with-cfitsio-incdir=<CFITSIO header dir>],
[Provide an alternative path to the CFITSIO header directory])])
[AS_HELP_STRING([--with-cfitsio-incdir=<CFITSIO include dir>],
[Provide an alternative path to the CFITSIO include directory])])
# Provide a special option for the default XSLT URL
with_xsl_url="file://"$(URBI_RESOLVE_DIR([$datadir]))"/$PACKAGE_TARNAME/$PACKAGE_TARNAME.xsl"
......@@ -320,19 +324,15 @@ if test "$enable_model_fitting" != "no"; then
fi
fi
AS_IF([test "x$enable_cfitsio" = "xyes"], [
ACX_CFITSIO($with_cfitsio_libdir, $with_cfitsio_incdir,, no,
[
AM_CFLAGS="$AM_CFLAGS $CFITSIO_CFLAGS "
AM_LDFLAGS="$AM_LDFLAGS $CFITSIO_LDFLAGS "
LIBS="$CFITSIO_LIBS $LIBS"
if test "$CFITSIO_WARN" != ""; then
AC_MSG_WARN([$CFITSIO_WARN])
fi
],
AC_MSG_ERROR([$CFITSIO_ERROR Exiting.])
)
])
########################## handle the CFITSIO library ########################
if test "$enable_cfitsio" != "no"; then
ACX_CFITSIO($with_cfitsio_libdir, $with_cfitsio_incdir,
[LIBS="$CFITSIO_LIBS $LIBS"]
if test "$CFITSIO_WARN" != ""; then
AC_MSG_WARN([$CFITSIO_WARN])
fi,
AC_MSG_ERROR([$CFITSIO_ERROR Exiting.]))
fi
AM_CONDITIONAL(USE_MODEL, [test "$enable_model_fitting" != "no"])
......
......@@ -67,9 +67,9 @@ author = u'E. Bertin'
# built documents.
#
# The short X.Y version.
version = '2.25.2'
version = '2.27.0'
# The full version, including alpha/beta/rc tags.
release = '2.25.2'
release = '2.27.0'
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
......@@ -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 = 'Wed Aug 12 2020'
today = 'Tue Sep 06 2022'
#
# Else, today_fmt is used as the format for a strftime call.
#
......@@ -144,7 +144,7 @@ html_theme_path = [sphinx_rtd_theme.get_html_theme_path()]
# The name for this set of Sphinx documents.
# "<project> v<release> documentation" by default.
#
# html_title = u'SExtractor v2.25.2'
# html_title = u'SExtractor v2.27.0'
# A shorter title for the navigation bar. Default is the same as html_title.
#
......
......@@ -7,7 +7,7 @@ dnl %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
dnl
dnl This file part of: AstrOmatic software
dnl
dnl Copyright: (C) 2019 IAP/CNRS/UPMC
dnl Copyright: (C) 2013 Emmanuel Bertin -- IAP/CNRS/UPMC
dnl
dnl License: GNU General Public License
dnl
......@@ -23,19 +23,24 @@ 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: 16/07/2019
dnl Last modified: 27/02/2013
dnl
dnl %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
dnl
dnl @synopsis ACX_CFITSIO([CFITSIO_LIBSDIR, CFITSIO_INCDIR, CFITSIO_PFLAG,
dnl ILP64_FLAG, [ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]]])
dnl
dnl You may wish to use these variables in your default LIBS:
dnl @synopsis ACX_CFITSIO([CFITSIO_DIR, CFITSIO_INCDIR,
dnl [ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]]])
dnl This macro figures out if the CFITSIO libraries and header
dnl files are installed.
dnl You may wish to use these variables in your default LIBS and CFLAGS:
dnl
dnl LIBS="$CFITSIO_LIBS $LIBS"
dnl
dnl You may wish to use these variables in your default CFLAGS:
dnl
dnl CFLAGS="$CFLAGS $CFITSIO_CFLAGS"
dnl
dnl ACTION-IF-FOUND is a list of shell commands to run if CFITSIO
dnl is found (HAVE_CFITSIO is defined first), and ACTION-IF-NOT-FOUND
dnl is found (HAVE_CFITSIO are defined first), and ACTION-IF-NOT-FOUND
dnl is a list of commands to run it if it is not found.
AC_DEFUN([ACX_CFITSIO], [
......@@ -45,77 +50,66 @@ dnl --------------------
dnl Search include files
dnl --------------------
CFITSIO_ERROR=""
acx_cfitsio_ok=no
if test x$2 = x; then
[acx_cfitsio_incdir="/"]
AC_CHECK_HEADERS(
[${acx_cfitsio_incdir}fitsio.h],,
[
[acx_cfitsio_incdir=""]
AC_CHECK_HEADER(
[fitsio.h],,
[CFITSIO_ERROR="CFITSIO header files not found!"]
)
]
)
AC_CHECK_HEADER(fitsio.h,[acx_cfitsio_ok=yes])
if test x$acx_cfitsio_ok = xyes; then
AC_DEFINE(CFITSIO_H, "fitsio.h", [CFITSIO header filename.])
else
AC_CHECK_HEADER(cfitsio/fitsio.h,[acx_cfitsio_ok=yes])
if test x$acx_cfitsio_ok = xyes; then
AC_DEFINE(CFITSIO_H, "cfitsio/fitsio.h", [CFITSIO header filename.])
else
CFITSIO_ERROR="CFITSIO include files not found at default location!"
fi
fi
else
acx_cfitsio_incdir="$2/"
AC_CHECK_HEADER(
[${acx_cfitsio_incdir}fitsio.h],,
[
[acx_cfitsio_incdir="$2/include/"]
AC_CHECK_HEADERS(
[${acx_cfitsio_incdir}fitsio.h],,
[CFITSIO_ERROR="CFITSIO header files not found in "$2"!"]
)]
)
AC_CHECK_HEADER($2/fitsio.h,[acx_cfitsio_ok=yes])
if test x$acx_cfitsio_ok = xyes; then
AC_DEFINE_UNQUOTED(CFITSIO_H, "$2/fitsio.h", [CFITSIO header filename.])
else
CFITSIO_ERROR="CFITSIO include files not found in $2!"
fi
fi
if test "x$CFITSIO_ERROR" = "x"; then
AC_DEFINE_UNQUOTED(FITSIO_H, "${acx_cfitsio_incdir}fitsio.h", [CFITSIO header filename.])
dnl --------------------
dnl Search library files
dnl --------------------
dnl ----------------------------
dnl Search CFITSIO library file
dnl ----------------------------
CFITSIO_LIBS=""
OLIBS="$LIBS"
LIBS=""
OLIBS="$LIBS"
LIBS=""
if test x$4 = xyes; then
acx_cfitsio_suffix="64"
CFITSIO_CFLAGS="-DCFITSIO_USE64BITINT -DLAPACK_ILP64"
else
acx_cfitsio_suffix=""
CFITSIO_CFLAGS=""
fi
if test x$acx_cfitsio_ok = xyes; then
if test x$1 = x; then
acx_cfitsio_libopt=""
AC_CHECK_LIB(cfitsio, ffopen, [acx_cfitsio_ok=yes], [acx_cfitsio_ok=no])
if test x$acx_cfitsio_ok = xyes; then
AC_DEFINE(HAVE_CFITSIO,1, [Define if you have the CFITSIO libraries and header files.])
CFITSIO_LIBS="-lcfitsio"
else
CFITSIO_ERROR="CFITSIO library files not found at usual locations!"
fi
else
acx_cfitsio_libopt="-L$1"
dnl -------------------------
dnl Specific libdir specified
dnl -------------------------
AC_CHECK_LIB(cfitsio, ffopen, [acx_cfitsio_ok=yes], [acx_cfitsio_ok=no], [-L$1])
if test x$acx_cfitsio_ok = xyes; then
AC_DEFINE(HAVE_CFITSIO,1, [Define if you have the CFITSIO libraries and header files.])
CFITSIO_LIBS="-L$1 -lcfitsio"
else
CFITSIO_ERROR="CFITSIO library files not found in $1!"
fi
fi
AC_SEARCH_LIBS(
[ffmahd], ["cfitsio"$acx_cfitsio_suffix],,
[CFITSIO_ERROR="CFITSIO"$acx_cfitsio_suffix" library file not found!"],
$acx_cfitsio_libopt
)
LIBS="$OLIBS"
fi
dnl -------------------------------------------------------------------------
dnl Finally execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND
dnl -------------------------------------------------------------------------
if test "x$CFITSIO_ERROR" = "x"; then
AC_DEFINE(HAVE_CFITSIO,1, [Define if you have the CFITSIO library and header files.])
CFITSIO_LIBS="$acx_cfitsio_libopt $ac_cv_search_ffmahd"
AC_SUBST(CFITSIO_CFLAGS)
AC_SUBST(CFITSIO_LDFLAGS, "")
LIBS="$OLIBS"
if test x$acx_cfitsio_ok = xyes; then
AC_SUBST(CFITSIO_LIBS)
AC_SUBST(CFITSIO_WARN)
$5
$3
else
AC_SUBST(CFITSIO_ERROR)
$6
$4
fi
])dnl ACX_CFITSIO
......@@ -7,7 +7,7 @@
*
* This file part of: SExtractor
*
* Copyright: (C) 1993-2016 Emmanuel Bertin -- IAP/CNRS/UPMC
* Copyright: (C) 1993-2016 IAP/CNRS/UPMC
*
* License: GNU General Public License
*
......
......@@ -7,7 +7,7 @@
*
* This file part of: SExtractor
*
* Copyright: (C) 1993-2014 Emmanuel Bertin -- IAP/CNRS/UPMC
* Copyright: (C) 1993-2020 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/06/2014
* Last modified: 23/09/2020
*
*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
......@@ -89,13 +89,16 @@ void makeback(picstruct *field, picstruct *wfield, int wscale_flag)
wfcurpos = wfcurpos2 = 0; /* to avoid gcc -Wall warnings */
QFTELL(field->file, fcurpos, field->filename);
currentElement = (tab->currentElement == 0) ? 1 : tab->currentElement; // CFITSIO
#ifdef HAVE_CFITSIO
currentElement = (tab->currentElement == 0) ? 1 : tab->currentElement;
#endif
if (wfield)
{
if (wfield) {
QFTELL(wfield->file, wfcurpos, wfield->filename);
wcurrentElement = (wtab->currentElement == 0) ? 1 : wtab->currentElement; // CFITSIO
}
#ifdef HAVE_CFITSIO
wcurrentElement = (wtab->currentElement == 0) ? 1 : wtab->currentElement;
#endif
}
/* Allocate a correct amount of memory to store pixels */
......@@ -183,10 +186,14 @@ 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);
currentElement2 = (tab->currentElement == 0) ? 1 : tab->currentElement; // CFITSIO
#ifdef HAVE_CFITSIO
currentElement2 = (tab->currentElement == 0) ? 1 : tab->currentElement;
#endif
if (wfield){
QFTELL(wfield->file, wfcurpos2, wfield->filename);
wcurrentElement2 = (wtab->currentElement == 0) ? 1 : wtab->currentElement; // CFITSIO
#ifdef HAVE_CFITSIO
wcurrentElement2 = (wtab->currentElement == 0) ? 1 : wtab->currentElement;
#endif
}
if (j == ny-1 && (n=field->height%field->backh))
{
......@@ -208,8 +215,9 @@ void makeback(picstruct *field, picstruct *wfield, int wscale_flag)
/*---- Read and skip, read and skip, etc... */
QFSEEK(field->file, bufshift*(OFF_T2)field->bytepix, SEEK_CUR,
field->filename);
tab->currentElement += bufshift; // CFITSIO
#ifdef HAVE_CFITSIO
tab->currentElement += bufshift;
#endif
buft = buf;
for (i=nlines; i--; buft += w)
{
......@@ -217,7 +225,9 @@ void makeback(picstruct *field, picstruct *wfield, int wscale_flag)
if (i) {
QFSEEK(field->file, jumpsize*(OFF_T2)field->bytepix, SEEK_CUR,
field->filename);
tab->currentElement += jumpsize; // CFITSIO
#ifdef HAVE_CFITSIO
tab->currentElement += jumpsize;
#endif
}
}
......@@ -226,8 +236,9 @@ void makeback(picstruct *field, picstruct *wfield, int wscale_flag)
/*------ Read and skip, read and skip, etc... now on the weight-map */
QFSEEK(wfield->file, bufshift*(OFF_T2)wfield->bytepix, SEEK_CUR,
wfield->filename);
wtab->currentElement += bufshift; // CFITSIO
#ifdef HAVE_CFITSIO
wtab->currentElement += bufshift;
#endif
wbuft = wbuf;
for (i=nlines; i--; wbuft += w)
{
......@@ -236,16 +247,18 @@ void makeback(picstruct *field, picstruct *wfield, int wscale_flag)
if (i){
QFSEEK(wfield->file, jumpsize*(OFF_T2)wfield->bytepix, SEEK_CUR,
wfield->filename);
wtab->currentElement += jumpsize; // CFITSIO
#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);
tab->currentElement = currentElement2; // CFITSIO
#ifdef HAVE_CFITSIO
tab->currentElement = currentElement2;
#endif
bm = backmesh;
for (m=nx; m--; bm++)
if (bm->mean <= -BIG)
......@@ -255,7 +268,9 @@ void makeback(picstruct *field, picstruct *wfield, int wscale_flag)
if (wfield)
{
QFSEEK(wfield->file, wfcurpos2, SEEK_SET, wfield->filename);
wtab->currentElement = wcurrentElement2; // CFITSIO
#ifdef HAVE_CFITSIO
wtab->currentElement = wcurrentElement2;
#endif
wbm = wbackmesh;
for (m=nx; m--; wbm++)
if (wbm->mean <= -BIG)
......@@ -310,10 +325,14 @@ void makeback(picstruct *field, picstruct *wfield, int wscale_flag)
/* Go back to the original position */
QFSEEK(field->file, fcurpos, SEEK_SET, field->filename);
tab->currentElement = currentElement; // CFITSIO
#ifdef HAVE_CFITSIO
tab->currentElement = currentElement;
#endif
if (wfield) {
QFSEEK(wfield->file, wfcurpos, SEEK_SET, wfield->filename);
wfield->tab->currentElement = wcurrentElement; // CFITSIO
#ifdef HAVE_CFITSIO
wfield->tab->currentElement = wcurrentElement;
#endif
}
/* Median-filter and check suitability of the background map */
......
......@@ -7,7 +7,7 @@
*
* This file part of: SExtractor
*
* Copyright: (C) 1993-2012 Emmanuel Bertin -- IAP/CNRS/UPMC
* Copyright: (C) 1993-2020 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: 12/07/2012
* Last modified: 23/09/2020
*
*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
......@@ -70,7 +70,10 @@ picstruct *newfield(char *filename, int flags, int ext)
field->cat = cat;
nok = 0;
tab = cat->tab;
if(tab->isTileCompressed) nok++;
#ifdef HAVE_CFITSIO
if (tab->isTileCompressed)
nok++;
#endif
if (tab->naxis >= 2
&& strncmp(tab->xtension, "BINTABLE", 8)
&& strncmp(tab->xtension, "ASCTABLE", 8))
......@@ -79,7 +82,10 @@ picstruct *newfield(char *filename, int flags, int ext)
for (ntab=cat->ntab; ext2-- && ntab--;)
{
tab=tab->nexttab;
if(tab->isTileCompressed) nok++;
#ifdef HAVE_CFITSIO
if (tab->isTileCompressed)
nok++;
#endif
if (tab->naxis >= 2
&& strncmp(tab->xtension, "BINTABLE", 8)
&& strncmp(tab->xtension, "ASCTABLE", 8))
......
......@@ -7,7 +7,7 @@
*
* This file part of: AstrOmatic FITS/LDAC library
*
* Copyright: (C) 1995-2010 IAP/CNRS/SorbonneU
* Copyright: (C) 1995-2020 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/2020
* Last modified: 26/08/2020
*
*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
......@@ -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 05/05/2001
VERSION 02/10/2017
***/
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,7 +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);
tab->currentElement = 1; // CFITSIO
#ifdef HAVE_CFITSIO
tab->currentElement = 1;
#endif
read_body(tab, (PIXTYPE *)tab->bodybuf, npix);
/*---- Apply pixel processing */
if (func)
......@@ -121,7 +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);
tab->currentElement = 1; // CFITSIO
#ifdef HAVE_CFITSIO
tab->currentElement = 1;
#endif
read_body(tab, buffer, spoonful/sizeof(PIXTYPE));
/*-- Apply pixel processing */
if (func)
......@@ -161,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/2012
VERSION 02/10/2017
***/
FLAGTYPE *alloc_ibody(tabstruct *tab,
void (*func)(FLAGTYPE *ptr, int npix))
......@@ -195,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)
......@@ -222,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)
......@@ -296,97 +314,77 @@ void free_body(tabstruct *tab)
return;
}
#ifdef HAVE_CFITSIO
void writeCfitsio(tabstruct *tab, size_t spoonful, void *cbufdata0) {
int status = 0; fits_write_img(tab->infptr, TFLOAT, tab->currentElement, spoonful, cbufdata0, &status);
if (status != 0) {
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;
}
void readTileCompressed(tabstruct *tab, size_t spoonful, double* 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 == 0) 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;
}
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);
#ifdef HAVE_CFITSIO
/******* readTileCompressed ***************************************************
*
* Function to read a chunk of a tile-compressed FITS image
*
***/
void readTileCompressed(tabstruct *tab, size_t spoonful, void *bufdata0) {
// report reading error
if (status != 0) {
int status, hdutype;
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
// 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;
void readSpoonful(tabstruct *tab, size_t spoonful, double* bufdata0, char* bufdata) {
#ifdef HAVE_CFITSIO
if(tab->isTileCompressed)
readTileCompressed(tab, spoonful, bufdata0);
else
#endif
QFREAD(bufdata, spoonful*tab->bytepix, tab->cat->file, tab->cat->filename);
}
// 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;
}
void writeSpoonful(tabstruct *tab, size_t spoonful, void *cbufdata0) {
#ifdef HAVE_CFITSIO
if (0 && tab->infptr != NULL)
writeCfitsio(tab, spoonful, cbufdata0);
else
#endif
QFWRITE(cbufdata0, spoonful * tab->bytepix, tab->cat->file, tab->cat->filename);
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)
......@@ -397,7 +395,7 @@ INPUT A pointer to the tab structure,
OUTPUT -.
NOTES .
AUTHOR E. Bertin (IAP)
VERSION 11/02/2020
VERSION 26/08/2020
***/
void read_body(tabstruct *tab, PIXTYPE *ptr, size_t size)
{
......@@ -416,18 +414,12 @@ 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;
// this cast from double to float loses precision
//bs = (PIXTYPE)tab->bscale;
//bz = (PIXTYPE)tab->bzero;
bs = tab->bscale;
bz = tab->bzero;
......@@ -445,8 +437,15 @@ void read_body(tabstruct *tab, PIXTYPE *ptr, size_t size)
if (spoonful>size)
spoonful = size;
bufdata = (char *)bufdata0;
readSpoonful(tab, spoonful, bufdata0, bufdata);
#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 // HAVE_CFITSIO
switch(tab->bitpix)
{
case BP_BYTE:
......@@ -483,8 +482,11 @@ void read_body(tabstruct *tab, PIXTYPE *ptr, size_t size)
break;
case BP_SHORT:
if (!tab->isTileCompressed)
#ifdef HAVE_CFITSIO
if (!tab->isTileCompressed && bswapflag)
#else
if (bswapflag)
#endif
swapbytes(bufdata, 2, spoonful);
if (blankflag)
{
......@@ -519,8 +521,11 @@ void read_body(tabstruct *tab, PIXTYPE *ptr, size_t size)
break;
case BP_LONG:
if (!tab->isTileCompressed)
#ifdef HAVE_CFITSIO
if (!tab->isTileCompressed && bswapflag)
#else
if (bswapflag)
#endif
swapbytes(bufdata, 4, spoonful);
if (blankflag)
{
......@@ -556,8 +561,11 @@ void read_body(tabstruct *tab, PIXTYPE *ptr, size_t size)
#ifdef HAVE_LONG_LONG_INT
case BP_LONGLONG:
if (!tab->isTileCompressed)
#ifdef HAVE_CFITSIO
if (!tab->isTileCompressed && bswapflag)
#else
if (bswapflag)
#endif
swapbytes(bufdata, 8, spoonful);
if (blankflag)
{
......@@ -592,8 +600,11 @@ void read_body(tabstruct *tab, PIXTYPE *ptr, size_t size)
break;
#endif
case BP_FLOAT:
if (!tab->isTileCompressed)
#ifdef HAVE_CFITSIO
if (!tab->isTileCompressed && bswapflag)
#else
if (bswapflag)
#endif
swapbytes(bufdata, 4, spoonful);
#pragma ivdep
for (i=spoonful; i--; bufdata += sizeof(float))
......@@ -603,8 +614,12 @@ void read_body(tabstruct *tab, PIXTYPE *ptr, size_t size)
case BP_DOUBLE:
if (bswapflag)
{
if (!tab->isTileCompressed)
#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))
......@@ -737,7 +752,7 @@ INPUT A pointer to the tab structure,
OUTPUT -.
NOTES .
AUTHOR E. Bertin (IAP)
VERSION 11/02/2020
VERSION 26/08/2020
***/
void read_ibody(tabstruct *tab, FLAGTYPE *ptr, size_t size)
{
......@@ -765,8 +780,15 @@ void read_ibody(tabstruct *tab, FLAGTYPE *ptr, size_t size)
if (spoonful>size)
spoonful = size;
bufdata = (char *)bufdata0;
readSpoonful(tab, spoonful, bufdata0, bufdata);
#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:
......@@ -776,8 +798,11 @@ void read_ibody(tabstruct *tab, FLAGTYPE *ptr, size_t size)
break;
case BP_SHORT:
if (!tab->isTileCompressed)
#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))
......@@ -785,8 +810,11 @@ void read_ibody(tabstruct *tab, FLAGTYPE *ptr, size_t size)
break;
case BP_LONG:
if (!tab->isTileCompressed)
#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))
......@@ -795,8 +823,11 @@ void read_ibody(tabstruct *tab, FLAGTYPE *ptr, size_t size)
#ifdef HAVE_LONG_LONG_INT
case BP_LONGLONG:
if (!tab->isTileCompressed)
#ifdef HAVE_CFITSIO
if (!tab->isTileCompressed && bswapflag)
#else
if (bswapflag)
#endif
swapbytes(bufdata, 8, spoonful);
#pragma ivdep
for (i=spoonful; i--; bufdata += sizeof(ULONGLONG))
......@@ -924,7 +955,7 @@ INPUT A pointer to the tab structure,
OUTPUT -.
NOTES .
AUTHOR E. Bertin (IAP)
VERSION 11/02/2020
VERSION 26/08/2020
***/
void write_body(tabstruct *tab, PIXTYPE *ptr, size_t size)
{
......@@ -1041,10 +1072,11 @@ void write_body(tabstruct *tab, PIXTYPE *ptr, size_t size)
for (i=spoonful; i--;)
*(bufdata++) = (*(ptr++)-bz)/bs;
// TODO not yet writing CFitsIO from SExtractor. CFITSIO - only perform byte-swap if we are NOT writing a tile-compressed format using cfitsio
// if (tab->infptr == NULL) // TODO
#ifdef HAVE_CFITSIO
if (!tab->infptr && bswapflag)
#else
if (bswapflag)
#endif
swapbytes(cbufdata0, 4, spoonful);
}
break;
......@@ -1066,7 +1098,60 @@ void write_body(tabstruct *tab, PIXTYPE *ptr, size_t size)
break;
}
writeSpoonful(tab, spoonful, cbufdata0);
#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;
......
......@@ -23,7 +23,7 @@
* along with AstrOmatic software.
* If not, see <http://www.gnu.org/licenses/>.
*
* Last modified: 15/07/2020
* Last modified: 26/08/2020
*
*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
......@@ -167,64 +167,33 @@ int close_cat(catstruct *cat)
return RETURN_OK;
}
int open_cfitsio(catstruct *cat)
{
#ifdef HAVE_CFITSIO
fitsfile *infptr;
int status;
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);
}
cat->tab->infptr = infptr;
return status;
#else
return 1;
#endif
}
#ifdef HAVE_CFITSIO
/****** close_cfitsio **************************************************************
int close_cfitsio(catstruct *cat)
Closes a file previously opened by cfitsio
***/
int close_cfitsio(fitsfile *infptr)
{
#ifdef HAVE_CFITSIO
int status = 0;
if (cat->tab->infptr) {
; fits_close_file(cat->tab->infptr, &status);
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: %s\n", cat->filename);
printf("ERROR could not close FITS file with cfitsio\n");
}
else {
cat->tab->infptr == NULL;
//printf("Successfully closed FITS file with cfitsio\n");
infptr == NULL;
}
}
return status;
#else
return 1;
#endif
else {
//printf("ERROR no cfitsio file to close\n");
}
}
#endif // HAVE_CFITSIO
void hdu_seek(tabstruct *tab) {
#ifdef HAVE_CFITSIO
if(!tab->infptr) {
tab->infptr = tab->prevtab->infptr;
}
int status = 0;
int hdutype;
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, tab->cat->filename);
if (tab->tabsize)
// IMPORTANT: moving to start of next header using fseek and cfitsio position rather than table size, as done previously
fseek(tab->cat->file, tab->infptr->Fptr->headstart[tab->hdunum], SEEK_SET);
#else
if (tab->tabsize)
QFSEEK(tab->cat->file, PADTOTAL(tab->tabsize), SEEK_CUR, tab->cat->filename);
#endif
}
/****** free_cat ***************************************************************
PROTO void free_cat(catstruct **cat, int ncat)
......@@ -382,9 +351,20 @@ int map_cat(catstruct *cat)
prevtab = NULL;
QCALLOC(tab, tabstruct, 1);
tab->cat = cat;
cat->tab = tab;
QFTELL(cat->file, tab->headpos, cat->filename);
open_cfitsio(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;
#endif // HAVE_CFITSIO
for (ntab=0; !get_head(tab); ntab++)
{
......@@ -392,19 +372,54 @@ int map_cat(catstruct *cat)
readbintabparam_head(tab);
QFTELL(cat->file, tab->bodypos, cat->filename);
tab->nseg = tab->seg = 1;
tab->hdunum = ntab + 1;
#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);
}
hdunum++;
#else
if (tab->tabsize)
QFSEEK(cat->file, PADTOTAL(tab->tabsize), SEEK_CUR, cat->filename);
#endif // HAVE_CFITSIO
if (prevtab)
{
tab->prevtab = prevtab;
prevtab->nexttab = tab;
}
else
cat->tab = tab;
prevtab = tab;
hdu_seek(tab);
QCALLOC(tab, tabstruct, 1);
tab->cat = 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)
......
......@@ -23,7 +23,7 @@
* along with AstrOmatic software.
* If not, see <http://www.gnu.org/licenses/>.
*
* Last modified: 11/02/2020
* Last modified: 26/08/2020
*
*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
......@@ -37,7 +37,7 @@
#endif
#ifdef HAVE_CFITSIO
#include FITSIO_H
#include CFITSIO_H
#endif
#define MAXCHARS 256 /* max. number of characters */
......@@ -185,8 +185,8 @@ typedef struct structtab
char *headbuf; /* buffer containing the header */
int headnblock; /* number of FITS blocks */
char *bodybuf; /* buffer containing the body */
OFF_T2 bodypos; /* position of the body in the file */
OFF_T2 headpos; /* position of the head in the file */
OFF_T2 bodypos; /* position of the body in the file */
OFF_T2 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 */
......@@ -196,14 +196,12 @@ typedef struct structtab
int swapflag; /* mapped to a swap file ? */
char swapname[MAXCHARS]; /* name of the swapfile */
unsigned int bodysum; /* Checksum of the FITS body */
#ifdef HAVE_CFITSIO
fitsfile *infptr; /* a cfitsio pointer to the file */
#endif
int hdunum; /* FITS HDU number for this 'table' */
int isTileCompressed; /* is this a tile compressed image? */
long currentElement; /* tracks the current image pixel */
#endif
} tabstruct;
......@@ -231,8 +229,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),
......@@ -284,7 +282,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),
close_cfitsio(catstruct *cat),
#ifdef HAVE_CFITSIO
close_cfitsio(fitsfile *infptr),
#endif
copy_key(tabstruct *tabin, char *keyname, tabstruct *tabout,
int pos),
copy_tab(catstruct *catin, char *tabname, int seg,
......@@ -342,8 +342,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
......@@ -7,7 +7,7 @@
*
* This file part of: AstrOmatic FITS/LDAC library
*
* Copyright: (C) 1995-2012 Emmanuel Bertin -- IAP/CNRS/UPMC
* Copyright: (C) 1995-2019 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: 29/08/2012
* Last modified: 04/12/2019
*
*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
......@@ -101,51 +101,38 @@ INPUT pointer to catstruct.
OUTPUT -.
NOTES -.
AUTHOR E. Bertin (IAP)
VERSION 03/06/2012
VERSION 04/12/2019
***/
void readbasic_head(tabstruct *tab)
{
char str[88];
char key[12], name[16],
char key[12], name[16], bitpix_key[16], naxis_key[16],
*filename;
int i;
KINGSIZE_T tabsize;
filename = (tab->cat? tab->cat->filename : strcpy(name, "internal header"));
// CFITSIO
char NAXIS_KEYWORD[14];
char BITPIX_KEYWORD[14];
if (fitsread(tab->headbuf, "ZIMAGE ", str, H_STRING, T_STRING) == RETURN_OK) {
tab->isTileCompressed = 1;
#ifndef HAVE_CFITSIO
error(EXIT_FAILURE, "*Error*: No CFITSIO support but detected tile compression in ", filename);
#endif
strcpy(NAXIS_KEYWORD, "ZNAXIS ");
strcpy(BITPIX_KEYWORD, "ZBITPIX ");
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);
}
else {
tab->isTileCompressed = 0;
strcpy(NAXIS_KEYWORD, "NAXIS ");
strcpy(BITPIX_KEYWORD, "BITPIX ");
}
if (fitsread(tab->headbuf, BITPIX_KEYWORD, &tab->bitpix, H_INT, T_LONG)
#endif
if (fitsread(tab->headbuf, bitpix_key, &tab->bitpix, 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);
if (fitsread(tab->headbuf, NAXIS_KEYWORD, &tab->naxis, H_INT, T_LONG)
==RETURN_ERROR) {
if (fitsread(tab->headbuf, naxis_key, &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)
{
......@@ -155,11 +142,12 @@ void readbasic_head(tabstruct *tab)
tabsize = 1;
for (i=0; i<tab->naxis && i<999; i++)
{
// CFITSIO
#ifdef HAVE_CFITSIO
if (tab->isTileCompressed)
sprintf(key,"ZNAXIS%-2d", (i+1));
sprintf(key,"ZNAXIS%-2d", i+1);
else
sprintf(key,"NAXIS%-3d", (i+1));
#endif
sprintf(key,"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);
......@@ -171,8 +159,11 @@ void readbasic_head(tabstruct *tab)
tab->pcount = 0;
fitsread(tab->headbuf, "PCOUNT ", &tab->pcount, H_INT, T_LONG);
#ifdef HAVE_CFITSIO
// CFITSIO TODO HACK
if (tab->isTileCompressed) tab->pcount = 0;
if (tab->isTileCompressed)
tab->pcount = 0;
#endif
tab->gcount = 1;
fitsread(tab->headbuf, "GCOUNT ", &tab->gcount, H_INT, T_LONG);
......@@ -314,9 +305,12 @@ int readbintabparam_head(tabstruct *tab)
key->htype = H_STRING;
break;
default:
#ifdef HAVE_CFITSIO
// CFITSIO TODO dodgy
key->ttype = T_FLOAT;
//error(EXIT_FAILURE, "*Error*: Unknown TFORM in ", cat->filename);
#else
error(EXIT_FAILURE, "*Error*: Unknown TFORM in ", cat->filename);
#endif
}
/*--handle the special case of multimensional arrays*/
......
......@@ -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;
}
......@@ -23,7 +23,7 @@
* along with AstrOmatic software.
* If not, see <http://www.gnu.org/licenses/>.
*
* Last modified: 09/10/2010
* Last modified: 20/11/2013
*
*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
......@@ -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;
......
......@@ -23,7 +23,7 @@
* along with AstrOmatic software.
* If not, see <http://www.gnu.org/licenses/>.
*
* Last modified: 11/02/2020
* Last modified: 26/08/2020
*
*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
......@@ -359,7 +359,7 @@ 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)
......
......@@ -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: 23/09/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);
......
......@@ -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: 23/09/2020
*
*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
......@@ -282,8 +282,10 @@ void makeit()
if ((imatab->naxis < 2)
|| !strncmp(imatab->xtension, "BINTABLE", 8)
|| !strncmp(imatab->xtension, "ASCTABLE", 8))
if (!imatab->isTileCompressed)
continue;
#ifdef HAVE_CFITSIO
if (!imatab->isTileCompressed)
#endif
continue;
next++;
}
}
......@@ -322,9 +324,10 @@ void makeit()
if (!forcextflag && ((imatab->naxis < 2)
|| !strncmp(imatab->xtension, "BINTABLE", 8)
|| !strncmp(imatab->xtension, "ASCTABLE", 8)))
if (!imatab->isTileCompressed)
#ifdef HAVE_CFITSIO
if (!imatab->isTileCompressed)
#endif
continue;
nok++;
/*-- Initial time measurement*/
......@@ -709,7 +712,7 @@ 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 08/10/2007
VERSION 23/09/2020
***/
static int selectext(char *filename)
{
......@@ -724,7 +727,8 @@ static int selectext(char *filename)
next = strtol(bracl+1, NULL, 0);
// VERY BAD HACK to check if this is tile-compressed, if so, add +1 to extension number requested
if (strstr(filename, ".fits.fz") != NULL) next = next + 1;
if (strstr(filename, ".fits.fz") != NULL)
next++;
return next;
}
......@@ -741,9 +745,9 @@ INPUT a character string,
OUTPUT RETURN_OK if everything went fine, RETURN_ERROR otherwise.
NOTES -.
AUTHOR E. Bertin (IAP)
VERSION 14/07/2006
VERSION 23/09/2020
***/
void write_error(char *msg1, char *msg2)
void write_error(const char *msg1, const char *msg2)
{
char error[MAXCHAR];
......
......@@ -7,7 +7,7 @@
*
* This file part of: SExtractor
*
* Copyright: (C) 1993-2015 Emmanuel Bertin -- IAP/CNRS/UPMC
* Copyright: (C) 1993-2020 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: 14/01/2015
* Last modified: 23/09/2020
*
*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
......@@ -94,10 +94,10 @@ void *loadstrip(picstruct *field, picstruct *wfield)
copydata(field, 0, nbpix);
else
{
#ifdef HAVE_CFITSIO
tab->currentElement = 1;
#endif
read_body(tab, data, nbpix);
//printf("read 1: data[0] = %f %f %f %f %f %f\n", data[0], data[1], data[222], data[777], data[field->width-1], data[nbpix-1]);
}
if (flags & (WEIGHT_FIELD|RMS_FIELD|BACKRMS_FIELD|VAR_FIELD))
weight_to_var(field, data, nbpix);
......@@ -203,12 +203,8 @@ void *loadstrip(picstruct *field, picstruct *wfield)
backrmsline(field, field->ymax, data);
else if (flags & INTERP_FIELD)
copydata(field, field->stripylim*w, w);
else {
else
read_body(tab, data, w);
//printf("read 2: data[0] = %f %f %f %f %f %f\n", data[0], data[1], data[222], data[777], data[field->width-1], data[w-1]);
}
if (flags & (WEIGHT_FIELD|RMS_FIELD|BACKRMS_FIELD|VAR_FIELD))
weight_to_var(field, data, w);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment