si_rec_objspider.c

00001 /* $Id: si_rec_objspider.c,v 1.12 2005/10/08 10:34:50 amodigli Exp $
00002  *
00003  * This file is part of the CPL (Common Pipeline Library)
00004  * Copyright (C) 2002 European Southern Observatory
00005  *
00006  * This library is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU Lesser General Public
00008  * License as published by the Free Software Foundation; either
00009  * version 2.1 of the License, or (at your option) any later version.
00010  *
00011  * This library 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 GNU
00014  * Lesser General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU Lesser General Public
00017  * License along with this library; if not, write to the Free Software
00018  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00019  */
00020 /*
00021  * $Author: amodigli $
00022  * $Date: 2005/10/08 10:34:50 $
00023  * $Revision: 1.12 $
00024  * $Name:  $
00025  */
00026 
00027  /****************************************************************
00028   *           Object Data reduction                              *
00029   ****************************************************************/
00030 
00031 
00032 #ifdef HAVE_CONFIG_H
00033 #include <config.h>       
00034 #endif
00035 /*-----------------------------------------------------------------------------
00036                                 Includes
00037  -----------------------------------------------------------------------------*/
00038 
00039 /* std */
00040 #include <strings.h>
00041 #include <string.h>
00042 #include <stdio.h>
00043 
00044 /* cx */
00045 #include <cxmacros.h>
00046 #include <cxtypes.h>
00047 #include <cxmessages.h>     /* defines message level types */
00048 
00049 /* qfits */
00050 #include <xmemory.h>
00051 
00052 /* cpl */
00053 #include <cpl_memory.h>       /* defines memory allocation functions */
00054 
00055 /* sinfoni */
00056 #include <sinfoni_general_config.h>
00057 #include <sinfoni_fake_config.h>
00058 #include <sinfoni_prepare_stacked_frames_config.h>
00059 #include <sinfoni_objspider_config.h>
00060 #include <prepare_stacked_frames.h>
00061 #include <objspider.h>
00062 #include <sinfoni_pro_types.h>
00063 #include <sinfoni_tpl_utils.h>
00064 #include <sinfoni_tpl_dfs.h>
00065 #include <sinfoni_memory.h>
00066 
00067 
00068 
00069 /*-----------------------------------------------------------------------------
00070                             Functions prototypes
00071  -----------------------------------------------------------------------------*/
00072 
00073 static cxint si_rec_objspider(cpl_parameterlist *, cpl_frameset *);
00074 
00075 /*-----------------------------------------------------------------------------
00076                             Static variables
00077  -----------------------------------------------------------------------------*/
00078 
00079 static char si_rec_objspider_description[] =
00080 "This recipe performs science skyspider data reduction.\n"
00081 "The input files are science object and sky frames with tags OBJECT_NODDING and SKY_NODDING\n"
00082 "Master calibration frames:\n"
00083 "A corresponding (band,preoptics) wavelength map image with tag WAVE_MAP\n"
00084 "A corresponding (band,preoptics) master flat field with tag MASTER_FLAT_LAMP\n"
00085 "A corresponding (band,preoptics) master bad pixel map with tag MASTER_BP_MAP\n"
00086 "A corresponding (band,preoptics) slitlets position frame with tag SLIT_POS\n"
00087 "A corresponding (band) distortion table with tag DISTORTION\n"
00088 "A corresponding (band) slitlet distance table with tag SLITLETS_DISTANCE\n"
00089 "The output is an image resulting from the IMA1 op IMA2 where op indicates\n"
00090 "A reference table with the position of the first  column with tag FIRST_COLUMN\n"
00091 "Relevant outputs are:\n"
00092 "combined cubes (PRO.CATG=x_OBS x=STD,OBJ,PSF)\n"
00093 "reconstructed cube (PRO.CATG=COADD_x_OBS x=STD,OBJ,PSF)\n"
00094 "An average along Z of the reconstructed cube (PRO.CATG=MED_x_OBS x=STD,OBJ,PSF)\n"
00095 "The bad pixel map associated to the cube (PRO.CATG=BP_MAP_COADD_x_OBS x=STD,OBJ,PSF)\n"
00096 "Information on relevant parameters can be found with"
00097 "esorex --params si_rec_objspider"
00098 "esorex --help si_rec_objspider"
00099 "\n";
00100 
00101 /*-----------------------------------------------------------------------------
00102                                 Functions code
00103  -----------------------------------------------------------------------------*/
00104 
00105 
00106 cxint
00107 si_rec_objspider_create(cpl_plugin *plugin)
00108 {
00109 
00110   /*
00111    * We have to provide the option we accept to the application.
00112    * We need to setup our parameter list and hook it into the recipe
00113    * interface.
00114    */
00115   cpl_recipe *recipe = (cpl_recipe *)plugin;
00116   recipe->parameters = cpl_parameterlist_new();
00117   if(recipe->parameters == NULL) {
00118     return 1;
00119   }
00120 
00121   /*
00122    * Fill the parameter list.
00123    */
00124 
00125   /* General parameters */
00126   /* Object Data Reduction parameters */
00127   /* cx_print("config\n"); */
00128  
00129   sinfoni_general_config_add(recipe->parameters); 
00130   sinfoni_prepare_stacked_frames_config_add(recipe->parameters);
00131   sinfoni_objspider_config_add(recipe->parameters); 
00132   sinfoni_fake_config_add(config);
00133   
00134   return 0;
00135 
00136 }
00137 
00138 cxint
00139 si_rec_objspider_exec(cpl_plugin *plugin)
00140 {
00141  
00142   cpl_recipe *recipe = (cpl_recipe *) plugin;
00143   if(recipe->parameters == NULL) {
00144     return 1;
00145   }
00146   if(recipe->frames == NULL) {
00147     return 1;
00148   }
00149   /* cx_print("exec\n"); */
00150   cpl_error_reset();
00151   return si_rec_objspider(recipe->parameters, recipe->frames);
00152 
00153 }
00154 
00155 cxint
00156 si_rec_objspider_destroy(cpl_plugin *plugin)
00157 {
00158   /* cx_print("destroy\n"); */
00159   cpl_recipe *recipe = (cpl_recipe *) plugin;
00160   /*
00161    * We just destroy what was created during the plugin initializzation phase
00162    * i.e. the parameter list. The frame set is managed by the application which
00163    * called us, so that we must not touch it.
00164    */
00165 
00166   cpl_parameterlist_delete(recipe->parameters);
00167 
00168   return 0;
00169 
00170 }
00171 
00172 int
00173 cpl_plugin_get_info(cpl_pluginlist *list)
00174 {
00175 
00176   cpl_recipe *recipe = cpl_calloc(1, sizeof *recipe);
00177   cpl_plugin *plugin = &recipe->interface;
00178 
00179 
00180   cpl_plugin_init(plugin,
00181           CPL_PLUGIN_API,
00182           SINFONI_BINARY_VERSION,
00183           CPL_PLUGIN_TYPE_RECIPE,
00184           "si_rec_objspider",
00185           "Object data reduction",
00186            si_rec_objspider_description,
00187           "Andrea Modigliani",
00188           "Andrea.Modigliani@eso.org",
00189           sinfoni_get_licence(),
00190           si_rec_objspider_create,
00191           si_rec_objspider_exec,
00192           si_rec_objspider_destroy);
00193 
00194   cpl_pluginlist_append(list, plugin);
00195 
00196   return 0;
00197 
00198 }
00199 
00200 
00201 /*
00202  * The actual recipe actually start here.
00203  */
00204 
00205 static cxint
00206 si_rec_objspider(cpl_parameterlist *config, cpl_frameset *set)
00207 {
00208   int ind=0;
00209 
00210   const char *_id = "si_rec_objspider";
00211 
00212   /* cpl_parameterlist_dump(config); */
00213 
00214    if(sinfoni_dfs_set_groups(set)) {
00215        cpl_msg_error(_id, "Cannot indentify RAW and CALIB frames") ;
00216        return -1;
00217     }
00218      /* =============================================================== 
00219         ARC LAMP FRAMES STACKING 
00220         =============================================================== */
00221 
00222     {
00223     cpl_msg_info (_id,"running RECIPE prepare_stacked_frames...") ; 
00224         if ( -1 == (ind = prepare_stacked_frames(config, set, PRO_OBJECT_SKYSPIDER_STACKED ) ) )
00225         {
00226         cpl_msg_error(_id," no: %d\n", ind) ;
00227         return -1 ;
00228     }
00229     cpl_msg_info (_id,"success RECIPE prepare_stacked_frames ended") ; 
00230     }    
00231 
00232      /* =============================================================== 
00233         OBJSPIDER
00234         =============================================================== */
00235 
00236 
00237      /* get object data reduction method */ 
00238     {
00239         cpl_msg_info(_id,"Running") ;
00240         if ( -1 == (ind = objspider(config, set ) ) )
00241         {
00242             cpl_msg_info(_id,"no: %d\n", ind) ;
00243         return -1 ;
00244         }
00245     cpl_msg_info(_id,"Success") ;
00246     } 
00247     return 0 ;
00248 
00249 }
00250 
00251 
00252 

Generated on Wed Oct 26 13:08:54 2005 for SINFONI Pipeline Reference Manual by doxygen1.2.13.1 written by Dimitri van Heesch, © 1997-2001