00001 /* * 00002 * This file is part of the ESO UVES 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 /* 00021 * $Author: amodigli $ 00022 * $Date: 2007/06/06 08:17:33 $ 00023 * $Revision: 1.9 $ 00024 * $Name: uves-3_9_0 $ 00025 * $Log: uves_physmod_chop_otab.c,v $ 00026 * Revision 1.9 2007/06/06 08:17:33 amodigli 00027 * replace tab with 4 spaces 00028 * 00029 * Revision 1.8 2007/05/16 16:32:55 amodigli 00030 * changed factor from 0.05to 0.075 00031 * 00032 * Revision 1.7 2007/04/24 12:50:29 jmlarsen 00033 * Replaced cpl_propertylist -> uves_propertylist which is much faster 00034 * 00035 * Revision 1.6 2006/11/06 15:19:41 jmlarsen 00036 * Removed unused include directives 00037 * 00038 * Revision 1.5 2006/07/28 14:51:26 amodigli 00039 * fixed some bugs on improper table selection 00040 * 00041 * Revision 1.4 2006/06/05 08:51:55 amodigli 00042 * cleaned some warnings from static checks 00043 * 00044 * Revision 1.3 2006/05/09 15:42:48 amodigli 00045 * safer way to do selection 00046 * 00047 * Revision 1.2 2006/05/08 15:42:16 amodigli 00048 * allow to specify order column label 00049 * 00050 * Revision 1.1 2006/02/03 07:46:30 jmlarsen 00051 * Moved recipe implementations to ./uves directory 00052 * 00053 * Revision 1.5 2006/01/19 08:47:24 jmlarsen 00054 * Inserted missing doxygen end tag 00055 * 00056 * Revision 1.4 2006/01/16 08:01:57 amodigli 00057 * 00058 * Added stability check 00059 * 00060 * Revision 1.3 2006/01/09 14:05:42 amodigli 00061 * Fixed doxigen warnings 00062 * 00063 * Revision 1.2 2006/01/03 16:57:13 amodigli 00064 * Fixed bug 00065 * 00066 * Revision 1.1 2006/01/03 14:47:53 amodigli 00067 * 00068 * Added uves_physmod_chop_otab.h .c to match MIDAS 00069 * 00070 * Revision 1.3 2005/12/19 16:17:55 jmlarsen 00071 * Replaced bool -> int 00072 * 00073 */ 00074 00075 /*----------------------------------------------------------------------------*/ 00079 /*----------------------------------------------------------------------------*/ 00082 #ifdef HAVE_CONFIG_H 00083 # include <config.h> 00084 #endif 00085 00086 /*----------------------------------------------------------------------------- 00087 Includes 00088 -----------------------------------------------------------------------------*/ 00089 #include <uves_physmod_chop_otab.h> 00090 00091 #include <uves_utils_wrappers.h> 00092 #include <uves_pfits.h> 00093 #include <uves_error.h> 00094 00095 /*----------------------------------------------------------------------------- 00096 Defines 00097 -----------------------------------------------------------------------------*/ 00098 /*----------------------------------------------------------------------------- 00099 Functions prototypes 00100 ----------------------------------------------------------------------------*/ 00101 /*----------------------------------------------------------------------------- 00102 Static variables 00103 -----------------------------------------------------------------------------*/ 00104 00105 /*----------------------------------------------------------------------------- 00106 Functions code 00107 -----------------------------------------------------------------------------*/ 00108 00109 /*----------------------------------------------------------------------------*/ 00124 /*----------------------------------------------------------------------------*/ 00125 00126 int uves_physmod_chop_otab(const uves_propertylist * raw_header, 00127 enum uves_chip chip, 00128 cpl_table** ord_tbl, 00129 const char* col_name, 00130 int * ord_min, 00131 int * ord_max) 00132 { 00133 00134 int nx=0; 00135 int ny=0; 00136 00137 double xbox[2]={0,0}; 00138 double ybox[2]={0,0}; 00139 const double fct=0.075; 00140 const double add=50.; 00141 cpl_table* tmp_tbl1=NULL; 00142 cpl_table* tmp_tbl2=NULL; 00143 00144 /* note those are swapped */ 00145 check (ny = uves_pfits_get_nx(raw_header,chip), 00146 "Could not read nx from input header"); 00147 check (nx = uves_pfits_get_ny(raw_header,chip), 00148 "Could not read ny from input header"); 00149 00150 xbox[0]=(double)(nx/2-nx*fct); 00151 xbox[1]=(double)(nx/2+nx*fct); 00152 ybox[0]=add; 00153 ybox[1]=(double)(ny-add); 00154 00155 uves_msg_debug("NX=%d NY=%d",nx,ny); 00156 uves_msg_debug("xbox=%f,%f ybox=%f,%f",xbox[0],xbox[1],ybox[0],ybox[1]); 00157 00158 check(tmp_tbl1=uves_extract_table_rows(*ord_tbl,"X",CPL_GREATER_THAN,xbox[0]), 00159 "Error selecting X"); 00160 00161 check(tmp_tbl2=uves_extract_table_rows(tmp_tbl1,"X",CPL_LESS_THAN,xbox[1]), 00162 "Error selecting X"); 00163 00164 *ord_min=(int)cpl_table_get_column_min(tmp_tbl2,col_name); 00165 *ord_max=(int)cpl_table_get_column_max(tmp_tbl2,col_name); 00166 uves_msg_debug("ord_min=%d ord_max=%d",*ord_min,*ord_max); 00167 00168 00169 cleanup: 00170 uves_free_table(&tmp_tbl1); 00171 uves_free_table(&tmp_tbl2); 00172 00173 return 0; 00174 00175 }
1.5.1