sinfo_step_jitter.c

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

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