uves_cal_ronbias.c

00001 /* $Id: uves_cal_ronbias.c,v 1.5 2008/04/08 07:52:28 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/04/08 07:52:28 $
00024  * $Revision: 1.5 $
00025  * $Name: uves-3_9_0 $
00026  */
00027 #ifdef HAVE_CONFIG_H
00028 #include <config.h>
00029 #endif
00030 
00031 /*----------------------------------------------------------------------------
00032                              Includes
00033  ----------------------------------------------------------------------------*/
00034 #include <stdbool.h>
00035 
00036 #include <cpl.h>
00037 
00038 #include "irplib_detmon.h"
00039 #include "uves_plugin.h"
00040 
00041 
00042 #include "uves_msg.h"
00043 #include "uves_error.h"
00044 #include "uves_utils.h"
00045 #include "uves_utils_wrappers.h"
00046 /* Define here the DO.CATG keywords */
00047 #define REGEXP "ARCFILE|MJD-OBS|ESO TPL ID|DATE-OBS|ESO DET DIT|ESO DET NDIT"
00048 #define RECIPE_NAME "uves_cal_ronbias"
00049 #define UVES_RONBIAS_RAW(it) ((it) == 0 ? "BIAS_RED" : \
00050                               (it) == 1 ? "BIAS_BLUE" : \
00051                                  "???")
00052 
00053 #define UVES_RONBIAS_MASTER_BIAS(it) ((it) == 0 ? "MASTER_BIAS_RED" : \
00054                                        (it) == 1 ? "MASTER_BIAS_BLUE" : "???")
00055 
00056 #define UVES_RONBIAS_INT_XSTRUCT(it) ((it) == 0 ? "INT_XSTRUCT_RED" : \
00057                                       (it) == 1 ? "INT_XSTRUCT_BLUE" : "???")
00058 
00059 
00060 #define UVES_RONBIAS_INT_YSTRUCT(it) ((it) == 0 ? "INT_YSTRUCT_RED" : \
00061                                       (it) == 1 ? "INT_YSTRUCT_BLUE" : "???")
00062 
00063 
00064 #define UVES_RONBIAS_SYNTH(it) ((it) == 0 ? "SYNTH_RED" : \
00065                                 (it) == 1 ? "SYNTH_BLUE" : "???")
00066 
00067 
00068 #define UVES_RONBIAS_BP_MAP_HP(it) ((it) == 0 ? "BP_MAP_HP_RED" : \
00069                                     (it) == 1 ? "BP_MAP_HP_BLUE" : "???")
00070 
00071 
00072 #define UVES_RONBIAS_BP_MAP_CP(it) ((it) == 0 ? "BP_MAP_CP_RED" : \
00073                                     (it) == 1 ? "BP_MAP_CP_BLUE" : "???")
00074 
00075 
00076 #define UVES_RONBIAS_BP_MAP_DP(it) ((it) == 0 ? "BP_MAP_DP_RED" : \
00077                                     (it) == 1 ? "BP_MAP_DP_BLUE" : "???")
00078 
00079 
00080 
00081 #define UVES_PIX2PIX CPL_TRUE
00082 #define UVES_EXTS_RED -1
00083 /*----------------------------------------------------------------------------
00084                 Functions prototypes
00085  ----------------------------------------------------------------------------*/
00086 
00087 UVES_IRPLIB_RECIPE_DEFINE(uves_cal_ronbias, 
00088                      UVES_BINARY_VERSION,
00089                      irplib_detmon_ronbias_fill_parlist_default(recipe->parameters,
00090                                                                 RECIPE_NAME,
00091                                                                 PACKAGE_TARNAME),
00092                      "Lander de Bilbao", PACKAGE_BUGREPORT, "2008",
00093                      "RON/Bias recipe",
00094                      irplib_detmon_ronbias_get_description(RECIPE_NAME,"UVES",
00095                                                            "BIAS_BLUE or BIAS_RED"));
00096 
00097 /*---------------------------------------------------------------------------*/
00098 /*
00099   @brief    Interpret the command line options and execute the data processing
00100   @param    frameset    the frames list
00101   @param    parlist     the parameters list
00102   @return   0 if everything is ok
00103  */
00104 /*---------------------------------------------------------------------------*/
00105 
00106 static int uves_cal_ronbias(cpl_frameset            * frameset,
00107                           const cpl_parameterlist * parlist)
00108 {
00109 
00110 
00111    int red;
00112    bool found_bias = false;
00113    int nbias = 0;
00114 
00115    cpl_error_code error=0;
00116    int processed=0;
00117    cpl_parameter* p=NULL;
00118    cpl_parameterlist* plist=NULL;
00119    cpl_frameset* bset=NULL;
00120 
00121    check_nomsg(plist=uves_parameterlist_duplicate(parlist));
00122 
00123    for (red = 0; red <= 1; red++){
00124 
00125       found_bias = cpl_frameset_find(frameset, UVES_RONBIAS_RAW(red));
00126       if(found_bias) {
00127          check_nomsg(bset=uves_frameset_extract(frameset,UVES_RONBIAS_RAW(red)));
00128          check_nomsg(nbias=cpl_frameset_get_size(bset));
00129          uves_msg("found %d biases",nbias);
00130          if(nbias>1) {
00131             if(red == 0) {
00132                //uves_msg_warning("%s data reduction not supported", 
00133                //                 UVES_RONBIAS_RAW(red));
00134                 
00135                uves_msg("Update exts param for RED ARM data");
00136                 check_nomsg(p=cpl_parameterlist_find(plist,PACKAGE "." RECIPE_NAME ".exts"));
00137 
00138                  cpl_ensure_code(p != NULL, CPL_ERROR_DATA_NOT_FOUND);
00139                  check_nomsg(error = cpl_parameter_set_int(p, UVES_EXTS_RED));
00140                  cpl_ensure_code(!error, error);
00141                
00142 
00143 
00144             }
00145                processed++;
00146 
00147                check_nomsg(error=
00148                            irplib_detmon_ronbias(frameset,
00149                                                  parlist,
00150                                                  UVES_RONBIAS_RAW(red),
00151                                                  RECIPE_NAME,
00152                                                  PACKAGE_TARNAME,
00153                                                  REGEXP,
00154                                                  UVES_RONBIAS_MASTER_BIAS(red),
00155                                                  UVES_RONBIAS_INT_XSTRUCT(red),
00156                                                  UVES_RONBIAS_INT_YSTRUCT(red),
00157                                                  UVES_RONBIAS_SYNTH(red),
00158                                                  UVES_RONBIAS_BP_MAP_HP(red),
00159                                                  UVES_RONBIAS_BP_MAP_CP(red),
00160                                                  UVES_RONBIAS_BP_MAP_DP(red),
00161                                                  PACKAGE "/" PACKAGE_VERSION,
00162                                                  NULL));
00163 
00164             
00165          } else {
00166 
00167             uves_msg("You must provide at least 2 frames tagged as %s",
00168                      UVES_RONBIAS_RAW(red));
00169 
00170          }
00171          uves_free_frameset(&bset);
00172       } else {
00173          uves_msg("You provided no frame tagged as %s",UVES_RONBIAS_RAW(red));
00174       }
00175    }
00176 
00177 
00178   cleanup:
00179    uves_free_frameset(&bset);
00180 
00181    if(processed>0) {
00182       /* Propagate the error, if any */
00183       cpl_ensure_code(!error, error);
00184    } else {
00185       uves_msg("No data has been processed.");
00186       uves_msg("Pls check if input frame set contains valid tags");
00187    }
00188 
00189 
00190 
00191     return CPL_ERROR_NONE;
00192 }
00193 
00194 

Generated on Fri Apr 18 14:11:41 2008 for UVES Pipeline Reference Manual by  doxygen 1.5.1