Commit 62858c2c authored by Ole Streicher's avatar Ole Streicher

Merge branch 'upstream' into debian

parents ebc076ec cd74f762
2.7.0 24/10/2015 Updated reflex wkf top level picture id, included Valentin's comments in tutorial, fixed some valgring error on unit tests
2.6.9 02/10/2015 Addressed PIPE-6121 (due to wavcal failure due to wrong addition of FITS keywords)
07/10/2015 Addressed PIPE-6223 (due to wavecal & jitter failures related to addition of wcs)
2.6.8 14/09/2015 Addressed DFS-11239
2.6.7 10/09/2015
"changed status of parameter SetProductExplorerMode to Triggered" sinfo.xml.in
......
......@@ -41,7 +41,7 @@ PRINTER_NAME=lp
PRINT_FONT=Monospaced:16
PRINT_ORIENTATION=P
RADEC_CONVERSION=true
RECIPE_SET=sinfo_rec_detlin=/home/quality/pipelines/sinfo/lib/esopipes-plugins/sinfo-2.6.8/sinfo_rec_detlin.so;sinfo_rec_distortion=/home/quality/pipelines/sinfo/lib/esopipes-plugins/sinfo-2.6.8/sinfo_rec_distortion.so;sinfo_rec_jitter=/home/quality/pipelines/sinfo/lib/esopipes-plugins/sinfo-2.6.8/sinfo_rec_jitter.so;sinfo_rec_mdark=/home/quality/pipelines/sinfo/lib/esopipes-plugins/sinfo-2.6.8/sinfo_rec_mdark.so;sinfo_rec_mflat=/home/quality/pipelines/sinfo/lib/esopipes-plugins/sinfo-2.6.8/sinfo_rec_mflat.so;sinfo_rec_pupil=/home/quality/pipelines/sinfo/lib/esopipes-plugins/sinfo-2.6.8/sinfo_rec_pupil.so;sinfo_rec_wavecal=/home/quality/pipelines/sinfo/lib/esopipes-plugins/sinfo-2.6.8/sinfo_rec_wavecal.so;sinfo_utl_bp_mask_add=/home/quality/pipelines/sinfo/lib/esopipes-plugins/sinfo-2.6.8/sinfo_utl_bp_mask_add.so;sinfo_utl_cube2ima=/home/quality/pipelines/sinfo/lib/esopipes-plugins/sinfo-2.6.8/sinfo_utl_cube2ima.so;sinfo_utl_cube_combine=/home/quality/pipelines/sinfo/lib/esopipes-plugins/sinfo-2.6.8/sinfo_utl_cube_combine.so;sinfo_utl_cube2spectrum=/home/quality/pipelines/sinfo/lib/esopipes-plugins/sinfo-2.6.8/sinfo_utl_cube2spectrum.so;sinfo_utl_cube_arith=/home/quality/pipelines/sinfo/lib/esopipes-plugins/sinfo-2.6.8/sinfo_utl_cube_arith.so;sinfo_utl_ima_arith=/home/quality/pipelines/sinfo/lib/esopipes-plugins/sinfo-2.6.8/sinfo_utl_ima_arith.so;sinfo_utl_skycor=/home/quality/pipelines/sinfo/lib/esopipes-plugins/sinfo-2.6.8/sinfo_utl_skycor.so;sinfo_utl_skymap=/home/quality/pipelines/sinfo/lib/esopipes-plugins/sinfo-2.6.8/sinfo_utl_skymap.so;sinfo_utl_spectrum_divide_by_blackbody=/home/quality/pipelines/sinfo/lib/esopipes-plugins/sinfo-2.6.8/sinfo_utl_spectrum_divide_by_blackbody.so;sinfo_utl_spectrum_wavelength_shift=/home/quality/pipelines/sinfo/lib/esopipes-plugins/sinfo-2.6.8/sinfo_utl_spectrum_wavelength_shift.so
RECIPE_SET=sinfo_rec_detlin=/home/quality/pipelines/sinfo/lib/esopipes-plugins/sinfo-2.7.0/sinfo_rec_detlin.so;sinfo_rec_distortion=/home/quality/pipelines/sinfo/lib/esopipes-plugins/sinfo-2.7.0/sinfo_rec_distortion.so;sinfo_rec_jitter=/home/quality/pipelines/sinfo/lib/esopipes-plugins/sinfo-2.7.0/sinfo_rec_jitter.so;sinfo_rec_mdark=/home/quality/pipelines/sinfo/lib/esopipes-plugins/sinfo-2.7.0/sinfo_rec_mdark.so;sinfo_rec_mflat=/home/quality/pipelines/sinfo/lib/esopipes-plugins/sinfo-2.7.0/sinfo_rec_mflat.so;sinfo_rec_pupil=/home/quality/pipelines/sinfo/lib/esopipes-plugins/sinfo-2.7.0/sinfo_rec_pupil.so;sinfo_rec_wavecal=/home/quality/pipelines/sinfo/lib/esopipes-plugins/sinfo-2.7.0/sinfo_rec_wavecal.so;sinfo_utl_bp_mask_add=/home/quality/pipelines/sinfo/lib/esopipes-plugins/sinfo-2.7.0/sinfo_utl_bp_mask_add.so;sinfo_utl_cube2ima=/home/quality/pipelines/sinfo/lib/esopipes-plugins/sinfo-2.7.0/sinfo_utl_cube2ima.so;sinfo_utl_cube_combine=/home/quality/pipelines/sinfo/lib/esopipes-plugins/sinfo-2.7.0/sinfo_utl_cube_combine.so;sinfo_utl_cube2spectrum=/home/quality/pipelines/sinfo/lib/esopipes-plugins/sinfo-2.7.0/sinfo_utl_cube2spectrum.so;sinfo_utl_cube_arith=/home/quality/pipelines/sinfo/lib/esopipes-plugins/sinfo-2.7.0/sinfo_utl_cube_arith.so;sinfo_utl_ima_arith=/home/quality/pipelines/sinfo/lib/esopipes-plugins/sinfo-2.7.0/sinfo_utl_ima_arith.so;sinfo_utl_skycor=/home/quality/pipelines/sinfo/lib/esopipes-plugins/sinfo-2.7.0/sinfo_utl_skycor.so;sinfo_utl_skymap=/home/quality/pipelines/sinfo/lib/esopipes-plugins/sinfo-2.7.0/sinfo_utl_skymap.so;sinfo_utl_spectrum_divide_by_blackbody=/home/quality/pipelines/sinfo/lib/esopipes-plugins/sinfo-2.7.0/sinfo_utl_spectrum_divide_by_blackbody.so;sinfo_utl_spectrum_wavelength_shift=/home/quality/pipelines/sinfo/lib/esopipes-plugins/sinfo-2.7.0/sinfo_utl_spectrum_wavelength_shift.so
SCRIPTS_DIR=/home/astro4/gasgano/scripts/gas-scripts
SHORTEN_FILES_PATH=false
SHORT_FILENAME=true
......
#! /bin/sh
# Guess values for system-dependent variables and create Makefiles.
# Generated by GNU Autoconf 2.69 for SINFONI Instrument Pipeline 2.6.8.
# Generated by GNU Autoconf 2.69 for SINFONI Instrument Pipeline 2.7.0.
#
# Report bugs to <usd-help@eso.org>.
#
......@@ -590,8 +590,8 @@ MAKEFLAGS=
# Identity of this package.
PACKAGE_NAME='SINFONI Instrument Pipeline'
PACKAGE_TARNAME='sinfo'
PACKAGE_VERSION='2.6.8'
PACKAGE_STRING='SINFONI Instrument Pipeline 2.6.8'
PACKAGE_VERSION='2.7.0'
PACKAGE_STRING='SINFONI Instrument Pipeline 2.7.0'
PACKAGE_BUGREPORT='usd-help@eso.org'
PACKAGE_URL=''
......@@ -1376,7 +1376,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 SINFONI Instrument Pipeline 2.6.8 to adapt to many kinds of systems.
\`configure' configures SINFONI Instrument Pipeline 2.7.0 to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]...
......@@ -1447,7 +1447,7 @@ fi
if test -n "$ac_init_help"; then
case $ac_init_help in
short | recursive ) echo "Configuration of SINFONI Instrument Pipeline 2.6.8:";;
short | recursive ) echo "Configuration of SINFONI Instrument Pipeline 2.7.0:";;
esac
cat <<\_ACEOF
......@@ -1575,7 +1575,7 @@ fi
test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then
cat <<\_ACEOF
SINFONI Instrument Pipeline configure 2.6.8
SINFONI Instrument Pipeline configure 2.7.0
generated by GNU Autoconf 2.69
Copyright (C) 2012 Free Software Foundation, Inc.
......@@ -1990,7 +1990,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 SINFONI Instrument Pipeline $as_me 2.6.8, which was
It was created by SINFONI Instrument Pipeline $as_me 2.7.0, which was
generated by GNU Autoconf 2.69. Invocation command line was
$ $0 $@
......@@ -2969,7 +2969,7 @@ fi
# Define the identity of the package.
PACKAGE='sinfo'
VERSION='2.6.8'
VERSION='2.7.0'
cat >>confdefs.h <<_ACEOF
......@@ -14932,7 +14932,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
# report actual input values of CONFIG_FILES etc. instead of their
# values after options handling.
ac_log="
This file was extended by SINFONI Instrument Pipeline $as_me 2.6.8, which was
This file was extended by SINFONI Instrument Pipeline $as_me 2.7.0, which was
generated by GNU Autoconf 2.69. Invocation command line was
CONFIG_FILES = $CONFIG_FILES
......@@ -14998,7 +14998,7 @@ _ACEOF
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
ac_cs_version="\\
SINFONI Instrument Pipeline config.status 2.6.8
SINFONI Instrument Pipeline config.status 2.7.0
configured by $0, generated by GNU Autoconf 2.69,
with options \\"\$ac_cs_config\\"
......
# Process this file with autoconf to produce a configure script.
AC_INIT([SINFONI Instrument Pipeline], [2.6.8], [usd-help@eso.org], [sinfo])
AC_INIT([SINFONI Instrument Pipeline], [2.7.0], [usd-help@eso.org], [sinfo])
AC_PREREQ([2.59])
......
......@@ -384,9 +384,9 @@ sinfo_cube_create(cpl_parameterlist * parameters, cpl_frameset * frames)
float* distances=NULL;
float* correct_dist=NULL;
char kernel[80];
char poly_file[80];
char pos_list[80];
char dist_list[80];
char poly_file[256];
char pos_list[256];
char dist_list[256];
int ns_index=0;
......@@ -410,6 +410,7 @@ sinfo_cube_create(cpl_parameterlist * parameters, cpl_frameset * frames)
check_nomsg(p=cpl_parameterlist_find(parameters,
"sinfoni.objnod.kernel_type"));
check_nomsg(strcpy(kernel,cpl_parameter_get_string(p)));
check_nomsg(p=cpl_parameterlist_find(parameters,"sinfoni.objnod.n_coeffs"));
......@@ -473,7 +474,6 @@ sinfo_cube_create(cpl_parameterlist * parameters, cpl_frameset * frames)
cpl_image_save(ima_obj_mflat,"ima_obj_mflat.fits", CPL_BPP_IEEE_FLOAT,
NULL,CPL_IO_DEFAULT);
//The following is not needed
cknull_nomsg(ima_mflat_dist=sinfo_new_image_warp_fits(ima_mflat,kernel,
poly_file));
......
......@@ -38,6 +38,7 @@ noinst_HEADERS = \
sinfo_dump.h \
sinfo_fit.h \
sinfo_utils_wrappers.h \
sinfo_boltzmann.h \
sinfo_hidden.h \
sinfo_stacked_hidden_config.h \
sinfo_skycor_config.h \
......
......@@ -472,6 +472,7 @@ noinst_HEADERS = \
sinfo_dump.h \
sinfo_fit.h \
sinfo_utils_wrappers.h \
sinfo_boltzmann.h \
sinfo_hidden.h \
sinfo_stacked_hidden_config.h \
sinfo_skycor_config.h \
......
......@@ -213,171 +213,6 @@ sinfo_new_edge ( float * xdat, float * parlist/*, int * npar, int * ndat*/ )
return return_value ;
}
/**
@name sinfo_new_hat2
@memo calculates the value of a hat function with parameters
parlist at the position xdat
@param xdat position array
@param parlist parameter list
@return function value of a linear hat function.
Intensity edge function
^
| parlist(6) /------\
| / \
| / \
| / \------parlist(7)
parlist(4) |-----------/
| ^ ^ ^ ^
|----------|----|------|---|------> X axis
pos1 pos2 pos3 pos4
@note
-The parameter list values are:
-# parlist(0): pos1
-# parlist(1): pos2
-# parlist(2): pos3
-# parlist(3): pos4
-# parlist(4): background left
-# parlist(5): background right
-# parlist(6): intensity left
-# parlist(7): intensity right
@doc This function returns a function with a constant background value for
xdat values smaller than pos1, linear increasing between pos1 and pos2,
linear between pos2 and pos3, linear decreasing between pos3 and pos4,
and constant background value for xdat values greater than pos4.
(see figure above)
TODO: NOT USED
*/
float
sinfo_new_hat2 ( float * xdat, float * parlist/*, int * npar, int * ndat*/ )
{
float return_value ;
float slope1, slope2, slope3 ;
/* compute the slopes */
slope1 = ( parlist[6] - parlist[4] ) / ( parlist[1] - parlist[0] ) ;
slope2 = ( parlist[7] - parlist[5] ) / ( parlist[3] - parlist[2] ) ;
slope3 = ( parlist[7] - parlist[6] ) / ( parlist[2] - parlist[1] ) ;
/* now build the hat function out of the parameters */
if ( xdat[0] <= parlist[0] )
{
return_value = parlist[4] ;
}
else if ( xdat[0] > parlist[0] && xdat[0] <= parlist[1] )
{
return_value = (xdat[0] - parlist[0]) * slope1 + parlist[4] ;
}
else if ( xdat[0] > parlist[1] && xdat[0] <= parlist[2] )
{
return_value = (xdat[0] - parlist[1]) * slope3 + parlist[6] ;
}
else if ( xdat[0] > parlist[2] && xdat[0] <= parlist[3] )
{
return_value = (parlist[3] - xdat[0]) * slope2 + parlist[5] ;
}
else if ( xdat[0] > parlist[3] )
{
return_value = parlist[5] ;
}
else
{
return_value = 0. ;
}
return return_value ;
}
/**
@name sinfo_new_hat1
@memo calculates the value of a hat function with parameters
parlist at the position xdat
@param xdat position array
@param parlist parameter list
@return function value of a linear hat function.
@note
-The parameter list values are:
-# parlist(0): pos1
-# parlist(1): pos2
-# parlist(2): pos3
-# parlist(3): pos4
-# parlist(4): background left
-# parlist(5): background right
-# parlist(6): intensity left
-# parlist(7): intensity right
Intensity edge function
^
| parlist(6) /------\
| / \
| / \
| / \------parlist(7)
parlist(4) |-----------/
| ^ ^ ^ ^
|----------|----|------|---|------> X axis
pos1 pos2 pos3 pos4
@doc This function returns a function with a constant background value for
xdat values smaller than pos1, linear increasing between pos1 and
pos1+slope_width, constant value intensity between pos1+slope_width and
pos2-slope_width, linear decreasing between pos2-slope_width and pos2,
and constant background value for xdat values greater than pos2.
(see figure above)
TODO: NOT USED
*/
float
sinfo_new_hat1 ( float * xdat, float * parlist/*, int * npar, int * ndat*/ )
{
float return_value=0 ;
float slope1, slope2 ;
/* take only positive values for the fit parameters */
/* compute the slopes */
slope1 = (parlist[4] - parlist[2]) / slopewidth ;
slope2 = (parlist[4] - parlist[3]) / slopewidth ;
/* now build the hat function out of the parameters */
if ( xdat[0] <= parlist[0] )
{
return_value = parlist[2] ;
}
else if ( xdat[0] > parlist[0] && xdat[0] <= parlist[0] + slopewidth )
{
return_value = (xdat[0] - parlist[0]) * slope1 + parlist[2] ;
}
else if ( xdat[0] > parlist[0] + slopewidth &&
xdat[0] <= parlist[1] - slopewidth )
{
return_value = parlist[4] ;
}
else if ( xdat[0] > parlist[1] - slopewidth && xdat[0] <= parlist[1] )
{
return_value = (parlist[1] - xdat[0]) * slope2 + parlist[3] ;
}
else if ( xdat[0] > parlist[1] )
{
return_value = parlist[3] ;
}
return return_value ;
}
/**
@name sinfo_new_edge_deriv()
......@@ -456,211 +291,8 @@ sinfo_new_edge_deriv( float * xdat, float * parlist,
}
return cpl_error_get_code();
}
/**
@name sinfo_new_hat_deriv2
@memo calculates the partial derivatives for a hat function with
parameters parlist at position xdat
@param xdat position array
@param parlist parameter list
@param dervs parameter derivatives (accuracies) list
@return nothing (void)
@note
-The parameter list values are: parlist
-# parlist[0]: pos1
-# parlist[1]: pos2
-# parlist[2]: pos3
-# parlist[3]: pos4
-# parlist[4]: background left
-# parlist[5]: background right
-# parlist[6]: intensity left
-# parlist[7]: intensity right
-The derivative values of a hat function at position xdat: dervs
-# dervs[0]: partial derivative by pos1
-# dervs[1]: partial derivative by pos2
-# dervs[2]: partial derivative by pos3
-# dervs[3]: partial derivative by pos4
-# dervs[4]: partial derivative by background left
-# dervs[5]: partial derivative by background right
-# dervs[6]: partial derivative by intensity left
-# dervs[7]: partial derivative by intensity right
Intensity edge function
^
| parlist(6) /------\
| / \
| / \
| / \------parlist(7)
parlist(4) |-----------/
| ^ ^ ^ ^
|----------|----|------|---|------> X axis
pos1 pos2 pos3 pos4
TODO: NOT USED
*/
void
sinfo_new_hat_deriv2(float * xdat, float * parlist,
float * dervs/*, int * npar*/ )
{
float deriv1_slope1 ;
float deriv1_slope2 ;
float deriv1_slope3 ;
/* compute the slopes */
deriv1_slope1 = ( parlist[6] - parlist[4] ) / SQR(parlist[1] - parlist[0]);
deriv1_slope2 = ( parlist[7] - parlist[5] ) / SQR(parlist[3] - parlist[2]);
deriv1_slope3 = ( parlist[7] - parlist[6] ) / SQR(parlist[2] - parlist[1]);
/* now build the hat derivatives out of the parameters */
if ( xdat[0] <= parlist[0] )
{
dervs[0] = 0. ;
dervs[1] = 0. ;
dervs[2] = 0. ;
dervs[3] = 0. ;
dervs[4] = 1. ;
dervs[5] = 0. ;
dervs[6] = 0. ;
dervs[7] = 0. ;
}
else if ( xdat[0] > parlist[0] && xdat[0] <= parlist[1] )
{
dervs[0] = ( xdat[0] - parlist[1] ) * deriv1_slope1 ;
dervs[1] = ( parlist[0] - xdat[0] ) * deriv1_slope1 ;
dervs[2] = 0. ;
dervs[3] = 0. ;
dervs[4] = ( parlist[0] - xdat[0] ) / ( parlist[1] - parlist[0] ) + 1.;
dervs[5] = 0. ;
dervs[6] = ( xdat[0] - parlist[0] ) / ( parlist[1] - parlist[0] ) ;
dervs[7] = 0. ;
}
else if ( xdat[0] > parlist[1] && xdat[0] <= parlist[2] )
{
dervs[0] = 0. ;
dervs[1] = (xdat[0] - parlist[2]) * deriv1_slope3 ;
dervs[2] = (parlist[1] - xdat[0]) * deriv1_slope3 ;
dervs[3] = 0. ;
dervs[4] = 0. ;
dervs[5] = 0. ;
dervs[6] = (parlist[1] - xdat[0]) / (parlist[2] - parlist[1]) + 1. ;
dervs[7] = (xdat[0] - parlist[1]) / (parlist[2] - parlist[1]) ;
}
else if ( xdat[0] > parlist[2] && xdat[0] <= parlist[3] )
{
dervs[0] = 0. ;
dervs[1] = 0. ;
dervs[2] = ( parlist[3] - xdat[0] ) * deriv1_slope2 ;
dervs[3] = ( xdat[0] - parlist[2] ) * deriv1_slope2 ;
dervs[4] = 0. ;
dervs[5] = ( xdat[0] - parlist[3] ) / ( parlist[3] - parlist[2] ) + 1.;
dervs[6] = 0. ;
dervs[7] = ( parlist[3] - xdat[0] ) / ( parlist[3] - parlist[2] ) ;
}
else if ( xdat[0] > parlist[3] )
{
dervs[0] = 0. ;
dervs[1] = 0. ;
dervs[2] = 0. ;
dervs[3] = 0. ;
dervs[4] = 0. ;
dervs[5] = 1. ;
dervs[6] = 0. ;
dervs[7] = 0. ;
}
}
/**
@name sinfo_new_hat_deriv1
@memo calculates the partial derivatives for a hat function with
parameters parlist at position xdat
@param xdat position array
@param parlist parameter list
@param dervs parameter derivatives (accuracies) list
@return nothing (void)
@note
-The parameter list values are: parlist
-# parlist[0]: pos1
-# parlist[1]: pos2
-# parlist[2]: background1
-# parlist[3]: background2
-# parlist[4]: intensity
-The derivative values of a hat function at position xdat: dervs
-# dervs[0]: partial derivative by pos1
-# dervs[1]: partial derivative by pos2
-# dervs[2]: partial derivative by background1
-# dervs[3]: partial derivative by background2
-# dervs[4]: partial derivative by intensity
Intensity edge function
^
| /------parlist(3)
| /
| /
| /
parlist(2) |-----------/
| ^ ^
|----------|----|---------------> X axis
parlist(0)=pos1 pos2=parlist(1)
TODO: NOT USED
*/
void
sinfo_new_hat_deriv1( float * xdat, float * parlist,
float * dervs/*, int * npar*/ )
{
/* now build the hat derivatives out of the parameters */
if ( xdat[0] <= parlist[0] )
{
dervs[0] = 0. ;
dervs[1] = 0. ;
dervs[2] = 1. ;
dervs[3] = 0. ;
dervs[4] = 0. ;
}
else if ( xdat[0] > parlist[0] && xdat[0] <= parlist[0] + slopewidth )
{
dervs[0] = ( parlist[2] - parlist[4] ) / slopewidth ;
dervs[1] = 0. ;
dervs[2] = (( parlist[0] - xdat[0] ) / slopewidth ) + 1. ;
dervs[3] = 0. ;
dervs[4] = ( xdat[0] - parlist[0] ) / slopewidth ;
}
else if ( xdat[0] > parlist[0] + slopewidth && xdat[0] <=
parlist[1] - slopewidth )
{
dervs[0] = 0. ;
dervs[1] = 0. ;
dervs[2] = 0. ;
dervs[3] = 0. ;
dervs[4] = 1. ;
}
else if ( xdat[0] > parlist[1] - slopewidth && xdat[0] <= parlist[1] )
{
dervs[0] = 0. ;
dervs[1] = ( parlist[4] - parlist[3] ) / slopewidth ;
dervs[2] = 0. ;
dervs[3] = (( xdat[0] - parlist[1] ) / slopewidth ) + 1. ;
dervs[4] = ( parlist[1] - xdat[0] ) / slopewidth ;
}
else if ( xdat[0] > parlist[1] )
{
dervs[0] = 0. ;
dervs[1] = 0. ;
dervs[2] = 0. ;
dervs[3] = 1. ;
dervs[4] = 0. ;
}
}
/**
@name sinfo_new_inv_mat_edge
......@@ -1098,1556 +730,133 @@ sinfo_new_lsqfit_edge ( float * xdat,
{
if ( (matrix1[i][i] <= 0.0 ) || (matrix2[i][i] <= 0.0) )
{
return -7 ;
}
epar[parptr[i]] = chi1 * sqrt( matrix2[i][i] ) /
sqrt( matrix1[i][i] ) ;
}
}
else /* non-linear fit */
{
/*----------------------------------------------------------------
* the non-linear fit uses the steepest descent method in combination
* with the Taylor method. The mixing of these methods is controlled
* by lambda. In the outer loop ( called the iteration loop ) we build
* the sinfo_matrix and calculate the correction sinfo_vector. In the
* inner loop
* (called the interpolation loop) we check whether we have obtained a
* better solution than the previous one. If so, we leave the inner loop
* else we increase lambda ( give more weight to the steepest descent
* method) calculate the correction sinfo_vector and check again.
* After the inner loop
* we do a final check on the goodness of the fit and if this satisfies
* the tolerance we calculate the errors of the fitted parameters.
*/
while ( !found ) /* iteration loop */
{
if ( itc++ == (*its) ) /* increase iteration counter */
{
return -4 ;
}
sinfo_new_get_mat_edge( xdat, xdim, ydat, wdat, ndat,
fpar, epar/*, npar*/ ) ;
/*-------------------------------------------------------------
* here we decrease lambda since we may assume that each iteration
* brings us closer to the answer.
*/
if ( labda > LABMINA )
{
labda = labda / LABFACA ; /* decrease lambda */
}
r = sinfo_new_get_vec_edge ( xdat, xdim, ydat, wdat, ndat,
fpar, epar, npar ) ;
if ( (int)fpar[1] - (int)fpar[0] <= 0 && fpar[1] / fpar[0] > 0. )
{
fpar[1] += 1. ;
continue ;
}
if ( r ) /* error */
{
return r ;
}
while ( chi1 >= chi2 ) /* interpolation loop */
{
/*-----------------------------------------------------------
* The next statement is based on experience, not on the
* mathematics of the problem. It is assumed that we have
* reached convergence when the pure steepest descent method
* does not produce a better solution.
*/
if ( labda > LABMAXA ) /* assume solution found */
{
break ;
}
labda = labda * LABFACA ; /* increase mixing parameter */
r = sinfo_new_get_vec_edge ( xdat, xdim, ydat, wdat,
ndat, fpar, epar, npar ) ;
if ( (int)fpar[1] - (int)fpar[0] <= 0 &&
fpar[1] / fpar[0] > 0. )
{
fpar[1] += 1. ;
continue ;
}
if ( r ) /* error */
{
return r ;
}
}
if ( labda <= LABMAXA ) /* save old parameters */
{
for ( i = 0 ; i < *npar ; i++ )
{
fpar[i] = epar[i] ;
}
}
if ( (fabs( chi2 - chi1 ) <= (tolerance * chi1)) ||
(labda > LABMAXA) )
{
/*------------------------------------------------------------
* we have a satisfying solution, so now we need to calculate
* the correct errors of the fitted parameters. This we do by
* using the pure Taylor method because we are very close to
* the real solution.
*/
labda = LABMINA ; /* for Taylor solution */
sinfo_new_get_mat_edge ( xdat, xdim, ydat, wdat, ndat,
fpar, epar/*, npar */) ;
r = sinfo_new_get_vec_edge ( xdat, xdim, ydat, wdat,
ndat, fpar, epar, npar ) ;
if ( r ) /* error */
{
return r ;
}
for ( i = 0 ; i < (*npar) ; i++ )
{
epar[i] = 0.0 ; /* set error to zero */
}
chi2 = sqrt ( chi2 / (double) (nuse - nfree) ) ;
for ( i = 0 ; i < nfree ; i++ )
{
if ( (matrix1[i][i] <= 0.0) || (matrix2[i][i] <= 0.0) )
{
return -7 ;
}
epar[parptr[i]] = chi2 * sqrt( matrix2[i][i] ) /
sqrt( matrix1[i][i] ) ;
}
found = 1 ; /* we found a solution */
}
}
}
return itc ; /* return number of iterations */
}
/**
@name sinfo_new_fit_slits1
@memo fits the beginning and end position of the slitlets by using non-linear
least square fitting of a hat function
@param lineImage emission line frame
@param par fit parameter data structure of fitted lines
@param sinfo_slit_pos allocated dummy array for the slitlet
positions [32][2]
@param box_length pixel length of the row box within the fit is done
@param y_box small box in spectral direction within the slitlet
may lie.
@param sinfo_slit_pos (out) beginning and end position of the slitlets
to sub-pixel accuracy
@returns # 0 if it worked,
# -1 if there was no line image given,
# -2 if there were no line fit parameters given,
# -3 if there was no dummy array for the slit positions
allocated
# -4 if the given box length is impossible
# -5 if the given y box length is impossible
# -6 if there were no emission lines found in the
first image columns
# -7 if not all slitlets could be found
# -8 if the least squares fit failed
TODO: NOT USED
*/
int
sinfo_new_fit_slits1( cpl_image * lineImage,
FitParams ** par,
float ** sinfo_slit_pos,
int box_length,
float y_box )
{
float* position=NULL ;
int * sinfo_edge, * edgeclean ;