VISIR Pipeline Reference Manual  4.1.7
visir_img_psf.c
1 /* $Id: visir_img_psf.c,v 1.72 2009-02-27 10:49:49 llundin Exp $
2  *
3  * This file is part of the VISIR Pipeline
4  * Copyright (C) 2002,2003 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 02111-1307 USA
19  */
20 
21 /*
22  * $Author: llundin $
23  * $Date: 2009-02-27 10:49:49 $
24  * $Revision: 1.72 $
25  * $Name: not supported by cvs2svn $
26  */
27 
28 #ifdef HAVE_CONFIG_H
29 #include <config.h>
30 #endif
31 
32 
33 
34 /*-----------------------------------------------------------------------------
35  Includes
36  -----------------------------------------------------------------------------*/
37 
38 #include "visir_recipe.h"
39 
40 /*-----------------------------------------------------------------------------
41  Defines
42  -----------------------------------------------------------------------------*/
43 
44 #define RECIPE_STRING "visir_img_psf"
45 
46 /*-----------------------------------------------------------------------------
47  Private Functions prototypes
48  -----------------------------------------------------------------------------*/
49 
50 static cpl_error_code visir_img_psf_save(cpl_frameset *,
51  const cpl_parameterlist *,
52  const cpl_table *);
53 
54 VISIR_RECIPE_DEFINE(visir_img_psf,
55  VISIR_PARAM_NODPOS | VISIR_PARAM_AUTOBPM |
56  VISIR_PARAM_STRIPITE | VISIR_PARAM_STRIPMOR |
57  VISIR_PARAM_STRIPNON |
58  VISIR_PARAM_GLITCH | VISIR_PARAM_PURGE,
59  "PSF recipe",
60  "This recipe simply computes the FWHM of a bright object.\n"
61  "The files listed in the Set Of Frames (sof-file) "
62  "must be tagged:\n"
63  "VISIR-psf-file.fits " VISIR_IMG_PSF_RAW "\n"
64  MAN_VISIR_CALIB_BPM_IMG);
65 
66 /*----------------------------------------------------------------------------*/
70 /*----------------------------------------------------------------------------*/
71 
72 /*-----------------------------------------------------------------------------
73  Functions code
74  -----------------------------------------------------------------------------*/
75 
76 /*----------------------------------------------------------------------------*/
83 /*----------------------------------------------------------------------------*/
84 static int visir_img_psf(cpl_frameset * framelist,
85  const cpl_parameterlist * parlist)
86 {
87  irplib_framelist * allframes = NULL;
88  irplib_framelist * rawframes = NULL;
89  const char * badpix;
90  const char * flat;
91  cpl_imagelist * nodded = NULL;
92  cpl_table * tab = NULL;
93  int nfiles;
94 
95 
96  /* Identify the RAW and CALIB frames in the input frameset */
97  skip_if (visir_dfs_set_groups(framelist));
98 
99  /* Objects observation */
100  allframes = irplib_framelist_cast(framelist);
101  skip_if(allframes == NULL);
102  rawframes = irplib_framelist_extract(allframes, VISIR_IMG_PSF_RAW);
103  skip_if (rawframes == NULL);
104 
105  skip_if(irplib_framelist_load_propertylist_all(rawframes, 0,
106  visir_property_regexp,
107  CPL_FALSE));
108 
109  skip_if(visir_dfs_check_framelist_tag(rawframes));
110 
111  /* Bad pixels calibration file */
112  badpix = irplib_frameset_find_file(framelist, VISIR_CALIB_BPM);
113 
114  /* Flatfield calibration file */
115  flat = irplib_frameset_find_file(framelist, VISIR_CALIB_FLAT);
116 
117  /* Combine the frames */
118  cpl_msg_info(cpl_func, "Construct the nodded images");
119  nodded = visir_inputs_combine(RECIPE_STRING, parlist, rawframes, badpix, flat,
120  NULL, CPL_FALSE, 0.0, 0);
121  if (nodded == NULL) {
122  cpl_msg_error(cpl_func, "Cannot combine the input frames");
123  skip_if(1);
124  }
125 
126  nfiles = cpl_imagelist_get_size(nodded);
127 
128  /* Create table Allocate and initialise arrays */
129  tab = visir_table_new_xypos(nodded, "FWHM");
130 
131  skip_if (tab == NULL);
132 
133  /* Save the combined image */
134  cpl_msg_info(cpl_func, "Save the produced combined image");
135  skip_if (visir_img_psf_save(framelist, parlist, tab));
136 
137  end_skip;
138 
139  irplib_framelist_delete(allframes);
140  irplib_framelist_delete(rawframes);
141  cpl_imagelist_delete(nodded);
142 
143  cpl_table_delete(tab);
144 
145  return cpl_error_get_code();
146 }
147 
148 /*----------------------------------------------------------------------------*/
156 /*----------------------------------------------------------------------------*/
157 static cpl_error_code visir_img_psf_save(cpl_frameset * set,
158  const cpl_parameterlist * parlist,
159  const cpl_table * tab)
160 {
161 
162  skip_if(irplib_dfs_save_table(set, parlist, set, tab, NULL, RECIPE_STRING,
163  VISIR_IMG_PSF_TAB_PROCATG, NULL, NULL,
164  visir_pipe_id, RECIPE_STRING CPL_DFS_FITS));
165 
166  end_skip;
167 
168  return cpl_error_get_code();
169 }
cpl_error_code visir_dfs_check_framelist_tag(const irplib_framelist *self)
Check the tags in a frameset (group raw only)
Definition: visir_dfs.c:218
cpl_error_code irplib_dfs_save_table(cpl_frameset *allframes, const cpl_parameterlist *parlist, const cpl_frameset *usedframes, const cpl_table *table, const cpl_propertylist *tablelist, const char *recipe, const char *procat, const cpl_propertylist *applist, const char *remregexp, const char *pipe_id, const char *filename)
Save a table as a DFS-compliant pipeline product.
Definition: irplib_utils.c:335
cpl_error_code irplib_framelist_load_propertylist_all(irplib_framelist *self, int ind, const char *regexp, cpl_boolean invert)
Load the propertylists of all frames in the framelist.
cpl_imagelist * visir_inputs_combine(const char *recipename, const cpl_parameterlist *parlist, const irplib_framelist *rawframes, const char *badpix, const char *flat, int *nodding_p, cpl_boolean do_spc_fix, double wlen, visir_spc_resol resol)
The VISIR input data re-combination is performed here.
Definition: visir_inputs.c:728
irplib_framelist * irplib_framelist_extract(const irplib_framelist *self, const char *tag)
Extract the frames with the given tag from a framelist.
int visir_dfs_set_groups(cpl_frameset *set)
Set the group as RAW or CALIB in a frameset.
Definition: visir_dfs.c:72
void irplib_framelist_delete(irplib_framelist *self)
Deallocate an irplib_framelist with its frames and properties.
const char * irplib_frameset_find_file(const cpl_frameset *self, const char *tag)
Find the filename with the given tag in a frame set.
irplib_framelist * irplib_framelist_cast(const cpl_frameset *frameset)
Create an irplib_framelist from a cpl_framelist.