VIRCAM Pipeline 2.3.15
casu_genbpm-test.c
1/* $Id: casu_genbpm-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
37int main(void) {
38 int status,retval,nbad,i,ilim,ind,ii,jj,isnull;
39 cpl_array *bpm_array;
40 float badfrac,lim,ave,*idata,off;
41 casu_fits *fitslist[10];
42 cpl_image *im,*master = NULL;
43
44 /* Initialise */
45
46 cpl_test_init(PACKAGE_BUGREPORT,CPL_MSG_WARNING);
47
48 /* Check inherited status */
49
50 status = CASU_FATAL;
51 retval = casu_genbpm(NULL,0,NULL,5.0,5.0,"EXPTIME",&bpm_array,&nbad,
52 &badfrac,&status);
53 cpl_test_eq(status,CASU_FATAL);
54 cpl_test_eq(status,retval);
55 status = CASU_OK;
56
57 /* Create some images */
58
59 for (i = 0; i <= 10; i++) {
60 ave = 100.0*(float)(i+1);
61 im = cpl_image_new(100,100,CPL_TYPE_FLOAT);
62 lim = 10.0*(float)(i+1);
63 ilim = 20*(i+1);
64 idata = cpl_image_get_data_float(im);
65 ind = 0;
66 for (ii = 0; ii < 100; ii++) {
67 for (jj = 0; jj < 100; jj++) {
68 off = lim - (float)(rand() % ilim);
69 idata[ind++] = ave + off;
70 }
71 }
72 if (i != 0) {
73 idata[5500] = 100*ave;
74 fitslist[i-1] = casu_fits_wrap(im,NULL,NULL,NULL);
75 } else {
76 master = im;
77 }
78 }
79
80 /* Run the routine and check the output values */
81
82 retval = casu_genbpm(fitslist,10,master,3.0,3.0,"EXPTIME",&bpm_array,
83 &nbad,&badfrac,&status);
84 cpl_test_eq(status,CASU_OK);
85 cpl_test_eq(status,retval);
86 cpl_test_eq(nbad,1);
87 cpl_test_rel(badfrac,1.0e-4,1.0e-6);
88 cpl_test_eq(cpl_array_get_int(bpm_array,5500,&isnull),1);
89
90 /* Tidy and exit */
91
92 cpl_image_delete(master);
93 for (i = 0; i < 10; i++) {
94 im = casu_fits_get_image(fitslist[i]);
95 casu_fits_unwrap(fitslist[i]);
96 cpl_image_delete(im);
97 }
98 cpl_array_delete(bpm_array);
99
100
101 return(cpl_test_end(0));
102}
103
104/*
105
106$Log: casu_genbpm-test.c,v $
107Revision 1.2 2015/08/07 13:06:54 jim
108Fixed copyright to ESO
109
110Revision 1.1.1.1 2015/06/12 10:44:32 jim
111Initial import
112
113Revision 1.1 2015/01/09 11:39:55 jim
114new entry
115
116
117*/
casu_fits * casu_fits_wrap(cpl_image *im, casu_fits *model, cpl_propertylist *phu, cpl_propertylist *ehu)
Definition: casu_fits.c:883
cpl_image * casu_fits_get_image(casu_fits *p)
Definition: casu_fits.c:436
void casu_fits_unwrap(casu_fits *p)
Definition: casu_fits.c:945
int casu_genbpm(casu_fits **flatlist, int nflatlist, cpl_image *master, float lthr, float hthr, const char *expkey, cpl_array **bpm_array, int *nbad, float *badfrac, int *status)
Generate a bad pixel mask from a list of dome flats.
Definition: casu_genbpm.c:97