fors_detlin.c

00001 /* $Id: fors_detlin.c,v 1.4 2008/09/03 09:45:53 cizzo Exp $
00002  *
00003  * This file is part of the FORS Data Reduction Pipeline
00004  * Copyright (C) 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/09/03 09:45:53 $
00024  * $Revision: 1.4 $
00025  * $Name:  $
00026  */
00027 #ifdef HAVE_CONFIG_H
00028 #include <config.h>
00029 #endif
00030 
00031 /*----------------------------------------------------------------------------
00032                              Includes
00033  ----------------------------------------------------------------------------*/
00034 
00035 #include <cpl.h>
00036 
00037 #include "irplib_detmon.h"
00038 #include "irplib_detmon_lg.h"
00039 #include "irplib_plugin.h"
00040 #include <fors_dfs.h>
00041 
00042 /* Define here the DO.CATG keywords */
00043 #define DETMON_OPT_LG_ON_RAW                    "DETECTOR_CHECK_FLAT"
00044 #define DETMON_OPT_LG_OFF_RAW                        "DETECTOR_CHECK_BIAS"
00045 
00046 #define RECIPE_NAME "fors_detlin"
00047 
00048 #define OPT FALSE
00049 
00050 /*----------------------------------------------------------------------------
00051                                 Functions prototypes
00052  ----------------------------------------------------------------------------*/
00053 
00054 static cpl_error_code
00055 fors_detlin_fill_parlist(cpl_parameterlist *);
00056 
00057 IRPLIB_RECIPE_DEFINE(fors_detlin, FORS_BINARY_VERSION,
00058                      fors_detlin_fill_parlist(recipe->parameters),
00059                      "Lander de Bilbao", "lbilbao@eso.org", "2008", 
00060                      "Linearity/Gain recipe for the optical domain",
00061                      irplib_detmon_lg_get_description("fors_detlin", 
00062                                                       PACKAGE_TARNAME,
00063                                                       DETMON_OPT_LG_ON_RAW,
00064                                                       DETMON_OPT_LG_OFF_RAW));
00065 
00066 /*---------------------------------------------------------------------------*/
00067 /*
00068   @brief    Interpret the command line options and execute the data processing
00069   @param    frameset    the frames list
00070   @param    parlist     the parameters list
00071   @return   0 if everything is ok
00072  */
00073 /*---------------------------------------------------------------------------*/
00074 
00075 static int fors_detlin(cpl_frameset            * frameset,
00076                          const cpl_parameterlist * parlist)
00077 {
00078     cpl_propertylist * lintbl = 
00079         irplib_detmon_fill_prolist("DET_LIN_INFO", "TYPE", "TECH", CPL_TRUE);
00080 
00081     cpl_propertylist * gaintbl = 
00082         irplib_detmon_fill_prolist("GAIN_INFO",    "TYPE", "TECH", CPL_TRUE);
00083 
00084     cpl_propertylist * coeffscube = 
00085         irplib_detmon_fill_prolist("COEFFS_CUBE",  "TYPE", "TECH", CPL_TRUE);
00086 
00087     cpl_propertylist * bpm = 
00088         irplib_detmon_fill_prolist("BP_MAP_NL",    "TYPE", "TECH", CPL_TRUE);
00089 
00090     cpl_propertylist * corr = 
00091         irplib_detmon_fill_prolist("AUTOCORR",     "TYPE", "TECH", CPL_TRUE);
00092 
00093     cpl_propertylist * diff_flat = 
00094         irplib_detmon_fill_prolist("DIFF_FLAT",    "TYPE", "TECH", CPL_TRUE);
00095 
00096     const cpl_error_code error = irplib_detmon_lg(frameset,
00097                                                   parlist,
00098                                                   DETMON_OPT_LG_ON_RAW,
00099                                                   DETMON_OPT_LG_OFF_RAW,
00100                                                   RECIPE_NAME,
00101                                                   PACKAGE_TARNAME,
00102                                                   REGEXP,
00103                                                   lintbl, gaintbl, coeffscube,
00104                                                   bpm, corr, diff_flat,
00105                                                   PACKAGE "/" PACKAGE_VERSION,
00106                                                   NULL, NULL, OPT);
00107 
00108     cpl_propertylist_delete(lintbl);
00109     cpl_propertylist_delete(gaintbl);
00110     cpl_propertylist_delete(coeffscube);
00111     cpl_propertylist_delete(bpm);
00112     cpl_propertylist_delete(corr);
00113     cpl_propertylist_delete(diff_flat);
00114 
00115     {
00116         /*
00117          * This part is added until ticket DFS05711 is fixed.
00118          */
00119 
00120         cpl_image *chipmap;
00121         cpl_image *badpixmap;
00122         int        llx = dfs_get_parameter_int(parlist, 
00123                          PACKAGE_TARNAME "." RECIPE_NAME ".llx", NULL);
00124         int        lly = dfs_get_parameter_int(parlist, 
00125                          PACKAGE_TARNAME "." RECIPE_NAME ".lly", NULL);
00126 
00127         badpixmap = dfs_load_image(frameset, "BP_MAP_NL", CPL_TYPE_FLOAT, 0, 1);
00128         chipmap = cpl_image_new(2048, 1024, CPL_TYPE_FLOAT);
00129         cpl_image_copy(chipmap, badpixmap, llx, lly - 5);
00130         cpl_image_delete(badpixmap);
00131         dfs_save_image(frameset, chipmap, "BP_MAP_NL_FULL", NULL, parlist, 
00132                        RECIPE_NAME, PACKAGE "/" PACKAGE_VERSION);
00133         cpl_image_delete(chipmap);
00134     }
00135 
00136     /* Propagate the error, if any */
00137     cpl_ensure_code(!error, error);
00138 
00139     return CPL_ERROR_NONE;
00140 }
00141 
00142 static cpl_error_code
00143 fors_detlin_fill_parlist(cpl_parameterlist * parlist)
00144 {
00145     cpl_error_code error;
00146     cpl_parameter * p;
00147 
00148     error = irplib_detmon_lg_fill_parlist_opt_default(parlist,
00149                                               "fors_detlin", PACKAGE_TARNAME);
00150 
00151     cpl_ensure_code(!error, error);
00152 
00153  
00154     p = cpl_parameterlist_find(parlist, 
00155                                PACKAGE_TARNAME "." RECIPE_NAME ".tolerance");
00156     cpl_ensure_code(p != NULL, CPL_ERROR_DATA_NOT_FOUND);
00157     error = cpl_parameter_set_default_double(p, 0.1);
00158     cpl_ensure_code(!error, error);
00159 
00160     p = cpl_parameterlist_find(parlist,
00161                                PACKAGE_TARNAME "." RECIPE_NAME ".pix2pix");
00162     cpl_ensure_code(p != NULL, CPL_ERROR_DATA_NOT_FOUND);
00163     error = cpl_parameter_set_default_bool(p, 1);
00164     cpl_ensure_code(!error, error);
00165 
00166     p = cpl_parameterlist_find(parlist,
00167                                PACKAGE_TARNAME "." RECIPE_NAME ".order");
00168     cpl_ensure_code(p != NULL, CPL_ERROR_DATA_NOT_FOUND);
00169     error = cpl_parameter_set_default_int(p, 2);
00170     cpl_ensure_code(!error, error);
00171 
00172     p = cpl_parameterlist_find(parlist,
00173                                PACKAGE_TARNAME "." RECIPE_NAME ".kappa");
00174     cpl_ensure_code(p != NULL, CPL_ERROR_DATA_NOT_FOUND);
00175     error = cpl_parameter_set_default_int(p, 4);
00176     cpl_ensure_code(!error, error);
00177 
00178     p = cpl_parameterlist_find(parlist,
00179                                PACKAGE_TARNAME "." RECIPE_NAME ".llx");
00180     cpl_ensure_code(p != NULL, CPL_ERROR_DATA_NOT_FOUND);
00181     error = cpl_parameter_set_default_int(p, 1);
00182     cpl_ensure_code(!error, error);
00183 
00184     p = cpl_parameterlist_find(parlist,
00185                                PACKAGE_TARNAME "." RECIPE_NAME ".urx");
00186     cpl_ensure_code(p != NULL, CPL_ERROR_DATA_NOT_FOUND);
00187     error = cpl_parameter_set_default_int(p, 2048);
00188     cpl_ensure_code(!error, error);
00189 
00190     p = cpl_parameterlist_find(parlist,
00191                                PACKAGE_TARNAME "." RECIPE_NAME ".lly");
00192     cpl_ensure_code(p != NULL, CPL_ERROR_DATA_NOT_FOUND);
00193     error = cpl_parameter_set_default_int(p, 6);
00194     cpl_ensure_code(!error, error);
00195 
00196     p = cpl_parameterlist_find(parlist,
00197                                PACKAGE_TARNAME "." RECIPE_NAME ".ury");
00198     cpl_ensure_code(p != NULL, CPL_ERROR_DATA_NOT_FOUND);
00199     error = cpl_parameter_set_default_int(p, 1030);
00200     cpl_ensure_code(!error, error);
00201 
00202 /*
00203     p = cpl_parameterlist_find(parlist,
00204                                PACKAGE_TARNAME "." RECIPE_NAME ".method");
00205     cpl_ensure_code(p != NULL, CPL_ERROR_DATA_NOT_FOUND);
00206     error = cpl_parameter_set_default_string(p, "MED");
00207     cpl_ensure_code(!error, error);
00208 */
00209 
00210     return error;
00211 
00212 }

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