X-shooter Pipeline Reference Manual 3.8.15
xsh_multiply.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.4 $
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_pre.h>
53#include <xsh_data_grid.h>
54
55/*---------------------------------------------------------------------------
56 Typedefs
57 ---------------------------------------------------------------------------*/
58
59/*---------------------------------------------------------------------------
60 Functions prototypes
61 ---------------------------------------------------------------------------*/
62
63/*---------------------------------------------------------------------------
64 Implementation
65 ---------------------------------------------------------------------------*/
66
67
77cpl_frame * xsh_multiply_flat( cpl_frame * frame, cpl_frame * flat,
78 const char* tag, xsh_instrument* instr)
79{
80 /* MUST BE DEALLOCATED in caller */
81 cpl_frame * result = NULL;
82 /* ALLOCATED locally */
83 xsh_pre* xframe = NULL;
84 xsh_pre* xflat = NULL;
85 char filename[256];
86
87 /* check input */
91
92 /* load the frames */
93 check( xframe = xsh_pre_load( frame, instr));
94 check( xflat = xsh_pre_load( flat, instr));
95
96 /* do the divide operation */
98 sprintf( filename, "%s.fits", tag);
99 /* save result */
100
101 check(result = xsh_pre_save (xframe, filename, tag,1));
102
103
104 check( cpl_frame_set_tag (result, tag));
105
106 cleanup:
107 if ( cpl_error_get_code() != CPL_ERROR_NONE) {
108 xsh_free_frame(&result);
109 }
110 xsh_pre_free( &xframe);
111 xsh_pre_free( &xflat);
112 return result;
113}
114
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_multiply(xsh_pre *self, const xsh_pre *right, double threshold)
Multiply 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.
#define check(COMMAND)
Definition: xsh_error.h:71
#define XSH_ASSURE_NOT_NULL(pointer)
Definition: xsh_error.h:99
cpl_frame * xsh_multiply_flat(cpl_frame *frame, cpl_frame *flat, const char *tag, xsh_instrument *instr)
multiply PRE frame with the master FLAT frame
Definition: xsh_multiply.c:77
void xsh_free_frame(cpl_frame **f)
Deallocate a frame and set the pointer to NULL.
Definition: xsh_utils.c:2269
#define XSH_MULTIPLY_FLAT_THRESH
Definition: xsh_drl.h:155