X-shooter Pipeline Reference Manual 3.8.15
test-xsh_cube_ext_save.c
Go to the documentation of this file.
1/* *
2 * This file is part of the ESO X-shooter Pipeline *
3 * Copyright (C) 2006 European Southern Observatory *
4 * *
5 * This library 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, 51 Franklin St, Fifth Floor, Boston, MA 02111-1307 USA *
18 * */
19
20/*
21 * $Author: amodigli $
22 * $Date: 2011-12-02 14:13:14 $
23 * $Revision: 1.2 $
24 */
25#ifdef HAVE_CONFIG_H
26# include <config.h>
27#endif
28
29/*--------------------------------------------------------------------------*/
35/*--------------------------------------------------------------------------*/
38/*---------------------------------------------------------------------------
39 Includes
40 ---------------------------------------------------------------------------*/
41
42
43#include <cpl.h>
44#include <xsh_data_instrument.h>
45#include <xsh_pfits.h>
46#include <xsh_msg.h>
47#include <xsh_utils.h>
48#include <xsh_data_order.h>
49#include <tests.h>
50#include <math.h>
51
52/*---------------------------------------------------------------------------
53 Defines
54 ---------------------------------------------------------------------------*/
55#define MODULE_ID "XSH_CUBE_EXT_SAVE"
56/*---------------------------------------------------------------------------
57 Functions prototypes
58 ---------------------------------------------------------------------------*/
59
60/*--------------------------------------------------------------------------*/
67/*--------------------------------------------------------------------------*/
68
69
70int main(void)
71{
72 cpl_image* ima=NULL;
73 cpl_imagelist* iml=NULL;
74 int i=0;
75 int j=0;
76 int ret=0;
77 int k=0;
78 int sx=5;
79 int sy=5;
80 int nlist=3;
81 int nima=3;
82 float* pi=NULL;
83 cpl_propertylist* plist=NULL;
84
87 xsh_msg("generate several imagelist and save them in multi-ext file");
88 for(k=0;k<nlist;k++){
89 iml=cpl_imagelist_new();
90 for(j=0;j<nima;j++){
91 ima=cpl_image_new(sx,sy,CPL_TYPE_FLOAT);
92 pi=cpl_image_get_data_float(ima);
93 /* fill ima with values */
94 for(i=0;i<sx*sy;i++){
95 pi[i]=k*j*i+1;
96 }
97 cpl_imagelist_set(iml,ima,j);
98 }
99 if(k==0) {
100 check(cpl_imagelist_save(iml,"cube.fits", CPL_BPP_IEEE_FLOAT,plist,
101 CPL_IO_DEFAULT));
102 } else {
103 check(cpl_imagelist_save(iml,"cube.fits", CPL_BPP_IEEE_FLOAT,plist,
104 CPL_IO_EXTEND));
105 }
106 xsh_free_imagelist(&iml);
107 }
108
109 cleanup:
110
111 xsh_free_propertylist(&plist);
112 xsh_free_imagelist(&iml);
113
114 if (cpl_error_get_code() != CPL_ERROR_NONE) {
115 xsh_error_dump(CPL_MSG_ERROR);
116 ret = 1;
117 }
119 TEST_END();
120 return ret;
121}
122
int main(void)
Unit test of XSH_BIN_CONVENTION.
#define MODULE_ID
#define check(COMMAND)
Definition: xsh_error.h:71
#define xsh_error_dump(level)
Definition: xsh_error.h:92
#define xsh_msg(...)
Print a message on info level.
Definition: xsh_msg.h:121
void xsh_free_propertylist(cpl_propertylist **p)
Deallocate a property list and set the pointer to NULL.
Definition: xsh_utils.c:2179
void xsh_free_imagelist(cpl_imagelist **i)
Deallocate an image list and set the pointer to NULL.
Definition: xsh_utils.c:2164
#define TESTS_CLEAN_WORKSPACE(DRL_ID)
Definition: tests.h:139
#define TESTS_INIT_WORKSPACE(DRL_ID)
Definition: tests.h:133
#define TEST_END()
Definition: tests.h:111
#define TESTS_INIT(DRL_ID)
Definition: tests.h:105