VIRCAM Pipeline  2.3.10
casu_mkconf-test.c
1 /* $Id: casu_mkconf-test.c,v 1.2 2015/08/07 13:06:54 jim Exp $
2  *
3  * This file is part of the CASU Pipeline utilities
4  * Copyright (C) 2015 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19  */
20 
21 /*
22  * $Author: jim $
23  * $Date: 2015/08/07 13:06:54 $
24  * $Revision: 1.2 $
25  * $Name: $
26  */
27 
28 #include <stdio.h>
29 #include <stdlib.h>
30 
31 #include <cpl_init.h>
32 #include <cpl_test.h>
33 #include <casu_fits.h>
34 #include <casu_utils.h>
35 #include <casu_mods.h>
36 
37 int main(void) {
38  int status,retval,nzero,i,*data;
39  cpl_image *outconf;
40  cpl_propertylist *drs;
41  cpl_image *im;
42  unsigned char *bpm;
43  casu_mask *cm;
44 
45  /* Initialise */
46 
47  cpl_test_init(PACKAGE_BUGREPORT,CPL_MSG_WARNING);
48 
49  /* Check inherited status */
50 
51  status = CASU_FATAL;
52  retval = casu_mkconf(NULL,NULL,NULL,&outconf,&drs,&status);
53  cpl_test_eq(status,CASU_FATAL);
54  cpl_test_eq(status,retval);
55  cpl_test_null(outconf);
56  cpl_test_null(drs);
57 
58  /* Make some input files. Start with the mask, then make a normalised
59  flat */
60 
61  bpm = cpl_calloc(100*100,sizeof(unsigned char));
62  bpm[0] = 1;
63  bpm[1] = 1;
64  cm = casu_mask_wrap_bpm(bpm,100,100);
65  im = cpl_image_new(100,100,CPL_TYPE_FLOAT);
66  cpl_image_fill_noise_uniform(im,0.9,1.1);
67  status = CASU_OK;
68  retval = casu_mkconf(im,"testflat.fit",cm,&outconf,&drs,&status);
69  cpl_test_eq(status,CASU_OK);
70  cpl_test_eq(status,retval);
71  cpl_test_nonnull(outconf);
72  cpl_test_nonnull(drs);
73  cpl_test_rel(100.0,cpl_image_get_mean(outconf),0.05);
74  nzero = 0;
75  data = cpl_image_get_data_int(outconf);
76  for (i = 0; i < 10000; i++)
77  if (data[i] == 0)
78  nzero++;
79  cpl_test_eq(nzero,2);
80 
81  /* Tidy and exit */
82 
83  cpl_propertylist_delete(drs);
84  cpl_image_delete(outconf);
85  casu_mask_delete(cm);
86  cpl_image_delete(im);
87 
88  return(cpl_test_end(0));
89 }
90 
91 /*
92 
93 $Log: casu_mkconf-test.c,v $
94 Revision 1.2 2015/08/07 13:06:54 jim
95 Fixed copyright to ESO
96 
97 Revision 1.1.1.1 2015/06/12 10:44:32 jim
98 Initial import
99 
100 Revision 1.1 2015/01/09 11:39:55 jim
101 new entry
102 
103 
104 */
void casu_mask_delete(casu_mask *m)
Definition: casu_mask.c:276
casu_mask * casu_mask_wrap_bpm(unsigned char *inbpm, int nx, int ny)
Definition: casu_mask.c:309
int casu_mkconf(cpl_image *flat, char *flatfile, casu_mask *bpm, cpl_image **outconf, cpl_propertylist **drs, int *status)
Create a confidence map.
Definition: casu_mkconf.c:87