midi_refpix.c
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #ifdef HAVE_CONFIG_H
00029 #include <config.h>
00030 #endif
00031
00032
00033
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
00047
00048
00049 static int midi_refpix_create(cpl_plugin *) ;
00050 static int midi_refpix_exec(cpl_plugin *) ;
00051 static int midi_refpix_destroy(cpl_plugin *) ;
00052 static int midi_refpix(cpl_parameterlist *, cpl_frameset *) ;
00053
00054
00055
00056
00057
00058 static char midi_refpix_description[] =
00059 "The purpose of this technical template is to evaluate the reference\n"
00060 "positions of the VLTI beams on the MIDI detector for the fine positioning\n"
00061 "of the target. The reference pixels of MIDI are the pixels of the detector\n"
00062 "onto which the centroids of the target images must fall in order to ensure\n"
00063 "a proper beam overlap.\n\n"
00064 "Input files:\n\n"
00065 " DO category: Type: Explanation: Required:\n"
00066 " REFPIX Raw Raw data frame Y\n\n"
00067 "Output files:\n\n"
00068 " DO category: Data type: Explanation:\n"
00069 " REDUCED_ REFPIX FITS image reference pixel description (header)"
00070 "\n\n";
00071
00072
00073
00074
00075
00076
00085
00086 int cpl_plugin_get_info(cpl_pluginlist * list)
00087 {
00088 cpl_recipe * recipe = cpl_calloc(1, sizeof *recipe ) ;
00089 cpl_plugin * plugin = &recipe->interface ;
00090
00091 cpl_plugin_init(plugin,
00092 CPL_PLUGIN_API,
00093 MIDI_BINARY_VERSION,
00094 CPL_PLUGIN_TYPE_RECIPE,
00095 "midi_refpix",
00096 "Evaluates the reference positions of the VLTI beams",
00097 midi_refpix_description,
00098 "Coorosh Sabet",
00099 PACKAGE_BUGREPORT,
00100 midi_get_license(),
00101 midi_refpix_create,
00102 midi_refpix_exec,
00103 midi_refpix_destroy) ;
00104
00105 cpl_pluginlist_append(list, plugin) ;
00106
00107 return 0;
00108 }
00109
00110
00118
00119 static int midi_refpix_create(cpl_plugin * plugin)
00120 {
00121 cpl_recipe * recipe ;
00122
00123
00124
00125 if (cpl_plugin_get_type(plugin) == CPL_PLUGIN_TYPE_RECIPE)
00126 recipe = (cpl_recipe *)plugin ;
00127 else return -1 ;
00128
00129
00130 recipe->parameters = cpl_parameterlist_new() ;
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151 return 0;
00152 }
00153
00154
00160
00161 static int midi_refpix_exec(cpl_plugin * plugin)
00162 {
00163 cpl_recipe * recipe ;
00164
00165
00166 if (cpl_plugin_get_type(plugin) == CPL_PLUGIN_TYPE_RECIPE)
00167 recipe = (cpl_recipe *)plugin ;
00168 else return -1 ;
00169
00170 batchNumber=0;
00171 return midi_refpix(recipe->parameters, recipe->frames) ;
00172 }
00173
00174
00180
00181 static int midi_refpix_destroy(cpl_plugin * plugin)
00182 {
00183 cpl_recipe * recipe ;
00184
00185
00186 if (cpl_plugin_get_type(plugin) == CPL_PLUGIN_TYPE_RECIPE)
00187 recipe = (cpl_recipe *)plugin ;
00188 else return -1 ;
00189
00190 cpl_parameterlist_delete(recipe->parameters) ;
00191 return 0 ;
00192 }
00193
00194
00201
00202 static int midi_refpix(
00203 cpl_parameterlist *parlist,
00204 cpl_frameset *frameset)
00205 {
00206
00207
00208 cpl_frame *current_frame;
00209 int error=0;
00210 FILE *sofPtr=NULL;
00211
00212 int plotDuration;
00213
00214
00215
00216
00217
00218
00219
00220
00221
00222
00223
00224
00225
00226
00227
00228
00229
00230
00231
00232 plotDuration = 0;
00233
00234 current_frame = cpl_frameset_get_first(frameset);
00235 sofPtr = fopen ("MIDI_sof.log", "w");
00236 while ( current_frame && sofPtr )
00237 {
00238 fprintf (sofPtr, "%s \n", (char *)cpl_frame_get_filename( current_frame ));
00239 current_frame = cpl_frameset_get_next( frameset );
00240 }
00241 fclose (sofPtr);
00242
00243
00244 executeDataReduction ("", "", "./", plotDuration, "MIDI_sof.log", &error,parlist,frameset);
00245
00246 if (error) return -1;
00247 remove ("MIDI_sof.log");
00248
00249 if (CPL_ERROR_NONE != appendPropertylist("MIDI_b1_pix.pro.fits", CPL_FRAME_TYPE_IMAGE, "REDUCED_REFPIX",frameset,parlist))
00250 {
00251 cpl_msg_error(cpl_func,"Error in appendPropertylist");
00252 }
00253
00254
00255
00256 if (cpl_error_get_code())
00257 return -1 ;
00258 else
00259 return 0 ;
00260 }
00261