ERIS Pipeline Reference Manual 1.9.2
eris_nix_img_skysub.c
1/* $Id$
2 *
3 * This file is part of the ERIS Pipeline
4 * Copyright (C) 2017 European Southern Observatory
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20
21/*
22 * $Author$
23 * $Date$
24 * $Revision$
25 */
26
27#ifdef HAVE_CONFIG_H
28#include <config.h>
29#endif
30
31/*-----------------------------------------------------------------------------
32 Includes
33 -----------------------------------------------------------------------------*/
34
35//#include <libgen.h>
36//#include <math.h>
37/*#include <regex.h>*/
38#include <string.h>
39
40//#include "casu_utils.h"
41//#include "casu_mods.h"
42/*#include "casu_getstds.c"
43*/
44
45//#include "eris_utils.h"
46//#include "eris_nix_utils.h"
47//#include "eris_pfits.h"
48//#include "eris_dfs.h"
49#include "eris_nix_dfs.h"
50//#include "eris_nix_catalogue.h"
51//#include "eris_nix_master_bpm.h"
52//#include "eris_nix_master_dark.h"
53//#include "eris_nix_match.h"
54//#include "eris_nix_gain_linearity.h"
55//#include <hdrl.h>
56#include <eris_nix_scired.h>
57#include <cpl.h>
58
59/*-----------------------------------------------------------------------------
60 Static variables
61 -----------------------------------------------------------------------------*/
62
63static const char eris_nix_img_skysub_description[] =
64"This recipe estimates and subtracts the sky background from a set of \n"
65ERIS_NIX_CAL_DET_OBJECT_JITTER_PRO_CATG" or "
66ERIS_NIX_CAL_DET_STD_JITTER_PRO_CATG" frames.\n"
67"\n"
68"Input files:\n"
69"\n"
70" The recipe has 2 modes of operation.\n"
71" If --sky-source='target' then the sky background will be estimated \n"
72" from the target frames themselves.\n"
73"\n"
74" DO CATG Explanation Req. #Frames\n"
75" ------- ----------- --- -------\n"
76" "ERIS_NIX_CAL_DET_OBJECT_JITTER_PRO_CATG
77 " target frames with the Y 1-n\n"
78" or detector signature\n"
79" "ERIS_NIX_CAL_DET_STD_JITTER_PRO_CATG
80 " removed.\n"
81"\n"
82" If --sky-source='offset' and for "
83ERIS_NIX_CAL_DET_OBJECT_JITTER_PRO_CATG"\n"
84" data only, the sky background will be estimated from a set of \n"
85" frames offset from the target region.\n"
86"\n"
87" DO CATG Explanation Req. #Frames\n"
88" ------- ----------- --- -------\n"
89" "ERIS_NIX_CAL_DET_OBJECT_JITTER_PRO_CATG
90 " target frames with the Y 1-n\n"
91" detector signature\n"
92" removed.\n"
93" "ERIS_NIX_CAL_DET_SKY_JITTER_PRO_CATG
94 " sky frames with the Y 1-m\n"
95" detector signature\n"
96" removed.\n"
97"\n"
98"Output files:\n"
99"\n"
100" DO CATG Explanation \n"
101" ------- ----------- \n"
102" "ERIS_NIX_SKYSUB_OBJECT_JITTER_PRO_CATG
103 " target frames with the sky removed.\n"
104" or\n"
105" "ERIS_NIX_SKYSUB_STD_JITTER_PRO_CATG"\n"
106"\n"
107" The output will be FITS files named 'skysub.<input filename>',\n"
108" containing extensions:\n"
109" - DATA, with the target data.\n"
110" - ERR, with the target error plane.\n"
111" - DQ, with the target data quality plane.\n"
112" - CONFIDENCE, with the target confidence plane.\n"
113" - BKG_DATA, with the estimated sky background.\n"
114" - BKG_ERR, with the error on the sky background.\n"
115" - BKG_CONF, with the confidence of the sky background.\n"
116"\n"
117"Notes on the method.\n"
118" Sky frames are taken from the pool of target or offset\n"
119" according to param --sky-source.\n"
120"\n"
121" The background for each frame is estimated from sky frames\n"
122" taken within sky-bracket-time/2 seconds of it.\n"
123"\n"
124" A first estimate of the background is made.\n"
125" If param --sky-method='collapse-median':\n"
126" - The estimate is a median collapse of the sky frames\n"
127" selected. This is prone to problems if the field is\n"
128" very crowded.\n"
129" If --sky-method='median-median':\n"
130" - The median of each sky frame is obtained, and the\n"
131" background frame set at the median of those values.\n"
132" The background is forced to be flat, which is more\n"
133" robust in crowded fields, or where there is\n"
134" nebulosity.\n"
135"\n"
136" The estimated backgrounds are subtracted from the sky\n"
137" frames, and a search made for objects in each image.\n"
138" Object masks are constructed which blank out astronomical\n"
139" flux the sky frames. The --catalogue.xxx params listed\n"
140" below are used in this search for objects.\n"
141"\n"
142" The masked sky frames are then used to re-estimate the\n"
143" sky backgrounds following the same sky-method.\n";
144
145
146#define RECIPE_NAME "eris.eris_nix_img_skysub"
147#define CONTEXT "eris."RECIPE_NAME
148/*-----------------------------------------------------------------------------
149 Private function prototypes
150 -----------------------------------------------------------------------------*/
151
152cpl_recipe_define(eris_nix_img_skysub, ERIS_BINARY_VERSION,
153 "John Lightfoot",
154 PACKAGE_BUGREPORT, "2017",
155 "Subtract sky background from frames",
156 eris_nix_img_skysub_description);
157
158/*-----------------------------------------------------------------------------
159 Function code
160 -----------------------------------------------------------------------------*/
161
162/*----------------------------------------------------------------------------*/
170/*----------------------------------------------------------------------------*/
171
172static cpl_error_code eris_nix_img_skysub_fill_parameterlist(
173 cpl_parameterlist * self) {
174
175 if (cpl_error_get_code() != CPL_ERROR_NONE) return cpl_error_get_code();
176
177
178 /* generate the general parameter list for the catalogue */
179 eris_nix_catalogue_param_set(CONTEXT, self, 20, 3.0, CPL_TRUE,
180 5.0, CPL_TRUE, 64, 2.0, 3.0, ERIS_NIX_SATURATION_DEFAULT, HDRL_CATALOGUE_ALL);
181
182
183
184 /* now the recipe-specific parameters */
185 eris_nix_skysub_param_set(CONTEXT, self);
186
187 /* coords of pixel to be used for diagnostics during reduction */
188 eris_nix_pixel_coord_diagnostic_param_set(CONTEXT, self);
189
190
191
192 return 0;
193}
194
195/*----------------------------------------------------------------------------*/
202/*----------------------------------------------------------------------------*/
203
204static int eris_nix_img_skysub(cpl_frameset * frameset,
205 const cpl_parameterlist * parlist) {
206
207
208 eris_nix_scired_skysub(frameset, parlist, RECIPE_NAME, CONTEXT);
209
210 return (int) cpl_error_get_code();
211}
cpl_error_code eris_nix_scired_skysub(cpl_frameset *frameset, const cpl_parameterlist *parlist, const char *recipe_name, const char *context)
This recipe estimates and subtracts the sky background from a set of science frames.