00001 /* $Id: midi_detron.c,v 1.6 2010/05/28 09:16:01 agabasch Exp $ 00002 * 00003 * This file is part of the MIDI 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: agabasch $ 00023 * $Date: 2010/05/28 09:16:01 $ 00024 * $Revision: 1.6 $ 00025 * $Name: midi-2_7_0 $ 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 "midi_utils.h" 00039 #include "midi_pfits.h" 00040 #include "midi_dfs.h" 00041 #include "midiControl.h" 00042 #include "midiGlobal.h" 00043 #include "midiAppendPropertylist.h" 00044 00045 /*----------------------------------------------------------------------------- 00046 Functions prototypes 00047 -----------------------------------------------------------------------------*/ 00048 00049 static int midi_detron_create(cpl_plugin *) ; 00050 static int midi_detron_exec(cpl_plugin *) ; 00051 static int midi_detron_destroy(cpl_plugin *) ; 00052 static int midi_detron(cpl_parameterlist *, cpl_frameset *) ; 00053 00054 /*----------------------------------------------------------------------------- 00055 Static variables 00056 -----------------------------------------------------------------------------*/ 00057 00058 static char midi_detron_description[] = 00059 "The purpose of this technical recipe is to evaluate the read-out noise\n" 00060 "of the detector.\n\n" 00061 "Input files:\n\n" 00062 " DO category: Type: Explanation: Required:\n" 00063 " DETRON Raw Raw data frame Y\n\n" 00064 "Output files:\n\n" 00065 " DO category: Data type: Explanation:\n" 00066 " REDUCED_DETRON FITS image detector read-out noise\n\n"; 00067 00068 /*----------------------------------------------------------------------------- 00069 Functions code 00070 -----------------------------------------------------------------------------*/ 00071 00072 /*----------------------------------------------------------------------------*/ 00081 /*----------------------------------------------------------------------------*/ 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 MIDI_BINARY_VERSION, 00090 CPL_PLUGIN_TYPE_RECIPE, 00091 "midi_detron", 00092 "Evaluates the detectors Readout Noise", 00093 midi_detron_description, 00094 "Coorosh Sabet", 00095 PACKAGE_BUGREPORT, 00096 midi_get_license(), 00097 midi_detron_create, 00098 midi_detron_exec, 00099 midi_detron_destroy) ; 00100 00101 cpl_pluginlist_append(list, plugin) ; 00102 00103 return 0; 00104 } 00105 00106 /*----------------------------------------------------------------------------*/ 00114 /*----------------------------------------------------------------------------*/ 00115 static int midi_detron_create(cpl_plugin * plugin) 00116 { 00117 cpl_recipe * recipe ; 00118 /* cpl_parameter * p ;*/ 00119 00120 /* Check that the plugin is part of a valid recipe */ 00121 if (cpl_plugin_get_type(plugin) == CPL_PLUGIN_TYPE_RECIPE) 00122 recipe = (cpl_recipe *)plugin ; 00123 else return -1 ; 00124 00125 /* Create the parameters list in the cpl_recipe object */ 00126 recipe->parameters = cpl_parameterlist_new() ; 00127 00128 /* Fill the parameters list */ 00129 00130 /* p = cpl_parameter_new_value("midi.midi_detron.productDir", */ 00131 /* CPL_TYPE_STRING, "Product directory", "midi.midi_detron", */ 00132 /* "product path. don't forget ending /"); */ 00133 /* cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "stropt1") ; */ 00134 /* cpl_parameter_disable(p, CPL_PARAMETER_MODE_ENV) ; */ 00135 /* cpl_parameterlist_append(recipe->parameters, p) ; */ 00136 00137 /* 00138 p = cpl_parameter_new_value("midi.midi_detron.plotDuration", 00139 CPL_TYPE_INT, "Plot duration (-1, 0, .. 5), -1 is the prompt mode", "midi.midi_detron", 0); 00140 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "intopt1") ; 00141 cpl_parameter_disable(p, CPL_PARAMETER_MODE_ENV) ; 00142 cpl_parameterlist_append(recipe->parameters, p) ; 00143 */ 00144 00145 00146 /* Return */ 00147 return 0; 00148 } 00149 00150 /*----------------------------------------------------------------------------*/ 00156 /*----------------------------------------------------------------------------*/ 00157 static int midi_detron_exec(cpl_plugin * plugin) 00158 { 00159 cpl_recipe * recipe ; 00160 00161 /* Get the recipe out of the plugin */ 00162 if (cpl_plugin_get_type(plugin) == CPL_PLUGIN_TYPE_RECIPE) 00163 recipe = (cpl_recipe *)plugin ; 00164 else return -1 ; 00165 00166 batchNumber=0; 00167 return midi_detron(recipe->parameters, recipe->frames) ; 00168 } 00169 00170 /*----------------------------------------------------------------------------*/ 00176 /*----------------------------------------------------------------------------*/ 00177 static int midi_detron_destroy(cpl_plugin * plugin) 00178 { 00179 cpl_recipe * recipe ; 00180 00181 /* Get the recipe out of the plugin */ 00182 if (cpl_plugin_get_type(plugin) == CPL_PLUGIN_TYPE_RECIPE) 00183 recipe = (cpl_recipe *)plugin ; 00184 else return -1 ; 00185 00186 cpl_parameterlist_delete(recipe->parameters) ; 00187 return 0 ; 00188 } 00189 00190 /*----------------------------------------------------------------------------*/ 00197 /*----------------------------------------------------------------------------*/ 00198 static int midi_detron( 00199 cpl_parameterlist *parlist, 00200 cpl_frameset *frameset) 00201 { 00202 /* const char *fctid = "midi_detron" ; */ 00203 /* cpl_parameter *param ;*/ 00204 cpl_frame *current_frame; 00205 int error=0; 00206 FILE *sofPtr=NULL; 00207 /* char *productDir; // In: Directory path of products */ 00208 int plotDuration; 00209 00210 /* RETRIEVE INPUT PARAMETERS */ 00211 00212 /* param = cpl_parameterlist_find(parlist, "midi.midi_detron.productDir"); */ 00213 /* productDir = (char *) (cpl_parameter_get_string(param)); */ 00214 /* printf ("productDir = %s \n", productDir); */ 00215 /* if (cpl_error_get_code()) */ 00216 /* { */ 00217 /* cpl_msg_error(fctid, "Failed to retrieve productDir") ; */ 00218 /* return -1 ; */ 00219 /* } */ 00220 00221 /* 00222 param = cpl_parameterlist_find(parlist, "midi.midi_detron.plotDuration"); 00223 plotDuration = cpl_parameter_get_int(param); 00224 printf ("plotDuration = %d \n", plotDuration); 00225 if ((plotDuration < -1) || (plotDuration > 5)) plotDuration = 0; 00226 */ 00227 00228 plotDuration = 0; 00229 current_frame = cpl_frameset_get_first(frameset); 00230 sofPtr = fopen ("MIDI_sof.log", "w"); 00231 while ( current_frame && sofPtr ) 00232 { 00233 fprintf (sofPtr, "%s \n", (char *)cpl_frame_get_filename( current_frame )); 00234 current_frame = cpl_frameset_get_next( frameset ); 00235 } /* All frames from frameset */ 00236 fclose (sofPtr); 00237 00238 /* NOW PERFORMING THE DATA REDUCTION */ 00239 executeDataReduction ("", "", "./", plotDuration, "MIDI_sof.log", &error,parlist,frameset); 00240 /* executeDataReduction ("", "", productDir, plotDuration, "MIDI_sof.log", &error); */ 00241 if (error) return -1; 00242 remove ("MIDI_sof.log"); 00243 00244 00245 if (CPL_ERROR_NONE != appendPropertylist("MIDI_b1_ron.pro.fits", CPL_FRAME_TYPE_IMAGE, "REDUCED_DETRON",frameset,parlist)) 00246 { 00247 cpl_msg_error(cpl_func,"Error in appendPropertylist"); 00248 } 00249 00250 00251 /* Return */ 00252 if (cpl_error_get_code()) 00253 return -1 ; 00254 else 00255 return 0 ; 00256 } 00257