Unverified Commit b2cfd631 authored by Emmanuel Bertin's avatar Emmanuel Bertin Committed by GitHub
Browse files

Merge pull request #10 from teake/teake/merge-roy

Rice compression support
parents 33253012 a7f2fe76
Loading
Loading
Loading
Loading
+29 −0
Original line number Original line Diff line number Diff line
@@ -53,6 +53,7 @@ sinclude(acx_atlas.m4)
sinclude(acx_openblas.m4)
sinclude(acx_openblas.m4)
sinclude(acx_fftw.m4)
sinclude(acx_fftw.m4)
sinclude(acx_mkl.m4)
sinclude(acx_mkl.m4)
sinclude(acx_cfitsio.m4)
sinclude(acx_prog_cc_optim.m4)
sinclude(acx_prog_cc_optim.m4)
sinclude(acx_pthread.m4)
sinclude(acx_pthread.m4)
sinclude(acx_urbi_resolve_dir.m4)
sinclude(acx_urbi_resolve_dir.m4)
@@ -180,6 +181,20 @@ AC_ARG_WITH(openblas-incdir,
	[AS_HELP_STRING([--with-openblas-incdir=<OpenBLAS header dir>],
	[AS_HELP_STRING([--with-openblas-incdir=<OpenBLAS header dir>],
	[Provide an alternative path to the OpenBLAS header directory])])
	[Provide an alternative path to the OpenBLAS header directory])])


# Provide special option for CFITSIO
AC_MSG_CHECKING([whether CFITSIO support is 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]),
	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])])

# Provide a special option for the default XSLT URL
# Provide a special option for the default XSLT URL
with_xsl_url="file://"$(URBI_RESOLVE_DIR([$datadir]))"/$PACKAGE_TARNAME/$PACKAGE_TARNAME.xsl"
with_xsl_url="file://"$(URBI_RESOLVE_DIR([$datadir]))"/$PACKAGE_TARNAME/$PACKAGE_TARNAME.xsl"
AC_ARG_WITH(xsl_url,
AC_ARG_WITH(xsl_url,
@@ -305,6 +320,20 @@ if test "$enable_model_fitting" != "no"; then
  fi
  fi
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.])
    )
])

AM_CONDITIONAL(USE_MODEL, [test "$enable_model_fitting" != "no"])
AM_CONDITIONAL(USE_MODEL, [test "$enable_model_fitting" != "no"])


# Compile with profiling option
# Compile with profiling option

m4/acx_cfitsio.m4

0 → 100644
+121 −0
Original line number Original line Diff line number Diff line
dnl
dnl				acx_cfitsio.m4
dnl
dnl Figure out if the CFITSIO library and header files are installed.
dnl
dnl %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
dnl
dnl	This file part of:	AstrOmatic software
dnl
dnl	Copyright:		(C) 2019 IAP/CNRS/UPMC
dnl
dnl	License:		GNU General Public License
dnl
dnl	AstrOmatic software is free software: you can redistribute it and/or
dnl	modify it under the terms of the GNU General Public License as
dnl	published by the Free Software Foundation, either version 3 of the
dnl	License, or (at your option) any later version.
dnl	AstrOmatic software is distributed in the hope that it will be useful,
dnl	but WITHOUT ANY WARRANTY; without even the implied warranty of
dnl	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
dnl	GNU General Public License for more details.
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
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
dnl        LIBS="$CFITSIO_LIBS $LIBS"
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 a list of commands to run it if it is not found.

AC_DEFUN([ACX_CFITSIO], [
AC_REQUIRE([AC_CANONICAL_HOST])

dnl --------------------
dnl Search include files
dnl --------------------

CFITSIO_ERROR=""
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!"]
      )
    ]
  )
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"!"]
    )]
  )
fi

if test "x$CFITSIO_ERROR" = "x"; then
  AC_DEFINE_UNQUOTED(FITSIO_H, "${acx_cfitsio_incdir}fitsio.h", [CFITSIO header filename.])

dnl ----------------------------
dnl Search CFITSIO library file
dnl ----------------------------

  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$1 = x; then
    acx_cfitsio_libopt=""
  else
    acx_cfitsio_libopt="-L$1"
  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, "")
  AC_SUBST(CFITSIO_LIBS)
  AC_SUBST(CFITSIO_WARN)
  $5
else
  AC_SUBST(CFITSIO_ERROR)
  $6
fi

])dnl ACX_CFITSIO
+4 −5
Original line number Original line Diff line number Diff line
@@ -7,7 +7,7 @@
*
*
*	This file part of:	SExtractor
*	This file part of:	SExtractor
*
*
*	Copyright:		(C) 1993-2016 IAP/CNRS/UPMC
*	Copyright:		(C) 1993-2016 Emmanuel Bertin -- IAP/CNRS/UPMC
*
*
*	License:		GNU General Public License
*	License:		GNU General Public License
*
*
@@ -280,8 +280,7 @@ void examineiso(picstruct *field, picstruct *dfield, objstruct *obj,
    emy2 /= flux2;	/* variance of ym */
    emy2 /= flux2;	/* variance of ym */
    emxy /= flux2;	/* covariance */
    emxy /= flux2;	/* covariance */


/*-- Handle fully correlated profile
/*-- Handle fully correlated profiles (which cause a singularity...) */
s (which cause a singularity...) */
    esum *= 0.08333/flux2;
    esum *= 0.08333/flux2;
    if (obj->singuflag && (emx2*emy2-emxy*emxy) < esum*esum)
    if (obj->singuflag && (emx2*emy2-emxy*emxy) < esum*esum)
      {
      {
+44 −15
Original line number Original line Diff line number Diff line
@@ -52,8 +52,10 @@ void makeback(picstruct *field, picstruct *wfield, int wscale_flag)


  {
  {
   backstruct	*backmesh,*wbackmesh, *bm,*wbm;
   backstruct	*backmesh,*wbackmesh, *bm,*wbm;
   tabstruct	*tab, *wtab;
   PIXTYPE	*buf,*wbuf, *buft,*wbuft;
   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_t	bufsize, bufsize2,
		size,meshsize;
		size,meshsize;
   int		i,j,k,m,n, step, nlines,
   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 the weight-map is not an external one, no stats are needed for it */
  if (wfield && wfield->flags&(INTERP_FIELD|BACKRMS_FIELD))
  if (wfield && wfield->flags&(INTERP_FIELD|BACKRMS_FIELD))
    wfield= NULL;
    wfield= NULL;

  tab = field->tab;
  if (wfield)
    wtab = wfield->tab;
  else
    wtab = NULL;	/* to avoid gcc -Wall warnings */
  w = field->width;
  w = field->width;
  bw = field->backw;
  bw = field->backw;
  bh = field->backh;
  bh = field->backh;
@@ -83,12 +89,17 @@ void makeback(picstruct *field, picstruct *wfield, int wscale_flag)


  wfcurpos = wfcurpos2 = 0;		/* to avoid gcc -Wall warnings */
  wfcurpos = wfcurpos2 = 0;		/* to avoid gcc -Wall warnings */
  QFTELL(field->file, fcurpos, field->filename);
  QFTELL(field->file, fcurpos, field->filename);
  currentElement = (tab->currentElement == 0) ? 1 : tab->currentElement; // CFITSIO

  if (wfield)
  if (wfield)
    {
    QFTELL(wfield->file, wfcurpos, wfield->filename);
    QFTELL(wfield->file, wfcurpos, wfield->filename);
    wcurrentElement = (wtab->currentElement == 0) ? 1 : wtab->currentElement; // CFITSIO
    }


/* Allocate a correct amount of memory to store pixels */
/* Allocate a correct amount of memory to store pixels */


  bufsize = (OFF_T)w*bh;
  bufsize = (OFF_T2)w*bh;
  meshsize = (size_t)bufsize;
  meshsize = (size_t)bufsize;
  nlines = 0;
  nlines = 0;
  if (bufsize > (size_t)BACK_BUFSIZE)
  if (bufsize > (size_t)BACK_BUFSIZE)
@@ -96,8 +107,8 @@ void makeback(picstruct *field, picstruct *wfield, int wscale_flag)
    nlines = BACK_BUFSIZE/w;
    nlines = BACK_BUFSIZE/w;
    step = (field->backh-1)/nlines+1;
    step = (field->backh-1)/nlines+1;
    bufsize = (size_t)(nlines = field->backh/step)*w;
    bufsize = (size_t)(nlines = field->backh/step)*w;
    bufshift = (step/2)*(OFF_T)w;
    bufshift = (step/2)*(OFF_T2)w;
    jumpsize = (step-1)*(OFF_T)w;
    jumpsize = (step-1)*(OFF_T2)w;
    }
    }
  else
  else
    bufshift = jumpsize = 0;		/* to avoid gcc -Wall warnings */
    bufshift = jumpsize = 0;		/* to avoid gcc -Wall warnings */
@@ -172,16 +183,19 @@ void makeback(picstruct *field, picstruct *wfield, int wscale_flag)
      {
      {
/*---- Image size too big, we have to skip a few data !*/
/*---- Image size too big, we have to skip a few data !*/
      QFTELL(field->file, fcurpos2, field->filename);
      QFTELL(field->file, fcurpos2, field->filename);
      if (wfield)
      currentElement2 = (tab->currentElement == 0) ? 1 : tab->currentElement; // CFITSIO
      if (wfield){
        QFTELL(wfield->file, wfcurpos2, wfield->filename);
        QFTELL(wfield->file, wfcurpos2, wfield->filename);
        wcurrentElement2 = (wtab->currentElement == 0) ? 1 : wtab->currentElement; // CFITSIO
      }
      if (j == ny-1 && (n=field->height%field->backh))
      if (j == ny-1 && (n=field->height%field->backh))
        {
        {
        meshsize = n*(size_t)w;
        meshsize = n*(size_t)w;
        nlines = BACK_BUFSIZE/w;
        nlines = BACK_BUFSIZE/w;
        step = (n-1)/nlines+1;
        step = (n-1)/nlines+1;
        bufsize = (nlines = n/step)*(size_t)w;
        bufsize = (nlines = n/step)*(size_t)w;
        bufshift = (step/2)*(OFF_T)w;
        bufshift = (step/2)*(OFF_T2)w;
        jumpsize = (step-1)*(OFF_T)w;
        jumpsize = (step-1)*(OFF_T2)w;
        free(buf);
        free(buf);
        QMALLOC(buf, PIXTYPE, bufsize);		/* pixel buffer */
        QMALLOC(buf, PIXTYPE, bufsize);		/* pixel buffer */
        if (wfield)
        if (wfield)
@@ -192,35 +206,46 @@ void makeback(picstruct *field, picstruct *wfield, int wscale_flag)
        }
        }


/*---- Read and skip, read and skip, etc... */
/*---- Read and skip, read and skip, etc... */
      QFSEEK(field->file, bufshift*(OFF_T)field->bytepix, SEEK_CUR,
      QFSEEK(field->file, bufshift*(OFF_T2)field->bytepix, SEEK_CUR,
		field->filename);
		field->filename);
      tab->currentElement += bufshift; // CFITSIO

      buft = buf;
      buft = buf;
      for (i=nlines; i--; buft += w)
      for (i=nlines; i--; buft += w)
        {
        {
        read_body(field->tab, buft, w);
        read_body(field->tab, buft, w);
        if (i)
        if (i) {
          QFSEEK(field->file, jumpsize*(OFF_T)field->bytepix, SEEK_CUR,
          QFSEEK(field->file, jumpsize*(OFF_T2)field->bytepix, SEEK_CUR,
		field->filename);
		field->filename);
          tab->currentElement += jumpsize; // CFITSIO
        }
        }
        }


      if (wfield)
      if (wfield)
        {
        {
/*------ Read and skip, read and skip, etc... now on the weight-map */
/*------ 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_T2)wfield->bytepix, SEEK_CUR,
		wfield->filename);
		wfield->filename);
        wtab->currentElement += bufshift; // CFITSIO

        wbuft = wbuf;
        wbuft = wbuf;
        for (i=nlines; i--; wbuft += w)
        for (i=nlines; i--; wbuft += w)
          {
          {
          read_body(wfield->tab, wbuft, w);
          read_body(wfield->tab, wbuft, w);
          weight_to_var(wfield, wbuft, w);
          weight_to_var(wfield, wbuft, w);
          if (i)
          if (i){
            QFSEEK(wfield->file, jumpsize*(OFF_T)wfield->bytepix, SEEK_CUR,
            QFSEEK(wfield->file, jumpsize*(OFF_T2)wfield->bytepix, SEEK_CUR,
		wfield->filename);
		wfield->filename);
            wtab->currentElement += jumpsize; // CFITSIO

          }
          }
          }
        }
        }
      backstat(backmesh, wbackmesh, buf, wbuf, bufsize, nx, w, bw,
      backstat(backmesh, wbackmesh, buf, wbuf, bufsize, nx, w, bw,
	wfield?wfield->weight_thresh:0.0);
	wfield?wfield->weight_thresh:0.0);
      QFSEEK(field->file, fcurpos2, SEEK_SET, field->filename);
      QFSEEK(field->file, fcurpos2, SEEK_SET, field->filename);
      tab->currentElement = currentElement2; // CFITSIO

      bm = backmesh;
      bm = backmesh;
      for (m=nx; m--; bm++)
      for (m=nx; m--; bm++)
        if (bm->mean <= -BIG)
        if (bm->mean <= -BIG)
@@ -230,6 +255,7 @@ void makeback(picstruct *field, picstruct *wfield, int wscale_flag)
      if (wfield)
      if (wfield)
        {
        {
        QFSEEK(wfield->file, wfcurpos2, SEEK_SET, wfield->filename);
        QFSEEK(wfield->file, wfcurpos2, SEEK_SET, wfield->filename);
        wtab->currentElement = wcurrentElement2; // CFITSIO
        wbm = wbackmesh;
        wbm = wbackmesh;
        for (m=nx; m--; wbm++)
        for (m=nx; m--; wbm++)
          if (wbm->mean <= -BIG)
          if (wbm->mean <= -BIG)
@@ -284,8 +310,11 @@ void makeback(picstruct *field, picstruct *wfield, int wscale_flag)


/* Go back to the original position */
/* Go back to the original position */
  QFSEEK(field->file, fcurpos, SEEK_SET, field->filename);
  QFSEEK(field->file, fcurpos, SEEK_SET, field->filename);
  if (wfield)
  tab->currentElement = currentElement; // CFITSIO
  if (wfield) {
    QFSEEK(wfield->file, wfcurpos, SEEK_SET, wfield->filename);
    QFSEEK(wfield->file, wfcurpos, SEEK_SET, wfield->filename);
    wfield->tab->currentElement =  wcurrentElement; // CFITSIO
  }


/* Median-filter and check suitability of the background map */
/* Median-filter and check suitability of the background map */
  NFPRINTF(OUTPUT, "Filtering background map(s)");
  NFPRINTF(OUTPUT, "Filtering background map(s)");
+1 −2
Original line number Original line Diff line number Diff line
@@ -1059,7 +1059,7 @@ void reendcat()
  {
  {
   keystruct	*key;
   keystruct	*key;
   tabstruct	*tab;
   tabstruct	*tab;
   OFF_T	pos;
   OFF_T2	pos;
   char		*head;
   char		*head;


  switch(prefs.cat_type)
  switch(prefs.cat_type)
@@ -1127,4 +1127,3 @@ void zerocat(void)
  }
  }


Loading