FORS Pipeline Reference Manual  4.12.5
fors_config.c
1 /* $Id: fors_config.c,v 1.5 2013-10-09 15:59:38 cgarcia Exp $
2  *
3  * This file is part of the FORS Data Reduction Pipeline
4  * Copyright (C) 2002-2010 European Southern Observatory
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19  */
20 
21 /*
22  * $Author: cgarcia $
23  * $Date: 2013-10-09 15:59:38 $
24  * $Revision: 1.5 $
25  * $Name: not supported by cvs2svn $
26  */
27 
28 #ifdef HAVE_CONFIG_H
29 #include <config.h>
30 #endif
31 
32 #include <string.h>
33 #include <math.h>
34 #include <cpl.h>
35 #include <moses.h>
36 #include <fors_dfs.h>
37 
38 static int fors_config_create(cpl_plugin *);
39 static int fors_config_exec(cpl_plugin *);
40 static int fors_config_destroy(cpl_plugin *);
41 static int fors_config(cpl_parameterlist *, cpl_frameset *);
42 
43 static char fors_config_description[] =
44 "This recipe is used to create the so-called GRISM_TABLE, containing all\n"
45 "the FORS spectral pipeline configuration parameters related to a specific\n"
46 "grism. This is a way to provide for each specific instrument mode a set of\n"
47 "appropriate defaults for the recipe parameters.\n"
48 "The values assigned to each input parameter of fors_config are simply\n"
49 "copied to a FITS table consisting of one row, and as many columns as the\n"
50 "input parameter: each column will have the same name and type of each\n"
51 "parameter. Only the three parameters \"instrument\", \"grism\", and\n"
52 "\"id\" are not written to the table columns, but to the descriptor header\n"
53 "keywords INSTRUME, ESO INS GRIS1 NAME, and ESO INS GRIS1 ID, that will be\n"
54 "used by the automatic pipeline for appropriate data association.\n\n"
55 "Input files: none\n\n"
56 " DO category: Type: Explanation: Required:\n"
57 "Output files:\n\n"
58 " DO category: Data type: Explanation:\n"
59 " GRISM_TABLE FITS table Recipe configuration parameters\n\n";
60 
61 #define fors_config_exit(message) \
62 { \
63 if (message) cpl_msg_error(recipe, message); \
64 cpl_table_delete(table); \
65 cpl_propertylist_delete(header); \
66 cpl_free(filename); \
67 return -1; \
68 }
69 
70 
82 int cpl_plugin_get_info(cpl_pluginlist *list)
83 {
84  cpl_recipe *recipe = cpl_calloc(1, sizeof *recipe );
85  cpl_plugin *plugin = &recipe->interface;
86 
87  cpl_plugin_init(plugin,
88  CPL_PLUGIN_API,
89  FORS_BINARY_VERSION,
90  CPL_PLUGIN_TYPE_RECIPE,
91  "fors_config",
92  "Creation of FORS recipes configuration tables",
93  fors_config_description,
94  "Carlo Izzo",
95  PACKAGE_BUGREPORT,
96  "This file is currently part of the FORS Instrument Pipeline\n"
97  "Copyright (C) 2002-2010 European Southern Observatory\n\n"
98  "This program is free software; you can redistribute it and/or modify\n"
99  "it under the terms of the GNU General Public License as published by\n"
100  "the Free Software Foundation; either version 2 of the License, or\n"
101  "(at your option) any later version.\n\n"
102  "This program is distributed in the hope that it will be useful,\n"
103  "but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
104  "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n"
105  "GNU General Public License for more details.\n\n"
106  "You should have received a copy of the GNU General Public License\n"
107  "along with this program; if not, write to the Free Software Foundation,\n"
108  "Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA\n",
109  fors_config_create,
110  fors_config_exec,
111  fors_config_destroy);
112 
113  cpl_pluginlist_append(list, plugin);
114 
115  return 0;
116 }
117 
118 
129 static int fors_config_create(cpl_plugin *plugin)
130 {
131  cpl_recipe *recipe;
132  cpl_parameter *p;
133 
134 
135  /*
136  * Check that the plugin is part of a valid recipe
137  */
138 
139  if (cpl_plugin_get_type(plugin) == CPL_PLUGIN_TYPE_RECIPE)
140  recipe = (cpl_recipe *)plugin;
141  else
142  return -1;
143 
144  /*
145  * Create the parameters list in the cpl_recipe object
146  */
147 
148  recipe->parameters = cpl_parameterlist_new();
149 
150 
151  /*
152  * Dispersion
153  */
154 
155  p = cpl_parameter_new_value("fors.fors_config.dispersion",
156  CPL_TYPE_DOUBLE,
157  "Expected spectral dispersion (Angstrom/pixel)",
158  "fors.fors_config",
159  0.0);
160  cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "dispersion");
161  cpl_parameter_disable(p, CPL_PARAMETER_MODE_ENV);
162  cpl_parameterlist_append(recipe->parameters, p);
163 
164  /*
165  * Peak detection level
166  */
167 
168  p = cpl_parameter_new_value("fors.fors_config.peakdetection",
169  CPL_TYPE_DOUBLE,
170  "Peak detection threshold (ADU)",
171  "fors.fors_config",
172  250.0);
173  cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "peakdetection");
174  cpl_parameter_disable(p, CPL_PARAMETER_MODE_ENV);
175  cpl_parameterlist_append(recipe->parameters, p);
176 
177  /*
178  * Degree of wavelength calibration polynomial
179  */
180 
181  p = cpl_parameter_new_value("fors.fors_config.wdegree",
182  CPL_TYPE_INT,
183  "Degree of wavelength calibration polynomial",
184  "fors.fors_config",
185  4);
186  cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "wdegree");
187  cpl_parameter_disable(p, CPL_PARAMETER_MODE_ENV);
188  cpl_parameterlist_append(recipe->parameters, p);
189 
190  /*
191  * Reference lines search radius
192  */
193 
194 /*
195  p = cpl_parameter_new_value("fors.fors_config.wradius",
196  CPL_TYPE_INT,
197  "Search radius if iterating pattern-matching "
198  "with first-guess method",
199  "fors.fors_config",
200  0);
201  cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "wradius");
202  cpl_parameter_disable(p, CPL_PARAMETER_MODE_ENV);
203  cpl_parameterlist_append(recipe->parameters, p);
204 */
205 
206  /*
207  * Rejection threshold in dispersion relation polynomial fitting
208  */
209 
210 /*
211  p = cpl_parameter_new_value("fors.fors_config.wreject",
212  CPL_TYPE_DOUBLE,
213  "Rejection threshold in dispersion "
214  "relation fit (pixel)",
215  "fors.fors_config",
216  0.7);
217  cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "wreject");
218  cpl_parameter_disable(p, CPL_PARAMETER_MODE_ENV);
219  cpl_parameterlist_append(recipe->parameters, p);
220 */
221 
222  /*
223  * Wavelength solution interpolation (for LSS data)
224  */
225 
226 /*
227  p = cpl_parameter_new_value("fors.fors_config.wmode",
228  CPL_TYPE_INT,
229  "Interpolation mode of wavelength solution "
230  "applicable to LSS-like data (0 = no "
231  "interpolation, 1 = fill gaps, 2 = global "
232  "model",
233  "fors.fors_config",
234  0);
235  cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "wmode");
236  cpl_parameter_disable(p, CPL_PARAMETER_MODE_ENV);
237  cpl_parameterlist_append(recipe->parameters, p);
238 */
239 
240  /*
241  * Degree of spectral curvature polynomial
242  */
243 
244  p = cpl_parameter_new_value("fors.fors_config.cdegree",
245  CPL_TYPE_INT,
246  "Degree of spectral curvature polynomial",
247  "fors.fors_config",
248  4);
249  cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "cdegree");
250  cpl_parameter_disable(p, CPL_PARAMETER_MODE_ENV);
251  cpl_parameterlist_append(recipe->parameters, p);
252 
253  /*
254  * Global curvature model
255  */
256 
257 /*
258  p = cpl_parameter_new_value("fors.fors_config.cglobal",
259  CPL_TYPE_BOOL,
260  "Global curvature model",
261  "fors.fors_config",
262  TRUE);
263  cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "cglobal");
264  cpl_parameter_disable(p, CPL_PARAMETER_MODE_ENV);
265  cpl_parameterlist_append(recipe->parameters, p);
266 */
267 
268  /*
269  * Start wavelength for spectral extraction
270  */
271 
272  p = cpl_parameter_new_value("fors.fors_config.startwavelength",
273  CPL_TYPE_DOUBLE,
274  "Start wavelength in spectral extraction",
275  "fors.fors_config",
276  0.0);
277  cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "startwavelength");
278  cpl_parameter_disable(p, CPL_PARAMETER_MODE_ENV);
279  cpl_parameterlist_append(recipe->parameters, p);
280 
281  /*
282  * End wavelength for spectral extraction
283  */
284 
285  p = cpl_parameter_new_value("fors.fors_config.endwavelength",
286  CPL_TYPE_DOUBLE,
287  "End wavelength in spectral extraction",
288  "fors.fors_config",
289  0.0);
290  cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "endwavelength");
291  cpl_parameter_disable(p, CPL_PARAMETER_MODE_ENV);
292  cpl_parameterlist_append(recipe->parameters, p);
293 
294  /*
295  * Try slit identification
296  */
297 
298 /*
299  p = cpl_parameter_new_value("fors.fors_config.slit_ident",
300  CPL_TYPE_BOOL,
301  "Attempt slit identification for MOS or MXU",
302  "fors.fors_config",
303  TRUE);
304  cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "slit_ident");
305  cpl_parameter_disable(p, CPL_PARAMETER_MODE_ENV);
306  cpl_parameterlist_append(recipe->parameters, p);
307 */
308 
309  /*
310  * Degree of flat field fitting polynomial along spatial direction
311  * (used for LSS data)
312  */
313 
314 /*
315  p = cpl_parameter_new_value("fors.fors_config.sdegree",
316  CPL_TYPE_INT,
317  "Degree of flat field fitting polynomial "
318  "along spatial direction (used for LSS "
319  "data only)",
320  "fors.fors_config",
321  4);
322  cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "sdegree");
323  cpl_parameter_disable(p, CPL_PARAMETER_MODE_ENV);
324  cpl_parameterlist_append(recipe->parameters, p);
325 */
326 
327  /*
328  * Degree of flat field fitting polynomial along dispersion direction
329  * (used for MOS and MXU data)
330  */
331 
332 /*
333  p = cpl_parameter_new_value("fors.fors_config.ddegree",
334  CPL_TYPE_INT,
335  "Degree of flat field fitting polynomial "
336  "along dispersion direction (used for MOS "
337  "and MXU data only)",
338  "fors.fors_config",
339  7);
340  cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "ddegree");
341  cpl_parameter_disable(p, CPL_PARAMETER_MODE_ENV);
342  cpl_parameterlist_append(recipe->parameters, p);
343 */
344 
345  /*
346  * Smooth box radius for flat field along dispersion direction
347  */
348 
349 /*
350  p = cpl_parameter_new_value("fors.fors_config.dradius",
351  CPL_TYPE_INT,
352  "Smooth box radius for flat field along "
353  "dispersion direction",
354  "fors.fors_config",
355  10);
356  cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "dradius");
357  cpl_parameter_disable(p, CPL_PARAMETER_MODE_ENV);
358  cpl_parameterlist_append(recipe->parameters, p);
359 */
360 
361  /*
362  * Smooth box radius for flat field along spatial direction
363  * (used for LSS data only)
364  */
365 
366 /*
367  p = cpl_parameter_new_value("fors.fors_config.sradius",
368  CPL_TYPE_INT,
369  "Smooth box radius for flat field along "
370  "spatial direction (used for LSS data only)",
371  "fors.fors_config",
372  10);
373  cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "sradius");
374  cpl_parameter_disable(p, CPL_PARAMETER_MODE_ENV);
375  cpl_parameterlist_append(recipe->parameters, p);
376 */
377 
378  /*
379  * Sky lines alignment
380  */
381 
382 /*
383  p = cpl_parameter_new_value("fors.fors_config.skyalign",
384  CPL_TYPE_INT,
385  "Polynomial order for sky lines alignment, "
386  "or -1 to avoid alignment",
387  "fors.fors_config",
388  -1);
389  cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "skyalign");
390  cpl_parameter_disable(p, CPL_PARAMETER_MODE_ENV);
391  cpl_parameterlist_append(recipe->parameters, p);
392 */
393 
394  /*
395  * Instrument name
396  */
397 
398  p = cpl_parameter_new_value("fors.fors_config.instrument",
399  CPL_TYPE_STRING,
400  "Name of instrument",
401  "fors.fors_config",
402  "0");
403  cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "instrument");
404  cpl_parameter_disable(p, CPL_PARAMETER_MODE_ENV);
405  cpl_parameterlist_append(recipe->parameters, p);
406 
407  /*
408  * Grism name
409  */
410 
411  p = cpl_parameter_new_value("fors.fors_config.grism",
412  CPL_TYPE_STRING,
413  "Name of grism",
414  "fors.fors_config",
415  "0");
416  cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "grism");
417  cpl_parameter_disable(p, CPL_PARAMETER_MODE_ENV);
418  cpl_parameterlist_append(recipe->parameters, p);
419 
420  /*
421  * Grism id
422  */
423 
424  p = cpl_parameter_new_value("fors.fors_config.grism_id",
425  CPL_TYPE_STRING,
426  "Grism ID",
427  "fors.fors_config",
428  "0");
429  cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "grism_id");
430  cpl_parameter_disable(p, CPL_PARAMETER_MODE_ENV);
431  cpl_parameterlist_append(recipe->parameters, p);
432 
433  /*
434  * Filter name
435  */
436 
437  p = cpl_parameter_new_value("fors.fors_config.filter",
438  CPL_TYPE_STRING,
439  "Name of filter",
440  "fors.fors_config",
441  "0");
442  cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "filter");
443  cpl_parameter_disable(p, CPL_PARAMETER_MODE_ENV);
444  cpl_parameterlist_append(recipe->parameters, p);
445 
446  /*
447  * Filter id
448  */
449 
450  p = cpl_parameter_new_value("fors.fors_config.filter_id",
451  CPL_TYPE_STRING,
452  "Filter ID",
453  "fors.fors_config",
454  "0");
455  cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "filter_id");
456  cpl_parameter_disable(p, CPL_PARAMETER_MODE_ENV);
457  cpl_parameterlist_append(recipe->parameters, p);
458 
459  return 0;
460 }
461 
462 
471 static int fors_config_exec(cpl_plugin *plugin)
472 {
473  cpl_recipe *recipe;
474 
475  if (cpl_plugin_get_type(plugin) == CPL_PLUGIN_TYPE_RECIPE)
476  recipe = (cpl_recipe *)plugin;
477  else
478  return -1;
479 
480  return fors_config(recipe->parameters, recipe->frames);
481 }
482 
483 
492 static int fors_config_destroy(cpl_plugin *plugin)
493 {
494  cpl_recipe *recipe;
495 
496  if (cpl_plugin_get_type(plugin) == CPL_PLUGIN_TYPE_RECIPE)
497  recipe = (cpl_recipe *)plugin;
498  else
499  return -1;
500 
501  cpl_parameterlist_delete(recipe->parameters);
502 
503  return 0;
504 }
505 
506 
516 static int fors_config(cpl_parameterlist *parlist, cpl_frameset *frameset)
517 {
518 
519  const char *recipe = "fors_config";
520 
521 
522  /*
523  * Input parameters
524  */
525 
526  double dispersion;
527  double peakdetection;
528  int wdegree;
529  int cdegree;
530  double startwavelength;
531  double endwavelength;
532 /*
533  * int wradius;
534  * double wreject;
535  * int wmode;
536  * int cglobal;
537  * int slit_ident;
538  * int sdegree;
539  * int ddegree;
540  * int sradius;
541  * int dradius;
542  * int skyalign;
543  */
544 
545  const char *instrument;
546  const char *grism;
547  const char *grism_id;
548  const char *filter;
549  const char *filter_id;
550 
551  char *filename = NULL;
552 
553  /*
554  * CPL objects
555  */
556 
557  cpl_table *table = NULL;
558  cpl_propertylist *header = NULL;
559 
560  /*
561  * Auxiliary variables
562  */
563 
564  int len;
565 
566 
567  if (frameset){} /* To avoid compiler warning */
568 
569  /*
570  * Get configuration parameters
571  */
572 
573  cpl_msg_info(recipe, "Recipe %s configuration parameters:", recipe);
574  cpl_msg_indent_more();
575 
576  table = cpl_table_new(1);
577 
578  dispersion = dfs_get_parameter_double(parlist,
579  "fors.fors_config.dispersion", NULL);
580 
581  if (dispersion <= 0.0)
582  fors_config_exit("Invalid spectral dispersion value");
583 
584  cpl_table_new_column(table, "dispersion", CPL_TYPE_DOUBLE);
585  cpl_table_set_double(table, "dispersion", 0, dispersion);
586 
587  peakdetection = dfs_get_parameter_double(parlist,
588  "fors.fors_config.peakdetection", NULL);
589  if (peakdetection <= 0.0)
590  fors_config_exit("Invalid peak detection level");
591 
592  cpl_table_new_column(table, "peakdetection", CPL_TYPE_DOUBLE);
593  cpl_table_set_double(table, "peakdetection", 0, peakdetection);
594 
595  wdegree = dfs_get_parameter_int(parlist, "fors.fors_config.wdegree", NULL);
596 
597  if (wdegree < 1)
598  fors_config_exit("Invalid polynomial degree");
599 
600  if (wdegree > 5)
601  fors_config_exit("Max allowed polynomial degree is 5");
602 
603  cpl_table_new_column(table, "wdegree", CPL_TYPE_INT);
604  cpl_table_set_int(table, "wdegree", 0, wdegree);
605 
606 /*
607  * wradius = dfs_get_parameter_int(parlist,
608  * "fors.fors_config.wradius", NULL);
609  *
610  * if (wradius < 0)
611  * fors_config_exit("Invalid search radius");
612  *
613  * cpl_table_new_column(table, "wradius", CPL_TYPE_INT);
614  * cpl_table_set_int(table, "wradius", 0, wradius);
615  *
616  * wreject = dfs_get_parameter_double(parlist,
617  * "fors.fors_config.wreject", NULL);
618  *
619  * if (wreject <= 0.0)
620  * fors_config_exit("Invalid rejection threshold");
621  *
622  * cpl_table_new_column(table, "wreject", CPL_TYPE_DOUBLE);
623  * cpl_table_set_double(table, "wreject", 0, wreject);
624  *
625  * wmode = dfs_get_parameter_int(parlist, "fors.fors_config.wmode", NULL);
626  *
627  * if (wmode < 0 || wmode > 2)
628  * fors_config_exit("Invalid wavelength solution interpolation mode");
629  *
630  * cpl_table_new_column(table, "wmode", CPL_TYPE_INT);
631  * cpl_table_set_int(table, "wmode", 0, wmode);
632  */
633 
634  cdegree = dfs_get_parameter_int(parlist, "fors.fors_config.cdegree", NULL);
635 
636  if (cdegree < 1)
637  fors_config_exit("Invalid polynomial degree");
638 
639  if (cdegree > 5)
640  fors_config_exit("Max allowed polynomial degree is 5");
641 
642  cpl_table_new_column(table, "cdegree", CPL_TYPE_INT);
643  cpl_table_set_int(table, "cdegree", 0, cdegree);
644 
645 /*
646  * cglobal = dfs_get_parameter_bool(parlist, "fors.fors_config.cglobal",
647  * NULL);
648  *
649  * cpl_table_new_column(table, "cglobal", CPL_TYPE_INT);
650  * cpl_table_set_int(table, "cglobal", 0, cglobal);
651  */
652 
653  startwavelength = dfs_get_parameter_double(parlist,
654  "fors.fors_config.startwavelength", NULL);
655  if (startwavelength > 1.0)
656  if (startwavelength < 3000.0 || startwavelength > 13000.0)
657  fors_config_exit("Invalid wavelength");
658 
659  cpl_table_new_column(table, "startwavelength", CPL_TYPE_DOUBLE);
660  cpl_table_set_double(table, "startwavelength", 0, startwavelength);
661 
662  endwavelength = dfs_get_parameter_double(parlist,
663  "fors.fors_config.endwavelength", NULL);
664  if (endwavelength > 1.0)
665  if (endwavelength < 3000.0 || endwavelength > 13000.0)
666  fors_config_exit("Invalid wavelength");
667 
668  if (startwavelength > 1.0 && endwavelength > 1.0)
669  if (endwavelength - startwavelength <= 0.0)
670  fors_config_exit("Invalid wavelength interval");
671 
672  cpl_table_new_column(table, "endwavelength", CPL_TYPE_DOUBLE);
673  cpl_table_set_double(table, "endwavelength", 0, endwavelength);
674 
675 /*
676  * slit_ident = dfs_get_parameter_bool(parlist,
677  * "fors.fors_config.slit_ident", NULL);
678  *
679  * cpl_table_new_column(table, "slit_ident", CPL_TYPE_INT);
680  * cpl_table_set_int(table, "slit_ident", 0, slit_ident);
681  *
682  * sdegree = dfs_get_parameter_int(parlist,
683  * "fors.fors_config.sdegree", NULL);
684  *
685  * cpl_table_new_column(table, "sdegree", CPL_TYPE_INT);
686  * cpl_table_set_int(table, "sdegree", 0, sdegree);
687  *
688  * ddegree = dfs_get_parameter_int(parlist,
689  * "fors.fors_config.ddegree", NULL);
690  *
691  * cpl_table_new_column(table, "ddegree", CPL_TYPE_INT);
692  * cpl_table_set_int(table, "ddegree", 0, ddegree);
693  *
694  * sradius = dfs_get_parameter_int(parlist,
695  * "fors.fors_config.sradius", NULL);
696  * dradius = dfs_get_parameter_int(parlist,
697  * "fors.fors_config.dradius", NULL);
698  *
699  * if (sradius < 1 || dradius < 1)
700  * fors_config_exit("Invalid smoothing box radius");
701  *
702  * cpl_table_new_column(table, "sradius", CPL_TYPE_INT);
703  * cpl_table_set_int(table, "sradius", 0, sradius);
704  * cpl_table_new_column(table, "dradius", CPL_TYPE_INT);
705  * cpl_table_set_int(table, "dradius", 0, dradius);
706  *
707  * skyalign = dfs_get_parameter_int(parlist, "fors.fors_config.skyalign",
708  * NULL);
709  *
710  * cpl_table_new_column(table, "skyalign", CPL_TYPE_INT);
711  * cpl_table_set_int(table, "skyalign", 0, skyalign);
712  */
713 
714  header = cpl_propertylist_new();
715 
716  instrument = dfs_get_parameter_string(parlist,
717  "fors.fors_config.instrument", NULL);
718  cpl_propertylist_update_string(header, "INSTRUME", instrument);
719 
720  grism = dfs_get_parameter_string(parlist, "fors.fors_config.grism", NULL);
721  cpl_propertylist_update_string(header, "ESO INS GRIS1 NAME", grism);
722 
723  grism_id = dfs_get_parameter_string(parlist,
724  "fors.fors_config.grism_id", NULL);
725  cpl_propertylist_update_string(header, "ESO INS GRIS1 ID", grism_id);
726 
727  filter = dfs_get_parameter_string(parlist, "fors.fors_config.filter", NULL);
728  cpl_propertylist_update_string(header, "ESO INS FILT1 NAME", filter);
729 
730  filter_id = dfs_get_parameter_string(parlist,
731  "fors.fors_config.filter_id", NULL);
732  cpl_propertylist_update_string(header, "ESO INS FILT1 ID", filter_id);
733 
734  if (cpl_error_get_code())
735  fors_config_exit("Failed to get the configuration parameters");
736 
737  cpl_propertylist_update_string(header, "ESO PRO CATG", "GRISM_TABLE");
738 
739  len = 14;
740  len += strlen(instrument);
741  len += strlen(grism + 5);
742  len += strlen(grism_id);
743  len += strlen(filter);
744  len += strlen(filter_id);
745 
746  filename = cpl_calloc(len, sizeof(char));
747 
748  sprintf(filename, "%s_GRS_%s_%s_%s_%s.fits",
749  instrument, grism + 5, grism_id+1, filter, filter_id+1);
750 
751  cpl_table_save(table, header, NULL, filename, CPL_IO_DEFAULT);
752  cpl_propertylist_delete(header); header = NULL;
753  cpl_table_delete(table); table = NULL;
754  cpl_free(filename); filename = NULL;
755 
756  if (cpl_error_get_code()) {
757  cpl_msg_error(cpl_error_get_where(), "%s", cpl_error_get_message());
758  fors_config_exit(NULL);
759  }
760  else
761  return 0;
762 }
int cpl_plugin_get_info(cpl_pluginlist *list)
Build the list of available plugins, for this module.
Definition: fors_bias.c:62
const char * dfs_get_parameter_string(cpl_parameterlist *parlist, const char *name, const cpl_table *defaults)
Reading a recipe string parameter value.
Definition: fors_dfs.c:587
int dfs_get_parameter_int(cpl_parameterlist *parlist, const char *name, const cpl_table *defaults)
Reading a recipe integer parameter value.
Definition: fors_dfs.c:392
Definition: list.c:74
double dfs_get_parameter_double(cpl_parameterlist *parlist, const char *name, const cpl_table *defaults)
Reading a recipe double parameter value.
Definition: fors_dfs.c:489