uves_cal_lingain.c

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

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