SINFONI Pipeline Reference Manual  2.5.2
sinfo_tpl_utils.c
1 /* $Id: sinfo_tpl_utils.c,v 1.4 2013-07-15 08:13:35 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: 2013-07-15 08:13:35 $
24  * $Revision: 1.4 $
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 #include <string.h>
36 #include <cpl.h>
37 
38 #include "sinfo_tpl_utils.h"
39 #include "sinfo_globals.h"
40 
42 /*----------------------------------------------------------------------------*/
46 /*----------------------------------------------------------------------------*/
47 
48 
49 /*----------------------------------------------------------------------------*/
57 /*----------------------------------------------------------------------------*/
58 const char * sinfo_get_license(void)
59 {
60  const char * sinfoni_license =
61  "This file is part of the SINFONI Instrument Pipeline\n"
62  "Copyright (C) 2002,2003 European Southern Observatory\n"
63  "\n"
64  "This program is free software; you can redistribute it and/or modify\n"
65  "it under the terms of the GNU General Public License as published by\n"
66  "the Free Software Foundation; either version 2 of the License, or\n"
67  "(at your option) any later version.\n"
68  "\n"
69  "This program is distributed in the hope that it will be useful,\n"
70  "but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
71  "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n"
72  "GNU General Public License for more details.\n"
73  "\n"
74  "You should have received a copy of the GNU General Public License\n"
75  "along with this program; if not, write to the Free Software\n"
76  "Foundation, Inc., 59 Temple Place, Suite 330, Boston, \n"
77  "MA 02111-1307 USA" ;
78 
79  return sinfoni_license ;
80 }
81 
82 
83 /*---------------------------------------------------------------------------*/
92 /*---------------------------------------------------------------------------*/
93 cpl_frameset * sinfo_extract_frameset(
94  const cpl_frameset * in,
95  const char * tag)
96 {
97  cpl_frameset * out ;
98  const cpl_frame * cur_frame ;
99  cpl_frame * loc_frame ;
100  int nbframes, nbext ;
101  int i ;
102 
103  /* Test entries */
104  if (in == NULL) return NULL ;
105  if (tag == NULL) return NULL ;
106 
107  /* Initialise */
108  nbframes = cpl_frameset_get_size(in) ;
109 
110  /* Count the frames with the tag */
111  if ((nbext = cpl_frameset_count_tags(in, tag)) == 0) return NULL ;
112 
113  /* Create the output frameset */
114  out = cpl_frameset_new() ;
115 
116  /* Loop on the requested frames and store them in out */
117  nbext = 0 ;
118  for (i=0 ; i<nbframes ; i++) {
119  cur_frame = cpl_frameset_get_frame_const(in, i) ;
120  if (!strcmp(cpl_frame_get_tag(cur_frame), tag)) {
121  loc_frame = cpl_frame_duplicate(cur_frame) ;
122  cpl_frameset_insert(out, loc_frame) ;
123  nbext ++ ;
124  }
125  }
126  return out ;
127 }
128 /*----------------------------------------------------------------------------*/
135 /*----------------------------------------------------------------------------*/
136 const char * sinfo_extract_filename(
137  const cpl_frameset * in,
138  const char * tag)
139 {
140  const cpl_frame * cur_frame ;
141 
142  /* Get the frame */
143  if ((cur_frame = cpl_frameset_find_const(in, tag)) == NULL) return NULL ;
144  return cpl_frame_get_filename(cur_frame) ;
145 }
146 
147 /*-------------------------------------------------------------------------*/
153 /*--------------------------------------------------------------------------*/
154 const char * sinfo_std_band_name(sinfo_band band)
155 {
156  switch (band) {
157  case SINFO_BAND_J: return "J" ;
158  case SINFO_BAND_JS: return "Js" ;
159  case SINFO_BAND_JBLOCK: return "J+Block" ;
160  case SINFO_BAND_H: return "H" ;
161  case SINFO_BAND_K: return "K" ;
162  case SINFO_BAND_KS: return "Ks" ;
163  case SINFO_BAND_L: return "L" ;
164  case SINFO_BAND_M: return "M" ;
165  case SINFO_BAND_LP: return "Lp" ;
166  case SINFO_BAND_MP: return "Mp" ;
167  case SINFO_BAND_Z: return "Z" ;
168  case SINFO_BAND_SZ: return "SZ" ;
169  case SINFO_BAND_SH: return "SH" ;
170  case SINFO_BAND_SK: return "SK" ;
171  case SINFO_BAND_SL: return "SL" ;
172  default: return "Unknown" ;
173  }
174 }
175