00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
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
00040 {"U_BESS", 'U'},
00041 {"u_HIGH", 'U'},
00042 {"B_BESS", 'B'},
00043 {"b_HIGH", 'B'},
00044 {"g_HIGH", 'V'},
00045 {"V_BESS", 'V'},
00046 {"v_HIGH", 'V'},
00047 {"R_BESS", 'R'},
00048 {"I_BESS", 'I'},
00049
00050
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