naco_img_lingain.c

00001 /* $Id: naco_img_lingain.c,v 1.11 2013/03/12 08:03:07 llundin Exp $
00002  *
00003  * This file is part of the DETMON Pipeline
00004  * Copyright (C) 2002,2003 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  02111-1307  USA
00019  */
00020 
00021 /*
00022  * $Author: llundin $
00023  * $Date: 2013/03/12 08:03:07 $
00024  * $Revision: 1.11 $
00025  * $Name: naco-4_3_3 $
00026  */
00027 
00028 #ifdef HAVE_CONFIG_H
00029 #include <config.h>
00030 #endif
00031 
00032 /*----------------------------------------------------------------------------
00033                              Includes and Defines
00034  ----------------------------------------------------------------------------*/
00035 
00036 #include <cpl.h>
00037 
00038 #include "irplib_detmon_lg.h"
00039 #include "irplib_plugin.h"
00040 
00041 /* Define here the DO.CATG keywords */
00042 #define NACO_IMG_LINGAIN_ON_RAW             "CAL_LINGAIN_LAMP"
00043 #define NACO_IMG_LINGAIN_OFF_RAW            "CAL_LINGAIN_DARK"
00044 
00045 #define RECIPE_NAME "naco_img_lingain"
00046 
00047 /* Copy here instrument specific keywords which need to be in the PAF file */
00048 #define INSTREGEXP   "ESO DET MODE NAME|ESO DET NCORRS NAME|" \
00049                      "ESO INS OPTI7 NAME|ESO INS OPTI6 NAME|" \
00050                      "ESO INS OPTI5 NAME|ESO INS OPTI4 NAME"
00051 
00052 #define PAFREGEXP    "^(" REGEXP "|" INSTREGEXP ")$"
00053 
00054 #define NIR TRUE
00055 
00056 #ifndef NACO_REF_LEVEL
00057 /* DFO states that the NACO reference level is in the range 1600 - 4000
00058    with 3500 being the typical level. For one dataset 3500 is too high,
00059    while values below 2300 work. */
00060 #define NACO_REF_LEVEL 2000
00061 #endif
00062 
00063 /*----------------------------------------------------------------------------
00064                  Functions prototypes
00065  ----------------------------------------------------------------------------*/
00066 cpl_recipe_define(naco_img_lingain, NACO_BINARY_VERSION,
00067                   "Lars Lundin", PACKAGE_BUGREPORT, "2007", 
00068                   "Linearity/Gain recipe for the IR domain",
00069                   irplib_detmon_lg_get_description(RECIPE_NAME, "NACO",
00070                                                    NACO_IMG_LINGAIN_ON_RAW,
00071                                                    NACO_IMG_LINGAIN_OFF_RAW));
00072 
00073 /*----------------------------------------------------------------------------*/
00077 /*----------------------------------------------------------------------------*/
00078 
00079 /*-----------------------------------------------------------------------------
00080                                 Functions code
00081  -----------------------------------------------------------------------------*/
00082 
00083 
00084 
00085 /*---------------------------------------------------------------------------*/
00086 /*
00087   @brief    Interpret the command line options and execute the data processing
00088   @param    frameset    the frames list
00089   @param    parlist     the parameters list
00090   @return   0 iff everything is ok
00091  */
00092 /*---------------------------------------------------------------------------*/
00093 static int naco_img_lingain(cpl_frameset            * frameset,
00094                             const cpl_parameterlist * parlist)
00095 {
00096 
00097     cpl_propertylist * pro_lintbl     = cpl_propertylist_new();
00098     cpl_propertylist * pro_gaintbl    = cpl_propertylist_new();
00099     cpl_propertylist * pro_coeffscube = cpl_propertylist_new();
00100     cpl_propertylist * pro_bpm        = cpl_propertylist_new();
00101     cpl_propertylist * pro_corr       = cpl_propertylist_new();
00102     cpl_propertylist * pro_diff       = cpl_propertylist_new();
00103     cpl_error_code     error = CPL_ERROR_NONE;
00104 
00105     error |= cpl_propertylist_append_string(pro_lintbl, "ESO PRO CATG",
00106                                             "DET_LIN_INFO");
00107     error |= cpl_propertylist_append_string(pro_gaintbl, "ESO PRO CATG",
00108                                             "GAIN_INFO");
00109     error |= cpl_propertylist_append_string(pro_coeffscube, "ESO PRO CATG",
00110                                             "COEFFS_CUBE");
00111     error |= cpl_propertylist_append_string(pro_bpm, "ESO PRO CATG",
00112                                             "BP_MAP_NL");
00113     error |= cpl_propertylist_append_string(pro_corr, "ESO PRO CATG",
00114                                             "AUTOCORR");
00115     error |= cpl_propertylist_append_string(pro_diff, "ESO PRO CATG",
00116                                             "DIFF_FLAT");
00117 
00118     error |= irplib_detmon_lg(frameset,
00119                               parlist,
00120                               NACO_IMG_LINGAIN_ON_RAW,
00121                               NACO_IMG_LINGAIN_OFF_RAW,
00122                               RECIPE_NAME,
00123                               PACKAGE,
00124                               PAFREGEXP,
00125                               pro_lintbl,
00126                               pro_gaintbl,
00127                               pro_coeffscube,
00128                               pro_bpm,
00129                               pro_corr,
00130                               pro_diff,
00131                               PACKAGE "/" PACKAGE_VERSION,
00132                               NULL, NULL, NIR);
00133 
00134     cpl_propertylist_delete(pro_lintbl);
00135     cpl_propertylist_delete(pro_gaintbl);
00136     cpl_propertylist_delete(pro_coeffscube);
00137     cpl_propertylist_delete(pro_bpm);
00138     cpl_propertylist_delete(pro_corr);
00139     cpl_propertylist_delete(pro_diff);
00140 
00141     /* Propagate the error, if any */
00142     cpl_ensure_code(!error, cpl_error_get_code());
00143 
00144     return CPL_ERROR_NONE;
00145 }
00146 
00147 
00148 
00149 /*---------------------------------------------------------------------------*/
00150 /*
00151   @internal
00152   @brief    Fill the parameterlist including NACO specific defaults
00153   @param    self     The parameter list to fill
00154   @return   0 if everything is ok
00155  */
00156 /*---------------------------------------------------------------------------*/
00157 static
00158 cpl_error_code naco_img_lingain_fill_parameterlist(cpl_parameterlist * self)
00159 {
00160 
00161     cpl_error_code error =
00162         irplib_detmon_lg_fill_parlist_nir_default(self, RECIPE_NAME, PACKAGE);
00163     cpl_parameter * p;
00164 
00165     cpl_ensure_code(!error, error);
00166 
00167     /* FIXME: Put the parameter names and their new default values in two arrays
00168        and iterate through them */
00169     p = cpl_parameterlist_find(self, PACKAGE "." RECIPE_NAME ".ref_level");
00170 
00171     cpl_ensure_code(p != NULL, CPL_ERROR_DATA_NOT_FOUND);
00172 
00173     error = cpl_parameter_set_default_int(p, NACO_REF_LEVEL);
00174 
00175     cpl_ensure_code(!error, error);
00176 
00177     return CPL_ERROR_NONE;
00178 }

Generated on Tue Mar 12 15:19:53 2013 for NACO Pipeline Reference Manual by  doxygen 1.4.7