VIRCAM Pipeline 2.3.15
casu_gaincor-test.c
1/* $Id: casu_gaincor-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;
39 float scl;
40 casu_fits *in;
41 cpl_image *inim;
42 cpl_propertylist *ehu;
43 double mean,stdev;
44
45 /* Initialise */
46
47 cpl_test_init(PACKAGE_BUGREPORT,CPL_MSG_WARNING);
48
49 /* Check inherited status */
50
51 status = CASU_FATAL;
52 in = NULL;
53 scl = 0.0;
54 retval = casu_gaincor(in,scl,&status);
55 cpl_test_eq(status,CASU_FATAL);
56 cpl_test_eq(status,retval);
57
58 /* Create an image */
59
60 inim = cpl_image_new(10,10,CPL_TYPE_FLOAT);
61 ehu = cpl_propertylist_new();
62 cpl_propertylist_update_float(ehu,"ESO DRS GAINCOR",2.0);
63 in = casu_fits_wrap(inim,NULL,NULL,ehu);
64 cpl_propertylist_delete(ehu);
65 ehu = casu_fits_get_ehu(in);
66 status = CASU_OK;
67
68 /* Status should be OK if it thinks it's already corrected the image */
69
70 retval = casu_gaincor(in,scl,&status);
71 cpl_test_eq(status,CASU_OK);
72 cpl_test_eq(status,retval);
73
74 /* Check to make sure you get a warning if the scale is <= 0.0 */
75
76 cpl_propertylist_erase(ehu,"ESO DRS GAINCOR");
77 retval = casu_gaincor(in,scl,&status);
78 cpl_test_eq(status,CASU_WARN);
79 cpl_test_eq(status,retval);
80
81 /* Give the image some values */
82
83 cpl_propertylist_erase(ehu,"ESO DRS GAINCOR");
84 cpl_image_add_scalar(inim,10.0);
85 scl = 2.0;
86 status = CASU_OK;
87
88 /* Test to see if you get the right answer */
89
90 retval = casu_gaincor(in,scl,&status);
91 cpl_test_eq(status,CASU_OK);
92 cpl_test_eq(status,retval);
93 mean = cpl_image_get_mean((const cpl_image *)inim);
94 stdev = cpl_image_get_stdev((const cpl_image *)inim);
95 cpl_test_rel(mean,20.0,1.0e-6);
96 cpl_test_rel(stdev,0.0,1.0e-6);
97 cpl_test_rel(2.0,cpl_propertylist_get_float(ehu,"ESO DRS GAINCOR"),1.0e-6);
98
99 /* Tidy up and get out of here */
100
102 cpl_image_delete(inim);
103
104 return(cpl_test_end(0));
105}
106
107/*
108
109$Log: casu_gaincor-test.c,v $
110Revision 1.2 2015/08/07 13:06:54 jim
111Fixed copyright to ESO
112
113Revision 1.1.1.1 2015/06/12 10:44:32 jim
114Initial import
115
116Revision 1.1 2014/03/26 15:31:29 jim
117New Entry
118
119
120*/
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_ehu(casu_fits *p)
Definition: casu_fits.c:576
void casu_fits_unwrap(casu_fits *p)
Definition: casu_fits.c:945
int casu_gaincor(casu_fits *infile, float gainscl, int *status)
Gain correct input data frame.
Definition: casu_gaincor.c:77