fors_photometry-test.c

00001 /* $Id: fors_photometry-test.c,v 1.8 2008/01/29 15:48:31 cizzo Exp $
00002  *
00003  * This file is part of the FORS Library
00004  * Copyright (C) 2002-2006 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., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
00019  */
00020 
00021 /*
00022  * $Author: cizzo $
00023  * $Date: 2008/01/29 15:48:31 $
00024  * $Revision: 1.8 $
00025  * $Name:  $
00026  */
00027 
00028 #ifdef HAVE_CONFIG_H
00029 #include <config.h>
00030 #endif
00031 
00032 #include <fors_photometry_impl.h>
00033 #include <fors_dfs.h>
00034 #include <fors_utils.h>
00035 #include <test_simulate.h>
00036 #include <test.h>
00037 
00044 #undef cleanup
00045 #define cleanup \
00046 do { \
00047     cpl_frameset_delete(frames); \
00048     cpl_parameterlist_delete(parameters); \
00049     cpl_propertylist_delete(header); \
00050 } while(0)
00051 
00054 static void
00055 test_photometry(void)
00056 {
00057     cpl_parameterlist *parameters = cpl_parameterlist_new();
00058     cpl_frameset *frames = cpl_frameset_new();
00059 
00060     const char *filename[] = {"photometry_aligned0.fits",
00061                   "photometry_aligned1.fits",
00062                   "photometry_aligned2.fits",
00063                   "photometry_aligned3.fits"};
00064     cpl_propertylist *header = cpl_propertylist_new();
00065     double exptime = 10.0;
00066     cpl_frameset_insert(frames, create_sky_flat("photometry_master_flat.fits",
00067                         MASTER_SKY_FLAT_IMG,
00068                         CPL_FRAME_GROUP_RAW,
00069                         10.0));
00070 
00071     cpl_frameset_insert(frames, create_phot_table("photometry_phot_table.fits",
00072                                                   PHOT_TABLE,
00073                                                   CPL_FRAME_GROUP_CALIB));
00074 
00075     create_standard_keys(header, exptime);
00076     cpl_propertylist_update_double(header, "AIRMASS", 1.234);
00077     
00078     {
00079     int i;
00080     for (i = 0; i < sizeof(filename)/sizeof(*filename); i++) {
00081 
00082         /* Probably better would be to use fors_create_sources_table()
00083            to create the ALIGNED_PHOT table */
00084         
00085         cpl_table *aligned = cpl_table_new(1);
00086         
00087         cpl_frame *f = cpl_frame_new();
00088         cpl_frame_set_tag(f, ALIGNED_PHOT);
00089         cpl_frame_set_filename(f, filename[i]);
00090         cpl_frameset_insert(frames, f);
00091         
00092         cpl_table_new_column(aligned, "INSTR_MAG", CPL_TYPE_DOUBLE);
00093         cpl_table_new_column(aligned, "DINSTR_MAG", CPL_TYPE_DOUBLE);
00094         cpl_table_new_column(aligned, "MAG", CPL_TYPE_DOUBLE);
00095         cpl_table_new_column(aligned, "DMAG", CPL_TYPE_DOUBLE);
00096         cpl_table_new_column(aligned, "CAT_MAG", CPL_TYPE_DOUBLE);
00097         cpl_table_new_column(aligned, "DCAT_MAG", CPL_TYPE_DOUBLE);
00098         cpl_table_new_column(aligned, "COLOR", CPL_TYPE_DOUBLE);
00099         cpl_table_new_column(aligned, "RA", CPL_TYPE_DOUBLE);
00100         cpl_table_new_column(aligned, "DEC", CPL_TYPE_DOUBLE);
00101         cpl_table_new_column(aligned, "X", CPL_TYPE_DOUBLE);
00102         cpl_table_new_column(aligned, "Y", CPL_TYPE_DOUBLE);
00103         cpl_table_new_column(aligned, "A", CPL_TYPE_DOUBLE);
00104         cpl_table_new_column(aligned, "B", CPL_TYPE_DOUBLE);
00105         cpl_table_new_column(aligned, "FWHM", CPL_TYPE_DOUBLE);
00106         cpl_table_new_column(aligned, "THETA", CPL_TYPE_DOUBLE);
00107         cpl_table_new_column(aligned, "CLASS_STAR", CPL_TYPE_DOUBLE);
00108         cpl_table_new_column(aligned, "OBJECT", CPL_TYPE_STRING);
00109         cpl_table_new_column(aligned, "USE_CAT", CPL_TYPE_INT);
00110         
00111         cpl_table_set_double(aligned, "INSTR_MAG", 0, -13.8);
00112         cpl_table_set_double(aligned, "DINSTR_MAG", 0, 0.1);
00113         cpl_table_set_double(aligned, "MAG", 0, 14.4);
00114         cpl_table_set_double(aligned, "DMAG", 0, 0.004);
00115         cpl_table_set_double(aligned, "CAT_MAG", 0, 14.2);
00116         cpl_table_set_double(aligned, "DCAT_MAG", 0, 0.002);
00117         cpl_table_set_double(aligned, "COLOR", 0, 0.4);
00118         
00119         cpl_table_set_double(aligned, "RA", 0, 100);
00120         cpl_table_set_double(aligned, "DEC", 0, 1);
00121         
00122         cpl_table_set_double(aligned, "X", 0, 400);
00123         cpl_table_set_double(aligned, "Y", 0, 500);
00124         cpl_table_set_double(aligned, "A", 0, 2);
00125         cpl_table_set_double(aligned, "B", 0, 1);
00126         cpl_table_set_double(aligned, "FWHM", 0, 1.4);
00127         cpl_table_set_double(aligned, "THETA", 0, 0.1);
00128         cpl_table_set_double(aligned, "CLASS_STAR", 0, 0.1);
00129         
00130         cpl_table_set_string(aligned, "OBJECT", 0, "MOBJEKT");
00131         cpl_table_set_int(aligned, "USE_CAT", 0, 1);        
00132         
00133         cpl_table_save(aligned, header, NULL, filename[i], CPL_IO_DEFAULT);
00134 
00135         cpl_table_delete(aligned); aligned = NULL;
00136     }
00137     }
00138 
00139     assure( !cpl_error_get_code(), return, NULL );
00140 
00141     fors_photometry_define_parameters(parameters);
00142     cpl_parameter_set_int(cpl_parameterlist_find(parameters,
00143                          "fors.fors_photometry.degreef1"),
00144               0);
00145     
00146     fors_photometry(frames, parameters);
00147 
00148     cleanup;
00149     return;
00150 }
00151 
00152 
00156 int main(void)
00157 {
00158     TEST_INIT;
00159     //cpl_msg_set_level(CPL_MSG_DEBUG);
00160     test_photometry();
00161 
00162     TEST_END;
00163 }
00164 

Generated on Wed Sep 10 07:31:52 2008 for FORS Pipeline Reference Manual by  doxygen 1.4.6