ERIS Pipeline Reference Manual 1.9.3
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 != NULL) {
86 result->calibrated_wave_image = hdrl_image_duplicate(
87 calibrated_wave_image);
88 } else {
89 result->calibrated_wave_image = NULL;
90 }
91 if (calibrated_wave_bpm != NULL) {
92 result->calibrated_wave_bpm = cpl_mask_duplicate(calibrated_wave_bpm);
93 } else {
94 result->calibrated_wave_bpm = NULL;
95 }
96 if (calibrated_wave_confidence != NULL) {
97 result->calibrated_wave_confidence = cpl_image_duplicate(
98 calibrated_wave_confidence);
99 } else {
100 result->calibrated_wave_confidence = NULL;
101 }
102 if (filename != NULL) {
103 result->filename = cpl_strdup(filename);
104 } else {
105 result->filename = NULL;
106 }
107 if (plist != NULL) {
108 result->plist = cpl_propertylist_duplicate(plist);
109 } else {
110 result->plist = NULL;
111 }
112
113 return result;
114}
115
120/*----------------------------------------------------------------------------*/
128/*----------------------------------------------------------------------------*/
129
130void en_master_wave_delete(master_wave * target) {
131
132 if (target) {
133 cpl_free(target->filename);
134 hdrl_image_delete(target->raw_wave_image);
135 cpl_mask_delete(target->raw_wave_bpm);
136 cpl_image_delete(target->raw_wave_confidence);
137 hdrl_image_delete(target->calibrated_wave_image);
138 cpl_mask_delete(target->calibrated_wave_bpm);
139 cpl_image_delete(target->calibrated_wave_confidence);
140 cpl_propertylist_delete(target->plist);
141 cpl_free(target);
142 }
143}
144
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