36#include "eris_utils.h"
37#include "eris_pfits.h"
48static char eris_recipe_calib_description[] =
49"This example text is used to describe the recipe.\n"
50"The description should include the required FITS-files and\n"
51"their associated tags, e.g.\n"
52"ERIS-ERIS_RECIPE-CALIB-raw-file.fits " ERIS_RECIPE_CALIB_RAW
"\n"
54"Additionally, it should describe functionality of the expected output."
61cpl_recipe_define(eris_recipe_calib, ERIS_BINARY_VERSION,
"Firstname Lastname",
62 PACKAGE_BUGREPORT,
"2017",
63 "Short description of eris_recipe_calib",
64 eris_recipe_calib_description);
81cpl_error_code eris_recipe_calib_fill_parameterlist(cpl_parameterlist *self)
83 cpl_errorstate prestate = cpl_errorstate_get();
88 p = cpl_parameter_new_value(
"eris.eris_recipe_calib.str_option",
89 CPL_TYPE_STRING,
"the string option",
90 "eris.eris_recipe_calib",NULL);
91 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI,
"stropt");
92 cpl_parameter_disable(p, CPL_PARAMETER_MODE_ENV);
93 cpl_parameterlist_append(self, p);
96 p = cpl_parameter_new_value(
"eris.eris_recipe_calib.bool_option",
97 CPL_TYPE_BOOL,
"a flag",
"eris.eris_recipe_calib", TRUE);
98 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI,
"boolopt");
99 cpl_parameter_disable(p, CPL_PARAMETER_MODE_ENV);
100 cpl_parameterlist_append(self, p);
102 return cpl_errorstate_is_equal(prestate) ? CPL_ERROR_NONE
103 : cpl_error_set_where(cpl_func);
114static int eris_recipe_calib(cpl_frameset * frameset,
115 const cpl_parameterlist * parlist)
117 const cpl_parameter * param;
118 const char * str_option;
120 cpl_frameset * rawframes;
121 const cpl_frame * firstframe;
123 cpl_propertylist * plist;
124 cpl_propertylist * applist;
131 cpl_errorstate prestate = cpl_errorstate_get();
135 param = cpl_parameterlist_find_const(parlist,
136 "eris.eris_recipe_calib.str_option");
137 str_option = cpl_parameter_get_string(param);
140 param = cpl_parameterlist_find_const(parlist,
141 "eris.eris_recipe_calib.bool_option");
142 bool_option = cpl_parameter_get_bool(param);
144 if (!cpl_errorstate_is_equal(prestate)) {
145 return (
int)cpl_error_set_message(cpl_func, cpl_error_get_code(),
146 "Could not retrieve the input "
152 cpl_error_get_code());
156 rawframes = cpl_frameset_new();
158 for (i = 0; i<cpl_frameset_get_size(frameset); i++) {
159 const cpl_frame * current_frame;
160 current_frame = cpl_frameset_get_position_const(frameset, i);
161 if(!strcmp(cpl_frame_get_tag(current_frame), ERIS_RECIPE_CALIB_RAW)) {
162 cpl_frame * new_frame = cpl_frame_duplicate(current_frame);
163 cpl_frameset_insert(rawframes, new_frame);
168 return (
int)cpl_error_set_message(cpl_func, CPL_ERROR_DATA_NOT_FOUND,
169 "SOF does not have any file tagged "
170 "with %s", ERIS_RECIPE_CALIB_RAW);
175 firstframe = cpl_frameset_get_position_const(rawframes, 0);
179 plist = cpl_propertylist_load_regexp(cpl_frame_get_filename(firstframe),
183 return (
int)cpl_error_set_message(cpl_func, cpl_error_get_code(),
184 "Could not read the FITS header");
187 if (bool_option == CPL_FALSE) {
188 cpl_msg_info(cpl_func,
"Bool option unset: String: %s", str_option);
192 cpl_propertylist_delete(plist);
196 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 (
int)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 ERIS_RECIPE_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,
"eris_recipe_calib", applist,
219 NULL, PACKAGE
"/" PACKAGE_VERSION,
220 "eris_recipe_calib.fits")) {
222 (void)cpl_error_set_where(cpl_func);
225 cpl_image_delete(image);
226 cpl_propertylist_delete(applist);
228 return (
int)cpl_error_get_code();
cpl_error_code eris_dfs_set_groups(cpl_frameset *self)
Set the group as RAW or CALIB in a frameset.
double eris_pfits_get_dit(const cpl_propertylist *plist)
find out the DIT value