30#include "iiinstrument_utils.h"
31#include "iiinstrument_pfits.h"
32#include "iiinstrument_dfs.h"
43#define RECIPE_NAME "rrrecipe_postproc"
44#define CONTEXT "iiinstrument."RECIPE_NAME
64static char rrrecipe_postproc_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-SCIENCE.fits " RRRECIPE_OUT_PROCATG
"\n"
70 "Additionally, it should describe functionality of the expected output."
74cpl_recipe_define( rrrecipe_postproc,
75 IIINSTRUMENT_BINARY_VERSION,
80 rrrecipe_postproc_description);
107static int rrrecipe_postproc(
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_OUT_PROCATG)) {
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_OUT_PROCATG);
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");
208 if (bool_option == CPL_TRUE) {
209 cpl_msg_info(cpl_func,
"Performing algorithm" );
212 applist = cpl_propertylist_new();
215 cpl_propertylist_append_string(applist, CPL_DFS_PRO_CATG,
216 RRRECIPE_OUT_POSTPROC_PROCATG);
219 cpl_propertylist_append_double(applist,
"ESO QC QCPARAM", qc_param);
222 if (cpl_dfs_save_image(frameset, NULL, parlist, frameset, NULL, image,
223 CPL_BPP_IEEE_FLOAT, RECIPE_NAME, applist,
224 NULL, PACKAGE
"/" PACKAGE_VERSION,
225 "rrrecipe_postproc.fits")) {
227 (void)cpl_error_set_where(cpl_func);
232 cpl_image_delete(image);
233 cpl_propertylist_delete(applist);
236 return cpl_error_get_code();
251static cpl_error_code rrrecipe_postproc_fill_parameterlist(
252 cpl_parameterlist *self)
255 cpl_errorstate prestate = cpl_errorstate_get();
261 par = cpl_parameter_new_value(CONTEXT
".str_option",
262 CPL_TYPE_STRING,
"the string option",
264 cpl_parameter_set_alias(par, CPL_PARAMETER_MODE_CLI,
"stropt");
265 cpl_parameter_disable(par, CPL_PARAMETER_MODE_ENV);
266 cpl_parameterlist_append(self, par);
269 par = cpl_parameter_new_value(CONTEXT
".bool_option",
270 CPL_TYPE_BOOL,
"a flag",
272 cpl_parameter_set_alias(par, CPL_PARAMETER_MODE_CLI,
"boolopt");
273 cpl_parameter_disable(par, CPL_PARAMETER_MODE_ENV);
274 cpl_parameterlist_append(self, par);
278 if (!cpl_errorstate_is_equal(prestate)) {
279 return cpl_error_set_message(cpl_func, cpl_error_get_code(),
280 "rrrecipe_postproc_fill_parameterlist failed!");
283 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