SINFONI Pipeline Reference Manual  2.6.0
sinfo_psf_ini_by_cpl.c
1 /*
2  * This file is part of the ESO SINFONI Pipeline
3  * Copyright (C) 2004,2005 European Southern Observatory
4  *
5  * This program 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  File name : sinfo_psf_ini_by_cpl.c
22  Author : Andrea Modigliani
23  Created on : May 20, 2004
24  Description : cpl input for sinfo_psf step for SPIFFI
25 
26 
27  ---------------------------------------------------------------------------*/
28 
29 
30 
31 #ifdef HAVE_CONFIG_H
32 # include <config.h>
33 #endif
34 /*---------------------------------------------------------------------------
35  Includes
36  ---------------------------------------------------------------------------*/
37 
38 #include "sinfo_psf_ini_by_cpl.h"
39 #include "sinfo_hidden.h"
40 
41 
42 /*---------------------------------------------------------------------------
43  Functions private to this module
44  ---------------------------------------------------------------------------*/
45 static void parse_section_frames(psf_config *,
46  cpl_frameset* sof,cpl_frameset** stk,int* status);
47 static void parse_section_reconstruction(psf_config *);
48 
49 
58 /*-------------------------------------------------------------------------*/
69 /*--------------------------------------------------------------------------*/
70 
71 psf_config * sinfo_parse_cpl_input_psf(cpl_frameset* sof,
72  cpl_frameset** stk)
73 {
74  psf_config * cfg =NULL;
75  int status=0;
76  /*
77  * Perform sanity checks, fill up the structure with what was
78  * found in the ini file
79  */
80 
81  cfg = sinfo_psf_cfg_create();
82  parse_section_reconstruction (cfg);
83  parse_section_frames (cfg, sof,stk,&status);
84  if (status > 0) {
85  sinfo_msg_error("parsing cpl input");
86  sinfo_psf_cfg_destroy(cfg);
87  cfg = NULL ;
88  return NULL ;
89  }
90  return cfg ;
91 }
92 
93 static void
94 parse_section_frames(psf_config * cfg,
95  cpl_frameset* sof,
96  cpl_frameset** stk,
97  int* status)
98 {
99  cpl_frame* frame = NULL;
100 
101  int npsf=0;
102  //int nraw=0;
103  char spat_res[FILE_NAME_SZ];
104  char lamp_status[FILE_NAME_SZ];
105  char band[FILE_NAME_SZ];
106  int ins_set=0;
107 
108  sinfo_contains_frames_type(sof,stk,PRO_PSF_CALIBRATOR_STACKED);
109  npsf = cpl_frameset_get_size(*stk);
110  if (npsf < 1) {
111  sinfo_contains_frames_type(sof,stk,PRO_STD_NODDING_STACKED);
112  npsf = cpl_frameset_get_size(*stk);
113  }
114 
115  npsf = cpl_frameset_get_size(*stk);
116  if (npsf < 1) {
117  sinfo_contains_frames_type(sof,stk,PRO_OBJECT_NODDING_STACKED);
118  npsf = cpl_frameset_get_size(*stk);
119  }
120 
121 
122  npsf = cpl_frameset_get_size(*stk);
123  if (npsf < 1) {
124  sinfo_contains_frames_type(sof,stk,PRO_PUPIL_LAMP_STACKED);
125  npsf = cpl_frameset_get_size(*stk);
126  }
127 
128  npsf = cpl_frameset_get_size(*stk);
129  if (npsf < 1) {
130  sinfo_msg_error("Cannot find input stacked frames") ;
131  (*status)++;
132  return;
133  }
134 
135  if(NULL != cpl_frameset_find(sof,PRO_COADD_PSF)) {
136  frame = cpl_frameset_find(sof,PRO_COADD_PSF);
137  strcpy(cfg -> inFrame,cpl_frame_get_filename(frame));
138  } else if(NULL != cpl_frameset_find(sof,PRO_OBS_PSF)) {
139  frame = cpl_frameset_find(sof,PRO_OBS_PSF);
140  strcpy(cfg -> inFrame,cpl_frame_get_filename(frame));
141  } else if(NULL != cpl_frameset_find(sof,PRO_COADD_STD)) {
142  frame = cpl_frameset_find(sof,PRO_COADD_STD);
143  strcpy(cfg -> inFrame,cpl_frame_get_filename(frame));
144  } else if(NULL != cpl_frameset_find(sof,PRO_OBS_STD)) {
145  frame = cpl_frameset_find(sof,PRO_OBS_STD);
146  strcpy(cfg -> inFrame,cpl_frame_get_filename(frame));
147  } else if(NULL != cpl_frameset_find(sof,PRO_COADD_OBJ)) {
148  frame = cpl_frameset_find(sof,PRO_COADD_OBJ);
149  strcpy(cfg -> inFrame,cpl_frame_get_filename(frame));
150  } else if(NULL != cpl_frameset_find(sof,PRO_OBS_OBJ)) {
151  frame = cpl_frameset_find(sof,PRO_OBS_OBJ);
152  strcpy(cfg -> inFrame,cpl_frame_get_filename(frame));
153  } else {
154  sinfo_msg_error("Frame %s or %s or %s or %s or %s or %s not found!",
155  PRO_COADD_PSF,PRO_OBS_PSF,
156  PRO_COADD_STD,PRO_OBS_STD,
157  PRO_COADD_OBJ,PRO_OBS_OBJ);
158  (*status)++;
159  return;
160  }
161 
162  strcpy(cfg -> outName, PSF_OUT_FILENAME);
163  //nraw = cpl_frameset_get_size(*stk);
164  frame = cpl_frameset_get_frame(*stk,0);
165 
166  sinfo_get_spatial_res(frame,spat_res);
167  switch(sinfo_frame_is_on(frame))
168  {
169 
170  case 0:
171  strcpy(lamp_status,"on");
172  break;
173  case 1:
174  strcpy(lamp_status,"off");
175  break;
176  case -1:
177  strcpy(lamp_status,"undefined");
178  break;
179  default:
180  strcpy(lamp_status,"undefined");
181  break;
182 
183  }
184 
185  sinfo_get_band(frame,band);
186  sinfo_msg("Spatial resolution: %s lamp status: %s band: %s \n",
187  spat_res, lamp_status, band);
188 
189  sinfo_get_ins_set(band,&ins_set);
190 
191  return;
192 
193 }
194 
195 static void
196 parse_section_reconstruction(psf_config * cfg)
197 {
198  cfg -> nslits = NSLITLETS;
199  return;
200 }
201 
202 void
203 sinfo_free_psf(psf_config ** cfg) {
204  sinfo_psf_cfg_destroy (*cfg);
205  *cfg=NULL;
206  return;
207 }
#define sinfo_msg_error(...)
Print an error message.
Definition: sinfo_msg.h:69