VIRCAM Pipeline  2.3.10
casu_nditcor-test.c
1 /* $Id: casu_nditcor-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;
39  cpl_image *im;
40  cpl_propertylist *phu,*ehu;
41  casu_fits *ff;
42 
43  /* Initialise */
44 
45  cpl_test_init(PACKAGE_BUGREPORT,CPL_MSG_WARNING);
46 
47  /* Check inherited status */
48 
49  status = CASU_FATAL;
50  retval = casu_nditcor(NULL,2,"EXPTIME",&status);
51  cpl_test_eq(status,CASU_FATAL);
52  cpl_test_eq(status,retval);
53 
54  /* Make a file to be corrected */
55 
56  im = cpl_image_new(100,100,CPL_TYPE_FLOAT);
57  cpl_image_fill_window(im,1,1,100,100,200.0);
58  phu = cpl_propertylist_new();
59  cpl_propertylist_update_double(phu,"EXPTIME",20.0);
60  ehu = cpl_propertylist_new();
61  cpl_propertylist_update_double(ehu,"EXPTIME",20.0);
62  cpl_propertylist_update_bool(ehu,"ESO DRS NDITCOR",CPL_TRUE);
63  ff = casu_fits_wrap(im,NULL,phu,ehu);
64  cpl_propertylist_delete(phu);
65  cpl_propertylist_delete(ehu);
66 
67  /* Ok this file has been made to look as though it's already been
68  corrected. See if the routine rejects it for processing on that
69  basis */
70 
71  status = CASU_OK;
72  retval = casu_nditcor(ff,2,"EXPTIME",&status);
73  cpl_test_eq(status,CASU_OK);
74  cpl_test_eq(status,retval);
75  cpl_test_rel(200.0,cpl_image_get_mean(casu_fits_get_image(ff)),0.001);
76  cpl_test_eq(20.0,cpl_propertylist_get_double(casu_fits_get_phu(ff),"EXPTIME"));
77  cpl_test_eq(20.0,cpl_propertylist_get_double(casu_fits_get_ehu(ff),"EXPTIME"));
78 
79  /* Right, erase the flag saying it's already been done. Then rerun and
80  see if we get the right answer */
81 
82  cpl_propertylist_erase(casu_fits_get_ehu(ff),"ESO DRS NDITCOR");
83  status = CASU_OK;
84  retval = casu_nditcor(ff,2,"EXPTIME",&status);
85  cpl_test_eq(status,CASU_OK);
86  cpl_test_eq(status,retval);
87  cpl_test_rel(100.0,cpl_image_get_mean(casu_fits_get_image(ff)),0.001);
88  cpl_test_eq(10.0,cpl_propertylist_get_double(casu_fits_get_phu(ff),"EXPTIME"));
89  cpl_test_eq(10.0,cpl_propertylist_get_double(casu_fits_get_ehu(ff),"EXPTIME"));
90  cpl_test_eq(1,cpl_propertylist_has(casu_fits_get_ehu(ff),"ESO DRS NDITCOR"));
91 
92  /* Tidy and exit */
93 
94  casu_fits_delete(ff);
95  return(cpl_test_end(0));
96 }
97 
98 /*
99 
100 $Log: casu_nditcor-test.c,v $
101 Revision 1.2 2015/08/07 13:06:54 jim
102 Fixed copyright to ESO
103 
104 Revision 1.1.1.1 2015/06/12 10:44:32 jim
105 Initial import
106 
107 Revision 1.1 2015/01/09 11:39:55 jim
108 new entry
109 
110 
111 */
cpl_image * casu_fits_get_image(casu_fits *p)
Definition: casu_fits.c:436
void casu_fits_delete(casu_fits *p)
Definition: casu_fits.c:364
casu_fits * casu_fits_wrap(cpl_image *im, casu_fits *model, cpl_propertylist *phu, cpl_propertylist *ehu)
Definition: casu_fits.c:883
cpl_propertylist * casu_fits_get_phu(casu_fits *p)
Definition: casu_fits.c:531
cpl_propertylist * casu_fits_get_ehu(casu_fits *p)
Definition: casu_fits.c:576
int casu_nditcor(casu_fits *infile, int ndit, const char *expkey, int *status)
Correct input data for number of dits.
Definition: casu_nditcor.c:85