MOONS Pipeline Reference Manual 0.13.2
moo_detector.c
1/*
2 * This file is part of the MOONS Pipeline
3 * Copyright (C) 2002-2016 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, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 */
19
20#ifdef HAVE_CONFIG_H
21#include <config.h>
22#endif
23
24/*-----------------------------------------------------------------------------
25 Includes
26 -----------------------------------------------------------------------------*/
27#include <cpl.h>
28#include "moo_detector.h"
29#include "moo_pfits.h"
30#include "moo_utils.h"
31/*----------------------------------------------------------------------------*/
44/*----------------------------------------------------------------------------*/
45
48/*-----------------------------------------------------------------------------
49 Function codes
50 -----------------------------------------------------------------------------*/
51
52/*----------------------------------------------------------------------------*/
64/*----------------------------------------------------------------------------*/
65const char *
67{
68 cpl_ensure(ntas <= 2, CPL_ERROR_ILLEGAL_INPUT, NULL);
69 if (ntas >= 1) {
70 const char *res[] = { MOO_EXTNAME(MOO_ERR, MOO_DETECTOR_RI1_NAME),
71 MOO_EXTNAME(MOO_ERR, MOO_DETECTOR_RI2_NAME),
72 MOO_EXTNAME(MOO_ERR, MOO_DETECTOR_YJ1_NAME),
73 MOO_EXTNAME(MOO_ERR, MOO_DETECTOR_YJ2_NAME),
74 MOO_EXTNAME(MOO_ERR, MOO_DETECTOR_H1_NAME),
75 MOO_EXTNAME(MOO_ERR, MOO_DETECTOR_H2_NAME) };
76 int idx = type * 2 + ntas - 1;
77 return res[idx];
78 }
79 else {
80 const char *res[] = { MOO_EXTNAME(MOO_ERR, MOO_CHANNEL_RI_NAME),
81 MOO_EXTNAME(MOO_ERR, MOO_CHANNEL_YJ_NAME),
82 MOO_EXTNAME(MOO_ERR, MOO_CHANNEL_H_NAME) };
83 return res[type];
84 }
85}
86
87/*----------------------------------------------------------------------------*/
99/*----------------------------------------------------------------------------*/
100const char *
102{
103 cpl_ensure(ntas <= 2, CPL_ERROR_ILLEGAL_INPUT, NULL);
104
105 if (ntas >= 1) {
106 const char *res[] = { MOO_EXTNAME(MOO_QUAL, MOO_DETECTOR_RI1_NAME),
107 MOO_EXTNAME(MOO_QUAL, MOO_DETECTOR_RI2_NAME),
108 MOO_EXTNAME(MOO_QUAL, MOO_DETECTOR_YJ1_NAME),
109 MOO_EXTNAME(MOO_QUAL, MOO_DETECTOR_YJ2_NAME),
110 MOO_EXTNAME(MOO_QUAL, MOO_DETECTOR_H1_NAME),
111 MOO_EXTNAME(MOO_QUAL, MOO_DETECTOR_H2_NAME) };
112 int idx = type * 2 + ntas - 1;
113 return res[idx];
114 }
115 else {
116 const char *res[] = { MOO_EXTNAME(MOO_QUAL, MOO_CHANNEL_RI_NAME),
117 MOO_EXTNAME(MOO_QUAL, MOO_CHANNEL_YJ_NAME),
118 MOO_EXTNAME(MOO_QUAL, MOO_CHANNEL_H_NAME) };
119 return res[type];
120 }
121}
122
123/*----------------------------------------------------------------------------*/
135/*----------------------------------------------------------------------------*/
136const char *
138{
139 cpl_ensure(ntas <= 2, CPL_ERROR_ILLEGAL_INPUT, NULL);
140 if (ntas >= 1) {
141 const char *res[] = { MOO_DETECTOR_RI1_NAME, MOO_DETECTOR_RI2_NAME,
142 MOO_DETECTOR_YJ1_NAME, MOO_DETECTOR_YJ2_NAME,
143 MOO_DETECTOR_H1_NAME, MOO_DETECTOR_H2_NAME };
144 int idx = type * 2 + ntas - 1;
145 return res[idx];
146 }
147 else {
148 return moo_detector_get_name(type);
149 }
150}
151
152/*----------------------------------------------------------------------------*/
163/*----------------------------------------------------------------------------*/
164int
166{
167 return ntas;
168}
169
170/*----------------------------------------------------------------------------*/
181/*----------------------------------------------------------------------------*/
182const char *
184{
185 const char *res[] = { MOO_CHANNEL_RI_NAME, MOO_CHANNEL_YJ_NAME,
186 MOO_CHANNEL_H_NAME };
187 int idx = type;
188 return res[idx];
189}
190
191/*----------------------------------------------------------------------------*/
202/*----------------------------------------------------------------------------*/
203const char *
204moo_mode_get_name(moo_mode_type type)
205{
206 const char *res[] = { MOO_MODE_LR_NAME, MOO_MODE_HR_NAME };
207 int idx = type;
208 return res[idx];
209}
210
211/*----------------------------------------------------------------------------*/
222/*----------------------------------------------------------------------------*/
223moo_mode_type
224moo_mode_get(const cpl_frame *frame)
225{
226 moo_mode_type res = MOO_MODE_LR;
227 cpl_propertylist *plist = NULL;
228
229 cpl_ensure(frame != NULL, CPL_ERROR_NULL_INPUT, res);
230
231 const char *filename = cpl_frame_get_filename(frame);
232
233 moo_try_check(plist = cpl_propertylist_load(filename, 0), " ");
234 moo_try_check(res = moo_pfits_get_mode(plist), " ");
235
236moo_try_cleanup:
237 cpl_propertylist_delete(plist);
238 return res;
239}
240
241/*----------------------------------------------------------------------------*/
252/*----------------------------------------------------------------------------*/
253int
254moo_offset_get(const cpl_frame *refframe)
255{
256 int offset = -1;
257 cpl_propertylist *plist = NULL;
258
259 cpl_ensure(refframe != NULL, CPL_ERROR_NULL_INPUT, offset);
260
261 const char *filename = cpl_frame_get_filename(refframe);
262
263 moo_try_check(plist = cpl_propertylist_load(filename, 0), " ");
264 moo_try_check(offset = moo_pfits_get_slit_offset(plist), " ");
265
266moo_try_cleanup:
267 cpl_propertylist_delete(plist);
268 return offset;
269}
const char * moo_detector_get_name(moo_detector_type type)
Get the extension name of a detector.
Definition: moo_detector.c:183
int moo_detector_get_spectro(int ntas)
Get the spctro name for a ntas.
Definition: moo_detector.c:165
moo_mode_type moo_mode_get(const cpl_frame *frame)
Get the name of a mode from a frame.
Definition: moo_detector.c:224
int moo_offset_get(const cpl_frame *refframe)
Get the offset from a frame.
Definition: moo_detector.c:254
const char * moo_detector_get_err_extname(moo_detector_type type, int ntas)
Get the ERROR extension name of a detector.
Definition: moo_detector.c:66
const char * moo_detector_get_extname(moo_detector_type type, int ntas)
Get the extension name of a detector.
Definition: moo_detector.c:137
enum _moo_detector_type_ moo_detector_type
The type code type.
Definition: moo_detector.h:64
const char * moo_detector_get_qual_extname(moo_detector_type type, int ntas)
Get the QUAL extension name of a detector.
Definition: moo_detector.c:101
const char * moo_mode_get_name(moo_mode_type type)
Get the name of a mode.
Definition: moo_detector.c:204
moo_mode_type moo_pfits_get_mode(const cpl_propertylist *plist)
find out the INS SLIT MODE value
Definition: moo_pfits.c:1131
int moo_pfits_get_slit_offset(const cpl_propertylist *plist)
find out the INS SLIT OFFSET value
Definition: moo_pfits.c:1110