SINFONI Pipeline Reference Manual  2.5.2
recipes/sinfo_utl_spectrum_divide_by_blackbody.c
1 /* $Id: sinfo_utl_spectrum_divide_by_blackbody.c,v 1.10 2007-10-26 09:40:28 amodigli Exp $
2  *
3  * This file is part of the SINFONI 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19  */
20 
21 /*
22  * $Author: amodigli $
23  * $Date: 2007-10-26 09:40:28 $
24  * $Revision: 1.10 $
25  * $Name: not supported by cvs2svn $
26  */
27 
28 #ifdef HAVE_CONFIG_H
29 #include <config.h>
30 #endif
31 
32 /*-----------------------------------------------------------------------------
33  Includes
34  ----------------------------------------------------------------------------*/
35 
36 /* cpl */
37 #include <cpl.h>
38 
39 /* irplib */
40 #include <irplib_utils.h>
41 #include <string.h>
42 #include <sinfo_tpl_utils.h>
43 #include <sinfo_pfits.h>
44 #include <sinfo_tpl_dfs.h>
45 #include <sinfo_msg.h>
46 #include <sinfo_utl_spectrum_divide_by_blackbody.h>
47 /*-----------------------------------------------------------------------------
48  Functions prototypes
49  ----------------------------------------------------------------------------*/
50 
51 static int sinfo_utl_spectrum_divide_by_blackbody_create(cpl_plugin *) ;
52 static int sinfo_utl_spectrum_divide_by_blackbody_exec(cpl_plugin *) ;
53 static int sinfo_utl_spectrum_divide_by_blackbody_destroy(cpl_plugin *) ;
54 
55 /*-----------------------------------------------------------------------------
56  Static variables
57  ----------------------------------------------------------------------------*/
58 
59 static char sinfo_utl_spectrum_divide_by_blackbody_description1[] =
60  "This recipe divides a spectrum by a black body "
61  "spectrum of given temperature.\n"
62  "The input file is a spectrum. Its associated tag must be SPECTRUM.\n"
63  "The output is a spectrum\n";
64 
65 
66 static char sinfo_utl_spectrum_divide_by_blackbody_description2[] =
67  "Parameter is \n"
68  "sinfoni.sinfo_utl_spectrum_divide_by_blackbody.temperature\n"
69  "having aliases 'temp' \n"
70  "\n";
71 
72 static char sinfo_utl_spectrum_divide_by_blackbody_description[900];
73 
74 /*-----------------------------------------------------------------------------
75  Functions code
76  ----------------------------------------------------------------------------*/
77 /*---------------------------------------------------------------------------*/
82 /*---------------------------------------------------------------------------*/
85 /*---------------------------------------------------------------------------*/
93 /*---------------------------------------------------------------------------*/
94 int cpl_plugin_get_info(cpl_pluginlist * list)
95 {
96  cpl_recipe * recipe = cpl_calloc(1, sizeof *recipe ) ;
97  cpl_plugin * plugin = &recipe->interface ;
98 
99  strcpy(sinfo_utl_spectrum_divide_by_blackbody_description,
100  sinfo_utl_spectrum_divide_by_blackbody_description1);
101  strcat(sinfo_utl_spectrum_divide_by_blackbody_description,
102  sinfo_utl_spectrum_divide_by_blackbody_description2);
103 
104  cpl_plugin_init(plugin,
105  CPL_PLUGIN_API,
106  SINFONI_BINARY_VERSION,
107  CPL_PLUGIN_TYPE_RECIPE,
108  "sinfo_utl_spectrum_divide_by_blackbody",
109  "Spectrum normalization by a blackbody",
110  sinfo_utl_spectrum_divide_by_blackbody_description,
111  "Andrea Modigliani",
112  "Andrea.Modigliani@eso.org",
113  sinfo_get_license(),
114  sinfo_utl_spectrum_divide_by_blackbody_create,
115  sinfo_utl_spectrum_divide_by_blackbody_exec,
116  sinfo_utl_spectrum_divide_by_blackbody_destroy) ;
117 
118  cpl_pluginlist_append(list, plugin) ;
119 
120  return 0;
121 }
122 
123 /*---------------------------------------------------------------------------*/
132 /*---------------------------------------------------------------------------*/
133 static int sinfo_utl_spectrum_divide_by_blackbody_create(cpl_plugin * plugin)
134 {
135  cpl_recipe * recipe ;
136  cpl_parameter * p ;
137 
138  /* Get the recipe out of the plugin */
139  if (cpl_plugin_get_type(plugin) == CPL_PLUGIN_TYPE_RECIPE)
140  recipe = (cpl_recipe *)plugin ;
141  else return -1 ;
142 
143  cpl_error_reset();
144  irplib_reset();
145  /* Create the parameters list in the cpl_recipe object */
146  recipe->parameters = cpl_parameterlist_new() ;
147 
148  /* Fill the parameters list */
149  /* --stropt */
150  /* --doubleopt */
151  p = cpl_parameter_new_value("sinfoni.sinfo_utl_spectrum_divide_by_blackbody.temperature",
152  CPL_TYPE_DOUBLE, "Black Body Temperature",
153  "sinfoni.sinfo_utl_spectrum_divide_by_blackbody", 100000.) ;
154  cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "temp") ;
155  cpl_parameterlist_append(recipe->parameters, p) ;
156 
157  /* Return */
158  return 0;
159 }
160 
161 /*---------------------------------------------------------------------------*/
167 /*---------------------------------------------------------------------------*/
168 static int sinfo_utl_spectrum_divide_by_blackbody_exec(cpl_plugin * plugin)
169 {
170  cpl_recipe * recipe ;
171  int code=0;
172 
173  /* Get the recipe out of the plugin */
174  if (cpl_plugin_get_type(plugin) == CPL_PLUGIN_TYPE_RECIPE)
175  recipe = (cpl_recipe *)plugin ;
176  else return -1 ;
177 
178  sinfo_msg("Welcome to SINFONI Pipeline release %d.%d.%d",
179  SINFONI_MAJOR_VERSION,SINFONI_MINOR_VERSION,SINFONI_MICRO_VERSION);
180  code=sinfo_utl_spectrum_divide_by_blackbody(recipe->parameters,
181  recipe->frames) ;
182  return code;
183 }
184 
185 /*---------------------------------------------------------------------------*/
191 /*---------------------------------------------------------------------------*/
192 static int sinfo_utl_spectrum_divide_by_blackbody_destroy(cpl_plugin * plugin)
193 {
194  cpl_recipe * recipe ;
195 
196  /* Get the recipe out of the plugin */
197  if (cpl_plugin_get_type(plugin) == CPL_PLUGIN_TYPE_RECIPE)
198  recipe = (cpl_recipe *)plugin ;
199  else return -1 ;
200 
201  cpl_parameterlist_delete(recipe->parameters) ;
202  return 0 ;
203 }
204