ERIS Pipeline Reference Manual 1.8.15
eris_nix_master_wave.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 <string.h>
37
38#include "eris_nix_master_wave.h"
39#include "eris_nix_utils.h"
40
41/*----------------------------------------------------------------------------*/
45/*----------------------------------------------------------------------------*/
46
49/*----------------------------------------------------------------------------*/
60/*----------------------------------------------------------------------------*/
61
63 const hdrl_image * raw_wave_image,
64 const cpl_mask * raw_wave_bpm,
65 const cpl_image * raw_wave_confidence,
66 const hdrl_image * calibrated_wave_image,
67 const cpl_mask * calibrated_wave_bpm,
68 const cpl_image * calibrated_wave_confidence,
69 const char * filename,
70 const cpl_propertylist * plist) {
71
72 if (cpl_error_get_code() != CPL_ERROR_NONE) return NULL;
73
74 /* check for NULL inputs */
75
76 cpl_ensure(raw_wave_image, CPL_ERROR_NULL_INPUT, NULL);
77 cpl_ensure(raw_wave_bpm, CPL_ERROR_NULL_INPUT, NULL);
78 cpl_ensure(raw_wave_confidence, CPL_ERROR_NULL_INPUT, NULL);
79
80 master_wave * result = cpl_malloc(sizeof(master_wave));
81
82 result->raw_wave_image = hdrl_image_duplicate(raw_wave_image);
83 result->raw_wave_bpm = cpl_mask_duplicate(raw_wave_bpm);
84 result->raw_wave_confidence = cpl_image_duplicate(raw_wave_confidence);
85 if (calibrated_wave_image) {
86 result->calibrated_wave_image = hdrl_image_duplicate(
87 calibrated_wave_image);
88 }
89 if (calibrated_wave_bpm) {
90 result->calibrated_wave_bpm = cpl_mask_duplicate(calibrated_wave_bpm);
91 }
92 if (calibrated_wave_confidence) {
93 result->calibrated_wave_confidence = cpl_image_duplicate(
94 calibrated_wave_confidence);
95 }
96 if (filename) {
97 result->filename = cpl_strdup(filename);
98 } else {
99 result->filename = NULL;
100 }
101 if (plist) {
102 result->plist = cpl_propertylist_duplicate(plist);
103 } else {
104 result->plist = NULL;
105 }
106
107 return result;
108}
109
114/*----------------------------------------------------------------------------*/
122/*----------------------------------------------------------------------------*/
123
124void en_master_wave_delete(master_wave * target) {
125
126 if (target) {
127 cpl_free(target->filename);
128 hdrl_image_delete(target->raw_wave_image);
129 cpl_mask_delete(target->raw_wave_bpm);
130 cpl_image_delete(target->raw_wave_confidence);
131 hdrl_image_delete(target->calibrated_wave_image);
132 cpl_mask_delete(target->calibrated_wave_bpm);
133 cpl_image_delete(target->calibrated_wave_confidence);
134 cpl_propertylist_delete(target->plist);
135 cpl_free(target);
136 }
137}
138
master_wave * en_master_wave_create(const hdrl_image *raw_wave_image, const cpl_mask *raw_wave_bpm, const cpl_image *raw_wave_confidence, const hdrl_image *calibrated_wave_image, const cpl_mask *calibrated_wave_bpm, const cpl_image *calibrated_wave_confidence, const char *filename, const cpl_propertylist *plist)
Create a new master_wave struct and initialise the contents.
hdrl_image * hdrl_image_duplicate(const hdrl_image *himg)
copy hdrl_image
Definition: hdrl_image.c:391
void hdrl_image_delete(hdrl_image *himg)
delete hdrl_image
Definition: hdrl_image.c:379