VIRCAM Pipeline  2.3.10
casu_wcsutils-test.c
1 /* $Id: casu_wcsutils-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 #include <casu_wcsutils.h>
37 
38 int main(void) {
39  cpl_propertylist *plist,*plist2;
40  cpl_wcs *wcs,*wcs2;
41  double ra,dec,x,y,xi,eta,ra2,dec2,x2,y2;
42  int status;
43 
44  /* Initialise */
45 
46  cpl_test_init(PACKAGE_BUGREPORT,CPL_MSG_WARNING);
47 
48  /* Create the propertylist and get the wcs descriptor */
49 
50  plist = cpl_propertylist_new();
51  cpl_propertylist_update_string(plist,"CTYPE1","RA---ZPN");
52  cpl_propertylist_update_string(plist,"CTYPE2","DEC--ZPN");
53  cpl_propertylist_update_double(plist,"CRVAL1",81.0578935624986);
54  cpl_propertylist_update_double(plist,"CRVAL2",-24.5408992630551);
55  cpl_propertylist_update_double(plist,"CRPIX1",2159.65203390075);
56  cpl_propertylist_update_double(plist,"CRPIX2",2187.28057518062);
57  cpl_propertylist_update_double(plist,"CD1_1",-2.96100210581431E-05);
58  cpl_propertylist_update_double(plist,"CD2_1",-3.54397484069851E-08);
59  cpl_propertylist_update_double(plist,"CD1_2",-3.93573000440439E-08);
60  cpl_propertylist_update_double(plist,"CD2_2",2.96102853649076E-05);
61  cpl_propertylist_update_double(plist,"PV2_1",1.0);
62  cpl_propertylist_update_double(plist,"PV2_3",400.0);
63  cpl_propertylist_update_int(plist,"NAXIS",2);
64  cpl_propertylist_update_int(plist,"NAXIS1",2048);
65  cpl_propertylist_update_int(plist,"NAXIS2",2048);
66  wcs = cpl_wcs_new_from_propertylist(plist);
67 
68  /* Do some tests now */
69 
70  x = 1000.0;
71  y = 1000.0;
72  casu_xytoradec(wcs,x,y,&ra,&dec);
73  cpl_test_rel(ra,81.09569,0.001);
74  cpl_test_rel(dec,-24.57600,0.001);
75  casu_radectoxy(wcs,ra,dec,&x,&y);
76  cpl_test_rel(x,1000.0,0.00001);
77  cpl_test_rel(y,1000.0,0.00001);
78  casu_radectoxieta(wcs,ra,dec,&xi,&eta);
79  cpl_test_rel(xi,0.000600115,0.000001);
80  cpl_test_rel(eta,-0.000612866,0.00001);
81  status = CASU_OK;
82  casu_coverage(plist,0,&ra,&ra2,&dec,&dec2,&status);
83  cpl_test_eq(status,CASU_OK);
84  cpl_test_rel(ra,81.06153,0.001);
85  cpl_test_rel(ra2,81.12822,0.001);
86  cpl_test_rel(dec,-24.60560,0.001);
87  cpl_test_rel(dec2,-24.54493,0.001);
88  plist2 = cpl_propertylist_duplicate(plist);
89  cpl_propertylist_update_double(plist2,"CRVAL1",81.1578935624986);
90  cpl_propertylist_update_double(plist2,"CRVAL2",-24.6408992630551);
91  wcs2 = cpl_wcs_new_from_propertylist(plist2);
92  casu_xytoxy_list(wcs,wcs2,1,&x,&y,&x2,&y2);
93  cpl_test_rel(x2,4068.86290,0.001);
94  cpl_test_rel(y2,4382.93236,0.001);
95 
96  /* Tidy and exit */
97 
98  cpl_wcs_delete(wcs);
99  cpl_wcs_delete(wcs2);
100  cpl_propertylist_delete(plist);
101  cpl_propertylist_delete(plist2);
102  return(cpl_test_end(0));
103 }
104 
105 /*
106 
107 $Log: casu_wcsutils-test.c,v $
108 Revision 1.2 2015/08/07 13:06:54 jim
109 Fixed copyright to ESO
110 
111 Revision 1.1.1.1 2015/06/12 10:44:32 jim
112 Initial import
113 
114 Revision 1.1 2015/01/09 11:39:55 jim
115 new entry
116 
117 
118 */
void casu_radectoxieta(cpl_wcs *wcs, double ra, double dec, double *xi, double *eta)
void casu_radectoxy(cpl_wcs *wcs, double ra, double dec, double *x, double *y)
void casu_xytoradec(cpl_wcs *wcs, double x, double y, double *ra, double *dec)
Definition: casu_wcsutils.c:93
void casu_xytoxy_list(cpl_wcs *wcs1, cpl_wcs *wcs2, int nc, double *x_1, double *y_1, double *x_2, double *y_2)
int casu_coverage(cpl_propertylist *plist, int fudge, double *ra1, double *ra2, double *dec1, double *dec2, int *status)