sinfo_rec_lingain.c

00001 /* $Id: sinfo_rec_lingain.c,v 1.21 2009/09/11 10:14:37 amodigli 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: amodigli $
00023  * $Date: 2009/09/11 10:14:37 $
00024  * $Revision: 1.21 $
00025  * $Name: sinfo-2_2_5 $
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 #include "sinfo_irplib_cpl_wrp.h"
00038 
00039 #include "sinfo_msg.h"
00040 #include "sinfo_utils_wrappers.h"
00041 #include "sinfo_error.h"
00042 
00043 /* Define here the DO.CATG keywords */
00044 #define SINFO_LINGAIN_ON_RAW                    "LINEARITY_LAMP_ON"
00045 #define SINFO_LINGAIN_OFF_RAW           "LINEARITY_LAMP_OFF"
00046 
00047 #define RECIPE_NAME "sinfo_rec_lingain"
00048 
00049 /* Copy here instrument specific keywords which need to be in the PAF file */
00050 #define INSTREGEXP   "ESO INS SETUP ID"
00051 
00052 #define PAFREGEXP    "^(" REGEXP "|" INSTREGEXP ")$"
00053 #define NIR TRUE
00054 #define SINFO_BPMBIN 1
00055 #define SINFO_KAPPA 9
00056 
00057 
00058 /*----------------------------------------------------------------------------
00059                  Functions prototypes
00060  ----------------------------------------------------------------------------*/
00061 
00062 /*---------------------------------------------------------------------------*/
00066 /*---------------------------------------------------------------------------*/
00069 cpl_error_code
00070 sinfo_lingain_fill_parlist_default(cpl_parameterlist * parlist);
00071 
00072 CPL_RECIPE_DEFINE(sinfo_rec_lingain, SINFONI_BINARY_VERSION,
00073              /* Replace DETMON_BINARY_VERSION with
00074             corresponding pipeline macro */
00075                      sinfo_lingain_fill_parlist_default(recipe->parameters),
00076              /* Replace "sinfoni" with PACKAGE_TARNAME
00077             when moved into SINFONI */
00078                      "Lander de Bilbao", "lbilbao@eso.org", "2008",
00079                      "Linearity/Gain recipe for the IR domain",
00080                      LG_DESCR(RECIPE_NAME, "SINFONI",
00081                                                       SINFO_LINGAIN_ON_RAW,
00082                                                       SINFO_LINGAIN_OFF_RAW));
00083 
00084 /*---------------------------------------------------------------------------*/
00085 /*
00086   @brief    Interpret the command line options and execute the data processing
00087   @param    frameset    the frames list
00088   @param    parlist     the parameters list
00089   @return   0 if everything is ok
00090  */
00091 /*---------------------------------------------------------------------------*/
00092 
00093 static int sinfo_rec_lingain(cpl_frameset            * frameset,
00094              const cpl_parameterlist * parlist)
00095 {
00096   const char* name_o=NULL;
00097   cpl_frame* frm=NULL;
00098   cpl_image* ima=NULL;
00099   cpl_error_code error = CPL_ERROR_NONE;
00100   cpl_propertylist* plist=NULL;
00101    cpl_propertylist * lintbl;
00102    cpl_propertylist * gaintbl;
00103    cpl_propertylist * coeffscube;
00104    cpl_propertylist * bpm;
00105    cpl_propertylist * corr;
00106    cpl_propertylist * diff_flat;
00107 
00108 
00109    lintbl =  DETMON_FILL_PROLIST("DET_LIN_INFO", "TYPE", "TECH", CPL_TRUE);
00110    gaintbl = DETMON_FILL_PROLIST("GAIN_INFO",    "TYPE", "TECH", CPL_TRUE);
00111    coeffscube = DETMON_FILL_PROLIST("COEFFS_CUBE",  "TYPE", "TECH", CPL_TRUE);
00112    bpm = DETMON_FILL_PROLIST("BP_MAP_NL",    "TYPE", "TECH", CPL_TRUE);
00113    corr = DETMON_FILL_PROLIST("AUTOCORR",     "TYPE", "TECH", CPL_TRUE);
00114    diff_flat = DETMON_FILL_PROLIST("DIFF_FLAT",    "TYPE", "TECH", CPL_TRUE);
00115 
00116    error = DETMON_LG(frameset,
00117                                                   parlist,
00118                                                   SINFO_LINGAIN_ON_RAW,
00119                                                   SINFO_LINGAIN_OFF_RAW,
00120                                                   RECIPE_NAME,
00121     /* Replace this string ("sinfoni") with */    PACKAGE_TARNAME,
00122     /* PACKAGE_TARNAME when moved into SINFONI */ PAFREGEXP,
00123                                                   lintbl, gaintbl,
00124                                               coeffscube, bpm,
00125                           corr, diff_flat,
00126                                                   PACKAGE "/" PACKAGE_VERSION,
00127                                                   NULL, NULL, NIR);
00128     sinfo_free_propertylist(&lintbl);
00129     sinfo_free_propertylist(&gaintbl);
00130     sinfo_free_propertylist(&coeffscube);
00131     sinfo_free_propertylist(&bpm);
00132     sinfo_free_propertylist(&corr);
00133     sinfo_free_propertylist(&diff_flat);
00134 
00135     check_nomsg(frm=cpl_frameset_find(frameset,"BP_MAP_NL"));
00136     check_nomsg(name_o=cpl_frame_get_filename(frm));
00137     check_nomsg(plist=cpl_propertylist_load(name_o,0));
00138     check_nomsg(ima=cpl_image_load(name_o,CPL_TYPE_FLOAT,0,0));
00139     check_nomsg(cpl_image_threshold(ima,0.1,0.9,1,0));
00140     check_nomsg(cpl_image_save(ima,name_o,CPL_BPP_IEEE_FLOAT,plist,CPL_IO_DEFAULT));
00141 
00142   cleanup:
00143     sinfo_free_propertylist(&plist);
00144     sinfo_free_image(&ima);
00145 
00146     /* Propagate the error, if any */
00147     cpl_ensure_code(!error, error);
00148 
00149     return CPL_ERROR_NONE;
00150 }
00151 
00152 cpl_error_code
00153 sinfo_lingain_fill_parlist_default(cpl_parameterlist * parlist)
00154 {
00155 
00156    cpl_error_code error = CPL_ERROR_NONE;
00157    cpl_parameter * p;
00158    error = DETMON_LG_FILL_PARLIST_NIR_DEFAULT(parlist,RECIPE_NAME,
00159                                                  PACKAGE_TARNAME);
00160     cpl_ensure_code(!error, error);
00161     p = cpl_parameterlist_find(parlist, PACKAGE_TARNAME "." RECIPE_NAME ".bpmbin");
00162     cpl_ensure_code(p != NULL, CPL_ERROR_DATA_NOT_FOUND);
00163     error = cpl_parameter_set_default_bool(p, SINFO_BPMBIN);
00164     p = cpl_parameterlist_find(parlist, PACKAGE_TARNAME "." RECIPE_NAME ".kappa");
00165     cpl_ensure_code(p != NULL, CPL_ERROR_DATA_NOT_FOUND);
00166     error = cpl_parameter_set_default_double(p, SINFO_KAPPA);
00167     cpl_ensure_code(!error, error);
00168     return error;
00169 
00170 }
00171 

Generated on 8 Mar 2011 for SINFONI Pipeline Reference Manual by  doxygen 1.6.1