36#include "eris_utils.h"
37#include "eris_pfits.h"
46static const char eris_recipe_description[] =
47"This example text is used to describe the recipe.\n"
48"The description should include the required FITS-files and\n"
49"their associated tags, e.g.\n"
50"ERIS-ERIS_RECIPE-raw-file.fits " ERIS_RECIPE_RAW
"\n"
51"and any optional files, e.g.\n"
52"ERIS-ERIS_RECIPE-flat-file.fits " ERIS_CALIB_FLAT
"\n"
54"Additionally, it should describe functionality of the expected output."
57static const char eris_recipe_name[] =
"eris_recipe";
63cpl_recipe_define(eris_recipe, ERIS_BINARY_VERSION,
"Firstname Lastname",
64 PACKAGE_BUGREPORT,
"2017",
65 "Short description of eris_recipe",
66 eris_recipe_description);
81static cpl_error_code eris_recipe_fill_parameterlist(cpl_parameterlist *self)
83 cpl_errorstate prestate = cpl_errorstate_get();
88 p = cpl_parameter_new_value(
"eris.eris_recipe.str_option",
89 CPL_TYPE_STRING,
"the string option",
90 "eris.eris_recipe",
"NONE");
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);
95 p = cpl_parameter_new_value(
"eris.eris_recipe.file_option",
96 CPL_TYPE_STRING,
"the file option",
97 "eris.eris_recipe",
"NONE");
98 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI,
"fileopt");
99 cpl_parameter_disable(p, CPL_PARAMETER_MODE_ENV);
100 cpl_parameterlist_append(self, p);
103 p = cpl_parameter_new_value(
"eris.eris_recipe.bool_option",
104 CPL_TYPE_BOOL,
"a flag",
105 "eris.eris_recipe", TRUE);
106 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI,
"boolopt");
107 cpl_parameter_disable(p, CPL_PARAMETER_MODE_ENV);
108 cpl_parameterlist_append(self, p);
110 p = cpl_parameter_new_value(
"eris.eris_recipe.int_option",
111 CPL_TYPE_INT,
"an integer",
112 "eris.eris_recipe", 3);
113 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI,
"intopt");
114 cpl_parameter_disable(p, CPL_PARAMETER_MODE_ENV);
115 cpl_parameterlist_append(self, p);
117 p = cpl_parameter_new_value(
"eris.eris_recipe.float_option", CPL_TYPE_DOUBLE,
120 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI,
"floatopt");
121 cpl_parameter_disable(p, CPL_PARAMETER_MODE_ENV);
122 cpl_parameterlist_append(self, p);
124 p = cpl_parameter_new_range(
"eris.eris_recipe.range_option", CPL_TYPE_INT,
125 "This is a value range of type int",
126 "Example", 3, 0, 10);
127 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI,
"rangeopt");
128 cpl_parameter_disable(p, CPL_PARAMETER_MODE_ENV);
129 cpl_parameterlist_append(self, p);
131 p = cpl_parameter_new_enum(
"eris.eris_recipe.enum_option", CPL_TYPE_STRING,
132 "This is an enumeration of type string",
133 "Example",
"first", 3,
"first",
"second",
"third");
134 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI,
"enumopt");
135 cpl_parameter_disable(p, CPL_PARAMETER_MODE_ENV);
136 cpl_parameterlist_append(self, p);
138 p = cpl_parameter_new_range(
"eris.eris_recipe.float_range_option", CPL_TYPE_DOUBLE,
139 "This is a value range of type float."
140 " Valid ragne is [-5.5, 5.5]",
141 "Example", 3.5, -5.5, 5.5);
142 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI,
"floatrangeopt");
143 cpl_parameter_disable(p, CPL_PARAMETER_MODE_ENV);
144 cpl_parameterlist_append(self, p);
146 return cpl_errorstate_is_equal(prestate) ? CPL_ERROR_NONE
147 : cpl_error_set_where(cpl_func);
158static int eris_recipe(cpl_frameset * frameset,
159 const cpl_parameterlist * parlist)
161 const cpl_parameter * param;
162 const char * str_option;
164 const cpl_frame * rawframe;
165 const cpl_frame * flat;
167 cpl_propertylist * plist;
168 cpl_propertylist * applist;
173 cpl_errorstate prestate = cpl_errorstate_get();
177 param = cpl_parameterlist_find_const(parlist,
178 "eris.eris_recipe.str_option");
179 str_option = cpl_parameter_get_string(param);
182 param = cpl_parameterlist_find_const(parlist,
183 "eris.eris_recipe.bool_option");
184 bool_option = cpl_parameter_get_bool(param);
186 if (!cpl_errorstate_is_equal(prestate)) {
187 return (
int)cpl_error_set_message(cpl_func, cpl_error_get_code(),
188 "Could not retrieve the input "
194 cpl_error_get_code());
198 rawframe = cpl_frameset_find_const(frameset, ERIS_RECIPE_RAW);
199 if (rawframe == NULL) {
202 return (
int)cpl_error_set_message(cpl_func, CPL_ERROR_DATA_NOT_FOUND,
203 "SOF does not have any file tagged "
204 "with %s", ERIS_RECIPE_RAW);
207 flat = cpl_frameset_find(frameset, ERIS_CALIB_FLAT);
209 cpl_msg_warning(cpl_func,
"SOF does not have any file tagged with %s",
215 plist = cpl_propertylist_load_regexp(cpl_frame_get_filename(rawframe),
219 return (
int)cpl_error_set_message(cpl_func, cpl_error_get_code(),
220 "Could not read the FITS header");
223 if (bool_option == CPL_FALSE) {
224 cpl_msg_info(cpl_func,
"Bool option unset: String: %s", str_option);
228 cpl_propertylist_delete(plist);
232 cpl_ensure_code(cpl_errorstate_is_equal(prestate), cpl_error_get_code());
236 image = cpl_image_load(cpl_frame_get_filename(rawframe), CPL_TYPE_FLOAT, 0,
239 return (
int)cpl_error_set_message(cpl_func, cpl_error_get_code(),
240 "Could not load the image");
243 applist = cpl_propertylist_new();
246 cpl_propertylist_append_string(applist, CPL_DFS_PRO_CATG,
247 ERIS_RECIPE_OUT_PROCATG);
250 cpl_propertylist_append_double(applist,
"ESO QC QCPARAM", qc_param);
253 if (cpl_dfs_save_image(frameset, NULL, parlist, frameset, NULL, image,
254 CPL_BPP_IEEE_FLOAT,
"eris_recipe", applist,
255 NULL, PACKAGE
"/" PACKAGE_VERSION,
256 "eris_recipe.fits")) {
258 (void)cpl_error_set_where(cpl_func);
261 cpl_image_delete(image);
262 cpl_propertylist_delete(applist);
264 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