38 #include "midi_utils.h"
39 #include "midi_pfits.h"
41 #include "midiControl.h"
42 #include "midiGlobal.h"
43 #include "midiAppendPropertylist.h"
49 static int midi_refpix_create(cpl_plugin *) ;
50 static int midi_refpix_exec(cpl_plugin *) ;
51 static int midi_refpix_destroy(cpl_plugin *) ;
52 static int midi_refpix(cpl_parameterlist *, cpl_frameset *) ;
58 static char midi_refpix_description[] =
59 "The purpose of this technical template is to evaluate the reference\n"
60 "positions of the VLTI beams on the MIDI detector for the fine positioning\n"
61 "of the target. The reference pixels of MIDI are the pixels of the detector\n"
62 "onto which the centroids of the target images must fall in order to ensure\n"
63 "a proper beam overlap.\n\n"
65 " DO category: Type: Explanation: Required:\n"
66 " REFPIX Raw Raw data frame Y\n\n"
68 " DO category: Data type: Explanation:\n"
69 " REDUCED_ REFPIX FITS image reference pixel description (header)"
88 cpl_recipe * recipe = cpl_calloc(1,
sizeof *recipe ) ;
89 cpl_plugin * plugin = &recipe->interface ;
91 cpl_plugin_init(plugin,
94 CPL_PLUGIN_TYPE_RECIPE,
96 "Evaluates the reference positions of the VLTI beams",
97 midi_refpix_description,
103 midi_refpix_destroy) ;
105 cpl_pluginlist_append(list, plugin) ;
119 static int midi_refpix_create(cpl_plugin * plugin)
121 cpl_recipe * recipe ;
125 if (cpl_plugin_get_type(plugin) == CPL_PLUGIN_TYPE_RECIPE)
126 recipe = (cpl_recipe *)plugin ;
130 recipe->parameters = cpl_parameterlist_new() ;
161 static int midi_refpix_exec(cpl_plugin * plugin)
163 cpl_recipe * recipe ;
166 if (cpl_plugin_get_type(plugin) == CPL_PLUGIN_TYPE_RECIPE)
167 recipe = (cpl_recipe *)plugin ;
171 return midi_refpix(recipe->parameters, recipe->frames) ;
181 static int midi_refpix_destroy(cpl_plugin * plugin)
183 cpl_recipe * recipe ;
186 if (cpl_plugin_get_type(plugin) == CPL_PLUGIN_TYPE_RECIPE)
187 recipe = (cpl_recipe *)plugin ;
190 cpl_parameterlist_delete(recipe->parameters) ;
202 static int midi_refpix(
203 cpl_parameterlist *parlist,
204 cpl_frameset *frameset)
208 cpl_frame *current_frame;
234 current_frame = cpl_frameset_get_first(frameset);
235 sofPtr = fopen (
"MIDI_sof.log",
"w");
236 while ( current_frame && sofPtr )
238 fprintf (sofPtr,
"%s \n", (
char *)cpl_frame_get_filename( current_frame ));
239 current_frame = cpl_frameset_get_next( frameset );
244 executeDataReduction (
"",
"",
"./", plotDuration,
"MIDI_sof.log", &error,parlist,frameset);
246 if (error)
return -1;
247 remove (
"MIDI_sof.log");
249 if (CPL_ERROR_NONE != appendPropertylist(
"MIDI_b1_pix.pro.fits", CPL_FRAME_TYPE_IMAGE,
"REDUCED_REFPIX",frameset,parlist))
251 cpl_msg_error(cpl_func,
"Error in appendPropertylist");
256 if (cpl_error_get_code())