70static int gravity_piezo(cpl_frameset *,
const cpl_parameterlist *);
77static char gravity_piezo_description[] =
"This recipe compute the response (open loop transfer function) of the piezo actuators used to fringe-track in GRAVITY.\n"
79 "* Compute the piezo TF QC parameter"
104 cpl_recipe * recipe = cpl_calloc(1,
sizeof *recipe );
105 cpl_plugin * plugin = &recipe->interface;
107 if (cpl_plugin_init(plugin,
109 GRAVI_BINARY_VERSION,
110 CPL_PLUGIN_TYPE_RECIPE,
114 "Nabih Azouaoui, Vincent Lapeyrere, JB. Le Bouquin",
120 cpl_msg_error(cpl_func,
"Plugin initialization failed");
121 (void)cpl_error_set_where(cpl_func);
125 if (cpl_pluginlist_append(list, plugin)) {
126 cpl_msg_error(cpl_func,
"Error adding plugin to list");
127 (void)cpl_error_set_where(cpl_func);
149 if (cpl_error_get_code() != CPL_ERROR_NONE) {
150 cpl_msg_error(cpl_func,
"%s():%d: An error is already set: %s",
151 cpl_func, __LINE__, cpl_error_get_where());
152 return (
int)cpl_error_get_code();
155 if (plugin == NULL) {
156 cpl_msg_error(cpl_func,
"Null plugin");
157 cpl_ensure_code(0, (
int)CPL_ERROR_NULL_INPUT);
161 if (cpl_plugin_get_type(plugin) != CPL_PLUGIN_TYPE_RECIPE) {
162 cpl_msg_error(cpl_func,
"Plugin is not a recipe");
163 cpl_ensure_code(0, (
int)CPL_ERROR_TYPE_MISMATCH);
167 recipe = (cpl_recipe *)plugin;
170 recipe->parameters = cpl_parameterlist_new();
171 if (recipe->parameters == NULL) {
172 cpl_msg_error(cpl_func,
"Parameter list allocation failed");
173 cpl_ensure_code(0, (
int)CPL_ERROR_ILLEGAL_OUTPUT);
197 cpl_errorstate initial_errorstate = cpl_errorstate_get();
201 if (cpl_error_get_code() != CPL_ERROR_NONE) {
202 cpl_msg_error(cpl_func,
"%s():%d: An error is already set: %s",
203 cpl_func, __LINE__, cpl_error_get_where());
204 return (
int)cpl_error_get_code();
207 if (plugin == NULL) {
208 cpl_msg_error(cpl_func,
"Null plugin");
209 cpl_ensure_code(0, (
int)CPL_ERROR_NULL_INPUT);
213 if (cpl_plugin_get_type(plugin) != CPL_PLUGIN_TYPE_RECIPE) {
214 cpl_msg_error(cpl_func,
"Plugin is not a recipe");
215 cpl_ensure_code(0, (
int)CPL_ERROR_TYPE_MISMATCH);
219 recipe = (cpl_recipe *)plugin;
222 if (recipe->parameters == NULL) {
223 cpl_msg_error(cpl_func,
"Recipe invoked with NULL parameter list");
224 cpl_ensure_code(0, (
int)CPL_ERROR_NULL_INPUT);
226 if (recipe->frames == NULL) {
227 cpl_msg_error(cpl_func,
"Recipe invoked with NULL frame set");
228 cpl_ensure_code(0, (
int)CPL_ERROR_NULL_INPUT);
232 recipe_status =
gravity_piezo(recipe->frames, recipe->parameters);
235 if (cpl_dfs_update_product_header(recipe->frames)) {
237 recipe_status = (int)cpl_error_get_code();
241 if (!cpl_errorstate_is_equal(initial_errorstate)) {
244 cpl_errorstate_dump(initial_errorstate, CPL_FALSE, NULL);
247 return recipe_status;
261 if (plugin == NULL) {
262 cpl_msg_error(cpl_func,
"Null plugin");
263 cpl_ensure_code(0, (
int)CPL_ERROR_NULL_INPUT);
267 if (cpl_plugin_get_type(plugin) != CPL_PLUGIN_TYPE_RECIPE) {
268 cpl_msg_error(cpl_func,
"Plugin is not a recipe");
269 cpl_ensure_code(0, (
int)CPL_ERROR_TYPE_MISMATCH);
273 recipe = (cpl_recipe *)plugin;
275 cpl_parameterlist_delete(recipe->parameters);
291 const cpl_parameterlist * parlist)
293 cpl_frameset * recipe_frameset=NULL, *used_frameset=NULL, * current_frameset=NULL;
295 cpl_frame * frame=NULL;
307 cpl_error_get_code()) ;
313 if (cpl_frameset_is_empty (recipe_frameset)) {
314 cpl_error_set_message (cpl_func, CPL_ERROR_ILLEGAL_INPUT,
315 "No PIEZOTF file on the frameset") ;
321 used_frameset = cpl_frameset_new();
328 nb_frame = cpl_frameset_get_size (recipe_frameset);
330 for (
int i_file = 0; i_file < nb_frame; i_file++){
331 current_frameset = cpl_frameset_duplicate (used_frameset);
333 cpl_msg_info (cpl_func,
" ***** File %d over %d ***** ", i_file+1, nb_frame);
339 frame = cpl_frameset_get_position (recipe_frameset, i_file);
346 current_frameset, frame,
"gravity_piezo",
352 FREE (cpl_frameset_delete, current_frameset);
366 FREE (cpl_frameset_delete,recipe_frameset);
367 FREE (cpl_frameset_delete,current_frameset);
368 FREE (cpl_frameset_delete,used_frameset);
371 return (
int)cpl_error_get_code();
typedefCPL_BEGIN_DECLS struct _gravi_data_ gravi_data
#define GRAVI_RECIPE_OUTPUT
#define GRAVI_PIEZOTF_MAP
#define GRAVI_RECIPE_FLOW
#define GRAVI_PIEZOTF_RAW
#define GRAVI_RECIPE_INPUT
cpl_msg_info(cpl_func, "Compute WAVE_SCAN for %s", GRAVI_TYPE(type_data))
#define CPLCHECK_CLEAN(msg)
#define gravi_msg_function_exit(flag)
#define FREE(function, variable)
#define gravi_msg_function_start(flag)
static int gravity_piezo_create(cpl_plugin *)
Setup the recipe options
static char gravity_piezo_short[]
int cpl_plugin_get_info(cpl_pluginlist *list)
Build the list of available plugins, for this module.
static int gravity_piezo_exec(cpl_plugin *)
Execute the plugin instance given by the interface.
static int gravity_piezo(cpl_frameset *, const cpl_parameterlist *)
Compute the visibilities, and closure phase and create the io fits file.
static char gravity_piezo_description[]
static int gravity_piezo_destroy(cpl_plugin *)
Destroy what has been created by the 'create' function.
gravi_data * gravi_compute_piezotf(gravi_data *data, const cpl_parameterlist *params)
Create piezo transfer function for Kalman Calibration & monitoring.
gravi_data * gravi_data_load_rawframe(cpl_frame *frame, cpl_frameset *used_frameset)
Load a RAW FITS file and create a gravi_data.
cpl_error_code gravi_data_save_new(gravi_data *self, cpl_frameset *allframes, const char *filename, const char *suffix, const cpl_parameterlist *parlist, cpl_frameset *usedframes, cpl_frame *frame, const char *recipe, cpl_propertylist *applist, const char *proCatg)
Save a gravi data in a CPL-complian FITS file.
void gravi_data_delete(gravi_data *self)
Delete a gravi data.
cpl_parameter * gravi_parameter_add_static_name(cpl_parameterlist *self)
cpl_frameset * gravi_frameset_extract_piezotf_data(cpl_frameset *frameset)
cpl_error_code gravi_dfs_set_groups(cpl_frameset *set)
Set the group as RAW or CALIB in a frameset.
void gravity_print_banner(void)
const char * gravi_get_license(void)
Get the pipeline copyright and license.