|
GRAVI Pipeline Reference Manual 0.1.1
|
00001 /* $Id: gravi_all_wave.c,v 1.29 2011/11/21 09:16:12 nazouaoui Exp $ 00002 * 00003 * This file is part of the GRAVI Pipeline 00004 * Copyright (C) 2002,2003 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00019 */ 00020 00021 /* 00022 * $Author: nazouaoui $ 00023 * $Date: 2011/03/10 09:16:12 $ 00024 * $Revision: 1.29 $ 00025 * $Name: $ 00026 */ 00027 00028 #ifdef HAVE_CONFIG_H 00029 #include <config.h> 00030 #endif 00031 00032 /*----------------------------------------------------------------------------- 00033 Includes 00034 -----------------------------------------------------------------------------*/ 00035 00036 #include <cpl.h> 00037 #include <stdio.h> 00038 #include <string.h> 00039 00040 #include "gravi_utils.h" 00041 #include "gravi_pfits.h" 00042 #include "gravi_dfs.h" 00043 #include "gravi_calib.h" 00044 00045 #include "gravi_data.h" 00046 00047 00048 /*----------------------------------------------------------------------------- 00049 Private function prototypes 00050 -----------------------------------------------------------------------------*/ 00051 00052 static int gravi_all_wave_create(cpl_plugin *); 00053 static int gravi_all_wave_exec(cpl_plugin *); 00054 static int gravi_all_wave_destroy(cpl_plugin *); 00055 static int gravi_all_wave(cpl_frameset *, const cpl_parameterlist *); 00056 00057 /*----------------------------------------------------------------------------- 00058 Static variables 00059 -----------------------------------------------------------------------------*/ 00060 00061 static char gravi_all_wave_description[] = 00062 "This recipe is associated to the template GRAVI_ALL_WAVE.\n " 00063 "Its aim is to reduce the raw spectral file for spectrograph calibration. " 00064 "It is used in both modes Dual and Single.\n" 00065 "The description should include the required FITS-files and\n" 00066 "their associated tags, e.g.\n" 00067 "GRAVI-GRAVI_ALL_DARK-raw-file.fits " GRAVI_FT_WAVE "\n" 00068 "and any optional files, e.g.\n" 00069 "GRAVI-GRAVI_ALL_DARK-flat-file.fits " WAVE_FT "\n" 00070 "\n" 00071 "Additionally, it should describe functionality of the expected output." 00072 "\n"; 00073 00074 /*----------------------------------------------------------------------------- 00075 Function code 00076 -----------------------------------------------------------------------------*/ 00077 00078 /*----------------------------------------------------------------------------*/ 00088 /*----------------------------------------------------------------------------*/ 00089 int cpl_plugin_get_info(cpl_pluginlist * list) 00090 { 00091 cpl_recipe * recipe = cpl_calloc(1, sizeof *recipe ); 00092 cpl_plugin * plugin = &recipe->interface; 00093 00094 if (cpl_plugin_init(plugin, 00095 CPL_PLUGIN_API, 00096 GRAVI_BINARY_VERSION, 00097 CPL_PLUGIN_TYPE_RECIPE, 00098 "gravi_all_wave", 00099 "This recipe reduce the raw spectral file " 00100 "for spectrograph calibration", 00101 gravi_all_wave_description, 00102 "Firstname Lastname", 00103 PACKAGE_BUGREPORT, 00104 gravi_get_license(), 00105 gravi_all_wave_create, 00106 gravi_all_wave_exec, 00107 gravi_all_wave_destroy)) { 00108 cpl_msg_error(cpl_func, "Plugin initialization failed"); 00109 (void)cpl_error_set_where(cpl_func); 00110 return 1; 00111 } 00112 00113 if (cpl_pluginlist_append(list, plugin)) { 00114 cpl_msg_error(cpl_func, "Error adding plugin to list"); 00115 (void)cpl_error_set_where(cpl_func); 00116 return 1; 00117 } 00118 00119 return 0; 00120 } 00121 00122 /*----------------------------------------------------------------------------*/ 00130 /*----------------------------------------------------------------------------*/ 00131 static int gravi_all_wave_create(cpl_plugin * plugin) 00132 { 00133 cpl_recipe * recipe; 00134 cpl_parameter * p; 00135 00136 /* Do not create the recipe if an error code is already set */ 00137 if (cpl_error_get_code() != CPL_ERROR_NONE) { 00138 cpl_msg_error(cpl_func, "%s():%d: An error is already set: %s", 00139 cpl_func, __LINE__, cpl_error_get_where()); 00140 return (int)cpl_error_get_code(); 00141 } 00142 00143 if (plugin == NULL) { 00144 cpl_msg_error(cpl_func, "Null plugin"); 00145 cpl_ensure_code(0, (int)CPL_ERROR_NULL_INPUT); 00146 } 00147 00148 /* Verify plugin type */ 00149 if (cpl_plugin_get_type(plugin) != CPL_PLUGIN_TYPE_RECIPE) { 00150 cpl_msg_error(cpl_func, "Plugin is not a recipe"); 00151 cpl_ensure_code(0, (int)CPL_ERROR_TYPE_MISMATCH); 00152 } 00153 00154 /* Get the recipe */ 00155 recipe = (cpl_recipe *)plugin; 00156 00157 /* Create the parameters list in the cpl_recipe object */ 00158 recipe->parameters = cpl_parameterlist_new(); 00159 if (recipe->parameters == NULL) { 00160 cpl_msg_error(cpl_func, "Parameter list allocation failed"); 00161 cpl_ensure_code(0, (int)CPL_ERROR_ILLEGAL_OUTPUT); 00162 } 00163 00164 /* --the width of the profile element */ 00165 p = cpl_parameter_new_value("gravi.gravi_all_flat." 00166 "profile_width", CPL_TYPE_INT, "profile width option", 00167 "gravi.gravi_all_flat", 5); 00168 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "profile width"); 00169 cpl_parameter_disable(p, CPL_PARAMETER_MODE_ENV); 00170 cpl_parameterlist_append(recipe->parameters, p); 00171 00172 /* Fill the parameters list */ 00173 return 0; 00174 } 00175 00176 /*----------------------------------------------------------------------------*/ 00182 /*----------------------------------------------------------------------------*/ 00183 static int gravi_all_wave_exec(cpl_plugin * plugin) 00184 { 00185 00186 cpl_recipe * recipe; 00187 int recipe_status; 00188 cpl_errorstate initial_errorstate = cpl_errorstate_get(); 00189 00190 /* Return immediately if an error code is already set */ 00191 if (cpl_error_get_code() != CPL_ERROR_NONE) { 00192 cpl_msg_error(cpl_func, "%s():%d: An error is already set: %s", 00193 cpl_func, __LINE__, cpl_error_get_where()); 00194 return (int)cpl_error_get_code(); 00195 } 00196 00197 if (plugin == NULL) { 00198 cpl_msg_error(cpl_func, "Null plugin"); 00199 cpl_ensure_code(0, (int)CPL_ERROR_NULL_INPUT); 00200 } 00201 00202 /* Verify plugin type */ 00203 if (cpl_plugin_get_type(plugin) != CPL_PLUGIN_TYPE_RECIPE) { 00204 cpl_msg_error(cpl_func, "Plugin is not a recipe"); 00205 cpl_ensure_code(0, (int)CPL_ERROR_TYPE_MISMATCH); 00206 } 00207 00208 /* Get the recipe */ 00209 recipe = (cpl_recipe *)plugin; 00210 00211 /* Verify parameter and frame lists */ 00212 if (recipe->parameters == NULL) { 00213 cpl_msg_error(cpl_func, "Recipe invoked with NULL parameter list"); 00214 cpl_ensure_code(0, (int)CPL_ERROR_NULL_INPUT); 00215 } 00216 if (recipe->frames == NULL) { 00217 cpl_msg_error(cpl_func, "Recipe invoked with NULL frame set"); 00218 cpl_ensure_code(0, (int)CPL_ERROR_NULL_INPUT); 00219 } 00220 00221 /* Invoke the recipe */ 00222 recipe_status = gravi_all_wave(recipe->frames, recipe->parameters); 00223 00224 /* Ensure DFS-compliance of the products */ 00225 if (cpl_dfs_update_product_header(recipe->frames)) { 00226 if (!recipe_status) recipe_status = (int)cpl_error_get_code(); 00227 } 00228 00229 if (!cpl_errorstate_is_equal(initial_errorstate)) { 00230 /* Dump the error history since recipe execution start. 00231 At this point the recipe cannot recover from the error */ 00232 cpl_errorstate_dump(initial_errorstate, CPL_FALSE, NULL); 00233 } 00234 00235 return recipe_status; 00236 } 00237 00238 /*----------------------------------------------------------------------------*/ 00244 /*----------------------------------------------------------------------------*/ 00245 static int gravi_all_wave_destroy(cpl_plugin * plugin) 00246 { 00247 cpl_recipe * recipe; 00248 00249 if (plugin == NULL) { 00250 cpl_msg_error(cpl_func, "Null plugin"); 00251 cpl_ensure_code(0, (int)CPL_ERROR_NULL_INPUT); 00252 } 00253 00254 /* Verify plugin type */ 00255 if (cpl_plugin_get_type(plugin) != CPL_PLUGIN_TYPE_RECIPE) { 00256 cpl_msg_error(cpl_func, "Plugin is not a recipe"); 00257 cpl_ensure_code(0, (int)CPL_ERROR_TYPE_MISMATCH); 00258 } 00259 00260 /* Get the recipe */ 00261 recipe = (cpl_recipe *)plugin; 00262 00263 cpl_parameterlist_delete(recipe->parameters); 00264 00265 return 0; 00266 } 00267 00268 00269 /*----------------------------------------------------------------------------*/ 00277 /*----------------------------------------------------------------------------*/ 00278 static int gravi_all_wave(cpl_frameset * frameset, 00279 const cpl_parameterlist * parlist) 00280 { 00281 cpl_frameset * wave_frameset = NULL, * usedframes, * flat_frameset, 00282 * dark_frameset; 00283 cpl_frame * frame; 00284 cpl_propertylist * applist, * primary_hdr, *primary_hdr_dark, 00285 * profile_primary_hdr; 00286 cpl_property * p_min, * p_max; 00287 const char * input, * frame_tag, * filename; 00288 char * output; 00289 double dit, darkmean, gain, darkrms; 00290 gravi_data * raw_wave, * reduced_wave, * profile_map, * dark_map, 00291 ** raw_data, * data; 00292 int result, * shutter; 00293 int comp, nb_frame, i, test_dark = 0; 00294 00295 /* Identify the RAW and CALIB frames in the input frameset */ 00296 cpl_ensure_code(gravi_dfs_set_groups(frameset) == CPL_ERROR_NONE, 00297 cpl_error_get_code()) ; 00298 00299 /* - Extract a set of frame wave */ 00300 wave_frameset = gravi_frameset_extract_wave(frameset); 00301 flat_frameset = gravi_frameset_extract_flat_file(frameset); 00302 dark_frameset = gravi_frameset_extract_dark_file(frameset); 00303 if (cpl_frameset_is_empty(wave_frameset)) { 00304 /* To use this recipe the frameset must contain at least 00305 * one wave frame. */ 00306 cpl_frameset_delete(dark_frameset); 00307 cpl_frameset_delete(wave_frameset); 00308 cpl_frameset_delete(flat_frameset); 00309 return (int)cpl_error_set_message(cpl_func, CPL_ERROR_INVALID_TYPE, 00310 "No wave frame on the frameset") ; 00311 } 00312 nb_frame = cpl_frameset_get_size(wave_frameset); 00313 00314 /* Check and get the dark frame */ 00315 if (cpl_frameset_is_empty(dark_frameset)) { 00316 frame = cpl_frameset_get_first(wave_frameset); 00317 for (i = 0; i < nb_frame; i++){ 00318 filename = cpl_frame_get_filename(frame); 00319 data = gravi_data_load(filename); 00320 primary_hdr = gravi_data_get_propertylist(data, 00321 GRAVI_PRIMARY_HDR_NAME_EXT); 00322 shutter = gravi_shutters_check(primary_hdr); 00323 if (shutter == NULL){ 00324 cpl_frameset_delete(dark_frameset); 00325 cpl_frameset_delete(wave_frameset); 00326 cpl_frameset_delete(flat_frameset); 00327 gravi_data_delete(data); 00328 return (int)cpl_error_set_message(cpl_func, 00329 CPL_ERROR_ILLEGAL_OUTPUT, "Shutter problem"); 00330 } 00331 /* The dark file must contains all the shutter close */ 00332 if((shutter[0] == 0) && (shutter[1] == 0) && (shutter[2] == 0) 00333 && (shutter[3] == 0)){ 00334 cpl_msg_info (NULL, "This file %s is a dark file", 00335 filename); 00336 dark_map = gravi_compute_dark(data); 00337 if (cpl_error_get_code()) { 00338 cpl_frameset_delete(dark_frameset); 00339 cpl_frameset_delete(wave_frameset); 00340 cpl_frameset_delete(flat_frameset); 00341 gravi_data_delete(dark_map); 00342 gravi_data_delete(data); 00343 return (int)cpl_error_set_message(cpl_func, 00344 CPL_ERROR_ILLEGAL_OUTPUT, 00345 "Error while computing the dark_map"); 00346 } 00347 00348 /* Save the dark map */ 00349 cpl_frameset_insert(dark_frameset, cpl_frame_duplicate(frame)); 00350 frame_tag = cpl_frame_get_tag(frame) ; 00351 primary_hdr_dark = gravi_data_get_propertylist(dark_map, 00352 GRAVI_PRIMARY_HDR_NAME_EXT); 00353 applist = cpl_propertylist_new(); 00354 dit = gravi_pfits_get_dit(primary_hdr_dark); 00355 //insname = gravi_pfits_get_insname(primary_hdr_dark); 00356 darkmean = cpl_propertylist_get_double(primary_hdr_dark, 00357 QC_MEANDARK); 00358 darkrms = cpl_propertylist_get_double(primary_hdr_dark, 00359 QC_DARKRMS); 00360 00361 if (!strcmp(frame_tag, GRAVI_FT_WAVE)) 00362 cpl_propertylist_append_string(applist, CPL_DFS_PRO_CATG, 00363 DARK_FT); 00364 else if (!strcmp(frame_tag, GRAVI_SC_WAVE)) 00365 cpl_propertylist_append_string(applist, CPL_DFS_PRO_CATG, 00366 DARK_SC); 00367 00368 cpl_propertylist_append_double(applist, GRAVI_DET_DIT, dit); 00369 //cpl_propertylist_append_string(applist, "INSNAME", insname); 00370 cpl_propertylist_append_double(applist, QC_MEANDARK, darkmean); 00371 cpl_propertylist_append_double(applist, QC_DARKRMS, darkrms); 00372 00373 if (gravi_data_save(dark_map, frameset, "gravi_final_dark.fits", parlist, 00374 dark_frameset, "gravi_all_wave", applist) 00375 != CPL_ERROR_NONE){ 00376 00377 cpl_frameset_delete(dark_frameset); 00378 cpl_frameset_delete(wave_frameset); 00379 cpl_frameset_delete(flat_frameset); 00380 gravi_data_delete(dark_map); 00381 cpl_propertylist_delete(applist); 00382 gravi_data_delete(data); 00383 00384 return (int) cpl_error_set_message(cpl_func, 00385 CPL_ERROR_ILLEGAL_OUTPUT, "Could not save the dark_map" 00386 " on the output file"); 00387 } 00388 cpl_propertylist_delete(applist); 00389 00390 test_dark = 1; 00391 } 00392 frame = cpl_frameset_get_next(wave_frameset); 00393 gravi_data_delete(data); 00394 cpl_free(shutter); 00395 if (test_dark) 00396 break; 00397 } 00398 } 00399 else{ 00400 frame = cpl_frameset_get_first(dark_frameset); 00401 00402 filename = cpl_frame_get_filename(frame); 00403 00404 cpl_msg_info (NULL, "This file %s is a dark file already " 00405 "computed", filename); 00406 dark_map = gravi_data_load(filename); 00407 00408 } 00409 /* Check that the dark_map in the input frameset */ 00410 if ((dark_map == NULL)){ 00411 cpl_frameset_delete(dark_frameset); 00412 cpl_frameset_delete(wave_frameset); 00413 cpl_frameset_delete(flat_frameset); 00414 gravi_data_delete(dark_map); 00415 return (int)cpl_error_set_message(cpl_func, CPL_ERROR_ILLEGAL_INPUT, 00416 "No dark frames in the frameset"); 00417 } 00418 00419 /* Extract or conpute the profile map */ 00420 frame_tag = cpl_frame_get_tag(cpl_frameset_get_first(wave_frameset)); 00421 if (!strcmp(frame_tag, GRAVI_SC_WAVE)){ 00422 if (cpl_frameset_is_empty(flat_frameset)) { 00423 00424 /* Construction of the raw data */ 00425 raw_data = cpl_malloc(nb_frame * sizeof(gravi_data *)); 00426 frame = cpl_frameset_get_first(wave_frameset); 00427 for (i = 0; i < nb_frame; i++){ 00428 filename = cpl_frame_get_filename(frame); 00429 raw_data[i] = gravi_data_load(filename); 00430 frame = cpl_frameset_get_next(wave_frameset); 00431 } 00432 00433 /* Compute the gain and extract the gain map*/ 00434 gain = gravi_compute_gain(raw_data, nb_frame, dark_map); 00435 /* Check that the gain map in the input frameset */ 00436 00437 if ((gain == 0)){ 00438 cpl_frameset_delete(dark_frameset); 00439 cpl_frameset_delete(flat_frameset); 00440 cpl_frameset_delete(wave_frameset); 00441 gravi_data_delete(dark_map); 00442 for (i = 0; i < nb_frame; i++){ 00443 gravi_data_delete(raw_data[i]); 00444 } 00445 cpl_free(raw_data); 00446 return (int)cpl_error_set_message(cpl_func, CPL_ERROR_INVALID_TYPE, 00447 "Compute of the gain failed"); 00448 } 00449 00450 frame = cpl_frameset_get_first(wave_frameset); 00451 frame_tag = cpl_frame_get_tag(frame); 00452 00453 00454 /* Compute the profile */ 00455 profile_map = gravi_compute_profile(raw_data, dark_map, nb_frame, parlist); 00456 if (cpl_error_get_code()){ 00457 cpl_frameset_delete(dark_frameset); 00458 cpl_frameset_delete(wave_frameset); 00459 cpl_frameset_delete(flat_frameset); 00460 gravi_data_delete(profile_map); 00461 gravi_data_delete(dark_map); 00462 for (i = 0; i < nb_frame; i++){ 00463 gravi_data_delete(raw_data[i]); 00464 } 00465 cpl_free(raw_data); 00466 return (int)cpl_error_set_message(cpl_func, CPL_ERROR_INVALID_TYPE, 00467 "Compute of the profile map failed"); 00468 } 00469 00470 /* Save the profile map */ 00471 applist = cpl_propertylist_new(); 00472 cpl_propertylist_append_double (applist, QC_MEANGAIN, gain); 00473 if (!strcmp(frame_tag, GRAVI_FT_P2VM)) 00474 cpl_propertylist_append_string(applist, CPL_DFS_PRO_CATG, 00475 FLAT_FT); 00476 else if (!strcmp(frame_tag, GRAVI_SC_P2VM)) 00477 cpl_propertylist_append_string(applist, CPL_DFS_PRO_CATG, 00478 FLAT_SC); 00479 00480 if (gravi_data_save(profile_map, frameset, "gravi_final_profile.fits", parlist, 00481 wave_frameset, "gravi_all_wave", applist) 00482 != CPL_ERROR_NONE){ 00483 00484 cpl_frameset_delete(wave_frameset); 00485 cpl_frameset_delete(dark_frameset); 00486 cpl_frameset_delete(flat_frameset); 00487 for (i = 0; i < nb_frame; i++){ 00488 gravi_data_delete(raw_data[i]); 00489 } 00490 cpl_free(raw_data); 00491 gravi_data_delete(dark_map); 00492 cpl_propertylist_delete(applist); 00493 00494 return (int) cpl_error_set_message(cpl_func, 00495 CPL_ERROR_ILLEGAL_OUTPUT, "Could not save the wave_map" 00496 " on the output file"); 00497 } 00498 cpl_propertylist_delete(applist); 00499 for (i = 0; i < nb_frame; i++){ 00500 gravi_data_delete(raw_data[i]); 00501 } 00502 cpl_free(raw_data); 00503 00504 } 00505 else{ 00506 00507 frame = cpl_frameset_get_first(flat_frameset); 00508 filename = cpl_frame_get_filename(frame); 00509 profile_map = gravi_data_load(filename); 00510 } 00511 00512 00513 } 00514 else if (!strcmp(frame_tag, GRAVI_FT_WAVE)) 00515 profile_map = gravi_data_duplicate(dark_map); 00516 00517 if ((profile_map == NULL)){ 00518 cpl_frameset_delete(dark_frameset); 00519 cpl_frameset_delete(wave_frameset); 00520 cpl_frameset_delete(flat_frameset); 00521 gravi_data_delete(profile_map); 00522 gravi_data_delete(dark_map); 00523 return (int)cpl_error_set_message(cpl_func, CPL_ERROR_ILLEGAL_INPUT, 00524 "No profile frames in the frameset"); 00525 } 00526 00527 /* Apply the treatment for each wave frame contained in the frameset */ 00528 00529 frame = cpl_frameset_get_first(wave_frameset); 00530 00531 for (comp = 0; comp < nb_frame; comp++){ 00532 00533 /* Find the file name and initialization of the output name */ 00534 input = cpl_frame_get_filename(frame) ; 00535 output = cpl_sprintf("gravi_all_wave_0%d.fits", comp + 1); 00536 00537 if (input == NULL) { 00538 /* The file name does not exist */ 00539 cpl_free(output); 00540 cpl_frameset_delete(wave_frameset); 00541 return (int)cpl_error_set_message(cpl_func, CPL_ERROR_NULL_INPUT, 00542 "SOF does not have any file tagged ") ; 00543 } 00544 00545 /* This function computes the relation between spectral 00546 * element and wavelength */ 00547 raw_wave = gravi_data_load(input); 00548 00549 primary_hdr = gravi_data_get_propertylist (raw_wave, 00550 GRAVI_PRIMARY_HDR_NAME_EXT); 00551 shutter = gravi_shutters_check(primary_hdr); 00552 00553 if ((shutter [0] != 1) || (shutter [1] != 1) || 00554 (shutter [2] != 1) || (shutter [3] != 1)){ 00555 gravi_data_delete(raw_wave); 00556 cpl_free(output); 00557 continue; 00558 } 00559 00560 reduced_wave = gravi_compute_wave (raw_wave, profile_map); 00561 if (cpl_error_get_code()) { 00562 cpl_free(output); 00563 gravi_data_delete(reduced_wave); 00564 gravi_data_delete(raw_wave); 00565 gravi_data_delete(profile_map); 00566 gravi_data_delete(dark_map); 00567 cpl_frameset_delete(wave_frameset); 00568 cpl_frameset_delete(dark_frameset); 00569 cpl_frameset_delete(flat_frameset); 00570 return (int)cpl_error_set_message(cpl_func, CPL_ERROR_ILLEGAL_OUTPUT, 00571 "Error while computing the wavelength"); 00572 } 00573 00574 primary_hdr = gravi_data_get_propertylist(reduced_wave, 00575 GRAVI_PRIMARY_HDR_NAME_EXT); 00576 p_min = cpl_propertylist_get_property(primary_hdr, QC_MINWAVE); 00577 p_max = cpl_propertylist_get_property(primary_hdr, QC_MAXWAVE); 00578 00579 /* Create product frame, add DataFlow keywords, save the file, log the 00580 * saved file in the input frameset*/ 00581 usedframes = cpl_frameset_new(); 00582 cpl_frameset_insert(usedframes, cpl_frame_duplicate(frame)); 00583 applist = cpl_propertylist_new(); 00584 frame_tag = cpl_frame_get_tag(frame) ; 00585 00586 if (!strcmp(frame_tag, GRAVI_FT_WAVE)) 00587 cpl_propertylist_append_string(applist, CPL_DFS_PRO_CATG, WAVE_FT); 00588 else if (!strcmp(frame_tag, GRAVI_SC_WAVE)) 00589 cpl_propertylist_append_string(applist, CPL_DFS_PRO_CATG, WAVE_SC); 00590 else{ 00591 cpl_free(output); 00592 gravi_data_delete(reduced_wave); 00593 gravi_data_delete(raw_wave); 00594 gravi_data_delete(profile_map); 00595 gravi_data_delete(dark_map); 00596 cpl_frameset_delete(wave_frameset); 00597 cpl_frameset_delete(dark_frameset); 00598 cpl_frameset_delete(flat_frameset); 00599 cpl_frameset_delete(usedframes); 00600 cpl_propertylist_delete(applist); 00601 return (int)cpl_error_set_message(cpl_func, CPL_ERROR_INVALID_TYPE, 00602 "Invalid type of wave tag"); 00603 } 00604 00605 cpl_propertylist_append_property(applist, p_min); 00606 cpl_propertylist_append_property(applist, p_max); 00607 00608 if (gravi_data_save(reduced_wave, frameset, output, parlist, 00609 usedframes, "gravi_all_wave", applist) 00610 != CPL_ERROR_NONE){ 00611 cpl_free(output); 00612 gravi_data_delete(reduced_wave); 00613 gravi_data_delete(raw_wave); 00614 gravi_data_delete(profile_map); 00615 gravi_data_delete(dark_map); 00616 cpl_frameset_delete(wave_frameset); 00617 cpl_frameset_delete(dark_frameset); 00618 cpl_frameset_delete(flat_frameset); 00619 cpl_frameset_delete(usedframes); 00620 cpl_propertylist_delete(applist); 00621 return (int) cpl_error_set_message(cpl_func, 00622 CPL_ERROR_ILLEGAL_OUTPUT, "Could not save the raw_wave" 00623 " on the output file"); 00624 } 00625 00626 frame = cpl_frameset_get_next(wave_frameset); 00627 00628 gravi_data_delete(reduced_wave); 00629 gravi_data_delete(raw_wave); 00630 cpl_frameset_delete(usedframes); 00631 cpl_propertylist_delete(applist); 00632 cpl_free(output); 00633 00634 } 00635 00636 /* Deallocation of all variables */ 00637 gravi_data_delete(profile_map); 00638 gravi_data_delete(dark_map); 00639 cpl_frameset_delete(dark_frameset); 00640 cpl_frameset_delete(flat_frameset); 00641 cpl_frameset_delete(wave_frameset); 00642 00643 return (int)cpl_error_get_code(); 00644 } 00645 00646
1.7.4