sinfo_rec_psf.c

00001 /* $Id: sinfo_rec_psf.c,v 1.22 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 /*
00023  * $Author: amodigli $
00024  * $Date: 2008/02/12 14:56:50 $
00025  * $Revision: 1.22 $
00026  * $Name: sinfo-2_2_5 $
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     cpl_errorstate initial_errorstate = cpl_errorstate_get();
00219     
00220     /* Get the recipe out of the plugin */
00221     if (cpl_plugin_get_type(plugin) == CPL_PLUGIN_TYPE_RECIPE) 
00222         recipe = (cpl_recipe *)plugin ;
00223     else return -1 ;
00224 
00225     if (!cpl_errorstate_is_equal(initial_errorstate)) {                      
00226         /* Dump the error history since recipe execution start.                
00227            At this point the recipe cannot recover from the error */           
00228         cpl_errorstate_dump(initial_errorstate, CPL_FALSE, NULL);              
00229     } 
00230   return sinfo_rec_psf(recipe->parameters, recipe->frames);
00231 
00232 }
00233 
00234 /*---------------------------------------------------------------------------*/
00240 /*---------------------------------------------------------------------------*/
00241 static int sinfo_rec_psf_destroy(cpl_plugin *plugin)
00242 {
00243     cpl_recipe  *   recipe ;
00244     
00245     /* Get the recipe out of the plugin */
00246     if (cpl_plugin_get_type(plugin) == CPL_PLUGIN_TYPE_RECIPE) 
00247         recipe = (cpl_recipe *)plugin ;
00248     else return -1 ;
00249 
00250   cpl_parameterlist_delete(recipe->parameters);
00251 
00252   return 0;
00253 
00254 }
00255 
00256 
00257 /*---------------------------------------------------------------------------*/
00264 /*---------------------------------------------------------------------------*/
00265 
00266 /*
00267  * The actual recipe actually start here.
00268  */
00269 
00270 static int
00271 sinfo_rec_psf(cpl_parameterlist *config, cpl_frameset *set)
00272 {
00273 
00274 
00275   const char* pro_ctg_cube;
00276   sinfo_msg("Welcome to SINFONI Pipeline release %d.%d.%d",
00277         SINFONI_MAJOR_VERSION,SINFONI_MINOR_VERSION,SINFONI_MICRO_VERSION);
00278 
00279   if(sinfo_dfs_set_groups(set)) {
00280     sinfo_msg("Cannot indentify RAW and CALIB frames") ;
00281     return -1;
00282   }
00283 
00284   /* =============================================================== 
00285      Defines several framesets each with a pair obj-sky, 
00286      stack each pair, put the results in set 
00287      =============================================================== */
00288   ck0(sinfo_cub_stk_frames(config,&set,cpl_func,&pro_ctg_cube),
00289                            "Cannot stack RAW frames") ;
00290  
00291   /* =============================================================== 
00292      SCI OBJNOD 
00293      =============================================================== */
00294   sinfo_msg("------------------------------") ;
00295   sinfo_msg("COADDING CUBES");
00296   sinfo_msg("------------------------------") ;
00297 
00298   ck0(sinfo_new_cubes_coadd(cpl_func,config, set, pro_ctg_cube),
00299       "COADDING CUBES");
00300   sinfo_msg("------------------------------") ;
00301   sinfo_msg("COADDED CUBES");
00302   sinfo_msg("------------------------------") ;
00303 
00304   /* =============================================================== 
00305      PSF
00306      =============================================================== */
00307 
00308   sinfo_msg("------------------------------") ;
00309   sinfo_msg("REDUCE PSF STD STAR FRAMES");
00310   sinfo_msg("------------------------------") ; 
00311   ck0(sinfo_new_psf(cpl_func,config,set),"REDUCING PSF STD STAR FRAMES");
00312   sinfo_msg("SUCCESS REDUCE PSF STD STAR FRAMES") ; 
00313 
00314 
00315  cleanup:
00316 
00317 
00318   if (cpl_error_get_code() != CPL_ERROR_NONE) {
00319     return -1;
00320   } else {
00321     return 0;
00322   }
00323 
00324 
00325 
00326 }

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