sinfo_rec_pupil.c

00001 /* $Id: sinfo_rec_pupil.c,v 1.17 2008/02/12 14:56:50 amodigli Exp $
00002  *
00003  * This file is part of the SINFONI 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/02/12 14:56:50 $
00024  * $Revision: 1.17 $
00025  * $Name: sinfo-2_2_5 $
00026  */
00027 
00028  /****************************************************************
00029   *          Wave_Cal Frames Data Reduction                          *
00030   ****************************************************************/
00031 
00032 /*-----------------------------------------------------------------------------
00033                                 Includes
00034  -----------------------------------------------------------------------------*/
00035 
00036 #ifdef HAVE_CONFIG_H
00037 #include <config.h>          /* allows the program compilation */
00038 #endif
00039 
00040 /* std */
00041 #include <strings.h>
00042 #include <string.h>
00043 #include <stdio.h>
00044 
00045 
00046 /* cpl */
00047 #include <cpl.h>      
00048 
00049 /* irplib */
00050 #include <irplib_utils.h>
00051 
00052 
00053 /* sinfoni */
00054 #include <sinfo_pro_types.h>
00055 #include <sinfo_product_config.h>
00056 #include <sinfo_prepare_stacked_frames_config.h>
00057 #include <sinfo_objnod_config.h>
00058 #include <sinfo_raw_types.h>
00059 #include <sinfo_tpl_utils.h>
00060 #include <sinfo_tpl_dfs.h>
00061 #include <sinfo_hidden.h>
00062 #include <sinfo_globals.h>
00063 #include <sinfo_functions.h>
00064 #include <sinfo_msg.h>
00065 #include <sinfo_new_prepare_stacked_frames.h>
00066 #include <sinfo_new_objnod.h>
00067 #include <sinfo_error.h>
00068 #include <sinfo_utils_wrappers.h>
00069 /*-----------------------------------------------------------------------------
00070                             Functions prototypes
00071  -----------------------------------------------------------------------------*/
00072 static int sinfo_rec_pupil_create(cpl_plugin *);
00073 static int sinfo_rec_pupil_exec(cpl_plugin *);
00074 static int sinfo_rec_pupil_destroy(cpl_plugin *);
00075 static int sinfo_rec_pupil(cpl_parameterlist *, cpl_frameset *);
00076 
00077 /*-----------------------------------------------------------------------------
00078                             Static variables
00079  -----------------------------------------------------------------------------*/
00080 static char sinfo_rec_pupil_description1[] =
00081 "This recipe performs science data reduction.\n"
00082 "The input files are science object and sky frames \n"
00083 "with tags OBJECT_NODDING and SKY_NODDING\n"
00084 "Master calibration frames:\n";
00085 
00086 
00087 static char sinfo_rec_pupil_description2[] =
00088 "A corresponding (band,preoptics) wavelength map image with tag WAVE_MAP\n"
00089 "A corresponding (band,preoptics) master flat field with tag MASTER_FLAT_LAMP\n"
00090 "A corresponding (band,preoptics) master bad pixel map with tag MASTER_BP_MAP\n"
00091 "A corresponding (band,preoptics) slitlets position frame with tag SLIT_POS\n"
00092 "A corresponding (band) distortion table with tag DISTORTION\n"
00093 "A corresponding (band) slitlet distance table with tag SLITLETS_DISTANCE\n";
00094 
00095 
00096 static char sinfo_rec_pupil_description3[] =
00097 "The output is an image resulting from the IMA1 op IMA2 where op indicates\n"
00098 "A reference table with the position of the 1st column with tag FIRST_COLUMN\n"
00099 "Relevant outputs are:\n"
00100 "combined cubes (PRO.CATG=x_OBS x=STD,OBJ,PSF)\n"
00101 "reconstructed cube (PRO.CATG=COADD_x_OBS x=STD,OBJ,PSF)\n"
00102 "An average along Z of the reconstructed cube \n"
00103 "(PRO.CATG=MED_x_OBS x=STD,OBJ,PSF)\n"
00104 "The bad pixel map associated to the cube \n"
00105 "(PRO.CATG=BP_MAP_COADD_x_OBS x=STD,OBJ,PSF)\n";
00106 
00107 
00108 static char sinfo_rec_pupil_description4[] =
00109 "Information on relevant parameters can be found with\n"
00110 "esorex --params sinfo_rec_pupil\n"
00111 "esorex --help sinfo_rec_pupil\n"
00112 "\n";
00113 
00114 static char sinfo_rec_pupil_description[1300];
00115 
00116 /*-----------------------------------------------------------------------------
00117                                 Functions code
00118  ----------------------------------------------------------------------------*/
00119 /*---------------------------------------------------------------------------*/
00123 /*---------------------------------------------------------------------------*/
00125 /*---------------------------------------------------------------------------*/
00134 /*---------------------------------------------------------------------------*/
00135 
00136 int
00137 cpl_plugin_get_info(cpl_pluginlist *list)
00138 {
00139 
00140   cpl_recipe *recipe = cpl_calloc(1, sizeof *recipe);
00141   cpl_plugin *plugin = &recipe->interface;
00142 
00143 
00144   strcpy(sinfo_rec_pupil_description,sinfo_rec_pupil_description1);
00145   strcat(sinfo_rec_pupil_description,sinfo_rec_pupil_description2);
00146   strcat(sinfo_rec_pupil_description,sinfo_rec_pupil_description3);
00147   strcat(sinfo_rec_pupil_description,sinfo_rec_pupil_description4);
00148 
00149   cpl_plugin_init(plugin,
00150           CPL_PLUGIN_API,
00151           SINFONI_BINARY_VERSION,
00152           CPL_PLUGIN_TYPE_RECIPE,
00153           "sinfo_rec_pupil",
00154           "Pupil data reduction",
00155           sinfo_rec_pupil_description,
00156           "Andrea Modigliani",
00157           "Andrea.Modigliani@eso.org",
00158           sinfo_get_license(),
00159           sinfo_rec_pupil_create,
00160           sinfo_rec_pupil_exec,
00161           sinfo_rec_pupil_destroy);
00162  
00163   cpl_pluginlist_append(list, plugin);
00164 
00165   return 0;
00166 
00167 }
00168 
00169 /*---------------------------------------------------------------------------*/
00177 /*---------------------------------------------------------------------------*/
00178  
00179 static int sinfo_rec_pupil_create(cpl_plugin *plugin)
00180 {
00181    cpl_recipe      * recipe ;
00182 
00183     /* Check that the plugin is part of a valid recipe */
00184     if (cpl_plugin_get_type(plugin) == CPL_PLUGIN_TYPE_RECIPE) 
00185         recipe = (cpl_recipe *)plugin ;
00186     else return -1 ;
00187     cpl_error_reset();
00188     irplib_reset();
00189 
00190     /* Create the parameters list in the cpl_recipe object */
00191     recipe->parameters = cpl_parameterlist_new() ; 
00192 
00193 
00194   /*
00195    * Fill the parameter list.
00196    */  
00197 
00198   sinfo_product_config_add(recipe->parameters);
00199   sinfo_prepare_stacked_frames_config_add(recipe->parameters);
00200   sinfo_objnod_config_add(recipe->parameters);
00201   return 0;
00202 
00203 }
00204 
00205 /*---------------------------------------------------------------------------*/
00211 /*---------------------------------------------------------------------------*/
00212 
00213 
00214 static int sinfo_rec_pupil_exec(cpl_plugin *plugin)
00215 {
00216 
00217   cpl_recipe *recipe = (cpl_recipe *) plugin;
00218    /* Get the recipe out of the plugin */
00219     if (cpl_plugin_get_type(plugin) == CPL_PLUGIN_TYPE_RECIPE) 
00220         recipe = (cpl_recipe *)plugin ;
00221     else return -1 ;
00222 
00223   return sinfo_rec_pupil(recipe->parameters, recipe->frames);
00224 
00225 }
00226 
00227 /*---------------------------------------------------------------------------*/
00233 /*---------------------------------------------------------------------------*/
00234 static int sinfo_rec_pupil_destroy(cpl_plugin *plugin)
00235 {
00236   cpl_recipe  *   recipe ;
00237     /* Get the recipe out of the plugin */
00238     if (cpl_plugin_get_type(plugin) == CPL_PLUGIN_TYPE_RECIPE) 
00239         recipe = (cpl_recipe *)plugin ;
00240     else return -1 ;
00241 
00242   cpl_parameterlist_delete(recipe->parameters);
00243 
00244   return 0;
00245 
00246 }
00247 
00248 /*---------------------------------------------------------------------------*/
00255 /*---------------------------------------------------------------------------*/
00256 /*
00257  * The actual recipe actually start here.
00258  */
00259 
00260 static int sinfo_rec_pupil(cpl_parameterlist *config, cpl_frameset *set)
00261 {
00262  
00263   fake* fk=NULL;
00264   fk=sinfo_fake_new();
00265 
00266    sinfo_msg("Welcome to SINFONI Pipeline release %d.%d.%d",
00267         SINFONI_MAJOR_VERSION,SINFONI_MINOR_VERSION,SINFONI_MICRO_VERSION);
00268 
00269    ck0(sinfo_dfs_set_groups(set),"Cannot indentify RAW and CALIB frames") ;
00270 
00271    /* hidden parameters */
00272    sinfo_msg("---------------------------------------------");
00273    sinfo_msg("%s FRAME DETERMINATION", PRO_PUPIL_LAMP_STACKED);
00274    sinfo_msg("---------------------------------------------");
00275   
00276    ck0(sinfo_new_prepare_stacked_frames(cpl_func,config, set, NULL,
00277                     PRO_PUPIL_LAMP_STACKED,0,fk ),
00278        "Failed %s FRAME DETERMINATION", PRO_PUPIL_LAMP_STACKED);
00279    sinfo_msg("%s FRAME DETERMINATION SUCCESS", PRO_PUPIL_LAMP_STACKED);
00280   
00281    sinfo_msg("---------------------------------------------");
00282    sinfo_msg("PUPIL DATA REDUCTION");
00283    sinfo_msg("---------------------------------------------");
00284   
00285    ck0(sinfo_new_objnod(cpl_func,config, set,PRO_COADD_PUPIL),
00286        "Failed PUPIL DATA REDUCTION") ;
00287    sinfo_msg("PUPIL DATA REDUCTION SUCCESS");
00288  
00289  cleanup:
00290   sinfo_fake_delete(&fk);
00291 
00292   if (cpl_error_get_code() != CPL_ERROR_NONE) {
00293     return -1;
00294   } else {
00295     return 0;
00296   }
00297 
00298 
00299 }

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