38 #include "midi_utils.h"
39 #include "midi_pfits.h"
41 #include "midiControl.h"
42 #include "midiGlobal.h"
43 #include "midiAppendPropertylist.h"
50 static int midi_detlin_create(cpl_plugin *) ;
51 static int midi_detlin_exec(cpl_plugin *) ;
52 static int midi_detlin_destroy(cpl_plugin *) ;
53 static int midi_detlin(cpl_parameterlist *, cpl_frameset *) ;
59 static char midi_detlin_description[] =
60 "The purpose of this technical template is to evaluate the linearity of the\n"
61 "detector, i.e. the relationship between the detector counts and the number\n"
64 " DO category: Type: Explanation: Required:\n"
65 " DETLIN Raw Raw data frame Y\n\n"
67 " DO category: Data type: Explanation:\n"
68 " REDUCED_DETLIN FITS image linearity coefficient in the header\n"
87 cpl_recipe * recipe = cpl_calloc(1,
sizeof *recipe ) ;
88 cpl_plugin * plugin = &recipe->interface ;
90 cpl_plugin_init(plugin,
93 CPL_PLUGIN_TYPE_RECIPE,
95 "Evaluates the detector linearity",
96 midi_detlin_description,
102 midi_detlin_destroy) ;
104 cpl_pluginlist_append(list, plugin) ;
118 static int midi_detlin_create(cpl_plugin * plugin)
120 cpl_recipe * recipe ;
124 if (cpl_plugin_get_type(plugin) == CPL_PLUGIN_TYPE_RECIPE)
125 recipe = (cpl_recipe *)plugin ;
129 recipe->parameters = cpl_parameterlist_new() ;
159 static int midi_detlin_exec(cpl_plugin * plugin)
161 cpl_recipe * recipe ;
164 if (cpl_plugin_get_type(plugin) == CPL_PLUGIN_TYPE_RECIPE)
165 recipe = (cpl_recipe *)plugin ;
169 return midi_detlin(recipe->parameters, recipe->frames) ;
179 static int midi_detlin_destroy(cpl_plugin * plugin)
181 cpl_recipe * recipe ;
184 if (cpl_plugin_get_type(plugin) == CPL_PLUGIN_TYPE_RECIPE)
185 recipe = (cpl_recipe *)plugin ;
188 cpl_parameterlist_delete(recipe->parameters) ;
200 static int midi_detlin(
201 cpl_parameterlist *parlist,
202 cpl_frameset *frameset)
206 cpl_frame *current_frame;
231 current_frame = cpl_frameset_get_first(frameset);
232 sofPtr = fopen (
"MIDI_sof.log",
"w");
233 while ( current_frame && sofPtr )
235 fprintf (sofPtr,
"%s \n", (
char *)cpl_frame_get_filename( current_frame ));
236 current_frame = cpl_frameset_get_next( frameset );
241 executeDataReduction (
"",
"",
"./", plotDuration,
"MIDI_sof.log", &error,parlist,frameset);
243 if (error)
return -1;
244 remove (
"MIDI_sof.log");
247 if (CPL_ERROR_NONE != appendPropertylist(
"MIDI_b1_lin.pro.fits", CPL_FRAME_TYPE_IMAGE,
"REDUCED_DETLIN",frameset,parlist))
249 cpl_msg_error(cpl_func,
"Error in appendPropertylist");
254 if (cpl_error_get_code())