|
KMOS Pipeline Reference Manual
1.3.17
|
00001 /* 00002 * This file is part of the KMOS Pipeline 00003 * Copyright (C) 2002,2003 European Southern Observatory 00004 * 00005 * This program is free software; you can redistribute it and/or modify 00006 * it under the terms of the GNU General Public License as published by 00007 * the Free Software Foundation; either version 2 of the License, or 00008 * (at your option) any later version. 00009 * 00010 * This program is distributed in the hope that it will be useful, 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 * GNU General Public License for more details. 00014 * 00015 * You should have received a copy of the GNU General Public License 00016 * along with this program; if not, write to the Free Software 00017 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00018 */ 00019 00020 #ifdef HAVE_CONFIG_H 00021 #include <config.h> 00022 #endif 00023 00024 /*----------------------------------------------------------------------------- 00025 * Includes 00026 *----------------------------------------------------------------------------*/ 00027 00028 #include <string.h> 00029 #include <math.h> 00030 00031 #include <cpl.h> 00032 00033 #include "kmo_utils.h" 00034 #include "kmos_oscan.h" 00035 00036 /*----------------------------------------------------------------------------- 00037 * Functions prototypes 00038 *----------------------------------------------------------------------------*/ 00039 00040 static int kmos_test_create(cpl_plugin *); 00041 static int kmos_test_exec(cpl_plugin *); 00042 static int kmos_test_destroy(cpl_plugin *); 00043 static int kmos_test(cpl_parameterlist *, cpl_frameset *); 00044 00045 /*----------------------------------------------------------------------------- 00046 * Static variables 00047 *----------------------------------------------------------------------------*/ 00048 00049 static char kmos_test_description[] = "Testing recipe\n" ; 00050 00051 int cpl_plugin_get_info(cpl_pluginlist *list) 00052 { 00053 cpl_recipe *recipe = cpl_calloc(1, sizeof *recipe); 00054 cpl_plugin *plugin = &recipe->interface; 00055 00056 cpl_plugin_init(plugin, 00057 CPL_PLUGIN_API, 00058 KMOS_BINARY_VERSION, 00059 CPL_PLUGIN_TYPE_RECIPE, 00060 "kmos_test", 00061 "test", 00062 kmos_test_description, 00063 "Yves Jung", 00064 "yjung@eso.org", 00065 kmos_get_license(), 00066 kmos_test_create, 00067 kmos_test_exec, 00068 kmos_test_destroy); 00069 00070 cpl_pluginlist_append(list, plugin); 00071 00072 return 0; 00073 } 00074 static int kmos_test_create(cpl_plugin *plugin) 00075 { 00076 cpl_recipe *recipe; 00077 cpl_parameter *p; 00078 00079 /* Check that the plugin is part of a valid recipe */ 00080 if (cpl_plugin_get_type(plugin) == CPL_PLUGIN_TYPE_RECIPE) 00081 recipe = (cpl_recipe *)plugin; 00082 else 00083 return -1; 00084 00085 /* Create the parameters list in the cpl_recipe object */ 00086 recipe->parameters = cpl_parameterlist_new(); 00087 00088 return 0 ; 00089 } 00090 00091 static int kmos_test_exec(cpl_plugin *plugin) 00092 { 00093 cpl_recipe *recipe; 00094 00095 /* Get the recipe out of the plugin */ 00096 if (cpl_plugin_get_type(plugin) == CPL_PLUGIN_TYPE_RECIPE) 00097 recipe = (cpl_recipe *)plugin; 00098 else return -1; 00099 00100 return kmos_test(recipe->parameters, recipe->frames); 00101 } 00102 00103 static int kmos_test_destroy(cpl_plugin *plugin) 00104 { 00105 cpl_recipe *recipe; 00106 00107 /* Get the recipe out of the plugin */ 00108 if (cpl_plugin_get_type(plugin) == CPL_PLUGIN_TYPE_RECIPE) 00109 recipe = (cpl_recipe *)plugin; 00110 else return -1 ; 00111 00112 cpl_parameterlist_delete(recipe->parameters); 00113 return 0 ; 00114 } 00115 00116 static int kmos_test(cpl_parameterlist * parlist, cpl_frameset * frameset) 00117 { 00118 cpl_frame * fr ; 00119 cpl_image * img_in, * img_in_oscan ; 00120 char * name ; 00121 int i ; 00122 00123 fr = cpl_frameset_get_position(frameset, 0); 00124 00125 /* Loop on detectors */ 00126 for (i = 1; i <= 3 ; i++) { 00127 cpl_msg_info(cpl_func, "Processing detector No. %d", i); 00128 cpl_msg_indent_more() ; 00129 00130 /* Load current detector DARK frames into an imagelist */ 00131 img_in = cpl_image_load(cpl_frame_get_filename(fr),CPL_TYPE_FLOAT,0,i); 00132 00133 /* Overscan Correction */ 00134 img_in_oscan = kmos_oscan_correct(img_in) ; 00135 if (img_in_oscan == NULL) { 00136 cpl_msg_info(__func__, "Failed on detector %d", i) ; 00137 cpl_image_delete(img_in) ; 00138 return -1 ; 00139 } 00140 cpl_image_delete(img_in) ; 00141 00142 /* Save */ 00143 name = cpl_sprintf("out_%d.fits", i) ; 00144 cpl_image_save(img_in_oscan, name, CPL_TYPE_FLOAT, NULL, 00145 CPL_IO_CREATE) ; 00146 00147 cpl_free(name) ; 00148 cpl_image_delete(img_in_oscan) ; 00149 cpl_msg_indent_less() ; 00150 } 00151 /* Free and Return */ 00152 return 0; 00153 } 00154
1.7.6.1