00001 /* * 00002 * This file is part of the ESO X-shooter Pipeline * 00003 * Copyright (C) 2006 European Southern Observatory * 00004 * * 00005 * This library is free software; you can redistribute it and/or modify * 00006 * it under the terms of the GNU General Public License as published by * 00007 * the Free Software Foundation; either version 2 of the License, or * 00008 * (at your option) any later version. * 00009 * * 00010 * This program is distributed in the hope that it will be useful, * 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 00013 * GNU General Public License for more details. * 00014 * * 00015 * You should have received a copy of the GNU General Public License * 00016 * along with this program; if not, write to the Free Software * 00017 * Foundation, 51 Franklin St, Fifth Floor, Boston, MA 02111-1307 USA * 00018 * */ 00019 00020 /* 00021 * $Author: amodigli $ 00022 * $Date: 2011/12/02 14:15:28 $ 00023 * $Revision: 1.13 $ 00024 * $Name: HEAD $ 00025 */ 00026 00027 #ifdef HAVE_CONFIG_H 00028 #include <config.h> 00029 #endif 00030 00031 /*---------------------------------------------------------------------------*/ 00038 /*---------------------------------------------------------------------------*/ 00041 /*--------------------------------------------------------------------------- 00042 Includes 00043 ----------------------------------------------------------------------------*/ 00044 #include <math.h> 00045 00046 #include <xsh_drl.h> 00047 #include <xsh_pfits.h> 00048 #include <xsh_error.h> 00049 #include <xsh_msg.h> 00050 #include <xsh_badpixelmap.h> 00051 #include <xsh_data_order.h> 00052 #include <xsh_data_grid.h> 00053 00054 /*--------------------------------------------------------------------------- 00055 Typedefs 00056 ---------------------------------------------------------------------------*/ 00057 00058 /*--------------------------------------------------------------------------- 00059 Functions prototypes 00060 ---------------------------------------------------------------------------*/ 00061 00062 /*--------------------------------------------------------------------------- 00063 Implementation 00064 ---------------------------------------------------------------------------*/ 00065 00075 cpl_frame * xsh_divide_flat( cpl_frame * frame, cpl_frame * flat, 00076 const char* tag, xsh_instrument* instr) 00077 { 00078 /* MUST BE DEALLOCATED in caller */ 00079 cpl_frame * result = NULL; 00080 /* ALLOCATED locally */ 00081 xsh_pre* xframe = NULL; 00082 xsh_pre* xflat = NULL; 00083 char filename[256]; 00084 00085 /* check input */ 00086 XSH_ASSURE_NOT_NULL(frame); 00087 XSH_ASSURE_NOT_NULL(flat); 00088 XSH_ASSURE_NOT_NULL(instr); 00089 00090 /* load the frames */ 00091 check( xframe = xsh_pre_load( frame, instr)); 00092 check( xflat = xsh_pre_load( flat, instr)); 00093 00094 /* do the divide operation */ 00095 check( xsh_pre_divide( xframe, xflat, XSH_DIVIDE_FLAT_THRESH)); 00096 sprintf( filename, "%s.fits", tag); 00097 /* save result */ 00098 00099 check(result = xsh_pre_save (xframe, filename, tag,0)); 00100 00101 00102 check( cpl_frame_set_tag (result, tag)); 00103 00104 cleanup: 00105 if ( cpl_error_get_code() != CPL_ERROR_NONE) { 00106 xsh_free_frame(&result); 00107 } 00108 xsh_pre_free( &xframe); 00109 xsh_pre_free( &xflat); 00110 return result; 00111 } 00112