20#include "cpl_errorstate.h"
23#include "cpl_propertylist.h"
29#include "cpl_frameset.h"
69 cpl_ensure(set != NULL, CPL_ERROR_NULL_INPUT, NULL);
71 res = cpl_calloc(
sizeof(cpl_frameset *), 2);
72 res[0] = cpl_frameset_new();
73 res[1] = cpl_frameset_new();
77 for (i = 0; i < cpl_frameset_get_size(set); ++i) {
78 const cpl_frame *frame = cpl_frameset_get_position_const(set, i);
79 const char *filename = cpl_frame_get_filename(frame);
80 cpl_propertylist *list = cpl_propertylist_load(filename, 0);
84 if (fabs(offset - MOONS_SLIT_OFFSET_POS1) <=
85 MOONS_SLIT_OFFSET_EPSILON) {
86 cpl_frameset_insert(res[0], cpl_frame_duplicate(frame));
88 else if (fabs(offset - MOONS_SLIT_OFFSET_POS2) <=
89 MOONS_SLIT_OFFSET_EPSILON) {
90 cpl_frameset_insert(res[1], cpl_frame_duplicate(frame));
92 cpl_propertylist_delete(list);
99moo_dfs_group_offsets(
const cpl_frameset *set,
100 cpl_frameset *group1,
101 cpl_frameset *group2,
104 cpl_ensure(set != NULL, CPL_ERROR_NULL_INPUT, CPL_ERROR_NULL_INPUT);
105 cpl_ensure(group1 != NULL, CPL_ERROR_NULL_INPUT, CPL_ERROR_NULL_INPUT);
106 cpl_ensure(group2 != NULL, CPL_ERROR_NULL_INPUT, CPL_ERROR_NULL_INPUT);
108 cpl_errorstate status = cpl_errorstate_get();
109 cpl_frameset_iterator *it = cpl_frameset_iterator_new(set);
110 const cpl_frame *frame = NULL;
111 while ((frame = cpl_frameset_iterator_get_const(it)) != NULL) {
112 const char *filename = cpl_frame_get_filename(frame);
115 const cpl_propertylist *properties = cpl_propertylist_load(filename, 0);
120 cpl_errorstate _status = cpl_errorstate_get();
122 if (!cpl_errorstate_is_equal(_status) &&
123 (cpl_error_get_code() == CPL_ERROR_DATA_NOT_FOUND)) {
124 cpl_errorstate_set(_status);
127 if (fabs(offset - MOONS_SLIT_OFFSET_POS1) <=
128 MOONS_SLIT_OFFSET_EPSILON) {
129 cpl_frameset_insert(group1, cpl_frame_duplicate(frame));
131 else if (fabs(offset - MOONS_SLIT_OFFSET_POS2) <=
132 MOONS_SLIT_OFFSET_EPSILON) {
133 cpl_frameset_insert(group2, cpl_frame_duplicate(frame));
135 else if (other != NULL) {
136 cpl_frameset_insert(other, cpl_frame_duplicate(frame));
142 cpl_frameset_insert(group1, cpl_frame_duplicate(frame));
143 cpl_frameset_insert(group2, cpl_frame_duplicate(frame));
145 cpl_propertylist_delete((cpl_propertylist *)properties);
147 _status = cpl_errorstate_get();
148 cpl_frameset_iterator_advance(it, 1);
149 if (!cpl_errorstate_is_equal(_status) &&
150 (cpl_error_get_code() == CPL_ERROR_ACCESS_OUT_OF_RANGE)) {
151 cpl_errorstate_set(_status);
154 cpl_frameset_iterator_delete(it);
156 if (!cpl_errorstate_is_equal(status)) {
157 return cpl_error_get_code();
159 return CPL_ERROR_NONE;
163moo_dfs_extract_tag(
const cpl_frameset *set,
const char *tag)
165 cpl_ensure(set != NULL, CPL_ERROR_NULL_INPUT, NULL);
166 cpl_ensure(tag != NULL, CPL_ERROR_NULL_INPUT, NULL);
168 cpl_frameset *selected = cpl_frameset_new();
170 cpl_errorstate status = cpl_errorstate_get();
171 cpl_frameset_iterator *it = cpl_frameset_iterator_new(set);
172 const cpl_frame *frame = NULL;
173 while ((frame = cpl_frameset_iterator_get_const(it)) != NULL) {
174 if (strcmp(tag, cpl_frame_get_tag(frame)) == 0) {
175 cpl_frameset_insert(selected, cpl_frame_duplicate(frame));
177 cpl_errorstate _status = cpl_errorstate_get();
178 cpl_frameset_iterator_advance(it, 1);
179 if (!cpl_errorstate_is_equal(_status) &&
180 (cpl_error_get_code() == CPL_ERROR_ACCESS_OUT_OF_RANGE)) {
181 cpl_errorstate_set(_status);
184 cpl_frameset_iterator_delete(it);
186 if (!cpl_errorstate_is_equal(status)) {
187 cpl_frameset_delete(selected);
208 cpl_errorstate prestate = cpl_errorstate_get();
212 cpl_frameset_iterator *it = cpl_frameset_iterator_new(set);
215 cpl_frame *frame = NULL;
216 while ((frame = cpl_frameset_iterator_get(it)) != NULL) {
217 const char *tag = cpl_frame_get_tag(frame);
220 cpl_msg_warning(cpl_func,
"Frame %d has no tag", i);
222 else if (!strcmp(tag, MOONS_TAG_BIAS) ||
223 !strcmp(tag, MOONS_TAG_LINEARITY) ||
224 !strcmp(tag, MOONS_TAG_LINEARITY_OFF) ||
225 !strcmp(tag, MOONS_TAG_OBJECT) ||
226 !strcmp(tag, MOONS_TAG_DARK_VIS) ||
227 !strcmp(tag, MOONS_TAG_DARK_NIR) ||
228 !strcmp(tag, MOONS_TAG_FLAT) ||
229 !strcmp(tag, MOONS_TAG_FLAT_ATTACHED) ||
230 !strcmp(tag, MOONS_TAG_FLAT_OFF) ||
231 !strcmp(tag, MOONS_TAG_ARC) ||
232 !strcmp(tag, MOONS_TAG_ARC_OFF) ||
233 !strcmp(tag, MOONS_TAG_STD_FLUX) ||
234 !strcmp(tag, MOONS_TAG_STD_TELL) ||
235 !strcmp(tag, MOONS_TAG_OBJECT_STARE) ||
236 !strcmp(tag, MOONS_TAG_OBJECT_STARENOD) ||
237 !strcmp(tag, MOONS_TAG_SKY_STARENOD) ||
238 !strcmp(tag, MOONS_TAG_OBJECT_XSWITCH) ||
239 !strcmp(tag, MOONS_TAG_MOLECFIT_SCI)) {
241 cpl_frame_set_group(frame, CPL_FRAME_GROUP_RAW);
243 else if (!strcmp(tag, MOONS_TAG_LINE_CATALOG) ||
244 !strcmp(tag, MOONS_TAG_FLUX_STD_CATALOG) ||
245 !strcmp(tag, MOONS_TAG_ATMOS_EXT) ||
246 !strcmp(tag, MOONS_TAG_ARC_LINE_LIST) ||
247 !strcmp(tag, MOONS_TAG_SKY_LINE_LIST) ||
248 !strcmp(tag, MOONS_TAG_MASTER_BIAS) ||
249 !strcmp(tag, MOONS_TAG_MASTER_DARK_VIS) ||
250 !strcmp(tag, MOONS_TAG_MASTER_DARK_NIR) ||
251 !strcmp(tag, MOONS_TAG_BP_MAP_RP) ||
252 !strcmp(tag, MOONS_TAG_BP_MAP_NL) ||
253 !strcmp(tag, MOONS_TAG_FF_TRACE_GUESS) ||
254 !strcmp(tag, MOONS_TAG_FF_TRACE) ||
255 !strcmp(tag, MOONS_TAG_P2P_MAP) ||
256 !strcmp(tag, MOONS_TAG_SPECTRAL_FORMAT) ||
257 !strcmp(tag, MOONS_TAG_LAYOUT) ||
258 !strcmp(tag, MOONS_TAG_WAVEMAP_GUESS) ||
259 !strcmp(tag, MOONS_TAG_WAVEMAP) ||
260 !strcmp(tag, MOONS_TAG_F2F_TABLE) ||
261 !strcmp(tag, MOONS_TAG_FF_EXTSPECTRA) ||
262 !strcmp(tag, MOONS_TAG_LINEARITY_COEFF_CUBE) ||
263 !strcmp(tag, MOONS_TAG_TELLURIC_CORR) ||
264 !strcmp(tag, MOONS_TAG_RESPONSE) ||
265 !strcmp(tag, MOONS_TAG_MOLECFIT_MOLECULES) ||
266 !strcmp(tag, MOONS_TAG_MOLECFIT_ATM_PARAMS) ||
267 !strcmp(tag, MOONS_TAG_MOLECFIT_BEST_FIT_PARAMS) ||
268 !strcmp(tag, MOONS_TAG_MOLECFIT_KERNEL_LIBRARY) ||
269 !strcmp(tag, MOONS_TAG_MOLECFIT_WINCLUDE)) {
271 cpl_frame_set_group(frame, CPL_FRAME_GROUP_CALIB);
274 cpl_frameset_iterator_advance(it, 1);
277 cpl_frameset_iterator_delete(it);
279 if (!cpl_errorstate_is_equal(prestate)) {
280 return cpl_error_set_message(cpl_func, cpl_error_get_code(),
281 "Could not identify RAW and CALIB "
285 return CPL_ERROR_NONE;
303 cpl_ensure(set != NULL, CPL_ERROR_NULL_INPUT, NULL);
304 int size = cpl_frameset_get_size(set);
305 res = cpl_malloc(
sizeof(
double) * size);
309 for (i = 0; i < size; i++) {
310 const cpl_frame *frame = cpl_frameset_get_position_const(set, i);
311 const char *filename = cpl_frame_get_filename(frame);
312 cpl_propertylist *list = cpl_propertylist_load(filename, 0);
314 cpl_propertylist_delete(list);
double * moo_dfs_get_exptime(cpl_frameset *set)
Get the EXPTIME from the frameset.
cpl_error_code moo_dfs_set_groups(cpl_frameset *set)
Set the group as RAW or CALIB in a frameset.
cpl_frameset ** moo_dfs_split_by_offset(cpl_frameset *set)
Get the EXPTIME from the frameset.
int moo_pfits_get_slit_offset(const cpl_propertylist *plist)
find out the INS SLIT OFFSET value
double moo_pfits_get_exptime(const cpl_propertylist *plist)
find out the EXPTIME value