uves_cal_lingain.c

00001 /* $Id: uves_cal_lingain.c,v 1.11 2008/03/28 08:47:06 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: 2008/03/28 08:47:06 $
00024  * $Revision: 1.11 $
00025  * $Name: uves-4_2_2 $
00026  */
00027 
00028 #ifdef HAVE_CONFIG_H
00029 #include <config.h>
00030 #endif
00031 
00032 /*----------------------------------------------------------------------------
00033                              Includes and Defines
00034  ----------------------------------------------------------------------------*/
00035 #include <stdbool.h>
00036 
00037 #include <cpl.h>
00038 
00039 #include "irplib_detmon_lg.h"
00040 #include "uves_plugin.h"
00041 //#include "uves_chip_type.h"
00042 #include "uves_dfs.h"
00043 #include "uves_msg.h"
00044 #include "uves_error.h"
00045 #include "uves_utils.h"
00046 #include "uves_utils_wrappers.h"
00047 
00048 /* Define here the DO.CATG keywords */
00049 
00050 #define UVES_LINGAIN_ON_RAW(it) ((it) == 0 ? "SCREEN_FLAT_DETCHAR_RED" : \
00051                                  (it) == 1 ? "SCREEN_FLAT_DETCHAR_BLUE" : \
00052                                  "???")
00053 
00054 #define UVES_LINGAIN_OFF_RAW(it) ((it) == 0 ? "BIAS_DETCHAR_RED" : \
00055                                   (it) == 1 ? "BIAS_DETCHAR_BLUE" : "???")
00056 
00057 #define UVES_LINGAIN_DET_LIN_INFO(it) ((it) == 0 ? "DET_LIN_INFO_RED" : \
00058                                        (it) == 1 ? "DET_LIN_INFO_BLUE" : "???")
00059 
00060 #define UVES_LINGAIN_GAIN_INFO(it) ((it) == 0 ? "GAIN_INFO_RED" : \
00061                                     (it) == 1 ? "GAIN_INFO_BLUE" : "???")
00062 
00063 #define UVES_LINGAIN_COEFFS_CUBE(it) ((it) == 0 ? "COEFFS_CUBE_RED" : \
00064                                       (it) == 1 ? "COEFFS_CUBE_BLUE" : "???")
00065 
00066 #define UVES_LINGAIN_BP_MAP_NL(it) ((it) == 0 ? "BP_MAP_NL_RED" : \
00067                                     (it) == 1 ? "BP_MAP_NL_BLUE" : "???")
00068 
00069 #define UVES_LINGAIN_AUTOCORR(it) ((it) == 0 ? "AUTOCORR_RED" : \
00070                                    (it) == 1 ? "AUTOCORR_BLUE" : "???")
00071 
00072 #define UVES_LINGAIN_DIFF_FLAT(it) ((it) == 0 ? "DIFF_FLAT_RED" : \
00073                                     (it) == 1 ? "DIFF_FLAT_BLUE" : "???")
00074 
00075 #define RECIPE_NAME "uves_cal_lingain"
00076 
00077 /* Copy here instrument specific keywords which need to be in the PAF file */
00078 #define INSTREGEXP   "ESO INS SETUP ID"
00079 
00080 #define PAFREGEXP    "^(" REGEXP "|" INSTREGEXP ")$"
00081 
00082 #define OPT FALSE
00083 #define UVES_PIX2PIX CPL_TRUE
00084 #define UVES_EXTS_RED -1
00085 /*----------------------------------------------------------------------------
00086                  Functions prototypes
00087  ----------------------------------------------------------------------------*/
00088 
00089 cpl_error_code
00090 uves_cal_lingain_fill_parlist_default(cpl_parameterlist * parlist);
00091 
00092 UVES_IRPLIB_RECIPE_DEFINE(uves_cal_lingain, UVES_BINARY_VERSION,
00093              /* Replace DETMON_BINARY_VERSION with
00094             corresponding pipeline macro */
00095                      uves_cal_lingain_fill_parlist_default(recipe->parameters),
00096              /* Replace "uves" with PACKAGE_TARNAME
00097             when moved into UVES */
00098                      "Lander de Bilbao", PACKAGE_BUGREPORT, "2008", 
00099                      "Linearity/Gain recipe for the optical domain",
00100                      irplib_detmon_lg_get_description(RECIPE_NAME, "UVES",
00101                                                       "FLAT_BLUE",
00102                                                       "FLAT_RED"));
00103 
00104 
00105 /*---------------------------------------------------------------------------*/
00106 /*
00107   @brief    Interpret the command line options and execute the data processing
00108   @param    frameset    the frames list
00109   @param    parlist     the parameters list
00110   @return   0 if everything is ok
00111  */
00112 /*---------------------------------------------------------------------------*/
00113 
00114 static int 
00115 uves_cal_lingain(cpl_frameset            * frameset,
00116                  const cpl_parameterlist * parlist)
00117 {
00118 
00119 
00120    int red;
00121    bool found_bias = false;
00122    bool found_flat = false;
00123    cpl_error_code error=0;
00124    int processed=0;
00125    cpl_parameter* p=NULL;
00126    cpl_parameterlist* plist=NULL;
00127 
00128    check_nomsg(plist=uves_parameterlist_duplicate(parlist));
00129 
00130    for (red = 0; red <= 1; red++){
00131 
00132       found_bias = cpl_frameset_find(frameset, UVES_LINGAIN_ON_RAW(red));
00133       found_flat = cpl_frameset_find(frameset, UVES_LINGAIN_OFF_RAW(red));
00134 
00135       if((found_bias) && (found_flat)) {
00136 
00137         if(red == 0) {
00138            uves_msg("Update exts param for RED ARM data");
00139       
00140            check_nomsg(p=cpl_parameterlist_find(plist,PACKAGE "." RECIPE_NAME ".exts"));
00141 
00142            cpl_ensure_code(p != NULL, CPL_ERROR_DATA_NOT_FOUND);
00143            check_nomsg(error = cpl_parameter_set_int(p, UVES_EXTS_RED));
00144            cpl_ensure_code(!error, error);
00145 
00146 
00147 
00148 
00149          }
00150          processed++;
00151 
00152          check_nomsg(error = irplib_detmon_lg(frameset,
00153                                               plist,
00154                                               UVES_LINGAIN_ON_RAW(red),
00155                                               UVES_LINGAIN_OFF_RAW(red),
00156                                               RECIPE_NAME,
00157                                               "uves",
00158                                               PAFREGEXP,
00159                                               UVES_LINGAIN_DET_LIN_INFO(red),
00160                                               UVES_LINGAIN_GAIN_INFO(red),
00161                                               UVES_LINGAIN_COEFFS_CUBE(red), 
00162                                               UVES_LINGAIN_BP_MAP_NL(red),
00163                                               UVES_LINGAIN_AUTOCORR(red), 
00164                                               UVES_LINGAIN_DIFF_FLAT(red),
00165                                               PACKAGE "/" PACKAGE_VERSION,
00166                                               NULL, NULL, OPT));
00167 
00168 
00169       }
00170    }
00171    if(processed>0) {
00172       /* Propagate the error, if any */
00173       cpl_ensure_code(!error, error);
00174    } else {
00175       uves_msg("No data has been processed.");
00176       uves_msg("Pls check if input frame set contains valid tags");
00177    }
00178 
00179 
00180   cleanup:
00181    //uves_free_parameterlist(&plist);
00182 
00183    return CPL_ERROR_NONE;
00184 }
00185 
00186 cpl_error_code
00187 uves_cal_lingain_fill_parlist_default(cpl_parameterlist * parlist)
00188 {
00189 
00190     cpl_error_code error =
00191         irplib_detmon_lg_fill_parlist_opt_default(parlist, RECIPE_NAME, PACKAGE);
00192     cpl_parameter * p;
00193 
00194     cpl_ensure_code(!error, error);
00195 
00196     /* FIXME: Put the parameter names and their new default values in two arrays
00197        and iterate through them */
00198     p = cpl_parameterlist_find(parlist, PACKAGE "." RECIPE_NAME ".pix2pix");
00199 
00200     cpl_ensure_code(p != NULL, CPL_ERROR_DATA_NOT_FOUND);
00201 
00202     error = cpl_parameter_set_default_bool(p, UVES_PIX2PIX);
00203 
00204 
00205     cpl_ensure_code(!error, error);
00206 
00207     return CPL_ERROR_NONE;
00208 }
00209 
00210 

Generated on Mon Apr 21 10:56:54 2008 for UVES Pipeline Reference Manual by  doxygen 1.5.1