test_simulate.c

00001 /* $Id: test_simulate.c,v 1.34 2009-02-25 15:34:48 hlorch 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: hlorch $
00023  * $Date: 2009-02-25 15:34:48 $
00024  * $Revision: 1.34 $
00025  * $Name: not supported by cvs2svn $
00026  */
00027 
00028 #ifdef HAVE_CONFIG_H
00029 #include <config.h>
00030 #endif
00031 
00032 #include <test_simulate.h>
00033 
00034 #include <fors_instrument.h>
00035 #include <fors_image.h>
00036 #include <fors_dfs.h>
00037 #include <fors_data.h>
00038 #include <fors_pfits.h>
00039 #include <fors_utils.h>
00040 
00041 #include <cpl.h>
00042 
00043 #include <math.h>
00044 
00045 /* FIXME:   - remove FORS_DATA_STD_* !!!
00046  *          - replace below in create_std_cat()
00047  *              1.) by creation of a standard star list, and
00048  *              2.) and a new function fors_std_cat_test_create_stetson()
00049  *                  in fors_std_cat.c
00050  */
00051 const char *const FORS_DATA_STD_MAG[FORS_NUM_FILTER] =
00052 {"U",
00053  "B",
00054  //"G",
00055  "V",  /* G uses V */
00056  "V",
00057  "R",
00058  "I",
00059  "Z"};
00060 
00061 const char *const FORS_DATA_STD_DMAG[FORS_NUM_FILTER] =
00062 {"ERR_U",
00063  "ERR_B",
00064  //"ERR_G",
00065  "ERR_V", /* G uses V */
00066  "ERR_V",
00067  "ERR_R",
00068  "ERR_I",
00069  "ERR_Z"};
00070 
00071 const char *const FORS_DATA_STD_COL[FORS_NUM_FILTER] = 
00072 {"U_B",
00073  "B_V",
00074  "B_V",
00075  "B_V",
00076  "V_R",
00077  "V_R",
00078  "?Z?"};
00079 
00080 const char *const FORS_DATA_STD_RA   = "RA";
00081 const char *const FORS_DATA_STD_DEC  = "DEC";
00082 const char *const FORS_DATA_STD_NAME = "OBJECT";
00083 
00094 static const int det_nx = 400;        /* Unbinned detector pixels */
00095 static const int det_ny = 400;
00096 static const int pres_nx = 5;
00097 static const int binx = 2;
00098 static const int biny = 2;
00099 static const double ron   = 4.0;       /* ADU */
00100 static const double conad = 0.78;   /* e- / ADU */
00101 
00102 static const double bias_avg = 200; /* ADU */
00103 static const double dark_avg = 50;  /* ADU */
00104 static const char *const instrume = "fors2";
00105 static const char *const chip_id = "Test chip 234";
00106 static const char *const read_clock = "200Kps/2ports/low_gain";
00107 
00115 static cpl_frame *
00116 frame_new(const char *filename, const char *tag, cpl_frame_group group)
00117 {
00118     cpl_frame *f = cpl_frame_new();
00119 
00120     cpl_frame_set_filename(f, filename);
00121     cpl_frame_set_tag     (f, tag);
00122     cpl_frame_set_group   (f, group);
00123 
00124     return f;
00125 }
00126 
00132 void
00133 create_standard_keys(cpl_propertylist *header, double exptime)
00134 {
00135     int nx = det_nx / binx;
00136     int ny = det_ny / biny;
00137 
00138     cpl_propertylist_update_string(header, "ESO DPR TYPE", "some");
00139     cpl_propertylist_update_string(header, "ESO TPL ID", "tpl id.");
00140     cpl_propertylist_update_string(header, "ESO INS COLL NAME", "collimator name");
00141     cpl_propertylist_update_string(header, "ARCFILE", "archive filename");
00142     
00143     cpl_propertylist_update_string(header, FORS_PFITS_INSTRUME, instrume);
00144     cpl_propertylist_update_string(header, FORS_PFITS_FILTER_NAME, "R_SPECIAL");
00145 
00146     cpl_propertylist_update_double(header, FORS_PFITS_AIRMASS_START, 1.156);    
00147     cpl_propertylist_update_double(header, FORS_PFITS_AIRMASS_END  , 1.619);    
00148     
00149     cpl_propertylist_update_int   (header, "HIERARCH ESO DET CHIP1 NX", nx);
00150     cpl_propertylist_update_int   (header, "HIERARCH ESO DET CHIP1 NY", ny);
00151     cpl_propertylist_update_int   (header, "HIERARCH ESO DET OUT1 X", 1);
00152     cpl_propertylist_update_int   (header, "HIERARCH ESO DET OUT1 Y", 1);
00153     cpl_propertylist_update_double(header, "HIERARCH ESO DET CHIP1 PSZX", 15.0);
00154     cpl_propertylist_update_double(header, "HIERARCH ESO DET CHIP1 PSZY", 15.0);
00155     cpl_propertylist_update_int   (header, FORS_PFITS_DET_NY, ny);
00156     cpl_propertylist_update_int   (header, FORS_PFITS_DET_NX, nx);
00157     cpl_propertylist_update_int   (header, FORS_PFITS_DET_NY, ny);
00158     cpl_propertylist_update_int   (header, FORS_PFITS_BINX, binx);
00159     cpl_propertylist_update_int   (header, FORS_PFITS_BINY, biny);
00160     cpl_propertylist_update_int   (header, FORS_PFITS_OVERSCANX, 0);
00161     cpl_propertylist_update_int   (header, FORS_PFITS_OVERSCANY, 0);
00162     cpl_propertylist_update_int   (header, FORS_PFITS_PRESCANX, pres_nx);
00163     cpl_propertylist_update_int   (header, FORS_PFITS_PRESCANY, 0);
00164 
00165     cpl_propertylist_update_double(header, FORS_PFITS_PIXSCALE, 0.126);
00166     
00167     cpl_propertylist_update_int(header, FORS_PFITS_OUTPUTS, 1);
00168     cpl_propertylist_update_double(header, FORS_PFITS_CONAD[0], conad);
00169     cpl_propertylist_update_double(header, "HIERARCH ESO DET OUT1 GAIN", 1./conad);
00170     
00171     /* Convert RON to e- units */
00172     cpl_propertylist_update_double(header, FORS_PFITS_RON[0], ron*conad);
00173     cpl_propertylist_update_double(header, FORS_PFITS_EXPOSURE_TIME, exptime);
00174 
00175     cpl_propertylist_update_string(header, FORS_PFITS_CHIP_ID, chip_id);
00176     cpl_propertylist_update_string(header, FORS_PFITS_READ_CLOCK, read_clock);
00177     
00178     /* WCS info, fine tuned to match simulated catalogue */
00179     {
00180         struct {
00181             const char *name;
00182             double value;
00183         } data[] = {
00184             {"CRVAL1", 8.1368333333},
00185             {"CRVAL2", -46.9576388889},
00186             {"CRPIX1", 1},
00187             {"CRPIX2", 1},
00188 //            {"CD1_1", 5.81347849634012E-21}, 
00189 //            {"CD1_2", 9.49444444444444E-05},
00190 //            {"CD2_1",-9.49444444444444E-05}, 
00191 //            {"CD2_2",-5.81347849634012E-21},
00192             {"CD1_1", 5.81347849634012E-20}, 
00193             {"CD1_2", 9.49444444444444E-04},
00194             {"CD2_1",-9.49444444444444E-04}, 
00195             {"CD2_2",-5.81347849634012E-20},
00196             {"PV2_1", 1.0},
00197             {"PV2_2", 0.0},
00198             {"PV2_3", 42.0},
00199             {"PV2_4", 0.0}, 
00200             {"PV2_5", 0.0}
00201         };
00202         
00203         unsigned i;
00204         for (i = 0; i < sizeof(data) / sizeof(*data); i++) {
00205             cpl_propertylist_append_double(header, data[i].name, data[i].value);
00206         }
00207     }
00208     
00209     return;
00210 }
00211 
00212 
00213 #undef cleanup
00214 #define cleanup \
00215 do { \
00216     fors_image_delete(&bias); \
00217     cpl_propertylist_delete(header); \
00218 } while(0)
00219 
00229 cpl_frame *
00230 create_bias(const char *filename, const char *tag, cpl_frame_group group)
00231 {
00232     int nx = det_nx / binx + pres_nx;
00233     int ny = det_ny / biny;
00234     double exptime = 0.0;
00235     
00236     cpl_image *data     = cpl_image_new(nx, ny, FORS_IMAGE_TYPE);
00237     cpl_image *variance = cpl_image_new(nx, ny, FORS_IMAGE_TYPE);
00238     fors_image *bias = NULL;
00239     cpl_propertylist *header = cpl_propertylist_new();
00240     
00241     create_standard_keys(header, exptime);
00242     cpl_propertylist_erase(header, FORS_PFITS_FILTER_NAME); /* No filter */
00243 
00244     {
00245         int x, y;
00246         for (y = 1; y <= ny; y++)
00247             for (x = 1; x <= nx; x++) {
00248                 cpl_image_set(data   , x, y, 
00249                               (int)(bias_avg + ron*fors_rand_gauss() + 0.5));
00250                 cpl_image_set(variance, x, y, ron*ron);
00251             }
00252     }
00253     
00254     bias = fors_image_new(data, variance);
00255     fors_image_save(bias, header, NULL, filename);
00256 
00257     assure( !cpl_error_get_code(), return NULL,
00258             "Saving bias to %s failed", filename );
00259 
00260     cleanup;
00261     return frame_new(filename, tag, group);
00262 }
00263 
00273 cpl_frame *
00274 create_master_bias(const char *filename, const char *tag, cpl_frame_group group)
00275 {
00276     int nx = det_nx / binx;
00277     int ny = det_ny / biny;
00278     double exptime = 0.0;
00279     
00280     cpl_image *data     = cpl_image_new(nx, ny, FORS_IMAGE_TYPE);
00281     cpl_image *variance = cpl_image_new(nx, ny, FORS_IMAGE_TYPE);
00282     fors_image *bias = NULL;
00283     cpl_propertylist *header = cpl_propertylist_new();
00284     
00285     create_standard_keys(header, exptime);
00286     cpl_propertylist_erase(header, FORS_PFITS_FILTER_NAME); /* No filter */
00287     cpl_propertylist_append_double(header, "ESO QC DET OUT1 RON",4.44); /* No filter */
00288 
00289     {
00290         int x, y;
00291         for (y = 1; y <= ny; y++)
00292             for (x = 1; x <= nx; x++) {
00293                 cpl_image_set(data   , x, y, 
00294                               (int)(ron*fors_rand_gauss() + 0.5)); //Overscan already removed
00295                 cpl_image_set(variance, x, y, ron*ron);
00296             }
00297     }
00298     
00299     bias = fors_image_new(data, variance);
00300     fors_image_save(bias, header, NULL, filename);
00301 
00302     assure( !cpl_error_get_code(), return NULL,
00303             "Saving master bias to %s failed", filename );
00304 
00305     cleanup;
00306     return frame_new(filename, tag, group);
00307 }
00308 
00309 #undef cleanup
00310 #define cleanup \
00311 do { \
00312     fors_image_delete(&dark); \
00313     cpl_propertylist_delete(header); \
00314 } while(0)
00315 
00326 cpl_frame *
00327 create_dark(const char *filename, const char *tag, cpl_frame_group group)
00328 {
00329     int nx = det_nx / binx + pres_nx;
00330     int ny = det_ny / biny;
00331     double exptime = 3.0;
00332     
00333     cpl_image *data     = cpl_image_new(nx, ny, FORS_IMAGE_TYPE);
00334     cpl_image *variance = cpl_image_new(nx, ny, FORS_IMAGE_TYPE);
00335     fors_image *dark = NULL;
00336     cpl_propertylist *header = cpl_propertylist_new();
00337     
00338     create_standard_keys(header, exptime);
00339 
00340     {
00341         int x, y;
00342         for (y = 1; y <= ny; y++)
00343             for (x = 1; x <= nx; x++) {
00344                 double var = ron*ron + dark_avg/conad;
00345                 
00346                 cpl_image_set(data   , x, y, 
00347                               (int)(bias_avg + dark_avg + 
00348                                     sqrt(var)*fors_rand_gauss() 
00349                                     + 0.5));
00350                 cpl_image_set(variance, x, y, var);
00351             }
00352         //Fill the prescan region
00353         for (y = 1; y <= ny; y++)
00354             for (x = 1; x <= pres_nx; x++)
00355             {
00356                 cpl_image_set(data   , x, y, 
00357                               (int)(bias_avg + ron*fors_rand_gauss() + 0.5));
00358                 cpl_image_set(variance, x, y, ron*ron);
00359             }
00360     }
00361     
00362     dark = fors_image_new(data, variance);
00363     fors_image_save(dark, header, NULL, filename);
00364 
00365     assure( !cpl_error_get_code(), return NULL, 
00366             "Saving dark to %s failed", filename );
00367     
00368     cleanup;
00369     return frame_new(filename, tag, group);
00370 }
00371 
00372 
00373 #undef cleanup
00374 #define cleanup \
00375 do { \
00376     fors_image_delete(&sflat); \
00377     cpl_propertylist_delete(header); \
00378 } while(0)
00379 
00389 cpl_frame *
00390 create_screen_flat(const char *filename, const char *tag, cpl_frame_group group)
00391 {
00392     int nx = det_nx / binx + pres_nx;
00393     int ny = det_ny / biny;
00394     double exptime = 3.0;
00395 
00396     cpl_image *data     = cpl_image_new(nx, ny, FORS_IMAGE_TYPE);
00397     cpl_image *variance = cpl_image_new(nx, ny, FORS_IMAGE_TYPE);
00398     fors_image *sflat = NULL;
00399     cpl_propertylist *header = cpl_propertylist_new();
00400     
00401     create_standard_keys(header, exptime);
00402 
00403     {
00404         int x, y;
00405         for (y = 1; y <= ny; y++)
00406             for (x = 1; x <= nx; x++) {
00407                 double medium_scale_structure = 1000*(2 + sin(x*30.0/nx + y*30.0/ny));
00408                 double  large_scale_structure = 1000*(1 + sin(x*4.0/nx));
00409                 double flat = 5000 + medium_scale_structure + large_scale_structure;
00410                 double var = ron*ron + flat/conad;
00411                 
00412                 cpl_image_set(data   , x, y, 
00413                               (int)(bias_avg + flat + sqrt(var)*fors_rand_gauss() + 0.5));
00414                 cpl_image_set(variance, x, y, var);
00415             }
00416         //Fill the prescan region
00417         for (y = 1; y <= ny; y++)
00418             for (x = 1; x <= pres_nx; x++)
00419             {
00420                 cpl_image_set(data   , x, y, 
00421                               (int)(bias_avg + ron*fors_rand_gauss() + 0.5));
00422                 cpl_image_set(variance, x, y, ron*ron);
00423             }
00424     }
00425     
00426     sflat = fors_image_new(data, variance);
00427     fors_image_save(sflat, header, NULL, filename);
00428 
00429     assure( !cpl_error_get_code(), return NULL, 
00430             "Saving screen flat to %s failed", filename );
00431     
00432     cleanup;
00433     return frame_new(filename, tag, group);
00434 }
00435 
00436 #undef cleanup
00437 #define cleanup \
00438 do { \
00439     fors_image_delete(&sflat); \
00440     cpl_propertylist_delete(header); \
00441 } while(0)
00442 
00453 cpl_frame *
00454 create_sky_flat(const char *filename, const char *tag, cpl_frame_group group,
00455                 double exptime)
00456 {
00457     int nx = det_nx / binx + pres_nx;
00458     int ny = det_ny / biny;
00459 
00460     cpl_image *data     = cpl_image_new(nx, ny, FORS_IMAGE_TYPE);
00461     cpl_image *variance = cpl_image_new(nx, ny, FORS_IMAGE_TYPE);
00462     fors_image *sflat = NULL;
00463     cpl_propertylist *header = cpl_propertylist_new();
00464     
00465     create_standard_keys(header, exptime);
00466 
00467     {
00468         int x, y;
00469         for (y = 1; y <= ny; y++)
00470             for (x = 1; x <= nx; x++) {
00471                 double medium_scale_structure = 1000*(2 + sin(x*30.0/nx - y*10.0/ny));
00472                 double  large_scale_structure = 1000*(1 + sin(x*4.0/nx));
00473                 double flat = exptime*(5000 + 
00474                                        medium_scale_structure + 
00475                                        large_scale_structure);
00476                 double var = ron*ron + flat/conad;
00477                 
00478                 cpl_image_set(data   , x, y, 
00479                               (int)(flat + sqrt(var)*fors_rand_gauss() + 0.5));//Overscan already removed
00480                 cpl_image_set(variance, x, y, var);
00481             }
00482         //Fill the prescan region
00483         for (y = 1; y <= ny; y++)
00484             for (x = 1; x <= pres_nx; x++)
00485             {
00486                 cpl_image_set(data   , x, y, 
00487                               (int)(bias_avg + ron*fors_rand_gauss() + 0.5));
00488                 cpl_image_set(variance, x, y, ron*ron);
00489             }
00490     }
00491     
00492     sflat = fors_image_new(data, variance);
00493     fors_image_save(sflat, header, NULL, filename);
00494 
00495     assure( !cpl_error_get_code(), return NULL, 
00496             "Saving sky flat to %s failed", filename );
00497 
00498     cleanup;
00499     return frame_new(filename, tag, group);
00500 }
00501 
00513 cpl_frame *
00514 create_master_sky_flat(const char *filename, 
00515                        const char *tag, cpl_frame_group group,
00516                        double exptime)
00517 {
00518     int nx = det_nx / binx;
00519     int ny = det_ny / biny;
00520 
00521     cpl_image *data     = cpl_image_new(nx, ny, FORS_IMAGE_TYPE);
00522     cpl_image *variance = cpl_image_new(nx, ny, FORS_IMAGE_TYPE);
00523     fors_image *sflat = NULL;
00524     cpl_propertylist *header = cpl_propertylist_new();
00525     
00526     create_standard_keys(header, exptime);
00527 
00528     {
00529         int x, y;
00530         for (y = 1; y <= ny; y++)
00531             for (x = 1; x <= nx; x++) {
00532                 double medium_scale_structure = 1000*(2 + sin(x*30.0/nx - y*10.0/ny));
00533                 double  large_scale_structure = 1000*(1 + sin(x*4.0/nx));
00534                 double flat = exptime*(5000 + 
00535                                        medium_scale_structure + 
00536                                        large_scale_structure);
00537                 double var = ron*ron + flat/conad;
00538                 
00539                 cpl_image_set(data   , x, y, 
00540                               (int)(flat + sqrt(var)*fors_rand_gauss() + 0.5));//Overscan already removed
00541                 cpl_image_set(variance, x, y, var);
00542             }
00543     }
00544     
00545     sflat = fors_image_new(data, variance);
00546     fors_image_save(sflat, header, NULL, filename);
00547 
00548     assure( !cpl_error_get_code(), return NULL, 
00549             "Saving sky flat to %s failed", filename );
00550 
00551     cleanup;
00552     return frame_new(filename, tag, group);
00553 }
00554 
00562 cpl_frame *
00563 create_standard(const char *filename, const char *tag, cpl_frame_group group)
00564 {
00565     // fixme: add stars
00566     double exptime = 1.0;
00567     return create_sky_flat(filename, tag, group, exptime);
00568 }
00569 
00570 
00571 #undef cleanup
00572 #define cleanup \
00573 do { \
00574     cpl_table_delete(t); \
00575 } while(0)
00576 
00584 cpl_frame *
00585 create_std_cat(const char *filename, const char *tag, cpl_frame_group group)
00586 {
00587     cpl_table *t;
00588     struct {
00589         double ra, dec;
00590         double magnitude, dmagnitude;
00591         double col;
00592         const char *name;
00593     } 
00594     data[] =  {
00595         {8.15958, -47.0347, 15.824000, 0.001, 0.8, "object 1"},
00596         {8.14792, -46.9664, 12.895000, 0.002, -0.2, ""},
00597         {8.15083, -47.0092, 12.861000, 0.003, -0.3, " dff bject 1"},
00598         {8.15583, -47.0222, 16.540001, 0.001, 0.7, "-9"},
00599         {8.17167, -47.10  , 11.970000, 0.005, 0.12, NULL},
00600         {8.14833, -47.0567, 13.861000, 0.003, -0.2, ""},
00601         {8.1475 , -47.0411, 13.903000, 0.001, -0.8, "dddddddobject 1"},
00602         {7.92542,  2.62917, 15.446000, 0.002, -0.2, "start 1"},
00603     };
00604 
00605     int N = sizeof(data) / sizeof(*data);
00606     int i;
00607 
00608     t = cpl_table_new(N);
00609     cpl_table_new_column(t, FORS_DATA_STD_RA , CPL_TYPE_DOUBLE);
00610     cpl_table_new_column(t, FORS_DATA_STD_DEC, CPL_TYPE_DOUBLE);
00611     cpl_table_new_column(t, FORS_DATA_STD_NAME, CPL_TYPE_STRING);
00612     
00613     for (i = 0; i < FORS_NUM_FILTER; i++) {
00614         if (!cpl_table_has_column(t, FORS_DATA_STD_MAG[i])) {
00615         cpl_table_new_column(t, FORS_DATA_STD_MAG[i], CPL_TYPE_FLOAT);
00616     }
00617         if (!cpl_table_has_column(t, FORS_DATA_STD_DMAG[i])) {
00618         cpl_table_new_column(t, FORS_DATA_STD_DMAG[i], CPL_TYPE_FLOAT);
00619     }
00620         if (!cpl_table_has_column(t, FORS_DATA_STD_COL[i])) {
00621             cpl_table_new_column(t, FORS_DATA_STD_COL[i], CPL_TYPE_FLOAT);
00622         }
00623     }
00624 
00625     for (i = 0; i < N; i++) {
00626         int j;
00627         
00628         cpl_table_set_double(t, FORS_DATA_STD_RA  , i, data[i].ra);
00629         cpl_table_set_double(t, FORS_DATA_STD_DEC , i, data[i].dec);
00630         cpl_table_set_string(t, FORS_DATA_STD_NAME, i, data[i].name);
00631         
00632         for (j = 0; j < FORS_NUM_FILTER; j++) {
00633             cpl_table_set_float (t, FORS_DATA_STD_MAG[j], i, data[i].magnitude);
00634             cpl_table_set_float (t, FORS_DATA_STD_DMAG[j], i, data[i].dmagnitude);
00635             cpl_table_set_float (t, FORS_DATA_STD_COL[j], i, data[i].col);
00636         }
00637     }
00638 
00639     cpl_table_save(t, NULL, NULL, filename, CPL_IO_DEFAULT);
00640     assure( !cpl_error_get_code(), return NULL, 
00641             "Failed to save standard catalogue to %s", filename );
00642     
00643     cleanup;
00644     return frame_new(filename, tag, group);
00645 }
00646 
00647 
00648 
00649 #undef cleanup
00650 #define cleanup \
00651 do { \
00652     cpl_table_delete(t); \
00653 } while(0)
00654 
00662 cpl_frame *
00663 create_phot_table(const char *filename, const char *tag, cpl_frame_group group)
00664 {
00665     cpl_table *t;
00666     struct {
00667         char    band;
00668         double ext_coeff, dext_coeff;
00669         double color_term, dcolor_term;
00670         double expected_zeropoint, dexpected_zeropoint;
00671     } 
00672     data[FORS_NUM_FILTER] = {
00673         {'U', 0.4  , 0.01, -0.076, 0.001, 20, 0.2},
00674         {'B', 0.05 , 0.01,  0.033, 0.001, 21.123456, 0.2},
00675         {'G', 0.1  , 0.01,  0.01 , 0.001, 22, 0.2},
00676         {'V', 0.09 , 0.01, -0.02 , 0.001, -18, 0.2},
00677         {'R', 0.2  , 0.01,  0.03 , 0.001, 0, 0.2},
00678         {'I', 0.000, 0.01, -0.04 , 0.001, 1.0, 0.2},
00679     };
00680     
00681     int N = fors_instrument_known_filters_get_number();
00682     int i;
00683     
00684     t = cpl_table_new(N);
00685     cpl_table_new_column(t, FORS_DATA_PHOT_FILTER   , CPL_TYPE_STRING);
00686     cpl_table_new_column(t, FORS_DATA_PHOT_EXTCOEFF , CPL_TYPE_DOUBLE);
00687     cpl_table_new_column(t, FORS_DATA_PHOT_DEXTCOEFF , CPL_TYPE_DOUBLE);
00688     cpl_table_new_column(t, FORS_DATA_PHOT_COLORTERM, CPL_TYPE_DOUBLE);
00689     cpl_table_new_column(t, FORS_DATA_PHOT_DCOLORTERM, CPL_TYPE_DOUBLE);
00690     cpl_table_new_column(t, FORS_DATA_PHOT_ZEROPOINT, CPL_TYPE_DOUBLE);
00691     cpl_table_new_column(t, FORS_DATA_PHOT_DZEROPOINT, CPL_TYPE_DOUBLE);
00692 
00693     /* For each filtername (e.g. "U_BESS") find the matching filter (e.g. FILTER_U) */
00694     for (i = 0; i < N; i++) {
00695         cpl_table_set_string(       t,
00696                                     FORS_DATA_PHOT_FILTER,
00697                                     i,
00698                                     fors_instrument_known_filters_get_name(i));
00699 
00700         unsigned j;
00701         for (j = 0; j < FORS_NUM_FILTER; j++) {
00702             if (fors_instrument_known_filters_get_band(i) == data[j].band)
00703             {
00704                 cpl_table_set_double(t, FORS_DATA_PHOT_EXTCOEFF , i, data[j].ext_coeff);
00705                 cpl_table_set_double(t, FORS_DATA_PHOT_DEXTCOEFF , i, data[j].dext_coeff);
00706                 cpl_table_set_double(t, FORS_DATA_PHOT_COLORTERM, i, data[j].color_term);
00707                 cpl_table_set_double(t, FORS_DATA_PHOT_DCOLORTERM, i, data[j].dcolor_term);
00708                 cpl_table_set_double(t, FORS_DATA_PHOT_ZEROPOINT, i, data[j].expected_zeropoint);
00709                 cpl_table_set_double(t, FORS_DATA_PHOT_DZEROPOINT, i, data[j].dexpected_zeropoint);
00710             }
00711         }
00712     }
00713 
00714     cpl_table_save(t, NULL, NULL, filename, CPL_IO_DEFAULT);
00715     assure( !cpl_error_get_code(), return NULL, 
00716             "Failed to save photometry table to %s", filename );
00717     
00718     cleanup;
00719     return frame_new(filename, tag, group);
00720 }

Generated on 12 Feb 2016 for FORS Pipeline Reference Manual by  doxygen 1.6.1