29#include "moo_spectral_format.h"
65 moo_spectral_format *res = cpl_calloc(1,
sizeof(moo_spectral_format));
78moo_spectral_format_info *
81 moo_spectral_format_info *res =
82 cpl_calloc(1,
sizeof(moo_spectral_format_info));
101 cpl_ensure(frame != NULL, CPL_ERROR_NULL_INPUT, NULL);
102 const char *filename = cpl_frame_get_filename(frame);
103 cpl_ensure(filename != NULL, CPL_ERROR_NULL_INPUT, NULL);
105 cpl_errorstate prev_state = cpl_errorstate_get();
108 cpl_table *full_table = cpl_table_load(filename, 1, 0);
111 cpl_table_select_all(full_table);
112 cpl_table_and_selected_string(full_table, MODE_COLNAME, CPL_EQUAL_TO, mode);
113 res->table = cpl_table_extract_selected(full_table);
114 cpl_table_delete(full_table);
116 if (!cpl_errorstate_is_equal(prev_state)) {
117 cpl_errorstate_set(prev_state);
118 cpl_msg_error(
"moo_spectral_format",
119 "Error in loading spectral_format %s", filename);
126static moo_spectral_format_info *
127_moo_spectral_format_get(moo_spectral_format *self,
int nrow)
129 moo_spectral_format_info *info = NULL;
131 double wmin = cpl_table_get_double(self->table, WMIN_COLNAME, nrow, &flag);
132 double wmax = cpl_table_get_double(self->table, WMAX_COLNAME, nrow, &flag);
134 cpl_table_get_double(self->table, RES_COLNAME, nrow, &flag);
136 cpl_table_get_double(self->table, DISPMIN_COLNAME, nrow, &flag);
138 cpl_table_get_double(self->table, DISPMAX_COLNAME, nrow, &flag);
139 int dir = cpl_table_get_int(self->table, DIRECTION_COLNAME, nrow, &flag);
141 info->dispmin = dispmin;
142 info->dispmax = dispmax;
143 info->resolution = resolution;
146 info->direction = dir;
159moo_spectral_format_info *
164 moo_spectral_format_info *info = NULL;
166 cpl_ensure(self != NULL, CPL_ERROR_NULL_INPUT, NULL);
167 cpl_ensure(ntas >= 1 && ntas <= 2, CPL_ERROR_ILLEGAL_INPUT, NULL);
170 cpl_table_select_all(self->table);
171 cpl_table_and_selected_string(self->table, ARM_COLNAME, CPL_EQUAL_TO, arm);
172 cpl_array *idx_array = cpl_table_where_selected(self->table);
173 double idx = cpl_array_get(idx_array, 0, NULL);
175 info = _moo_spectral_format_get(self, idx);
177 cpl_array_delete(idx_array);
201 cpl_ensure_code(self != NULL, CPL_ERROR_NULL_INPUT);
202 cpl_ensure_code(min != NULL, CPL_ERROR_NULL_INPUT);
203 cpl_ensure_code(max != NULL, CPL_ERROR_NULL_INPUT);
211 return cpl_error_get_code();
227 if (self->table != NULL) {
228 cpl_table_delete(self->table);
const char * moo_detector_get_name(moo_detector_type type)
Get the extension name of a detector.
enum _moo_detector_type_ moo_detector_type
The type code type.
const char * moo_mode_get_name(moo_mode_type type)
Get the name of a mode.