irplib_wcs-test.c

00001 /* $Id: irplib_wcs-test.c,v 1.6 2009/03/19 12:27:46 lbilbao Exp $
00002  *
00003  * This file is part of the ESO Common Pipeline Library
00004  * Copyright (C) 2001-2008 European Southern Observatory
00005  *
00006  * This program is free software; you can redistribute it and/or modify
00007  * it under the terms of the GNU General Public License as published by
00008  * the Free Software Foundation; either version 2 of the License, or
00009  * (at your option) any later version.
00010  *
00011  * This program is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  * GNU General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU General Public License
00017  * along with this program; if not, write to the Free Software
00018  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00019  */
00020 
00021 /*
00022  * $Author: lbilbao $
00023  * $Date: 2009/03/19 12:27:46 $
00024  * $Revision: 1.6 $
00025  * $Name: naco-4_2_1 $
00026  */
00027 
00028 /*-----------------------------------------------------------------------------
00029                                    Includes
00030  -----------------------------------------------------------------------------*/
00031 #ifdef HAVE_CONFIG_H
00032 #include <config.h>
00033 #endif
00034 
00035 #include <cpl_test.h>
00036 
00037 #include "irplib_wcs.h"
00038 
00039 /*-----------------------------------------------------------------------------
00040                                    Static functions
00041  -----------------------------------------------------------------------------*/
00042 static void irplib_wcs_all_test(void);
00043 
00044 /*-----------------------------------------------------------------------------
00045                                   Main
00046  -----------------------------------------------------------------------------*/
00047 int main (void)
00048 {
00049 
00050     cpl_test_init(PACKAGE_BUGREPORT, CPL_MSG_WARNING);
00051 
00052     irplib_wcs_all_test();
00053 
00054     return cpl_test_end(0);
00055 }
00056 
00057 static void irplib_wcs_all_test(void)
00058 {
00059     cpl_propertylist * prop_wcs; 
00060     cpl_wcs *          wcs = NULL;
00061     double             xorig,yorig;
00062     double             xnew,ynew;
00063     double             ra, dec;
00064     
00065     /* Create WCS object */
00066     prop_wcs = cpl_propertylist_new();
00067     cpl_test_nonnull(prop_wcs);
00068     cpl_propertylist_append_double(prop_wcs, "CRVAL1", 10.);
00069     cpl_propertylist_append_double(prop_wcs, "CRVAL2", 20.);
00070     cpl_propertylist_append_int(prop_wcs, "CRPIX1", 1);
00071     cpl_propertylist_append_int(prop_wcs, "CRPIX2", 2);
00072     cpl_propertylist_append_double(prop_wcs, "CD1_1", 10.);
00073     cpl_propertylist_append_double(prop_wcs, "CD1_2", 11.);
00074     cpl_propertylist_append_double(prop_wcs, "CD2_1", 13.);
00075     cpl_propertylist_append_double(prop_wcs, "CD2_2", 14.);
00076     wcs = cpl_wcs_new_from_propertylist(prop_wcs);
00077     if(cpl_error_get_code() == CPL_ERROR_NO_WCS)
00078     {
00079         cpl_msg_warning(__func__,"No WCS present. Tests disabled");
00080         cpl_test_error(CPL_ERROR_NO_WCS);
00081         cpl_test_null(wcs);
00082         cpl_propertylist_delete(prop_wcs);
00083         return;
00084     }
00085     cpl_test_nonnull(wcs);
00086     
00087     /* Test that a simple call to xytoradec does not fail*/
00088     xorig = 1;
00089     yorig = 2;
00090     irplib_wcs_xytoradec(wcs, xorig, yorig, &ra, &dec);
00091     cpl_test_error(CPL_ERROR_NONE);
00092     
00093     /* Get the transformation back and compare */
00094     irplib_wcs_radectoxy(wcs, ra, dec, &xnew, &ynew);
00095     cpl_test_leq((xnew - xorig), 2 * DBL_EPSILON);
00096     cpl_test_leq((ynew - yorig), 2 * DBL_EPSILON);
00097     cpl_test_error(CPL_ERROR_NONE);
00098     
00099     /* Free */
00100     cpl_wcs_delete(wcs);
00101     cpl_propertylist_delete(prop_wcs);
00102     
00103 }

Generated on Tue Jun 29 12:16:39 2010 for NACO Pipeline Reference Manual by  doxygen 1.4.7