00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
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
00077 cpl_propertylist_update_string(header, "ORIGIN", "ESO");
00078 cpl_propertylist_update_double(header, "MJD-OBS", 0.5);
00079
00080 {
00081 int i;
00082 for (i = 0; i < (int)(sizeof(filename)/sizeof(*filename)); i++)
00083 {
00084 double airmass;
00085 airmass = 1.1 + 0.1*i;
00086
00087
00088 cpl_propertylist_update_double(header, "AIRMASS", airmass);
00089
00090
00091
00092
00093 cpl_table *aligned = cpl_table_new(1);
00094
00095 cpl_frame *f = cpl_frame_new();
00096 cpl_frame_set_tag(f, ALIGNED_PHOT);
00097 cpl_frame_set_filename(f, filename[i]);
00098 cpl_frameset_insert(frames, f);
00099
00100 cpl_table_new_column(aligned, "INSTR_MAG", CPL_TYPE_DOUBLE);
00101 cpl_table_new_column(aligned, "DINSTR_MAG", CPL_TYPE_DOUBLE);
00102 cpl_table_new_column(aligned, "MAG", CPL_TYPE_DOUBLE);
00103 cpl_table_new_column(aligned, "DMAG", CPL_TYPE_DOUBLE);
00104 cpl_table_new_column(aligned, "CAT_MAG", CPL_TYPE_DOUBLE);
00105 cpl_table_new_column(aligned, "DCAT_MAG", CPL_TYPE_DOUBLE);
00106 cpl_table_new_column(aligned, "COLOR", CPL_TYPE_DOUBLE);
00107 cpl_table_new_column(aligned, "RA", CPL_TYPE_DOUBLE);
00108 cpl_table_new_column(aligned, "DEC", CPL_TYPE_DOUBLE);
00109 cpl_table_new_column(aligned, "X", CPL_TYPE_DOUBLE);
00110 cpl_table_new_column(aligned, "Y", CPL_TYPE_DOUBLE);
00111 cpl_table_new_column(aligned, "A", CPL_TYPE_DOUBLE);
00112 cpl_table_new_column(aligned, "B", CPL_TYPE_DOUBLE);
00113 cpl_table_new_column(aligned, "FWHM", CPL_TYPE_DOUBLE);
00114 cpl_table_new_column(aligned, "THETA", CPL_TYPE_DOUBLE);
00115 cpl_table_new_column(aligned, "CLASS_STAR", CPL_TYPE_DOUBLE);
00116 cpl_table_new_column(aligned, "OBJECT", CPL_TYPE_STRING);
00117 cpl_table_new_column(aligned, "USE_CAT", CPL_TYPE_INT);
00118
00119 cpl_table_set_double(aligned, "INSTR_MAG", 0, -13.8 + (airmass-1)*0.1);
00120 cpl_table_set_double(aligned, "DINSTR_MAG", 0, 0.1);
00121 cpl_table_set_double(aligned, "MAG", 0, 14.4);
00122 cpl_table_set_double(aligned, "DMAG", 0, 0.004);
00123 cpl_table_set_double(aligned, "CAT_MAG", 0, 14.2);
00124 cpl_table_set_double(aligned, "DCAT_MAG", 0, 0.002);
00125 cpl_table_set_double(aligned, "COLOR", 0, 0.4);
00126
00127 cpl_table_set_double(aligned, "RA", 0, 100);
00128 cpl_table_set_double(aligned, "DEC", 0, 1);
00129
00130 cpl_table_set_double(aligned, "X", 0, 400);
00131 cpl_table_set_double(aligned, "Y", 0, 500);
00132 cpl_table_set_double(aligned, "A", 0, 2);
00133 cpl_table_set_double(aligned, "B", 0, 1);
00134 cpl_table_set_double(aligned, "FWHM", 0, 1.4);
00135 cpl_table_set_double(aligned, "THETA", 0, 0.1);
00136 cpl_table_set_double(aligned, "CLASS_STAR", 0, 0.1);
00137
00138 cpl_table_set_string(aligned, "OBJECT", 0, "MOBJEKT");
00139 cpl_table_set_int(aligned, "USE_CAT", 0, 1);
00140
00141 cpl_table_save(aligned, header, NULL, filename[i], CPL_IO_DEFAULT);
00142
00143 cpl_table_delete(aligned); aligned = NULL;
00144 }
00145 }
00146
00147 assure( !cpl_error_get_code(), return, NULL );
00148
00149 fors_photometry_define_parameters(parameters);
00150 cpl_parameter_set_int(cpl_parameterlist_find(parameters,
00151 "fors.fors_photometry.degreef1"),
00152 0);
00153
00154 fors_photometry(frames, parameters);
00155
00156 cleanup;
00157 return;
00158 }
00159
00160
00164 int main(void)
00165 {
00166 TEST_INIT;
00167
00168 test_photometry();
00169
00170 TEST_END;
00171 }
00172