sinfo_step_jitter.c

00001 /* $Id: sinfo_step_jitter.c,v 1.8 2006/12/18 08:05:10 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  * $Author: amodigli $
00022  * $Date: 2006/12/18 08:05:10 $
00023  * $Revision: 1.8 $
00024  * $Name:  $
00025  */
00026 
00027  /****************************************************************
00028   *           Object Data reduction                              *
00029   ****************************************************************/
00030 
00031 #ifdef HAVE_CONFIG_H
00032 #include <config.h>          /* allows the program compilation */
00033 #endif
00034 
00035 /*-----------------------------------------------------------------------------
00036                                 Includes
00037  ----------------------------------------------------------------------------*/
00038 
00039 /* std */
00040 #include <strings.h>
00041 #include <string.h>
00042 #include <stdio.h>
00043 #include <math.h>
00044 #include <libgen.h>
00045 
00046 
00047 /* cpl */
00048 #include <cpl.h>  
00049 
00050 /* irplib */
00051 #include <irplib_utils.h>
00052 
00053 /* sinfoni */
00054 #include <sinfo_pro_types.h>
00055 #include <sinfo_prepare_stacked_frames_config.h>
00056 #include <sinfo_objnod_config.h>
00057 #include <sinfo_standard_star_config.h>
00058 #include <sinfo_psf_config.h>
00059 #include <sinfo_skycor_config.h>
00060 #include <sinfo_new_objnod.h>
00061 #include <sinfo_new_stdstar.h>
00062 #include <sinfo_new_psf.h>
00063 #include <sinfo_new_prepare_stacked_frames.h>
00064 #include <sinfo_key_names.h>
00065 #include <sinfo_raw_types.h>
00066 #include <sinfo_functions.h>
00067 #include <sinfo_tpl_utils.h>
00068 #include <sinfo_tpl_dfs.h>
00069 #include <sinfo_hidden.h>
00070 #include <sinfo_globals.h>
00071 #include <sinfo_msg.h>
00072 #include <sinfo_rec_utils.h>
00073 #include <irplib_utils.h>
00074 
00075 /*-----------------------------------------------------------------------------
00076                             Functions prototypes
00077  ----------------------------------------------------------------------------*/
00078 
00079 static int sinfo_step_jitter_create(cpl_plugin *) ;
00080 static int sinfo_step_jitter_exec(cpl_plugin *) ;
00081 static int sinfo_step_jitter_destroy(cpl_plugin *) ;
00082 static int sinfo_step_jitter(cpl_parameterlist *config, cpl_frameset *set);
00083 /*-----------------------------------------------------------------------------
00084                             Static variables
00085  ----------------------------------------------------------------------------*/
00086 
00087 static char sinfo_step_jitter_description1[] =
00088 "This recipe performs science data reduction.\n"
00089 "The input files are:\n"
00090 "science object and sky frames with tags OBJECT_NODDING and SKY_NODDING or\n"
00091 "Telluric standard star frames and sky frames with tags STD and SKY_STD or\n"
00092 "PSF standard star and sky frames with tags \n"
00093 "PSF_CALIBRATOR and SKY_PSF_CALIBRATOR\n"
00094 "and Master calibration frames:\n";
00095 
00096 
00097 static char sinfo_step_jitter_description2[] =
00098 "A corresponding (band,preoptics) wavelength map image with tag WAVE_MAP\n"
00099 "A corresponding (band,preoptics) master flat field with tag MASTER_FLAT_LAMP\n"
00100 "A corresponding (band,preoptics) master bad pixel map with tag MASTER_BP_MAP\n"
00101 "A corresponding (band,preoptics) slitlets position frame with tag SLIT_POS\n"
00102 "A corresponding (band) distortion table with tag DISTORTION\n"
00103 "A corresponding (band) slitlet distance table with tag SLITLETS_DISTANCE\n";
00104 
00105 
00106 static char sinfo_step_jitter_description3[] =
00107 "The output is an image resulting from the IMA1 op IMA2 where op indicates\n"
00108 "A reference table with the position of the first "
00109 "column with tag FIRST_COLUMN\n"
00110 "Relevant outputs are:\n"
00111 "combined cubes (PRO.CATG=x_OBS x=STD,OBJ,PSF)\n"
00112 "reconstructed cube (PRO.CATG=COADD_x_OBS x=STD,OBJ,PSF)\n"
00113 "An average along Z of the reconstructed cube \n"
00114 "(PRO.CATG=MED_x_OBS x=STD,OBJ,PSF)\n"
00115 "The bad pixel map associated to the cube \n"
00116 "(PRO.CATG=BP_MAP_COADD_x_OBS x=STD,OBJ,PSF)\n";
00117 
00118 
00119 static char sinfo_step_jitter_description4[] =
00120 "Information on relevant parameters can be found with\n"
00121 "esorex --params sinfo_step_jitter\n"
00122 "esorex --help sinfo_step_jitter\n"
00123 "\n";
00124 
00125 static char sinfo_step_jitter_description[1400];
00126 
00127 /*-----------------------------------------------------------------------------
00128                                 Functions code
00129  ----------------------------------------------------------------------------*/
00130 /*---------------------------------------------------------------------------*/
00135 /*---------------------------------------------------------------------------*/
00136 
00137 
00138 /*---------------------------------------------------------------------------*/
00147 /*---------------------------------------------------------------------------*/
00148 
00149 int
00150 cpl_plugin_get_info(cpl_pluginlist *list)
00151 {
00152 
00153   cpl_recipe *recipe = cpl_calloc(1, sizeof *recipe);
00154   cpl_plugin *plugin = &recipe->interface;
00155 
00156   strcpy(sinfo_step_jitter_description,sinfo_step_jitter_description1);
00157   strcat(sinfo_step_jitter_description,sinfo_step_jitter_description2);
00158   strcat(sinfo_step_jitter_description,sinfo_step_jitter_description3);
00159   strcat(sinfo_step_jitter_description,sinfo_step_jitter_description4);
00160 
00161   cpl_plugin_init(plugin,
00162           CPL_PLUGIN_API,
00163           SINFONI_BINARY_VERSION,
00164           CPL_PLUGIN_TYPE_RECIPE,
00165           "sinfo_step_jitter",
00166           "Object or STD star or PSF star data reduction",
00167            sinfo_step_jitter_description,
00168           "Andrea Modigliani",
00169           "Andrea.Mdigliani@eso.org",
00170           sinfo_get_license(),
00171           sinfo_step_jitter_create,
00172           sinfo_step_jitter_exec,
00173           sinfo_step_jitter_destroy);
00174 
00175   cpl_pluginlist_append(list, plugin);
00176 
00177   return 0;
00178 
00179 }
00180 
00181 /*---------------------------------------------------------------------------*/
00189 /*---------------------------------------------------------------------------*/
00190 static int sinfo_step_jitter_create(cpl_plugin *plugin)
00191 {
00192     cpl_recipe      * recipe ;
00193 
00194     /* Check that the plugin is part of a valid recipe */
00195     if (cpl_plugin_get_type(plugin) == CPL_PLUGIN_TYPE_RECIPE) 
00196         recipe = (cpl_recipe *)plugin ;
00197     else return -1 ;
00198 
00199     /* Create the parameters list in the cpl_recipe object */
00200     recipe->parameters = cpl_parameterlist_new() ; 
00201   cpl_error_reset();
00202   irplib_reset();
00203 
00204 
00205   /*
00206    * Fill the parameter list.
00207    */
00208 
00209   sinfo_prepare_stacked_frames_config_add(recipe->parameters);
00210   sinfo_objnod_config_add(recipe->parameters); 
00211   sinfo_skycor_config_add(recipe->parameters); 
00212   sinfo_standard_star_config_add(recipe->parameters);
00213   sinfo_psf_config_add(recipe->parameters);
00214 
00215   return 0;
00216 
00217 }
00218 
00219 /*---------------------------------------------------------------------------*/
00225 /*---------------------------------------------------------------------------*/
00226 static int sinfo_step_jitter_exec(cpl_plugin *plugin)
00227 {
00228  
00229   cpl_recipe *recipe = (cpl_recipe *) plugin;
00230 
00231   /* Get the recipe out of the plugin */
00232   if (cpl_plugin_get_type(plugin) == CPL_PLUGIN_TYPE_RECIPE) 
00233       recipe = (cpl_recipe *)plugin ;
00234   else return -1 ;
00235 
00236   return sinfo_step_jitter(recipe->parameters, recipe->frames);
00237 
00238 }
00239 
00240 /*---------------------------------------------------------------------------*/
00246 /*---------------------------------------------------------------------------*/
00247 static int sinfo_step_jitter_destroy(cpl_plugin *plugin)
00248 {
00249 
00250    cpl_recipe  *   recipe ;
00251     
00252     /* Get the recipe out of the plugin */
00253     if (cpl_plugin_get_type(plugin) == CPL_PLUGIN_TYPE_RECIPE) 
00254         recipe = (cpl_recipe *)plugin ;
00255     else return -1 ;
00256 
00257   cpl_parameterlist_delete(recipe->parameters);
00258 
00259   return 0;
00260 
00261 }
00262 
00263 /*---------------------------------------------------------------------------*/
00270 /*---------------------------------------------------------------------------*/
00271 
00272 /*
00273  * The actual recipe actually start here.
00274  */
00275 
00276 static int sinfo_step_jitter(cpl_parameterlist *config, cpl_frameset *set)
00277 {
00278   const char* pro_ctg_cube=NULL;
00279   int ind=0;
00280   cpl_parameter* p=NULL;
00281   int psf_sw=0;
00282   int std_sw=0;
00283   cpl_frameset* obj_set=NULL;
00284   cpl_frame* obj_frm=NULL;
00285   char tag[FILE_NAME_SZ];
00286 
00287   if(sinfo_dfs_set_groups(set)) {
00288     sinfo_msg_error("Cannot indentify RAW and CALIB frames") ;
00289     return -1;
00290   }
00291 
00292  obj_set=cpl_frameset_new();
00293  sinfo_extract_obj_products(set,obj_set);
00294  if(NULL == (obj_frm = cpl_frameset_get_frame(obj_set,0))) {
00295    sinfo_msg_error("No object frames in input set.");
00296    cpl_frameset_delete(obj_set);
00297    return -1;
00298  }
00299 
00300  strcpy(tag,cpl_frame_get_tag(obj_frm));
00301  if(NULL!=sinfo_new_set_obj_procatg(tag)){
00302    pro_ctg_cube=sinfo_new_set_obj_procatg(tag);
00303  } else {
00304     sinfo_msg_error("Frame tag %s not supported.",tag);
00305     cpl_frameset_delete(obj_set);
00306     return -1;
00307  }
00308  cpl_frameset_delete(obj_set);
00309 
00310     /* =============================================================== 
00311         SCI OBJNOD 
00312         =============================================================== */
00313 
00314     {
00315         /* Launch the recipe */
00316     /* 
00317      * MAIN CALL TO spiffi_new_objnod recipe
00318      */
00319       /*
00320         sinfo_msg("------------------------------") ; 
00321             sinfo_msg("NODDING SCIENCE FRAMES");
00322         sinfo_msg("------------------------------") ; 
00323 
00324 
00325         if ( -1 == (ind = sinfo_new_objnod(cpl_func,config, set, pro_ctg_cube ) ) )
00326         {
00327             sinfo_msg_error("NODDING SCIENCE FRAMES no. %d\n", ind) ;
00328         return -1 ;
00329         }
00330         sinfo_msg("------------------------------") ; 
00331             sinfo_msg("NODDED SCIENCE FRAMES");
00332         sinfo_msg("------------------------------") ; 
00333       */
00334     } 
00335 
00336 
00337     /* =============================================================== 
00338         PSF
00339         =============================================================== */
00340   
00341     if((strcmp(pro_ctg_cube,PRO_COADD_OBJ) == 0) ||
00342         (strcmp(pro_ctg_cube,PRO_COADD_PSF) == 0) ||
00343         (strcmp(pro_ctg_cube,PRO_COADD_STD) == 0) ||
00344         (strcmp(pro_ctg_cube,PRO_COADD_PUPIL) == 0) ) {
00345 
00346       
00347       p = cpl_parameterlist_find(config, "sinfoni.psf.switch");
00348       psf_sw = cpl_parameter_get_bool(p);
00349       sinfo_msg("switch=%d",psf_sw);
00350       if(psf_sw) {
00351     sinfo_msg("------------------------------") ;
00352     sinfo_msg("REDUCE PSF STD STAR FRAMES");
00353     sinfo_msg("------------------------------") ; 
00354     if ( -1 == (ind = sinfo_new_psf(cpl_func,config,set) ) )
00355       {
00356         sinfo_msg("no: %d\n", ind) ;
00357         return -1 ;
00358       }
00359     sinfo_msg("SUCCESS REDUCE PSF STD STAR FRAMES") ;
00360       }
00361       
00362       p = cpl_parameterlist_find(config, "sinfoni.std_star.switch");
00363       std_sw = cpl_parameter_get_bool(p);
00364       sinfo_msg("switch=%d",std_sw);
00365       if(std_sw) {
00366     sinfo_msg("------------------------------") ;
00367     sinfo_msg("STD STAR DATA REDUCTION");
00368     sinfo_msg("------------------------------") ;
00369 
00370 
00371     if ( -1 == (ind = sinfo_new_stdstar(cpl_func,config, set ) ) )
00372       {
00373         sinfo_msg("REDUCING STD STAR DATA No: %d",ind) ;
00374         return -1 ;
00375       }
00376     sinfo_msg("STD STAR DATA REDUCTION SUCCESS") ;
00377       }
00378 
00379     }   
00380   return 0 ;
00381 }
00382 
00383 

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