FORS Pipeline Reference Manual  4.12.5
fors_photometry-test.c
1 /* $Id: fors_photometry-test.c,v 1.9 2009-02-17 12:18:28 hlorch Exp $
2  *
3  * This file is part of the FORS Library
4  * Copyright (C) 2002-2006 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19  */
20 
21 /*
22  * $Author: hlorch $
23  * $Date: 2009-02-17 12:18:28 $
24  * $Revision: 1.9 $
25  * $Name: not supported by cvs2svn $
26  */
27 
28 #ifdef HAVE_CONFIG_H
29 #include <config.h>
30 #endif
31 
32 #include <fors_photometry_impl.h>
33 #include <fors_dfs.h>
34 #include <fors_utils.h>
35 #include <test_simulate.h>
36 #include <test.h>
37 
44 #undef cleanup
45 #define cleanup \
46 do { \
47  cpl_frameset_delete(frames); \
48  cpl_parameterlist_delete(parameters); \
49  cpl_propertylist_delete(header); \
50 } while(0)
51 
54 static void
56 {
57  cpl_parameterlist *parameters = cpl_parameterlist_new();
58  cpl_frameset *frames = cpl_frameset_new();
59 
60  const char *filename[] = {"photometry_aligned0.fits",
61  "photometry_aligned1.fits",
62  "photometry_aligned2.fits",
63  "photometry_aligned3.fits"};
64  cpl_propertylist *header = cpl_propertylist_new();
65  double exptime = 10.0;
66  cpl_frameset_insert(frames, create_sky_flat("photometry_master_flat.fits",
67  MASTER_SKY_FLAT_IMG,
68  CPL_FRAME_GROUP_RAW,
69  10.0));
70 
71  cpl_frameset_insert(frames, create_phot_table("photometry_phot_table.fits",
72  PHOT_TABLE,
73  CPL_FRAME_GROUP_CALIB));
74 
75  create_standard_keys(header, exptime);
76  /* required by fors_photometry parameter --fite=pernight */
77  cpl_propertylist_update_string(header, "ORIGIN", "ESO");
78  cpl_propertylist_update_double(header, "MJD-OBS", 0.5);
79 
80  {
81  int i;
82  for (i = 0; i < (int)(sizeof(filename)/sizeof(*filename)); i++)
83  {
84  double airmass;
85  airmass = 1.1 + 0.1*i;
86 
87  /* create an airmass range for fitting the atm. ext. */
88  cpl_propertylist_update_double(header, "AIRMASS", airmass);
89 
90  /* Probably better would be to use fors_create_sources_table()
91  to create the ALIGNED_PHOT table */
92 
93  cpl_table *aligned = cpl_table_new(1);
94 
95  cpl_frame *f = cpl_frame_new();
96  cpl_frame_set_tag(f, ALIGNED_PHOT);
97  cpl_frame_set_filename(f, filename[i]);
98  cpl_frameset_insert(frames, f);
99 
100  cpl_table_new_column(aligned, "INSTR_MAG", CPL_TYPE_DOUBLE);
101  cpl_table_new_column(aligned, "DINSTR_MAG", CPL_TYPE_DOUBLE);
102  cpl_table_new_column(aligned, "MAG", CPL_TYPE_DOUBLE);
103  cpl_table_new_column(aligned, "DMAG", CPL_TYPE_DOUBLE);
104  cpl_table_new_column(aligned, "CAT_MAG", CPL_TYPE_DOUBLE);
105  cpl_table_new_column(aligned, "DCAT_MAG", CPL_TYPE_DOUBLE);
106  cpl_table_new_column(aligned, "COLOR", CPL_TYPE_DOUBLE);
107  cpl_table_new_column(aligned, "RA", CPL_TYPE_DOUBLE);
108  cpl_table_new_column(aligned, "DEC", CPL_TYPE_DOUBLE);
109  cpl_table_new_column(aligned, "X", CPL_TYPE_DOUBLE);
110  cpl_table_new_column(aligned, "Y", CPL_TYPE_DOUBLE);
111  cpl_table_new_column(aligned, "A", CPL_TYPE_DOUBLE);
112  cpl_table_new_column(aligned, "B", CPL_TYPE_DOUBLE);
113  cpl_table_new_column(aligned, "FWHM", CPL_TYPE_DOUBLE);
114  cpl_table_new_column(aligned, "THETA", CPL_TYPE_DOUBLE);
115  cpl_table_new_column(aligned, "CLASS_STAR", CPL_TYPE_DOUBLE);
116  cpl_table_new_column(aligned, "OBJECT", CPL_TYPE_STRING);
117  cpl_table_new_column(aligned, "USE_CAT", CPL_TYPE_INT);
118 
119  cpl_table_set_double(aligned, "INSTR_MAG", 0, -13.8 + (airmass-1)*0.1);
120  cpl_table_set_double(aligned, "DINSTR_MAG", 0, 0.1);
121  cpl_table_set_double(aligned, "MAG", 0, 14.4);
122  cpl_table_set_double(aligned, "DMAG", 0, 0.004);
123  cpl_table_set_double(aligned, "CAT_MAG", 0, 14.2);
124  cpl_table_set_double(aligned, "DCAT_MAG", 0, 0.002);
125  cpl_table_set_double(aligned, "COLOR", 0, 0.4);
126 
127  cpl_table_set_double(aligned, "RA", 0, 100);
128  cpl_table_set_double(aligned, "DEC", 0, 1);
129 
130  cpl_table_set_double(aligned, "X", 0, 400);
131  cpl_table_set_double(aligned, "Y", 0, 500);
132  cpl_table_set_double(aligned, "A", 0, 2);
133  cpl_table_set_double(aligned, "B", 0, 1);
134  cpl_table_set_double(aligned, "FWHM", 0, 1.4);
135  cpl_table_set_double(aligned, "THETA", 0, 0.1);
136  cpl_table_set_double(aligned, "CLASS_STAR", 0, 0.1);
137 
138  cpl_table_set_string(aligned, "OBJECT", 0, "MOBJEKT");
139  cpl_table_set_int(aligned, "USE_CAT", 0, 1);
140 
141  cpl_table_save(aligned, header, NULL, filename[i], CPL_IO_DEFAULT);
142 
143  cpl_table_delete(aligned); aligned = NULL;
144  }
145  }
146 
147  assure( !cpl_error_get_code(), return, NULL );
148 
149  fors_photometry_define_parameters(parameters);
150  cpl_parameter_set_int(cpl_parameterlist_find(parameters,
151  "fors.fors_photometry.degreef1"),
152  0);
153 
154  fors_photometry(frames, parameters);
155 
156  cleanup;
157  return;
158 }
159 
160 
164 int main(void)
165 {
166  TEST_INIT;
167  //cpl_msg_set_level(CPL_MSG_DEBUG);
168  test_photometry();
169 
170  TEST_END;
171 }
172 
static void test_photometry(void)
test
#define assure(EXPR)
Definition: list.c:101
void create_standard_keys(cpl_propertylist *header, double exptime)
Write FORS standard keywords to simulated header.
int main(void)
Test of QC module.
cpl_frame * create_sky_flat(const char *filename, const char *tag, cpl_frame_group group, double exptime)
Simulate sky flat image.
cpl_frame * create_phot_table(const char *filename, const char *tag, cpl_frame_group group)
Create photometry table.