GRAVI Pipeline Reference Manual  1.2.3
gravity_viscal.c
1 /* $Id: gravity_viscal.c,v 1.29 2011/12/3 09:16:12 nazouaoui Exp $
2  *
3  * This file is part of the GRAVI Pipeline
4  * Copyright (C) 2002,2003 European Southern Observatory
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19  */
20 
21 /*
22  * $Author: nazouaoui $
23  * $Date: 2011/12/3 09:16:12 $
24  * $Revision: 1.29 $
25  * $Name: $
26  */
27 
28 #ifdef HAVE_CONFIG_H
29 #include <config.h>
30 #endif
31 
32 /*-----------------------------------------------------------------------------
33  Includes
34  -----------------------------------------------------------------------------*/
35 
36 #include <cpl.h>
37 #include <stdio.h>
38 #include <string.h>
39 #include <math.h>
40 #include <time.h>
41 
42 #include "gravi_utils.h"
43 #include "gravi_pfits.h"
44 #include "gravi_data.h"
45 #include "gravi_dfs.h"
46 #include "gravi_calib.h"
47 #include "gravi_p2vmred.h"
48 #include "gravi_vis.h"
49 #include "gravi_tf.h"
50 
51 /*-----------------------------------------------------------------------------
52  Private function prototypes
53  -----------------------------------------------------------------------------*/
54 
55 static int gravity_viscal_create(cpl_plugin *);
56 static int gravity_viscal_exec(cpl_plugin *);
57 static int gravity_viscal_destroy(cpl_plugin *);
58 static int gravity_viscal(cpl_frameset *, const cpl_parameterlist *);
59 
60 /*-----------------------------------------------------------------------------
61  Static variables
62  -----------------------------------------------------------------------------*/
63 
64 static char gravity_viscal_short[] = "Calibrate visibilities from the transfer function.";
65 static char gravity_viscal_description[] =
66  "This recipe calibrates the visibilities acquired on science target using visibilities acquired on a calibrator target. If the DIAMETER_CAT is not provided, the recipe will use the diameter provided in the header to compute the transfer function QC parameters. The corresponding keywords are INS.SOBJ.DIAMETER and FT.ROBJ.DIAMETER. The OI_FLUX data are not yet calibrated."
67  "\n"
68  "The tag in the DO category can be SINGLE/DUAL and CAL/SCI. The tag in the PRO.CATG category will be SINGLE/DUAL and CAL/SCI depending on the input tag.\n"
69  GRAVI_RECIPE_FLOW"\n"
70  "* Loop on all input CALIB files, compute the TF for each of them and write the corresponding product\n"
71  "* Loop on all input SCIENCE files, interpolate the TF at that time, calibrate, and write the corresponding product\n"
72  GRAVI_RECIPE_INPUT"\n"
73  GRAVI_VIS_SINGLE_SCIENCE" (>=1) : visibilities on sciences\n"
74  GRAVI_VIS_SINGLE_CALIB" (>=1) : visibilities on calibrators\n"
75  GRAVI_DIAMETER_CAT" (opt) : catalog of stellar diameters\n"
76  GRAVI_RECIPE_OUTPUT"\n"
77  GRAVI_VIS_SINGLE_CALIBRATED" : calibrated science visibilities\n"
78  GRAVI_TF_SINGLE_CALIB" : Transfer Function (TF) estimated on calibrators\n"
79  GRAVI_TF_SINGLE_SCIENCE" : TF interpolated at the time of sciences\n"
80  "";
81 
82 /*-----------------------------------------------------------------------------
83  Function code
84  -----------------------------------------------------------------------------*/
85 
86 /*----------------------------------------------------------------------------*/
96 /*----------------------------------------------------------------------------*/
97 int cpl_plugin_get_info(cpl_pluginlist * list)
98 {
99  cpl_recipe * recipe = cpl_calloc(1, sizeof *recipe );
100  cpl_plugin * plugin = &recipe->interface;
101 
102  if (cpl_plugin_init(plugin,
103  CPL_PLUGIN_API,
104  GRAVI_BINARY_VERSION,
105  CPL_PLUGIN_TYPE_RECIPE,
106  "gravity_viscal",
107  gravity_viscal_short,
108  gravity_viscal_description,
109  "Nabih Azouaoui, Vincent Lapeyrere, JB. Le Bouquin",
110  PACKAGE_BUGREPORT,
112  gravity_viscal_create,
113  gravity_viscal_exec,
114  gravity_viscal_destroy)) {
115  cpl_msg_error(cpl_func, "Plugin initialization failed");
116  (void)cpl_error_set_where(cpl_func);
117  return 1;
118  }
119 
120  if (cpl_pluginlist_append(list, plugin)) {
121  cpl_msg_error(cpl_func, "Error adding plugin to list");
122  (void)cpl_error_set_where(cpl_func);
123  return 1;
124  }
125 
126  return 0;
127 }
128 
129 /*----------------------------------------------------------------------------*/
137 /*----------------------------------------------------------------------------*/
138 static int gravity_viscal_create(cpl_plugin * plugin)
139 {
140  cpl_recipe * recipe;
141  cpl_parameter * p;
142 
143  /* Do not create the recipe if an error code is already set */
144  if (cpl_error_get_code() != CPL_ERROR_NONE) {
145  cpl_msg_error(cpl_func, "%s():%d: An error is already set: %s",
146  cpl_func, __LINE__, cpl_error_get_where());
147  return (int)cpl_error_get_code();
148  }
149 
150  if (plugin == NULL) {
151  cpl_msg_error(cpl_func, "Null plugin");
152  cpl_ensure_code(0, (int)CPL_ERROR_NULL_INPUT);
153  }
154 
155  /* Verify plugin type */
156  if (cpl_plugin_get_type(plugin) != CPL_PLUGIN_TYPE_RECIPE) {
157  cpl_msg_error(cpl_func, "Plugin is not a recipe");
158  cpl_ensure_code(0, (int)CPL_ERROR_TYPE_MISMATCH);
159  }
160 
161  /* Get the recipe */
162  recipe = (cpl_recipe *)plugin;
163 
164  /* Create the parameters list in the cpl_recipe object */
165  recipe->parameters = cpl_parameterlist_new();
166  if (recipe->parameters == NULL) {
167  cpl_msg_error(cpl_func, "Parameter list allocation failed");
168  cpl_ensure_code(0, (int)CPL_ERROR_ILLEGAL_OUTPUT);
169  }
170 
171  /* Fill the parameters list */
172  gravi_parameter_add_static_name (recipe->parameters);
173 
174  /* delta-time */
175  p = cpl_parameter_new_value ("gravity.viscal.delta-time-calib", CPL_TYPE_DOUBLE,
176  "Delta time to interpolate the TF [s]",
177  "gravity.viscal", 3600.0);
178  cpl_parameter_set_alias (p, CPL_PARAMETER_MODE_CLI, "delta-time-calib");
179  cpl_parameter_disable (p, CPL_PARAMETER_MODE_ENV);
180  cpl_parameterlist_append (recipe->parameters, p);
181 
182  /* force-calib */
183  p = cpl_parameter_new_value ("gravity.viscal.force-calib", CPL_TYPE_BOOL,
184  "Force the calibration, don't check setup",
185  "gravity.viscal", FALSE);
186  cpl_parameter_set_alias (p, CPL_PARAMETER_MODE_CLI, "force-calib");
187  cpl_parameter_disable (p, CPL_PARAMETER_MODE_ENV);
188  cpl_parameterlist_append (recipe->parameters, p);
189 
190  /* smooth */
191  p = cpl_parameter_new_value ("gravity.viscal.nsmooth-tfvis-sc", CPL_TYPE_INT,
192  "Smooth the TF spectrally by this number of "
193  "spectral bin, to enhance SNR (only "
194  "apply to VIS2, VISPHI, VISAMP, T3PHI, T3AMP). "
195  "This parameter is ignored in spectral mode LOW.",
196  "gravity.viscal", 0);
197  cpl_parameter_set_alias (p, CPL_PARAMETER_MODE_CLI, "nsmooth-tfvis-sc");
198  cpl_parameter_disable (p, CPL_PARAMETER_MODE_ENV);
199  cpl_parameterlist_append (recipe->parameters, p);
200 
201  p = cpl_parameter_new_value ("gravity.viscal.nsmooth-tfflux-sc", CPL_TYPE_INT,
202  "Smooth the TF spectrally by this number of "
203  "spectral bin, to enhance SNR (only "
204  "apply to FLUX, RVIS, IVIS). "
205  "This parameter is ignored in spectral mode LOW.",
206  "gravity.viscal", 0);
207  cpl_parameter_set_alias (p, CPL_PARAMETER_MODE_CLI, "nsmooth-tfflux-sc");
208  cpl_parameter_disable (p, CPL_PARAMETER_MODE_ENV);
209  cpl_parameterlist_append (recipe->parameters, p);
210 
211  p = cpl_parameter_new_value ("gravity.viscal.maxdeg-tfvis-sc", CPL_TYPE_INT,
212  "Fit the TF spectrally by a polynomial to enhance SNR "
213  "(only apply to VIS2, VISPHI, VISAMP, T3PHI, T3AMP). "
214  "This parameter is ignored in spectral mode LOW.",
215  "gravity.viscal", 5);
216  cpl_parameter_set_alias (p, CPL_PARAMETER_MODE_CLI, "maxdeg-tfvis-sc");
217  cpl_parameter_disable (p, CPL_PARAMETER_MODE_ENV);
218  cpl_parameterlist_append (recipe->parameters, p);
219 
220  p = cpl_parameter_new_value ("gravity.viscal.calib-flux", CPL_TYPE_BOOL,
221  "Normalize the FLUX by the calibrator.",
222  "gravity.viscal", FALSE);
223  cpl_parameter_set_alias (p, CPL_PARAMETER_MODE_CLI, "calib-flux");
224  cpl_parameter_disable (p, CPL_PARAMETER_MODE_ENV);
225  cpl_parameterlist_append (recipe->parameters, p);
226 
227  return 0;
228 }
229 
230 /*----------------------------------------------------------------------------*/
236 /*----------------------------------------------------------------------------*/
237 static int gravity_viscal_exec(cpl_plugin * plugin)
238 {
239 
240  cpl_recipe * recipe;
241  int recipe_status;
242  cpl_errorstate initial_errorstate = cpl_errorstate_get();
243 
244  /* Return immediately if an error code is already set */
245  if (cpl_error_get_code() != CPL_ERROR_NONE) {
246  cpl_msg_error(cpl_func, "%s():%d: An error is already set: %s",
247  cpl_func, __LINE__, cpl_error_get_where());
248  return (int)cpl_error_get_code();
249  }
250 
251  if (plugin == NULL) {
252  cpl_msg_error(cpl_func, "Null plugin");
253  cpl_ensure_code(0, (int)CPL_ERROR_NULL_INPUT);
254  }
255 
256  /* Verify plugin type */
257  if (cpl_plugin_get_type(plugin) != CPL_PLUGIN_TYPE_RECIPE) {
258  cpl_msg_error(cpl_func, "Plugin is not a recipe");
259  cpl_ensure_code(0, (int)CPL_ERROR_TYPE_MISMATCH);
260  }
261 
262  /* Get the recipe */
263  recipe = (cpl_recipe *)plugin;
264 
265  /* Verify parameter and frame lists */
266  if (recipe->parameters == NULL) {
267  cpl_msg_error(cpl_func, "Recipe invoked with NULL parameter list");
268  cpl_ensure_code(0, (int)CPL_ERROR_NULL_INPUT);
269  }
270  if (recipe->frames == NULL) {
271  cpl_msg_error(cpl_func, "Recipe invoked with NULL frame set");
272  cpl_ensure_code(0, (int)CPL_ERROR_NULL_INPUT);
273  }
274 
275  /* Invoke the recipe */
276  recipe_status = gravity_viscal(recipe->frames, recipe->parameters);
277 
278  /* Ensure DFS-compliance of the products */
279 
280  if (cpl_dfs_update_product_header(recipe->frames)) {
281  if (!recipe_status){
282  recipe_status = (int)cpl_error_get_code();
283  }
284  }
285 
286  if (!cpl_errorstate_is_equal(initial_errorstate)) {
287  /* Dump the error history since recipe execution start.
288  At this point the recipe cannot recover from the error */
289  cpl_errorstate_dump(initial_errorstate, CPL_FALSE, NULL);
290  }
291 
292  return recipe_status;
293 }
294 
295 /*----------------------------------------------------------------------------*/
301 /*----------------------------------------------------------------------------*/
302 static int gravity_viscal_destroy(cpl_plugin * plugin)
303 {
304  cpl_recipe * recipe;
305 
306  if (plugin == NULL) {
307  cpl_msg_error(cpl_func, "Null plugin");
308  cpl_ensure_code(0, (int)CPL_ERROR_NULL_INPUT);
309  }
310 
311  /* Verify plugin type */
312  if (cpl_plugin_get_type(plugin) != CPL_PLUGIN_TYPE_RECIPE) {
313  cpl_msg_error(cpl_func, "Plugin is not a recipe");
314  cpl_ensure_code(0, (int)CPL_ERROR_TYPE_MISMATCH);
315  }
316 
317  /* Get the recipe */
318  recipe = (cpl_recipe *)plugin;
319 
320  cpl_parameterlist_delete(recipe->parameters);
321 
322  return 0;
323 }
324 
325 
326 /*----------------------------------------------------------------------------*/
334 /*----------------------------------------------------------------------------*/
335 static int gravity_viscal(cpl_frameset * frameset,
336  const cpl_parameterlist * parlist)
337 {
338  cpl_frameset * vis_calib_frameset = NULL, * vis_sci_frameset = NULL, *current_frameset = NULL;
339  cpl_frameset * tf_calib_frameset = NULL, * used_frameset = NULL, * diamcat_frameset = NULL;
340  cpl_frame * frame = NULL;
341 
342  cpl_propertylist * applist = NULL;
343 
344  cpl_errorstate errorstate;
345 
346  gravi_data ** vis_calibs = NULL, *vis_calib = NULL, * zero_data = NULL, * tf_science = NULL;
347  gravi_data * calibrated = NULL, * vis_data = NULL, * diamcat_data = NULL;
348 
349  int data_mode, nb_frame_tf = 0, nb_frame_calib = 0, nb_frame_sci, i, j, nb_calib = 0;
350 
351  /* Message */
352  gravity_print_banner ();
353  cpl_msg_set_time_on();
354  cpl_msg_set_component_on();
355  gravi_msg_function_start(1);
356 
357  /* Identify the RAW and CALIB frames in the input frameset */
358  cpl_ensure_code(gravi_dfs_set_groups(frameset) == CPL_ERROR_NONE,
359  cpl_error_get_code());
360 
361  /* Extract a set of vis_calib and vis_sci data frameset */
362  vis_calib_frameset = gravi_frameset_extract_vis_calib (frameset);
363  vis_sci_frameset = gravi_frameset_extract_vis_science (frameset);
364  tf_calib_frameset = gravi_frameset_extract_tf_calib (frameset);
365  diamcat_frameset = gravi_frameset_extract_diamcat_map (frameset);
366 
367  /* To use this recipe the frameset must contain
368  * at least one VIS_*_CAL frame or TF_*_CAL frame. */
369  if ( cpl_frameset_is_empty (vis_calib_frameset) &&
370  cpl_frameset_is_empty (tf_calib_frameset) ) {
371  cpl_error_set_message (cpl_func, CPL_ERROR_ILLEGAL_INPUT,
372  "No VIS or TF file on the frameset") ;
373  goto cleanup;
374  }
375 
376  /* Get the number of the frames contained in the frameset */
377  nb_frame_tf = cpl_frameset_get_size (tf_calib_frameset);
378  nb_frame_calib = cpl_frameset_get_size (vis_calib_frameset);
379  nb_frame_sci = cpl_frameset_get_size (vis_sci_frameset);
380 
381  /* Init memory */
382  vis_calibs = cpl_malloc ( (nb_frame_calib + nb_frame_tf) * sizeof (gravi_data *));
383  for (j = 0; j < (nb_frame_calib + nb_frame_tf); j++) vis_calibs[j] = NULL;
384 
385  /*
386  * Load or compute of the transfer function
387  */
388 
389  /* Load the DIAMETER_CAT
390  * FIXME: how/when install in the used_frameset ? */
391  if ( !cpl_frameset_is_empty (diamcat_frameset) ) {
392  frame = cpl_frameset_get_position (diamcat_frameset, 0);
393  diamcat_data = gravi_data_load_frame (frame, NULL);
394  }
395 
396  /* Init the frameset for all calibration (TF computed and loaded) */
397  used_frameset = cpl_frameset_new();
398 
399  /* Loop on the TF to compute */
400  for (j = 0; j < nb_frame_calib; j++) {
401  errorstate = cpl_errorstate_get();
402 
403  cpl_msg_info (cpl_func, "*** Compute TF %i over %i ***", j+1, nb_frame_calib);
404 
405  /* Load the VIS data and compute TF */
406  frame = cpl_frameset_get_position (vis_calib_frameset, j);
407  vis_data = gravi_data_load_frame (frame, NULL);
408  vis_calib = gravi_compute_tf (vis_data, diamcat_data);
409 
410  /* Smooth the TF if required */
411  if ( !strcmp (gravi_data_get_spec_res (vis_calib), "LOW")) {
412  cpl_msg_info (cpl_func,"LOW spectral resolution -> don't smooth the TF");
413  } else {
414  cpl_size smooth_vis_sc = gravi_param_get_int (parlist, "gravity.viscal.nsmooth-tfvis-sc");
415  cpl_size smooth_flx_sc = gravi_param_get_int (parlist, "gravity.viscal.nsmooth-tfflux-sc");
416  cpl_size maxdeg_sc = gravi_param_get_int (parlist, "gravity.viscal.maxdeg-tfvis-sc");
417  gravi_vis_smooth (vis_calib, smooth_vis_sc, smooth_flx_sc, maxdeg_sc);
418  }
419 
420  /* Check the TF has been computed */
421  if (vis_calib == NULL) {
422  cpl_msg_error (cpl_func, "Cannot compute this TF... continue");
423  goto cleanup_rawtf;
424  }
425 
426  CPLCHECK_GOTO ("Cannot compute the TF", cleanup_rawtf);
427 
428  /* Save the TF file */
429  data_mode = gravi_data_frame_get_mode (frame);
430 
431  gravi_data_save_new (vis_calib, frameset, NULL, NULL, parlist,
432  NULL, frame, "gravity_vis",
433  NULL, GRAVI_TF_CALIB(data_mode));
434 
435  CPLCHECK_GOTO ("Cannot save the TF", cleanup_rawtf);
436 
437  /* Store this successfull TF */
438  vis_calibs[nb_calib] = vis_calib;
439  vis_calib = NULL;
440  nb_calib++;
441 
442  /* Update the used_frameset -- now used as calibration */
443  frame = cpl_frame_duplicate (frame);
444  cpl_frame_set_group (frame, CPL_FRAME_GROUP_CALIB);
445  cpl_frameset_insert (used_frameset, frame);
446 
447  /* Clean memory of the loop */
448  cleanup_rawtf:
449  FREE (gravi_data_delete, vis_data);
450  FREE (gravi_data_delete, vis_calib);
451  cpl_errorstate_set (errorstate);
452  }
453  /* End loop on the TF to compute */
454 
455  cpl_msg_info (cpl_func,"*** Load already computed TF ***");
456 
457  /* Loop on the TF to load */
458  for (j = 0; j < nb_frame_tf; j++) {
459  errorstate = cpl_errorstate_get();
460 
461  cpl_msg_info (cpl_func," %i over %i", j+1, nb_frame_tf);
462 
463  frame = cpl_frameset_get_position (tf_calib_frameset, j);
464  vis_calib = gravi_data_load_frame (frame, used_frameset);
465 
466  CPLCHECK_GOTO("Cannot load the TF", cleanup_caltf);
467 
468  /* Store this successfull TF */
469  vis_calibs[nb_calib] = vis_calib;
470  vis_calib = NULL;
471  nb_calib++;
472 
473  cleanup_caltf:
474  FREE (gravi_data_delete,vis_calib);
475  cpl_errorstate_set (errorstate);
476  }
477  /* End loop on TF to load */
478 
479  cpl_msg_info (cpl_func,"*** All TF computed or loaded ***");
480 
481  cpl_msg_info (cpl_func, "Load or create successfully %i TF over %i input CAL files", nb_calib, nb_frame_calib + nb_frame_tf);
482 
483  /*
484  * Compute the zero of the metrology if several TF are availables
485  */
486 
487  if ( nb_calib > 1 ) {
488  errorstate = cpl_errorstate_get();
489 
490  cpl_msg_info (cpl_func, "*** Compute the zero of the metrology -- FIXME: to be done ***");
491  zero_data = gravi_compute_zp (vis_calibs, nb_calib);
492 
493  CPLCHECK_GOTO("Cannot compute ZP", cleanup_zp);
494 
495  gravi_data_save_new (zero_data, frameset, "output.fits", NULL, parlist,
496  used_frameset, NULL, "gravity_vis",
497  NULL, GRAVI_ZP_CAL);
498 
499  CPLCHECK_GOTO("Cannot save ZP", cleanup_zp);
500 
501  cleanup_zp:
502  FREE (gravi_data_delete,zero_data);
503  cpl_errorstate_set (errorstate);
504  }
505 
506 
507  /*
508  * Apply the TF to the SCIENCE files of the frameset
509  */
510 
511  /* Loop on the SCI files to calibrate */
512  for (i = 0; i < nb_frame_sci; i++){
513  errorstate = cpl_errorstate_get();
514  current_frameset = cpl_frameset_duplicate (used_frameset);
515 
516  cpl_msg_info (cpl_func, "*** Calibration of file %i over %i ***", i+1, nb_frame_sci);
517 
518  frame = cpl_frameset_get_position (vis_sci_frameset, i);
519  vis_data = gravi_data_load_frame (frame, current_frameset);
520 
521  tf_science = gravi_data_duplicate (vis_data);
522  calibrated = gravi_calibrate_vis (vis_data, vis_calibs, nb_calib, zero_data, tf_science, parlist);
523 
524  CPLCHECK_GOTO("Cannot calibrate the visibility", cleanup_calib);
525 
526  /* Save calibrated visibilities */
527  data_mode = gravi_data_frame_get_mode (frame);
528 
529  gravi_data_save_new (calibrated, frameset, NULL, NULL, parlist,
530  current_frameset, frame, "gravity_vis",
531  NULL, GRAVI_VIS_CALIBRATED(data_mode));
532 
533  CPLCHECK_GOTO("Cannot save the calibrated visibility", cleanup_calib);
534 
535  /* Save TF interpolated at the science visibilities */
536  data_mode = gravi_data_frame_get_mode (frame);
537 
538  gravi_data_save_new (tf_science, frameset, NULL, NULL, parlist,
539  current_frameset, frame, "gravity_vis", NULL,
540  GRAVI_TF_SCIENCE(data_mode));
541 
542  CPLCHECK_GOTO("Cannot save the TF interpolated for this visibility", cleanup_calib);
543 
544  cleanup_calib:
545  FREE (gravi_data_delete,vis_data);
546  FREE (gravi_data_delete,tf_science);
547  FREE (gravi_data_delete,calibrated);
548  FREE (cpl_propertylist_delete,applist);
549  FREE (cpl_frameset_delete,current_frameset);
550  cpl_errorstate_set (errorstate);
551  }
552  /* End loop on VIS_*_SCI files to calibrate */
553 
554  /* Terminate the function */
555  goto cleanup;
556 
557 cleanup:
558  /* Deallocation of all variables */
559  cpl_msg_info(cpl_func,"Memory cleanup");
560 
561  FREE (gravi_data_delete,diamcat_data);
562  FREE (gravi_data_delete,zero_data);
563  FREE (cpl_frameset_delete,tf_calib_frameset);
564  FREE (cpl_frameset_delete,vis_calib_frameset);
565  FREE (cpl_frameset_delete,vis_sci_frameset);
566  FREE (cpl_frameset_delete,diamcat_frameset);
567  FREE (cpl_frameset_delete,current_frameset);
568  FREE (cpl_frameset_delete,used_frameset);
569  FREELOOP (gravi_data_delete,vis_calibs,nb_frame_calib+nb_frame_tf);
570 
571  gravi_msg_function_exit(1);
572  return (int)cpl_error_get_code();
573 }
gravi_data * gravi_data_load_frame(cpl_frame *frame, cpl_frameset *used_frameset)
Load a FITS file and create a gravi_data.
Definition: gravi_data.c:573
gravi_data * gravi_calibrate_vis(gravi_data *vis_data, gravi_data **tf_data, int num_tf, gravi_data *zero, gravi_data *tf_science, const cpl_parameterlist *parlist)
Computes the calibrated visibility from science a single data and several previously evaluated instru...
Definition: gravi_tf.c:520
gravi_data * gravi_compute_zp(gravi_data **vis_calib, int num_calib)
Compute the ZP data.
Definition: gravi_tf.c:1027
cpl_error_code gravi_dfs_set_groups(cpl_frameset *set)
Set the group as RAW or CALIB in a frameset.
Definition: gravi_dfs.c:78
gravi_data * gravi_compute_tf(gravi_data *vis_data, gravi_data *diamcat_data)
This function evaluates the transfer function from the observation of a reference star whose diameter...
Definition: gravi_tf.c:756
cpl_error_code gravi_vis_smooth(gravi_data *oi_data, cpl_size nsamp_vis, cpl_size nsamp_flx, cpl_size maxdeg)
Smooth the SC table by nsamp consecutive spectral bins.
Definition: gravi_vis.c:3102
const char * gravi_get_license(void)
Get the pipeline copyright and license.
Definition: gravi_utils.c:104
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.
Definition: gravi_data.c:896
void gravi_data_delete(gravi_data *self)
Delete a gravi data.
Definition: gravi_data.c:137
gravi_data * gravi_data_duplicate(const gravi_data *self)
Create a copy of the gravi data.
Definition: gravi_data.c:236