X-shooter Pipeline Reference Manual 3.8.15
xsh_divide.c
Go to the documentation of this file.
1/* *
2 * This file is part of the ESO X-shooter Pipeline *
3 * Copyright (C) 2006 European Southern Observatory *
4 * *
5 * This library is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) any later version. *
9 * *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
14 * *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the Free Software *
17 * Foundation, 51 Franklin St, Fifth Floor, Boston, MA 02111-1307 USA *
18 * */
19
20/*
21 * $Author: amodigli $
22 * $Date: 2011-12-02 14:15:28 $
23 * $Revision: 1.13 $
24 * $Name: not supported by cvs2svn $
25 */
26
27#ifdef HAVE_CONFIG_H
28#include <config.h>
29#endif
30
31/*---------------------------------------------------------------------------*/
38/*---------------------------------------------------------------------------*/
41/*---------------------------------------------------------------------------
42 Includes
43 ----------------------------------------------------------------------------*/
44#include <math.h>
45
46#include <xsh_drl.h>
47#include <xsh_pfits.h>
48#include <xsh_error.h>
49#include <xsh_msg.h>
50#include <xsh_badpixelmap.h>
51#include <xsh_data_order.h>
52#include <xsh_data_grid.h>
53
54/*---------------------------------------------------------------------------
55 Typedefs
56 ---------------------------------------------------------------------------*/
57
58/*---------------------------------------------------------------------------
59 Functions prototypes
60 ---------------------------------------------------------------------------*/
61
62/*---------------------------------------------------------------------------
63 Implementation
64 ---------------------------------------------------------------------------*/
65
75cpl_frame * xsh_divide_flat( cpl_frame * frame, cpl_frame * flat,
76 const char* tag, xsh_instrument* instr)
77{
78 /* MUST BE DEALLOCATED in caller */
79 cpl_frame * result = NULL;
80 /* ALLOCATED locally */
81 xsh_pre* xframe = NULL;
82 xsh_pre* xflat = NULL;
83 char filename[256];
84
85 /* check input */
89
90 /* load the frames */
91 check( xframe = xsh_pre_load( frame, instr));
92 check( xflat = xsh_pre_load( flat, instr));
93
94 /* do the divide operation */
95 check( xsh_pre_divide( xframe, xflat, 1, XSH_DIVIDE_FLAT_THRESH));
96 sprintf( filename, "%s.fits", tag);
97 /* save result */
98
99 check(result = xsh_pre_save (xframe, filename, tag,0));
100
101
102 check( cpl_frame_set_tag (result, tag));
103
104 cleanup:
105 if ( cpl_error_get_code() != CPL_ERROR_NONE) {
106 xsh_free_frame(&result);
107 }
108 xsh_pre_free( &xframe);
109 xsh_pre_free( &xflat);
110 return result;
111}
112
xsh_pre * xsh_pre_load(cpl_frame *frame, xsh_instrument *instr)
Load a xsh_pre structure from a frame.
Definition: xsh_data_pre.c:849
void xsh_pre_divide(xsh_pre *self, const xsh_pre *right, const int is_flat, double threshold)
Divide a PRE image from another.
void xsh_pre_free(xsh_pre **pre)
Free a xsh_pre structure.
Definition: xsh_data_pre.c:823
cpl_frame * xsh_pre_save(const xsh_pre *pre, const char *filename, const char *tag, int temp)
Save PRE on disk.
cpl_frame * xsh_divide_flat(cpl_frame *frame, cpl_frame *flat, const char *tag, xsh_instrument *instr)
divide PRE frame with the master FLAT frame
Definition: xsh_divide.c:75
#define check(COMMAND)
Definition: xsh_error.h:71
#define XSH_ASSURE_NOT_NULL(pointer)
Definition: xsh_error.h:99
void xsh_free_frame(cpl_frame **f)
Deallocate a frame and set the pointer to NULL.
Definition: xsh_utils.c:2269
#define XSH_DIVIDE_FLAT_THRESH
Definition: xsh_drl.h:151