naco_img_lingain.c

00001 /* $Id: naco_img_lingain.c,v 1.9 2008/08/22 11:46:46 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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00019  */
00020 
00021 /*
00022  * $Author: llundin $
00023  * $Date: 2008/08/22 11:46:46 $
00024  * $Revision: 1.9 $
00025  * $Name: HEAD $
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 static cpl_error_code naco_img_lingain_fill_parameterlist(cpl_parameterlist *);
00067 
00068 CPL_RECIPE_DEFINE(naco_img_lingain, NACO_BINARY_VERSION,
00069                   naco_img_lingain_fill_parameterlist(recipe->parameters),
00070                   "Lars Lundin", PACKAGE_BUGREPORT, "2007", 
00071                   "Linearity/Gain recipe for the IR domain",
00072                   irplib_detmon_lg_get_description(RECIPE_NAME, "NACO",
00073                                                    NACO_IMG_LINGAIN_ON_RAW,
00074                                                    NACO_IMG_LINGAIN_OFF_RAW));
00075 
00076 /*----------------------------------------------------------------------------*/
00080 /*----------------------------------------------------------------------------*/
00081 
00082 /*-----------------------------------------------------------------------------
00083                                 Functions code
00084  -----------------------------------------------------------------------------*/
00085 
00086 
00087 
00088 /*---------------------------------------------------------------------------*/
00089 /*
00090   @brief    Interpret the command line options and execute the data processing
00091   @param    frameset    the frames list
00092   @param    parlist     the parameters list
00093   @return   0 iff everything is ok
00094  */
00095 /*---------------------------------------------------------------------------*/
00096 static int naco_img_lingain(cpl_frameset            * frameset,
00097                             const cpl_parameterlist * parlist)
00098 {
00099 
00100     cpl_propertylist * pro_lintbl     = cpl_propertylist_new();
00101     cpl_propertylist * pro_gaintbl    = cpl_propertylist_new();
00102     cpl_propertylist * pro_coeffscube = cpl_propertylist_new();
00103     cpl_propertylist * pro_bpm        = cpl_propertylist_new();
00104     cpl_propertylist * pro_corr       = cpl_propertylist_new();
00105     cpl_propertylist * pro_diff       = cpl_propertylist_new();
00106     cpl_error_code     error = CPL_ERROR_NONE;
00107 
00108     error |= cpl_propertylist_append_string(pro_lintbl, "ESO PRO CATG",
00109                                             "DET_LIN_INFO");
00110     error |= cpl_propertylist_append_string(pro_gaintbl, "ESO PRO CATG",
00111                                             "GAIN_INFO");
00112     error |= cpl_propertylist_append_string(pro_coeffscube, "ESO PRO CATG",
00113                                             "COEFFS_CUBE");
00114     error |= cpl_propertylist_append_string(pro_bpm, "ESO PRO CATG",
00115                                             "BP_MAP_NL");
00116     error |= cpl_propertylist_append_string(pro_corr, "ESO PRO CATG",
00117                                             "AUTOCORR");
00118     error |= cpl_propertylist_append_string(pro_diff, "ESO PRO CATG",
00119                                             "DIFF_FLAT");
00120 
00121     error |= irplib_detmon_lg(frameset,
00122                               parlist,
00123                               NACO_IMG_LINGAIN_ON_RAW,
00124                               NACO_IMG_LINGAIN_OFF_RAW,
00125                               RECIPE_NAME,
00126                               PACKAGE,
00127                               PAFREGEXP,
00128                               pro_lintbl,
00129                               pro_gaintbl,
00130                               pro_coeffscube,
00131                               pro_bpm,
00132                               pro_corr,
00133                               pro_diff,
00134                               PACKAGE "/" PACKAGE_VERSION,
00135                               NULL, NULL, NIR);
00136 
00137     cpl_propertylist_delete(pro_lintbl);
00138     cpl_propertylist_delete(pro_gaintbl);
00139     cpl_propertylist_delete(pro_coeffscube);
00140     cpl_propertylist_delete(pro_bpm);
00141     cpl_propertylist_delete(pro_corr);
00142     cpl_propertylist_delete(pro_diff);
00143 
00144     /* Propagate the error, if any */
00145     cpl_ensure_code(!error, cpl_error_get_code());
00146 
00147     return CPL_ERROR_NONE;
00148 }
00149 
00150 
00151 
00152 /*---------------------------------------------------------------------------*/
00153 /*
00154   @internal
00155   @brief    Fill the parameterlist including NACO specific defaults
00156   @param    self     The parameter list to fill
00157   @return   0 if everything is ok
00158  */
00159 /*---------------------------------------------------------------------------*/
00160 static
00161 cpl_error_code naco_img_lingain_fill_parameterlist(cpl_parameterlist * self)
00162 {
00163 
00164     cpl_error_code error =
00165         irplib_detmon_lg_fill_parlist_nir_default(self, RECIPE_NAME, PACKAGE);
00166     cpl_parameter * p;
00167 
00168     cpl_ensure_code(!error, error);
00169 
00170     /* FIXME: Put the parameter names and their new default values in two arrays
00171        and iterate through them */
00172     p = cpl_parameterlist_find(self, PACKAGE "." RECIPE_NAME ".ref_level");
00173 
00174     cpl_ensure_code(p != NULL, CPL_ERROR_DATA_NOT_FOUND);
00175 
00176     error = cpl_parameter_set_default_int(p, NACO_REF_LEVEL);
00177 
00178     cpl_ensure_code(!error, error);
00179 
00180     return CPL_ERROR_NONE;
00181 }

Generated on Wed Mar 9 15:46:17 2011 for NACO Pipeline Reference Manual by  doxygen 1.5.8