30#include "iiinstrument_utils.h"
31#include "iiinstrument_pfits.h"
32#include "iiinstrument_dfs.h"
43#define RECIPE_NAME "rrrecipe_calib"
44#define CONTEXT "iiinstrument."RECIPE_NAME
64static char rrrecipe_calib_description[] =
65 "This example text is used to describe the recipe.\n"
66 "The description should include the required FITS-files and\n"
67 "their associated tags, e.g.\n"
68 "IIINSTRUMENT-RRRECIPE-CALIB-raw-file.fits " RRRECIPE_CALIB_RAW
"\n"
70 "Additionally, it should describe functionality of the expected output."
74cpl_recipe_define( rrrecipe_calib,
75 IIINSTRUMENT_BINARY_VERSION,
80 rrrecipe_calib_description);
107static int rrrecipe_calib(
108 cpl_frameset * frameset,
109 const cpl_parameterlist * parlist)
111 const cpl_parameter *param;
112 const char *str_option;
114 cpl_frameset *rawframes;
115 const cpl_frame *firstframe;
117 cpl_propertylist *plist;
118 cpl_propertylist *applist;
125 return cpl_error_get_code();
131 cpl_errorstate prestate = cpl_errorstate_get();
137 param = cpl_parameterlist_find_const(parlist, CONTEXT
".str_option");
138 str_option = cpl_parameter_get_string(param);
141 param = cpl_parameterlist_find_const(parlist, CONTEXT
".bool_option");
142 bool_option = cpl_parameter_get_bool(param);
144 if (!cpl_errorstate_is_equal(prestate)) {
145 return cpl_error_set_message(cpl_func, cpl_error_get_code(),
146 "Could not retrieve the input parameters");
152 rawframes = cpl_frameset_new();
154 for (i = 0; i<cpl_frameset_get_size(frameset); i++) {
155 const cpl_frame * current_frame;
156 current_frame = cpl_frameset_get_position_const(frameset, i);
157 if(!strcmp(cpl_frame_get_tag(current_frame), RRRECIPE_CALIB_RAW)) {
158 cpl_frame * new_frame = cpl_frame_duplicate(current_frame);
159 cpl_frameset_insert(rawframes, new_frame);
164 return (
int)cpl_error_set_message(cpl_func, CPL_ERROR_DATA_NOT_FOUND,
165 "SOF does not have any file tagged "
166 "with %s", RRRECIPE_CALIB_RAW);
171 firstframe = cpl_frameset_get_position_const(rawframes, 0);
176 plist = cpl_propertylist_load_regexp(cpl_frame_get_filename(firstframe),
180 return cpl_error_set_message(cpl_func, cpl_error_get_code(),
181 "Could not read the FITS header");
184 if (bool_option == CPL_FALSE) {
185 cpl_msg_info(cpl_func,
"Bool option unset: String: %s", str_option);
189 cpl_propertylist_delete(plist);
194 cpl_ensure_code(cpl_errorstate_is_equal(prestate), cpl_error_get_code());
200 image = cpl_image_load(cpl_frame_get_filename(firstframe), CPL_TYPE_FLOAT, 0,
203 return cpl_error_set_message(cpl_func, cpl_error_get_code(),
204 "Could not load the image");
207 applist = cpl_propertylist_new();
210 cpl_propertylist_append_string(applist, CPL_DFS_PRO_CATG,
211 RRRECIPE_OUT_CALIB_PROCATG);
214 cpl_propertylist_append_double(applist,
"ESO QC QCPARAM", qc_param);
217 if (cpl_dfs_save_image(frameset, NULL, parlist, frameset, NULL, image,
218 CPL_BPP_IEEE_FLOAT, RECIPE_NAME, applist,
219 NULL, PACKAGE
"/" PACKAGE_VERSION,
220 "rrrecipe_calib.fits")) {
222 (void)cpl_error_set_where(cpl_func);
227 cpl_image_delete(image);
228 cpl_propertylist_delete(applist);
231 return cpl_error_get_code();
246static cpl_error_code rrrecipe_calib_fill_parameterlist(
247 cpl_parameterlist *self)
250 cpl_errorstate prestate = cpl_errorstate_get();
256 par = cpl_parameter_new_value(CONTEXT
".str_option",
257 CPL_TYPE_STRING,
"the string option",
259 cpl_parameter_set_alias(par, CPL_PARAMETER_MODE_CLI,
"stropt");
260 cpl_parameter_disable(par, CPL_PARAMETER_MODE_ENV);
261 cpl_parameterlist_append(self, par);
264 par = cpl_parameter_new_value(CONTEXT
".bool_option",
265 CPL_TYPE_BOOL,
"a flag",
267 cpl_parameter_set_alias(par, CPL_PARAMETER_MODE_CLI,
"boolopt");
268 cpl_parameter_disable(par, CPL_PARAMETER_MODE_ENV);
269 cpl_parameterlist_append(self, par);
273 if (!cpl_errorstate_is_equal(prestate)) {
274 return cpl_error_set_message(cpl_func, cpl_error_get_code(),
275 "rrrecipe_calib_fill_parameterlist failed!");
278 return CPL_ERROR_NONE;
double iiinstrument_pfits_get_dit(const cpl_propertylist *plist)
find out the DIT value
cpl_error_code iiinstrument_check_and_set_groups(cpl_frameset *frameset)
check the entries in the recipe and classify the frameset with the tags