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.4 $ 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_pre.h> 00053 #include <xsh_data_grid.h> 00054 00055 /*--------------------------------------------------------------------------- 00056 Typedefs 00057 ---------------------------------------------------------------------------*/ 00058 00059 /*--------------------------------------------------------------------------- 00060 Functions prototypes 00061 ---------------------------------------------------------------------------*/ 00062 00063 /*--------------------------------------------------------------------------- 00064 Implementation 00065 ---------------------------------------------------------------------------*/ 00066 00067 00077 cpl_frame * xsh_multiply_flat( cpl_frame * frame, cpl_frame * flat, 00078 const char* tag, xsh_instrument* instr) 00079 { 00080 /* MUST BE DEALLOCATED in caller */ 00081 cpl_frame * result = NULL; 00082 /* ALLOCATED locally */ 00083 xsh_pre* xframe = NULL; 00084 xsh_pre* xflat = NULL; 00085 char filename[256]; 00086 00087 /* check input */ 00088 XSH_ASSURE_NOT_NULL(frame); 00089 XSH_ASSURE_NOT_NULL(flat); 00090 XSH_ASSURE_NOT_NULL(instr); 00091 00092 /* load the frames */ 00093 check( xframe = xsh_pre_load( frame, instr)); 00094 check( xflat = xsh_pre_load( flat, instr)); 00095 00096 /* do the divide operation */ 00097 check( xsh_pre_multiply( xframe, xflat, XSH_MULTIPLY_FLAT_THRESH)); 00098 sprintf( filename, "%s.fits", tag); 00099 /* save result */ 00100 00101 check(result = xsh_pre_save (xframe, filename, tag,1)); 00102 00103 00104 check( cpl_frame_set_tag (result, tag)); 00105 00106 cleanup: 00107 if ( cpl_error_get_code() != CPL_ERROR_NONE) { 00108 xsh_free_frame(&result); 00109 } 00110 xsh_pre_free( &xframe); 00111 xsh_pre_free( &xflat); 00112 return result; 00113 } 00114