ERIS Pipeline Reference Manual 1.8.10
eris_nix_casu_utils.c
1/* $Id$
2 *
3 * This file is part of the ERIS/NIX Pipeline
4 * Copyright (C) 2017 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 * $Rev$
25 */
26
27#ifdef HAVE_CONFIG_H
28#include <config.h>
29#endif
30
31/*-----------------------------------------------------------------------------
32 Includes
33 -----------------------------------------------------------------------------*/
34
35#include <cpl.h>
36#include <libgen.h>
37#include <math.h>
38#include <string.h>
39#include "eris_nix_casu_utils.h"
40#include <hdrl.h>
41
42/*----------------------------------------------------------------------------*/
46/*----------------------------------------------------------------------------*/
47
50/*----------------------------------------------------------------------------*/
59/*----------------------------------------------------------------------------*/
60
61cpl_error_code encu_limlist_to_casu_fits(located_imagelist * limlist,
62 casu_fits *** indata,
63 casu_fits *** inconf,
64 casu_fits *** invar) {
65
66 if (cpl_error_get_code() != CPL_ERROR_NONE) return cpl_error_get_code();
67 if (!limlist) return CPL_ERROR_NONE;
68
69 cpl_size nimages = limlist->size;
70 *indata = cpl_malloc(nimages * sizeof(casu_fits *));
71 *inconf = cpl_malloc(nimages * sizeof(casu_fits *));
72 *invar = cpl_malloc(nimages * sizeof(casu_fits *));
73
74 for (int i = 0; i < (int)nimages; i++) {
75 enu_check(limlist->limages[i]->himage != NULL,
76 CPL_ERROR_NULL_INPUT,
77 "located image has no himage");
78 (*indata)[i] = casu_fits_wrap(cpl_image_cast(hdrl_image_get_image(
79 limlist->limages[i]->himage),
80 CPL_TYPE_FLOAT), NULL,
81 limlist->limages[i]->plist,
82 limlist->limages[i]->plist);
83 (*indata)[i]->fname = cpl_strdup(cpl_frame_get_filename(
84 limlist->limages[i]->frame));
85 (*indata)[i]->nexten = 1;
86 enu_check(limlist->limages[i]->confidence != NULL,
87 CPL_ERROR_NULL_INPUT,
88 "located image has no confidence array");
89 (*inconf)[i] = casu_fits_wrap(cpl_image_cast(
90 limlist->limages[i]->confidence,
91 CPL_TYPE_FLOAT), NULL,
92 limlist->limages[i]->plist, NULL);
93 (*inconf)[i]->fname = cpl_strdup(cpl_frame_get_filename(
94 limlist->limages[i]->frame));
95 (*inconf)[i]->nexten = 4;
96 (*invar)[i] = casu_fits_wrap(cpl_image_cast(hdrl_image_get_error(
97 limlist->limages[i]->himage),
98 CPL_TYPE_FLOAT), NULL,
99 limlist->limages[i]->plist,
100 limlist->limages[i]->plist);
101 (*invar)[i]->fname = cpl_strdup(cpl_frame_get_filename(
102 limlist->limages[i]->frame));
103 (*invar)[i]->nexten = 2;
104 }
105
106 cleanup:
107
108 /* memory cleanup tbd */
109
110 return cpl_error_get_code();;
111}
112
cpl_error_code encu_limlist_to_casu_fits(located_imagelist *limlist, casu_fits ***indata, casu_fits ***inconf, casu_fits ***invar)
Translate a located_imagelist to arrays of casu_fits structs.
cpl_image * hdrl_image_get_error(hdrl_image *himg)
get error as cpl image
Definition: hdrl_image.c:131
cpl_image * hdrl_image_get_image(hdrl_image *himg)
get data as cpl image
Definition: hdrl_image.c:105