IIINSTRUMENT Pipeline Reference Manual 0.1.14
iiinstrument_utils.c
1/*
2 * This file is part of the IIINSTRUMENT Pipeline
3 * Copyright (C) 2002-2017 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 St, Fifth Floor, Boston, MA 02110-1301 USA
18 */
19
20#ifdef HAVE_CONFIG_H
21#include <config.h>
22#endif
23
24/*----------------------------------------------------------------------------*/
28/*----------------------------------------------------------------------------*/
29
30#include <cpl.h>
31
32#include "iiinstrument_utils.h"
33#include "iiinstrument_dfs.h"
34
35/*----------------------------------------------------------------------------*/
39/*----------------------------------------------------------------------------*/
40
43/*----------------------------------------------------------------------------*/
53/*----------------------------------------------------------------------------*/
54const char * iiinstrument_get_license(void)
55{
56 const char *iiinstrument_license = cpl_get_license("IIINSTRUMENT", "2002,2018");
57
58 return iiinstrument_license ;
59}
60
61/*----------------------------------------------------------------------------*/
69/*----------------------------------------------------------------------------*/
71 cpl_frameset *frameset)
72{
73 /* Check size of frameset for to know if the sof file is not empty */
74 cpl_size nframes = cpl_frameset_get_size(frameset);
75 for (cpl_size i = 0; i < nframes; i++) {
76
77 cpl_frame *frame = cpl_frameset_get_position(frameset, i);
78 const char *filename = cpl_frame_get_filename(frame);
79
80 /* Check if the FITS file exist and have correct data,
81 * return 0 if the fits file is valid without extensions */
82 if (cpl_fits_count_extensions(filename) < 0){
83
84 return cpl_error_set_message(cpl_func, cpl_error_get_code(),
85 "Problem with the file '%s' (%s --> Code %d)",
86 filename, cpl_error_get_message(), cpl_error_get_code());
87 }
88 }
89
90 /* Identify the RAW, CONF and CALIB frames in the input frameset */
91 if (iiinstrument_dfs_set_groups(frameset)) {
92
93 /* Error classify frames */
94 return cpl_error_set_message(cpl_func, CPL_ERROR_DATA_NOT_FOUND,
95 "Cannot classify RAW and/or CALIB frames");
96 } else {
97
98 /* Check classification */
99 for (cpl_size i = 0; i < nframes; i++) {
100
101 cpl_frame *frame = cpl_frameset_get_position(frameset, i);
102 const char *tag = cpl_frame_get_tag(frame);
103 cpl_frame_group group = cpl_frame_get_group(frame);
104
105 /* The tag is invalid */
106 if (group == CPL_FRAME_GROUP_NONE) {
107 return cpl_error_set_message(cpl_func, CPL_ERROR_INCOMPATIBLE_INPUT,
108 "Frame:%lld with tag:%s is invalid", i, tag);
109 }
110 }
111 }
112
113 return CPL_ERROR_NONE;
114}
115
cpl_error_code iiinstrument_dfs_set_groups(cpl_frameset *set)
Set the group as RAW or CALIB in a frameset.
const char * iiinstrument_get_license(void)
Get the pipeline copyright and license.
cpl_error_code iiinstrument_check_and_set_groups(cpl_frameset *frameset)
check the entries in the recipe and classify the frameset with the tags