MOONS Pipeline Reference Manual 0.13.2
moons_quicklook.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
28#include "moo_dfs.h"
29#include "moo_drl.h"
30#include "moo_extlist.h"
31#include "moo_params.h"
32#include "moo_pfits.h"
33#include "moo_products.h"
34#include "moo_utils.h"
35#include <cpl.h>
36
37#include <string.h>
38
39/*-----------------------------------------------------------------------------
40 Plugin registration
41 -----------------------------------------------------------------------------*/
42
43int cpl_plugin_get_info(cpl_pluginlist *list);
44
45/*-----------------------------------------------------------------------------
46 Private function prototypes
47 -----------------------------------------------------------------------------*/
48
49static int _moons_quicklook_create(cpl_plugin *plugin);
50static int _moons_quicklook_exec(cpl_plugin *plugin);
51static int _moons_quicklook_destroy(cpl_plugin *plugin);
52static int
53_moons_quicklook(cpl_frameset *frameset, const cpl_parameterlist *parlist);
54
55/*-----------------------------------------------------------------------------
56 Static variables
57 -----------------------------------------------------------------------------*/
58
59static const char *const _moons_quicklook_description =
60 "quickly produce reduced spectra for a subset of the observed objects and "
61 "assess the quality of the data\n"
62 "INPUT FRAMES\n"
63 " * science exposure frame 1 file (RAW) with tag OBJECT_STARE "
64 ": "
65 "science frame in stare mode file\n"
66 " * [OPTIONAL] ReferenceBadPixMask 1 file (QUA) with tag BP_MAP_RP : "
67 "cosmetic bad pixel map\n"
68 " * [OPTIONAL] NonLinearityBadPixMask 1 file (QUA) with tag BP_MAP_NL : "
69 "cosmetic bad pixel map coming from linearity recipe\n"
70 " * MasterBias 1 file (DET) with tag MASTER_BIAS : "
71 "master bias file\n"
72 " * MasterDarkNir 1 file (DET) with tag "
73 "MASTER_DARK_NIR : "
74 "master dark nir file\n"
75 " * [OPTIONAL]MasterDarkVis 1 file (DET) with tag "
76 "MASTER_DARK_VIS : "
77 "master dark vis file\n"
78 " * [OPTIONAL] CoeffsCube 1 file (3D) with tag "
79 "LINEARITY_COEFF_CUBE : "
80 "coefficients to correct pixels detector linearity\n"
81 " * [OPTIONAL] P2pMap 1 file (DET) with tag P2P_MAP : "
82 "pixel to pixel map\n"
83 " * LocTab 1 file (LOC) with tag FF_TRACE : "
84 "the localisation table\n"
85 " * Ffext 1 file (EXT) with tag FF_EXTSPECTRA "
86 ": "
87 "the extracted flat field\n"
88 " * F2f 1 file (F2F) with tag F2F_TABLE : "
89 "the fibre-to-fibre relative response\n"
90 " * SFormat 1 file (FMT) with tag "
91 "SPECTRAL_FORMAT : "
92 "the spectral format table\n"
93 " * WaveMap 1 file (WMAP) with tag WAVE_MAP : "
94 "the wavelength map\n"
95 " * SkyLines 1 file (CAT) with tag SKY_LINE_LIST "
96 ": "
97 "the sky lines list table\n"
98 "PRODUCTS\n"
99 " * QUICKLOOK_SCI.fits (SCI) with tag SCIENCE_QUICKLOOK_SKSSPECTRA : "
100 "Science product coadd calibrated frame\n"
101 "\n";
102
103/*-----------------------------------------------------------------------------
104 Function code
105 -----------------------------------------------------------------------------*/
106
107/*----------------------------------------------------------------------------*/
117/*----------------------------------------------------------------------------*/
118
119int
120cpl_plugin_get_info(cpl_pluginlist *list)
121{
122 cpl_recipe *recipe = cpl_calloc(1, sizeof *recipe);
123 cpl_plugin *plugin = &recipe->interface;
124
125 if (cpl_plugin_init(plugin, CPL_PLUGIN_API, MOONS_BINARY_VERSION,
126 CPL_PLUGIN_TYPE_RECIPE, "moons_quicklook",
127 "quickly produce reduced spectra for a subset of the "
128 "observed objects and assess the quality of the data",
129 _moons_quicklook_description, "Regis Haigron",
130 PACKAGE_BUGREPORT, moo_get_license(),
131 _moons_quicklook_create, _moons_quicklook_exec,
132 _moons_quicklook_destroy)) {
133 cpl_msg_error(cpl_func, "Plugin initialization failed");
134 (void)cpl_error_set_where(cpl_func);
135 return 1;
136 }
137
138 if (cpl_pluginlist_append(list, plugin)) {
139 cpl_msg_error(cpl_func, "Error adding plugin to list");
140 (void)cpl_error_set_where(cpl_func);
141 return 1;
142 }
143
144 return 0;
145}
146
147/*----------------------------------------------------------------------------*/
155/*----------------------------------------------------------------------------*/
156
157static int
158_moons_quicklook_create(cpl_plugin *plugin)
159{
160 cpl_recipe *recipe;
161
162 /* Do not create the recipe if an error code is already set */
163 if (cpl_error_get_code() != CPL_ERROR_NONE) {
164 cpl_msg_error(cpl_func, "%s():%d: An error is already set: %s",
165 cpl_func, __LINE__, cpl_error_get_where());
166 return (int)cpl_error_get_code();
167 }
168
169 if (plugin == NULL) {
170 cpl_msg_error(cpl_func, "Null plugin");
171 cpl_ensure_code(0, (int)CPL_ERROR_NULL_INPUT);
172 }
173
174 /* Verify plugin type */
175 if (cpl_plugin_get_type(plugin) != CPL_PLUGIN_TYPE_RECIPE) {
176 cpl_msg_error(cpl_func, "Plugin is not a recipe");
177 cpl_ensure_code(0, (int)CPL_ERROR_TYPE_MISMATCH);
178 }
179
180 /* Get the recipe */
181 recipe = (cpl_recipe *)plugin;
182
183 /* Create the parameters list in the cpl_recipe object */
184 recipe->parameters = cpl_parameterlist_new();
185 if (recipe->parameters == NULL) {
186 cpl_msg_error(cpl_func, "Parameter list allocation failed");
187 cpl_ensure_code(0, (int)CPL_ERROR_ILLEGAL_OUTPUT);
188 }
189
190 moo_params *params = moo_params_new("moons", "moons_quicklook");
191
192 /* Fill the parameters list */
193 moo_params_add_keep_temp(params, recipe->parameters);
194 moo_params_add_prepare(params, recipe->parameters);
195 moo_params_add_quicklook_fibre_list(params, recipe->parameters);
196 moo_params_add_correct_bias(params, recipe->parameters,
197 MOO_CORRECT_BIAS_METHOD_MASTER);
198 moo_params_add_rebin(params, recipe->parameters);
199 moo_params_add_sub_sky_stare_simple(params, recipe->parameters);
200 moo_params_delete(params);
201
202 return 0;
203}
204
205/*----------------------------------------------------------------------------*/
211/*----------------------------------------------------------------------------*/
212
213static int
214_moons_quicklook_exec(cpl_plugin *plugin)
215{
216 cpl_recipe *recipe;
217 int recipe_status;
218 cpl_errorstate initial_errorstate = cpl_errorstate_get();
219
220 /* Return immediately if an error code is already set */
221 if (cpl_error_get_code() != CPL_ERROR_NONE) {
222 cpl_msg_error(cpl_func, "%s():%d: An error is already set: %s",
223 cpl_func, __LINE__, cpl_error_get_where());
224 return (int)cpl_error_get_code();
225 }
226
227 if (plugin == NULL) {
228 cpl_msg_error(cpl_func, "Null plugin");
229 cpl_ensure_code(0, (int)CPL_ERROR_NULL_INPUT);
230 }
231
232 /* Verify plugin type */
233 if (cpl_plugin_get_type(plugin) != CPL_PLUGIN_TYPE_RECIPE) {
234 cpl_msg_error(cpl_func, "Plugin is not a recipe");
235 cpl_ensure_code(0, (int)CPL_ERROR_TYPE_MISMATCH);
236 }
237
238 /* Get the recipe */
239 recipe = (cpl_recipe *)plugin;
240
241 /* Verify parameter and frame lists */
242 if (recipe->parameters == NULL) {
243 cpl_msg_error(cpl_func, "Recipe invoked with NULL parameter list");
244 cpl_ensure_code(0, (int)CPL_ERROR_NULL_INPUT);
245 }
246 if (recipe->frames == NULL) {
247 cpl_msg_error(cpl_func, "Recipe invoked with NULL frame set");
248 cpl_ensure_code(0, (int)CPL_ERROR_NULL_INPUT);
249 }
250
251 /* Invoke the recipe */
252 recipe_status = _moons_quicklook(recipe->frames, recipe->parameters);
253
254 /* Ensure DFS-compliance of the products */
255 if (cpl_dfs_update_product_header(recipe->frames)) {
256 if (!recipe_status)
257 recipe_status = (int)cpl_error_get_code();
258 }
259
260 if (!cpl_errorstate_is_equal(initial_errorstate)) {
261 /* Dump the error history since recipe execution start.
262 At this point the recipe cannot recover from the error */
263 cpl_errorstate_dump(initial_errorstate, CPL_FALSE, NULL);
264 }
265
266 return recipe_status;
267}
268
269/*----------------------------------------------------------------------------*/
275/*----------------------------------------------------------------------------*/
276
277static int
278_moons_quicklook_destroy(cpl_plugin *plugin)
279{
280 cpl_recipe *recipe;
281
282 if (plugin == NULL) {
283 cpl_msg_error(cpl_func, "Null plugin");
284 cpl_ensure_code(0, (int)CPL_ERROR_NULL_INPUT);
285 }
286
287 /* Verify plugin type */
288 if (cpl_plugin_get_type(plugin) != CPL_PLUGIN_TYPE_RECIPE) {
289 cpl_msg_error(cpl_func, "Plugin is not a recipe");
290 cpl_ensure_code(0, (int)CPL_ERROR_TYPE_MISMATCH);
291 }
292
293 /* Get the recipe */
294 recipe = (cpl_recipe *)plugin;
295
296 cpl_parameterlist_delete(recipe->parameters);
297
298 return 0;
299}
300
301static int
302_moons_select_quicklook_targets(moo_det *det,
303 moo_loc *loc,
304 const cpl_frame *f2f_frame,
305 moo_sub_sky_stare_params *params,
306 cpl_array *index_list)
307{
308 moo_f2f *f2f = NULL;
309 cpl_array *sel = NULL;
310 cpl_array *sky_sel = NULL;
311 cpl_array *obj_sel = NULL;
312 cpl_table **sky_stare_tables = NULL;
313 int nb_targets = 0;
314
315 cpl_ensure(det != NULL, CPL_ERROR_NULL_INPUT, 0);
316 cpl_ensure(loc != NULL, CPL_ERROR_NULL_INPUT, 0);
317 cpl_ensure(f2f_frame != NULL, CPL_ERROR_NULL_INPUT, 0);
318 cpl_ensure(params != NULL, CPL_ERROR_NULL_INPUT, 0);
319
320 moo_try_check(f2f = moo_f2f_load(f2f_frame), " ");
321 cpl_table *det_fibre_table = moo_det_get_fibre_table(det);
322 cpl_table *loc_fibre_table = moo_loc_get_fibre_table(loc);
323
324 moo_try_assure(det_fibre_table != NULL, CPL_ERROR_ILLEGAL_INPUT, " ");
325 moo_try_assure(loc_fibre_table != NULL, CPL_ERROR_ILLEGAL_INPUT, " ");
326
327
328 /* sort all table by index */
329 moo_fibres_table_by_index(det_fibre_table);
330 moo_fibres_table_by_index(loc_fibre_table);
332 cpl_table_new_column(det_fibre_table, MOO_TARGET_TABLE_INDEXRBN,
333 CPL_TYPE_INT);
334 int tsize = cpl_table_get_nrow(det_fibre_table);
335 int *indexextt =
336 cpl_table_get_data_int(loc_fibre_table, MOO_FIBRES_TABLE_INDEXEXT);
337 for (int i = 1; i <= tsize; i++) {
338 int indexext = indexextt[i];
339 if (indexext > 0) {
340 cpl_table_set_int(det_fibre_table, MOO_TARGET_TABLE_INDEXRBN, i - 1,
341 i);
342 }
343 }
344 int index_size = cpl_array_get_size(index_list);
345 /* remove all CHECK_OBJECT */
346 if (index_size > 0) {
347 cpl_table_unselect_all(det_fibre_table);
348 int size =
349 cpl_table_or_selected_string(det_fibre_table, MOO_FIBRES_TABLE_TYPE,
350 CPL_EQUAL_TO,
351 MOO_FIBRES_TABLE_TYPE_CHECKOBJ);
352 sel = cpl_table_where_selected(det_fibre_table);
353 for (int i = 0; i < size; i++) {
354 int fidx = cpl_array_get_cplsize(sel, i, NULL);
355 cpl_table_set_string(det_fibre_table, MOO_FIBRES_TABLE_TYPE, fidx,
356 "");
357 }
358 cpl_array_delete(sel);
359 sel = NULL;
360
361 for (int i = 0; i < index_size; i++) {
362 const char *fibname = cpl_array_get_string(index_list, i);
363 cpl_table_unselect_all(det_fibre_table);
364 size = cpl_table_or_selected_string(det_fibre_table,
365 MOO_FIBRES_TABLE_FIBRE,
366 CPL_EQUAL_TO, fibname);
367 sel = cpl_table_where_selected(det_fibre_table);
368 int fidx = cpl_array_get_cplsize(sel, 0, NULL);
369 cpl_table_set_string(det_fibre_table, MOO_FIBRES_TABLE_TYPE, fidx,
370 MOO_FIBRES_TABLE_TYPE_CHECKOBJ);
371 cpl_array_delete(sel);
372 sel = NULL;
373 }
374 }
375 /* propagate broken fibre from loc */
376 cpl_table_unselect_all(loc_fibre_table);
377 int size =
378 cpl_table_or_selected_int(loc_fibre_table, MOO_FIBRES_TABLE_HEALTH,
379 CPL_EQUAL_TO, 0);
380 sel = cpl_table_where_selected(loc_fibre_table);
381
382 for (int i = 0; i < size; i++) {
383 int fidx = cpl_array_get_cplsize(sel, i, NULL);
384 cpl_table_set_int(det_fibre_table, MOO_FIBRES_TABLE_HEALTH, fidx, 0);
385 }
386 cpl_array_delete(sel);
387 sel = NULL;
388
389 cpl_table_select_all(det_fibre_table);
390 cpl_table_and_selected_int(det_fibre_table, MOO_FIBRES_TABLE_INDEXRBN,
391 CPL_NOT_EQUAL_TO, 0);
392 cpl_table_and_selected_int(det_fibre_table, MOO_FIBRES_TABLE_HEALTH,
393 CPL_NOT_EQUAL_TO, 0);
394 nb_targets =
395 cpl_table_and_selected_string(det_fibre_table, MOO_FIBRES_TABLE_TYPE,
396 CPL_EQUAL_TO,
397 MOO_FIBRES_TABLE_TYPE_CHECKOBJ);
398
399 if (nb_targets > 0) {
400 size = cpl_table_or_selected_string(det_fibre_table,
401 MOO_FIBRES_TABLE_TYPE, CPL_EQUAL_TO,
402 MOO_FIBRES_TABLE_TYPE_SKY);
403 cpl_table_and_selected_int(det_fibre_table, MOO_FIBRES_TABLE_INDEXRBN,
404 CPL_NOT_EQUAL_TO, 0);
405
406 size = cpl_table_not_selected(det_fibre_table);
407 sel = cpl_table_where_selected(det_fibre_table);
408
409 for (int i = 0; i < size; i++) {
410 int fidx = cpl_array_get_cplsize(sel, i, NULL);
411 int h = cpl_table_get_int(det_fibre_table, MOO_FIBRES_TABLE_HEALTH,
412 fidx, NULL);
413 if (h != 0) {
414 cpl_table_set_int(det_fibre_table, MOO_FIBRES_TABLE_HEALTH,
415 fidx, -1);
416 }
417 }
418 cpl_table_select_all(det_fibre_table);
419 int sky_size =
420 cpl_table_and_selected_string(det_fibre_table,
421 MOO_FIBRES_TABLE_TYPE, CPL_EQUAL_TO,
422 MOO_FIBRES_TABLE_TYPE_SKY);
423 sky_size =
424 cpl_table_and_selected_int(det_fibre_table, MOO_FIBRES_TABLE_HEALTH,
425 CPL_EQUAL_TO, 1);
426 sky_size = cpl_table_and_selected_int(det_fibre_table,
427 MOO_FIBRES_TABLE_INDEXRBN,
428 CPL_NOT_EQUAL_TO, 0);
429
430 sky_sel = cpl_table_where_selected(det_fibre_table);
431
432 cpl_table_select_all(det_fibre_table);
433 cpl_table_and_selected_string(det_fibre_table, MOO_FIBRES_TABLE_TYPE,
434 CPL_EQUAL_TO,
435 MOO_FIBRES_TABLE_TYPE_CHECKOBJ);
436 size =
437 cpl_table_and_selected_int(det_fibre_table, MOO_FIBRES_TABLE_HEALTH,
438 CPL_NOT_EQUAL_TO, 0);
439 size = cpl_table_and_selected_int(det_fibre_table,
440 MOO_FIBRES_TABLE_INDEXRBN,
441 CPL_NOT_EQUAL_TO, 0);
442
443 obj_sel = cpl_table_where_selected(det_fibre_table);
444
445 int obj_idx = 1;
446
447 sky_stare_tables = cpl_calloc(3, sizeof(cpl_table *));
448 for (int t = 0; t < 3; t++) {
449 cpl_table *sky_stare_table = cpl_table_new(0);
450 cpl_table_new_column(sky_stare_table, MOO_SKY_STARE_INDEXTARG,
451 CPL_TYPE_INT);
452 cpl_table_new_column(sky_stare_table, MOO_SKY_STARE_TARGNAME,
453 CPL_TYPE_STRING);
454 cpl_table_new_column(sky_stare_table, MOO_SKY_STARE_INDEXRBN,
455 CPL_TYPE_INT);
456 cpl_table_new_column(sky_stare_table, MOO_SKY_STARE_SKYINDEXRBN,
457 CPL_TYPE_INT);
458 cpl_table_new_column(sky_stare_table, MOO_SKY_STARE_SKYDSLIT,
459 CPL_TYPE_INT);
460 cpl_table_new_column(sky_stare_table, MOO_SKY_STARE_SKYTRANS,
461 CPL_TYPE_DOUBLE);
462 cpl_table_new_column(sky_stare_table, MOO_SKY_STARE_RADIUS,
463 CPL_TYPE_DOUBLE);
464 cpl_table_new_column(sky_stare_table, MOO_SKY_STARE_SKYDIST,
465 CPL_TYPE_DOUBLE);
466 for (int i = 0; i < size; i++) {
467 moo_detector_type type = t;
468 int fidx = cpl_array_get_cplsize(obj_sel, i, NULL);
469 const char *tname =
470 cpl_table_get_string(det_fibre_table,
471 MOO_FIBRES_TABLE_TARGNAME, fidx);
472 int indexrbn =
473 cpl_table_get_int(det_fibre_table,
474 MOO_TARGET_TABLE_INDEXRBN, fidx, NULL);
475 double obj_targalpha =
476 cpl_table_get_double(det_fibre_table,
477 MOO_FIBRES_TABLE_TARGALPHA, fidx,
478 NULL);
479 double obj_targdelta =
480 cpl_table_get_double(det_fibre_table,
481 MOO_FIBRES_TABLE_TARGDELTA, fidx,
482 NULL);
483
484 cpl_array *sky_indexes =
485 moo_select_sky(tname, obj_idx, indexrbn, obj_targalpha,
486 obj_targdelta, det_fibre_table,
487 MOO_TARGET_TABLE_INDEXRBN, sky_stare_table,
488 type, params->maxdistslit, params->min_trans,
489 params->min_sky, params->radius_sky,
490 params->step_r, fidx, f2f, sky_sel);
491
492 obj_idx++;
493 cpl_array_delete(sky_indexes);
494 }
495 sky_stare_tables[t] = sky_stare_table;
496 }
497
498 for (int i = 0; i < sky_size; i++) {
499 int fidx = cpl_array_get_cplsize(sky_sel, i, NULL);
500 cpl_table_set_int(det_fibre_table, MOO_FIBRES_TABLE_HEALTH, fidx,
501 -1);
502 }
503
504 for (int i = 0; i < 3; i++) {
505 cpl_table *sky_stare_table = sky_stare_tables[i];
506 int nrow = cpl_table_get_nrow(sky_stare_table);
507
508 for (int r = 0; r < nrow; r++) {
509 int indexrbn =
510 cpl_table_get_int(sky_stare_table,
511 MOO_SKY_STARE_SKYINDEXRBN, r, NULL);
512 cpl_table_select_all(det_fibre_table);
513 cpl_table_and_selected_int(det_fibre_table,
514 MOO_FIBRES_TABLE_INDEXRBN,
515 CPL_EQUAL_TO, indexrbn);
516 cpl_array *detsel = cpl_table_where_selected(det_fibre_table);
517 int fidx = cpl_array_get_cplsize(detsel, 0, NULL);
518 cpl_table_set_int(det_fibre_table, MOO_FIBRES_TABLE_HEALTH,
519 fidx, 1);
520 cpl_array_delete(detsel);
521 }
522 cpl_table_delete(sky_stare_table);
523 }
524
525 cpl_table_select_all(det_fibre_table);
526 size =
527 cpl_table_and_selected_int(det_fibre_table, MOO_FIBRES_TABLE_HEALTH,
528 CPL_EQUAL_TO, -1);
529 cpl_array_delete(sel);
530 sel = cpl_table_where_selected(det_fibre_table);
531 for (int i = 0; i < size; i++) {
532 int fidx = cpl_array_get_cplsize(sel, i, NULL);
533 cpl_table_set_int(loc_fibre_table, MOO_FIBRES_TABLE_HEALTH, fidx,
534 -1);
535 }
536 }
537 cpl_table_erase_column(det_fibre_table, MOO_TARGET_TABLE_INDEXRBN);
538
539moo_try_cleanup:
540 cpl_free(sky_stare_tables);
541 cpl_array_delete(sky_sel);
542 cpl_array_delete(obj_sel);
543 cpl_array_delete(sel);
544 moo_f2f_delete(f2f);
545 return nb_targets;
546}
547
548static cpl_error_code
549_moons_quicklook_check_sof(cpl_frameset *frameset,
550 cpl_frame **frame,
551 const char **bpmap_rp_name,
552 const char **bpmap_nl_name,
553 const cpl_frame **masterbias,
554 const cpl_frame **masterdark_vis,
555 const cpl_frame **masterdark_nir,
556 const cpl_frame **fftrace,
557 const cpl_frame **coeffs_cube,
558 const cpl_frame **wmap,
559 const cpl_frame **skylines,
560 const cpl_frame **flat,
561 const cpl_frame **f2f,
562 const cpl_frame **p2pmap,
563 const cpl_frame **sformat,
564 const cpl_frame **atmo,
565 const cpl_frame **resp)
566{
567 cpl_ensure_code(moo_dfs_set_groups(frameset) == CPL_ERROR_NONE,
568 cpl_error_get_code());
569 int i;
570 int nb_object = 0;
571
572 for (i = 0; i < cpl_frameset_get_size(frameset); ++i) {
573 cpl_frame *current_frame = cpl_frameset_get_position(frameset, i);
574 if (!strcmp(cpl_frame_get_tag(current_frame), MOONS_TAG_OBJECT_STARE)) {
575 *frame = current_frame;
576 nb_object++;
577 }
578 else if (!strcmp(cpl_frame_get_tag(current_frame),
579 MOONS_TAG_OBJECT_STARENOD)) {
580 *frame = current_frame;
581 nb_object++;
582 }
583 else if (!strcmp(cpl_frame_get_tag(current_frame),
584 MOONS_TAG_OBJECT_XSWITCH)) {
585 *frame = current_frame;
586 nb_object++;
587 }
588 else if (!strcmp(cpl_frame_get_tag(current_frame),
589 MOONS_TAG_BP_MAP_RP)) {
590 *bpmap_rp_name = cpl_frame_get_filename(current_frame);
591 }
592 else if (!strcmp(cpl_frame_get_tag(current_frame),
593 MOONS_TAG_BP_MAP_NL)) {
594 *bpmap_nl_name = cpl_frame_get_filename(current_frame);
595 }
596 else if (!strcmp(cpl_frame_get_tag(current_frame),
597 MOONS_TAG_MASTER_BIAS)) {
598 *masterbias = current_frame;
599 }
600 else if (!strcmp(cpl_frame_get_tag(current_frame),
601 MOONS_TAG_MASTER_DARK_VIS)) {
602 *masterdark_vis = current_frame;
603 }
604 else if (!strcmp(cpl_frame_get_tag(current_frame),
605 MOONS_TAG_MASTER_DARK_NIR)) {
606 *masterdark_nir = current_frame;
607 }
608 else if (!strcmp(cpl_frame_get_tag(current_frame), MOONS_TAG_P2P_MAP)) {
609 *p2pmap = current_frame;
610 }
611 else if (!strcmp(cpl_frame_get_tag(current_frame),
612 MOONS_TAG_SPECTRAL_FORMAT)) {
613 *sformat = current_frame;
614 }
615 else if (!strcmp(cpl_frame_get_tag(current_frame),
616 MOONS_TAG_ATMOS_EXT)) {
617 *atmo = current_frame;
618 }
619 else if (!strcmp(cpl_frame_get_tag(current_frame),
620 MOONS_TAG_RESPONSE)) {
621 *resp = current_frame;
622 }
623 else if (!strcmp(cpl_frame_get_tag(current_frame),
624 MOONS_TAG_FF_TRACE)) {
625 *fftrace = current_frame;
626 }
627 else if (!strcmp(cpl_frame_get_tag(current_frame),
628 MOONS_TAG_LINEARITY_COEFF_CUBE)) {
629 *coeffs_cube = current_frame;
630 }
631 else if (!strcmp(cpl_frame_get_tag(current_frame), MOONS_TAG_WAVEMAP)) {
632 *wmap = current_frame;
633 }
634 else if (!strcmp(cpl_frame_get_tag(current_frame),
635 MOONS_TAG_SKY_LINE_LIST)) {
636 *skylines = current_frame;
637 }
638 else if (!strcmp(cpl_frame_get_tag(current_frame),
639 MOONS_TAG_FF_EXTSPECTRA)) {
640 *flat = current_frame;
641 }
642 else if (!strcmp(cpl_frame_get_tag(current_frame),
643 MOONS_TAG_F2F_TABLE)) {
644 *f2f = current_frame;
645 }
646 }
647
648 if (*sformat == NULL) {
649 return (int)cpl_error_set_message(cpl_func, CPL_ERROR_DATA_NOT_FOUND,
650 "SOF does not have any file tagged "
651 "with %s",
652 MOONS_TAG_SPECTRAL_FORMAT);
653 }
654
655 if (nb_object != 1) {
656 return (int)cpl_error_set_message(cpl_func, CPL_ERROR_DATA_NOT_FOUND,
657 "SOF does exactly one file tagged "
658 "with %s or %s or %s",
659 MOONS_TAG_OBJECT_STARE,
660 MOONS_TAG_OBJECT_STARENOD,
661 MOONS_TAG_OBJECT_XSWITCH);
662 }
663
664 if (*fftrace == NULL) {
665 return (int)cpl_error_set_message(cpl_func, CPL_ERROR_DATA_NOT_FOUND,
666 "SOF does not have any file tagged "
667 "with %s",
668 MOONS_TAG_FF_TRACE);
669 }
670
671 if (*wmap == NULL) {
672 return (int)cpl_error_set_message(cpl_func, CPL_ERROR_DATA_NOT_FOUND,
673 "SOF does not have any file tagged "
674 "with %s",
675 MOONS_TAG_WAVEMAP);
676 }
677
678 if (*skylines == NULL) {
679 return (int)cpl_error_set_message(cpl_func, CPL_ERROR_DATA_NOT_FOUND,
680 "SOF does not have any file tagged "
681 "with %s",
682 MOONS_TAG_SKY_LINE_LIST);
683 }
684 if (*flat == NULL) {
685 return (int)cpl_error_set_message(cpl_func, CPL_ERROR_DATA_NOT_FOUND,
686 "SOF does not have any file tagged "
687 "with %s",
688 MOONS_TAG_FF_EXTSPECTRA);
689 }
690 return CPL_ERROR_NONE;
691}
692
693static cpl_error_code
694_moons_p2pmap(moo_det *arc, const cpl_frame *p2pmap)
695{
696 cpl_error_code status = CPL_ERROR_NONE;
697 moo_det *p2p = NULL;
698
699 if (p2pmap != NULL) {
700 cpl_msg_info("test", "apply_p2P");
701 moo_try_check(p2p = moo_det_create(p2pmap), " ");
702 moo_try_check(moo_apply_p2p(arc, p2p), " ");
703 }
704moo_try_cleanup:
705 moo_det_delete(p2p);
706 return status;
707}
708
709static cpl_error_code
710_moons_apply_flat(moo_ext *ext,
711 const cpl_frame *flat_frame,
712 const cpl_frame *f2f_frame)
713{
714 cpl_error_code status = CPL_ERROR_NONE;
715 moo_ext *flat = NULL;
716 moo_f2f *f2f = NULL;
717
718 moo_try_check(flat = moo_ext_create(flat_frame), " ");
719 if (f2f_frame != NULL) {
720 f2f = moo_f2f_load(f2f_frame);
721 }
722 moo_try_check(moo_apply_flat(ext, flat, f2f), " ");
723
724moo_try_cleanup:
725 moo_ext_delete(flat);
726 moo_f2f_delete(f2f);
727 return status;
728}
729
730static moo_sci *
731_moons_sub_sky_stare(moo_rbn *rbn,
732 moo_target_table *target_table,
733 const cpl_frame *f2f_frame,
734 const cpl_frame *solflux_frame,
735 const cpl_frame *airglow_group_frame,
736 const cpl_frame *airglow_var_frame,
737 moo_sub_sky_stare_params *sky_params,
738 const char *sci_filename)
739{
740 moo_sci *result = NULL;
741 moo_f2f *f2f = NULL;
742
743 if (f2f_frame != NULL) {
744 f2f = moo_f2f_load(f2f_frame);
745 }
746 moo_try_check(result =
747 moo_sub_sky_stare(rbn, target_table, rbn, f2f,
748 solflux_frame, airglow_group_frame,
749 airglow_var_frame, sky_params,
750 sci_filename, MOO_SCI1D_NOT_PAIRED),
751 " ");
752
753moo_try_cleanup:
754 moo_f2f_delete(f2f);
755 return result;
756}
757
758static moo_sci *
759_moons_quicklook_notarget_sci(moo_det *det, const char *filename)
760{
761 moo_sci *res = NULL;
762
763 res = moo_sci_new();
764 res->filename = filename;
765 res->primary_header = cpl_propertylist_duplicate(det->primary_header);
766 moo_target_table *ttable = moo_create_empty_target_table();
767
768 res->target_table = ttable;
769 moo_sci_save(res, filename);
770 return res;
771}
772/*----------------------------------------------------------------------------*/
779/*----------------------------------------------------------------------------*/
780
781static int
782_moons_quicklook(cpl_frameset *frameset, const cpl_parameterlist *parlist)
783{
784 /* parameters */
785 moo_prepare_params *prepare_params = NULL;
786 moo_correct_bias_params *correct_bias_params = NULL;
787 moo_extract_params *extract_params = NULL;
788 moo_rebin_params *rbn_params = NULL;
789 moo_target_table_params *target_table_params = NULL;
790 moo_sub_sky_stare_params *sky_params = NULL;
791 cpl_array *index_list = NULL;
792 moo_loc *loc = NULL;
793 moo_spectral_format *sformat = NULL;
794 moo_map *wmap = NULL;
795 moo_sky_lines_list *skylines = NULL;
796 moo_det *det = NULL;
797 moo_ext *ext = NULL;
798 moo_rbn *rbn = NULL;
799 moo_sci *sci = NULL;
800 moo_target_table *target_table = NULL;
801
802 moo_atm *atm = NULL;
803 moo_resp *resp = NULL;
804
805 cpl_frame *frame = NULL;
806
807 const char *bpmap_rp_name = NULL;
808 const char *bpmap_nl_name = NULL;
809 const cpl_frame *masterbias = NULL;
810 const cpl_frame *masterdark_vis = NULL;
811 const cpl_frame *masterdark_nir = NULL;
812 const cpl_frame *p2pmap = NULL;
813 const cpl_frame *sformat_frame = NULL;
814 const cpl_frame *atmo_frame = NULL;
815 const cpl_frame *resp_frame = NULL;
816 const cpl_frame *fftrace = NULL;
817 const cpl_frame *coeffs_cube = NULL;
818 const cpl_frame *wmap_frame = NULL;
819 const cpl_frame *skylines_frame = NULL;
820 const cpl_frame *flat_frame = NULL;
821 const cpl_frame *f2f_frame = NULL;
822 const char *ref_filename = NULL;
823 cpl_propertylist *ref_header = NULL;
824
825 moo_mode_type mode;
826 const char *mode_name = NULL;
827 int offset;
828 int nb_targets = 0;
829 char *extname = NULL;
830 char *rbnname = NULL;
831 char *sciname = NULL;
832
833 cpl_errorstate prestate = cpl_errorstate_get();
834
835 moo_products *products =
836 moo_products_new(frameset, parlist, "moons_quicklook",
837 PACKAGE "/" PACKAGE_VERSION);
838
839 const moo_params *params = moo_products_get_params(products);
840 moo_try_check(prepare_params = moo_params_get_prepare(params, parlist),
841 " ");
842 moo_try_check(correct_bias_params =
843 moo_params_get_correct_bias(params, parlist),
844 " ");
845 extract_params = moo_extract_params_new();
846 extract_params->method = MOO_EXTRACT_METHOD_SUM;
847 moo_try_check(rbn_params = moo_params_get_rebin(params, parlist), " ");
848 target_table_params = moo_target_table_params_new();
849 target_table_params->nosky = CPL_TRUE;
850 moo_try_check(sky_params =
852 " ");
853 moo_try_check(index_list =
855 " ");
856 moo_try_check(_moons_quicklook_check_sof(frameset, &frame, &bpmap_rp_name,
857 &bpmap_nl_name, &masterbias,
858 &masterdark_vis, &masterdark_nir,
859 &fftrace, &coeffs_cube,
860 &wmap_frame, &skylines_frame,
861 &flat_frame, &f2f_frame, &p2pmap,
862 &sformat_frame, &atmo_frame,
863 &resp_frame),
864 " ");
865
866 ref_filename = cpl_frame_get_filename(frame);
867 moo_try_check(mode = moo_mode_get(frame), " ");
868 mode_name = moo_mode_get_name(mode);
869 moo_try_check(ref_header = cpl_propertylist_load(ref_filename, 0), " ");
870 moo_try_check(offset = moo_pfits_get_slit_offset(ref_header), " ");
871 cpl_propertylist_delete(ref_header);
872 ref_header = NULL;
873 cpl_msg_info(__func__, "Do offset %d Use mode %s", offset, mode_name);
874
875 moo_try_check(sformat = moo_spectral_format_load(sformat_frame, mode), " ");
876 moo_try_check(wmap = moo_map_load(wmap_frame), " ");
877 moo_try_check(loc = moo_loc_load(fftrace), " ");
878
879 moo_try_check(det = moo_prepare(frame, bpmap_rp_name, bpmap_nl_name,
880 masterbias, NULL, prepare_params),
881 " ");
882 moo_try_check(moo_products_add(products, det, CPL_FRAME_LEVEL_INTERMEDIATE,
883 MOONS_TAG_QUICKLOOK_PREPARE, NULL, frame),
884 " ");
885
886 moo_try_check(nb_targets =
887 _moons_select_quicklook_targets(det, loc, f2f_frame,
888 sky_params, index_list),
889 " ");
890
891 if (nb_targets == 0) {
892 cpl_msg_info("test", "No target");
893 sci = _moons_quicklook_notarget_sci(det, "QLOOK_SCI.fits");
894 }
895 else {
896 moo_try_check(moo_correct_bias(det, masterbias, correct_bias_params),
897 " ");
898 moo_try_check(moo_correct_dark(det, NULL, masterdark_vis,
899 masterdark_nir),
900 " ");
901 moo_try_check(moo_products_add(products, det,
902 CPL_FRAME_LEVEL_INTERMEDIATE,
903 MOONS_TAG_QUICKLOOK_CORRECTDARK, NULL,
904 frame),
905 " ");
906
907 moo_try_check(_moons_p2pmap(det, p2pmap), " ");
908
909 moo_try_check(moo_products_add(products, det,
910 CPL_FRAME_LEVEL_INTERMEDIATE,
911 MOONS_TAG_QUICKLOOK_APPLYP2P, NULL,
912 frame),
913 " ");
914 extname =
915 cpl_sprintf("%s.fits", MOONS_TAG_SCIENCE_QUICKLOOK_EXTSPECTRA);
916 moo_try_check(ext =
917 moo_extract(det, loc, NULL, extract_params, extname),
918 " ");
919 moo_try_check(moo_products_add_ext(
920 products, ext, CPL_FRAME_LEVEL_INTERMEDIATE,
921 MOONS_TAG_SCIENCE_QUICKLOOK_EXTSPECTRA, NULL, frame),
922 " ");
923
924 moo_try_check(_moons_apply_flat(ext, flat_frame, f2f_frame), " ");
925 moo_try_check(skylines = moo_sky_lines_list_load(skylines_frame), " ");
926 moo_try_check(moo_ext_compute_snr(ext, wmap, sformat, skylines), " ");
927 moo_try_check(
928 moo_products_add_ext(products, ext, CPL_FRAME_LEVEL_INTERMEDIATE,
929 MOONS_TAG_SCIENCE_QUICKLOOK_FFEXTSPECTRA, NULL,
930 frame),
931 " ");
932 rbnname =
933 cpl_sprintf("%s.fits", MOONS_TAG_SCIENCE_QUICKLOOK_RBNSPECTRA);
934 moo_try_check(rbn = moo_rebin(ext, wmap, sformat, rbn_params, rbnname),
935 " ");
936 moo_try_check(moo_rbn_compute_snr(rbn, skylines), " ");
937 moo_try_check(moo_products_add_rbn(
938 products, rbn, CPL_FRAME_LEVEL_INTERMEDIATE,
939 MOONS_TAG_SCIENCE_QUICKLOOK_RBNSPECTRA, NULL, frame),
940 " ");
941
942 moo_try_check(target_table =
943 moo_create_target_table(rbn, NULL, MOO_MODE_STARE,
944 target_table_params),
945 " ");
946
947 moo_try_check(moo_products_add_target_table(
948 products, target_table, CPL_FRAME_LEVEL_INTERMEDIATE,
949 MOONS_TAG_SCIENCE_QUICKLOOK_TARGET_TABLE, NULL,
950 frame),
951 " ");
952
953 sciname =
954 cpl_sprintf("%s.fits", MOONS_TAG_SCIENCE_QUICKLOOK_SKSSPECTRA);
955 moo_try_check(sci = _moons_sub_sky_stare(rbn, target_table, f2f_frame,
956 NULL, NULL, NULL, sky_params,
957 sciname),
958 " ");
959 moo_try_check(moo_sci_compute_snr(sci, skylines), " ");
960 }
961 moo_try_check(moo_products_add_sci(products, sci, CPL_FRAME_LEVEL_FINAL,
962 MOONS_TAG_SCIENCE_QUICKLOOK_SKSSPECTRA,
963 NULL, frame),
964 " ");
965moo_try_cleanup:
966 if (!cpl_errorstate_is_equal(prestate)) {
967 cpl_propertylist_delete(ref_header);
968 }
969
970 moo_ext_delete(ext);
971 moo_det_delete(det);
972
973 moo_atm_delete(atm);
974 moo_resp_delete(resp);
975 moo_loc_delete(loc);
977 moo_map_delete(wmap);
979 moo_target_table_delete(target_table);
980 moo_sci_delete(sci);
981 moo_rbn_delete(rbn);
982 moo_target_table_params_delete(target_table_params);
983 moo_rebin_params_delete(rbn_params);
984 moo_sub_sky_stare_params_delete(sky_params);
985 moo_extract_params_delete(extract_params);
986 moo_correct_bias_params_delete(correct_bias_params);
987 moo_prepare_params_delete(prepare_params);
988 cpl_array_delete(index_list);
989 moo_products_delete(products);
990 cpl_free(extname);
991 cpl_free(rbnname);
992 cpl_free(sciname);
993 return (int)cpl_error_get_code();
994}
void moo_atm_delete(moo_atm *self)
Delete a moo_atm.
Definition: moo_atm.c:154
moo_det * moo_det_create(const cpl_frame *frame)
Create a new moo_det from the given DET frame.
Definition: moo_det.c:91
cpl_table * moo_det_get_fibre_table(moo_det *self)
Get the FIBRE TABLE in DET.
Definition: moo_det.c:424
void moo_det_delete(moo_det *self)
Delete a moo_det.
Definition: moo_det.c:472
moo_mode_type moo_mode_get(const cpl_frame *frame)
Get the name of a mode from a frame.
Definition: moo_detector.c:224
enum _moo_detector_type_ moo_detector_type
The type code type.
Definition: moo_detector.h:64
const char * moo_mode_get_name(moo_mode_type type)
Get the name of a mode.
Definition: moo_detector.c:204
moo_ext * moo_ext_create(const cpl_frame *frame)
Create a new empty EXT filename.
Definition: moo_ext.c:86
void moo_ext_delete(moo_ext *self)
Delete a moo_ext.
Definition: moo_ext.c:370
cpl_error_code moo_ext_compute_snr(moo_ext *self, moo_map *wmap, moo_spectral_format *sformat, moo_sky_lines_list *skylines)
Compute SNR for all fibres EXT.
Definition: moo_ext.c:553
void moo_f2f_delete(moo_f2f *self)
Delete a moo_f2f.
Definition: moo_f2f.c:413
moo_f2f * moo_f2f_load(const cpl_frame *f2f_frame)
Load a F2F table from a fits file.
Definition: moo_f2f.c:139
cpl_error_code moo_f2f_order_by_index(moo_f2f *self)
Order F2F by SPECTRO,INDEX (ASC)
Definition: moo_f2f.c:190
cpl_error_code moo_fibres_table_by_index(cpl_table *table)
Order fibres table by INDEX (ASC)
moo_loc * moo_loc_load(const cpl_frame *locframe)
Load a LOC frame and create a moo_loc.
Definition: moo_loc.c:109
cpl_table * moo_loc_get_fibre_table(moo_loc *self)
Get the FIBRE TABLE in LOC.
Definition: moo_loc.c:306
void moo_loc_delete(moo_loc *self)
Delete a moo_loc.
Definition: moo_loc.c:332
void moo_map_delete(moo_map *self)
Delete a moo_map.
Definition: moo_map.c:236
cpl_array * moo_params_get_quicklook_fibre_list(const moo_params *self, const cpl_parameterlist *list)
Get quicklook_fibre_list parameter from moons parameters list.
Definition: moo_params.c:1358
moo_prepare_params * moo_params_get_prepare(const moo_params *self, const cpl_parameterlist *list)
Get remove prepare parameters from moons parameters list.
Definition: moo_params.c:1073
cpl_error_code moo_params_add_sub_sky_stare_simple(moo_params *self, cpl_parameterlist *list)
Add default parameters for moo_sub_sky_stare.
Definition: moo_params.c:2459
moo_sub_sky_stare_params * moo_params_get_sub_sky_stare_simple(const moo_params *self, const cpl_parameterlist *list)
Get sub sky stare simple parameters from moons parameters list.
Definition: moo_params.c:2957
cpl_error_code moo_params_add_quicklook_fibre_list(moo_params *self, cpl_parameterlist *list)
Add default parameters for quicklook.
Definition: moo_params.c:956
moo_correct_bias_params * moo_params_get_correct_bias(const moo_params *self, const cpl_parameterlist *list)
Get correct_bias parameters from moons parameters list.
Definition: moo_params.c:1167
void moo_params_delete(moo_params *self)
Delete a moo_params.
Definition: moo_params.c:85
cpl_error_code moo_params_add_correct_bias(moo_params *self, cpl_parameterlist *list, const char *method)
Add default parameters for correct_bias.
Definition: moo_params.c:860
cpl_error_code moo_params_add_keep_temp(moo_params *self, cpl_parameterlist *list)
Add default parameters for keep-temp.
Definition: moo_params.c:932
cpl_error_code moo_params_add_prepare(moo_params *self, cpl_parameterlist *list)
Add default parameters for prepare.
Definition: moo_params.c:667
moo_rebin_params * moo_params_get_rebin(const moo_params *self, const cpl_parameterlist *list)
Get rebin parameters from moons parameters list.
Definition: moo_params.c:2866
moo_params * moo_params_new(const char *pid, const char *recipe_id)
Create a new moo_params.
Definition: moo_params.c:62
cpl_error_code moo_params_add_rebin(moo_params *self, cpl_parameterlist *list)
Add default parameters for moo_rebin.
Definition: moo_params.c:2152
void moo_rbn_delete(moo_rbn *self)
Delete a moo_rbn.
Definition: moo_rbn.c:120
cpl_error_code moo_rbn_compute_snr(moo_rbn *self, moo_sky_lines_list *skylines)
Compute SNR for targets in RBN.
Definition: moo_rbn.c:421
void moo_resp_delete(moo_resp *self)
Delete a moo_resp.
Definition: moo_resp.c:320
void moo_sci_delete(moo_sci *self)
Delete a moo_sci.
Definition: moo_sci.c:84
moo_sci * moo_sci_new(void)
Create a new moo_sci.
Definition: moo_sci.c:66
void moo_sci_save(moo_sci *self, const char *filename)
Save a moo_sci to a FITS file.
Definition: moo_sci.c:385
cpl_error_code moo_sci_compute_snr(moo_sci *self, moo_sky_lines_list *skylines)
Compute SNR for all targets in SCI.
Definition: moo_sci.c:415
moo_sky_lines_list * moo_sky_lines_list_load(const cpl_frame *frame)
Load a SKY_LINES_LIST frame and create a moo_sky_lines_list.
void moo_sky_lines_list_delete(moo_sky_lines_list *self)
Delete a moo_sky_lines_list.
void moo_spectral_format_delete(moo_spectral_format *self)
Delete a moo_spectral_format.
moo_spectral_format * moo_spectral_format_load(const cpl_frame *frame, moo_mode_type m)
Load a SPECTRAL FORMAT frame and create a moo_spectral_format.
void moo_target_table_delete(moo_target_table *self)
Delete a moo_target_table.
moo_target_table * moo_create_target_table(moo_rbn *rbnA, moo_rbn *rbnB, moo_target_table_mode mode, moo_target_table_params *params)
Prepare target table for SCI frames using their attached fibre.
cpl_error_code moo_dfs_set_groups(cpl_frameset *set)
Set the group as RAW or CALIB in a frameset.
Definition: moo_dfs.c:206
moo_ext * moo_extract(moo_det *det, moo_loc *loc, moo_psf *master_flat, moo_extract_params *params, const char *filename)
extract the 1D spectrum of fibres
Definition: moo_extract.c:523
cpl_array * moo_select_sky(const char *targname, int indextarg, int obj_index, double obj_targalpha, double obj_targdelta, cpl_table *target_table, const char *index_colname, cpl_table *sky_stare_table, moo_detector_type type, int maxdistslit, double mintrans, int min_sky, double radius, double step_r, int target_table_idx, moo_f2f *f2f, cpl_array *allsky_indexes)
This function selects sky fibres around a target object.
cpl_error_code moo_apply_p2p(moo_det *flat, moo_det *p2pmap)
Divide DET by the pixel-to-pixel variation map.
moo_rbn * moo_rebin(moo_ext *ext, moo_map *wmap, moo_spectral_format *sformat, moo_rebin_params *params, const char *filename)
Rebin an EXT spectra in RBN format.
Definition: moo_rebin.c:783
moo_det * moo_prepare(const cpl_frame *rawframe, const char *const badpixmask_rp, const char *const badpixmask_nl, const cpl_frame *masterbias, const cpl_frame *cube_frame, moo_prepare_params *params)
This function transforms RAW frames in DET frames attaching the default bad pixel map and an error im...
Definition: moo_prepare.c:324
cpl_error_code moo_apply_flat(moo_ext *ext, moo_ext *flat, moo_f2f *f2f)
Divide spectra by 1D flat-field.
cpl_error_code moo_correct_bias(moo_det *det, const cpl_frame *masterbias_frame, moo_correct_bias_params *params)
Subtracts the Master Bias frame from a DET frame.
Definition: moo_drl.c:86
moo_sci * moo_sub_sky_stare(moo_rbn *obja_rbn, moo_target_table *target_table, moo_rbn *objb_rbn, moo_f2f *f2f, const cpl_frame *solflux_frame, const cpl_frame *airglow_group_frame, const cpl_frame *airglow_var_frame, moo_sub_sky_stare_params *params, const char *filename, int ispaired)
This function subtracts the sky in wavelength calibrated and extracted science frames obtain in Stare...
cpl_error_code moo_correct_dark(moo_det *det, moo_det *detoff, const cpl_frame *masterDarkVis, const cpl_frame *masterDarkNir)
Subtracts the master dark frame from a frame after scaling for exposure time (RI)....
Definition: moo_drl.c:250
int moo_pfits_get_slit_offset(const cpl_propertylist *plist)
find out the INS SLIT OFFSET value
Definition: moo_pfits.c:1110
moo_products * moo_products_new(cpl_frameset *framelist, const cpl_parameterlist *parlist, const char *recid, const char *pipeline_id)
create a moo_product object for a recipe
Definition: moo_products.c:53
cpl_frame * moo_products_add_sci(moo_products *self, moo_sci *sci, cpl_frame_level level, const char *tag, const char *filename, const cpl_frame *inherit_frame)
create a product from a SCI object
Definition: moo_products.c:420
cpl_frame * moo_products_add_rbn(moo_products *self, moo_rbn *rbn, cpl_frame_level level, const char *tag, const char *filename, const cpl_frame *inherit_frame)
create a product from a RBN object
Definition: moo_products.c:376
cpl_frame * moo_products_add_ext(moo_products *self, moo_ext *ext, cpl_frame_level level, const char *tag, const char *filename, const cpl_frame *inherit_frame)
create a product from a EXT object
Definition: moo_products.c:333
cpl_frame * moo_products_add_target_table(moo_products *self, moo_target_table *ttable, cpl_frame_level level, const char *tag, const char *filename, const cpl_frame *inherit_frame)
create a product from a TARGET_TABLE object
Definition: moo_products.c:774
cpl_frame * moo_products_add(moo_products *self, moo_det *det, cpl_frame_level level, const char *tag, const char *filename, const cpl_frame *inherit_frame)
create a product from a DET object
Definition: moo_products.c:203
const moo_params * moo_products_get_params(const moo_products *self)
get the moo_params object
Definition: moo_products.c:87
const char * moo_get_license(void)
Get the pipeline copyright and license.
Definition: moo_utils.c:81
the different type of detectors