uves_extract_profile.h

00001 /*
00002  * This file is part of the ESO UVES Pipeline
00003  * Copyright (C) 2004,2005 European Southern Observatory
00004  *
00005  * This program is free software; you can redistribute it and/or modify
00006  * it under the terms of the GNU General Public License as published by
00007  * the Free Software Foundation; either version 2 of the License, or
00008  * (at your option) any later version.
00009  *
00010  * This program is distributed in the hope that it will be useful,
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  * GNU General Public License for more details.
00014  *
00015  * You should have received a copy of the GNU General Public License
00016  * along with this program; if not, write to the Free Software
00017  * Foundation, 51 Franklin St, Fifth Floor, Boston, MA  02111-1307  USA
00018  */
00019 
00020 /*
00021  * $Author: amodigli $
00022  * $Date: 2010/09/24 09:32:03 $
00023  * $Revision: 1.5 $
00024  * $Name: uves-5_0_0 $
00025  * $Log: uves_extract_profile.h,v $
00026  * Revision 1.5  2010/09/24 09:32:03  amodigli
00027  * put back QFITS dependency to fix problem spot by NRI on FIBER mode (with MIDAS calibs) data
00028  *
00029  * Revision 1.3  2010/02/13 12:22:31  amodigli
00030  * removed inlines (let's do work to compiler)
00031  *
00032  * Revision 1.2  2007/06/06 08:17:33  amodigli
00033  * replace tab with 4 spaces
00034  *
00035  * Revision 1.1  2007/05/02 13:42:23  jmlarsen
00036  * Added header
00037  *
00038  * Revision 1.28  2007/04/24 12:50:29  jmlarsen
00039  * Replaced cpl_propertylist -> uves_propertylist which is much faster
00040  *
00041  * Revision 1.27  2006/11/15 14:04:08  jmlarsen
00042  * Removed non-const version of parameterlist_get_first/last/next which is already
00043  * in CPL, added const-safe wrapper, unwrapper and deallocator functions
00044  *
00045  * Revision 1.26  2006/09/19 07:15:35  jmlarsen
00046  * Added chip to argument list of uves_extract()
00047  *
00048  * Revision 1.25  2006/08/17 13:56:53  jmlarsen
00049  * Reduced max line length
00050  *
00051  * Revision 1.24  2006/05/16 12:13:07  amodigli
00052  * added QC log
00053  *
00054  * Revision 1.23  2006/05/12 15:04:13  jmlarsen
00055  * Changed gauss/moffat/virtual profile measuring methods to use 
00056  * global polynomials (rather than one polynomial per order)
00057  *
00058  * Revision 1.22  2006/04/24 09:21:18  jmlarsen
00059  * Implemented virtual resampling algorithm
00060  *
00061  * Revision 1.21  2006/02/28 09:15:22  jmlarsen
00062  * Minor update
00063  *
00064  * Revision 1.20  2005/12/19 16:17:56  jmlarsen
00065  * Replaced bool -> int
00066  *
00067  */
00068 #ifndef UVES_EXTRACT_PROFILE_H
00069 #define UVES_EXTRACT_PROFILE_H
00070 
00071 #include <uves_extract_iterate.h>
00072 
00073 typedef struct _uves_extract_profile uves_extract_profile;
00074 
00075 uves_extract_profile *uves_extract_profile_new(
00076     int (*f)   (const double x[], const double a[], double *result),
00077     int (*dfda)(const double x[], const double a[], double result[]),
00078     int M,
00079     double slit_length,
00080     int sampling_factor);
00081 
00082 uves_extract_profile *
00083 uves_extract_profile_new_constant(double slit_length);
00084 
00085 void uves_extract_profile_delete(uves_extract_profile **p);
00086 
00087 double
00088 uves_extract_profile_evaluate(const uves_extract_profile *profile,
00089                               const uves_iterate_position *pos);
00090 
00091 void uves_extract_profile_set(const uves_extract_profile *p, 
00092                   uves_iterate_position *pos,
00093                   int *warnings);
00094 double
00095 uves_extract_profile_get_y(uves_iterate_position *pos,
00096                double bin,
00097                int sampling_factor);
00098 
00099 double
00100 uves_extract_profile_get_bin(const uves_iterate_position *pos,
00101                  int sampling_factor);
00102 
00103 int uves_extract_profile_get_nbins(double slit_length, int sampling_factor);
00104 
00105 
00106 
00107 
00108 /* This should be defined to 0, and is used only for testing.
00109  * If set to 1 the profile is measured order by order (like the MIDAS algorithm
00110  * which is less robust)
00111  */
00112 #define ORDER_PER_ORDER 0
00113 
00114 /* The spatial profile   @cond 
00115    fixme: avoid exporting this definition,
00116    currently needed for uves_extract module
00117 */
00118 struct _uves_extract_profile
00119 {
00120     /* There are three types of profiles.
00121      *
00122      * If constant == true
00123      *    assume a constant spatial profile
00124      *    only the member current_area is used
00125      * else if f != NULL  (zero resampling)
00126      *     y0(x,m) and sigma(x,m) are the parameters
00127      *     of the assumed profile (gaussian/moffat)
00128      *     red_chisq(x,m) is the smoothed reduced
00129      *     chi^2 of the fits
00130      * 
00131      * else if f == NULL  (virtual resampling)
00132      *     dy is an array of polynomials.
00133      *     dy_i(x,m) is the profile of the i'th 
00134      *     spatial bin. 
00135      */
00136 
00137     bool constant;
00138 
00139     int (*f)   (const double x[], const double a[], double *result);
00140     int (*dfda)(const double x[], const double a[], double result[]);
00141     int M;
00142 
00143 #if ORDER_PER_ORDER
00144     polynomial **y0;   /* Polynomial for each order */
00145     polynomial **sigma;
00146     polynomial **red_chisq;
00147 #else
00148     polynomial *y0;
00149     polynomial *sigma;
00150     polynomial *red_chisq;
00151 #endif
00152 
00153     double current_y0;      /* This is for a "performance hack",      */
00154     double current_sigma;   /* so that we don't have to evaluate the  */
00155     double current_area;    /* polynomials too often. See also
00156                                uves_extract_profile_set().            */
00157 
00158     /* Virtual resampling */
00159     int spatial_bins;
00160     double slit_length;
00161     int sampling_factor;
00162 
00163 
00164     bool *is_zero_degree;  /* For efficiency: use polynomials or simple doubles
00165                               as necessary */
00166     polynomial **dy_poly;  /* Polynomial for each position along slit */
00167     double *dy_double;
00168 
00169     double *current_profile;   /* Array with profile at current x */
00170     double *current_ypos;      /* Array with y-positions where profile is known,
00171                                   at current x */
00172     double *current_interpolated;    /* Interpolated profile at current x */
00173 
00174 };
00175 /* @endcond */
00176 
00177 #endif

Generated on 9 Mar 2012 for UVES Pipeline Reference Manual by  doxygen 1.6.1