sinfo_rec_pupil.c

00001 /* $Id: sinfo_rec_pupil.c,v 1.12 2006/12/19 17:01:36 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: 2006/12/19 17:01:36 $
00024  * $Revision: 1.12 $
00025  * $Name:  $
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 
00068 /*-----------------------------------------------------------------------------
00069                             Functions prototypes
00070  -----------------------------------------------------------------------------*/
00071 static int sinfo_rec_pupil_create(cpl_plugin *);
00072 static int sinfo_rec_pupil_exec(cpl_plugin *);
00073 static int sinfo_rec_pupil_destroy(cpl_plugin *);
00074 static int sinfo_rec_pupil(cpl_parameterlist *, cpl_frameset *);
00075 
00076 /*-----------------------------------------------------------------------------
00077                             Static variables
00078  -----------------------------------------------------------------------------*/
00079 static char sinfo_rec_pupil_description1[] =
00080 "This recipe performs science data reduction.\n"
00081 "The input files are science object and sky frames \n"
00082 "with tags OBJECT_NODDING and SKY_NODDING\n"
00083 "Master calibration frames:\n";
00084 
00085 
00086 static char sinfo_rec_pupil_description2[] =
00087 "A corresponding (band,preoptics) wavelength map image with tag WAVE_MAP\n"
00088 "A corresponding (band,preoptics) master flat field with tag MASTER_FLAT_LAMP\n"
00089 "A corresponding (band,preoptics) master bad pixel map with tag MASTER_BP_MAP\n"
00090 "A corresponding (band,preoptics) slitlets position frame with tag SLIT_POS\n"
00091 "A corresponding (band) distortion table with tag DISTORTION\n"
00092 "A corresponding (band) slitlet distance table with tag SLITLETS_DISTANCE\n";
00093 
00094 
00095 static char sinfo_rec_pupil_description3[] =
00096 "The output is an image resulting from the IMA1 op IMA2 where op indicates\n"
00097 "A reference table with the position of the first column with tag FIRST_COLUMN\n"
00098 "Relevant outputs are:\n"
00099 "combined cubes (PRO.CATG=x_OBS x=STD,OBJ,PSF)\n"
00100 "reconstructed cube (PRO.CATG=COADD_x_OBS x=STD,OBJ,PSF)\n"
00101 "An average along Z of the reconstructed cube \n"
00102 "(PRO.CATG=MED_x_OBS x=STD,OBJ,PSF)\n"
00103 "The bad pixel map associated to the cube \n"
00104 "(PRO.CATG=BP_MAP_COADD_x_OBS x=STD,OBJ,PSF)\n";
00105 
00106 
00107 static char sinfo_rec_pupil_description4[] =
00108 "Information on relevant parameters can be found with\n"
00109 "esorex --params sinfo_rec_pupil\n"
00110 "esorex --help sinfo_rec_pupil\n"
00111 "\n";
00112 
00113 static char sinfo_rec_pupil_description[1300];
00114 
00115 /*-----------------------------------------------------------------------------
00116                                 Functions code
00117  ----------------------------------------------------------------------------*/
00118 /*---------------------------------------------------------------------------*/
00122 /*---------------------------------------------------------------------------*/
00124 /*---------------------------------------------------------------------------*/
00133 /*---------------------------------------------------------------------------*/
00134 
00135 int
00136 cpl_plugin_get_info(cpl_pluginlist *list)
00137 {
00138 
00139   cpl_recipe *recipe = cpl_calloc(1, sizeof *recipe);
00140   cpl_plugin *plugin = &recipe->interface;
00141 
00142 
00143   strcpy(sinfo_rec_pupil_description,sinfo_rec_pupil_description1);
00144   strcat(sinfo_rec_pupil_description,sinfo_rec_pupil_description2);
00145   strcat(sinfo_rec_pupil_description,sinfo_rec_pupil_description3);
00146   strcat(sinfo_rec_pupil_description,sinfo_rec_pupil_description4);
00147 
00148   cpl_plugin_init(plugin,
00149           CPL_PLUGIN_API,
00150           SINFONI_BINARY_VERSION,
00151           CPL_PLUGIN_TYPE_RECIPE,
00152           "sinfo_rec_pupil",
00153           "Pupil data reduction",
00154           sinfo_rec_pupil_description,
00155           "Andrea Modigliani",
00156           "Andrea.Modigliani@eso.org",
00157           sinfo_get_license(),
00158           sinfo_rec_pupil_create,
00159           sinfo_rec_pupil_exec,
00160           sinfo_rec_pupil_destroy);
00161  
00162   cpl_pluginlist_append(list, plugin);
00163 
00164   return 0;
00165 
00166 }
00167 
00168 /*---------------------------------------------------------------------------*/
00176 /*---------------------------------------------------------------------------*/
00177  
00178 static int sinfo_rec_pupil_create(cpl_plugin *plugin)
00179 {
00180    cpl_recipe      * recipe ;
00181 
00182     /* Check that the plugin is part of a valid recipe */
00183     if (cpl_plugin_get_type(plugin) == CPL_PLUGIN_TYPE_RECIPE) 
00184         recipe = (cpl_recipe *)plugin ;
00185     else return -1 ;
00186     cpl_error_reset();
00187     irplib_reset();
00188 
00189     /* Create the parameters list in the cpl_recipe object */
00190     recipe->parameters = cpl_parameterlist_new() ; 
00191 
00192 
00193   /*
00194    * Fill the parameter list.
00195    */  
00196 
00197   sinfo_product_config_add(recipe->parameters);
00198   sinfo_prepare_stacked_frames_config_add(recipe->parameters);
00199   sinfo_objnod_config_add(recipe->parameters);
00200   return 0;
00201 
00202 }
00203 
00204 /*---------------------------------------------------------------------------*/
00210 /*---------------------------------------------------------------------------*/
00211 
00212 
00213 static int sinfo_rec_pupil_exec(cpl_plugin *plugin)
00214 {
00215 
00216   cpl_recipe *recipe = (cpl_recipe *) plugin;
00217    /* Get the recipe out of the plugin */
00218     if (cpl_plugin_get_type(plugin) == CPL_PLUGIN_TYPE_RECIPE) 
00219         recipe = (cpl_recipe *)plugin ;
00220     else return -1 ;
00221 
00222   return sinfo_rec_pupil(recipe->parameters, recipe->frames);
00223 
00224 }
00225 
00226 /*---------------------------------------------------------------------------*/
00232 /*---------------------------------------------------------------------------*/
00233 static int sinfo_rec_pupil_destroy(cpl_plugin *plugin)
00234 {
00235   cpl_recipe  *   recipe ;
00236     /* Get the recipe out of the plugin */
00237     if (cpl_plugin_get_type(plugin) == CPL_PLUGIN_TYPE_RECIPE) 
00238         recipe = (cpl_recipe *)plugin ;
00239     else return -1 ;
00240 
00241   cpl_parameterlist_delete(recipe->parameters);
00242 
00243   return 0;
00244 
00245 }
00246 
00247 /*---------------------------------------------------------------------------*/
00254 /*---------------------------------------------------------------------------*/
00255 /*
00256  * The actual recipe actually start here.
00257  */
00258 
00259 static int sinfo_rec_pupil(cpl_parameterlist *config, cpl_frameset *set)
00260 {
00261  
00262   int  ind =0;
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   if(sinfo_dfs_set_groups(set)) {
00270 
00271     sinfo_msg("Cannot indentify RAW and CALIB frames") ;
00272     return -1;
00273 
00274   }
00275   /* hidden parameters */
00276   sinfo_msg("---------------------------------------------");
00277   sinfo_msg("%s FRAME DETERMINATION", PRO_PUPIL_LAMP_STACKED);
00278   sinfo_msg("---------------------------------------------");
00279   {
00280     if ( -1 == (ind = sinfo_new_prepare_stacked_frames(cpl_func,config, set, 
00281                       PRO_PUPIL_LAMP_STACKED,0,fk )))
00282       {
00283     sinfo_msg_error(" no: %d\n", ind) ;
00284         sinfo_fake_delete(&fk);
00285     return -1 ;
00286       }
00287     sinfo_msg("%s FRAME DETERMINATION SUCCESS", PRO_PUPIL_LAMP_STACKED);
00288   }    
00289 
00290 
00291   sinfo_msg("---------------------------------------------");
00292   sinfo_msg("PUPIL DATA REDUCTION");
00293   sinfo_msg("---------------------------------------------");
00294   {
00295     if ( -1 == (ind = sinfo_new_objnod(cpl_func,config, set,PRO_COADD_PUPIL)))
00296       {
00297     sinfo_msg_error("no: %d\n", ind) ;
00298     sinfo_fake_delete(&fk);
00299     return -1 ;
00300       }
00301     sinfo_msg("PUPIL DATA REDUCTION") ;
00302   }
00303 
00304   sinfo_fake_delete(&fk);
00305   return 0 ;
00306 
00307 }

Generated on Wed Jan 17 08:33:43 2007 for SINFONI Pipeline Reference Manual by  doxygen 1.4.4