GIRAFFE Pipeline Reference Manual

gimasterdark.c
1 /*
2  * This file is part of the GIRAFFE Pipeline
3  * Copyright (C) 2002-2019 European Southern Observatory
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18  */
19 
20 #ifdef HAVE_CONFIG_H
21 # include <config.h>
22 #endif
23 
24 #include <math.h>
25 
26 #include <cxmessages.h>
27 #include <cxmemory.h>
28 #include <cxlist.h>
29 
30 #include <cpl_recipe.h>
31 #include <cpl_plugininfo.h>
32 #include <cpl_parameterlist.h>
33 #include <cpl_frameset.h>
34 #include <cpl_propertylist.h>
35 #include <cpl_vector.h>
36 #include <cpl_msg.h>
37 
38 #include "gialias.h"
39 #include "gierror.h"
40 #include "giframe.h"
41 #include "giimage.h"
42 #include "giwindow.h"
43 #include "gifibers.h"
44 #include "gibias.h"
45 #include "gimath.h"
46 #include "gistacking.h"
47 #include "giqclog.h"
48 #include "giutils.h"
49 
50 
51 static cxint gimasterdark(cpl_parameterlist*, cpl_frameset*);
52 static cxint giqcmasterdark(cpl_frameset*);
53 
54 
55 static cxint
56 _giraffe_clean_badpixels(GiImage* image, GiImage* bpixel)
57 {
58 
59  cxint i = 0;
60 
61  cxint nx_image = 0;
62  cxint ny_image = 0;
63  cxint ny_mask = 0;
64  cxint shift = 0;
65  cxint* _bpixel = NULL;
66 
67  cxdouble* _image = NULL;
68 
69  cpl_propertylist* properties = NULL;
70 
71 
72  cx_assert(image != NULL);
73  cx_assert(bpixel != NULL);
74 
75  nx_image = cpl_image_get_size_y(giraffe_image_get(image));
76  ny_image = cpl_image_get_size_x(giraffe_image_get(image));
77 
78  ny_mask = cpl_image_get_size_x(giraffe_image_get(bpixel));
79 
80  properties = giraffe_image_get_properties(bpixel);
81  shift = cpl_propertylist_get_int(properties, GIALIAS_PRSCX);
82 
83  _image = cpl_image_get_data_double(giraffe_image_get(image));
84  _bpixel = cpl_image_get_data_int(giraffe_image_get(bpixel));
85 
86  for (i = 0; i < nx_image; i++) {
87 
88  cxint j = 0;
89 
90  for (j = 0; j < ny_image; j++) {
91 
92  if (_bpixel[i * ny_mask + j + shift] != 0) {
93  _image[i * ny_image + j] = 0.;
94  }
95 
96  }
97 
98  }
99 
100  return 0;
101 
102 }
103 
104 
105 /*
106  * Create the recipe instance, i.e. setup the parameter list for this
107  * recipe and make it availble to the application using the interface.
108  */
109 
110 static cxint
111 gimasterdark_create(cpl_plugin* plugin)
112 {
113 
114  cpl_parameter* p = NULL;
115 
116  cpl_recipe* recipe = (cpl_recipe*)plugin;
117 
118 
119  giraffe_error_init();
120 
121 
122  /*
123  * We have to provide the option we accept to the application. We
124  * need to setup our parameter list and hook it into the recipe
125  * interface.
126  */
127 
128  recipe->parameters = cpl_parameterlist_new();
129  cx_assert(recipe->parameters != NULL);
130 
131  /*
132  * Fill the parameter list.
133  */
134 
135  /* Frame combination */
136 
137  giraffe_stacking_config_add(recipe->parameters);
138  p = cpl_parameterlist_find(recipe->parameters, "giraffe.stacking.method");
139 
140  if ( p != NULL) {
141  cpl_parameter_set_default_string(p, "median");
142  }
143 
144  /* Bias removal */
145 
146  giraffe_bias_config_add(recipe->parameters);
147 
148  return 0;
149 
150 }
151 
152 /*
153  * Execute the plugin instance given by the interface.
154  */
155 
156 static cxint
157 gimasterdark_exec(cpl_plugin* plugin)
158 {
159 
160  cpl_recipe* recipe = (cpl_recipe*)plugin;
161 
162  cxint status = 0;
163 
164 
165  if (recipe->parameters == NULL || recipe->frames == NULL) {
166  return 1;
167  }
168 
169  status = gimasterdark(recipe->parameters, recipe->frames);
170 
171  if (status != 0) {
172  return 1;
173  }
174 
175  status = giqcmasterdark(recipe->frames);
176 
177  if (status != 0) {
178  return 1;
179  }
180 
181  return 0;
182 
183 }
184 
185 
186 static cxint
187 gimasterdark_destroy(cpl_plugin* plugin)
188 {
189 
190  cpl_recipe* recipe = (cpl_recipe*)plugin;
191 
192 
193  /*
194  * We just destroy what was created during the plugin initialization
195  * phase, i.e. the parameter list. The frame set is managed by the
196  * application which called us, so we must not touch it,
197  */
198 
199  cpl_parameterlist_delete(recipe->parameters);
200 
201  giraffe_error_clear();
202 
203  return 0;
204 
205 }
206 
207 
208 /*
209  * The actual recipe starts here.
210  */
211 
212 static cxint
213 gimasterdark(cpl_parameterlist* config, cpl_frameset* set)
214 {
215 
216  const cxchar* const _id = "gimasterdark";
217 
218  cxint i = 0;
219  cxint status = 0;
220  cxint count = 0;
221 
222  cxdouble exptotal = 0.;
223 
224  cx_list* darks = NULL;
225 
226  cx_list_const_iterator position = NULL;
227 
228  cpl_matrix* bias_areas = NULL;
229 
230  cpl_frame* dark_frame = NULL;
231  cpl_frame* mbias_frame = NULL;
232  cpl_frame* bpixel_frame = NULL;
233  cpl_frame* mdark_frame = NULL;
234 
235  cpl_image* _dark = NULL;
236 
237  cpl_propertylist* properties = NULL;
238 
239 
240  GiImage* result = NULL;
241  GiImage* mbias = NULL;
242  GiImage* bpixel = NULL;
243  GiImage** stack = NULL;
244 
245  GiBiasConfig* bias_config = NULL;
246 
247  GiStackingConfig* stack_config = NULL;
248 
249  GiRecipeInfo info = {(cxchar*)_id, 1, NULL, config};
250 
251  GiGroupInfo groups[] = {
252  {GIFRAME_DARK, CPL_FRAME_GROUP_RAW},
253  {GIFRAME_BIAS_MASTER, CPL_FRAME_GROUP_CALIB},
254  {GIFRAME_BADPIXEL_MAP, CPL_FRAME_GROUP_CALIB},
255  {NULL, CPL_FRAME_GROUP_NONE}
256  };
257 
258 
259 
260  /*
261  * Set frame group information
262  */
263 
264  status = giraffe_frameset_set_groups(set, groups);
265 
266  if (status != 0) {
267  cpl_msg_error(_id, "Setting frame group information failed!");
268  return 1;
269  }
270 
271 
272  /*
273  * Count the number of available raw frames
274  */
275 
276  count = cpl_frameset_count_tags(set, GIFRAME_DARK);
277 
278  if (count == 0) {
279  cpl_msg_error(_id, "No raw dark frames found in frameset! "
280  "Aborting ...");
281  return 1;
282  }
283 
284 
285  /*
286  * Verify frameset contents
287  */
288 
289  mbias_frame = cpl_frameset_find(set, GIFRAME_BIAS_MASTER);
290 
291  if (!mbias_frame) {
292  cpl_msg_error(_id, "No master bias present in frame set. "
293  "Aborting ...");
294  return 1;
295  }
296 
297  bpixel_frame = cpl_frameset_find(set, GIFRAME_BADPIXEL_MAP);
298 
299  if (!bpixel_frame) {
300  cpl_msg_info(_id, "No bad pixel map present in frame set.");
301  }
302 
303 
304  /*
305  * Load the raw data frames
306  */
307 
308  cpl_msg_info(_id, "Loading dark frames ...");
309 
310  darks = cx_list_new();
311  dark_frame = cpl_frameset_find(set, GIFRAME_DARK);
312 
313  i = 0;
314 
315  while ((dark_frame != NULL ) && (i < count)) {
316 
317  const cxchar* const filename = cpl_frame_get_filename(dark_frame);
318 
319  GiImage* dark = giraffe_image_new(CPL_TYPE_DOUBLE);
320 
321 
322  status = giraffe_image_load(dark, filename, 0);
323 
324  if (status != 0) {
325  cpl_msg_error(_id, "Cannot load dark from '%s'. Aborting ...",
326  filename);
327 
328  cx_list_destroy(darks, (cx_free_func)giraffe_image_delete);
329  darks = NULL;
330 
331  return 1;
332  }
333 
334  cx_list_push_back(darks, dark);
335 
336  dark_frame = cpl_frameset_find(set, NULL);
337  ++i;
338 
339  }
340 
341  cx_assert(i == count);
342 
343 
344  /*
345  * Prepare for bias subtraction
346  */
347 
348  bias_config = giraffe_bias_config_create(config);
349 
350  /*
351  * Setup user defined areas to use for the bias computation
352  */
353 
354  if (bias_config->method == GIBIAS_METHOD_MASTER ||
355  bias_config->method == GIBIAS_METHOD_ZMASTER) {
356 
357  if (mbias_frame == NULL) {
358  cpl_msg_error(_id, "Missing master bias frame! Selected bias "
359  "removal method requires a master bias frame!");
360 
361  giraffe_bias_config_destroy(bias_config);
362  bias_config = NULL;
363 
364  cx_list_destroy(darks, (cx_free_func)giraffe_image_delete);
365  darks = NULL;
366 
367  return 1;
368  }
369  else {
370 
371  const cxchar* filename = cpl_frame_get_filename(mbias_frame);
372 
373 
374  mbias = giraffe_image_new(CPL_TYPE_DOUBLE);
375  status = giraffe_image_load(mbias, filename, 0);
376 
377  if (status != 0) {
378  cpl_msg_error(_id, "Cannot load master bias from '%s'. "
379  "Aborting ...", filename);
380 
381  giraffe_image_delete(mbias);
382  mbias = NULL;
383 
384  giraffe_bias_config_destroy(bias_config);
385  bias_config = NULL;
386 
387  cx_list_destroy(darks, (cx_free_func)giraffe_image_delete);
388  darks = NULL;
389 
390  return 1;
391  }
392 
393  }
394  }
395 
396 
397  /*
398  * Load bad pixel map if it is present in the frame set.
399  */
400 
401  if (bpixel_frame) {
402 
403  const cxchar* filename = cpl_frame_get_filename(bpixel_frame);
404 
405 
406  bpixel = giraffe_image_new(CPL_TYPE_INT);
407  status = giraffe_image_load(bpixel, filename, 0);
408 
409  if (status != 0) {
410  cpl_msg_error(_id, "Cannot load bad pixel map from '%s'. "
411  "Aborting ...", filename);
412 
413  if (mbias != NULL) {
414  giraffe_image_delete(mbias);
415  mbias = NULL;
416  }
417 
418  giraffe_bias_config_destroy(bias_config);
419  bias_config = NULL;
420 
421  cx_list_destroy(darks, (cx_free_func)giraffe_image_delete);
422  darks = NULL;
423 
424  return 1;
425  }
426 
427  }
428 
429 
430  /*
431  * Subtract the bias from each dark.
432  */
433 
434  for (i = 0; i < count; i++) {
435 
436  GiImage* dark = cx_list_pop_front(darks);
437  GiImage* rdark = giraffe_image_new(CPL_TYPE_DOUBLE);
438 
439 
440  status = giraffe_bias_remove(rdark, dark, mbias, bpixel, bias_areas,
441  bias_config);
442 
443  if (status != 0) {
444 
445  cx_list_push_front(darks, dark);
446 
447  giraffe_image_delete(rdark);
448  rdark = NULL;
449 
450  if (mbias != NULL) {
451  giraffe_image_delete(mbias);
452  mbias = NULL;
453  }
454 
455  giraffe_bias_config_destroy(bias_config);
456  bias_config = NULL;
457 
458  cx_list_destroy(darks, (cx_free_func)giraffe_image_delete);
459  darks = NULL;
460 
461  return 1;
462 
463  }
464 
465  giraffe_image_delete(dark);
466  dark = NULL;
467 
468  cx_list_push_back(darks, rdark);
469 
470  }
471 
472  if (mbias != NULL) {
473  giraffe_image_delete(mbias);
474  mbias = NULL;
475  }
476 
477  giraffe_bias_config_destroy(bias_config);
478  bias_config = NULL;
479 
480 
481  /*
482  * Scale each bias subtracted dark to 1 second exposure time.
483  * Compute total exposure time.
484  */
485 
486  position = cx_list_begin(darks);
487 
488  while (position != cx_list_end(darks)) {
489 
490  cxdouble exptime = 0.;
491 
492  GiImage* dark = cx_list_get(darks, position);
493 
494  properties = giraffe_image_get_properties(dark);
495  exptime = cpl_propertylist_get_double(properties, GIALIAS_EXPTIME);
496 
497  cpl_image_divide_scalar(giraffe_image_get(dark), exptime);
498  exptotal += exptime;
499 
500  cpl_propertylist_update_double(properties, GIALIAS_EXPTIME, 1.);
501 
502  position = cx_list_next(darks, position);
503 
504  }
505 
506 
507  /*
508  * Check that enough raw frames are present in the frameset
509  * for the selected frame combination method.
510  */
511 
512  stack_config = giraffe_stacking_config_create(config);
513 
514  count = cx_list_size(darks);
515 
516  if (count < stack_config->min_nr_frames) {
517 
518  cpl_msg_error(_id, "Not enough frames (%d). Stacking method '%d' "
519  "requires at least %d frames! Aborting...", count,
520  stack_config->stackmethod, stack_config->min_nr_frames);
521 
522  giraffe_stacking_config_destroy(stack_config);
523  stack_config = NULL;
524 
525  return 1;
526 
527  }
528 
529 
530  /*
531  * Combine the raw dark frames
532  */
533 
534  cpl_msg_info(_id, "Combining %d of %d dark frames.", i, count);
535 
536  stack = cx_calloc(count + 1, sizeof(GiImage*));
537 
538  i = 0;
539  position = cx_list_begin(darks);
540 
541  while (position != cx_list_end(darks)) {
542  stack[i] = cx_list_get(darks, position);
543  position = cx_list_next(darks, position);
544  ++i;
545  }
546 
547  result = giraffe_stacking_stack_images(stack, stack_config);
548 
549  if (result == NULL) {
550 
551  cpl_msg_error(_id, "Frame combination failed! Aborting ...");
552 
553  cx_free(stack);
554  stack = NULL;
555 
556  cx_list_destroy(darks, (cx_free_func)giraffe_image_delete);
557  darks = NULL;
558 
559  giraffe_stacking_config_destroy(stack_config);
560  stack_config = NULL;
561 
562  return 1;
563 
564  }
565 
566  properties = giraffe_image_get_properties(stack[0]);
567  giraffe_image_set_properties(result, properties);
568 
569  cx_free(stack);
570  stack = NULL;
571 
572  giraffe_stacking_config_destroy(stack_config);
573  stack_config = NULL;
574 
575  cx_list_destroy(darks, (cx_free_func)giraffe_image_delete);
576  darks = NULL;
577 
578 
579  /*
580  * Clean the bad pixels if a bad pixel map is present. The flux of
581  * bad pixels is simply set to 0.
582  */
583 
584  if (bpixel) {
585 
586  status = _giraffe_clean_badpixels(result, bpixel);
587 
588  if (status != 0) {
589 
590  cpl_msg_error(_id, "Bad pixel cleaning on master dark frame "
591  "failed!");
592 
593  giraffe_image_delete(result);
594  result = NULL;
595 
596  giraffe_image_delete(bpixel);
597  bpixel = NULL;
598 
599  return 1;
600 
601  }
602 
603  }
604 
605  giraffe_image_delete(bpixel);
606  bpixel = NULL;
607 
608 
609  /*
610  * Update master dark properties.
611  */
612 
613  cpl_msg_info(_id, "Writing master dark image ...");
614 
615  properties = giraffe_image_get_properties(result);
616  cx_assert(properties != NULL);
617 
618  cpl_propertylist_update_double(properties, GIALIAS_CRPIX1, 1.);
619 
620  cpl_propertylist_update_double(properties, GIALIAS_EXPTTOT, exptotal);
621  cpl_propertylist_update_int(properties, GIALIAS_DATANCOM, count);
622 
623  _dark = giraffe_image_get(result);
624 
625  cpl_propertylist_update_double(properties, GIALIAS_DARKVALUE,
626  cpl_image_get_mean(_dark));
627  cpl_propertylist_set_comment(properties, GIALIAS_DARKVALUE,
628  "Dark current in ADU/s");
629 
630  cpl_propertylist_erase(properties, GIALIAS_TPLEXPNO);
631 
632 
633  giraffe_image_add_info(result, &info, set);
634 
635  mdark_frame = giraffe_frame_create_image(result,
636  GIFRAME_DARK_MASTER,
637  CPL_FRAME_LEVEL_FINAL,
638  TRUE, TRUE);
639 
640  if (mdark_frame == NULL) {
641 
642  cpl_msg_error(_id, "Cannot create local file! Aborting ...");
643 
644  if (result != NULL) {
645  giraffe_image_delete(result);
646  }
647 
648  return 1;
649 
650  }
651 
652  cpl_frameset_insert(set, mdark_frame);
653 
654 
655  if (result != NULL) {
656  giraffe_image_delete(result);
657  }
658 
659  return 0;
660 
661 }
662 
663 
664 /*
665  * The quality control task starts here.
666  */
667 
668 static cxint
669 giqcmasterdark(cpl_frameset* set)
670 {
671 
672  const cxchar* const fctid = "giqcmasterdark";
673 
674  cxint status = 0;
675 
676  cxdouble mean = 0.;
677  cxdouble exptime = 1.;
678  cxdouble gflux = 0.;
679 
680  cpl_size gpx = 0;
681  cpl_size gpy = 0;
682 
683  cpl_propertylist* properties = NULL;
684  cpl_propertylist* qclog = NULL;
685 
686 
687  cpl_image* _mdark = NULL;
688 
689  cpl_frame* rframe = NULL;
690  cpl_frame* pframe = NULL;
691 
692  GiPaf* qc = NULL;
693 
694  GiImage* mdark = NULL;
695  GiImage* dark = NULL;
696 
697  GiWindow w = {10, 200, 2038, 3000};
698 
699 
700  cpl_msg_info(fctid, "Computing QC1 parameters ...");
701 
702  qc = giraffe_qclog_open(0);
703 
704  if (qc == NULL) {
705  cpl_msg_error(fctid, "Cannot create QC1 log!");
706  return 1;
707  }
708 
709  qclog = giraffe_paf_get_properties(qc);
710  cx_assert(qclog != NULL);
711 
712 
713  /*
714  * Process master dark
715  */
716 
717  pframe = giraffe_get_frame(set, GIFRAME_DARK_MASTER,
718  CPL_FRAME_GROUP_PRODUCT);
719 
720  if (pframe == NULL) {
721  cpl_msg_error(fctid, "Missing product frame (%s)",
722  GIFRAME_DARK_MASTER);
723 
724  giraffe_paf_delete(qc);
725  qc = NULL;
726 
727  return 1;
728  }
729 
730  cpl_msg_info(fctid, "Processing product frame '%s' (%s)",
731  cpl_frame_get_filename(pframe), cpl_frame_get_tag(pframe));
732 
733  mdark = giraffe_image_new(CPL_TYPE_DOUBLE);
734  status = giraffe_image_load(mdark, cpl_frame_get_filename(pframe), 0);
735 
736  if (status != 0) {
737  cpl_msg_error(fctid, "Could not load master dark '%s'! Aborting ...",
738  cpl_frame_get_filename(pframe));
739 
740  giraffe_image_delete(mdark);
741  mdark = NULL;
742 
743  giraffe_paf_delete(qc);
744  qc = NULL;
745 
746  return 1;
747  }
748 
749 
750  /*
751  * Load first raw image as reference
752  */
753 
754  rframe = cpl_frameset_find(set, GIFRAME_DARK);
755 
756  if (rframe == NULL) {
757  cpl_msg_error(fctid, "Missing raw frame (%s)", GIFRAME_DARK);
758 
759  giraffe_image_delete(mdark);
760  mdark = NULL;
761 
762  giraffe_paf_delete(qc);
763  qc = NULL;
764 
765  return 1;
766  }
767 
768  dark = giraffe_image_new(CPL_TYPE_DOUBLE);
769  status = giraffe_image_load(dark, cpl_frame_get_filename(rframe), 0);
770 
771  if (status != 0) {
772  cpl_msg_error(fctid, "Could not load dark '%s'!",
773  cpl_frame_get_filename(rframe));
774 
775  giraffe_image_delete(dark);
776  dark = NULL;
777 
778  giraffe_image_delete(mdark);
779  mdark = NULL;
780 
781  giraffe_paf_delete(qc);
782  qc = NULL;
783 
784  return 1;
785 
786  }
787 
788  properties = giraffe_image_get_properties(dark);
789  cx_assert(properties != NULL);
790 
791  giraffe_propertylist_copy(qclog, "ARCFILE", properties, GIALIAS_ARCFILE);
792  giraffe_propertylist_copy(qclog, "TPL.ID", properties, GIALIAS_TPLID);
793 
794  cpl_propertylist_update_string(qclog, "PRO.CATG",
795  cpl_frame_get_tag(pframe));
796  cpl_propertylist_set_comment(qclog, "PRO.CATG",
797  "Pipeline product category");
798 
799  properties = giraffe_image_get_properties(mdark);
800  cx_assert(properties != NULL);
801 
802  giraffe_propertylist_copy(qclog, "PRO.DATAAVG", properties,
803  GIALIAS_DATAMEAN);
804  giraffe_propertylist_copy(qclog, "PRO.DATARMS", properties,
805  GIALIAS_DATASIG);
806  giraffe_propertylist_copy(qclog, "PRO.DATAMED", properties,
807  GIALIAS_DATAMEDI);
808  giraffe_propertylist_copy(qclog, "PRO.DATANCOM", properties,
809  GIALIAS_DATANCOM);
810 
811 
812  /*
813  * Get 1 over exposure time in hours from the master dark frame
814  */
815 
816  if (cpl_propertylist_has(properties, GIALIAS_EXPTIME) == TRUE) {
817 
818  exptime = cpl_propertylist_get_double(properties, GIALIAS_EXPTIME);
819 
820  }
821 
822  exptime = 3600. / exptime;
823 
824 
825  /*
826  * Compute average dark value on a central window of the
827  * master dark frame. The window is used to exclude the
828  * glow feature in the upper part of the CCD.
829  */
830 
831  _mdark = giraffe_image_get(mdark);
832 
833  mean = cpl_image_get_mean_window(_mdark, w.x0, w.y0, w.x1, w.y1);
834 
835 
836  cpl_propertylist_update_double(properties, GIALIAS_QCMDARKAVG,
837  mean * exptime);
838  cpl_propertylist_set_comment(properties, GIALIAS_QCMDARKAVG,
839  "Mean master dark current (ADU/hr)");
840 
841  giraffe_propertylist_copy(qclog, "QC.DARK.CURRENT", properties,
842  GIALIAS_QCMDARKAVG);
843 
844  /*
845  * Monitoring the glow in the upper right part of the CCD
846  */
847 
848  w.x0 = 1350;
849  w.x1 = 2048;
850  w.y0 = 3800;
851  w.y1 = 4095;
852 
853  gflux = cpl_image_get_flux_window(_mdark, w.x0, w.y0, w.x1, w.y1);
854 
855  cpl_image_get_maxpos_window(_mdark, w.x0, w.y0, w.x1, w.y1, &gpx, &gpy);
856 
857 
858  cpl_propertylist_update_double(properties, GIALIAS_QCGLOWFLX, gflux);
859  cpl_propertylist_set_comment(properties, GIALIAS_QCGLOWFLX,
860  "Total flux of glow feature (ADU/s)");
861 
862  cpl_propertylist_update_int(properties, GIALIAS_QCGLOWX, (cxint)gpx);
863  cpl_propertylist_set_comment(properties, GIALIAS_QCGLOWX,
864  "X position of glow feature (pxl)");
865 
866  cpl_propertylist_update_int(properties, GIALIAS_QCGLOWY, (cxint)gpy);
867  cpl_propertylist_set_comment(properties, GIALIAS_QCGLOWY,
868  "X position of glow feature (pxl)");
869 
870  giraffe_propertylist_copy(qclog, "QC.GLOW.LEVEL", properties,
871  GIALIAS_QCGLOWFLX);
872  giraffe_propertylist_copy(qclog, "QC.GLOW.POSX", properties,
873  GIALIAS_QCGLOWX);
874  giraffe_propertylist_copy(qclog, "QC.GLOW.POSY", properties,
875  GIALIAS_QCGLOWY);
876 
877  /*
878  * Write QC1 log and save updated master dark.
879  */
880 
881  giraffe_image_save(mdark, cpl_frame_get_filename(pframe));
882 
883  giraffe_image_delete(mdark);
884  mdark = NULL;
885 
886  giraffe_qclog_close(qc);
887  qc = NULL;
888 
889  return 0;
890 
891 }
892 
893 
894 /*
895  * Build table of contents, i.e. the list of available plugins, for
896  * this module. This function is exported.
897  */
898 
899 int
900 cpl_plugin_get_info(cpl_pluginlist* list)
901 {
902 
903  cpl_recipe* recipe = cx_calloc(1, sizeof *recipe);
904  cpl_plugin* plugin = &recipe->interface;
905 
906 
907  cpl_plugin_init(plugin,
908  CPL_PLUGIN_API,
909  GIRAFFE_BINARY_VERSION,
910  CPL_PLUGIN_TYPE_RECIPE,
911  "gimasterdark",
912  "Creates a master dark image from a set of raw dark "
913  "frames.",
914  "For detailed information please refer to the "
915  "GIRAFFE pipeline user manual.\nIt is available at "
916  "http://www.eso.org/pipelines.",
917  "Giraffe Pipeline",
918  PACKAGE_BUGREPORT,
920  gimasterdark_create,
921  gimasterdark_exec,
922  gimasterdark_destroy);
923 
924  cpl_pluginlist_append(list, plugin);
925 
926  return 0;
927 
928 }
GiBiasConfig * giraffe_bias_config_create(cpl_parameterlist *list)
Creates a setup structure for a bias removal task.
Definition: gibias.c:3438
void giraffe_bias_config_add(cpl_parameterlist *list)
Adds parameters for the bias removal.
Definition: gibias.c:3597
cxint giraffe_bias_remove(GiImage *result, const GiImage *raw, const GiImage *master_bias, const GiImage *bad_pixels, const cpl_matrix *biaslimits, const GiBiasConfig *config)
Removes the bias from an image.
Definition: gibias.c:3106
void giraffe_bias_config_destroy(GiBiasConfig *config)
Destroys a bias removal setup structure.
Definition: gibias.c:3569
cpl_frame * giraffe_frame_create_image(GiImage *image, const cxchar *tag, cpl_frame_level level, cxbool save, cxbool update)
Create an image product frame.
Definition: giframe.c:393
cpl_frame * giraffe_get_frame(const cpl_frameset *set, const cxchar *tag, cpl_frame_group group)
Get a frame from a frame set.
Definition: giframe.c:728
void giraffe_image_delete(GiImage *self)
Destroys an image.
Definition: giimage.c:181
cpl_propertylist * giraffe_image_get_properties(const GiImage *self)
Get the properties of an image.
Definition: giimage.c:282
cxint giraffe_image_add_info(GiImage *image, const GiRecipeInfo *info, const cpl_frameset *set)
Add additional frame information to an image.
Definition: giimage.c:773
cxint giraffe_image_save(GiImage *self, const cxchar *filename)
Write a Giraffe image to a file.
Definition: giimage.c:570
cpl_image * giraffe_image_get(const GiImage *self)
Gets the image data.
Definition: giimage.c:218
GiImage * giraffe_image_new(cpl_type type)
Creates an empty image container.
Definition: giimage.c:65
cxint giraffe_image_set_properties(GiImage *self, cpl_propertylist *properties)
Attaches a property list to an image.
Definition: giimage.c:312
cxint giraffe_image_load(GiImage *self, const cxchar *filename, cxint position)
Gets image data and properties from a file.
Definition: giimage.c:536
void giraffe_stacking_config_add(cpl_parameterlist *list)
Adds parameters for the stacking of images.
Definition: gistacking.c:812
void giraffe_stacking_config_destroy(GiStackingConfig *config)
Destroys a setup structure for the stacking of images.
Definition: gistacking.c:789
GiStackingConfig * giraffe_stacking_config_create(cpl_parameterlist *list)
Creates a setup structure for the stacking of images.
Definition: gistacking.c:673
GiImage * giraffe_stacking_stack_images(GiImage **img_array, const GiStackingConfig *config)
Stack a list of images using one of four different kinds of stacking and return the resulting image.
Definition: gistacking.c:571
cxint giraffe_propertylist_copy(cpl_propertylist *self, const cxchar *name, const cpl_propertylist *other, const cxchar *othername)
Copy a property from one list to another.
Definition: giutils.c:1104
const cxchar * giraffe_get_license(void)
Get the pipeline copyright and license.
Definition: giutils.c:418

This file is part of the GIRAFFE Pipeline Reference Manual 2.16.10.
Documentation copyright © 2002-2006 European Southern Observatory.
Generated on Thu Dec 15 2022 21:18:51 by doxygen 1.9.1 written by Dimitri van Heesch, © 1997-2004