|
33 #include <cxmessages.h>
34 #include <cxstrutils.h>
37 #include <cpl_parameterlist.h>
40 #include "gifiberutils.h"
81 GiFibersConfig *config)
84 const cxchar *fctid = "giraffe_fibers_select";
86 const cxchar *filename;
89 cxint *spectra = NULL;
96 if (!frame || !config) {
100 filename = cpl_frame_get_filename(frame);
101 cx_assert(filename != NULL);
104 if (config->spectra && *config->spectra != '\0') {
106 if (strcmp(config->spectra, "setup") == 0) {
108 if (reference != NULL) {
114 cpl_msg_error(fctid, "Invalid fiber setup!");
124 cpl_msg_error(fctid, "Invalid selection string `%s'!",
131 if (config->nspec > 0) {
138 if (config->nspec < nspec) {
140 spectra = cx_realloc(spectra,
141 config->nspec * sizeof(cxint));
142 nspec = config->nspec;
144 cpl_msg_warning(fctid, "Requested number of spectra (%d) "
145 "is less than number of listed spectra "
146 "(%d). Using %d spectra.", config->nspec,
147 nspec, config->nspec);
151 if (config->nspec > nspec) {
153 cpl_msg_warning(fctid, "Number of requested spectra "
154 "(%d) exceeds the number of listed "
155 "spectra (%d). Using all spectra in "
156 "the list!", config->nspec, nspec);
164 if (config->nspec > 0) {
173 nspec = config->nspec;
174 spectra = cx_malloc(nspec * sizeof(cxint));
180 for (i = 0; i < nspec; i++) {
191 cpl_table_delete(_fibers);
229 const cxchar *fctid = "giraffe_fibers_setup";
231 cxchar *filename = NULL;
233 cpl_table *_fibers =NULL;
235 GiTable *fibers = NULL;
239 cpl_error_set(fctid, CPL_ERROR_NULL_INPUT);
243 filename = (cxchar *)cpl_frame_get_filename(frame);
245 if (filename == NULL) {
246 cpl_error_set(fctid, CPL_ERROR_ILLEGAL_INPUT);
252 if (_fibers == NULL) {
259 cpl_table_delete(_fibers);
268 if (reference != NULL) {
272 GiTable *rfibers = 0;
275 filename = (cxchar *)cpl_frame_get_filename(reference);
277 if (filename == NULL) {
280 cpl_error_set(fctid, CPL_ERROR_ILLEGAL_INPUT);
287 if (rfibers == NULL) {
328 GiFibersConfig *config = NULL;
335 config = cx_calloc(1, sizeof *config);
343 config->spectra = NULL;
346 p = cpl_parameterlist_find(list, "giraffe.fibers.nspectra");
347 config->nspec = cpl_parameter_get_int(p);
350 p = cpl_parameterlist_find(list, "giraffe.fibers.spectra");
351 config->spectra = cx_strdup(cpl_parameter_get_string(p));
375 if (config->spectra) {
376 cx_free(config->spectra);
377 config->spectra = NULL;
409 p = cpl_parameter_new_value( "giraffe.fibers.spectra",
411 "Index list of spectra to use for "
412 "localization (e.g. 2,10,30-40,55).",
415 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "fiber-splist");
416 cpl_parameterlist_append(list, p);
418 p = cpl_parameter_new_range( "giraffe.fibers.nspectra",
420 "Number of spectra to localize.",
422 0, 0, CX_MAXINT - 1);
423 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "fiber-nspec");
424 cpl_parameterlist_append(list, p);
|