FORS Pipeline Reference Manual 4.9.20
|
00001 /* $Id: fors_instrument.c,v 1.4 2010/09/14 07:49:30 cizzo Exp $ 00002 * 00003 * This file is part of the FORS Library 00004 * Copyright (C) 2002-2010 European Southern Observatory 00005 * 00006 * This program is free software; you can redistribute it and/or modify 00007 * it under the terms of the GNU General Public License as published by 00008 * the Free Software Foundation; either version 2 of the License, or 00009 * (at your option) any later version. 00010 * 00011 * This program is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 * GNU General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU General Public License 00017 * along with this program; if not, write to the Free Software 00018 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 00019 */ 00020 00021 /* 00022 * $Author: cizzo $ 00023 * $Date: 2010/09/14 07:49:30 $ 00024 * $Revision: 1.4 $ 00025 * $Name: fors-4_9_20 $ 00026 */ 00027 00028 #ifdef HAVE_CONFIG_H 00029 #include <config.h> 00030 #endif 00031 00032 #include <fors_instrument.h> 00033 #include <string.h> 00034 00035 const struct fors_filterlist { 00036 const char name[10]; 00037 const char band; 00038 } fors_filterlist[15] = { 00039 /* FORS1 */ 00040 {"U_BESS", 'U'}, 00041 {"u_HIGH", 'U'}, 00042 {"B_BESS", 'B'}, 00043 {"b_HIGH", 'B'}, 00044 {"g_HIGH", 'V'}, /* G uses V ?????????????????????????????????? */ 00045 {"V_BESS", 'V'}, 00046 {"v_HIGH", 'V'}, 00047 {"R_BESS", 'R'}, 00048 {"I_BESS", 'I'}, 00049 00050 /* FORS2 */ 00051 {"U_SPECIAL", 'U'}, 00052 {"B_BESS" , 'B'}, 00053 {"V_BESS" , 'V'}, 00054 {"R_SPECIAL", 'R'}, 00055 {"I_BESS" , 'I'}, 00056 {"" , '\0'} 00057 }; 00058 00059 const char fors_filterband_unknown = '?', 00060 fors_filterband_none = '\0'; 00061 00076 char 00077 fors_instrument_filterband_get_by_setting( const fors_setting *setting) 00078 { 00079 char band; 00080 cpl_errorstate errstat = cpl_errorstate_get(); 00081 00082 if (setting == NULL) 00083 { 00084 cpl_error_set(cpl_func, CPL_ERROR_NULL_INPUT); 00085 return fors_filterband_unknown; 00086 } 00087 00088 band = fors_instrument_filterband_get_by_name(setting->filter_name); 00089 if (!cpl_errorstate_is_equal(errstat)) 00090 cpl_error_set_where(cpl_func); 00091 00092 return band; 00093 } 00094 00106 char 00107 fors_instrument_filterband_get_by_name( const char *filtername) 00108 { 00109 int n; 00110 00111 if (filtername == NULL || filtername[0] == '\0') 00112 return fors_filterband_none; 00113 00114 n = 0; 00115 while ((fors_filterlist[n].name)[0] != '\0') 00116 { 00117 if (strcmp(filtername, fors_filterlist[n].name) == 0) 00118 return fors_filterlist[n].band; 00119 n++; 00120 } 00121 00122 cpl_error_set_message( cpl_func, 00123 CPL_ERROR_ILLEGAL_INPUT, 00124 "unknown filter name \"%s\"", 00125 filtername); 00126 return fors_filterband_unknown; 00127 } 00128 00137 bool 00138 fors_instrument_filterband_is_defined( char band) 00139 { 00140 return (band >= 'A' && band <= 'Z'); 00141 } 00142 00150 bool 00151 fors_instrument_filterband_is_none( char band) 00152 { 00153 return (band == '\0'); 00154 } 00155 00164 bool 00165 fors_instrument_filterband_is_unknown( char band) 00166 { 00167 return !( fors_instrument_filterband_is_defined(band) 00168 || fors_instrument_filterband_is_none(band)); 00169 } 00170 00175 char 00176 fors_instrument_filterband_value_unknown( void) 00177 { 00178 return fors_filterband_unknown; 00179 } 00180 00185 int 00186 fors_instrument_known_filters_get_number( void) 00187 { 00188 return (sizeof(fors_filterlist)/sizeof(*fors_filterlist)) - 1; 00189 } 00190 00199 const char * 00200 fors_instrument_known_filters_get_name( int n) 00201 { 00202 if (n < 0 00203 || n >= fors_instrument_known_filters_get_number()) 00204 { 00205 cpl_error_set( cpl_func, 00206 CPL_ERROR_ACCESS_OUT_OF_RANGE); 00207 return NULL; 00208 } 00209 return fors_filterlist[n].name; 00210 } 00211 00221 char 00222 fors_instrument_known_filters_get_band( int n) 00223 { 00224 if (n < 0 00225 || n >= fors_instrument_known_filters_get_number()) 00226 { 00227 cpl_error_set( cpl_func, 00228 CPL_ERROR_ACCESS_OUT_OF_RANGE); 00229 return fors_filterband_unknown; 00230 } 00231 return fors_filterlist[n].band; 00232 } 00233 00234