NACO Pipeline Reference Manual  4.4.0
naco_img_twflat.c
1 /* $Id: naco_img_twflat.c,v 1.64 2009-01-29 08:54:58 llundin Exp $
2  *
3  * This file is part of the NACO 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., 51 Franklin St, Fifth Floor, Boston, MA 02111-1307 USA
19  */
20 
21 /*
22  * $Author: llundin $
23  * $Date: 2009-01-29 08:54:58 $
24  * $Revision: 1.64 $
25  * $Name: not supported by cvs2svn $
26  */
27 
28 #ifdef HAVE_CONFIG_H
29 #include <config.h>
30 #endif
31 
32 /*-----------------------------------------------------------------------------
33  Includes
34  -----------------------------------------------------------------------------*/
35 
36 #include <string.h>
37 
38 #include "naco_recipe.h"
39 #include "irplib_flat.h"
40 
41 /*-----------------------------------------------------------------------------
42  Defines
43  -----------------------------------------------------------------------------*/
44 
45 #define RECIPE_STRING "naco_img_twflat"
46 
47 /*-----------------------------------------------------------------------------
48  Private Functions prototypes
49  -----------------------------------------------------------------------------*/
50 
51 static cpl_imagelist * naco_img_twflat_reduce(const irplib_framelist *,
52  const irplib_framelist *);
53 
54 static cpl_error_code naco_img_twflat_qc(cpl_propertylist *,
55  const irplib_framelist *);
56 
57 static cpl_error_code naco_img_twflat_save(cpl_frameset *,
58  const cpl_parameterlist *,
59  const cpl_propertylist *,
60  const cpl_imagelist *,
61  const cpl_image *, int,
62  const irplib_framelist *);
63 
64 static char * naco_img_twflat_make_tag(const cpl_frame*,
65  const cpl_propertylist *, int);
66 
67 static char * naco_img_twflat_make_dark_tag(const cpl_frame*,
68  const cpl_propertylist *, int);
69 
70 NACO_RECIPE_DEFINE(naco_img_twflat,
71  NACO_PARAM_REJBORD |
72  NACO_PARAM_BPMTHRES |
73  NACO_PARAM_PROPFIT |
74  NACO_PARAM_BPM |
75  NACO_PARAM_ERRORMAP |
76  NACO_PARAM_INTCEPT,
77  "Twilight flat recipe",
78  RECIPE_STRING " -- NACO imaging flat-field creation from "
79  "twilight images.\n"
80  "The files listed in the Set Of Frames (sof-file) must be tagged:\n"
81  "raw-file.fits " NACO_IMG_TWFLAT_RAW " or\n"
82  "raw-or-calib-file.fits " NACO_IMG_DARK_RAW "\n"
83  "The flat frames are divided into groups, each group having identical "
84  "instrument settings. Each group of flats is reduced independently of "
85  "each other. For each group of flats, the set of frames shall contain "
86  "either zero, one or n dark frames with the same instrument settings, "
87  "where n is the number of flats in the group.");
88 
89 /*-----------------------------------------------------------------------------
90  Static variables
91  -----------------------------------------------------------------------------*/
92 
93 static struct {
94  int rej_left;
95  int rej_right;
96  int rej_bottom;
97  int rej_top;
98  double low_thresh;
99  double high_thresh;
100  int prop_flag;
101  int bpm_flag;
102  int errmap_flag;
103  int intercept_flag;
104 } naco_img_twflat_config;
105 
106 /*----------------------------------------------------------------------------*/
110 /*----------------------------------------------------------------------------*/
111 
112 /*-----------------------------------------------------------------------------
113  Functions code
114  -----------------------------------------------------------------------------*/
115 
116 /*----------------------------------------------------------------------------*/
123 /*----------------------------------------------------------------------------*/
124 static int naco_img_twflat(cpl_frameset * framelist,
125  const cpl_parameterlist * parlist)
126 {
127  cpl_errorstate cleanstate = cpl_errorstate_get();
128  irplib_framelist * allframes = NULL;
129  irplib_framelist * flatframes = NULL;
130  irplib_framelist * darkframes = NULL;
131  irplib_framelist * f_one = NULL;
132  irplib_framelist * d_one = NULL;
133  cpl_imagelist * twflat = NULL;
134  cpl_image * bpm_im = NULL;
135  cpl_mask * bpm = NULL;
136  cpl_propertylist * qclist = cpl_propertylist_new();
137  const char ** taglist = NULL;
138  const char * sval;
139  int nb_good = 0;
140  int nsets;
141  int i;
142 
143  /* Retrieve input parameters */
144  /* --r */
145  sval = naco_parameterlist_get_string(parlist, RECIPE_STRING,
146  NACO_PARAM_REJBORD);
147  skip_if (0);
148  skip_if (sscanf(sval, "%d %d %d %d",
149  &naco_img_twflat_config.rej_left,
150  &naco_img_twflat_config.rej_right,
151  &naco_img_twflat_config.rej_bottom,
152  &naco_img_twflat_config.rej_top) != 4);
153 
154  /* --t */
155  sval = naco_parameterlist_get_string(parlist, RECIPE_STRING,
156  NACO_PARAM_BPMTHRES);
157  skip_if (0);
158  skip_if (sscanf(sval, "%lg %lg",
159  &naco_img_twflat_config.low_thresh,
160  &naco_img_twflat_config.high_thresh) !=2 );
161  /* --prop */
162  naco_img_twflat_config.prop_flag
163  = naco_parameterlist_get_bool(parlist, RECIPE_STRING, NACO_PARAM_PROPFIT);
164  skip_if (0);
165  /* --bpm */
166  naco_img_twflat_config.bpm_flag
167  = naco_parameterlist_get_bool(parlist, RECIPE_STRING, NACO_PARAM_BPM);
168  skip_if (0);
169  /* --errmap */
170  naco_img_twflat_config.errmap_flag
171  = naco_parameterlist_get_bool(parlist, RECIPE_STRING, NACO_PARAM_ERRORMAP);
172  skip_if (0);
173  /* --intercept */
174  naco_img_twflat_config.intercept_flag
175  = naco_parameterlist_get_bool(parlist, RECIPE_STRING, NACO_PARAM_INTCEPT);
176 
177  /* Identify the RAW and CALIB frames in the input frameset */
178  skip_if (naco_dfs_set_groups(framelist));
179 
180  allframes = irplib_framelist_cast(framelist);
181  skip_if(allframes == NULL);
182 
183  flatframes = irplib_framelist_extract(allframes, NACO_IMG_TWFLAT_RAW);
184  skip_if(flatframes == NULL);
185 
186  skip_if(irplib_framelist_load_propertylist_all(flatframes, 0, "^("
187  IRPLIB_PFITS_REGEXP_RECAL "|"
188  NACO_PFITS_REGEXP_TWFLAT
189  ")$", CPL_FALSE));
190 
191  darkframes = irplib_framelist_extract(allframes, NACO_IMG_DARK_RAW);
192  irplib_framelist_empty(allframes);
193 
194  if (darkframes == NULL) {
195  naco_error_reset("The set of frames has no darks:");
196  } else {
197  /* dark frame(s) are provided */
198  skip_if(0);
199 
200  skip_if(irplib_framelist_load_propertylist_all(darkframes, 0, "^("
201  NACO_PFITS_REGEXP_TWFLAT_DARK
202  ")$", CPL_FALSE));
203 
204  cpl_free(naco_framelist_set_tag(darkframes,
205  naco_img_twflat_make_dark_tag,
206  &nsets));
207  skip_if(0);
208  }
209 
210  taglist = naco_framelist_set_tag(flatframes, naco_img_twflat_make_tag,
211  &nsets);
212  skip_if(taglist == NULL);
213 
214  cpl_msg_info(cpl_func, "Identified %d setting(s) in %d flat frame(s)",
215  nsets, irplib_framelist_get_size(flatframes));
216 
217  /* Extract settings and reduce each of them */
218  for (i=0 ; i < nsets ; i++) {
219  int nflats;
220 
221  /* Reduce data set nb i */
222  f_one = irplib_framelist_extract(flatframes, taglist[i]);
223 
224  nflats = irplib_framelist_get_size(f_one);
225 
226  /* Reset the tag */
227  skip_if(irplib_framelist_set_tag_all(f_one, NACO_IMG_TWFLAT_RAW));
228 
229  cpl_msg_info(cpl_func, "Reducing flat frame set %d of %d (size=%d) "
230  "with setting: %s", i+1, nsets, nflats, taglist[i]);
231 
232  if (darkframes != NULL) {
233  const char * post_filter = strchr(taglist[i], ':');
234 
235  bug_if(post_filter == NULL);
236 
237  /* Extract those darks with a matching ROM */
238  d_one = irplib_framelist_extract(darkframes, 1+post_filter);
239  if (d_one == NULL) {
240  naco_error_reset("None of the darks match this setting:");
241  } else {
242  /* Reset the tag */
243  bug_if (irplib_framelist_set_tag_all(d_one,
244  NACO_IMG_DARK_RAW));
245  }
246  }
247 
248  twflat = naco_img_twflat_reduce(f_one, d_one);
249 
250  if (twflat == NULL) {
251  if (nsets > 1)
252  irplib_error_recover(cleanstate, "Could not reduce set %d:", i+1);
253  } else {
254  if (naco_img_twflat_config.bpm_flag) {
255  /* Create the Bad pixel map */
256  if ((bpm = cpl_mask_threshold_image_create(
257  cpl_imagelist_get(twflat, 0),
258  naco_img_twflat_config.low_thresh,
259  naco_img_twflat_config.high_thresh)) == NULL) {
260  cpl_msg_warning(cpl_func, "Could not create the bad pixel "
261  "map: '%s' at %s", cpl_error_get_message(),
262  cpl_error_get_where());
263  cpl_error_reset();
264  } else {
265  skip_if(cpl_mask_not(bpm));
266  bpm_im = cpl_image_new_from_mask(bpm);
267  cpl_mask_delete(bpm);
268  bpm = NULL;
269  }
270  }
271  /* Save the products */
272  cpl_msg_info(cpl_func, "Saving the products");
273  if (d_one != NULL) {
274  /* Create a single list of frames used to create the products
275  of this setting - also delete the dark propertylists */
276  cpl_frame * frame = NULL;
277  const cpl_boolean is_calib = irplib_framelist_get_size(d_one)
278  == 1 ? CPL_TRUE : CPL_FALSE;
279 
280  while (irplib_framelist_get_size(d_one) > 0) {
281  frame = irplib_framelist_unset(d_one, 0, NULL);
282 
283  /* FIXME: Need a separate tag for this type of dark */
284  if (is_calib)
285  bug_if(cpl_frame_set_group(frame,
286  CPL_FRAME_GROUP_CALIB));
287 
288  bug_if(irplib_framelist_set(f_one, frame, nflats++));
289 
290  frame = NULL;
291  }
292  cpl_frame_delete(frame);
293  bug_if(irplib_framelist_get_size(d_one) != 0);
294  }
295 
296  skip_if(naco_img_twflat_qc(qclist, f_one));
297 
298  skip_if(naco_img_twflat_save(framelist, parlist, qclist,
299  twflat, bpm_im, i+1, f_one));
300  nb_good++;
301  cpl_propertylist_empty(qclist);
302  cpl_image_delete(bpm_im);
303  cpl_imagelist_delete(twflat);
304  bpm_im = NULL;
305  twflat = NULL;
306  }
307 
310  f_one = NULL;
311  d_one = NULL;
312  }
313 
314  irplib_ensure(nb_good > 0, CPL_ERROR_DATA_NOT_FOUND,
315  "None of the %d sets could be reduced", nsets);
316 
317  end_skip;
318 
319  irplib_framelist_delete(allframes);
320  irplib_framelist_delete(flatframes);
321  irplib_framelist_delete(darkframes);
324  cpl_mask_delete(bpm);
325  cpl_image_delete(bpm_im);
326  cpl_imagelist_delete(twflat);
327  cpl_free(taglist);
328  cpl_propertylist_delete(qclist);
329 
330  return cpl_error_get_code();
331 }
332 
333 /*----------------------------------------------------------------------------*/
345 /*----------------------------------------------------------------------------*/
346 static cpl_imagelist * naco_img_twflat_reduce(const irplib_framelist * f_one,
347  const irplib_framelist * d_one)
348 {
349  const cpl_propertylist * plist
351  const char * filter = naco_pfits_get_filter(plist);
352  const char * tpl_id = naco_pfits_get_templateid(plist);
353  const char * rom_name = naco_pfits_get_rom_name(plist);
354  cpl_imagelist * i_one = NULL;
355  cpl_image * dark = NULL;
356  cpl_imagelist * results = NULL;
357  cpl_stats * stats_img = NULL;
358  cpl_image * flat;
359  double min_count = DBL_MAX; /* Avoid uninit warning */
360  double max_count = DBL_MAX; /* Avoid uninit warning */
361  double norm;
362  const double dit = naco_pfits_get_dit(plist);
363  const int nflats = irplib_framelist_get_size(f_one);
364  const int ndarks = d_one == NULL ? 0
365  : irplib_framelist_get_size(d_one);
366  int i;
367  cpl_boolean ok_nonpositive;
368 
369 
370  bug_if (0);
371 
372  cpl_msg_info(cpl_func, "Filter: [%s]", filter);
373  cpl_msg_info(cpl_func, "Read-out mode: [%s]", rom_name);
374  cpl_msg_info(cpl_func, "DIT: [%g]", dit);
375 
376  cpl_msg_info(cpl_func, "Reducing %d flats with subtraction of %d dark(s)",
377  nflats, ndarks);
378 
379  irplib_ensure(ndarks == 0 || ndarks == 1 || ndarks == nflats,
380  CPL_ERROR_INCOMPATIBLE_INPUT,
381  "Cannot reduce %d flats with %d darks", nflats, ndarks);
382 
383  ok_nonpositive = strncmp(tpl_id, "NACO_img_cal_SkyFlats",
384  IRPLIB_FITS_STRLEN) == 0 &&
385  strncmp(rom_name, "Uncorr", IRPLIB_FITS_STRLEN) == 0
386  ? CPL_TRUE : CPL_FALSE;
387 
388  /* Load input image set */
389  cpl_msg_info(cpl_func, "---> Loading input set");
390  irplib_check(i_one = irplib_imagelist_load_framelist(f_one, CPL_TYPE_FLOAT,
391  0, 0),
392  "Could not load the images of the flat frames");
393 
394  /* Compute some stats on input images */
395  cpl_msg_info(cpl_func, "---> Computing stats");
396  cpl_msg_info(cpl_func, "image min max med rms");
397  cpl_msg_info(cpl_func, "---------------------------------------------");
398  for (i = 0 ; i < nflats ; i++) {
399  double curr_count;
400 
401  flat = cpl_imagelist_get(i_one, i);
402 
403  bug_if( flat == NULL);
404 
405  stats_img = cpl_stats_new_from_image(flat, CPL_STATS_MIN
406  | CPL_STATS_MAX
407  | CPL_STATS_STDEV
408  | CPL_STATS_MEDIAN);
409 
410  bug_if (stats_img == NULL);
411 
412  curr_count = cpl_stats_get_median(stats_img);
413 
414  cpl_msg_info(cpl_func, "%02d %10.2f %10.2f %10.2f %10.2f", i+1,
415  cpl_stats_get_min(stats_img), cpl_stats_get_max(stats_img),
416  curr_count, cpl_stats_get_stdev(stats_img));
417 
418  cpl_stats_delete(stats_img);
419  stats_img = NULL;
420 
421  if (i==0 || curr_count < min_count) min_count = curr_count;
422  if (i==0 || curr_count > max_count) max_count = curr_count;
423 
424  /* Test only if not Uncorr or not skyflats */
425 
426  irplib_ensure (ok_nonpositive || curr_count > 0.0,
427  CPL_ERROR_ILLEGAL_INPUT,
428  "Flat %d has negative flux=%g using template=%s", i+1,
429  curr_count, tpl_id);
430 
431  if (ndarks == 0) continue;
432 
433  /* Apply dark correction to all planes */
434 
435  if (i == 0 || ndarks > 1) {
436  const cpl_frame * frame = irplib_framelist_get_const(d_one, i);
437  const char * name = cpl_frame_get_filename(frame);
438 
439  cpl_image_delete(dark);
440  irplib_check(dark = cpl_image_load(name, CPL_TYPE_FLOAT, 0, 0),
441  "Could not load FITS-image from %s", name);
442  }
443 
444  skip_if (cpl_image_subtract(flat, dark));
445 
446  }
447 
448  cpl_msg_info(cpl_func, "---------------------------------------------");
449 
450  if (ndarks > 0) {
451 
452  cpl_image_delete(dark);
453  dark = NULL;
454 
455  /* With the darks provided, the proportional method is used */
456  cpl_msg_info(cpl_func, "Switching to proportional fit");
457  naco_img_twflat_config.prop_flag = 1;
458 
459  } else if (!naco_img_twflat_config.prop_flag) {
460  /* See if flux gradient is large enough for a correct fit */
461  const double min_grad = 4.0;
462  /* FIXME: why fabs() ? */
463  if (fabs(max_count) < min_grad * fabs(min_count)) {
464  const double grad = fabs(max_count/min_count);
465 
466  cpl_msg_warning(cpl_func, "Low flux gradient: %g < %g", grad,
467  min_grad);
468  cpl_msg_warning(cpl_func,"A proportional fit may give better "
469  "results (Requires either a single master dark "
470  "frame or one dark per flat frame)");
471  }
472  }
473 
474  /* Fit slopes, get results */
475  if (naco_img_twflat_config.prop_flag) {
476  cpl_msg_info(cpl_func, "---> Fitting slopes proportionally");
477  results = irplib_flat_fit_set(i_one, 0);
478  irplib_ensure(results != NULL, CPL_ERROR_ILLEGAL_INPUT,
479  "Could not create twilight flat-field with "
480  "proportional fit");
481  } else {
482  cpl_msg_info(cpl_func, "---> Fitting slopes non-proportionally");
483  results = irplib_flat_fit_set(i_one, 1);
484  irplib_ensure(results != NULL, CPL_ERROR_ILLEGAL_INPUT,
485  "Could not create twilight flat-field with "
486  "non-proportional fit");
487  }
488  cpl_imagelist_delete(i_one);
489  i_one = NULL;
490 
491  /* Normalize gain */
492  flat = cpl_imagelist_get(results, 0);
493  bug_if( flat == NULL);
494  irplib_check(norm =
495  cpl_image_get_mean_window(flat,
496  naco_img_twflat_config.rej_left+1,
497  naco_img_twflat_config.rej_bottom+1,
498  cpl_image_get_size_x(flat)
499  -naco_img_twflat_config.rej_right,
500  cpl_image_get_size_y(flat)
501  -naco_img_twflat_config.rej_top);
502  cpl_image_divide_scalar(flat, norm),
503  "Could not normalize gain with norm=%g", norm);
504 
505  end_skip;
506 
507  cpl_imagelist_delete(i_one);
508  cpl_stats_delete(stats_img);
509  cpl_image_delete(dark);
510 
511  if (cpl_error_get_code()) {
512  cpl_imagelist_delete(results);
513  results = NULL;
514  }
515 
516  return results;
517 }
518 
519 
520 /*----------------------------------------------------------------------------*/
527 /*----------------------------------------------------------------------------*/
528 static cpl_error_code naco_img_twflat_qc(cpl_propertylist * qclist,
529  const irplib_framelist * rawframes)
530 {
531 
532  const cpl_propertylist * reflist
534 
535 
536  bug_if (0);
537 
538  bug_if (cpl_propertylist_copy_property_regexp(qclist, reflist, "^("
539  IRPLIB_PFITS_REGEXP_RECAL
540  ")$", 0));
541 
542  bug_if (irplib_pfits_set_airmass(qclist, rawframes));
543 
544  end_skip;
545 
546  return cpl_error_get_code();
547 }
548 
549 /*----------------------------------------------------------------------------*/
561 /*----------------------------------------------------------------------------*/
562 static cpl_error_code naco_img_twflat_save(cpl_frameset * set_tot,
563  const cpl_parameterlist * parlist,
564  const cpl_propertylist * qclist,
565  const cpl_imagelist * flat,
566  const cpl_image * bpm,
567  int set_nb,
568  const irplib_framelist * f_one)
569 {
570 
571  cpl_frameset * rawframes = irplib_frameset_cast(f_one);
572  char * filename = NULL;
573  const int nflats = cpl_imagelist_get_size(flat);
574 
575 
576  /* This will catch f_one == NULL or plist == NULL */
577  bug_if (nflats != 2 && nflats != 3);
578 
579  /* Write the flat image */
580  filename = cpl_sprintf(RECIPE_STRING "_set%02d" CPL_DFS_FITS, set_nb);
581  skip_if (irplib_dfs_save_image(set_tot, parlist, rawframes,
582  cpl_imagelist_get_const(flat, 0),
583  CPL_BPP_IEEE_FLOAT, RECIPE_STRING,
584  NACO_IMG_TWFLAT_RES, qclist, NULL, naco_pipe_id,
585  filename));
586 
587  if (bpm != NULL) {
588  /* Write the bpm image */
589  cpl_free(filename);
590  filename = cpl_sprintf(RECIPE_STRING "_set%02d_bpm" CPL_DFS_FITS,
591  set_nb);
592  skip_if (irplib_dfs_save_image(set_tot, parlist, rawframes, bpm,
593  CPL_BPP_8_UNSIGNED, RECIPE_STRING,
594  NACO_IMG_TWFLAT_BPM, qclist, NULL,
595  naco_pipe_id, filename));
596  }
597 
598  if (naco_img_twflat_config.intercept_flag && nflats == 3) {
599  /* Write the intercept image */
600  cpl_free(filename);
601  filename = cpl_sprintf(RECIPE_STRING "_set%02d_inter"
602  CPL_DFS_FITS, set_nb);
603  skip_if (irplib_dfs_save_image(set_tot, parlist, rawframes,
604  cpl_imagelist_get_const(flat, 1),
605  CPL_BPP_IEEE_FLOAT, RECIPE_STRING,
606  NACO_IMG_TWFLAT_INTER, qclist, NULL,
607  naco_pipe_id, filename));
608  }
609 
610  if (naco_img_twflat_config.errmap_flag) {
611  /* Write the error map image */
612  cpl_free(filename);
613  filename = cpl_sprintf(RECIPE_STRING "_set%02d_errmap"
614  CPL_DFS_FITS, set_nb);
615  skip_if (irplib_dfs_save_image(set_tot, parlist, rawframes,
616  cpl_imagelist_get_const(flat, nflats - 1),
617  CPL_BPP_IEEE_FLOAT, RECIPE_STRING,
618  NACO_IMG_TWFLAT_ERRMAP, qclist, NULL,
619  naco_pipe_id, filename));
620  }
621 
622  end_skip;
623 
624  cpl_free(filename);
625  cpl_frameset_delete(rawframes);
626 
627  return cpl_error_get_code();
628 }
629 
630 /*----------------------------------------------------------------------------*/
643 /*----------------------------------------------------------------------------*/
644 static char * naco_img_twflat_make_tag(const cpl_frame* self,
645  const cpl_propertylist* plist, int dummy)
646 {
647 
648  char * tag = NULL;
649  const char * filter;
650  const char * mode;
651  const char * name;
652  double dit;
653 
654 
655  bug_if (cpl_error_get_code());
656 
657  bug_if(self == NULL);
658  bug_if(plist == NULL);
659  bug_if(dummy < 0); /* Avoid warning of unused variable */
660 
661 
662  /* filter */
663  filter = naco_pfits_get_filter(plist);
664  skip_if(cpl_error_get_code());
665 
666  /* ROM */
667  name = naco_pfits_get_rom_name(plist);
668  skip_if(cpl_error_get_code());
669 
670  /* mode */
671  mode = naco_pfits_get_mode(plist);
672  skip_if(cpl_error_get_code());
673 
674  /* the DIT */
675  dit = naco_pfits_get_dit(plist);
676  skip_if(cpl_error_get_code());
677 
678  tag = cpl_sprintf("%s:%s:%s:%.5f", filter,
679  name, mode, dit);
680  bug_if(tag == NULL);
681 
682  end_skip;
683 
684  if (cpl_error_get_code()) {
685  cpl_free(tag);
686  tag = NULL;
687  }
688 
689  return tag;
690 
691 }
692 
693 
694 /*----------------------------------------------------------------------------*/
706 /*----------------------------------------------------------------------------*/
707 static char * naco_img_twflat_make_dark_tag(const cpl_frame * self,
708  const cpl_propertylist * plist,
709  int dummy)
710 {
711  char * tag = NULL;
712  const char * mode;
713  const char * name;
714  double dit;
715 
716 
717  bug_if (cpl_error_get_code());
718 
719  bug_if(self == NULL);
720  bug_if(plist == NULL);
721  bug_if(dummy < 0); /* Avoid warning of unused variable */
722 
723 
724  /* ROM */
725  name = naco_pfits_get_rom_name(plist);
726  skip_if(cpl_error_get_code());
727 
728  /* mode */
729  mode = naco_pfits_get_mode(plist);
730  skip_if(cpl_error_get_code());
731 
732  /* the DIT */
733  dit = naco_pfits_get_dit(plist);
734  skip_if(cpl_error_get_code());
735 
736  tag = cpl_sprintf("%s:%s:%.5f", name, mode, dit);
737  bug_if(tag == NULL);
738 
739  end_skip;
740 
741  if (cpl_error_get_code()) {
742  cpl_free(tag);
743  tag = NULL;
744  }
745 
746  return tag;
747 
748 }
cpl_imagelist * irplib_imagelist_load_framelist(const irplib_framelist *self, cpl_type pixeltype, int planenum, int extnum)
Load an imagelist from a framelist.
cpl_frameset * irplib_frameset_cast(const irplib_framelist *self)
Create a CPL frameset from an irplib_framelist.
const char * naco_pfits_get_rom_name(const cpl_propertylist *self)
find out the read out mode name
Definition: naco_pfits.c:389
cpl_imagelist * irplib_flat_fit_set(cpl_imagelist *raw, int mode)
Compute a flat-field out of a set of exposures.
Definition: irplib_flat.c:87
double naco_pfits_get_dit(const cpl_propertylist *self)
find out the DIT
Definition: naco_pfits.c:131
cpl_error_code irplib_framelist_set_tag_all(irplib_framelist *self, const char *tag)
Set the tag of all frames in the list.
int naco_dfs_set_groups(cpl_frameset *set)
Set the group as RAW or CALIB in a frameset.
Definition: naco_dfs.c:62
cpl_error_code irplib_framelist_set(irplib_framelist *self, cpl_frame *frame, int pos)
Add a frame to a framelist.
cpl_error_code irplib_pfits_set_airmass(cpl_propertylist *self, const irplib_framelist *rawframes)
Update/Set the AIRMASS property.
Definition: irplib_pfits.c:373
const cpl_propertylist * irplib_framelist_get_propertylist_const(const irplib_framelist *self, int pos)
Get the propertylist of the specified frame in the framelist.
void irplib_framelist_empty(irplib_framelist *self)
Erase all frames from a framelist.
cpl_error_code irplib_dfs_save_image(cpl_frameset *allframes, const cpl_parameterlist *parlist, const cpl_frameset *usedframes, const cpl_image *image, cpl_type_bpp bpp, const char *recipe, const char *procat, const cpl_propertylist *applist, const char *remregexp, const char *pipe_id, const char *filename)
Save an image as a DFS-compliant pipeline product.
Definition: irplib_utils.c:208
cpl_error_code irplib_framelist_load_propertylist_all(irplib_framelist *self, int ind, const char *regexp, cpl_boolean invert)
Load the propertylists of all frames in the framelist.
cpl_frame * irplib_framelist_unset(irplib_framelist *self, int pos, cpl_propertylist **plist)
Erase a frame from a framelist and return it to the caller.
cpl_boolean naco_parameterlist_get_bool(const cpl_parameterlist *self, const char *recipe, naco_parameter bitmask)
Retrieve the value of a NACO boolean parameter.
irplib_framelist * irplib_framelist_extract(const irplib_framelist *self, const char *tag)
Extract the frames with the given tag from a framelist.
const cpl_frame * irplib_framelist_get_const(const irplib_framelist *self, int pos)
Get the specified frame from the framelist.
const char ** naco_framelist_set_tag(irplib_framelist *self, char *(*pftag)(const cpl_frame *, const cpl_propertylist *, int), int *pntags)
Retag a framelist according to the given tagging function.
Definition: naco_utils.c:176
void irplib_framelist_delete(irplib_framelist *self)
Deallocate an irplib_framelist with its frames and properties.
const char * naco_pfits_get_templateid(const cpl_propertylist *self)
find out the template ID
Definition: naco_pfits.c:413
const char * naco_pfits_get_mode(const cpl_propertylist *self)
find out the mode name
Definition: naco_pfits.c:268
irplib_framelist * irplib_framelist_cast(const cpl_frameset *frameset)
Create an irplib_framelist from a cpl_framelist.
const char * naco_parameterlist_get_string(const cpl_parameterlist *self, const char *recipe, naco_parameter bitmask)
Retrieve the value of a NACO string parameter.
int irplib_framelist_get_size(const irplib_framelist *self)
Get the size of a framelist.
const char * naco_pfits_get_filter(const cpl_propertylist *self)
find out the filter
Definition: naco_pfits.c:167