midi_detlin.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
00050 static int midi_detlin_create(cpl_plugin *) ;
00051 static int midi_detlin_exec(cpl_plugin *) ;
00052 static int midi_detlin_destroy(cpl_plugin *) ;
00053 static int midi_detlin(cpl_parameterlist *, cpl_frameset *) ;
00054
00055
00056
00057
00058
00059 static char midi_detlin_description[] =
00060 "The purpose of this technical template is to evaluate the linearity of the\n"
00061 "detector, i.e. the relationship between the detector counts and the number\n"
00062 "of photons.\n\n"
00063 "Input files:\n\n"
00064 " DO category: Type: Explanation: Required:\n"
00065 " DETLIN Raw Raw data frame Y\n\n"
00066 "Output files:\n\n"
00067 " DO category: Data type: Explanation:\n"
00068 " REDUCED_DETLIN FITS image linearity coefficient in the header\n"
00069 "\n";
00070
00071
00072
00073
00074
00075
00084
00085 int cpl_plugin_get_info(cpl_pluginlist * list)
00086 {
00087 cpl_recipe * recipe = cpl_calloc(1, sizeof *recipe ) ;
00088 cpl_plugin * plugin = &recipe->interface ;
00089
00090 cpl_plugin_init(plugin,
00091 CPL_PLUGIN_API,
00092 MIDI_BINARY_VERSION,
00093 CPL_PLUGIN_TYPE_RECIPE,
00094 "midi_detlin",
00095 "Evaluates the detector linearity",
00096 midi_detlin_description,
00097 "Coorosh Sabet",
00098 PACKAGE_BUGREPORT,
00099 midi_get_license(),
00100 midi_detlin_create,
00101 midi_detlin_exec,
00102 midi_detlin_destroy) ;
00103
00104 cpl_pluginlist_append(list, plugin) ;
00105
00106 return 0;
00107 }
00108
00109
00117
00118 static int midi_detlin_create(cpl_plugin * plugin)
00119 {
00120 cpl_recipe * recipe ;
00121
00122
00123
00124 if (cpl_plugin_get_type(plugin) == CPL_PLUGIN_TYPE_RECIPE)
00125 recipe = (cpl_recipe *)plugin ;
00126 else return -1 ;
00127
00128
00129 recipe->parameters = cpl_parameterlist_new() ;
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149 return 0;
00150 }
00151
00152
00158
00159 static int midi_detlin_exec(cpl_plugin * plugin)
00160 {
00161 cpl_recipe * recipe ;
00162
00163
00164 if (cpl_plugin_get_type(plugin) == CPL_PLUGIN_TYPE_RECIPE)
00165 recipe = (cpl_recipe *)plugin ;
00166 else return -1 ;
00167
00168 batchNumber=0;
00169 return midi_detlin(recipe->parameters, recipe->frames) ;
00170 }
00171
00172
00178
00179 static int midi_detlin_destroy(cpl_plugin * plugin)
00180 {
00181 cpl_recipe * recipe ;
00182
00183
00184 if (cpl_plugin_get_type(plugin) == CPL_PLUGIN_TYPE_RECIPE)
00185 recipe = (cpl_recipe *)plugin ;
00186 else return -1 ;
00187
00188 cpl_parameterlist_delete(recipe->parameters) ;
00189 return 0 ;
00190 }
00191
00192
00199
00200 static int midi_detlin(
00201 cpl_parameterlist *parlist,
00202 cpl_frameset *frameset)
00203 {
00204
00205
00206 cpl_frame *current_frame;
00207 int error=0;
00208 FILE *sofPtr=NULL;
00209
00210 int plotDuration;
00211
00212
00213
00214
00215
00216
00217
00218
00219
00220
00221
00222
00223
00224
00225
00226
00227
00228
00229 plotDuration = 0;
00230
00231 current_frame = cpl_frameset_get_first(frameset);
00232 sofPtr = fopen ("MIDI_sof.log", "w");
00233 while ( current_frame && sofPtr )
00234 {
00235 fprintf (sofPtr, "%s \n", (char *)cpl_frame_get_filename( current_frame ));
00236 current_frame = cpl_frameset_get_next( frameset );
00237 }
00238 fclose (sofPtr);
00239
00240
00241 executeDataReduction ("", "", "./", plotDuration, "MIDI_sof.log", &error,parlist,frameset);
00242
00243 if (error) return -1;
00244 remove ("MIDI_sof.log");
00245
00246
00247 if (CPL_ERROR_NONE != appendPropertylist("MIDI_b1_lin.pro.fits", CPL_FRAME_TYPE_IMAGE, "REDUCED_DETLIN",frameset,parlist))
00248 {
00249 cpl_msg_error(cpl_func,"Error in appendPropertylist");
00250 }
00251
00252
00253
00254 if (cpl_error_get_code())
00255 return -1 ;
00256 else
00257 return 0 ;
00258 }