NACO Pipeline Reference Manual  4.4.0
naco_img_strehl.c
1 /* $Id: naco_img_strehl.c,v 1.67 2011-12-22 11:09:36 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: 2011-12-22 11:09:36 $
24  * $Revision: 1.67 $
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 #include "naco_recipe.h"
36 #include "naco_strehl.h"
37 
38 #include <string.h>
39 
40 /*-----------------------------------------------------------------------------
41  Define
42  -----------------------------------------------------------------------------*/
43 
44 #define STREHL_MINIMUM_FLUX 100000
45 #define STREHL_MAXIMUM_PEAK 4000
46 #define STREHL_DEF_LOCATE_SX 512
47 #define STREHL_DEF_LOCATE_SY 512
48 
49 #define RECIPE_STRING "naco_img_strehl"
50 
51 /*-----------------------------------------------------------------------------
52  Private Functions prototypes
53  -----------------------------------------------------------------------------*/
54 
55 static cpl_image * naco_img_strehl_reduce(const cpl_parameterlist *,
56  const irplib_framelist *);
57 
58 static cpl_error_code naco_img_strehl_qc(cpl_propertylist *,
59  cpl_propertylist *,
60  const irplib_framelist *);
61 
62 static cpl_error_code naco_img_strehl_save(cpl_frameset *,
63  const cpl_parameterlist *,
64  const cpl_propertylist *,
65  const cpl_propertylist *,
66  const cpl_image *,
67  const irplib_framelist *,
68  int);
69 
70 NACO_RECIPE_DEFINE(naco_img_strehl,
71  NACO_PARAM_STAR_R |
72  NACO_PARAM_BG_RINT |
73  NACO_PARAM_BG_REXT,
74  "Strehl computation recipe",
75  RECIPE_STRING " -- NACO Strehl Ratio recipe.\n"
76  "This recipe estimates the strehl ratio and its error "
77  "bound.\nThe Set Of Frames (sof-file) must specify at "
78  "least one pair of files and they must be tagged either\n"
79  "NACO-raw-file.fits " NACO_IMG_STREHL_CAL " or\n"
80  "NACO-raw-file.fits " NACO_IMG_STREHL_TECH "\n");
81 
82 /*-----------------------------------------------------------------------------
83  Static variables
84  -----------------------------------------------------------------------------*/
85 
86 static struct {
87  /* Inputs */
88  int mode;
89  /* Outputs */
90  double pscale;
91  const char * filter;
92  double pos_x;
93  double pos_y;
94  double strehl;
95  double strehl_err;
96  double star_bg;
97  double star_peak;
98  double star_flux;
99  double psf_peak;
100  double psf_flux;
101  double bg_noise;
102 } naco_img_strehl_config;
103 
104 /*----------------------------------------------------------------------------*/
108 /*----------------------------------------------------------------------------*/
109 
110 /*-----------------------------------------------------------------------------
111  Functions code
112  -----------------------------------------------------------------------------*/
113 
114 
115 /*----------------------------------------------------------------------------*/
122 /*----------------------------------------------------------------------------*/
123 static int naco_img_strehl(cpl_frameset * framelist,
124  const cpl_parameterlist * parlist)
125 {
126  cpl_errorstate cleanstate = cpl_errorstate_get();
127  irplib_framelist * allframes = NULL;
128  irplib_framelist * rawframes = NULL;
129  irplib_framelist * framepair = NULL;
130  cpl_frame * frame1 = NULL;
131  cpl_frame * frame2 = NULL;
132  cpl_image * img = NULL;
133  cpl_propertylist * qclist = cpl_propertylist_new();
134  cpl_propertylist * paflist = cpl_propertylist_new();
135  int nframes, npairs;
136  int nb_good = 0;
137  int i;
138 
139  /* Identify the RAW and CALIB frames in the input frameset */
140  irplib_check(naco_dfs_set_groups(framelist),
141  "Could not group the input frames");
142 
143  allframes = irplib_framelist_cast(framelist);
144  skip_if(allframes == NULL);
145  irplib_check(rawframes
147  "^(" NACO_IMG_STREHL_CAL
148  "|" NACO_IMG_STREHL_TECH
149  ")$", CPL_FALSE),
150  "Could not load the raw frames");
151  irplib_framelist_empty(allframes);
152 
153  naco_img_strehl_config.mode = 0;
154  if (cpl_frameset_find(framelist, NACO_IMG_STREHL_CAL))
155  naco_img_strehl_config.mode = 1;
156 
157  if (cpl_frameset_find(framelist, NACO_IMG_STREHL_TECH)) {
158  irplib_ensure(!naco_img_strehl_config.mode, CPL_ERROR_INCOMPATIBLE_INPUT,
159  "Mixing of DO categories " NACO_IMG_STREHL_CAL " and "
160  NACO_IMG_STREHL_TECH "is not supported");
161  naco_img_strehl_config.mode = 2;
162  }
163 
164  /* Check if there is an even number of frames */
165  nframes = irplib_framelist_get_size(rawframes);
166  skip_if_lt(nframes, 2, "frames");
167 
168  if (nframes % 2) {
169  cpl_msg_warning(cpl_func, "The SOF comprises an odd number (%d) of raw "
170  "frames, ignoring the last", nframes);
171  skip_if(irplib_framelist_erase(rawframes, nframes - 1));
172  }
173  npairs = nframes/2;
174 
175  framepair = irplib_framelist_new();
176 
177  /* Reduce each pair */
178  for (i=0; i < npairs; i++) {
179  cpl_error_code error;
180 
181  /* Reduce data pair i */
182  cpl_msg_info(cpl_func, "Reducing pair %d out of %d", i+1, npairs);
183 
184  frame1 = irplib_framelist_unset(rawframes, 0, NULL);
185  error = irplib_framelist_set(framepair, frame1, 0);
186  bug_if(error);
187 
188  skip_if(irplib_framelist_load_propertylist(framepair, 0, 0, "^("
189  IRPLIB_PFITS_REGEXP_RECAL "|"
190  NACO_PFITS_REGEXP_STREHL "|"
191  NACO_PFITS_REGEXP_STREHL_PAF
192  ")$", CPL_FALSE));
193 
194  frame2 = irplib_framelist_unset(rawframes, 0, NULL);
195  error = irplib_framelist_set(framepair, frame2, 1);
196  bug_if(error);
197 
198  skip_if(irplib_framelist_load_propertylist_all(framepair, 0, "^("
199  NACO_PFITS_REGEXP_STREHL
200  ")$", CPL_FALSE));
201 
202  img = naco_img_strehl_reduce(parlist, framepair);
203 
204  if (img == NULL) {
205  if (npairs > 1)
206  irplib_error_recover(cleanstate, "Could not reduce pair number "
207  "%d:", i+1);
208  } else {
209 
210  skip_if(naco_img_strehl_qc(qclist, paflist, framepair));
211 
212  /* PRO.CATG */
213  bug_if (cpl_propertylist_append_string(paflist, CPL_DFS_PRO_CATG,
214  naco_img_strehl_config.mode
215  == 1 ? NACO_IMG_STREHL_RESCAL
216  : NACO_IMG_STREHL_RESTECH));
217 
218  irplib_ensure(!naco_img_strehl_save(framelist, parlist, qclist,
219  paflist, img, framepair, i+1),
220  CPL_ERROR_FILE_IO,
221  "Could not save the products of pair %d", i+1);
222 
223  cpl_image_delete(img);
224  img = NULL;
225  cpl_propertylist_empty(qclist);
226  cpl_propertylist_empty(paflist);
227 
228  nb_good++;
229  }
230 
231  /* Empty the list - and deallocate the propertylists */
232  irplib_framelist_empty(framepair);
233 
234  bug_if(irplib_framelist_get_size(framepair) != 0);
235 
236  }
237 
238  bug_if(irplib_framelist_get_size(rawframes) != 0);
239 
240  irplib_ensure(nb_good > 0, CPL_ERROR_DATA_NOT_FOUND,
241  "None of the %d pairs of frames could be reduced", npairs);
242 
243  end_skip;
244 
245  cpl_image_delete(img);
246  irplib_framelist_delete(allframes);
247  irplib_framelist_delete(rawframes);
248  irplib_framelist_delete(framepair);
249  cpl_propertylist_delete(qclist);
250  cpl_propertylist_delete(paflist);
251 
252  return cpl_error_get_code();
253 }
254 
255 /*----------------------------------------------------------------------------*/
262 /*----------------------------------------------------------------------------*/
263 static cpl_image * naco_img_strehl_reduce(const cpl_parameterlist * parlist,
264  const irplib_framelist * framepair)
265 {
266 
267  const cpl_frame * frame1 = irplib_framelist_get_const(framepair, 0);
268  const cpl_frame * frame2 = irplib_framelist_get_const(framepair, 1);
269  const cpl_propertylist * plist1
271  const cpl_propertylist * plist2
273  const char * sval1;
274  const char * sval2;
275  cpl_image * im1 = NULL;
276  cpl_image * im2 = NULL;
277  /* Sigma-levels for detection of a bright star.
278  NACO-3.3.1 mysteriously has: 5, 2, 2, 0.5 */
279  double psigmas[] = {5.0, 2.0, 1.0, 0.5};
280  const int nsigmas = (int)(sizeof(psigmas)/sizeof(double));
281  cpl_size isigma;
282  cpl_vector * sigmas = NULL;
283  cpl_apertures * apert = NULL;
284  double dval;
285  double pixscale;
286  double lam, dlam;
287  int iflux;
288  int ndit;
289 
290 
291  bug_if(cpl_error_get_code());
292 
293  naco_img_strehl_config.pscale = -1.0;
294  naco_img_strehl_config.pos_x = -1.0;
295  naco_img_strehl_config.pos_y = -1.0;
296  naco_img_strehl_config.strehl = -1.0;
297  naco_img_strehl_config.strehl_err = -1.0;
298  naco_img_strehl_config.star_bg = -1.0;
299  naco_img_strehl_config.star_peak = -1.0;
300  naco_img_strehl_config.star_flux = -1.0;
301  naco_img_strehl_config.psf_peak = -1.0;
302  naco_img_strehl_config.psf_flux = -1.0;
303  naco_img_strehl_config.bg_noise = -1.0;
304 
305  /* Print out the filter and the pixel scale */
306  irplib_check(sval1 = naco_pfits_get_filter(plist1);
307  sval2 = naco_pfits_get_filter(plist2);
308  pixscale = naco_pfits_get_pixscale(plist1);
309  dval = naco_pfits_get_pixscale(plist2),
310  "Could not load the filter names and Pixel-scales");
311 
312  irplib_ensure(!strcmp(sval1, sval2), CPL_ERROR_INCOMPATIBLE_INPUT,
313  "The filters in the pair are different: %s <=> %s", sval1, sval2);
314 
315  irplib_ensure(fabs(pixscale-dval) <= 1e-3, CPL_ERROR_INCOMPATIBLE_INPUT,
316  "The pixel-scales in the pair are different: %g <=> %g",
317  pixscale, dval);
318 
319  naco_img_strehl_config.pscale = pixscale;
320  naco_img_strehl_config.filter = sval1;
321 
322  cpl_msg_info(cpl_func, "Filter: [%s]", naco_img_strehl_config.filter);
323  cpl_msg_info(cpl_func, "Pixel scale: [%g]", naco_img_strehl_config.pscale);
324 
325  /* Load input images */
326  cpl_msg_info(cpl_func, "---> Loading the pair of input images");
327  im1 = cpl_image_load(cpl_frame_get_filename(frame1), CPL_TYPE_FLOAT, 0, 0);
328  skip_if(0);
329  im2 = cpl_image_load(cpl_frame_get_filename(frame2), CPL_TYPE_FLOAT, 0, 0);
330  skip_if(0);
331 
332  /* Subtract input images */
333  cpl_msg_info(cpl_func, "---> Subtracting input images");
334  skip_if(cpl_image_subtract(im1, im2));
335  cpl_image_delete(im2);
336  im2 = NULL;
337 
338  /* Get lam and dlam from the filter name for the Strehl computation */
339  irplib_check(naco_get_filter_infos(naco_img_strehl_config.filter, &lam, &dlam),
340  "Cannot get filter infos [%s]", naco_img_strehl_config.filter);
341 
342  cpl_msg_warning(cpl_func, "LAM=%g, DLAM=%g", lam, dlam);
343  /* Detect a bright star around the center */
344  cpl_msg_info(cpl_func, "---> Detecting a bright star using %d sigma-levels "
345  "ranging from %g down to %g", nsigmas, psigmas[0],
346  psigmas[nsigmas-1]);
347  sigmas = cpl_vector_wrap(nsigmas, psigmas);
348  irplib_check(apert = cpl_apertures_extract_window(im1, sigmas,
349  (int)(cpl_image_get_size_x(im1)-STREHL_DEF_LOCATE_SX)/2,
350  (int)(cpl_image_get_size_y(im1)-STREHL_DEF_LOCATE_SY)/2,
351  (int)(cpl_image_get_size_x(im1)+STREHL_DEF_LOCATE_SX)/2,
352  (int)(cpl_image_get_size_y(im1)+STREHL_DEF_LOCATE_SY)/2,
353  &isigma),
354  "Could not detect the star");
355 
356  skip_if(irplib_apertures_find_max_flux(apert, &iflux, 1));
357 
358  naco_img_strehl_config.pos_x = cpl_apertures_get_centroid_x(apert, iflux);
359  naco_img_strehl_config.pos_y = cpl_apertures_get_centroid_y(apert, iflux);
360  cpl_apertures_delete(apert);
361  apert = NULL;
362  cpl_msg_info(cpl_func, "Star detected at sigma=%g, at position %g %g",
363  psigmas[isigma],
364  naco_img_strehl_config.pos_x,
365  naco_img_strehl_config.pos_y);
366  skip_if(0);
367 
368  /* Get lam and dlam from the filter name for the Strehl computation */
369  irplib_check(naco_get_filter_infos(naco_img_strehl_config.filter, &lam, &dlam),
370  "Cannot get filter infos [%s]", naco_img_strehl_config.filter);
371 
372  /* Compute the strehl */
373  cpl_msg_info(cpl_func, "---> Computing the strehl ratio");
374  irplib_check(naco_strehl_compute(im1, parlist, RECIPE_STRING, lam, dlam,
375  naco_img_strehl_config.pos_x,
376  naco_img_strehl_config.pos_y,
377  naco_img_strehl_config.pscale,
378  &(naco_img_strehl_config.strehl),
379  &(naco_img_strehl_config.strehl_err),
380  &(naco_img_strehl_config.star_bg),
381  &(naco_img_strehl_config.star_peak),
382  &(naco_img_strehl_config.star_flux),
383  &(naco_img_strehl_config.psf_peak),
384  &(naco_img_strehl_config.psf_flux),
385  &(naco_img_strehl_config.bg_noise)),
386  "Could not compute the Strehl ratio");
387 
388  ndit = naco_pfits_get_ndit(plist1);
389  skip_if(cpl_error_get_code());
390 
391  cpl_msg_info(cpl_func, "Strehl: %g", naco_img_strehl_config.strehl);
392  cpl_msg_info(cpl_func, "Strehl error: %g", naco_img_strehl_config.strehl_err);
393  cpl_msg_info(cpl_func, "Star bg: %g", naco_img_strehl_config.star_bg);
394  cpl_msg_info(cpl_func, "Star peak: %g", naco_img_strehl_config.star_peak);
395  cpl_msg_info(cpl_func, "Star flux: %g", naco_img_strehl_config.star_flux);
396  cpl_msg_info(cpl_func, "PSF peak: %g", naco_img_strehl_config.psf_peak);
397  cpl_msg_info(cpl_func, "PSF flux: %g", naco_img_strehl_config.psf_flux);
398  cpl_msg_info(cpl_func, "Bg noise: %g", naco_img_strehl_config.bg_noise);
399 
400  if (ndit*naco_img_strehl_config.star_flux < STREHL_MINIMUM_FLUX)
401  cpl_msg_warning(cpl_func, "The Strehl may be unreliable, due to a too "
402  "low star flux: %g < %g/%d",
403  naco_img_strehl_config.star_flux,
404  (double)STREHL_MINIMUM_FLUX, ndit);
405 
406  if (naco_img_strehl_config.star_peak > STREHL_MAXIMUM_PEAK)
407  cpl_msg_warning(cpl_func, "The Strehl may be unreliable, due to a too "
408  "high star peak: %g > %g",
409  naco_img_strehl_config.star_peak,
410  (double)STREHL_MAXIMUM_PEAK);
411 
412  end_skip;
413 
414  cpl_image_delete(im2);
415  cpl_apertures_delete(apert);
416  cpl_vector_unwrap(sigmas);
417 
418  if (cpl_error_get_code()) {
419  cpl_image_delete(im1);
420  im1 = NULL;
421  }
422 
423  return im1;
424 }
425 
426 
427 /*----------------------------------------------------------------------------*/
435 /*----------------------------------------------------------------------------*/
436 static cpl_error_code naco_img_strehl_qc(cpl_propertylist * qclist,
437  cpl_propertylist * paflist,
438  const irplib_framelist * framepair)
439 {
440 
441  cpl_errorstate cleanstate = cpl_errorstate_get();
442  const cpl_propertylist * plist1
444  const cpl_propertylist * plist2
446  const char * optiname;
447  double dval1, dval2;
448  double mean;
449  const double almost_zero = 1e-3; /* FIXME: Arbitrary constant */
450 
451 
452 
453  bug_if (0);
454 
455  /* Get the keywords for the paf file */
456  skip_if (cpl_propertylist_copy_property_regexp(paflist, plist1, "^("
457  NACO_PFITS_REGEXP_STREHL_PAF
458  ")$", 0));
459 
460  /* AOS.RTC.DET.DST.L0MEAN */
461  dval1 = naco_pfits_get_l0mean(plist1);
462  dval2 = naco_pfits_get_l0mean(plist2);
463  mean = 0.0;
464  if (cpl_error_get_code())
465  naco_error_reset("Could not get FITS key:");
466  else {
467  if (fabs(dval1) <= almost_zero) mean = dval2;
468  else if (fabs(dval2) <= almost_zero) mean = dval1;
469  else mean = (dval1+dval2)/2.0;
470  }
471  skip_if(cpl_propertylist_append_double(paflist,
472  "ESO AOS RTC DET DST L0MEAN", mean));
473 
474  /* AOS.RTC.DET.DST.T0MEAN */
475  dval1 = naco_pfits_get_t0mean(plist1);
476  dval2 = naco_pfits_get_t0mean(plist2);
477  mean = 0.0;
478  if (cpl_error_get_code())
479  naco_error_reset("Could not get FITS key:");
480  else {
481  if (fabs(dval1) <= almost_zero) mean = dval2;
482  else if (fabs(dval2) <= almost_zero) mean = dval1;
483  else mean = (dval1+dval2)/2.0;
484  }
485  skip_if(cpl_propertylist_append_double(paflist, "ESO AOS RTC DET DST T0MEAN",
486  mean));
487 
488  /* AOS.RTC.DET.DST.R0MEAN */
489  dval1 = naco_pfits_get_r0mean(plist1);
490  dval2 = naco_pfits_get_r0mean(plist2);
491  mean = 0.0;
492  if (cpl_error_get_code())
493  naco_error_reset("Could not get FITS key:");
494  else {
495  if (fabs(dval1) <= almost_zero) mean = dval2;
496  else if (fabs(dval2) <= almost_zero) mean = dval1;
497  else mean = (dval1+dval2)/2.0;
498  }
499  skip_if(cpl_propertylist_append_double(paflist, "ESO AOS RTC DET DST R0MEAN",
500  mean));
501 
502  /* AOS.RTC.DET.DST.ECMEAN */
503  dval1 = naco_pfits_get_ecmean(plist1);
504  dval2 = naco_pfits_get_ecmean(plist2);
505  mean = 0.0;
506  if (cpl_error_get_code())
507  naco_error_reset("Could not get FITS key:");
508  else {
509  if (fabs(dval1) <= almost_zero) mean = dval2;
510  else if (fabs(dval2) <= almost_zero) mean = dval1;
511  else mean = (dval1+dval2)/2.0;
512  }
513  skip_if(cpl_propertylist_append_double(paflist, "ESO AOS RTC DET DST ECMEAN",
514  mean));
515 
516  /* AOS.RTC.DET.DST.FLUXMEAN */
517  dval1 = naco_pfits_get_fluxmean(plist1);
518  dval2 = naco_pfits_get_fluxmean(plist2);
519  mean = 0.0;
520  if (cpl_error_get_code())
521  naco_error_reset("Could not get FITS key:");
522  else {
523  if (fabs(dval1) <= almost_zero) mean = dval2;
524  else if (fabs(dval2) <= almost_zero) mean = dval1;
525  else mean = (dval1+dval2)/2.0;
526  }
527  skip_if(cpl_propertylist_append_double(paflist,"ESO AOS RTC DET DST FLUXMEAN",
528  mean));
529 
530  /* Add QC parameters */
531  skip_if(cpl_propertylist_append_string(qclist, "ESO QC FILTER OBS",
532  naco_img_strehl_config.filter));
533 
534  optiname = naco_pfits_get_opti3_name(plist1);
535  if (cpl_error_get_code())
536  naco_error_reset("Could not get FITS key:");
537  else
538  skip_if(cpl_propertylist_append_string(qclist, "ESO QC FILTER NDENS",
539  optiname));
540  optiname = naco_pfits_get_opti4_name(plist1);
541  if (cpl_error_get_code())
542  naco_error_reset("Could not get FITS key:");
543  else
544  skip_if(cpl_propertylist_append_string(qclist, "ESO QC FILTER POL",
545  optiname));
546 
547  /* QC.AIRMASS */
548  mean = 0.5*(naco_pfits_get_airmass_start(plist1) +
550  if (cpl_error_get_code()) {
551  mean = 0.0;
552  naco_error_reset("Could not get FITS key:");
553  }
554  skip_if(cpl_propertylist_append_double(qclist, "ESO QC AIRMASS", mean));
555 
556  /* STREHL */
557  cpl_propertylist_append_double(qclist, "ESO QC STREHL",
558  naco_img_strehl_config.strehl);
559  cpl_propertylist_append_double(qclist, "ESO QC STREHL FLUX",
560  naco_img_strehl_config.star_flux);
561  cpl_propertylist_append_double(qclist, "ESO QC STREHL PEAK",
562  naco_img_strehl_config.star_peak);
563  cpl_propertylist_append_double(qclist, "ESO QC STREHL ERROR",
564  naco_img_strehl_config.strehl_err);
565  cpl_propertylist_append_double(qclist, "ESO QC STREHL RMS",
566  naco_img_strehl_config.bg_noise);
567  cpl_propertylist_append_double(qclist, "ESO QC STREHL POSX",
568  naco_img_strehl_config.pos_x);
569  cpl_propertylist_append_double(qclist, "ESO QC STREHL POSY",
570  naco_img_strehl_config.pos_y);
571 
572  bug_if(0);
573 
574  bug_if (cpl_propertylist_append(paflist, qclist));
575 
576  bug_if (cpl_propertylist_copy_property_regexp(qclist, plist1, "^("
577  IRPLIB_PFITS_REGEXP_RECAL
578  ")$", 0));
579 
580  bug_if (irplib_pfits_set_airmass(qclist, framepair));
581 
582  end_skip;
583 
584  return cpl_error_get_code();
585 }
586 
587 /*----------------------------------------------------------------------------*/
599 /*----------------------------------------------------------------------------*/
600 static cpl_error_code naco_img_strehl_save(cpl_frameset * set_tot,
601  const cpl_parameterlist * parlist,
602  const cpl_propertylist * qclist,
603  const cpl_propertylist * paflist,
604  const cpl_image * ima,
605  const irplib_framelist * framepair,
606  int pair_id)
607 {
608  cpl_frameset * rawframes = irplib_frameset_cast(framepair);
609  char * filename = NULL;
610 
611 
612  bug_if(0);
613 
614  /* Write the FITS file */
615  filename = cpl_sprintf(RECIPE_STRING "%02d" CPL_DFS_FITS, pair_id);
616  skip_if (irplib_dfs_save_image(set_tot, parlist, rawframes, ima,
617  CPL_BPP_IEEE_FLOAT, RECIPE_STRING,
618  naco_img_strehl_config.mode == 1
619  ? NACO_IMG_STREHL_RESCAL
620  : NACO_IMG_STREHL_RESTECH, qclist, NULL,
621  naco_pipe_id, filename));
622 
623 
624  cpl_free(filename);
625  filename = cpl_sprintf(RECIPE_STRING "%02d" CPL_DFS_PAF, pair_id);
626  skip_if (cpl_dfs_save_paf("NACO", RECIPE_STRING, paflist, filename));
627 
628  end_skip;
629 
630  cpl_free(filename);
631  cpl_frameset_delete(rawframes);
632 
633  return cpl_error_get_code();
634 }
635 
636 
cpl_frameset * irplib_frameset_cast(const irplib_framelist *self)
Create a CPL frameset from an irplib_framelist.
cpl_error_code naco_strehl_compute(const cpl_image *self, const cpl_parameterlist *parlist, const char *recipename, double lam, double dlam, double pos_x, double pos_y, double pixscale, double *pstrehl, double *pstrehl_err, double *pstar_bg, double *pstar_peak, double *pstar_flux, double *ppsf_peak, double *ppsf_flux, double *pbg_noise)
Compute the strehl ratio in an image.
Definition: naco_strehl.c:80
double naco_pfits_get_pixscale(const cpl_propertylist *self)
find out the pixel scale
Definition: naco_pfits.c:341
const char * naco_pfits_get_opti4_name(const cpl_propertylist *self)
find out the OPTI4.NAME key
Definition: naco_pfits.c:316
cpl_error_code naco_get_filter_infos(const char *f, double *lam, double *dlam)
Get the infos of one of the filters.
Definition: naco_utils.c:61
double naco_pfits_get_t0mean(const cpl_propertylist *self)
find out the T0MEAN key
Definition: naco_pfits.c:401
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_apertures_find_max_flux(const cpl_apertures *self, int *ind, int nfind)
Find the aperture(s) with the greatest flux.
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
irplib_framelist * irplib_framelist_extract_regexp(const irplib_framelist *self, const char *regexp, cpl_boolean invert)
Extract the frames with the given tag from a framelist.
int naco_pfits_get_ndit(const cpl_propertylist *self)
find out the NDIT keyword
Definition: naco_pfits.c:292
double naco_pfits_get_l0mean(const cpl_propertylist *self)
find out the L0MEAN
Definition: naco_pfits.c:244
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.
double naco_pfits_get_airmass_start(const cpl_propertylist *self)
find out airmass start
Definition: naco_pfits.c:71
double naco_pfits_get_fluxmean(const cpl_propertylist *self)
find out the FLUXMEAN key
Definition: naco_pfits.c:208
const cpl_frame * irplib_framelist_get_const(const irplib_framelist *self, int pos)
Get the specified frame from the framelist.
const char * naco_pfits_get_opti3_name(const cpl_propertylist *self)
find out the OPTI3.NAME key
Definition: naco_pfits.c:304
void irplib_framelist_delete(irplib_framelist *self)
Deallocate an irplib_framelist with its frames and properties.
double naco_pfits_get_airmass_end(const cpl_propertylist *self)
find out airmass end
Definition: naco_pfits.c:83
double naco_pfits_get_r0mean(const cpl_propertylist *self)
find out the R0MEAN key
Definition: naco_pfits.c:353
cpl_error_code irplib_framelist_load_propertylist(irplib_framelist *self, int pos, int ind, const char *regexp, cpl_boolean invert)
Load the propertylist of the specified frame in the framelist.
irplib_framelist * irplib_framelist_cast(const cpl_frameset *frameset)
Create an irplib_framelist from a cpl_framelist.
irplib_framelist * irplib_framelist_new(void)
Create an empty framelist.
int irplib_framelist_get_size(const irplib_framelist *self)
Get the size of a framelist.
double naco_pfits_get_ecmean(const cpl_propertylist *self)
find out the ECMEAN key
Definition: naco_pfits.c:143
cpl_error_code irplib_framelist_erase(irplib_framelist *self, int pos)
Erase a frame from a framelist and delete it and its propertylist.
const char * naco_pfits_get_filter(const cpl_propertylist *self)
find out the filter
Definition: naco_pfits.c:167