FORS Pipeline Reference Manual 4.9.20
|
00001 /* $Id: fors_config.c,v 1.4 2010/09/14 07:38:16 cizzo Exp $ 00002 * 00003 * This file is part of the FORS Data Reduction Pipeline 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:38:16 $ 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 <string.h> 00033 #include <math.h> 00034 #include <cpl.h> 00035 #include <moses.h> 00036 #include <fors_dfs.h> 00037 00038 static int fors_config_create(cpl_plugin *); 00039 static int fors_config_exec(cpl_plugin *); 00040 static int fors_config_destroy(cpl_plugin *); 00041 static int fors_config(cpl_parameterlist *, cpl_frameset *); 00042 00043 static char fors_config_description[] = 00044 "This recipe is used to create the so-called GRISM_TABLE, containing all\n" 00045 "the FORS spectral pipeline configuration parameters related to a specific\n" 00046 "grism. This is a way to provide for each specific instrument mode a set of\n" 00047 "appropriate defaults for the recipe parameters.\n" 00048 "The values assigned to each input parameter of fors_config are simply\n" 00049 "copied to a FITS table consisting of one row, and as many columns as the\n" 00050 "input parameter: each column will have the same name and type of each\n" 00051 "parameter. Only the three parameters \"instrument\", \"grism\", and\n" 00052 "\"id\" are not written to the table columns, but to the descriptor header\n" 00053 "keywords INSTRUME, ESO INS GRIS1 NAME, and ESO INS GRIS1 ID, that will be\n" 00054 "used by the automatic pipeline for appropriate data association.\n\n" 00055 "Input files: none\n\n" 00056 " DO category: Type: Explanation: Required:\n" 00057 "Output files:\n\n" 00058 " DO category: Data type: Explanation:\n" 00059 " GRISM_TABLE FITS table Recipe configuration parameters\n\n"; 00060 00061 #define fors_config_exit(message) \ 00062 { \ 00063 if (message) cpl_msg_error(recipe, message); \ 00064 cpl_table_delete(table); \ 00065 cpl_propertylist_delete(header); \ 00066 cpl_free(filename); \ 00067 return -1; \ 00068 } 00069 00070 00082 int cpl_plugin_get_info(cpl_pluginlist *list) 00083 { 00084 cpl_recipe *recipe = cpl_calloc(1, sizeof *recipe ); 00085 cpl_plugin *plugin = &recipe->interface; 00086 00087 cpl_plugin_init(plugin, 00088 CPL_PLUGIN_API, 00089 FORS_BINARY_VERSION, 00090 CPL_PLUGIN_TYPE_RECIPE, 00091 "fors_config", 00092 "Creation of FORS recipes configuration tables", 00093 fors_config_description, 00094 "Carlo Izzo", 00095 PACKAGE_BUGREPORT, 00096 "This file is currently part of the FORS Instrument Pipeline\n" 00097 "Copyright (C) 2002-2010 European Southern Observatory\n\n" 00098 "This program is free software; you can redistribute it and/or modify\n" 00099 "it under the terms of the GNU General Public License as published by\n" 00100 "the Free Software Foundation; either version 2 of the License, or\n" 00101 "(at your option) any later version.\n\n" 00102 "This program is distributed in the hope that it will be useful,\n" 00103 "but WITHOUT ANY WARRANTY; without even the implied warranty of\n" 00104 "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n" 00105 "GNU General Public License for more details.\n\n" 00106 "You should have received a copy of the GNU General Public License\n" 00107 "along with this program; if not, write to the Free Software Foundation,\n" 00108 "Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA\n", 00109 fors_config_create, 00110 fors_config_exec, 00111 fors_config_destroy); 00112 00113 cpl_pluginlist_append(list, plugin); 00114 00115 return 0; 00116 } 00117 00118 00129 static int fors_config_create(cpl_plugin *plugin) 00130 { 00131 cpl_recipe *recipe; 00132 cpl_parameter *p; 00133 00134 00135 /* 00136 * Check that the plugin is part of a valid recipe 00137 */ 00138 00139 if (cpl_plugin_get_type(plugin) == CPL_PLUGIN_TYPE_RECIPE) 00140 recipe = (cpl_recipe *)plugin; 00141 else 00142 return -1; 00143 00144 /* 00145 * Create the parameters list in the cpl_recipe object 00146 */ 00147 00148 recipe->parameters = cpl_parameterlist_new(); 00149 00150 00151 /* 00152 * Dispersion 00153 */ 00154 00155 p = cpl_parameter_new_value("fors.fors_config.dispersion", 00156 CPL_TYPE_DOUBLE, 00157 "Expected spectral dispersion (Angstrom/pixel)", 00158 "fors.fors_config", 00159 0.0); 00160 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "dispersion"); 00161 cpl_parameter_disable(p, CPL_PARAMETER_MODE_ENV); 00162 cpl_parameterlist_append(recipe->parameters, p); 00163 00164 /* 00165 * Peak detection level 00166 */ 00167 00168 p = cpl_parameter_new_value("fors.fors_config.peakdetection", 00169 CPL_TYPE_DOUBLE, 00170 "Peak detection threshold (ADU)", 00171 "fors.fors_config", 00172 250.0); 00173 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "peakdetection"); 00174 cpl_parameter_disable(p, CPL_PARAMETER_MODE_ENV); 00175 cpl_parameterlist_append(recipe->parameters, p); 00176 00177 /* 00178 * Degree of wavelength calibration polynomial 00179 */ 00180 00181 p = cpl_parameter_new_value("fors.fors_config.wdegree", 00182 CPL_TYPE_INT, 00183 "Degree of wavelength calibration polynomial", 00184 "fors.fors_config", 00185 4); 00186 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "wdegree"); 00187 cpl_parameter_disable(p, CPL_PARAMETER_MODE_ENV); 00188 cpl_parameterlist_append(recipe->parameters, p); 00189 00190 /* 00191 * Reference lines search radius 00192 */ 00193 00194 /* 00195 p = cpl_parameter_new_value("fors.fors_config.wradius", 00196 CPL_TYPE_INT, 00197 "Search radius if iterating pattern-matching " 00198 "with first-guess method", 00199 "fors.fors_config", 00200 0); 00201 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "wradius"); 00202 cpl_parameter_disable(p, CPL_PARAMETER_MODE_ENV); 00203 cpl_parameterlist_append(recipe->parameters, p); 00204 */ 00205 00206 /* 00207 * Rejection threshold in dispersion relation polynomial fitting 00208 */ 00209 00210 /* 00211 p = cpl_parameter_new_value("fors.fors_config.wreject", 00212 CPL_TYPE_DOUBLE, 00213 "Rejection threshold in dispersion " 00214 "relation fit (pixel)", 00215 "fors.fors_config", 00216 0.7); 00217 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "wreject"); 00218 cpl_parameter_disable(p, CPL_PARAMETER_MODE_ENV); 00219 cpl_parameterlist_append(recipe->parameters, p); 00220 */ 00221 00222 /* 00223 * Wavelength solution interpolation (for LSS data) 00224 */ 00225 00226 /* 00227 p = cpl_parameter_new_value("fors.fors_config.wmode", 00228 CPL_TYPE_INT, 00229 "Interpolation mode of wavelength solution " 00230 "applicable to LSS-like data (0 = no " 00231 "interpolation, 1 = fill gaps, 2 = global " 00232 "model", 00233 "fors.fors_config", 00234 0); 00235 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "wmode"); 00236 cpl_parameter_disable(p, CPL_PARAMETER_MODE_ENV); 00237 cpl_parameterlist_append(recipe->parameters, p); 00238 */ 00239 00240 /* 00241 * Degree of spectral curvature polynomial 00242 */ 00243 00244 p = cpl_parameter_new_value("fors.fors_config.cdegree", 00245 CPL_TYPE_INT, 00246 "Degree of spectral curvature polynomial", 00247 "fors.fors_config", 00248 4); 00249 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "cdegree"); 00250 cpl_parameter_disable(p, CPL_PARAMETER_MODE_ENV); 00251 cpl_parameterlist_append(recipe->parameters, p); 00252 00253 /* 00254 * Global curvature model 00255 */ 00256 00257 /* 00258 p = cpl_parameter_new_value("fors.fors_config.cglobal", 00259 CPL_TYPE_BOOL, 00260 "Global curvature model", 00261 "fors.fors_config", 00262 TRUE); 00263 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "cglobal"); 00264 cpl_parameter_disable(p, CPL_PARAMETER_MODE_ENV); 00265 cpl_parameterlist_append(recipe->parameters, p); 00266 */ 00267 00268 /* 00269 * Start wavelength for spectral extraction 00270 */ 00271 00272 p = cpl_parameter_new_value("fors.fors_config.startwavelength", 00273 CPL_TYPE_DOUBLE, 00274 "Start wavelength in spectral extraction", 00275 "fors.fors_config", 00276 0.0); 00277 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "startwavelength"); 00278 cpl_parameter_disable(p, CPL_PARAMETER_MODE_ENV); 00279 cpl_parameterlist_append(recipe->parameters, p); 00280 00281 /* 00282 * End wavelength for spectral extraction 00283 */ 00284 00285 p = cpl_parameter_new_value("fors.fors_config.endwavelength", 00286 CPL_TYPE_DOUBLE, 00287 "End wavelength in spectral extraction", 00288 "fors.fors_config", 00289 0.0); 00290 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "endwavelength"); 00291 cpl_parameter_disable(p, CPL_PARAMETER_MODE_ENV); 00292 cpl_parameterlist_append(recipe->parameters, p); 00293 00294 /* 00295 * Try slit identification 00296 */ 00297 00298 /* 00299 p = cpl_parameter_new_value("fors.fors_config.slit_ident", 00300 CPL_TYPE_BOOL, 00301 "Attempt slit identification for MOS or MXU", 00302 "fors.fors_config", 00303 TRUE); 00304 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "slit_ident"); 00305 cpl_parameter_disable(p, CPL_PARAMETER_MODE_ENV); 00306 cpl_parameterlist_append(recipe->parameters, p); 00307 */ 00308 00309 /* 00310 * Degree of flat field fitting polynomial along spatial direction 00311 * (used for LSS data) 00312 */ 00313 00314 /* 00315 p = cpl_parameter_new_value("fors.fors_config.sdegree", 00316 CPL_TYPE_INT, 00317 "Degree of flat field fitting polynomial " 00318 "along spatial direction (used for LSS " 00319 "data only)", 00320 "fors.fors_config", 00321 4); 00322 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "sdegree"); 00323 cpl_parameter_disable(p, CPL_PARAMETER_MODE_ENV); 00324 cpl_parameterlist_append(recipe->parameters, p); 00325 */ 00326 00327 /* 00328 * Degree of flat field fitting polynomial along dispersion direction 00329 * (used for MOS and MXU data) 00330 */ 00331 00332 /* 00333 p = cpl_parameter_new_value("fors.fors_config.ddegree", 00334 CPL_TYPE_INT, 00335 "Degree of flat field fitting polynomial " 00336 "along dispersion direction (used for MOS " 00337 "and MXU data only)", 00338 "fors.fors_config", 00339 7); 00340 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "ddegree"); 00341 cpl_parameter_disable(p, CPL_PARAMETER_MODE_ENV); 00342 cpl_parameterlist_append(recipe->parameters, p); 00343 */ 00344 00345 /* 00346 * Smooth box radius for flat field along dispersion direction 00347 */ 00348 00349 /* 00350 p = cpl_parameter_new_value("fors.fors_config.dradius", 00351 CPL_TYPE_INT, 00352 "Smooth box radius for flat field along " 00353 "dispersion direction", 00354 "fors.fors_config", 00355 10); 00356 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "dradius"); 00357 cpl_parameter_disable(p, CPL_PARAMETER_MODE_ENV); 00358 cpl_parameterlist_append(recipe->parameters, p); 00359 */ 00360 00361 /* 00362 * Smooth box radius for flat field along spatial direction 00363 * (used for LSS data only) 00364 */ 00365 00366 /* 00367 p = cpl_parameter_new_value("fors.fors_config.sradius", 00368 CPL_TYPE_INT, 00369 "Smooth box radius for flat field along " 00370 "spatial direction (used for LSS data only)", 00371 "fors.fors_config", 00372 10); 00373 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "sradius"); 00374 cpl_parameter_disable(p, CPL_PARAMETER_MODE_ENV); 00375 cpl_parameterlist_append(recipe->parameters, p); 00376 */ 00377 00378 /* 00379 * Sky lines alignment 00380 */ 00381 00382 /* 00383 p = cpl_parameter_new_value("fors.fors_config.skyalign", 00384 CPL_TYPE_INT, 00385 "Polynomial order for sky lines alignment, " 00386 "or -1 to avoid alignment", 00387 "fors.fors_config", 00388 -1); 00389 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "skyalign"); 00390 cpl_parameter_disable(p, CPL_PARAMETER_MODE_ENV); 00391 cpl_parameterlist_append(recipe->parameters, p); 00392 */ 00393 00394 /* 00395 * Instrument name 00396 */ 00397 00398 p = cpl_parameter_new_value("fors.fors_config.instrument", 00399 CPL_TYPE_STRING, 00400 "Name of instrument", 00401 "fors.fors_config", 00402 "0"); 00403 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "instrument"); 00404 cpl_parameter_disable(p, CPL_PARAMETER_MODE_ENV); 00405 cpl_parameterlist_append(recipe->parameters, p); 00406 00407 /* 00408 * Grism name 00409 */ 00410 00411 p = cpl_parameter_new_value("fors.fors_config.grism", 00412 CPL_TYPE_STRING, 00413 "Name of grism", 00414 "fors.fors_config", 00415 "0"); 00416 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "grism"); 00417 cpl_parameter_disable(p, CPL_PARAMETER_MODE_ENV); 00418 cpl_parameterlist_append(recipe->parameters, p); 00419 00420 /* 00421 * Grism id 00422 */ 00423 00424 p = cpl_parameter_new_value("fors.fors_config.grism_id", 00425 CPL_TYPE_STRING, 00426 "Grism ID", 00427 "fors.fors_config", 00428 "0"); 00429 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "grism_id"); 00430 cpl_parameter_disable(p, CPL_PARAMETER_MODE_ENV); 00431 cpl_parameterlist_append(recipe->parameters, p); 00432 00433 /* 00434 * Filter name 00435 */ 00436 00437 p = cpl_parameter_new_value("fors.fors_config.filter", 00438 CPL_TYPE_STRING, 00439 "Name of filter", 00440 "fors.fors_config", 00441 "0"); 00442 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "filter"); 00443 cpl_parameter_disable(p, CPL_PARAMETER_MODE_ENV); 00444 cpl_parameterlist_append(recipe->parameters, p); 00445 00446 /* 00447 * Filter id 00448 */ 00449 00450 p = cpl_parameter_new_value("fors.fors_config.filter_id", 00451 CPL_TYPE_STRING, 00452 "Filter ID", 00453 "fors.fors_config", 00454 "0"); 00455 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "filter_id"); 00456 cpl_parameter_disable(p, CPL_PARAMETER_MODE_ENV); 00457 cpl_parameterlist_append(recipe->parameters, p); 00458 00459 return 0; 00460 } 00461 00462 00471 static int fors_config_exec(cpl_plugin *plugin) 00472 { 00473 cpl_recipe *recipe; 00474 00475 if (cpl_plugin_get_type(plugin) == CPL_PLUGIN_TYPE_RECIPE) 00476 recipe = (cpl_recipe *)plugin; 00477 else 00478 return -1; 00479 00480 return fors_config(recipe->parameters, recipe->frames); 00481 } 00482 00483 00492 static int fors_config_destroy(cpl_plugin *plugin) 00493 { 00494 cpl_recipe *recipe; 00495 00496 if (cpl_plugin_get_type(plugin) == CPL_PLUGIN_TYPE_RECIPE) 00497 recipe = (cpl_recipe *)plugin; 00498 else 00499 return -1; 00500 00501 cpl_parameterlist_delete(recipe->parameters); 00502 00503 return 0; 00504 } 00505 00506 00516 static int fors_config(cpl_parameterlist *parlist, cpl_frameset *frameset) 00517 { 00518 00519 const char *recipe = "fors_config"; 00520 00521 00522 /* 00523 * Input parameters 00524 */ 00525 00526 double dispersion; 00527 double peakdetection; 00528 int wdegree; 00529 int cdegree; 00530 double startwavelength; 00531 double endwavelength; 00532 /* 00533 * int wradius; 00534 * double wreject; 00535 * int wmode; 00536 * int cglobal; 00537 * int slit_ident; 00538 * int sdegree; 00539 * int ddegree; 00540 * int sradius; 00541 * int dradius; 00542 * int skyalign; 00543 */ 00544 00545 const char *instrument; 00546 const char *grism; 00547 const char *grism_id; 00548 const char *filter; 00549 const char *filter_id; 00550 00551 char *filename = NULL; 00552 00553 /* 00554 * CPL objects 00555 */ 00556 00557 cpl_table *table = NULL; 00558 cpl_propertylist *header = NULL; 00559 00560 /* 00561 * Auxiliary variables 00562 */ 00563 00564 int len; 00565 00566 00567 if (frameset){} /* To avoid compiler warning */ 00568 00569 /* 00570 * Get configuration parameters 00571 */ 00572 00573 cpl_msg_info(recipe, "Recipe %s configuration parameters:", recipe); 00574 cpl_msg_indent_more(); 00575 00576 table = cpl_table_new(1); 00577 00578 dispersion = dfs_get_parameter_double(parlist, 00579 "fors.fors_config.dispersion", NULL); 00580 00581 if (dispersion <= 0.0) 00582 fors_config_exit("Invalid spectral dispersion value"); 00583 00584 cpl_table_new_column(table, "dispersion", CPL_TYPE_DOUBLE); 00585 cpl_table_set_double(table, "dispersion", 0, dispersion); 00586 00587 peakdetection = dfs_get_parameter_double(parlist, 00588 "fors.fors_config.peakdetection", NULL); 00589 if (peakdetection <= 0.0) 00590 fors_config_exit("Invalid peak detection level"); 00591 00592 cpl_table_new_column(table, "peakdetection", CPL_TYPE_DOUBLE); 00593 cpl_table_set_double(table, "peakdetection", 0, peakdetection); 00594 00595 wdegree = dfs_get_parameter_int(parlist, "fors.fors_config.wdegree", NULL); 00596 00597 if (wdegree < 1) 00598 fors_config_exit("Invalid polynomial degree"); 00599 00600 if (wdegree > 5) 00601 fors_config_exit("Max allowed polynomial degree is 5"); 00602 00603 cpl_table_new_column(table, "wdegree", CPL_TYPE_INT); 00604 cpl_table_set_int(table, "wdegree", 0, wdegree); 00605 00606 /* 00607 * wradius = dfs_get_parameter_int(parlist, 00608 * "fors.fors_config.wradius", NULL); 00609 * 00610 * if (wradius < 0) 00611 * fors_config_exit("Invalid search radius"); 00612 * 00613 * cpl_table_new_column(table, "wradius", CPL_TYPE_INT); 00614 * cpl_table_set_int(table, "wradius", 0, wradius); 00615 * 00616 * wreject = dfs_get_parameter_double(parlist, 00617 * "fors.fors_config.wreject", NULL); 00618 * 00619 * if (wreject <= 0.0) 00620 * fors_config_exit("Invalid rejection threshold"); 00621 * 00622 * cpl_table_new_column(table, "wreject", CPL_TYPE_DOUBLE); 00623 * cpl_table_set_double(table, "wreject", 0, wreject); 00624 * 00625 * wmode = dfs_get_parameter_int(parlist, "fors.fors_config.wmode", NULL); 00626 * 00627 * if (wmode < 0 || wmode > 2) 00628 * fors_config_exit("Invalid wavelength solution interpolation mode"); 00629 * 00630 * cpl_table_new_column(table, "wmode", CPL_TYPE_INT); 00631 * cpl_table_set_int(table, "wmode", 0, wmode); 00632 */ 00633 00634 cdegree = dfs_get_parameter_int(parlist, "fors.fors_config.cdegree", NULL); 00635 00636 if (cdegree < 1) 00637 fors_config_exit("Invalid polynomial degree"); 00638 00639 if (cdegree > 5) 00640 fors_config_exit("Max allowed polynomial degree is 5"); 00641 00642 cpl_table_new_column(table, "cdegree", CPL_TYPE_INT); 00643 cpl_table_set_int(table, "cdegree", 0, cdegree); 00644 00645 /* 00646 * cglobal = dfs_get_parameter_bool(parlist, "fors.fors_config.cglobal", 00647 * NULL); 00648 * 00649 * cpl_table_new_column(table, "cglobal", CPL_TYPE_INT); 00650 * cpl_table_set_int(table, "cglobal", 0, cglobal); 00651 */ 00652 00653 startwavelength = dfs_get_parameter_double(parlist, 00654 "fors.fors_config.startwavelength", NULL); 00655 if (startwavelength > 1.0) 00656 if (startwavelength < 3000.0 || startwavelength > 13000.0) 00657 fors_config_exit("Invalid wavelength"); 00658 00659 cpl_table_new_column(table, "startwavelength", CPL_TYPE_DOUBLE); 00660 cpl_table_set_double(table, "startwavelength", 0, startwavelength); 00661 00662 endwavelength = dfs_get_parameter_double(parlist, 00663 "fors.fors_config.endwavelength", NULL); 00664 if (endwavelength > 1.0) 00665 if (endwavelength < 3000.0 || endwavelength > 13000.0) 00666 fors_config_exit("Invalid wavelength"); 00667 00668 if (startwavelength > 1.0 && endwavelength > 1.0) 00669 if (endwavelength - startwavelength <= 0.0) 00670 fors_config_exit("Invalid wavelength interval"); 00671 00672 cpl_table_new_column(table, "endwavelength", CPL_TYPE_DOUBLE); 00673 cpl_table_set_double(table, "endwavelength", 0, endwavelength); 00674 00675 /* 00676 * slit_ident = dfs_get_parameter_bool(parlist, 00677 * "fors.fors_config.slit_ident", NULL); 00678 * 00679 * cpl_table_new_column(table, "slit_ident", CPL_TYPE_INT); 00680 * cpl_table_set_int(table, "slit_ident", 0, slit_ident); 00681 * 00682 * sdegree = dfs_get_parameter_int(parlist, 00683 * "fors.fors_config.sdegree", NULL); 00684 * 00685 * cpl_table_new_column(table, "sdegree", CPL_TYPE_INT); 00686 * cpl_table_set_int(table, "sdegree", 0, sdegree); 00687 * 00688 * ddegree = dfs_get_parameter_int(parlist, 00689 * "fors.fors_config.ddegree", NULL); 00690 * 00691 * cpl_table_new_column(table, "ddegree", CPL_TYPE_INT); 00692 * cpl_table_set_int(table, "ddegree", 0, ddegree); 00693 * 00694 * sradius = dfs_get_parameter_int(parlist, 00695 * "fors.fors_config.sradius", NULL); 00696 * dradius = dfs_get_parameter_int(parlist, 00697 * "fors.fors_config.dradius", NULL); 00698 * 00699 * if (sradius < 1 || dradius < 1) 00700 * fors_config_exit("Invalid smoothing box radius"); 00701 * 00702 * cpl_table_new_column(table, "sradius", CPL_TYPE_INT); 00703 * cpl_table_set_int(table, "sradius", 0, sradius); 00704 * cpl_table_new_column(table, "dradius", CPL_TYPE_INT); 00705 * cpl_table_set_int(table, "dradius", 0, dradius); 00706 * 00707 * skyalign = dfs_get_parameter_int(parlist, "fors.fors_config.skyalign", 00708 * NULL); 00709 * 00710 * cpl_table_new_column(table, "skyalign", CPL_TYPE_INT); 00711 * cpl_table_set_int(table, "skyalign", 0, skyalign); 00712 */ 00713 00714 header = cpl_propertylist_new(); 00715 00716 instrument = dfs_get_parameter_string(parlist, 00717 "fors.fors_config.instrument", NULL); 00718 cpl_propertylist_update_string(header, "INSTRUME", instrument); 00719 00720 grism = dfs_get_parameter_string(parlist, "fors.fors_config.grism", NULL); 00721 cpl_propertylist_update_string(header, "ESO INS GRIS1 NAME", grism); 00722 00723 grism_id = dfs_get_parameter_string(parlist, 00724 "fors.fors_config.grism_id", NULL); 00725 cpl_propertylist_update_string(header, "ESO INS GRIS1 ID", grism_id); 00726 00727 filter = dfs_get_parameter_string(parlist, "fors.fors_config.filter", NULL); 00728 cpl_propertylist_update_string(header, "ESO INS FILT1 NAME", filter); 00729 00730 filter_id = dfs_get_parameter_string(parlist, 00731 "fors.fors_config.filter_id", NULL); 00732 cpl_propertylist_update_string(header, "ESO INS FILT1 ID", filter_id); 00733 00734 if (cpl_error_get_code()) 00735 fors_config_exit("Failed to get the configuration parameters"); 00736 00737 cpl_propertylist_update_string(header, "ESO PRO CATG", "GRISM_TABLE"); 00738 00739 len = 14; 00740 len += strlen(instrument); 00741 len += strlen(grism + 5); 00742 len += strlen(grism_id); 00743 len += strlen(filter); 00744 len += strlen(filter_id); 00745 00746 filename = cpl_calloc(len, sizeof(char)); 00747 00748 sprintf(filename, "%s_GRS_%s_%s_%s_%s.fits", 00749 instrument, grism + 5, grism_id+1, filter, filter_id+1); 00750 00751 cpl_table_save(table, header, NULL, filename, CPL_IO_DEFAULT); 00752 cpl_propertylist_delete(header); header = NULL; 00753 cpl_table_delete(table); table = NULL; 00754 cpl_free(filename); filename = NULL; 00755 00756 if (cpl_error_get_code()) { 00757 cpl_msg_error(cpl_error_get_where(), cpl_error_get_message()); 00758 fors_config_exit(NULL); 00759 } 00760 else 00761 return 0; 00762 }