62#define GRAVI_DATA_SIZE 30
113 cpl_ensure (nb_ext==0, CPL_ERROR_ILLEGAL_INPUT, NULL);
116 self->primary_hdr = cpl_propertylist_new ();
117 self->extra_primary_hdr = cpl_propertylist_new ();
120 self->exts_hdrs = cpl_malloc (
GRAVI_DATA_SIZE *
sizeof(cpl_propertylist*));
122 self->exts_imgl = cpl_malloc (
GRAVI_DATA_SIZE *
sizeof(cpl_imagelist*));
125 self->exts_tbs[i] = NULL;
126 self->exts_hdrs[i] = NULL;
127 self->exts_imgl[i] = NULL;
152 FREE (cpl_propertylist_delete, self->primary_hdr);
158 if(self->extra_primary_hdr != NULL)
159 FREE (cpl_propertylist_delete, self->extra_primary_hdr);
161 FREE (cpl_free, self);
176 if (hdr==NULL) {
return 0; }
177 if (!cpl_propertylist_has (hdr,
"EXTNAME")) {
return 0; }
200 cpl_ensure_code (hdr, CPL_ERROR_NULL_INPUT);
201 cpl_ensure_code (oi_table, CPL_ERROR_NULL_INPUT);
206 if ( cpl_table_has_column (oi_table,
"FLAG") ) {
207 cpl_table_set_column_savetype(oi_table,
"FLAG", CPL_TYPE_BOOL);
209 if ( cpl_table_has_column (oi_table,
"VISREFMAP") ) {
210 cpl_table_set_column_savetype(oi_table,
"VISREFMAP", CPL_TYPE_BOOL);
212 if ( cpl_table_has_column (oi_table,
"STA_INDEX") ) {
213 cpl_table_set_column_savetype(oi_table,
"STA_INDEX", CPL_TYPE_SHORT);
216 if ( cpl_table_has_column (oi_table,
"TARGET_ID") ) {
217 cpl_table_set_column_savetype(oi_table,
"TARGET_ID", CPL_TYPE_SHORT);
220 if ( cpl_table_has_column (oi_table,
"MNT_STA") ) {
221 cpl_table_set_column_savetype(oi_table,
"MNT_STA", CPL_TYPE_SHORT);
225 if ( cpl_error_get_code() != CPL_ERROR_NONE ) {
226 cpl_error_set_message(cpl_func, CPL_ERROR_ILLEGAL_INPUT,
227 "Cannot reinstall the savetypes");
228 return cpl_error_get_code();
231 return CPL_ERROR_NONE;
253 cpl_ensure (self, CPL_ERROR_NULL_INPUT, NULL);
256 copy->nb_ext = self->nb_ext;
258 if (self->primary_hdr) {
259 cpl_propertylist_delete (copy->primary_hdr);
260 copy->primary_hdr = cpl_propertylist_duplicate(self->primary_hdr);
262 cpl_msg_warning (cpl_func,
"a data without header shall not exist");
267 for (
int i = 0; i < copy->nb_ext ; i++){
268 if (self->exts_hdrs[i])
269 copy->exts_hdrs[i] = cpl_propertylist_duplicate(self->exts_hdrs[i]);
270 if (self->exts_tbs[i]) {
271 copy->exts_tbs[i] = cpl_table_duplicate(self->exts_tbs[i]);
274 if (self->exts_imgl[i])
275 copy->exts_imgl[i] = cpl_imagelist_duplicate(self->exts_imgl[i]);
280 if (self->extra_primary_hdr) {
281 cpl_propertylist_delete (copy->extra_primary_hdr);
282 copy->extra_primary_hdr = cpl_propertylist_duplicate(self->extra_primary_hdr);
311 cpl_ensure_code (first, CPL_ERROR_NULL_INPUT);
312 cpl_ensure_code (second, CPL_ERROR_NULL_INPUT);
313 cpl_ensure_code (first->nb_ext > 1, CPL_ERROR_INCOMPATIBLE_INPUT);
314 cpl_ensure_code (second->nb_ext > 1, CPL_ERROR_INCOMPATIBLE_INPUT);
316 cpl_msg_warning (cpl_func,
"Append data: keep only the HEADER of the first data");
317 cpl_msg_warning (cpl_func,
"Append data: FIXME: only works for OIFITS data");
319 cpl_size nb_ext = CPL_MIN(first->nb_ext, second->nb_ext);
320 for (
int i = 0; i < nb_ext ; i++) {
325 cpl_ensure_code (!strcmp (name1, name2), CPL_ERROR_INCOMPATIBLE_INPUT);
328 if ( !strcmp (name1,
"OI_WAVELENGTH") ||
329 !strcmp (name1,
"OI_TARGET") ||
330 !strcmp (name1,
"OI_ARRAY") ||
331 !strcmp (name1,
"IMAGING_DETECTOR_SC") ||
332 !strcmp (name1,
"IMAGING_DETECTOR_FT") ||
333 !strcmp (name1,
"ARRAY_DESCRIPTION") ||
334 !strcmp (name1,
"ARRAY_GEOMETRY") ||
335 !strcmp (name1,
"OPTICAL_TRAIN") ) {
343 cpl_error_set_message (cpl_func, CPL_ERROR_ILLEGAL_INPUT,
"Tables %s are different", name1);
350 if ( first->exts_tbs[i] != NULL ) {
352 cpl_table_insert (first->exts_tbs[i], second->exts_tbs[i], CPL_SIZE_MAX);
359 if ( first->exts_imgl[i] != NULL ) {
361 cpl_size n_first = cpl_imagelist_get_size (first->exts_imgl[i]);
362 cpl_size n_second = cpl_imagelist_get_size (second->exts_imgl[i]);
365 for (cpl_size iimg = 0; iimg < n_second; iimg++) {
366 cpl_image * img = cpl_image_duplicate (cpl_imagelist_get (second->exts_imgl[i], iimg));
367 cpl_imagelist_set (first->exts_imgl[i], img, n_first + iimg);
378 for (
int i = nb_ext; i < second->nb_ext; i++)
384 return CPL_ERROR_NONE;
405 cpl_ensure (filename, CPL_ERROR_NULL_INPUT, NULL);
410 int nb_ext = cpl_fits_count_extensions (filename);
412 cpl_error_set_message(cpl_func, CPL_ERROR_ILLEGAL_INPUT,
"no extension in this file");
420 cpl_propertylist *
header = cpl_propertylist_load (filename, 0);
421 cpl_propertylist_append (self->primary_hdr,
header);
425 for (
int i = 0; i < nb_ext ; i++ ){
428 self->exts_hdrs[i] = cpl_propertylist_load (filename, i+1);
433 self->exts_tbs[i] = cpl_table_load (filename, i+1, 0);
439 self->exts_imgl[i] = cpl_imagelist_load (filename,CPL_TYPE_DOUBLE,i+1);
444 cpl_error_set_message (cpl_func, CPL_ERROR_ILLEGAL_INPUT,
"The dimension of the extension is wrong");
475 const char * extensions_regexp)
478 cpl_ensure (filename, CPL_ERROR_NULL_INPUT, NULL);
483 int nb_ext = cpl_fits_count_extensions (filename);
485 cpl_error_set_message(cpl_func, CPL_ERROR_ILLEGAL_INPUT,
"no extension in this file");
493 cpl_propertylist *
header = cpl_propertylist_load (filename, 0);
494 cpl_propertylist_append (self->primary_hdr,
header);
499 int status = regcomp(&filter, extensions_regexp, REG_EXTENDED | REG_NOSUB);
501 cpl_error_set_message(cpl_func, CPL_ERROR_ILLEGAL_INPUT,
502 "Cannot interpret extension regular expression");
508 for (
int i = 0; i < nb_ext ; i++ ){
511 cpl_propertylist *proplist = cpl_propertylist_load (filename, i+1);
512 const char *extname = cpl_propertylist_get_string (proplist,
"EXTNAME");
516 if (regexec(&filter, extname, 0, NULL, 0) == REG_NOMATCH)
518 cpl_propertylist_delete(proplist);
522 self->exts_hdrs[iext] = proplist;
526 self->exts_tbs[iext] = cpl_table_load (filename, i+1, 0);
532 self->exts_imgl[iext] = cpl_imagelist_load (filename,CPL_TYPE_DOUBLE,i+1);
537 cpl_error_set_message (cpl_func, CPL_ERROR_ILLEGAL_INPUT,
"The dimension of the extension is wrong");
567 cpl_ensure_code (data, CPL_ERROR_NULL_INPUT);
568 cpl_errorstate prestate = cpl_errorstate_get();
576 if (cpl_errorstate_is_equal(prestate)) {
577 cpl_msg_info (cpl_func,
"(insmode: %s %s %s)", res, scpol, ftpol);
579 cpl_errorstate_set (prestate);
582 return CPL_ERROR_NONE;
600 cpl_frameset * used_frameset)
602 cpl_ensure (frame, CPL_ERROR_NULL_INPUT, NULL);
604 const char * filename = cpl_frame_get_filename (frame);
608 if (used_frameset) cpl_frameset_insert (used_frameset, cpl_frame_duplicate (frame));
636 cpl_frameset * patch_frameset)
638 cpl_ensure (file_to_patch, CPL_ERROR_NULL_INPUT, 0);
640 cpl_frame * patch_frame = NULL;
642 if ( !cpl_frameset_is_empty (patch_frameset) )
643 patch_frame = cpl_frameset_get_position(patch_frameset, 0);
646 const char * filename = cpl_frame_get_filename (patch_frame);
649 cpl_propertylist * plist_patch = cpl_propertylist_load (filename, 0);
654 for (
int i=0; i<cpl_propertylist_get_size(plist_patch); i++){
655 cpl_property * keyword = cpl_propertylist_get(plist_patch, i);
656 cpl_type type = cpl_property_get_type(keyword);
657 const char * p_name = cpl_property_get_name (keyword);
658 if ( (strstr(p_name,
" QC ") != NULL) ||
659 (strstr(p_name,
" TPL ") != NULL) ||
660 (strstr(p_name,
" OCS ") != NULL) ||
661 (strstr(p_name,
" OBS ") != NULL) ||
662 (strstr(p_name,
" MET ") != NULL) ||
663 (strstr(p_name,
" ISS ") != NULL) ||
664 (strstr(p_name,
" INS ") != NULL) ||
665 (strstr(p_name,
" FT ") != NULL) ||
666 (strstr(p_name,
" FDDL ") != NULL) ||
667 (strstr(p_name,
" ACQ ") != NULL) ) {
668 cpl_msg_info (cpl_func,
"Patch the keyword %s", p_name);
670 case CPL_TYPE_FLOAT :
671 cpl_propertylist_update_float(plist_file_to_patch, p_name, cpl_property_get_float(keyword));
673 case CPL_TYPE_DOUBLE :
677 cpl_propertylist_update_int(plist_file_to_patch, p_name, cpl_property_get_int(keyword));
679 case CPL_TYPE_STRING :
680 cpl_propertylist_update_string(plist_file_to_patch, p_name, cpl_property_get_string(keyword));
683 cpl_propertylist_update_char(plist_file_to_patch, p_name, cpl_property_get_char(keyword));
686 cpl_propertylist_update_bool(plist_file_to_patch, p_name, cpl_property_get_bool(keyword));
689 cpl_msg_error (cpl_func,
"'%s' is an invalid type of property",p_name);
690 cpl_error_set_message(cpl_func, CPL_ERROR_INVALID_TYPE,
691 "invalid type of property");
696 FREE (cpl_propertylist_delete, plist_patch);
717 cpl_frameset * used_frameset)
719 cpl_ensure (frame, CPL_ERROR_NULL_INPUT, NULL);
721 const char * filename = cpl_frame_get_filename (frame);
724 if (used_frameset) cpl_frameset_insert (used_frameset, cpl_frame_duplicate (frame));
761 cpl_frameset * used_frameset,
762 const char * extensions_regexp)
764 cpl_ensure (frame, CPL_ERROR_NULL_INPUT, NULL);
766 const char * filename = cpl_frame_get_filename (frame);
769 if (used_frameset) cpl_frameset_insert (used_frameset, cpl_frame_duplicate (frame));
798 cpl_ensure_code (self, CPL_ERROR_NULL_INPUT);
802 cpl_msg_info (cpl_func,
"HEADER: %p", self->primary_hdr);
805 for (
int i=0; i<self->nb_ext; i++){
814 return CPL_ERROR_NONE;
830 cpl_ensure (self, CPL_ERROR_ILLEGAL_INPUT, 0L);
831 return (
int)self->nb_ext;
857 const char * filename,
860 cpl_ensure_code (self, CPL_ERROR_NULL_INPUT);
861 cpl_ensure_code (filename, CPL_ERROR_NULL_INPUT);
863 cpl_propertylist *prim_hdr = cpl_propertylist_duplicate(self->primary_hdr);
864 if(self->extra_primary_hdr != NULL)
865 cpl_propertylist_append(prim_hdr, self->extra_primary_hdr);
868 if (self->exts_tbs[0] != NULL)
870 self->exts_hdrs[0], filename, mode);
871 else if (self->exts_imgl[0] != NULL){
872 cpl_propertylist_save (prim_hdr, filename, mode);
873 cpl_imagelist_save (self->exts_imgl[0], filename,
874 CPL_TYPE_DOUBLE, self->exts_hdrs[0], CPL_IO_EXTEND);
877 cpl_error_set_message(cpl_func, CPL_ERROR_NULL_INPUT,
878 "one of the inputs at least is NULL");
879 return CPL_ERROR_NULL_INPUT;
884 for (
int i = 1; i < self->nb_ext; i++){
888 self->exts_hdrs[i], filename, CPL_IO_EXTEND);
890 cpl_imagelist_save (self->exts_imgl[i], filename,
891 CPL_TYPE_DOUBLE, self->exts_hdrs[i], CPL_IO_EXTEND);
893 cpl_error_set_message(cpl_func, CPL_ERROR_ILLEGAL_INPUT,
894 "The dimension of the extension is wrong");
896 return CPL_ERROR_ILLEGAL_INPUT;
900 return CPL_ERROR_NONE;
926 cpl_frameset * allframes,
927 const char * filename,
929 const cpl_parameterlist * parlist,
930 cpl_frameset * usedframes,
933 cpl_propertylist * applist,
934 const char * proCatg)
937 cpl_ensure_code (filename || frame, CPL_ERROR_NULL_INPUT);
938 cpl_ensure_code (self, CPL_ERROR_NULL_INPUT);
939 cpl_ensure_code (proCatg, CPL_ERROR_NULL_INPUT);
941 cpl_frameset * frameset;
942 int ext, i = 0, j = 0;
946 if (applist == NULL) {
951 if(self->extra_primary_hdr != NULL)
952 cpl_propertylist_append(applist, self->extra_primary_hdr);
955 applist = cpl_propertylist_duplicate (applist);
959 cpl_propertylist_append_string (applist, CPL_DFS_PRO_CATG, proCatg);
968 if ( cpl_propertylist_has (hdr,
"DATE-OBS") ) {
969 cpl_propertylist_copy_property (applist, hdr,
"DATE-OBS");
974 if (strstr (proCatg,
"VIS") || strstr (proCatg,
"TF")) {
976 cpl_propertylist_append (applist, tmp);
977 FREE (cpl_propertylist_delete, tmp);
985 for(i = 0; proCatg[i]; i++)
if (proCatg[i]!=
'_') { catg_ext[j] = tolower(proCatg[i]); j++; }
990 if (filename == NULL && frame != NULL) {
991 filename = cpl_frame_get_filename (frame);
992 }
else if (filename == NULL && frame == NULL) {
993 cpl_error_set_message(cpl_func, CPL_ERROR_NULL_INPUT,
"Need a frame if filename is void");
994 return CPL_ERROR_NULL_INPUT;
998 char * product_name = NULL;
1000 if ( cpl_parameterlist_find_const (parlist,
"gravity.dfs.static-name") &&
1005 product_name = cpl_sprintf (
"%s_%s_%s.fits", recipe, catg_ext, suffix);
1007 product_name = cpl_sprintf (
"%s_%s.fits", recipe, catg_ext);
1012 char * filenoext = cpl_strdup (
FILESHORT(filename));
1013 char * lastdot = strrchr (filenoext,
'.');
1014 if (lastdot != NULL) *lastdot =
'\0';
1015 product_name = cpl_sprintf (
"%s_%s.fits", filenoext, catg_ext);
1016 FREE (cpl_free, filenoext);
1019 cpl_msg_info (cpl_func,
"Save file to %s", product_name);
1021 if (usedframes && frame==NULL) {
1023 frameset = cpl_frameset_duplicate (usedframes);
1025 else if (usedframes && frame) {
1028 frameset = cpl_frameset_new ();
1029 cpl_frameset_insert (frameset, cpl_frame_duplicate (frame));
1030 for (
int f = 0; f < cpl_frameset_get_size (usedframes); f++)
1031 if (strcmp (cpl_frame_get_filename (cpl_frameset_get_position (usedframes, f)), cpl_frame_get_filename (frame)))
1032 cpl_frameset_insert (frameset, cpl_frame_duplicate (cpl_frameset_get_position (usedframes, f)));
1034 else if (usedframes==NULL && frame) {
1036 frameset = cpl_frameset_new ();
1037 cpl_frameset_insert (frameset, cpl_frame_duplicate (frame));
1041 cpl_error_set_message(cpl_func, CPL_ERROR_NULL_INPUT,
"Bug: need a frame or a usedframes");
1042 return CPL_ERROR_NULL_INPUT;
1046 for (
int i = 0; i < cpl_propertylist_get_size(applist); i++) {
1047 cpl_property *p = cpl_propertylist_get(applist, i);
1048 if (cpl_property_get_type(p) == CPL_TYPE_FLOAT) {
1049 const char *name = cpl_property_get_name(p);
1050 const float value = cpl_property_get_float(p);
1051 if (!isfinite(value)) {
1052 cpl_msg_error(cpl_func,
"Card %s has invalid value %f", name, value);
1054 }
else if(cpl_property_get_type(p) == CPL_TYPE_DOUBLE) {
1055 const char *name = cpl_property_get_name(p);
1056 const double value = cpl_property_get_double(p);
1057 if (!isfinite(value)) {
1058 cpl_msg_error(cpl_func,
"Card %s has invalid value %f", name, value);
1064 cpl_dfs_save_propertylist (allframes, NULL, parlist,
1065 frameset, frame, recipe, applist,
1066 NULL, PACKAGE
"/" PACKAGE_VERSION, product_name);
1067 CPLCHECK_MSG(
"Cannot save the first extension primary header");
1070 for (ext = 0; ext < self->nb_ext; ext ++)
1072 if (self->exts_tbs[ext] != NULL)
1074 self->exts_hdrs[ext], product_name, CPL_IO_EXTEND);
1075 else if (self->exts_imgl[ext] != NULL)
1076 cpl_imagelist_save (self->exts_imgl[ext], product_name,
1077 cpl_image_get_type (cpl_imagelist_get (self->exts_imgl[ext], 0)),
1078 self->exts_hdrs[ext], CPL_IO_EXTEND);
1082 FREE (cpl_frameset_delete, frameset);
1083 FREE (cpl_free, product_name);
1084 FREE (cpl_propertylist_delete, applist);
1087 return CPL_ERROR_NONE;
1104 cpl_ensure_code (detector_table, CPL_ERROR_NULL_INPUT);
1112 return (ref0_y+ref1_y)/2;
1132 cpl_size nx, cpl_size ny)
1135 cpl_ensure (detector_table, CPL_ERROR_NULL_INPUT, NULL);
1136 cpl_ensure (nx > 2, CPL_ERROR_ILLEGAL_INPUT, NULL);
1137 cpl_ensure (ny > 2, CPL_ERROR_ILLEGAL_INPUT, NULL);
1140 cpl_size nreg = cpl_table_get_nrow (detector_table);
1141 cpl_ensure (nreg == 24 || nreg == 48, CPL_ERROR_ILLEGAL_INPUT, NULL);
1144 cpl_mask * mask = cpl_mask_new (nx, ny);
1146 cpl_msg_info (cpl_func,
"Create mask with size nx = %lli, ny = %lli", nx, ny);
1150 cpl_size mindeg = 0, maxdeg, hw;
1151 if (nx < 150) {maxdeg = 0; hw = 4;}
1152 else if (nx < 400) {maxdeg = 0; hw = 4;}
1153 else {maxdeg = 2; hw = 6;}
1157 const char * names[] = {
"LEFT",
"HALFLEFT",
"CENTER",
"HALFRIGHT",
"RIGHT"};
1160 for (
int n = 0; n < nnames; n++) {
1162 if (cpl_table_has_column (detector_table, names[n]) == 0) {
1163 CPLCHECK_NUL (
"Missing LEFT,HALFLEFT,CENTER,HALFRIGHT,RIGHT "
1164 "column in detector table (old data?), use another bias-method");
1169 cpl_polynomial * fit = cpl_polynomial_new (1);
1170 cpl_matrix * xp = cpl_matrix_new (1,nnames);
1171 cpl_vector * yp = cpl_vector_new (nnames);
1174 for (cpl_size reg = 0; reg < nreg; reg++) {
1177 for (
int n = 0; n < nnames; n++) {
1180 cpl_matrix_set (xp, 0, n, x0);
1181 cpl_vector_set (yp, n, y0);
1186 cpl_polynomial_fit (fit, xp, NULL, yp, NULL, CPL_FALSE, &mindeg, &maxdeg);
1187 CPLCHECK_NUL (
"Cannot fit the expected position from table");
1191 for (cpl_size x = 0; x < nx ; x++) {
1192 cpl_size y0 = cpl_polynomial_eval_1d (fit, x, NULL);
1193 for (cpl_size y = y0-hw; y <= y0+hw; y++) {
1194 if ((y >= 0) && (y < ny))
1195 cpl_mask_set (mask, x+1, y+1, CPL_BINARY_1);
1202 FREE (cpl_polynomial_delete, fit);
1203 FREE (cpl_matrix_delete, xp);
1204 FREE (cpl_vector_delete, yp);
1233 const cpl_parameterlist * parlist)
1236 cpl_ensure_code (data, CPL_ERROR_NULL_INPUT);
1243 cpl_size nreg = cpl_table_get_nrow (detector_table);
1250 cpl_size nframe = cpl_imagelist_get_size (imglist);
1251 cpl_size nx = cpl_image_get_size_x (cpl_imagelist_get (imglist, 0));
1252 cpl_size ny = cpl_image_get_size_y (cpl_imagelist_get (imglist, 0));
1264 cpl_msg_info (cpl_func,
"Skip gravi_remove_cosmicrays_sc");
1268 cpl_vector * bias_list = cpl_vector_new (nframe);
1271 cpl_size nx_bias_hr = 4;
1272 cpl_size ny_reg_mr = (ny - 1) / nreg;
1273 cpl_size n_bias_line = 5;
1282 "gravity.preproc.bias-method",
"AUTO");
1290 if (!strcmp(bias_method,
"AUTO"))
1292 if (cpl_table_has_column(detector_table,
"LEFT") )
1294 bias_method =
"MASKED_MEDIAN_PER_COLUMN";
1296 "Using MASKED_MEDIAN_PER_COLUMN bias method");
1300 bias_method =
"MEDIAN";
1301 cpl_msg_warning (cpl_func,
"Old data format found (or data is missing columns in IMAGING_DETECTOR_SC). "
1302 "Using MEDIAN bias method");
1306 if ( !strcmp (bias_method,
"MASKED_MEDIAN_PER_COLUMN")) {
1315 cpl_image * mask_img = cpl_image_new_from_mask (mask);
1319 for (cpl_size f = 0; f < nframe; f++) {
1320 cpl_image * frame = cpl_imagelist_get (imglist, f);
1336 cpl_mask * thismask = cpl_mask_duplicate (mask);
1337 cpl_mask * bpm = cpl_image_set_bpm (frame, thismask);
1338 FREE (cpl_mask_delete, bpm);
1341 cpl_image * collapse_y;
1342 collapse_y = cpl_image_collapse_median_create (frame, 0, 0, 0);
1346 thismask = cpl_image_set_bpm (frame, bpm);
1347 FREE (cpl_mask_delete, thismask);
1359 cpl_vector_set (bias_list, f, cpl_image_get_mean (collapse_y));
1368 FREE (cpl_mask_delete, mask);
1372 else if ( !strcmp(resolution,
"HIGH") && !strcmp (bias_method,
1373 "MEDIAN_PER_COLUMN")) {
1380 cpl_vector * bias = cpl_vector_new (nx);
1381 cpl_vector * bias_column = cpl_vector_new (n_bias_line*2);
1384 for (cpl_size f = 0; f < nframe; f++) {
1385 cpl_image * frame = cpl_imagelist_get (imglist, f);
1388 for (cpl_size x = 0; x < nx; x++) {
1389 cpl_size bias_index=0;
1392 for (cpl_size y = 0; y < n_bias_line; y++) {
1393 double value = cpl_image_get (frame, x+1, y+1, &nv);
1394 cpl_vector_set (bias_column, bias_index++, value);
1399 for (cpl_size y = 0; y < n_bias_line; y++) {
1400 double value = cpl_image_get (frame, x+1, ny-y, &nv);
1401 cpl_vector_set (bias_column, bias_index++, value);
1406 double bias_med = cpl_vector_get_median (bias_column);
1407 cpl_vector_set (bias, x, bias_med);
1410 for (cpl_size y = 0; y < ny; y++) {
1411 double value = cpl_image_get (frame, x+1, y+1, &nv);
1412 cpl_image_set (frame, x+1, y+1, value - bias_med);
1418 double bias_mean = cpl_vector_get_mean (bias);
1419 cpl_vector_set (bias_list, f, bias_mean);
1421 FREE (cpl_vector_delete, bias);
1422 FREE (cpl_vector_delete, bias_column);
1426 else if ( !strcmp(resolution,
"HIGH") ) {
1431 cpl_vector * bias = cpl_vector_new (nx_bias_hr * ny);
1434 for (cpl_size f = 0; f < nframe; f++) {
1435 cpl_image * frame = cpl_imagelist_get (imglist, f);
1438 for (cpl_size x = 0; x < nx_bias_hr; x++)
1439 for (cpl_size y = 0; y < ny; y++) {
1440 cpl_vector_set (bias, x * ny + y, cpl_image_get (frame, x+1, y+1, &nv));
1445 double bias_med = cpl_vector_get_median (bias);
1446 cpl_vector_set (bias_list, f, bias_med);
1447 cpl_image_subtract_scalar (frame, bias_med);
1450 FREE (cpl_vector_delete, bias);
1454 else if ( !strcmp (bias_method,
1455 "MEDIAN_PER_COLUMN")) {
1460 gravi_msg_warning (
"FIXME",
"Remove bias per column is experimental (LOW, MEDIUM)");
1462 cpl_vector * bias = cpl_vector_new (nx);
1464 cpl_vector * bias_column = cpl_vector_new ((nreg-1)*n_bias_line);
1465 cpl_vector * bias_coord = cpl_vector_new ((nreg-1)*n_bias_line);
1468 for (cpl_size f = 0; f < nframe; f++) {
1469 cpl_image * frame = cpl_imagelist_get (imglist, f);
1472 for (cpl_size x = 0; x < nx; x++) {
1473 cpl_size bias_index=0;
1483 for (cpl_size reg = 0; reg < nreg-1; reg++) {
1485 for (cpl_size y = 0; y < n_bias_line; y++){
1486 double value = cpl_image_get (frame, x+1, starty+y+1, &nv);
1487 cpl_vector_set (bias_column, bias_index, value);
1488 cpl_vector_set (bias_coord, bias_index++, starty+y);
1495 cpl_vector_set (bias, x, bias_med);
1498 for (cpl_size y = 0; y < ny; y++) {
1499 double value = cpl_image_get (frame, x+1, y+1, &nv);
1500 cpl_image_set (frame, x+1, y+1, value - bias_med);
1506 double bias_mean = cpl_vector_get_mean (bias);
1507 cpl_vector_set (bias_list, f, bias_mean);
1509 FREE (cpl_vector_delete, bias);
1510 FREE (cpl_vector_delete, bias_column);
1518 cpl_vector * bias = cpl_vector_new (nx * nreg);
1521 for (cpl_size f = 0; f < nframe; f++) {
1522 cpl_image * frame = cpl_imagelist_get (imglist, f);
1525 for (cpl_size x = 0; x < nx; x++)
1526 for (cpl_size y = 0; y < nreg; y++) {
1527 cpl_vector_set (bias, x * nreg + y, cpl_image_get (frame, x+1, (y+1)*ny_reg_mr+1, &nv));
1532 double bias_med = cpl_vector_get_median (bias);
1533 cpl_vector_set (bias_list, f, bias_med);
1534 cpl_image_subtract_scalar (frame, bias_med);
1537 FREE (cpl_vector_delete, bias);
1548 cpl_propertylist_set_comment (
header,
"ESO QC PIXBIAS AVG",
"[adu] avg over the bias pixel");
1551 cpl_propertylist_set_comment (
header,
"ESO QC PIXBIAS RMS",
"[adu] rms over frames");
1552 cpl_vector_delete (bias_list);
1555 return CPL_ERROR_NONE;
1564 while (ext < self->nb_ext){
1565 cpl_propertylist *p = self->exts_hdrs[ext];
1566 const char *key = cpl_propertylist_get_string (p,
"EXTNAME");
1567 if (strcmp(key, name) == 0)
break;
1593 const char * insname)
1595 cpl_ensure_code (output, CPL_ERROR_NULL_INPUT);
1596 cpl_ensure_code (input, CPL_ERROR_NULL_INPUT);
1597 cpl_ensure_code (name, CPL_ERROR_NULL_INPUT);
1598 cpl_ensure_code (insname, CPL_ERROR_NULL_INPUT);
1601 for (
int j = 0; j < n; j++){
1605 if (!cpl_propertylist_has (
plist,
"EXTNAME"))
continue;
1606 if (!cpl_propertylist_has (
plist,
"INSNAME"))
continue;
1613 if (plist_name == NULL)
continue;
1615 if (!(strcmp (plist_name, name)) &&
1616 !(strcmp (plist_insname, insname))) {
1619 if (type_data == 2) {
1623 else if (type_data == 3) {
1632 return CPL_ERROR_NONE;
1654 cpl_ensure_code (output, CPL_ERROR_NULL_INPUT);
1655 cpl_ensure_code (input, CPL_ERROR_NULL_INPUT);
1656 cpl_ensure_code (num>=0, CPL_ERROR_ILLEGAL_INPUT);
1657 cpl_ensure_code (num<input->nb_ext, CPL_ERROR_ILLEGAL_INPUT);
1667 else if (type_data == 3)
1675 return CPL_ERROR_NONE;
1697 cpl_ensure_code (output, CPL_ERROR_NULL_INPUT);
1698 cpl_ensure_code (input, CPL_ERROR_NULL_INPUT);
1699 cpl_ensure_code (name, CPL_ERROR_NULL_INPUT);
1702 for (
int j = 0; j < n; j++){
1709 if (plist_name == NULL)
continue;
1711 if (!(strcmp (plist_name, name))) {
1714 if (type_data == 2) {
1718 else if (type_data == 3) {
1727 return CPL_ERROR_NONE;
1749 cpl_ensure_code (output, CPL_ERROR_NULL_INPUT);
1750 cpl_ensure_code (input, CPL_ERROR_NULL_INPUT);
1751 cpl_ensure_code (name, CPL_ERROR_NULL_INPUT);
1756 for (
int j = 0; j < n; j++){
1763 if ( (plist_name!=NULL) &&
1764 !(strcmp (plist_name, name))) {
1766 cpl_msg_info (cpl_func,
"Move extension %s", plist_name);
1768 if (type_data == 2) {
1772 else if (type_data == 3) {
1781 input->exts_hdrs[jnew] = input->exts_hdrs[j];
1782 input->exts_imgl[jnew] = input->exts_imgl[j];
1783 input->exts_tbs[jnew] = input->exts_tbs[j];
1790 input->nb_ext = jnew;
1792 input->exts_hdrs[j] = NULL;
1793 input->exts_imgl[j] = NULL;
1794 input->exts_tbs[j] = NULL;
1798 return CPL_ERROR_NONE;
1813 cpl_ensure (raw_calib, CPL_ERROR_NULL_INPUT, 0);
1814 cpl_ensure (ext_name, CPL_ERROR_NULL_INPUT, 0);
1819 if (ext == raw_calib->nb_ext) {
1838 cpl_ensure (self, CPL_ERROR_NULL_INPUT, -1);
1839 cpl_ensure (type, CPL_ERROR_NULL_INPUT, -1);
1840 cpl_ensure (strlen (type)>1, CPL_ERROR_ILLEGAL_INPUT, -1);
1851 if ( (cpl_propertylist_has (
plist,
"INSNAME") &&
1853 (cpl_propertylist_has (
plist,
"EXTNAME") &&
1881 cpl_ensure (self, CPL_ERROR_NULL_INPUT, NULL);
1882 cpl_ensure (i>=0, CPL_ERROR_ILLEGAL_INPUT, NULL);
1883 cpl_ensure (i<self->nb_ext, CPL_ERROR_ILLEGAL_INPUT, NULL);
1885 return self->exts_hdrs[i];
1906 cpl_ensure (self, CPL_ERROR_NULL_INPUT, NULL);
1907 cpl_ensure (i>=0, CPL_ERROR_ILLEGAL_INPUT, NULL);
1908 cpl_ensure (i<self->nb_ext, CPL_ERROR_ILLEGAL_INPUT, NULL);
1910 return self->exts_tbs[i];
1931 cpl_ensure (self, CPL_ERROR_NULL_INPUT, NULL);
1932 cpl_ensure (i>=0, CPL_ERROR_ILLEGAL_INPUT, NULL);
1933 cpl_ensure (i<self->nb_ext, CPL_ERROR_ILLEGAL_INPUT, NULL);
1935 return self->exts_imgl[i];
1956 const char * extname,
1957 const char * insname)
1959 cpl_ensure (self, CPL_ERROR_NULL_INPUT, NULL);
1960 cpl_ensure (extname, CPL_ERROR_NULL_INPUT, NULL);
1961 cpl_ensure (insname, CPL_ERROR_NULL_INPUT, NULL);
1963 int nb_ext = self->nb_ext;
1965 for (
int i = 0; i < nb_ext; i++){
1967 if (cpl_propertylist_has (self->exts_hdrs[i],
"INSNAME")){
1977 cpl_msg_warning(cpl_func,
"The extention %s doesn't exist "
1978 "with the insname %s",
1983 return self->exts_tbs[pos];
2005 const char * extname,
2006 const char * insname)
2008 cpl_ensure (self, CPL_ERROR_NULL_INPUT, NULL);
2009 cpl_ensure (extname, CPL_ERROR_NULL_INPUT, NULL);
2010 cpl_ensure (insname, CPL_ERROR_NULL_INPUT, NULL);
2012 int nb_ext = self->nb_ext;
2014 for (
int i = 0; i < nb_ext; i++){
2015 if (cpl_propertylist_has (self->exts_hdrs[i],
"INSNAME")){
2025 cpl_msg_warning(cpl_func,
"The extention %s doesn't exist "
2026 "with the insname %s",
2031 return self->exts_hdrs[pos];
2053 const char * extname)
2055 cpl_ensure (self, CPL_ERROR_NULL_INPUT, NULL);
2056 cpl_ensure (extname, CPL_ERROR_NULL_INPUT, NULL);
2059 return self->primary_hdr;
2063 cpl_ensure (pos<self->nb_ext, CPL_ERROR_ILLEGAL_INPUT, NULL);
2065 return self->exts_hdrs[pos];
2079 cpl_ensure (self, CPL_ERROR_NULL_INPUT, NULL);
2080 return self->extra_primary_hdr;
2101 cpl_ensure (self, CPL_ERROR_NULL_INPUT, NULL);
2102 cpl_ensure (extname, CPL_ERROR_NULL_INPUT, NULL);
2106 cpl_ensure (pos<self->nb_ext, CPL_ERROR_ILLEGAL_INPUT, NULL);
2108 if ((self->exts_tbs[pos] == NULL) ||
2110 cpl_error_set_message(cpl_func, CPL_ERROR_ILLEGAL_INPUT,
2111 "No BINTABLE at the extension %s", extname);
2115 return self->exts_tbs[pos];
2136 cpl_ensure (self, CPL_ERROR_NULL_INPUT, NULL);
2137 cpl_ensure (extname, CPL_ERROR_NULL_INPUT, NULL);
2141 cpl_ensure (pos<self->nb_ext, CPL_ERROR_ILLEGAL_INPUT, NULL);
2143 if ((self->exts_imgl[pos] == NULL) ||
2145 cpl_error_set_message(cpl_func, CPL_ERROR_ILLEGAL_INPUT,
2146 "No IMAGE at the extension %s", extname);
2150 return self->exts_imgl[pos];
2166 cpl_ensure_code (self, CPL_ERROR_NULL_INPUT);
2167 cpl_ensure_code (pos>-1, CPL_ERROR_ILLEGAL_INPUT);
2171 for (
int i = 0; i < self->nb_ext; i++) {
2173 self->exts_hdrs[comp] = self->exts_hdrs[i];
2174 self->exts_tbs[comp] = self->exts_tbs[i];
2175 self->exts_imgl[comp] = self->exts_imgl[i];
2180 FREE (cpl_table_delete, self->exts_tbs[i]);
2182 FREE (cpl_imagelist_delete, self->exts_imgl[i]);
2185 FREE (cpl_propertylist_delete, self->exts_hdrs[i]);
2192 self->exts_hdrs[i] = NULL;
2193 self->exts_tbs[i] = NULL;
2194 self->exts_imgl[i] = NULL;
2198 self->nb_ext = comp;
2200 return CPL_ERROR_NONE;
2217 cpl_ensure_code (self, CPL_ERROR_NULL_INPUT);
2218 cpl_ensure_code (extname, CPL_ERROR_NULL_INPUT);
2224 if (pos == self->nb_ext) {
2225 cpl_msg_info (cpl_func,
"Cannot delete '%s' (not found)",extname);
2226 return CPL_ERROR_NONE;
2228 cpl_msg_info (cpl_func,
"Delete '%s' found in ext[%i] (over %i) ",extname, pos, self->nb_ext);
2235 return CPL_ERROR_NONE;
2252 cpl_ensure_code (self, CPL_ERROR_NULL_INPUT);
2253 cpl_ensure_code (type, CPL_ERROR_NULL_INPUT);
2254 cpl_ensure_code (strlen (type)>1, CPL_ERROR_ILLEGAL_INPUT);
2263 if ( (cpl_propertylist_has (
plist,
"INSNAME") &&
2265 (cpl_propertylist_has (
plist,
"EXTNAME") &&
2275 return CPL_ERROR_NONE;
2293 cpl_propertylist *
plist,
2294 const char * extname,
2297 cpl_ensure_code (self, CPL_ERROR_NULL_INPUT);
2298 cpl_ensure_code (table, CPL_ERROR_NULL_INPUT);
2301 if (
plist == NULL)
plist = cpl_propertylist_new ();
2302 if (extname != NULL) cpl_propertylist_update_string (
plist,
"EXTNAME", extname);
2305 cpl_propertylist_update_string (
plist,
"XTENSION",
"BINTABLE");
2306 self->exts_hdrs[self->nb_ext] =
plist;
2309 if (!cpl_propertylist_has(
plist,
"EXTNAME") ) {
2310 cpl_msg_error (cpl_func,
"FIXME: set a table without EXTNAME !!");
2311 cpl_propertylist_update_string (
plist,
"EXTNAME",
"UNKNOWN");
2315 const char * plist_name = 0;
2316 if (cpl_propertylist_has (
plist,
"EXTNAME"))
2325 cpl_propertylist_update_int (
plist,
"OI_REVN", 2);
2328 cpl_propertylist_update_int (
plist,
"OI_REVN", 1);
2333 self->exts_tbs[self->nb_ext] = table;
2334 self->exts_imgl[self->nb_ext] = NULL;
2339 return CPL_ERROR_NONE;
2357 cpl_propertylist *
plist,
2358 const char * extname,
2359 cpl_imagelist * imglist)
2362 cpl_ensure_code (self, CPL_ERROR_NULL_INPUT);
2363 cpl_ensure_code (imglist, CPL_ERROR_NULL_INPUT);
2365 if (
plist == NULL)
plist = cpl_propertylist_new ();
2366 if (extname != NULL) cpl_propertylist_update_string (
plist,
"EXTNAME", extname);
2369 self->exts_hdrs[self->nb_ext] =
plist;
2370 cpl_propertylist_update_string (self->exts_hdrs[self->nb_ext],
"XTENSION",
"IMAGE");
2373 self->exts_imgl[self->nb_ext] = (imglist);
2374 self->exts_tbs[self->nb_ext] = NULL;
2379 return CPL_ERROR_NONE;
2398 cpl_propertylist *
plist,
2399 const char * extname,
2400 cpl_image * image) {
2402 cpl_ensure_code (self, CPL_ERROR_NULL_INPUT);
2403 cpl_ensure_code (image, CPL_ERROR_NULL_INPUT);
2405 if (
plist == NULL)
plist = cpl_propertylist_new ();
2406 if (extname != NULL) cpl_propertylist_update_string (
plist,
"EXTNAME", extname);
2409 self->exts_hdrs[self->nb_ext] =
plist;
2410 cpl_propertylist_update_string (self->exts_hdrs[self->nb_ext],
"XTENSION",
"IMAGE");
2413 cpl_imagelist * imglist = cpl_imagelist_new ();
2414 cpl_imagelist_set (imglist, image, 0);
2417 self->exts_imgl[self->nb_ext] = (imglist);
2418 self->exts_tbs[self->nb_ext] = NULL;
2423 return CPL_ERROR_NONE;
2441 cpl_ensure_code (data, CPL_ERROR_NULL_INPUT);
2443 cpl_table * new_oimet_table;
2460 if (cpl_propertylist_has (
plist,
"INSNAME") &&
2475 cpl_size length = cpl_table_get_nrow (old_oimet_table);
2476 new_oimet_table = cpl_table_new(length);
2480 const char *names[] = {
"TIME",
"PHASE_FC_DRS",
"PHASE_TELFC_CORR",
"OPD_TELFC_CORR_XY",
"OPD_FC_CORR",
"OPD_TELFC_MCORR"};
2481 for (
int j =0; j<nb_names;j++)
2483 cpl_msg_info(cpl_func,
"duplicating columns %s",names[j]);
2484 cpl_table_duplicate_column (new_oimet_table, names[j], old_oimet_table, names[j]);
2485 CPLCHECK_MSG (
"Failed at duplicating column to new OI_VIS_MET table");
2491 FREE (cpl_propertylist_delete, data->exts_hdrs[i]);
2492 FREE (cpl_table_delete, data->exts_tbs[i]);
2493 FREE (cpl_imagelist_delete, data->exts_imgl[i]);
2497 if (new_oimet_table != NULL)
2505 if (data->exts_hdrs[i] || data->exts_tbs[i] || data->exts_imgl[i]) {
2507 data->exts_hdrs[j] = data->exts_hdrs[i]; data->exts_hdrs[i] = NULL;
2508 data->exts_tbs[j] = data->exts_tbs[i]; data->exts_tbs[i] = NULL;
2509 data->exts_imgl[j] = data->exts_imgl[i]; data->exts_imgl[i] = NULL;
2518 return CPL_ERROR_NONE;
2537 cpl_ensure_code (data, CPL_ERROR_NULL_INPUT);
2543 cpl_propertylist_append_int (
header,
"ESO QC CHECK FLAGS", 0);
2547 const char *extname[] = {
"ARRAY_DESCRIPTION",
"ARRAY_GEOMETRY",
"OPTICAL_TRAIN",
2548 "IMAGING_DATA_ACQ",
"ACQ_ABS_REF_POSITION",
2549 "OPDC",
"FDDL",
"METROLOGY",
2550 "IMAGING_DATA_SC",
"IMAGING_DETECTOR_SC",
2551 "IMAGING_DATA_FT",
"IMAGING_DETECTOR_FT"};
2553 for (
int ext = 0; ext< nb_ext; ext++) {
2557 sprintf (qc_msg,
"%s is missing", extname[ext]);
2562 cpl_propertylist *
plist;
2566 if (cpl_propertylist_has (
plist,
"ESO DET FRAM NO")) {
2567 int frame_no = cpl_propertylist_get_int (
plist,
"ESO DET FRAM NO");
2568 int naxis_3 = cpl_propertylist_get_int (
plist,
"NAXIS3");
2569 if ( frame_no != naxis_3) {
2570 sprintf (qc_msg,
"%s is missing DITs", extname[ext]);
2576 CPLCHECK_MSG (
"Cannot check consistency of tables...");
2583 int ndit = cpl_propertylist_get_int (
header,
"ESO DET2 NDIT");
2588 cpl_msg_debug (cpl_func,
"start = %8.0f and end = %10.0f (%s [us] from PCR.ACQ.START)",
2589 start_sc, end_sc,
"SC");
2593 const char *ext_rmn[] = {
"OPDC",
"FDDL",
"METROLOGY",
"IMAGING_DATA_FT"};
2595 for (
int ext = 0; ext< nb_ext_rmn; ext++) {
2602 double min_table = cpl_table_get_column_min (table,
"TIME");
2603 double max_table = cpl_table_get_column_max (table,
"TIME");
2605 cpl_msg_debug (cpl_func,
"start = %8.0f and end = %10.0f (%s [us] from PCR.ACQ.START)",
2606 min_table, max_table, ext_rmn[ext]);
2609 if ( min_table > start_sc) {
2610 sprintf (qc_msg,
"%s starts *after* the science exposure", ext_rmn[ext]);
2613 if ( max_table < end_sc) {
2614 sprintf (qc_msg,
"%s finish *before* the science exposure", ext_rmn[ext]);
2619 cpl_size nrow = cpl_table_get_nrow (table);
2620 int * time = cpl_table_get_data_int (table,
"TIME");
2624 cpl_size nsamp = CPL_MIN (10000, nrow-1);
2625 cpl_array * delta = cpl_array_new (nsamp, CPL_TYPE_INT);
2626 for (cpl_size row = 0; row < nsamp ; row++) {
2627 cpl_array_set_int (delta, row, time[row+1] - time[row]);
2629 double median_delta = cpl_array_get_median (delta);
2630 FREE (cpl_array_delete, delta);
2634 int nwrong_warning = 0;
2635 if (!strcmp (ext_rmn[ext],
"OPDC")) nwrong_warning = 2;
2636 for (cpl_size row = 0; row < nrow-1 ; row++) {
2637 double current_delta = time[row+1] - time[row];
2638 if (current_delta > 1.5 * median_delta) nwrong ++;
2640 if (nwrong > nwrong_warning) {
2641 sprintf (qc_msg,
"%s has %i wrong steps", ext_rmn[ext], nwrong);
2647 CPLCHECK_MSG (
"Cannot check consistency of RMN tables...");
2650 return CPL_ERROR_NONE;
2669 cpl_ensure (data, CPL_ERROR_NULL_INPUT, NULL);
2670 cpl_ensure (npol == 1 || npol == 2, CPL_ERROR_ILLEGAL_INPUT, NULL);
2671 cpl_ensure (type_data ==
GRAVI_SC || type_data ==
GRAVI_FT, CPL_ERROR_ILLEGAL_INPUT, NULL);
2673 cpl_table ** oiwave_tables = cpl_calloc (npol,
sizeof(cpl_table *));
2674 for (
int pol = 0; pol < npol; pol++)
2677 return oiwave_tables;
#define GRAVI_PRIMARY_HDR_EXT
#define gravi_table_get_value(table, name, row, value)
typedefCPL_BEGIN_DECLS struct _gravi_data_ gravi_data
#define gravi_data_get_header(data)
#define gravi_data_get_oi_wave(data, type, pol, npol)
#define gravi_data_get_qc(data)
cpl_table_save(vis_met, NULL, NULL, "vismet.fits", CPL_IO_CREATE)
cpl_msg_debug(cpl_func, "Spectra has <50 pixels -> don't flat")
cpl_propertylist * header
cpl_msg_info(cpl_func, "Compute WAVE_SCAN for %s", GRAVI_TYPE(type_data))
cpl_propertylist_update_double(header, "ESO QC MINWAVE SC", cpl_propertylist_get_double(plist, "ESO QC MINWAVE SC"))
cpl_image_delete(flat_profiled)
#define GRAVI_OI_VIS2_EXT
#define GRAVI_OI_VIS_ACQ_EXT
#define GRAVI_OI_VIS_MET_EXT
#define GRAVI_OI_TARGET_EXT
#define GRAVI_OI_ARRAY_EXT
#define GRAVI_OI_FLUX_EXT
#define GRAVI_IMAGING_DATA_SC_EXT
#define GRAVI_IMAGING_DETECTOR_SC_EXT
#define GRAVI_OI_WAVELENGTH_EXT
#define CPLCHECK_INT(msg)
#define gravi_msg_function_exit(flag)
#define FREE(function, variable)
#define CPLCHECK_NUL(msg)
#define gravi_msg_function_start(flag)
#define CPLCHECK_MSG(msg)
#define FREELOOP(function, variable, n)
cpl_error_code gravi_image_subtract_collapse(cpl_image *img, const cpl_image *collapse, int direction)
double gravi_vector_get_mean_clip(cpl_vector *vector_in, double percent, double nsigma)
Return the mean of a vector after extrema and RMS clipping.
int gravi_table_are_equal(cpl_table *first, cpl_table *second)
Check if two tables have the same content.
int gravi_data_patch(gravi_data *file_to_patch, cpl_frameset *patch_frameset)
Load a RAW FITS file and create a gravi_data.
cpl_error_code gravi_data_erase(gravi_data *self, const char *extname)
Erase an extension by its EXTNAME.
cpl_propertylist * gravi_data_get_oi_plist(gravi_data *self, const char *extname, const char *insname)
Get the propertylist from EXTNAME and INSNAME.
gravi_data * gravi_data_duplicate(const gravi_data *self)
Create a copy of the gravi data.
cpl_error_code gravi_data_add_cube(gravi_data *self, cpl_propertylist *plist, const char *extname, cpl_imagelist *imglist)
Add an IMAGE (imagelist) extension in gravi_data.
int gravi_data_get_dark_pos(cpl_table *detector_table, int reg)
retrun the position of the dark line on top of the region at x position
cpl_mask * gravi_data_create_bias_mask(cpl_table *detector_table, cpl_size nx, cpl_size ny)
return a mask with pixel to be possibly illuminated
cpl_imagelist * gravi_data_get_cube_x(gravi_data *self, int i)
Get the cube of an extension by position.
cpl_propertylist * gravi_data_get_extra_primary_header(gravi_data *self)
Get the propertylist for additional keywords to the primary header.
gravi_data * gravi_data_load_ext(const char *filename, const char *extensions_regexp)
Low-level function to load FITS file.
gravi_data * gravi_data_load(const char *filename)
Low-level function to load FITS file.
cpl_error_code gravi_data_clean_for_astro(gravi_data *data)
Clean the data to keep only OIFITS extensions related to SC.
cpl_propertylist * gravi_data_get_plist(gravi_data *self, const char *extname)
Get the propertylist from EXTNAME.
cpl_error_code gravi_data_check_savetypes(cpl_propertylist *hdr, cpl_table *oi_table)
Set the savetypes of the OIFITS table.
gravi_data * gravi_data_new(int nb_ext)
Create an empty gravi_data.
cpl_error_code gravi_data_add_table(gravi_data *self, cpl_propertylist *plist, const char *extname, cpl_table *table)
Add a BINTABLE extension in gravi_data.
static int _gravi_data_find(const gravi_data *self, const char *name)
cpl_error_code gravi_data_add_img(gravi_data *self, cpl_propertylist *plist, const char *extname, cpl_image *image)
Add an IMAGE (single image) extension in gravi_data.
cpl_error_code gravi_data_erase_type(gravi_data *self, const char *type)
Erase all extension related to an instrument (SC, FT, MET...)
cpl_error_code gravi_data_copy_ext_i(gravi_data *output, gravi_data *input, cpl_size num)
Copy extensions from one data to another.
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_detector_cleanup(gravi_data *data, const cpl_parameterlist *parlist)
Perform self-bias correction to the SC raw data.
cpl_table ** gravi_data_get_oiwave_tables(gravi_data *data, int type_data, int npol)
Get pointer to the OI_WAVELENGTH tables of both polarisations.
cpl_error_code gravi_data_dump_mode(gravi_data *data)
Dump some information about data in messagin.
cpl_imagelist * gravi_data_get_cube(gravi_data *self, const char *extname)
Return a pointer on an IMAGE extension by its EXTNAME.
int gravi_data_has_extension(gravi_data *raw_calib, const char *ext_name)
Check if data has extension with given EXTNAME.
int gravi_data_is_oi_ext(cpl_propertylist *hdr)
Check if EXTNAME starts with 'OI_' (OIFITS extension)
int gravi_data_has_type(gravi_data *self, const char *type)
Return the number of ext whose EXTNAME and INSNAME match 'type'.
cpl_error_code gravi_data_save_data(gravi_data *self, const char *filename, unsigned mode)
Save a gravi data in a FITS file.
cpl_table * gravi_data_get_table(gravi_data *self, const char *extname)
Return a pointer on a table extension by its EXTNAME.
cpl_table * gravi_data_get_oi_table(gravi_data *self, const char *extname, const char *insname)
Get an OI_FITS table from EXTNAME and INSNAME.
cpl_error_code gravi_remove_cosmicrays_sc(cpl_imagelist *imglist_sc)
Remove cosmic rays via filtering through images.
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_move_ext(gravi_data *output, gravi_data *input, const char *name)
Move extensions from one data to another.
cpl_error_code gravi_data_erase_x(gravi_data *self, int pos)
Erase an extension by its position.
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.
cpl_propertylist * gravi_data_get_plist_x(gravi_data *self, int i)
Get the propertylist of an extension by position.
int gravi_data_get_size(const gravi_data *self)
Get the number of extension in a gravi_data.
cpl_error_code gravi_data_copy_ext(gravi_data *output, gravi_data *input, const char *name)
Copy extensions from one data to another.
cpl_error_code gravi_data_dump(gravi_data *self)
Dump the overall structure of a gravi_data in stdout.
cpl_error_code gravi_data_copy_ext_insname(gravi_data *output, gravi_data *input, const char *name, const char *insname)
Copy extensions from one data to another.
gravi_data * gravi_data_load_rawframe_ext(cpl_frame *frame, cpl_frameset *used_frameset, const char *extensions_regexp)
Load a RAW FITS file and create a gravi_data from specified extensions.
cpl_error_code gravi_data_check_consistency(gravi_data *data)
Verify the integrity of RAW data.
cpl_table * gravi_data_get_table_x(gravi_data *self, int i)
Get the table of an extension by position.
void gravi_data_delete(gravi_data *self)
Delete a gravi data.
int gravi_param_get_bool(const cpl_parameterlist *parlist, const char *name)
int gravi_param_get_bool_default(const cpl_parameterlist *parlist, const char *name, int def)
const char * gravi_param_get_string_default(const cpl_parameterlist *parlist, const char *name, const char *def)
const char * gravi_pfits_get_insname(const cpl_propertylist *plist)
cpl_propertylist * gravi_plist_get_oifits_keywords(cpl_propertylist *header)
Create OIFITS keywords to satisfy standar.
const char * gravi_pfits_get_pola_mode(const cpl_propertylist *plist, int type_data)
cpl_error_code gravi_pfits_add_check(cpl_propertylist *header, const char *msg)
Add a QC.CHECK keyword to the header.
int gravi_pfits_get_extension_type(const cpl_propertylist *plist)
const char * gravi_pfits_get_spec_res(const cpl_propertylist *plist)
double gravi_pfits_get_dit_sc(const cpl_propertylist *plist)
const char * gravi_pfits_get_resolution(const cpl_propertylist *plist)
double gravi_pfits_get_time_sc(const cpl_propertylist *header, cpl_size row)
Time of the middle of the SC exposure row in [us], counted from PRC.ACQ.START.
cpl_error_code gravi_pfits_add_pipe_build(cpl_propertylist *header)
Add the ESO PRO REC# PIPE LAST_BUILD in header.
const char * gravi_pfits_get_extname(const cpl_propertylist *plist)
cpl_error_code gravi_msg_warning(const char *component, const char *msg)
cpl_propertylist * extra_primary_hdr
cpl_propertylist ** exts_hdrs
cpl_propertylist * primary_hdr
cpl_imagelist ** exts_imgl