visir_img_psf.c

00001 /* $Id: visir_img_psf.c,v 1.72 2009/02/27 10:49:49 llundin Exp $
00002  *
00003  * This file is part of the VISIR 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., 51 Franklin St, Fifth Floor, Boston, MA  02111-1307  USA
00019  */
00020 
00021 /*
00022  * $Author: llundin $
00023  * $Date: 2009/02/27 10:49:49 $
00024  * $Revision: 1.72 $
00025  * $Name: visir-3_5_0 $
00026  */
00027 
00028 #ifdef HAVE_CONFIG_H
00029 #include <config.h>
00030 #endif
00031 
00032 
00033 
00034 /*-----------------------------------------------------------------------------
00035                                 Includes
00036  -----------------------------------------------------------------------------*/
00037 
00038 #include "visir_recipe.h"
00039 
00040 /*-----------------------------------------------------------------------------
00041                                 Defines
00042  -----------------------------------------------------------------------------*/
00043 
00044 #define RECIPE_STRING "visir_img_psf"
00045 
00046 /*-----------------------------------------------------------------------------
00047                             Private Functions prototypes
00048  -----------------------------------------------------------------------------*/
00049 
00050 static cpl_error_code visir_img_psf_save(cpl_frameset *,
00051                                          const cpl_parameterlist *,
00052                                          const cpl_table *);
00053 
00054 VISIR_RECIPE_DEFINE(visir_img_psf,
00055                     VISIR_PARAM_NODPOS | VISIR_PARAM_AUTOBPM |
00056                     VISIR_PARAM_STRIPITE | VISIR_PARAM_STRIPMOR |
00057                     VISIR_PARAM_STRIPNON |
00058                     VISIR_PARAM_GLITCH | VISIR_PARAM_PURGE,
00059                     "PSF recipe",
00060                     "This recipe simply computes the FWHM of a bright object.\n"
00061                     "The files listed in the Set Of Frames (sof-file) "
00062                     "must be tagged:\n"
00063                     "VISIR-psf-file.fits " VISIR_IMG_PSF_RAW "\n"
00064                     MAN_VISIR_CALIB_BPM_IMG);
00065 
00066 /*----------------------------------------------------------------------------*/
00070 /*----------------------------------------------------------------------------*/
00071 
00072 /*-----------------------------------------------------------------------------
00073                                 Functions code
00074  -----------------------------------------------------------------------------*/
00075 
00076 /*----------------------------------------------------------------------------*/
00083 /*----------------------------------------------------------------------------*/
00084 static int visir_img_psf(cpl_frameset            * framelist,
00085                          const cpl_parameterlist * parlist)
00086 {
00087     irplib_framelist * allframes = NULL;
00088     irplib_framelist * rawframes = NULL;
00089     const char      *   badpix;
00090     const char      *   flat;
00091     cpl_imagelist   *   nodded = NULL;
00092     cpl_table       *   tab = NULL;
00093     int                 nfiles;
00094 
00095 
00096     /* Identify the RAW and CALIB frames in the input frameset */
00097     skip_if (visir_dfs_set_groups(framelist));
00098 
00099     /* Objects observation */
00100     allframes = irplib_framelist_cast(framelist);
00101     skip_if(allframes == NULL);
00102     rawframes = irplib_framelist_extract(allframes, VISIR_IMG_PSF_RAW);
00103     skip_if (rawframes == NULL);
00104 
00105     skip_if(irplib_framelist_load_propertylist_all(rawframes, 0,
00106                                                    visir_property_regexp,
00107                                                    CPL_FALSE));
00108 
00109     skip_if(visir_dfs_check_framelist_tag(rawframes));
00110     
00111     /* Bad pixels calibration file */
00112     badpix = irplib_frameset_find_file(framelist, VISIR_CALIB_BPM);
00113 
00114     /* Flatfield calibration file */
00115     flat = irplib_frameset_find_file(framelist, VISIR_CALIB_FLAT);
00116 
00117     /* Combine the frames */
00118     cpl_msg_info(cpl_func, "Construct the nodded images");
00119     nodded = visir_inputs_combine(RECIPE_STRING, parlist, rawframes, badpix, flat,
00120                                 NULL, CPL_FALSE, 0.0, 0);
00121     if (nodded == NULL) {
00122         cpl_msg_error(cpl_func, "Cannot combine the input frames");
00123         skip_if(1);
00124     }
00125 
00126     nfiles = cpl_imagelist_get_size(nodded);
00127     
00128     /* Create table Allocate and initialise arrays */
00129     tab = visir_table_new_xypos(nodded, "FWHM");
00130 
00131     skip_if (tab == NULL);
00132 
00133     /* Save the combined image */
00134     cpl_msg_info(cpl_func, "Save the produced combined image");
00135     skip_if (visir_img_psf_save(framelist, parlist, tab));
00136 
00137     end_skip;
00138 
00139     irplib_framelist_delete(allframes);
00140     irplib_framelist_delete(rawframes);
00141     cpl_imagelist_delete(nodded);
00142 
00143     cpl_table_delete(tab);
00144 
00145     return cpl_error_get_code();
00146 }
00147 
00148 /*----------------------------------------------------------------------------*/
00156 /*----------------------------------------------------------------------------*/
00157 static cpl_error_code visir_img_psf_save(cpl_frameset            * set,
00158                                          const cpl_parameterlist * parlist,
00159                                          const cpl_table         * tab)
00160 {
00161 
00162     skip_if(irplib_dfs_save_table(set, parlist, set, tab, NULL, RECIPE_STRING,
00163                               VISIR_IMG_PSF_TAB_PROCATG, NULL, NULL,
00164                               visir_pipe_id, RECIPE_STRING CPL_DFS_FITS));
00165 
00166     end_skip;
00167 
00168     return cpl_error_get_code();
00169 }

Generated on Mon Feb 6 15:23:49 2012 for VISIR Pipeline Reference Manual by  doxygen 1.5.8