From dd49b374edd1d3a889e74feeb44016f3d542105a Mon Sep 17 00:00:00 2001 From: Emmanuel Bertin Date: Fri, 9 Oct 2009 16:21:18 +0000 Subject: [PATCH] Improved the quality of model resampling for subsampled objects. Implemented a more consistent model size and flux scaling scheme for subsampled objects. Fixed Sersic model generation bug. Pushed version number to 2.9.6. --- configure | 20 ++++++------- configure.ac | 2 +- man/sex.1 | 2 +- src/profit.c | 82 +++++++++++++++++++++++++++++++++++----------------- src/profit.h | 6 ++-- 5 files changed, 70 insertions(+), 42 deletions(-) diff --git a/configure b/configure index eba3cb2..3d65a47 100755 --- a/configure +++ b/configure @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.63 for sextractor 2.9.5. +# Generated by GNU Autoconf 2.63 for sextractor 2.9.6. # # Report bugs to . # @@ -750,8 +750,8 @@ SHELL=${CONFIG_SHELL-/bin/sh} # Identity of this package. PACKAGE_NAME='sextractor' PACKAGE_TARNAME='sextractor' -PACKAGE_VERSION='2.9.5' -PACKAGE_STRING='sextractor 2.9.5' +PACKAGE_VERSION='2.9.6' +PACKAGE_STRING='sextractor 2.9.6' PACKAGE_BUGREPORT='bertin@iap.fr' ac_unique_file="src/makeit.c" @@ -1505,7 +1505,7 @@ if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures sextractor 2.9.5 to adapt to many kinds of systems. +\`configure' configures sextractor 2.9.6 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1575,7 +1575,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of sextractor 2.9.5:";; + short | recursive ) echo "Configuration of sextractor 2.9.6:";; esac cat <<\_ACEOF @@ -1706,7 +1706,7 @@ fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -sextractor configure 2.9.5 +sextractor configure 2.9.6 generated by GNU Autoconf 2.63 Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, @@ -1720,7 +1720,7 @@ cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by sextractor $as_me 2.9.5, which was +It was created by sextractor $as_me 2.9.6, which was generated by GNU Autoconf 2.63. Invocation command line was $ $0 $@ @@ -2423,7 +2423,7 @@ fi # Define the identity of the package. PACKAGE='sextractor' - VERSION='2.9.5' + VERSION='2.9.6' cat >>confdefs.h <<_ACEOF @@ -28291,7 +28291,7 @@ exec 6>&1 # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by sextractor $as_me 2.9.5, which was +This file was extended by sextractor $as_me 2.9.6, which was generated by GNU Autoconf 2.63. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -28354,7 +28354,7 @@ Report bugs to ." _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_version="\\ -sextractor config.status 2.9.5 +sextractor config.status 2.9.6 configured by $0, generated by GNU Autoconf 2.63, with options \\"`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`\\" diff --git a/configure.ac b/configure.ac index 2bf4d8d..9a0da6f 100644 --- a/configure.ac +++ b/configure.ac @@ -6,7 +6,7 @@ define([AC_CACHE_LOAD],) define([AC_CACHE_SAVE],) # This is your standard Bertin source code... -AC_INIT(sextractor, 2.9.5, [bertin@iap.fr]) +AC_INIT(sextractor, 2.9.6, [bertin@iap.fr]) AC_CONFIG_SRCDIR(src/makeit.c) AC_CONFIG_AUX_DIR(autoconf) AM_CONFIG_HEADER(config.h) diff --git a/man/sex.1 b/man/sex.1 index 28249e8..bc587c8 100644 --- a/man/sex.1 +++ b/man/sex.1 @@ -1,4 +1,4 @@ -.TH SEXTRACTOR "1" "October 2009" "SWarp 2.9.5" "User Commands" +.TH SEXTRACTOR "1" "October 2009" "SWarp 2.9.6" "User Commands" .SH NAME sex \- extract a source catalog from an astronomical FITS image .SH SYNOPSIS diff --git a/src/profit.c b/src/profit.c index ca0f2d7..43fe51d 100644 --- a/src/profit.c +++ b/src/profit.c @@ -9,7 +9,7 @@ * * Contents: Fit an arbitrary profile combination to a detection. * -* Last modify: 06/10/2009 +* Last modify: 09/10/2009 * *%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% */ @@ -173,7 +173,7 @@ OUTPUT Pointer to an allocated fit structure (containing details about the fit). NOTES It is a modified version of the lm_minimize() of lmfit. AUTHOR E. Bertin (IAP) -VERSION 06/10/2009 +VERSION 09/10/2009 ***/ void profit_fit(profitstruct *profit, picstruct *field, picstruct *wfield, @@ -217,13 +217,14 @@ void profit_fit(profitstruct *profit, profit->objnaxisn[0] = profit->objnaxisn[1]; if (profit->objnaxisn[0]>PROFIT_MAXOBJSIZE) { - profit->nsubsamp = ceil((float)profit->objnaxisn[0]/PROFIT_MAXOBJSIZE); - profit->objnaxisn[1] = (profit->objnaxisn[0] /= (int)profit->nsubsamp); - profit->pixstep *= profit->nsubsamp; + profit->subsamp = ceil((float)profit->objnaxisn[0]/PROFIT_MAXOBJSIZE); +// profit->fluxfac *= profit->subsamp*profit->subsamp; + profit->objnaxisn[1] = (profit->objnaxisn[0] /= (int)profit->subsamp); +// profit->pixstep *= profit->subsamp; obj2->prof_flag |= PROFLAG_OBJSUB; } else - profit->nsubsamp = 1.0; + profit->subsamp = 1.0; /* Use (dirty) global variables to interface with lmfit */ the_field = field; @@ -257,9 +258,11 @@ void profit_fit(profitstruct *profit, /* Create pixmap at PSF resolution */ profit->modnaxisn[0] = - ((int)(profit->objnaxisn[0]/profit->pixstep +0.4999)/2+1)*2; + ((int)(profit->objnaxisn[0]*profit->subsamp/profit->pixstep + +0.4999)/2+1)*2; profit->modnaxisn[1] = - ((int)(profit->objnaxisn[1]/profit->pixstep +0.4999)/2+1)*2; + ((int)(profit->objnaxisn[1]*profit->subsamp/profit->pixstep + +0.4999)/2+1)*2; if (profit->modnaxisn[1] < profit->modnaxisn[0]) profit->modnaxisn[1] = profit->modnaxisn[0]; else @@ -1101,7 +1104,7 @@ INPUT Profile-fitting structure. OUTPUT -. NOTES -. AUTHOR E. Bertin (IAP) -VERSION 07/09/2009 +VERSION 09/10/2009 ***/ void profit_resample(profitstruct *profit, float *inpix, PIXTYPE *outpix, float factor) @@ -1109,8 +1112,8 @@ void profit_resample(profitstruct *profit, float *inpix, PIXTYPE *outpix, double flux; float posin[2], posout[2], dnaxisn[2], *dx,*dy, - xcout,ycout, xcin,ycin, invpixstep; - int d,i; + xcout,ycout, xcin,ycin, invpixstep, pix, off,step; + int d,i, ix,iy,ns; xcout = (float)(profit->objnaxisn[0]/2) + 1.0; /* FITS convention */ if ((dx=(profit->paramlist[PARAM_X]))) @@ -1120,7 +1123,7 @@ void profit_resample(profitstruct *profit, float *inpix, PIXTYPE *outpix, ycout += *dy; xcin = (profit->modnaxisn[0]/2) + 1.0; /* FITS convention */ ycin = (profit->modnaxisn[1]/2) + 1.0; /* FITS convention */ - invpixstep = 1.0/profit->pixstep; + invpixstep = profit->subsamp/profit->pixstep; /* Initialize multi-dimensional counters */ for (d=0; d<2; d++) @@ -1129,20 +1132,45 @@ void profit_resample(profitstruct *profit, float *inpix, PIXTYPE *outpix, dnaxisn[d] = profit->objnaxisn[d]+0.5; } -/* Remap each pixel */ +/* Remap each pixel (and rebin if necessary) */ flux = 0.0; - for (i=profit->objnaxisn[0]*profit->objnaxisn[1]; i--;) - { - posin[0] = (posout[0] - xcout)*invpixstep + xcin; - posin[1] = (posout[1] - ycout)*invpixstep + ycin; - flux += ((*(outpix++) = (PIXTYPE)(factor*interpolate_pix(posin, inpix, - profit->modnaxisn, INTERP_LANCZOS3)))); - for (d=0; d<2; d++) - if ((posout[d]+=1.0) < dnaxisn[d]) - break; - else - posout[d] = 1.0; + ns=(int)profit->subsamp; + if (ns>1) + { + step = 1.0/profit->subsamp; + off = 0.5*(step - 1.0); + xcin += off; + ycin += off; + for (i=profit->objnaxisn[0]*profit->objnaxisn[1]; i--;) + { + posin[0] = (posout[0] - xcout)*invpixstep + xcin; + posin[1] = (posout[1] - ycout)*invpixstep + ycin; + pix = 0.0; + for (iy=ns; iy--; posin[1] += step) + for (ix=ns; ix--; posin[0] += step) + pix += (PIXTYPE)(factor*interpolate_pix(posin, inpix, + profit->modnaxisn, INTERP_LANCZOS3)); + flux += (*(outpix++) = pix); + for (d=0; d<2; d++) + if ((posout[d]+=1.0) < dnaxisn[d]) + break; + else + posout[d] = 1.0; + } } + else + for (i=profit->objnaxisn[0]*profit->objnaxisn[1]; i--;) + { + posin[0] = (posout[0] - xcout)*invpixstep + xcin; + posin[1] = (posout[1] - ycout)*invpixstep + ycin; + flux += ((*(outpix++) = (PIXTYPE)(factor*interpolate_pix(posin, inpix, + profit->modnaxisn, INTERP_LANCZOS3)))); + for (d=0; d<2; d++) + if ((posout[d]+=1.0) < dnaxisn[d]) + break; + else + posout[d] = 1.0; + } return; } @@ -1320,7 +1348,7 @@ int profit_copyobjpix(profitstruct *profit, picstruct *field, return 0; backnoise2 = field->backsig*field->backsig; - sn = (int)profit->nsubsamp; + sn = (int)profit->subsamp; sflag = (sn>1); w = profit->objnaxisn[0]*sn; h = profit->objnaxisn[1]*sn; @@ -2399,7 +2427,7 @@ INPUT Profile structure, OUTPUT Corrected flux contribution. NOTES -. AUTHOR E. Bertin (IAP) -VERSION 08/10/2009 +VERSION 09/10/2009 ***/ float prof_add(profstruct *prof, profitstruct *profit) { @@ -2518,7 +2546,7 @@ float prof_add(profstruct *prof, profitstruct *profit) /*---- Copy the symmetric part */ if ((npix2=(profit->modnaxisn[1]-nx2)*profit->modnaxisn[0]) > 0) { - pixin2 = pixin - profit->modnaxisn[0] - 1; + pixin2 = pixin - profit->modnaxisn[0]; for (i=npix2; i--;) *(pixin++) = *(pixin2--); } diff --git a/src/profit.h b/src/profit.h index 04e2caf..5bf3945 100644 --- a/src/profit.h +++ b/src/profit.h @@ -9,7 +9,7 @@ * * Contents: Include file for profit.c. * -* Last modify: 07/10/2009 +* Last modify: 09/10/2009 * *%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% */ @@ -36,7 +36,7 @@ #define PROFIT_HIDEFRES 201 /* Resolution of the high def. model raster */ #define PROFIT_REFFFAC 6.0 /* Factor in r_eff for measurement radius*/ #define PROFIT_DYNPARAM 10.0 /* Dynamic compression param. in sigma units */ -#define PROFIT_MAXMODSIZE 1024 /* Maximum size allowed for the model raster */ +#define PROFIT_MAXMODSIZE 512 /* Maximum size allowed for the model raster */ #define PROFIT_MAXOBJSIZE 512 /* Maximum size allowed for the object raster */ #define PROFIT_BARXFADE 0.1 /* Fract. of bar length crossfaded with arms */ #define PROFIT_MAXEXTRA 2 /* Max. nb of extra free params of profiles */ @@ -125,7 +125,7 @@ typedef struct struct psf *psf; /* PSF */ float pixstep; /* Model/PSF sampling step */ float fluxfac; /* Model flux scaling factor */ - float nsubsamp; /* Subsampling factor */ + float subsamp; /* Subsampling factor */ float *psfdft; /* Compressed Fourier Transform of the PSF */ float *psfpix; /* Full res. pixmap of the PSF */ float *modpix; /* Full res. pixmap of the complete model */ -- GitLab