72 "This recipe allows to manipulate the product of the GRAVITY pipeline, mostly the VIS. It permits to merge several files together into a single VIS file with all observations; to average the observations of one or several VIS file to increse the SNR; to remove some data (FT, SC); and to resample the SC observation with spectral binning.\n"
74 "The list of input files can be P2VMRED, VIS, VIS_CALIBRATED (or even RAW for some parameters). However they should all be compatible in term of setup and observed objets !! Note that the recipe performs only litle checks of the input file content and structure. Thus the user shall ensure the input files are conformable (same polarisation and spectral mode for instante)\n"
77 "* Execute request from user\n"
80 "Input files : see above\n"
82 "POSTPROCESSED : Output file\n"
102 cpl_recipe * recipe = cpl_calloc(1,
sizeof *recipe );
103 cpl_plugin * plugin = &recipe->interface;
105 if (cpl_plugin_init(plugin,
107 GRAVI_BINARY_VERSION,
108 CPL_PLUGIN_TYPE_RECIPE,
109 "gravity_postprocess",
112 "Nabih Azouaoui, Vincent Lapeyrere, JB. Le Bouquin",
118 cpl_msg_error(cpl_func,
"Plugin initialization failed");
119 (void)cpl_error_set_where(cpl_func);
123 if (cpl_pluginlist_append(list, plugin)) {
124 cpl_msg_error(cpl_func,
"Error adding plugin to list");
125 (void)cpl_error_set_where(cpl_func);
147 if (cpl_error_get_code() != CPL_ERROR_NONE) {
148 cpl_msg_error(cpl_func,
"%s():%d: An error is already set: %s",
149 cpl_func, __LINE__, cpl_error_get_where());
150 return (
int)cpl_error_get_code();
153 if (plugin == NULL) {
154 cpl_msg_error(cpl_func,
"Null plugin");
155 cpl_ensure_code(0, (
int)CPL_ERROR_NULL_INPUT);
159 if (cpl_plugin_get_type(plugin) != CPL_PLUGIN_TYPE_RECIPE) {
160 cpl_msg_error(cpl_func,
"Plugin is not a recipe");
161 cpl_ensure_code(0, (
int)CPL_ERROR_TYPE_MISMATCH);
165 recipe = (cpl_recipe *)plugin;
168 recipe->parameters = cpl_parameterlist_new();
169 if (recipe->parameters == NULL) {
170 cpl_msg_error(cpl_func,
"Parameter list allocation failed");
171 cpl_ensure_code(0, (
int)CPL_ERROR_ILLEGAL_OUTPUT);
184 p = cpl_parameter_new_value (
"gravity.postprocess.force-merge", CPL_TYPE_BOOL,
185 "Force merging even if inconsistent data",
186 "gravity.postprocess", FALSE);
187 cpl_parameter_set_alias (p, CPL_PARAMETER_MODE_CLI,
"force-merge");
188 cpl_parameter_disable (p, CPL_PARAMETER_MODE_ENV);
189 cpl_parameterlist_append (recipe->parameters, p);
192 p = cpl_parameter_new_value (
"gravity.postprocess.remove-ft", CPL_TYPE_BOOL,
193 "Remove FT extensions",
194 "gravity.postprocess", FALSE);
195 cpl_parameter_set_alias (p, CPL_PARAMETER_MODE_CLI,
"remove-ft");
196 cpl_parameter_disable (p, CPL_PARAMETER_MODE_ENV);
197 cpl_parameterlist_append (recipe->parameters, p);
200 p = cpl_parameter_new_value (
"gravity.postprocess.remove-sc", CPL_TYPE_BOOL,
201 "Remove SC extensions",
202 "gravity.postprocess", FALSE);
203 cpl_parameter_set_alias (p, CPL_PARAMETER_MODE_CLI,
"remove-sc");
204 cpl_parameter_disable (p, CPL_PARAMETER_MODE_ENV);
205 cpl_parameterlist_append (recipe->parameters, p);
208 p = cpl_parameter_new_value (
"gravity.postprocess.remove-opdc", CPL_TYPE_BOOL,
209 "Remove OPDC extensions",
210 "gravity.postprocess", FALSE);
211 cpl_parameter_set_alias (p, CPL_PARAMETER_MODE_CLI,
"remove-opdc");
212 cpl_parameter_disable (p, CPL_PARAMETER_MODE_ENV);
213 cpl_parameterlist_append (recipe->parameters, p);
216 p = cpl_parameter_new_value (
"gravity.postprocess.remove-met", CPL_TYPE_BOOL,
217 "Remove METROLOGY related extensions",
218 "gravity.postprocess", FALSE);
219 cpl_parameter_set_alias (p, CPL_PARAMETER_MODE_CLI,
"remove-met");
220 cpl_parameter_disable (p, CPL_PARAMETER_MODE_ENV);
221 cpl_parameterlist_append (recipe->parameters, p);
224 p = cpl_parameter_new_value (
"gravity.postprocess.nbin-lambda-sc", CPL_TYPE_INT,
225 "Bin SC extensions in spectral dimension",
226 "gravity.postprocess", 0);
227 cpl_parameter_set_alias (p, CPL_PARAMETER_MODE_CLI,
"nbin-lambda-sc");
228 cpl_parameter_disable (p, CPL_PARAMETER_MODE_ENV);
229 cpl_parameterlist_append (recipe->parameters, p);
246 cpl_errorstate initial_errorstate = cpl_errorstate_get();
250 if (cpl_error_get_code() != CPL_ERROR_NONE) {
251 cpl_msg_error(cpl_func,
"%s():%d: An error is already set: %s",
252 cpl_func, __LINE__, cpl_error_get_where());
253 return (
int)cpl_error_get_code();
256 if (plugin == NULL) {
257 cpl_msg_error(cpl_func,
"Null plugin");
258 cpl_ensure_code(0, (
int)CPL_ERROR_NULL_INPUT);
262 if (cpl_plugin_get_type(plugin) != CPL_PLUGIN_TYPE_RECIPE) {
263 cpl_msg_error(cpl_func,
"Plugin is not a recipe");
264 cpl_ensure_code(0, (
int)CPL_ERROR_TYPE_MISMATCH);
268 recipe = (cpl_recipe *)plugin;
271 if (recipe->parameters == NULL) {
272 cpl_msg_error(cpl_func,
"Recipe invoked with NULL parameter list");
273 cpl_ensure_code(0, (
int)CPL_ERROR_NULL_INPUT);
275 if (recipe->frames == NULL) {
276 cpl_msg_error(cpl_func,
"Recipe invoked with NULL frame set");
277 cpl_ensure_code(0, (
int)CPL_ERROR_NULL_INPUT);
284 if (cpl_dfs_update_product_header(recipe->frames)) {
286 recipe_status = (int)cpl_error_get_code();
290 if (!cpl_errorstate_is_equal(initial_errorstate)) {
293 cpl_errorstate_dump(initial_errorstate, CPL_FALSE, NULL);
296 return recipe_status;
310 if (plugin == NULL) {
311 cpl_msg_error(cpl_func,
"Null plugin");
312 cpl_ensure_code(0, (
int)CPL_ERROR_NULL_INPUT);
316 if (cpl_plugin_get_type(plugin) != CPL_PLUGIN_TYPE_RECIPE) {
317 cpl_msg_error(cpl_func,
"Plugin is not a recipe");
318 cpl_ensure_code(0, (
int)CPL_ERROR_TYPE_MISMATCH);
322 recipe = (cpl_recipe *)plugin;
324 cpl_parameterlist_delete(recipe->parameters);
340 const cpl_parameterlist * parlist)
342 cpl_frameset *used_frameset=NULL;
343 cpl_frame * frame=NULL, *frame_merged=NULL;
352 cpl_error_get_code());
354 cpl_size nframe = cpl_frameset_get_size (frameset);
360 cpl_error_set_message (cpl_func, CPL_ERROR_ILLEGAL_INPUT,
361 "Not enough frames in the frameset");
369 used_frameset = cpl_frameset_new();
373 for (cpl_size f = 0; f < nframe ; f++ ) {
376 frame = cpl_frameset_get_position (frameset, f);
412 frame_merged = frame;
413 data_merged = data; data = NULL;
428 gravi_msg_warning (
"FIXME",
"Average the different observations = EXPERIMENTAL");
436 if ( resamp_sc > 1) {
456 used_frameset, frame_merged,
"gravity_postprocess",
457 NULL,
"POSTPROCESSED");
470 FREE (cpl_frameset_delete,used_frameset);
473 return (
int)cpl_error_get_code();
typedefCPL_BEGIN_DECLS struct _gravi_data_ gravi_data
#define GRAVI_RECIPE_OUTPUT
#define GRAVI_RECIPE_FLOW
#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_postprocess_exec(cpl_plugin *)
Execute the plugin instance given by the interface.
static char gravity_postprocess_description[]
int cpl_plugin_get_info(cpl_pluginlist *list)
Build the list of available plugins, for this module.
static int gravity_postprocess_destroy(cpl_plugin *)
Destroy what has been created by the 'create' function.
static char gravity_postprocess_short[]
static int gravity_postprocess_create(cpl_plugin *)
Setup the recipe options
static int gravity_postprocess(cpl_frameset *, const cpl_parameterlist *)
Compute the visibilities, and closure phase and create the io fits file.
cpl_error_code gravi_data_erase_type(gravi_data *self, const char *type)
Erase all extension related to an instrument (SC, FT, MET...)
gravi_data * gravi_data_load_frame(cpl_frame *frame, cpl_frameset *used_frameset)
Load a FITS file and create a gravi_data.
cpl_error_code gravi_data_append(gravi_data *first, const gravi_data *second, int force)
Append a gravi_data into another existing one.
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.
int gravi_param_get_bool(const cpl_parameterlist *parlist, const char *name)
cpl_parameter * gravi_parameter_copy_fluxdata(cpl_parameterlist *self)
cpl_parameter * gravi_parameter_add_average_vis(cpl_parameterlist *self)
int gravi_param_get_int(const cpl_parameterlist *parlist, const char *name)
cpl_parameter * gravi_parameter_add_force_uncertainties(cpl_parameterlist *self)
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)
cpl_error_code gravi_msg_warning(const char *component, const char *msg)
const char * gravi_get_license(void)
Get the pipeline copyright and license.
cpl_error_code gravi_force_uncertainties(gravi_data *oi_data, const cpl_parameterlist *parlist)
Force uncertainties.
cpl_error_code gravi_vis_mjd_to_time(gravi_data *vis_data)
Recompute the TIME column of all OIFITS extension from the MJD column, following the OIFITS standard ...
cpl_error_code gravi_vis_copy_fluxdata(gravi_data *oi_data, int delete_flux)
Duplicate the column FLUX into FLUXDATA, for OIFITS2 compliance.
cpl_error_code gravi_vis_resamp(gravi_data *oi_data, cpl_size nsamp)
Re-bin the SC table by nsamp consecutive spectral bins.
cpl_error_code gravi_average_vis(gravi_data *oi_data)
Coadd the observations together.