File: uves_chip.c

package info (click to toggle)
cpl-plugin-uves 6.1.3+dfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, sid
  • size: 23,128 kB
  • sloc: ansic: 171,056; sh: 4,359; python: 3,002; makefile: 1,322
file content (195 lines) | stat: -rw-r--r-- 6,708 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
/*                                                                              *
 *   This file is part of the ESO UVES Pipeline                                 *
 *   Copyright (C) 2004,2005 European Southern Observatory                      *
 *                                                                              *
 *   This library is free software; you can redistribute it and/or modify       *
 *   it under the terms of the GNU General Public License as published by       *
 *   the Free Software Foundation; either version 2 of the License, or          *
 *   (at your option) any later version.                                        *
 *                                                                              *
 *   This program is distributed in the hope that it will be useful,            *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of             *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the              *
 *   GNU General Public License for more details.                               *
 *                                                                              *
 *   You should have received a copy of the GNU General Public License          *
 *   along with this program; if not, write to the Free Software                *
 *   Foundation, 51 Franklin St, Fifth Floor, Boston, MA  02111-1307  USA       *
 *                                                                              */

/*
 * $Author: amodigli $
 * $Date: 2010-09-24 09:32:02 $
 * $Revision: 1.8 $
 * $Name: not supported by cvs2svn $
 * $Log: not supported by cvs2svn $
 * Revision 1.6  2007/06/06 08:17:33  amodigli
 * replace tab with 4 spaces
 *
 * Revision 1.5  2007/01/10 12:35:33  jmlarsen
 * Added uves_chip_tochar
 *
 * Revision 1.4  2006/08/17 13:56:52  jmlarsen
 * Reduced max line length
 *
 * Revision 1.3  2005/12/19 16:17:56  jmlarsen
 * Replaced bool -> int
 *
 */

#ifdef HAVE_CONFIG_H
#  include <config.h>
#endif

/*----------------------------------------------------------------------------*/
/**
 * @defgroup uves_chip    CCD Chip
 *
 * The CCD chip abstract data type
 */
/*----------------------------------------------------------------------------*/
/**@{*/


/*-----------------------------------------------------------------------------
                                Includes
 -----------------------------------------------------------------------------*/

#include <uves_chip.h>
#include <cpl.h>

/*-----------------------------------------------------------------------------
                            Functions prototypes
 -----------------------------------------------------------------------------*/

/*-----------------------------------------------------------------------------
                            Implementation
 -----------------------------------------------------------------------------*/



/*----------------------------------------------------------------------------*/
/**
   @brief    Get first chip for blue or red arm
   @param    blue          Blue (if true) or red (if false) arm
   @return   The first (using some arbitrary but self-consistent definition of
             chip ordering)
             chip of the specified arm.

   This function is used to loop through all (in the case of UVES, 1 or 2) chips
   of an arm.

   @code
     for (chip = uves_chip_get_first(blue); 
          chip != UVES_CHIP_INVALID; 
      chip = uves_chip_get_next(chip))
     {...}
   @endcode

*/
/*----------------------------------------------------------------------------*/
enum uves_chip
uves_chip_get_first(bool blue)
{
    return (blue) ? UVES_CHIP_BLUE : UVES_CHIP_REDL;
}

/*----------------------------------------------------------------------------*/
/**
   @brief    Get next chip
   @param    chip          The current chip
   @return   The chip following the specified @em chip

   See @c uves_chip_get_first()
*/
/*----------------------------------------------------------------------------*/

enum uves_chip
uves_chip_get_next(enum uves_chip chip)
{
    return
    (chip == UVES_CHIP_REDL) ? UVES_CHIP_REDU :
    (chip == UVES_CHIP_BLUE) ? UVES_CHIP_INVALID :
    (chip == UVES_CHIP_REDU) ? UVES_CHIP_INVALID :
    UVES_CHIP_INVALID;
}

/*----------------------------------------------------------------------------*/
/**
   @brief    Convert to integer
   @param    chip          The CCD chip
   @return   The specified @em chip converted to integer (1 if REDU, otherwise 0)
*/
/*----------------------------------------------------------------------------*/
int uves_chip_get_index(enum uves_chip chip)
{
    /* 0 = REDL/BLUE, 1 = REDU */
    return (chip == UVES_CHIP_REDU) ? 1 : 0;
}

/*----------------------------------------------------------------------------*/
/**
   @brief    Convert to string
   @param    chip          The CCD chip
   @return   A lower case textual representation of the specified @em chip
*/
/*----------------------------------------------------------------------------*/

const char *
uves_chip_tostring_lower(enum uves_chip chip)
{
    return
    (chip == UVES_CHIP_BLUE) ? "blue" : 
    (chip == UVES_CHIP_REDU) ? "redu" : 
    (chip == UVES_CHIP_REDL) ? "redl" : "?chip?";
}

/*----------------------------------------------------------------------------*/
/**
   @brief    Convert to string
   @param    chip          The CCD chip
   @return   An upper case textual representation of the specified @em chip
*/
/*----------------------------------------------------------------------------*/

const char *
uves_chip_tostring_upper(enum uves_chip chip)
{
    return
    (chip == UVES_CHIP_BLUE) ? "BLUE" : 
    (chip == UVES_CHIP_REDU) ? "REDU" : 
    (chip == UVES_CHIP_REDL) ? "REDL" : "?CHIP?";
}


/*----------------------------------------------------------------------------*/
/**
   @brief    Get letters used in filenames
   @param    chip          The CCD chip
   @return   letters
*/
/*----------------------------------------------------------------------------*/
const char *uves_chip_get_det(enum uves_chip chip)
{
    return
    (chip == UVES_CHIP_BLUE) ? "be" : 
    (chip == UVES_CHIP_REDU) ? "rm" : 
    (chip == UVES_CHIP_REDL) ? "re" : "??";
}

/*----------------------------------------------------------------------------*/
/**
   @brief    Get letters used in filenames
   @param    chip          The CCD chip
   @return   character representation of chip
*/
/*----------------------------------------------------------------------------*/
char uves_chip_tochar(enum uves_chip chip)
{
    return
    (chip == UVES_CHIP_BLUE) ? 'b' : 
    (chip == UVES_CHIP_REDU) ? 'u' : 
    (chip == UVES_CHIP_REDL) ? 'l' : '?';
}

/**@}*/