sinfo_rec_psf.c

00001 /* $Id: sinfo_rec_psf.c,v 1.18 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 /*
00023  * $Author: amodigli $
00024  * $Date: 2006/12/19 17:01:36 $
00025  * $Revision: 1.18 $
00026  * $Name:  $
00027  */
00028 
00029  /****************************************************************
00030   *          Psf Frames Data Reduction                          *
00031   ****************************************************************/
00032 
00033 #ifdef HAVE_CONFIG_H
00034 #include <config.h>          /* allows the program compilation */
00035 #endif
00036 /*-----------------------------------------------------------------------------
00037                                 Includes
00038  ----------------------------------------------------------------------------*/
00039 
00040 /* std */
00041 #include <strings.h>
00042 #include <string.h>
00043 #include <stdio.h>
00044 
00045 /* cpl */
00046 #include <cpl.h>  
00047  
00048 /* irplib */
00049 #include <irplib_utils.h>
00050 
00051 /* sinfoni */
00052 #include <sinfo_pro_types.h>
00053 #include <sinfo_product_config.h>
00054 #include <sinfo_prepare_stacked_frames_config.h>
00055 #include <sinfo_objnod_config.h>
00056 #include <sinfo_skycor_config.h>
00057 #include <sinfo_functions.h>
00058 #include <sinfo_new_prepare_stacked_frames.h>
00059 #include <sinfo_new_cubes_coadd.h>
00060 #include <sinfo_new_stdstar.h>
00061 #include <sinfo_new_psf.h>
00062 #include <sinfo_tpl_utils.h>
00063 #include <sinfo_tpl_dfs.h>
00064 #include <sinfo_hidden.h>
00065 #include <sinfo_globals.h>
00066 #include <sinfo_msg.h>
00067 #include <sinfo_rec_utils.h>
00068 #include <sinfo_error.h>
00069 #include <sinfo_utils_wrappers.h>
00070 
00071 
00072 /*-----------------------------------------------------------------------------
00073                             Functions prototypes
00074  ----------------------------------------------------------------------------*/
00075 static int sinfo_rec_psf_create(cpl_plugin *) ;
00076 static int sinfo_rec_psf_exec(cpl_plugin *) ;
00077 static int sinfo_rec_psf_destroy(cpl_plugin *) ;
00078 static int sinfo_rec_psf(cpl_parameterlist *, cpl_frameset *);
00079 /*-----------------------------------------------------------------------------
00080                             Static variables
00081  ----------------------------------------------------------------------------*/
00082 
00083 static char sinfo_rec_psf_description1[] =
00084 "This recipe performs psf standard data reduction.\n"
00085 "The input files are science object and sky frames with tags\n"
00086 "PSF_CALIBRATOR and SKY_PSF_CALIBRATOR\n"
00087 "Master calibration frames:\n";
00088 
00089 static char sinfo_rec_psf_description2[] =
00090 "Master calibration frames:\n"
00091 "A corresponding (band,preoptics) wavelength map image (tag=WAVE_MAP)\n"
00092 "A corresponding (band,preoptics) master flat field (tag=MASTER_FLAT_LAMP)\n"
00093 "A corresponding (band,preoptics) master bad pixel map (tag=MASTER_BP_MAP)\n"
00094 "A corresponding (band,preoptics) slitlets position frame (tag=SLIT_POS)\n"
00095 "A corresponding (band) distortion table (tag=DISTORTION)\n"
00096 "A corresponding (band) slitlet distance table (tag=SLITLETS_DISTANCE)\n";
00097 
00098 
00099 static char sinfo_rec_psf_description3[] =
00100 "The output is an image resulting from the IMA1 op IMA2 where op indicates\n"
00101 "the chosen operation\n"
00102 "A reference table with the position of the first column (tag=FIRST_COLUMN)\n"
00103 "Relevant outputs are:\n"
00104 "combined cubes (PRO.CATG=x_OBS x=STD,OBJ,PSF)\n"
00105 "reconstructed cube (PRO.CATG=COADD_x_OBS x=STD,OBJ,PSF)\n"
00106 "An average along Z of the reconstructed cube \n"
00107 "(PRO.CATG=MED_x_OBS x=STD,OBJ,PSF)\n"
00108 "The bad pixel map associated to the cube \n"
00109 "(PRO.CATG=BP_MAP_COADD_x_OBS x=STD,OBJ,PSF)\n";
00110 
00111 static char sinfo_rec_psf_description4[] =
00112 "Information on relevant parameters can be found with\n"
00113 "esorex --params sinfo_rec_psf\n"
00114 "esorex --help sinfo_rec_psf\n"
00115 "\n";
00116 
00117 
00118 static char sinfo_rec_psf_description[1300];
00119 
00120 
00121 
00122 /*-----------------------------------------------------------------------------
00123                                 Functions code
00124  ----------------------------------------------------------------------------*/
00125 
00126 /*---------------------------------------------------------------------------*/
00130 /*---------------------------------------------------------------------------*/
00132 /*---------------------------------------------------------------------------*/
00141 /*---------------------------------------------------------------------------*/
00142 
00143 
00144 
00145 int
00146 cpl_plugin_get_info(cpl_pluginlist *list)
00147 {
00148 
00149   cpl_recipe *recipe = cpl_calloc(1, sizeof *recipe);
00150   cpl_plugin *plugin = &recipe->interface;
00151   strcpy(sinfo_rec_psf_description,sinfo_rec_psf_description1);
00152   strcat(sinfo_rec_psf_description,sinfo_rec_psf_description2);
00153   strcat(sinfo_rec_psf_description,sinfo_rec_psf_description3);
00154   strcat(sinfo_rec_psf_description,sinfo_rec_psf_description4);
00155 
00156   cpl_plugin_init(plugin,
00157           CPL_PLUGIN_API,
00158           SINFONI_BINARY_VERSION,
00159           CPL_PLUGIN_TYPE_RECIPE,
00160           "sinfo_rec_psf",
00161           "PSF star data reduction",
00162           sinfo_rec_psf_description,
00163           "Andrea Modigliani",
00164           "Andrea.Modigliani@eso.org",
00165           sinfo_get_license(),
00166           sinfo_rec_psf_create,
00167           sinfo_rec_psf_exec,
00168           sinfo_rec_psf_destroy);
00169 
00170   cpl_pluginlist_append(list, plugin);
00171 
00172   return 0;
00173 
00174 }
00175 
00176 /*---------------------------------------------------------------------------*/
00184 /*---------------------------------------------------------------------------*/
00185 static int sinfo_rec_psf_create(cpl_plugin *plugin)
00186 {
00187     cpl_recipe      * recipe ;
00188 
00189     /* Check that the plugin is part of a valid recipe */
00190     if (cpl_plugin_get_type(plugin) == CPL_PLUGIN_TYPE_RECIPE) 
00191         recipe = (cpl_recipe *)plugin ;
00192     else return -1 ;
00193     irplib_reset();
00194 
00195     /* Create the parameters list in the cpl_recipe object */
00196     recipe->parameters = cpl_parameterlist_new() ; 
00197 
00198   /*
00199    * Fill the parameter list.
00200    */
00201   sinfo_product_config_add(recipe->parameters);
00202   sinfo_prepare_stacked_frames_config_add(recipe->parameters);
00203   sinfo_objnod_config_add(recipe->parameters); 
00204   sinfo_skycor_config_add(recipe->parameters); 
00205  return 0;
00206 
00207 }
00208 /*---------------------------------------------------------------------------*/
00214 /*---------------------------------------------------------------------------*/
00215 static int sinfo_rec_psf_exec(cpl_plugin *plugin)
00216 {
00217     cpl_recipe  *   recipe ;
00218     
00219     /* Get the recipe out of the plugin */
00220     if (cpl_plugin_get_type(plugin) == CPL_PLUGIN_TYPE_RECIPE) 
00221         recipe = (cpl_recipe *)plugin ;
00222     else return -1 ;
00223 
00224   return sinfo_rec_psf(recipe->parameters, recipe->frames);
00225 
00226 }
00227 
00228 /*---------------------------------------------------------------------------*/
00234 /*---------------------------------------------------------------------------*/
00235 static int sinfo_rec_psf_destroy(cpl_plugin *plugin)
00236 {
00237     cpl_recipe  *   recipe ;
00238     
00239     /* Get the recipe out of the plugin */
00240     if (cpl_plugin_get_type(plugin) == CPL_PLUGIN_TYPE_RECIPE) 
00241         recipe = (cpl_recipe *)plugin ;
00242     else return -1 ;
00243 
00244   cpl_parameterlist_delete(recipe->parameters);
00245 
00246   return 0;
00247 
00248 }
00249 
00250 
00251 /*---------------------------------------------------------------------------*/
00258 /*---------------------------------------------------------------------------*/
00259 
00260 /*
00261  * The actual recipe actually start here.
00262  */
00263 
00264 static int
00265 sinfo_rec_psf(cpl_parameterlist *config, cpl_frameset *set)
00266 {
00267 
00268 
00269   const char* pro_ctg_cube;
00270   sinfo_msg("Welcome to SINFONI Pipeline release %d.%d.%d",
00271         SINFONI_MAJOR_VERSION,SINFONI_MINOR_VERSION,SINFONI_MICRO_VERSION);
00272 
00273   if(sinfo_dfs_set_groups(set)) {
00274     sinfo_msg("Cannot indentify RAW and CALIB frames") ;
00275     return -1;
00276   }
00277 
00278   /* =============================================================== 
00279      Defines several framesets each with a pair obj-sky, 
00280      stack each pair, put the results in set 
00281      =============================================================== */
00282   ck0(sinfo_cub_stk_frames(config,&set,cpl_func,&pro_ctg_cube),
00283                            "Cannot stack RAW frames") ;
00284  
00285   /* =============================================================== 
00286      SCI OBJNOD 
00287      =============================================================== */
00288   sinfo_msg("------------------------------") ;
00289   sinfo_msg("COADDING CUBES");
00290   sinfo_msg("------------------------------") ;
00291 
00292   ck0(sinfo_new_cubes_coadd(cpl_func,config, set, pro_ctg_cube),"COADDING CUBES");
00293   sinfo_msg("------------------------------") ;
00294   sinfo_msg("COADDED CUBES");
00295   sinfo_msg("------------------------------") ;
00296 
00297   /* =============================================================== 
00298      PSF
00299      =============================================================== */
00300 
00301   sinfo_msg("------------------------------") ;
00302   sinfo_msg("REDUCE PSF STD STAR FRAMES");
00303   sinfo_msg("------------------------------") ; 
00304   ck0(sinfo_new_psf(cpl_func,config,set),"REDUCING PSF STD STAR FRAMES");
00305   sinfo_msg("SUCCESS REDUCE PSF STD STAR FRAMES") ; 
00306   return 0 ;
00307 
00308  cleanup:
00309   irplib_error_dump(CPL_MSG_ERROR,CPL_MSG_ERROR);
00310 
00311   return -1 ;
00312 
00313 }

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