visir_util_inputs.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 "visir_recipe.h"
00037
00038
00039
00040
00041
00042
00043
00044 #define RECIPE_STRING "visir_util_inputs"
00045
00046
00047
00048
00049
00050 static cpl_error_code visir_util_inputs_save(cpl_frameset *,
00051 const cpl_parameterlist *,
00052 const cpl_imagelist *);
00053
00054 VISIR_RECIPE_DEFINE(visir_util_inputs,
00055 VISIR_PARAM_NODPOS | VISIR_PARAM_AUTOBPM |
00056 VISIR_PARAM_STRIPITE | VISIR_PARAM_STRIPMOR |
00057 VISIR_PARAM_GLITCH | VISIR_PARAM_PURGE,
00058 "Conversion of raw images to nodded images",
00059 "The files listed in the Set Of Frames (sof-file) "
00060 "must be tagged:\n"
00061 "VISIR-raw-file.fits " VISIR_UTIL_INPUTS_RAW
00062 "\nAdditionally, a bad pixel map\n"
00063 "may be added to the Set Of Frames "
00064 "with tag: " VISIR_CALIB_BPM "."
00065 "\nAdditionally, a flat field\n"
00066 "may be added to the Set Of Frames "
00067 "with tag: " VISIR_CALIB_FLAT ".\n"
00068 "\nThe product(s) will have a FITS card\n"
00069 "'HIERARCH ESO PRO CATG' with a value of:\n"
00070 VISIR_UTIL_INPUTS_COMBINED_PROCATG);
00071
00072
00076
00077
00078
00079
00080
00081
00082
00089
00090 static int visir_util_inputs(cpl_frameset * framelist,
00091 const cpl_parameterlist * parlist)
00092 {
00093 irplib_framelist * allframes = NULL;
00094 irplib_framelist * rawframes = NULL;
00095 const char * badpix;
00096 const char * flat;
00097 cpl_imagelist * nodded = NULL;
00098
00099
00100
00101 skip_if (visir_dfs_set_groups(framelist));
00102
00103
00104 allframes = irplib_framelist_cast(framelist);
00105 skip_if(allframes == NULL);
00106 rawframes = irplib_framelist_extract(allframes, VISIR_UTIL_INPUTS_RAW);
00107 skip_if (rawframes == NULL);
00108
00109
00110 badpix = irplib_frameset_find_file(framelist, VISIR_CALIB_BPM);
00111
00112
00113 flat = irplib_frameset_find_file(framelist, VISIR_CALIB_FLAT);
00114
00115 skip_if(irplib_framelist_load_propertylist_all(rawframes, 0,
00116 visir_property_regexp,
00117 CPL_FALSE));
00118
00119
00120 cpl_msg_info(cpl_func, "Construct the nodded images");
00121 nodded = visir_inputs_combine(RECIPE_STRING, parlist, rawframes, badpix, flat,
00122 NULL, CPL_FALSE, 0.0, 0);
00123 if (nodded == NULL) {
00124 cpl_msg_error(cpl_func, "Cannot combine the input frames");
00125 skip_if(1);
00126 }
00127
00128
00129 cpl_msg_info(cpl_func, "Save the results");
00130 skip_if (visir_util_inputs_save(framelist, parlist, nodded));
00131
00132 end_skip;
00133
00134 irplib_framelist_delete(allframes);
00135 irplib_framelist_delete(rawframes);
00136
00137 cpl_imagelist_delete(nodded);
00138
00139 return cpl_error_get_code();
00140 }
00141
00142
00150
00151 static cpl_error_code visir_util_inputs_save(cpl_frameset * set,
00152 const cpl_parameterlist * parlist,
00153 const cpl_imagelist * nodded)
00154 {
00155
00156 int i;
00157 char * filename = NULL;
00158
00159
00160 bug_if (nodded == NULL);
00161
00162
00163 for (i=0 ; i < cpl_imagelist_get_size(nodded) ; i++) {
00164 cpl_free(filename);
00165 filename = cpl_sprintf(RECIPE_STRING "%d" CPL_DFS_FITS, i+1);
00166 skip_if (irplib_dfs_save_image(set, parlist, set,
00167 cpl_imagelist_get_const(nodded, i),
00168 CPL_BPP_IEEE_FLOAT, RECIPE_STRING,
00169 VISIR_UTIL_INPUTS_COMBINED_PROCATG,
00170 NULL, NULL, visir_pipe_id, filename));
00171 }
00172
00173 end_skip;
00174
00175 cpl_free(filename);
00176
00177 return cpl_error_get_code();
00178 }