sinfo_utils.c

00001 /*                                                                           *
00002  *   This file is part of the ESO SINFONI Pipeline                           *
00003  *   Copyright (C) 2004,2005 European Southern Observatory                   *
00004  *                                                                           *
00005  *   This library 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  * $Author: kmirny $
00021  * $Date: 2010/09/30 14:00:03 $
00022  * $Revision: 1.6 $
00023  * $Name: sinfo-2_2_5 $
00024  * $Log: sinfo_utils.c,v $
00025  * Revision 1.6  2010/09/30 14:00:03  kmirny
00026  * moving function from wavecal to utils
00027  *
00028  * Revision 1.5  2007/05/25 06:28:35  amodigli
00029  * fixed plugintest warnings
00030  *
00031  * Revision 1.4  2006/11/07 07:13:25  amodigli
00032  * added doxygen
00033  *
00034  * Revision 1.3  2006/11/04 15:28:36  amodigli
00035  * doxygen
00036  *
00037  * Revision 1.2  2006/10/17 07:02:24  amodigli
00038  * shorten line length
00039  *
00040  * Revision 1.1  2006/08/09 12:26:36  amodigli
00041  * added sinfo_utils.h sinfo_utils.c
00042  *
00043 
00044  */
00045 
00046 #ifdef HAVE_CONFIG_H
00047 #  include <config.h>
00048 #endif
00049 
00050 /*---------------------------------------------------------------------------*/
00057 /*---------------------------------------------------------------------------*/
00058 
00059 /*----------------------------------------------------------------------------
00060                             Includes
00061  ----------------------------------------------------------------------------*/
00062 
00063 #include <sinfo_utils.h>
00071 /*----------------------------------------------------------------------------
00072                             Functions prototypes
00073  ----------------------------------------------------------------------------*/
00074 /*----------------------------------------------------------------------------
00075                             Implementation
00076  ----------------------------------------------------------------------------*/
00077 
00078 /*---------------------------------------------------------------------------*/
00087 /*---------------------------------------------------------------------------*/
00088 long
00089 sinfo_round_double(double x)
00090 {
00091     return (x >=0) ? (long)(x+0.5) : (long)(x-0.5);
00092 }
00098 int
00099 sinfo_parameter_get_default_flag ( const cpl_parameter* p )
00100 {
00101    int flag_gasgano=0;
00102    int flag_norm=0;
00103    int flag=0;
00104    cpl_type type =0;
00105 
00106    flag_norm = ( cpl_parameter_get_default_flag ( p ) == 0 ) ? 1 : 0;
00107    type=cpl_parameter_get_type ( p );
00108 
00109    switch ( type )
00110    {
00111       case CPL_TYPE_BOOL:
00112          flag_gasgano = ( cpl_parameter_get_default_bool ( p ) ==
00113                           cpl_parameter_get_bool ( p ) ) ? 1:0;
00114          break;
00115       case CPL_TYPE_INT:
00116          flag_gasgano = ( cpl_parameter_get_default_int ( p ) ==
00117                           cpl_parameter_get_int ( p ) ) ? 1:0;
00118          break;
00119       case CPL_TYPE_DOUBLE:
00120          flag_gasgano = ( cpl_parameter_get_default_double ( p ) ==
00121                           cpl_parameter_get_double ( p ) ) ? 1:0;
00122          break;
00123       case CPL_TYPE_STRING:
00124          flag_gasgano = ( cpl_parameter_get_default_string ( p ) ==
00125                           cpl_parameter_get_string ( p ) ) ? 1:0;
00126          break;
00127 
00128       default:
00129          cpl_msg_error (cpl_func, "type not supported" );
00130    }
00131 
00132    flag = ( flag_gasgano && flag_norm ) ? 0 : 1;
00133 
00134    return flag;
00135 }

Generated on 8 Mar 2011 for SINFONI Pipeline Reference Manual by  doxygen 1.6.1