GIRAFFE Pipeline Reference Manual

gilinedata.c
1 /* $Id$
2  *
3  * This file is part of the GIRAFFE Pipeline
4  * Copyright (C) 2002-2006 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 02110-1301 USA
19  */
20 
21 /*
22  * $Author$
23  * $Date$
24  * $Revision$
25  * $Name$
26  */
27 
28 #ifdef HAVE_CONFIG_H
29 # include <config.h>
30 #endif
31 
32 #include <string.h>
33 
34 #include <cxtypes.h>
35 #include <cxmemory.h>
36 #include <cxmessages.h>
37 #include <cxmap.h>
38 #include <cxstrutils.h>
39 
40 #include <cpl_error.h>
41 #include <cpl_image.h>
42 
43 #include "gialias.h"
44 #include "gierror.h"
45 #include "giutils.h"
46 #include "gilinedata.h"
47 
48 
49 
50 /*
51  * @defgroup gilinedata Line Data Storage
52  *
53  * TBD
54  */
55 
58 struct GiLineData {
59 
60  const cxchar* model;
61 
62  cxint nfibers;
63  cxint nlines;
64  cxint* ignore;
65 
66  cxdouble* wavelength;
67 
68  cpl_image* status;
69 
70  cx_map* values;
71 
72 };
73 
74 
75 inline static cxbool
76 _giraffe_linedata_compare(cxcptr s, cxcptr t)
77 {
78 
79  return strcmp(s, t) < 0 ? TRUE : FALSE;
80 
81 }
82 
83 
84 inline static cxptr
85 _giraffe_linedata_get_data(cx_map* map, const cxchar* name)
86 {
87 
88 
89  cpl_image* data = cx_map_get(map, name);
90 
91  if (data == NULL) {
92  return NULL;
93  }
94 
95  return cpl_image_get_data(data);
96 
97 }
98 
99 
100 inline static void
101 _giraffe_linedata_clear(GiLineData* self)
102 {
103 
104  self->nfibers = 0;
105  self->nlines = 0;
106 
107  if (self->model) {
108  cx_free((cxptr)self->model);
109  self->model = NULL;
110  }
111 
112  if (self->ignore) {
113  cx_free(self->ignore);
114  self->ignore = NULL;
115  }
116 
117  if (self->wavelength) {
118  cx_free(self->wavelength);
119  self->wavelength = NULL;
120  }
121 
122  if (self->status) {
123  cpl_image_delete(self->status);
124  self->status = NULL;
125  }
126 
127  if (self->values) {
128  cx_map_clear(self->values);
129  }
130 
131  cx_assert(cx_map_empty(self->values));
132 
133  return;
134 }
135 
136 
137 inline static cxint
138 _giraffe_linedata_assign(GiLineData* self, cx_map* map, const cxchar* name,
139  const cpl_image* values)
140 {
141 
142  cx_map_iterator position = cx_map_find(map, name);
143 
144 
145  if (cpl_image_get_size_x(values) != self->nfibers) {
146  return 1;
147  }
148 
149  if (cpl_image_get_size_y(values) != self->nlines) {
150  return 2;
151  }
152 
153  if (position == cx_map_end(map)) {
154  cx_map_insert(map, cx_strdup(name), values);
155  }
156  else {
157 
158  cpl_image* previous = cx_map_assign(map, position, values);
159 
160  if (previous != NULL) {
161  cpl_image_delete(previous);
162  previous = NULL;
163  }
164 
165  }
166 
167  return 0;
168 
169 }
170 
171 
172 inline static cxint
173 _giraffe_linedata_set(GiLineData* self, cx_map* map, const cxchar* name,
174  cxint i, cxint j, cxdouble value)
175 {
176 
177  cxdouble* data = NULL;
178 
179  cx_map_const_iterator position = cx_map_find(map, name);
180 
181 
182  if (position == cx_map_end(map)) {
183 
184  cpl_image* buffer = cpl_image_new(self->nfibers, self->nlines,
185  CPL_TYPE_DOUBLE);
186  cx_map_insert(map, cx_strdup(name), buffer);
187  data = cpl_image_get_data(buffer);
188 
189  }
190  else {
191 
192  data = cpl_image_get_data(cx_map_get_value(map, position));
193 
194  }
195 
196  data[self->nfibers * j + i] = value;
197 
198  return 0;
199 
200 }
201 
202 
203 inline static cxint
204 _giraffe_linedata_get(const GiLineData* self, const cx_map* map,
205  const cxchar* name, cxint i, cxint j, cxdouble* value)
206 {
207 
208  cxdouble* data = NULL;
209 
210  cx_map_const_iterator position = cx_map_find(map, name);
211 
212  if (position == cx_map_end(map)) {
213  return 1;
214  }
215 
216  data = cpl_image_get_data(cx_map_get_value(map, position));
217  *value = data[self->nfibers * j + i];
218 
219  return 0;
220 
221 }
222 
223 
224 GiLineData*
225 giraffe_linedata_new(void)
226 {
227 
228  GiLineData* self = cx_calloc(1, sizeof *self);
229 
230  self->nfibers = 0;
231  self->nlines = 0;
232 
233  self->model = NULL;
234  self->ignore = NULL;
235 
236  self->wavelength = NULL;
237  self->status = NULL;
238 
239  self->values = cx_map_new(_giraffe_linedata_compare, cx_free,
240  (cx_free_func)cpl_image_delete);
241  cx_assert(cx_map_empty(self->values));
242 
243  return self;
244 
245 }
246 
247 
248 GiLineData*
249 giraffe_linedata_create(const cpl_table* lines, const cpl_table* fibers,
250  const cxchar* model)
251 {
252  cxint i;
253 
254  GiLineData* self = NULL;
255 
256 
257  if (lines == NULL) {
258  return NULL;
259  }
260 
261  if (!cpl_table_has_column(lines, "WLEN")) {
262  return NULL;
263  }
264 
265  if (fibers == NULL) {
266  return NULL;
267  }
268 
269  if (model == NULL) {
270  return NULL;
271  }
272 
273  self = cx_malloc(sizeof(GiLineData));
274  cx_assert(self);
275 
276  self->nfibers = cpl_table_get_nrow(fibers);
277  self->nlines = cpl_table_get_nrow(lines);
278 
279  self->model = cx_strdup(model);
280  self->ignore = cx_calloc(self->nlines, sizeof(cxint));
281 
282  self->wavelength = cx_calloc(self->nlines, sizeof(cxdouble));
283 
284  for (i = 0; i < self->nlines; i++) {
285  self->wavelength[i] = cpl_table_get(lines, "WLEN", i, NULL);
286  }
287 
288  /* Lazy buffer creation! */
289  self->status = NULL;
290 
291  self->values = cx_map_new(_giraffe_linedata_compare, cx_free,
292  (cx_free_func)cpl_image_delete);
293  cx_assert(cx_map_empty(self->values));
294 
295  return self;
296 
297 }
298 
299 
300 void
301 giraffe_linedata_delete(GiLineData* self)
302 {
303 
304  if (self) {
305  _giraffe_linedata_clear(self);
306 
307  if (self->values != NULL) {
308  cx_map_delete(self->values);
309  }
310 
311  cx_free(self);
312  }
313 
314  return;
315 
316 }
317 
318 
319 cxint
320 giraffe_linedata_reset(GiLineData* self, const cpl_table* lines,
321  const cpl_table* fibers, const cxchar* model)
322 {
323 
324  cxint i;
325 
326 
327  cx_assert(self != NULL);
328 
329  if (lines == NULL) {
330  return 1;
331  }
332 
333  if (!cpl_table_has_column(lines, "WLEN")) {
334  return 1;
335  }
336 
337  if (fibers == NULL) {
338  return 1;
339  }
340 
341  if (model == NULL) {
342  return 1;
343  }
344 
345 
346  self->nfibers = cpl_table_get_nrow(fibers);
347  self->nlines = cpl_table_get_nrow(lines);
348 
349  if (self->model != NULL) {
350  cx_free((cxchar*)self->model);
351  }
352  self->model = cx_strdup(model);
353 
354  if (self->ignore != NULL) {
355  cx_free(self->ignore);
356  }
357  self->ignore = cx_calloc(self->nlines, sizeof(cxint));
358 
359  self->wavelength = cx_realloc(self->wavelength,
360  self->nlines * sizeof(cxdouble));
361 
362  for (i = 0; i < self->nlines; i++) {
363 
364  self->wavelength[i] = cpl_table_get(lines, "WLEN", i,
365  NULL);
366 
367  }
368 
369  if (self->status != NULL) {
370  cpl_image_delete(self->status);
371  self->status = NULL;
372  }
373 
374  if (!cx_map_empty(self->values)) {
375  cx_map_clear(self->values);
376  }
377 
378  return 0;
379 
380 }
381 
382 
383 const cxchar*
384 giraffe_linedata_model(const GiLineData* self)
385 {
386 
387  cx_assert(self != NULL);
388 
389  return self->model;
390 
391 }
392 
393 
394 cxsize
395 giraffe_linedata_lines(const GiLineData* self)
396 {
397 
398  cx_assert(self != NULL);
399 
400  return self->nlines;
401 
402 }
403 
404 
405 cxsize
406 giraffe_linedata_fibers(const GiLineData* self)
407 {
408 
409  cx_assert(self != NULL);
410 
411  return self->nfibers;
412 
413 }
414 
415 
416 cxbool
417 giraffe_linedata_contains(GiLineData* self, const cxchar* name)
418 {
419 
420  cx_map_const_iterator position;
421 
422 
423  cx_assert(self != NULL);
424 
425  if (name == NULL) {
426  return FALSE;
427  }
428 
429  position = cx_map_find(self->values, name);
430 
431  if (position == cx_map_end(self->values)) {
432  return FALSE;
433  }
434 
435  return TRUE;
436 
437 }
438 
439 
440 cxsize
441 giraffe_linedata_rejected(const GiLineData* self)
442 {
443 
444  cxint i;
445  cxint* status;
446 
447  cxsize count = 0;
448 
449 
450  cx_assert(self != NULL);
451 
452  if (self->status != NULL) {
453 
454  status = cpl_image_get_data(self->status);
455 
456  for (i = 0; i < self->nfibers * self->nlines; i++) {
457  if (status[i] > 0) {
458  ++count;
459  }
460  }
461 
462  }
463 
464  return count;
465 
466 }
467 
468 
469 cxsize
470 giraffe_linedata_accepted(const GiLineData* self)
471 {
472 
473  cxsize count = 0;
474 
475 
476  cx_assert(self != NULL);
477 
478  count = self->nfibers * self->nlines;
479 
480  return count - giraffe_linedata_rejected(self);
481 
482 }
483 
484 
485 cpl_image*
486 giraffe_linedata_status(const GiLineData* self)
487 {
488 
489  cx_assert(self != NULL);
490 
491  if (self->status == NULL) {
492  return cpl_image_new(self->nfibers, self->nlines, CPL_TYPE_INT);
493  }
494 
495  return cpl_image_duplicate(self->status);
496 
497 }
498 
499 
500 cxint
501 giraffe_linedata_set_status(GiLineData* self, cxint fiber, cxint line,
502  cxint status)
503 {
504 
505  cxint* data = NULL;
506 
507 
508  cx_assert(self != NULL);
509 
510  if (fiber >= self->nfibers) {
511  return 1;
512  }
513 
514  if (line >= self->nlines) {
515  return 1;
516  }
517 
518  if (self->status == NULL) {
519  self->status = cpl_image_new(self->nfibers, self->nlines,
520  CPL_TYPE_INT);
521  if (self->status == NULL) {
522  return -1;
523  }
524  }
525 
526  data = cpl_image_get_data(self->status);
527 
528  data[self->nfibers * line + fiber] = status;
529 
530  if (status != 0) {
531  self->ignore[line] += 1;
532  }
533 
534  return 0;
535 
536 }
537 
538 
539 cxint
540 giraffe_linedata_get_status(const GiLineData* self, cxint fiber, cxint line)
541 {
542 
543  cxint* data = NULL;
544 
545 
546  cx_assert(self != NULL);
547 
548  if (fiber >= self->nfibers) {
549  return 1;
550  }
551 
552  if (line >= self->nlines) {
553  return 1;
554  }
555 
556  if (self->status == NULL) {
557  return 0;
558  }
559 
560  data = cpl_image_get_data(self->status);
561 
562  return data[self->nfibers * line + fiber];
563 
564 }
565 
566 
567 cxint
568 giraffe_linedata_set_wavelength(GiLineData* self, cxint line, cxdouble lambda)
569 {
570 
571  cx_assert(self != NULL);
572 
573  if (line < 0 || line >= self->nlines) {
574  return 1;
575  }
576 
577  self->wavelength[line] = lambda;
578 
579  return 0;
580 
581 }
582 
583 
584 cxdouble
585 giraffe_linedata_get_wavelength(const GiLineData* self, cxint line)
586 {
587 
588  const cxchar* const fctid = "giraffe_linedata_get_wavelength";
589 
590 
591  cx_assert(self != NULL);
592 
593  if (line < 0 || line >= self->nlines) {
594  cpl_error_set(fctid, CPL_ERROR_ILLEGAL_INPUT);
595  return 0.;
596  }
597 
598  return self->wavelength[line];
599 
600 }
601 
602 
603 cxint
604 giraffe_linedata_set(GiLineData* self, const cxchar* name, cxint fiber,
605  cxint line, cxdouble value)
606 {
607 
608  cxint status = 0;
609 
610  cx_assert(self != NULL);
611 
612  if (name == NULL) {
613  return 1;
614  }
615 
616  if (fiber >= self->nfibers) {
617  return 1;
618  }
619 
620  if (line >= self->nlines) {
621  return 1;
622  }
623 
624  status = _giraffe_linedata_set(self, self->values, name, fiber, line,
625  value);
626 
627  if (status != 0) {
628  return 1;
629  }
630 
631  return 0;
632 
633 }
634 
635 
636 cxdouble
637 giraffe_linedata_get(const GiLineData* self, const cxchar* name, cxint fiber,
638  cxint line)
639 {
640 
641  const cxchar* const fctid = "giraffe_linedata_get";
642 
643  cxint status = 0;
644 
645  cxdouble value = 0.;
646 
647 
648  cx_assert(self != NULL);
649 
650  if (name == NULL) {
651  return 1;
652  }
653 
654  if (fiber >= self->nfibers) {
655  return 1;
656  }
657 
658  if (line >= self->nlines) {
659  return 1;
660  }
661 
662  status = _giraffe_linedata_get(self, self->values, name, fiber, line,
663  &value);
664 
665  if (status != 0) {
666  cpl_error_set(fctid, CPL_ERROR_DATA_NOT_FOUND);
667  return 0.;
668  }
669 
670  return value;
671 
672 }
673 
674 
675 cxint
676 giraffe_linedata_set_data(GiLineData* self, const cxchar* name,
677  const cpl_image* data)
678 {
679 
680  cxint status = 0;
681 
682 
683  cx_assert(self != NULL);
684 
685  if (name == NULL) {
686  return 1;
687  }
688 
689  if (data == NULL) {
690  return 1;
691  }
692 
693  status = _giraffe_linedata_assign(self, self->values, name, data);
694 
695  if (status != 0) {
696  return 1;
697  }
698 
699  return 0;
700 
701 }
702 
703 
704 const cpl_image*
705 giraffe_linedata_get_data(const GiLineData* self, const cxchar* name)
706 {
707 
708  cx_assert(self != NULL);
709 
710  if (name == NULL) {
711  return NULL;
712  }
713 
714  return cx_map_get(self->values, name);
715 
716 }
717 
718 
719 cxint
720 giraffe_linedata_load(GiLineData* self, const cxchar* filename)
721 {
722 
723  cxsize extension = 1;
724 
725  cpl_table* lines = NULL;
726 
727  cpl_propertylist* p = NULL;
728 
729 
730  if (self == NULL || filename == NULL) {
731  return -1;
732  }
733 
734  _giraffe_linedata_clear(self);
735 
736 
737  giraffe_error_push();
738 
739  p = cpl_propertylist_load(filename, 0);
740 
741  if (p == NULL) {
742  return 1;
743  }
744 
745  if (cpl_propertylist_has(p, GIALIAS_WSOL_LMNAME) == 0) {
746  return 1;
747  }
748  else {
749 
750  self->model = cx_strdup(cpl_propertylist_get_string(p,
751  GIALIAS_WSOL_LMNAME));
752 
753  }
754 
755  if (cpl_error_get_code() != CPL_ERROR_NONE) {
756 
757  if (p != NULL) {
758  cpl_propertylist_delete(p);
759  p = NULL;
760  }
761 
762  return 1;
763 
764  }
765 
766  giraffe_error_pop();
767 
768  cpl_propertylist_delete(p);
769  p = NULL;
770 
771 
772  /*
773  * Load line wavelength and line status flags
774  */
775 
776  lines = cpl_table_load(filename, extension, 0);
777 
778  if (lines == NULL) {
779  _giraffe_linedata_clear(self);
780  return 2;
781  }
782 
783  if (cpl_table_has_column(lines, "WLEN") == FALSE) {
784  _giraffe_linedata_clear(self);
785  return 2;
786  }
787  else {
788 
789  const cxdouble* lambda = cpl_table_get_data_double(lines, "WLEN");
790 
791  self->nlines = cpl_table_get_nrow(lines);
792 
793  self->ignore = cx_calloc(self->nlines, sizeof(cxint));
794  self->wavelength = cx_malloc(self->nlines * sizeof(cxdouble));
795 
796  memcpy(self->wavelength, lambda, self->nlines * sizeof(cxdouble));
797  }
798 
799  ++extension;
800 
801  self->status = cpl_image_load(filename, CPL_TYPE_INT, 0, extension);
802 
803  if (self->status == NULL) {
804  _giraffe_linedata_clear(self);
805  return 2;
806  }
807 
808  self->nfibers = cpl_image_get_size_x(self->status);
809 
810  ++extension;
811 
812 
813  /*
814  * Load the data buffers from the following extensions.
815  * The extension labels are used as names to as the names
816  * of the line parameters.
817  */
818 
819  p = cpl_propertylist_load(filename, extension);
820 
821  // FIXME: The condition extension < 22 is needed because of a problem
822  // in cpl_propertylist_load() of CPL 4.0. It must be removed if the
823  // patched version is available on Paranal/DFO machines.
824 
825  while ((p != NULL) && (extension < 22)) {
826 
827  const cxchar* name = cpl_propertylist_get_string(p, GIALIAS_EXTNAME);
828 
829  if (name == NULL) {
830  cpl_propertylist_delete(p);
831  p = NULL;
832 
833  _giraffe_linedata_clear(self);
834 
835  return 3;
836  }
837  else {
838 
839  cpl_image* buffer = cpl_image_load(filename, CPL_TYPE_DOUBLE,
840  0, extension);
841 
842  if ((cpl_image_get_size_x(buffer) != self->nfibers) ||
843  (cpl_image_get_size_y(buffer) != self->nlines)) {
844 
845  cpl_image_delete(buffer);
846  buffer = NULL;
847 
848  cpl_propertylist_delete(p);
849  p = NULL;
850 
851  _giraffe_linedata_clear(self);
852 
853  return 3;
854 
855  }
856 
857  cx_map_insert(self->values, cx_strdup(name), buffer);
858 
859  }
860 
861  ++extension;
862 
863  cpl_propertylist_delete(p);
864  p = cpl_propertylist_load(filename, extension);
865 
866  }
867 
868  cpl_propertylist_delete(p);
869  p = NULL;
870 
871  return 0;
872 
873 }
874 
875 
876 cxint
877 giraffe_linedata_save(GiLineData* self, const cpl_propertylist* properties,
878  const cxchar* filename)
879 {
880 
881  cxint status = 0;
882 
883  cpl_propertylist* p = NULL;
884 
885 
886  if (self == NULL || properties == NULL || filename == NULL) {
887  return -1;
888  }
889 
890  p = cpl_propertylist_duplicate(properties);
891 
892  status = giraffe_linedata_writer(self, p, filename, NULL);
893 
894  cpl_propertylist_delete(p);
895  p = NULL;
896 
897  return status;
898 
899 }
900 
901 
902 cxint
903 giraffe_linedata_writer(const GiLineData* self, cpl_propertylist* properties,
904  const cxchar* filename, cxcptr data)
905 {
906 
907  const cxchar* const fctid = "giraffe_linedata_writer";
908 
909  cx_map_const_iterator position;
910 
911  cpl_propertylist* p = NULL;
912 
913  cpl_table* lines = NULL;
914 
915 
916  /* Unused */
917  data = NULL;
918 
919  if (self == NULL || properties == NULL || filename == NULL) {
920  return -1;
921  }
922 
923  lines = cpl_table_new(self->nlines);
924 
925  if (lines == NULL) {
926  return 1;
927  }
928 
929  giraffe_error_push();
930 
931  cpl_table_new_column(lines, "WLEN", CPL_TYPE_DOUBLE);
932  cpl_table_copy_data_double(lines, "WLEN", self->wavelength);
933 
934  if (cpl_error_get_code() != CPL_ERROR_NONE) {
935  cpl_table_delete(lines);
936  lines = NULL;
937 
938  return 1;
939  }
940 
941  giraffe_error_pop();
942 
943 
944  /* FIXME: Workaround for CPL deficiency. World coordinate
945  * keywords are not removed from table headers.
946  */
947 
948  cpl_propertylist_erase_regexp(properties, "^CRPIX[0-9]$", 0);
949  cpl_propertylist_erase_regexp(properties, "^CRVAL[0-9]$", 0);
950  cpl_propertylist_erase_regexp(properties, "^CDELT[0-9]$", 0);
951  cpl_propertylist_erase_regexp(properties, "^CTYPE[0-9]$", 0);
952 
953 
954  cpl_propertylist_update_string(properties, GIALIAS_WSOL_LMNAME,
955  self->model);
956  cpl_propertylist_set_comment(properties, GIALIAS_WSOL_LMNAME,
957  "Line profile model");
958 
959  p = cpl_propertylist_new();
960  cpl_propertylist_append_string(p, GIALIAS_EXTNAME, "LINES");
961  cpl_propertylist_set_comment(p, GIALIAS_EXTNAME, "FITS Extension name");
962 
963  giraffe_error_push();
964 
965  cpl_table_save(lines, properties, p, filename, CPL_IO_CREATE);
966 
967  if (cpl_error_get_code() != CPL_ERROR_NONE) {
968 
969  cpl_propertylist_delete(p);
970  p = NULL;
971 
972  cpl_table_delete(lines);
973  lines = NULL;
974 
975  return 2;
976  }
977 
978  cpl_table_delete(lines);
979  lines = NULL;
980 
981  giraffe_error_pop();
982 
983  cpl_propertylist_set_string(p, GIALIAS_EXTNAME, "LINE_FLAGS");
984 
985  giraffe_error_push();
986 
987  if (self->status == NULL) {
988 
989  cpl_image* status = cpl_image_new(self->nfibers, self->nlines,
990  CPL_TYPE_INT);
991 
992  cpl_image_save(status, filename, CPL_BPP_16_SIGNED, p,
993  CPL_IO_EXTEND);
994  cpl_image_delete(status);
995  status = NULL;
996 
997  }
998  else {
999  cpl_image_save(self->status, filename, CPL_BPP_16_SIGNED, p,
1000  CPL_IO_EXTEND);
1001  }
1002 
1003  if (cpl_error_get_code() != CPL_ERROR_NONE) {
1004  cpl_propertylist_delete(p);
1005  p = NULL;
1006 
1007  return 2;
1008  }
1009 
1010  position = cx_map_begin(self->values);
1011  while (position != cx_map_end(self->values)) {
1012 
1013  cxint format = 0;
1014 
1015  const cpl_image* ldata = cx_map_get_value(self->values, position);
1016 
1017 
1018  switch (cpl_image_get_type(ldata)) {
1019  case CPL_TYPE_INT:
1020  format = CPL_BPP_32_SIGNED;
1021  break;
1022 
1023  case CPL_TYPE_FLOAT:
1024  format = CPL_BPP_IEEE_FLOAT;
1025  break;
1026 
1027  case CPL_TYPE_DOUBLE:
1028  format = CPL_BPP_IEEE_FLOAT;
1029  break;
1030 
1031  default:
1032  cpl_propertylist_delete(p);
1033  p = NULL;
1034 
1035  cpl_error_set(fctid, CPL_ERROR_TYPE_MISMATCH);
1036  return 2;
1037 
1038  break;
1039  }
1040 
1041  cpl_propertylist_set_string(p, GIALIAS_EXTNAME,
1042  cx_map_get_key(self->values, position));
1043 
1044  cpl_image_save(ldata, filename, format, p, CPL_IO_EXTEND);
1045 
1046  if (cpl_error_get_code() != CPL_ERROR_NONE) {
1047  cpl_propertylist_delete(p);
1048  p = NULL;
1049 
1050  return 2;
1051  }
1052 
1053  position = cx_map_next(self->values, position);
1054 
1055  }
1056 
1057  giraffe_error_pop();
1058 
1059  cpl_propertylist_delete(p);
1060  p = NULL;
1061 
1062  return 0;
1063 
1064 }

This file is part of the GIRAFFE Pipeline Reference Manual 2.12.
Documentation copyright © 2002-2006 European Southern Observatory.
Generated on Mon Mar 24 2014 11:43:52 by doxygen 1.8.2 written by Dimitri van Heesch, © 1997-2004