31#include "moo_params.h"
33#include "moo_badpix.h"
34#include "moo_extlist.h"
35#include "moo_correct_tell.h"
36#include "moo_subtract_nod.h"
37#include "moo_combine_pair.h"
38#include "moo_combine_sky.h"
39#include "moo_products.h"
48int cpl_plugin_get_info(cpl_pluginlist *list);
54static int _moons_science_starenod2_create(cpl_plugin *plugin);
55static int _moons_science_starenod2_exec(cpl_plugin *plugin);
56static int _moons_science_starenod2_destroy(cpl_plugin *plugin);
57static int _moons_science_starenod2(cpl_frameset *frameset,
58 const cpl_parameterlist *parlist);
63static const char *
const _moons_science_starenod2_description =
64 "From an observation sequence in StareNod mode, this recipe removes the"
65 " instrumental signature and provides calibrated science products. During "
67 " sequence, the telescope nods from one position on targets (labeled as T "
69 "Fig. 5-12) to a blank sky position (S). In the sequence, different slit "
71 " positions can be used: as represented in Fig. 5-12, the combination is "
73 "with 1D wavelength calibrated sky subtracted spectra. Using different "
75 "offset positions implies that different sets of calibration (FF, wave "
77 "are given as inputs.\n"
79 " * science exposure frames n>=1 file(s) (RAW) with tag "
81 "science frame in stare+nod mode file\n"
82 " * sky exposure frames n file(s) (RAW) with tag "
84 "Sky Frames illuminated by blank sky only, obtained in the Stare+Nod"
85 " observation mode. The amount of exposure time (or DIT × NDIT for NIR), "
87 "well as the number of exposures, can be less than for the corresponding "
88 "OBJECT_STARENOD frames.\n"
89 " * [OPTIONAL] ReferenceBadPixMask 1 file (QUA) with tag "
91 "cosmetic bad pixel map\n"
92 " * [OPTIONAL] NonLinearityBadPixMask 1 file (QUA) with tag "
94 "cosmetic bad pixel map coming from linearity recipe\n"
95 " * MasterBias 1 file (DET) with tag "
98 " * MasterDarkNir 1 file (DET) with tag "
100 "master dark nir for object\n"
101 " * [OPTIONAL] MasterDarkNir 1 file (DET) with tag "
103 "master dark nir file for sky (if exposure time is different from object)\n"
104 " * [OPTIONAL] MasterDarkVis 1 file (DET) with tag "
106 "master dark vis file\n"
107 " * [OPTIONAL] CoeffsCube 1 or 2 file(s) one by offset (3D) with tag "
108 "LINEARITY_COEFF_CUBE : "
109 "coefficients to correct pixels detector linearity\n"
110 " * [OPTIONAL] P2pMap 1 file (DET) with tag "
112 "pixel to pixel map\n"
113 " * Fftrace 1 or 2 file(s) one by offset (LOC) with tag "
115 "the localisation table\n"
116 " * [OPTIONAL] MasterFlat 1 or 2 file(s) one by offset (PSF) with tag "
118 "the master flat used for optimal extraction\n"
119 " * Ffext 1 or 2 file(s) one by offset (EXT) with tag "
121 "the extracted flat field\n"
122 " * F2f [OPTIONAL] 1 or 2 file(s) one by offset (F2F) with tag "
124 "the fibre-to-fibre relative response\n"
125 " * SFormat 1 file (FMT) with tag "
127 "the spectral format table\n"
128 " * WaveMap 1 or 2 file(s) one by offset (WMAP) with tag "
130 "the wavelength map\n"
131 " * SkyLines 1 file (CAT) with tag "
133 "the sky lines list table\n"
134 " * [OPTIONAL] response 1 file (RESPONSE) with "
136 "the response spectra in the extracted pixel space\n"
137 " * [OPTIONAL] TellCorr 1 file (TELLURIC_CORR) "
138 "with tag TELLURIC_CORR : "
139 "the telluric correction spectra\n"
140 " * [OPTIONAL] atmosExt 1 file (ATMO) with tag "
142 "the atmospheric extinction table\n"
144 " * STARENOD_RBNSPECTRA_OFFSET[offset]_[insmode]_i.fits (RBN) with tag "
145 "STARENOD_RBNSPECTRA : "
146 "Science product individual calibrated frames\n"
147 " * STARENOD_RBNFLXSPECTRA_OFFSET[offset]_[insmode]_i.fits (RBN) with tag "
148 "STARENOD_RBNFLXSPECTRA : "
149 "Science product individual flux calibrated frames\n"
150 " * STARENOD_SKSSPECTRA_OFFSET[offset]_[insmode]_i.fits (SCI) with tag "
151 "STARENOD_SKSSPECTRA : "
152 "Science product individual sky subtracted frames\n"
153 " * STARENOD_SKSSPECTRA_[insmode].fits (SCI) with tag "
154 "STARENOD_SKSSPECTRA : "
155 "Science product coadd calibrated frame\n"
175cpl_plugin_get_info(cpl_pluginlist *list)
177 cpl_recipe *recipe = cpl_calloc(1,
sizeof *recipe);
178 cpl_plugin *plugin = &recipe->interface;
179 if (cpl_plugin_init(plugin, CPL_PLUGIN_API, MOONS_BINARY_VERSION,
180 CPL_PLUGIN_TYPE_RECIPE,
"moons_science_starenod2",
181 "Reduces science exposure in stare and stare+nod modes",
182 _moons_science_starenod2_description,
"Regis Haigron",
184 _moons_science_starenod2_create,
185 _moons_science_starenod2_exec,
186 _moons_science_starenod2_destroy)) {
187 cpl_msg_error(cpl_func,
"Plugin initialization failed");
188 (void)cpl_error_set_where(cpl_func);
191 if (cpl_pluginlist_append(list, plugin)) {
192 cpl_msg_error(cpl_func,
"Error adding plugin to list");
193 (void)cpl_error_set_where(cpl_func);
210_moons_science_starenod2_create(cpl_plugin *plugin)
214 if (cpl_error_get_code() != CPL_ERROR_NONE) {
215 cpl_msg_error(cpl_func,
"%s():%d: An error is already set: %s",
216 cpl_func, __LINE__, cpl_error_get_where());
217 return (
int)cpl_error_get_code();
219 if (plugin == NULL) {
220 cpl_msg_error(cpl_func,
"Null plugin");
221 cpl_ensure_code(0, (
int)CPL_ERROR_NULL_INPUT);
224 if (cpl_plugin_get_type(plugin) != CPL_PLUGIN_TYPE_RECIPE) {
225 cpl_msg_error(cpl_func,
"Plugin is not a recipe");
226 cpl_ensure_code(0, (
int)CPL_ERROR_TYPE_MISMATCH);
229 recipe = (cpl_recipe *)plugin;
231 recipe->parameters = cpl_parameterlist_new();
232 if (recipe->parameters == NULL) {
233 cpl_msg_error(cpl_func,
"Parameter list allocation failed");
234 cpl_ensure_code(0, (
int)CPL_ERROR_ILLEGAL_OUTPUT);
236 moo_params *params =
moo_params_new(
"moons",
"moons_science_starenod2");
242 MOO_CORRECT_BIAS_METHOD_MASTER);
263_moons_science_starenod2_exec(cpl_plugin *plugin)
267 cpl_errorstate initial_errorstate = cpl_errorstate_get();
269 if (cpl_error_get_code() != CPL_ERROR_NONE) {
270 cpl_msg_error(cpl_func,
"%s():%d: An error is already set: %s",
271 cpl_func, __LINE__, cpl_error_get_where());
272 return (
int)cpl_error_get_code();
274 if (plugin == NULL) {
275 cpl_msg_error(cpl_func,
"Null plugin");
276 cpl_ensure_code(0, (
int)CPL_ERROR_NULL_INPUT);
279 if (cpl_plugin_get_type(plugin) != CPL_PLUGIN_TYPE_RECIPE) {
280 cpl_msg_error(cpl_func,
"Plugin is not a recipe");
281 cpl_ensure_code(0, (
int)CPL_ERROR_TYPE_MISMATCH);
284 recipe = (cpl_recipe *)plugin;
286 if (recipe->parameters == NULL) {
287 cpl_msg_error(cpl_func,
"Recipe invoked with NULL parameter list");
288 cpl_ensure_code(0, (
int)CPL_ERROR_NULL_INPUT);
290 if (recipe->frames == NULL) {
291 cpl_msg_error(cpl_func,
"Recipe invoked with NULL frame set");
292 cpl_ensure_code(0, (
int)CPL_ERROR_NULL_INPUT);
296 _moons_science_starenod2(recipe->frames, recipe->parameters);
298 if (cpl_dfs_update_product_header(recipe->frames)) {
300 recipe_status = (int)cpl_error_get_code();
302 if (!cpl_errorstate_is_equal(initial_errorstate)) {
305 cpl_errorstate_dump(initial_errorstate, CPL_FALSE, NULL);
307 return recipe_status;
319_moons_science_starenod2_destroy(cpl_plugin *plugin)
322 if (plugin == NULL) {
323 cpl_msg_error(cpl_func,
"Null plugin");
324 cpl_ensure_code(0, (
int)CPL_ERROR_NULL_INPUT);
327 if (cpl_plugin_get_type(plugin) != CPL_PLUGIN_TYPE_RECIPE) {
328 cpl_msg_error(cpl_func,
"Plugin is not a recipe");
329 cpl_ensure_code(0, (
int)CPL_ERROR_TYPE_MISMATCH);
332 recipe = (cpl_recipe *)plugin;
333 cpl_parameterlist_delete(recipe->parameters);
338_moons_science_starenod2_check_sof(
339 cpl_frameset *frameset,
340 cpl_frameset *offset_frameset,
341 const char **bpmap_rp_name,
342 const char **bpmap_nl_name,
343 const cpl_frame **masterbias,
344 const cpl_frame **masterdark_vis,
345 cpl_frameset *masterdark_nir,
346 const cpl_frame **p2pmap,
347 const cpl_frame **sformat,
348 const cpl_frame **sky_lines,
349 const cpl_frame **atmo,
350 const cpl_frame **resp,
351 const cpl_frame **tell,
352 const cpl_frame **airglow_group,
353 const cpl_frame **airglow_var,
354 const cpl_frame **solflux,
355 const moo_sub_sky_stare_params *subsky_params)
358 cpl_error_get_code());
364 for (i = 0; i < cpl_frameset_get_size(frameset); ++i) {
365 cpl_frame *current_frame = cpl_frameset_get_position(frameset, i);
366 if (!strcmp(cpl_frame_get_tag(current_frame),
367 MOONS_TAG_OBJECT_STARENOD)) {
368 cpl_frameset_insert(offset_frameset,
369 cpl_frame_duplicate(current_frame));
372 else if (!strcmp(cpl_frame_get_tag(current_frame),
373 MOONS_TAG_OBJECT_STARE)) {
374 cpl_frameset_insert(offset_frameset,
375 cpl_frame_duplicate(current_frame));
378 else if (!strcmp(cpl_frame_get_tag(current_frame),
379 MOONS_TAG_SKY_STARENOD)) {
380 cpl_frameset_insert(offset_frameset,
381 cpl_frame_duplicate(current_frame));
384 else if (!strcmp(cpl_frame_get_tag(current_frame),
385 MOONS_TAG_BP_MAP_RP)) {
386 *bpmap_rp_name = cpl_frame_get_filename(current_frame);
388 else if (!strcmp(cpl_frame_get_tag(current_frame),
389 MOONS_TAG_BP_MAP_NL)) {
390 *bpmap_nl_name = cpl_frame_get_filename(current_frame);
392 else if (!strcmp(cpl_frame_get_tag(current_frame),
393 MOONS_TAG_MASTER_BIAS)) {
394 *masterbias = current_frame;
396 else if (!strcmp(cpl_frame_get_tag(current_frame),
397 MOONS_TAG_MASTER_DARK_VIS)) {
398 *masterdark_vis = current_frame;
400 else if (!strcmp(cpl_frame_get_tag(current_frame),
401 MOONS_TAG_MASTER_DARK_NIR)) {
402 cpl_frameset_insert(masterdark_nir,
403 cpl_frame_duplicate(current_frame));
405 else if (!strcmp(cpl_frame_get_tag(current_frame),
406 MOONS_TAG_MASTER_FLAT)) {
407 cpl_frameset_insert(offset_frameset,
408 cpl_frame_duplicate(current_frame));
410 else if (!strcmp(cpl_frame_get_tag(current_frame), MOONS_TAG_P2P_MAP)) {
411 *p2pmap = current_frame;
413 else if (!strcmp(cpl_frame_get_tag(current_frame),
414 MOONS_TAG_FF_TRACE)) {
415 cpl_frameset_insert(offset_frameset,
416 cpl_frame_duplicate(current_frame));
418 else if (!strcmp(cpl_frame_get_tag(current_frame),
419 MOONS_TAG_LINEARITY_COEFF_CUBE)) {
420 cpl_frameset_insert(offset_frameset,
421 cpl_frame_duplicate(current_frame));
423 else if (!strcmp(cpl_frame_get_tag(current_frame),
424 MOONS_TAG_SPECTRAL_FORMAT)) {
425 *sformat = current_frame;
427 else if (!strcmp(cpl_frame_get_tag(current_frame), MOONS_TAG_WAVEMAP)) {
428 cpl_frameset_insert(offset_frameset,
429 cpl_frame_duplicate(current_frame));
431 else if (!strcmp(cpl_frame_get_tag(current_frame),
432 MOONS_TAG_SKY_LINE_LIST)) {
433 *sky_lines = current_frame;
435 else if (!strcmp(cpl_frame_get_tag(current_frame),
436 MOONS_TAG_FF_EXTSPECTRA)) {
437 cpl_frameset_insert(offset_frameset,
438 cpl_frame_duplicate(current_frame));
440 else if (!strcmp(cpl_frame_get_tag(current_frame),
441 MOONS_TAG_F2F_TABLE)) {
442 cpl_frameset_insert(offset_frameset,
443 cpl_frame_duplicate(current_frame));
445 else if (!strcmp(cpl_frame_get_tag(current_frame),
446 MOONS_TAG_ATMOS_EXT)) {
447 *atmo = current_frame;
449 else if (!strcmp(cpl_frame_get_tag(current_frame),
450 MOONS_TAG_RESPONSE)) {
451 *resp = current_frame;
453 else if (!strcmp(cpl_frame_get_tag(current_frame),
454 MOONS_TAG_TELLURIC_CORR)) {
455 *tell = current_frame;
457 else if (!strcmp(cpl_frame_get_tag(current_frame),
458 MOONS_TAG_AIRGLOW_GROUP)) {
459 *airglow_group = current_frame;
461 else if (!strcmp(cpl_frame_get_tag(current_frame),
462 MOONS_TAG_AIRGLOW_VAR)) {
463 *airglow_var = current_frame;
465 else if (!strcmp(cpl_frame_get_tag(current_frame), MOONS_TAG_SOLFLUX)) {
466 *solflux = current_frame;
469 if (nb_stare > 0 && nb_starenod > 0) {
470 return (
int)cpl_error_set_message(
471 cpl_func, CPL_ERROR_DATA_NOT_FOUND,
472 "SOF have mixed file tags STARE and STARENOD");
474 if (nb_stare > 0 && nb_sky > 0) {
475 return (
int)cpl_error_set_message(cpl_func, CPL_ERROR_DATA_NOT_FOUND,
476 "remove SKY from sof");
478 if (nb_starenod > 0 && nb_sky <= 0) {
479 return (
int)cpl_error_set_message(cpl_func, CPL_ERROR_DATA_NOT_FOUND,
480 "SOF does not have any file tagged "
482 MOONS_TAG_SKY_STARENOD);
484 if (*sformat == NULL) {
485 return (
int)cpl_error_set_message(cpl_func, CPL_ERROR_DATA_NOT_FOUND,
486 "SOF does not have any file tagged "
488 MOONS_TAG_SPECTRAL_FORMAT);
490 if (*sky_lines == NULL) {
491 return (
int)cpl_error_set_message(cpl_func, CPL_ERROR_DATA_NOT_FOUND,
492 "SOF does not have any file tagged "
494 MOONS_TAG_SKY_LINE_LIST);
496 if (*airglow_group == NULL &&
497 strcmp(subsky_params->method, MOO_SUB_SKY_STARE_METHOD_SKYCORR) == 0) {
498 return (
int)cpl_error_set_message(cpl_func, CPL_ERROR_DATA_NOT_FOUND,
499 "SOF does not have any file tagged "
501 MOONS_TAG_AIRGLOW_GROUP);
503 if (*airglow_var == NULL &&
504 strcmp(subsky_params->method, MOO_SUB_SKY_STARE_METHOD_SKYCORR) == 0) {
505 return (
int)cpl_error_set_message(cpl_func, CPL_ERROR_DATA_NOT_FOUND,
506 "SOF does not have any file tagged "
508 MOONS_TAG_AIRGLOW_VAR);
510 if (*solflux == NULL &&
511 strcmp(subsky_params->method, MOO_SUB_SKY_STARE_METHOD_SKYCORR) == 0) {
512 return (
int)cpl_error_set_message(cpl_func, CPL_ERROR_DATA_NOT_FOUND,
513 "SOF does not have any file tagged "
517 return CPL_ERROR_NONE;
521_moons_science_starenod2_check_sof_byoffset(
522 cpl_frameset *frameset,
523 cpl_frameset *object_frameset,
524 cpl_frameset *sky_frameset,
525 const cpl_frame **master_flat,
526 const cpl_frame **fftrace,
527 const cpl_frame **coeffs_cube,
528 const cpl_frame **wmap,
529 const cpl_frame **flat,
530 const cpl_frame **f2f,
531 moo_extract_params *ext_params,
532 moo_sub_sky_stare_params *sky_params,
536 cpl_error_get_code());
541 for (i = 0; i < cpl_frameset_get_size(frameset); ++i) {
542 cpl_frame *current_frame = cpl_frameset_get_position(frameset, i);
543 if (!strcmp(cpl_frame_get_tag(current_frame),
544 MOONS_TAG_OBJECT_STARENOD)) {
545 cpl_frameset_insert(object_frameset,
546 cpl_frame_duplicate(current_frame));
549 else if (!strcmp(cpl_frame_get_tag(current_frame),
550 MOONS_TAG_OBJECT_STARE)) {
551 cpl_frameset_insert(object_frameset,
552 cpl_frame_duplicate(current_frame));
556 else if (!strcmp(cpl_frame_get_tag(current_frame),
557 MOONS_TAG_SKY_STARENOD)) {
558 cpl_frameset_insert(sky_frameset,
559 cpl_frame_duplicate(current_frame));
562 else if (!strcmp(cpl_frame_get_tag(current_frame),
563 MOONS_TAG_MASTER_FLAT)) {
564 *master_flat = current_frame;
566 else if (!strcmp(cpl_frame_get_tag(current_frame),
567 MOONS_TAG_FF_TRACE)) {
568 *fftrace = current_frame;
570 else if (!strcmp(cpl_frame_get_tag(current_frame),
571 MOONS_TAG_LINEARITY_COEFF_CUBE)) {
572 *coeffs_cube = current_frame;
574 else if (!strcmp(cpl_frame_get_tag(current_frame), MOONS_TAG_WAVEMAP)) {
575 *wmap = current_frame;
577 else if (!strcmp(cpl_frame_get_tag(current_frame),
578 MOONS_TAG_FF_EXTSPECTRA)) {
579 *flat = current_frame;
581 else if (!strcmp(cpl_frame_get_tag(current_frame),
582 MOONS_TAG_F2F_TABLE)) {
583 *f2f = current_frame;
587 if (nb_object <= 0) {
588 return (
int)cpl_error_set_message(cpl_func, CPL_ERROR_DATA_NOT_FOUND,
589 "SOF does not have any file tagged "
591 MOONS_TAG_OBJECT_STARENOD);
595 *mode = MOO_MODE_STARE;
596 cpl_msg_info(
"test",
"Recipe running in STARE mode");
599 *mode = MOO_MODE_STARENOD;
600 cpl_msg_info(
"test",
"Recipe running in STARENOD mode");
603 if (*mode == MOO_MODE_STARENOD) {
605 return (
int)cpl_error_set_message(
606 cpl_func, CPL_ERROR_DATA_NOT_FOUND,
607 "SOF (filter by offset) does not have any file tagged "
609 MOONS_TAG_SKY_STARENOD);
611 if (strcmp(sky_params->method, MOO_SUB_SKY_STARE_METHOD_NONE) == 0) {
612 return (
int)cpl_error_set_message(
613 cpl_func, CPL_ERROR_DATA_NOT_FOUND,
614 "sky subtraction NONE method not allowed in STARENOD");
618 if (*fftrace == NULL) {
619 return (
int)cpl_error_set_message(cpl_func, CPL_ERROR_DATA_NOT_FOUND,
620 "SOF does not have any file tagged "
625 return (
int)cpl_error_set_message(cpl_func, CPL_ERROR_DATA_NOT_FOUND,
626 "SOF does not have any file tagged "
631 return (
int)cpl_error_set_message(cpl_func, CPL_ERROR_DATA_NOT_FOUND,
632 "SOF does not have any file tagged "
634 MOONS_TAG_FF_EXTSPECTRA);
636 if (*master_flat == NULL &&
637 strcmp(ext_params->method, MOO_EXTRACT_METHOD_OPTIMAL) == 0) {
638 return (
int)cpl_error_set_message(cpl_func, CPL_ERROR_DATA_NOT_FOUND,
639 "SOF does not have any file tagged "
641 MOONS_TAG_MASTER_FLAT);
644 return CPL_ERROR_NONE;
648_moons_p2pmap(moo_det *arc,
const cpl_frame *p2pmap)
650 cpl_error_code status = CPL_ERROR_NONE;
652 if (p2pmap != NULL) {
662_moons_apply_flat(moo_ext *ext,
663 const cpl_frame *flat_frame,
664 const cpl_frame *f2f_frame)
666 cpl_error_code status = CPL_ERROR_NONE;
667 moo_ext *flat = NULL;
670 if (f2f_frame != NULL) {
681_moons_starenod_rebin(
int inum,
685 const cpl_frame *ref_frame,
686 moo_spectral_format *sformat,
687 moo_sky_lines_list *sky_lines,
689 const cpl_frame *atmo_frame,
690 const cpl_frame *resp_frame,
691 const cpl_frame *tell_frame,
692 moo_rebin_params *rbn_params,
693 moo_products *products,
696 cpl_frame *rbn_frame = NULL;
698 moo_resp *resp = NULL;
699 moo_telluric *telluric = NULL;
702 char *rbn_filename = NULL;
703 char *calibflux_filename = NULL;
704 char *tellcorr_filename = NULL;
706 cpl_ensure(ext != NULL, CPL_ERROR_NULL_INPUT, NULL);
707 cpl_ensure(ref_frame != NULL, CPL_ERROR_NULL_INPUT, NULL);
709 rbn_filename = cpl_sprintf(
"%s_RBNSPECTRA_OFFSET%d_%s_%d.fits", prefix,
711 moo_try_check(rbn =
moo_rebin(ext, wmap, sformat, rbn_params, rbn_filename),
716 MOONS_TAG_SCIENCE_STARENOD_RBNSPECTRA,
717 rbn_filename, ref_frame),
720 if (atmo_frame != NULL && resp_frame != NULL) {
724 calibflux_filename = cpl_sprintf(
"%s_RBNFLXSPECTRA_OFFSET%d_%s_%d.fits",
725 prefix, offset, mode, inum);
728 products, rbn, CPL_FRAME_LEVEL_FINAL,
729 MOONS_TAG_SCIENCE_STARENOD_RBNFLXSPECTRA,
730 calibflux_filename, ref_frame),
734 cpl_msg_info(__func__,
"No flux calibration");
737 if (tell_frame != NULL) {
741 cpl_sprintf(
"%s_RBNTELLCORRSPECTRA_OFFSET%d_%s_%d.fits", prefix,
745 products, rbn, CPL_FRAME_LEVEL_FINAL,
746 MOONS_TAG_SCIENCE_STARENOD_RBNTELLCORRSPECTRA,
747 tellcorr_filename, ref_frame),
751 cpl_msg_info(__func__,
"No telluric correction");
755 cpl_free(tellcorr_filename);
756 cpl_free(calibflux_filename);
757 cpl_free(rbn_filename);
766_moons_sub_sky_stare(moo_rbn *rbn,
768 const cpl_frame *f2f_frame,
769 const cpl_frame *solflux_frame,
770 const cpl_frame *airglow_group_frame,
771 const cpl_frame *airglow_var_frame,
772 moo_sub_sky_stare_params *sky_params,
773 const char *sci_filename)
775 moo_sci *result = NULL;
778 if (f2f_frame != NULL) {
781 moo_try_check(result =
783 solflux_frame, airglow_group_frame,
784 airglow_var_frame, sky_params,
785 sci_filename, MOO_SCI1D_NOT_PAIRED),
794_moons_stare_sci(
int inum,
797 const cpl_frame *ref_frame,
798 const cpl_frame *rbn_frame,
799 moo_sky_lines_list *sky_lines,
800 const cpl_frame *f2f_frame,
801 const cpl_frame *airglow_group_frame,
802 const cpl_frame *airglow_var_frame,
803 const cpl_frame *solflux_frame,
804 moo_target_table_params *target_table_params,
805 moo_sub_sky_stare_params *sky_params,
806 moo_products *products,
809 cpl_frame *sci_frame = NULL;
814 char *ttable_filename = NULL;
815 char *sci_filename = NULL;
817 cpl_ensure(rbn_frame != NULL, CPL_ERROR_NULL_INPUT, NULL);
818 cpl_ensure(ref_frame != NULL, CPL_ERROR_NULL_INPUT, NULL);
821 moo_try_check(target_table =
823 target_table_params),
825 ttable_filename = cpl_sprintf(
"%s_TARGET_TABLE_OFFSET%d_%s_%d.fits", prefix,
828 products, target_table, CPL_FRAME_LEVEL_INTERMEDIATE,
829 MOONS_TAG_SCIENCE_STARENOD_TARGET_TABLE, ttable_filename,
834 cpl_sprintf(
"%s_SCI_OFFSET%d_%s_%d.fits", prefix, offset, mode, inum);
836 moo_try_check(sci = _moons_sub_sky_stare(rbn, target_table, f2f_frame,
837 solflux_frame, airglow_group_frame,
838 airglow_var_frame, sky_params,
845 MOONS_TAG_SCIENCE_STARENOD_SKSSPECTRA,
846 sci_filename, ref_frame),
850 cpl_free(ttable_filename);
851 cpl_free(sci_filename);
859_moons_starenod_sci1d(
int inum,
862 const cpl_frame *obj_frame,
863 const cpl_frame *obj_rbn_frame,
864 const cpl_frame *sky_rbn_frame,
865 moo_sky_lines_list *sky_lines,
866 const cpl_frame *f2f_frame,
867 const cpl_frame *airglow_group_frame,
868 const cpl_frame *airglow_var_frame,
869 const cpl_frame *solflux_frame,
871 moo_sub_sky_stare_params *sky_params,
872 moo_products *products,
875 cpl_frame *result = NULL;
876 moo_rbn *sky_rbn = NULL;
877 moo_rbn *obj_rbn = NULL;
878 moo_sci *sci1d = NULL;
881 char *sci1d_filename = NULL;
883 cpl_ensure(obj_rbn_frame != NULL, CPL_ERROR_NULL_INPUT, NULL);
884 cpl_ensure(sky_rbn_frame != NULL, CPL_ERROR_NULL_INPUT, NULL);
886 cpl_errorstate prestate = cpl_errorstate_get();
892 cpl_sprintf(
"%s_SCI1D_OFFSET%d_%s_%d.fits", prefix, offset, mode, inum);
894 if (f2f_frame != NULL) {
897 moo_try_check(sci1d =
899 solflux_frame, airglow_group_frame,
900 airglow_var_frame, sky_params,
901 sci1d_filename, MOO_SCI1D_NOT_PAIRED),
908 MOONS_TAG_SCIENCE_STARENOD_SKSSPECTRA,
909 sci1d_filename, obj_frame),
913 if (!cpl_errorstate_is_equal(prestate)) {
914 cpl_frame_delete(result);
917 cpl_free(sci1d_filename);
926_moons_starenod_sci2d(
const char *mode,
928 const cpl_frame *ref_frame,
929 const cpl_frame *nod_rbn_frame,
930 cpl_frameset *sky_rbn_frameset,
931 moo_sky_lines_list *sky_lines,
933 moo_products *products,
936 cpl_frame *result = NULL;
937 moo_rbn *nod_rbn = NULL;
938 moo_rbn *sky_rbn = NULL;
939 moo_rbnlist *sky_rbnlist = NULL;
940 moo_sci *sci2d = NULL;
941 char *sci2d_filename = NULL;
943 cpl_ensure(nod_rbn_frame != NULL, CPL_ERROR_NULL_INPUT, NULL);
944 cpl_ensure(sky_rbn_frameset != NULL, CPL_ERROR_NULL_INPUT, NULL);
946 cpl_errorstate prestate = cpl_errorstate_get();
953 cpl_sprintf(
"%s_SCI2D_OFFSET%d_%s.fits", prefix, offset, mode);
955 moo_try_check(sci2d =
956 moo_create_sci2d(nod_rbn, sky_rbn, NULL, target_table,
957 MOO_SCI2D_NOT_PAIRED, sci2d_filename),
964 MOONS_TAG_SCIENCE_STARENOD_SKSSPECTRA,
965 sci2d_filename, ref_frame),
969 if (!cpl_errorstate_is_equal(prestate)) {
970 cpl_frame_delete(result);
973 cpl_free(sci2d_filename);
981static const cpl_frame *
982find_masterdark_nir(moo_det *det, cpl_frameset *set)
984 const cpl_frame *result = NULL;
987 double exptime = 0.0;
991 moo_det *current_det = NULL;
993 cpl_ensure(det != NULL, CPL_ERROR_NULL_INPUT, NULL);
995 for (num = 1; num <= 2; num++) {
996 for (type = 1; type <= 2; type++) {
998 if (single != NULL) {
1001 exptime = dit * ndit;
1011 if (find && set != NULL) {
1012 int size = cpl_frameset_get_size(set);
1013 for (
int i = 0; i < size; i++) {
1014 const cpl_frame *current = cpl_frameset_get_position_const(set, i);
1016 moo_single *current_single =
1021 double current_exptime = dit * ndit;
1022 if (fabs(exptime - current_exptime) <= 1E-9) {
1030 if (result != NULL) {
1031 cpl_msg_info(__func__,
"Find MASTER_DARK_NIR for exptime %f : %s",
1032 exptime, cpl_frame_get_filename(result));
1035 cpl_msg_warning(__func__,
"MASTER_DARK_NIR not found for exptime %f",
1044_moons_starenod_subtractnod(
int inum,
1047 const cpl_frame *obj_frame,
1048 const cpl_frame *obj_det_frame,
1049 const cpl_frame *sky_det_frame,
1050 moo_products *products)
1052 cpl_frame *result = NULL;
1053 char *nod_det_filename = NULL;
1054 moo_det *nod_det = NULL;
1059 moo_try_check(
moo_det_load(obj_det, badpix_level),
" ");
1060 moo_try_check(
moo_det_load(sky_det, badpix_level),
" ");
1063 cpl_sprintf(
"%s_OFFSET%d_%s_%d.fits", MOONS_TAG_STARENOD_SUBTRACTNOD,
1064 offset, mode, inum);
1066 moo_try_check(nod_det =
1070 CPL_FRAME_LEVEL_INTERMEDIATE,
1071 MOONS_TAG_STARENOD_SUBTRACTNOD,
1072 nod_det_filename, obj_frame),
1076 cpl_free(nod_det_filename);
1085_moons_starenod_prepare(
int inum,
1088 const cpl_frame *frame,
1089 const char *bpmap_rp_name,
1090 const char *bpmap_nl_name,
1091 const cpl_frame *masterbias,
1092 const cpl_frame *masterdark_vis,
1093 cpl_frameset *masterdark_nir_frameset,
1094 const cpl_frame *p2pmap,
1095 const cpl_frame *coeffs_cube,
1096 moo_prepare_params *prepare_params,
1097 moo_correct_bias_params *cbias_params,
1098 moo_products *products,
1101 cpl_frame *result = NULL;
1102 const cpl_frame *masterdark_nir = NULL;
1103 moo_det *det = NULL;
1104 char *det_filename = NULL;
1105 char *det_p2p_filename = NULL;
1106 const char *det_tags[] = { MOONS_TAG_STARENOD_OBJ_CORRECTDARK,
1107 MOONS_TAG_STARENOD_SKY_CORRECTDARK };
1108 const char *detp2p_tags[] = { MOONS_TAG_STARENOD_OBJ_APPLYP2P,
1109 MOONS_TAG_STARENOD_SKY_APPLYP2P };
1111 cpl_ensure(frame != NULL, CPL_ERROR_NULL_INPUT, NULL);
1113 moo_try_check(det =
moo_prepare(frame, bpmap_rp_name, bpmap_nl_name,
1114 masterbias, coeffs_cube, prepare_params),
1118 masterdark_nir = find_masterdark_nir(det, masterdark_nir_frameset);
1122 det_filename = cpl_sprintf(
"%s_OFFSET%d_%s_%d.fits", det_tags[objtype],
1123 offset, mode, inum);
1124 moo_try_check(
moo_products_add(products, det, CPL_FRAME_LEVEL_INTERMEDIATE,
1125 det_tags[objtype], det_filename, frame),
1127 moo_try_check(_moons_p2pmap(det, p2pmap),
" ");
1128 det_p2p_filename = cpl_sprintf(
"%s_OFFSET%d_%s_%d.fits",
1129 detp2p_tags[objtype], offset, mode, inum);
1131 CPL_FRAME_LEVEL_INTERMEDIATE,
1132 detp2p_tags[objtype],
1133 det_p2p_filename, frame),
1137 cpl_free(det_filename);
1138 cpl_free(det_p2p_filename);
1144_moons_starenod_extract(
int inum,
1147 const cpl_frame *ref_frame,
1148 const cpl_frame *det_frame,
1151 moo_spectral_format *sformat,
1152 moo_sky_lines_list *skylines,
1153 const cpl_frame *masterflat_frame,
1154 const cpl_frame *flat_frame,
1155 const cpl_frame *f2f_frame,
1156 moo_extract_params *extract_params,
1157 moo_products *products,
1160 cpl_frame *ext_frame = NULL;
1161 moo_det *det = NULL;
1162 moo_psf *psf = NULL;
1163 moo_ext *ext = NULL;
1165 char *ext_filename = NULL;
1166 char *extff_filename = NULL;
1168 cpl_ensure(det_frame != NULL, CPL_ERROR_NULL_INPUT, NULL);
1170 ext_filename = cpl_sprintf(
"%s_EXTSPECTRA_OFFSET%d_%s_%d.fits", prefix,
1171 offset, mode, inum);
1172 if (masterflat_frame != NULL) {
1177 moo_extract(det, loc, psf, extract_params, ext_filename),
1180 products, ext, CPL_FRAME_LEVEL_INTERMEDIATE,
1181 MOONS_TAG_SCIENCE_STARENOD_EXTSPECTRA, ext_filename,
1185 moo_try_check(_moons_apply_flat(ext, flat_frame, f2f_frame),
" ");
1187 extff_filename = cpl_sprintf(
"%s_EXTFFSPECTRA_OFFSET%d_%s_%d.fits", prefix,
1188 offset, mode, inum);
1191 products, ext, CPL_FRAME_LEVEL_INTERMEDIATE,
1192 MOONS_TAG_SCIENCE_STARENOD_EXTSPECTRA, extff_filename,
1197 cpl_free(ext_filename);
1198 cpl_free(extff_filename);
1206_moons_sort_mjdobs(
const cpl_frame *a,
const cpl_frame *b)
1210 const char *filenameA = cpl_frame_get_filename(a);
1211 const char *filenameB = cpl_frame_get_filename(b);
1213 cpl_propertylist *lista = cpl_propertylist_load(filenameA, 0);
1214 cpl_propertylist *listb = cpl_propertylist_load(filenameB, 0);
1216 if (cpl_propertylist_has(lista, MOO_PFITS_MJDOBS) &&
1217 cpl_propertylist_has(listb, MOO_PFITS_MJDOBS)) {
1223 else if (mjdA > mjdB) {
1230 cpl_propertylist_delete(listb);
1231 cpl_propertylist_delete(lista);
1236_moons_compare_offset(
const cpl_frame *a,
const cpl_frame *b)
1239 const char *filenameA = cpl_frame_get_filename(a);
1240 cpl_propertylist *lista = cpl_propertylist_load(filenameA, 0);
1243 const char *filenameB = cpl_frame_get_filename(b);
1244 cpl_propertylist *listb = cpl_propertylist_load(filenameB, 0);
1247 if (fabs(oA - oB) < 1E-12) {
1251 cpl_propertylist_delete(lista);
1252 cpl_propertylist_delete(listb);
1257_starenod_getsky_index(
const cpl_frame *obj_frame,
1258 const cpl_frameset *sky_frameset)
1262 cpl_ensure(obj_frame != NULL, CPL_ERROR_NULL_INPUT, 0);
1263 cpl_ensure(sky_frameset != NULL, CPL_ERROR_NULL_INPUT, 0);
1265 const char *obj_filename = cpl_frame_get_filename(obj_frame);
1266 cpl_propertylist *obj_list = cpl_propertylist_load(obj_filename, 0);
1269 int size = cpl_frameset_get_size(sky_frameset);
1270 for (
int i = 0; i < size; i++) {
1271 const cpl_frame *sky_frame =
1272 cpl_frameset_get_position_const(sky_frameset, i);
1273 const char *sky_filename = cpl_frame_get_filename(sky_frame);
1274 cpl_propertylist *sky_list = cpl_propertylist_load(sky_filename, 0);
1276 double diff = fabs(sky_mjd - obj_mjd);
1280 else if (odiff > diff) {
1284 cpl_propertylist_delete(sky_list);
1286 cpl_propertylist_delete(obj_list);
1291_starenod_nod_rebin(cpl_frameset *det_frameset,
1294 const cpl_frame *ref_frame,
1297 moo_spectral_format *sformat,
1298 moo_sky_lines_list *skylines,
1299 const cpl_frame *masterflat_frame,
1300 const cpl_frame *flat_frame,
1301 const cpl_frame *f2f_frame,
1302 const cpl_frame *atmo_frame,
1303 const cpl_frame *resp_frame,
1304 const cpl_frame *tell_frame,
1305 moo_extract_params *extract_params,
1306 moo_rebin_params *rbn_params,
1307 moo_products *products,
1310 cpl_frame *result = NULL;
1311 moo_detlist *detlist = NULL;
1312 moo_det *combined = NULL;
1314 moo_psf *psf = NULL;
1315 moo_ext *ext = NULL;
1316 moo_crh_params *crh_params = NULL;
1317 moo_atm *atm = NULL;
1318 moo_resp *resp = NULL;
1319 moo_telluric *telluric = NULL;
1320 moo_rbn *rbn = NULL;
1322 char *comb_filename = NULL;
1323 char *ext_filename = NULL;
1324 char *extff_filename = NULL;
1326 char *rbn_filename = NULL;
1327 char *calibflux_filename = NULL;
1328 char *tellcorr_filename = NULL;
1330 cpl_ensure(det_frameset != NULL, CPL_ERROR_NULL_INPUT, NULL);
1332 cpl_errorstate prestate = cpl_errorstate_get();
1333 crh_params = moo_crh_params_new();
1334 crh_params->method = MOO_CRH_METHOD_MEDIAN;
1336 moo_try_check(combined =
moo_remove_CRH(detlist, NULL, crh_params),
" ");
1338 cpl_sprintf(
"%s_COMB2D_OFFSET%d_%s.fits", prefix, offset, mode);
1341 CPL_FRAME_LEVEL_INTERMEDIATE,
1342 MOONS_TAG_STARENOD_REMOVECRH, comb_filename,
1347 cpl_sprintf(
"%s_EXTSPECTRA_OFFSET%d_%s.fits", prefix, offset, mode);
1348 if (masterflat_frame != NULL) {
1352 moo_try_check(ext =
moo_extract(combined, loc, psf, extract_params,
1356 CPL_FRAME_LEVEL_INTERMEDIATE,
1357 MOONS_TAG_SCIENCE_STARENOD_EXTSPECTRA,
1358 ext_filename, ref_frame),
1361 moo_try_check(_moons_apply_flat(ext, flat_frame, f2f_frame),
" ");
1364 cpl_sprintf(
"%s_EXTFFSPECTRA_OFFSET%d_%s.fits", prefix, offset, mode);
1367 CPL_FRAME_LEVEL_INTERMEDIATE,
1368 MOONS_TAG_SCIENCE_STARENOD_EXTSPECTRA,
1369 extff_filename, ref_frame),
1373 cpl_sprintf(
"%s_RBNSPECTRA_OFFSET%d_%s.fits", prefix, offset, mode);
1374 moo_try_check(rbn =
moo_rebin(ext, wmap, sformat, rbn_params, rbn_filename),
1379 MOONS_TAG_SCIENCE_STARENOD_RBNSPECTRA,
1380 rbn_filename, ref_frame),
1383 if (atmo_frame != NULL && resp_frame != NULL) {
1387 calibflux_filename = cpl_sprintf(
"%s_RBNFLXSPECTRA_OFFSET%d_%s.fits",
1388 prefix, offset, mode);
1391 products, rbn, CPL_FRAME_LEVEL_FINAL,
1392 MOONS_TAG_SCIENCE_STARENOD_RBNFLXSPECTRA,
1393 calibflux_filename, ref_frame),
1397 cpl_msg_info(__func__,
"No flux calibration");
1400 if (tell_frame != NULL) {
1404 cpl_sprintf(
"%s_RBNTELLCORRSPECTRA_OFFSET%d_%s.fits", prefix,
1408 products, rbn, CPL_FRAME_LEVEL_FINAL,
1409 MOONS_TAG_SCIENCE_STARENOD_RBNTELLCORRSPECTRA,
1410 tellcorr_filename, ref_frame),
1414 cpl_msg_info(__func__,
"No telluric correction");
1416 result = cpl_frame_duplicate(result);
1419 if (!cpl_errorstate_is_equal(prestate)) {
1420 cpl_frame_delete(result);
1424 moo_crh_params_delete(crh_params);
1426 cpl_free(comb_filename);
1430 cpl_free(ext_filename);
1431 cpl_free(extff_filename);
1432 cpl_free(rbn_filename);
1435 cpl_free(tellcorr_filename);
1436 cpl_free(calibflux_filename);
1446_moons_science_starenod2_byoffset(cpl_frameset *frameset,
1447 cpl_frameset *sci1d_frameset,
1448 cpl_frameset *sci2d_frameset,
1449 cpl_frameset *ref_frameset,
1450 const char *bpmap_rp_name,
1451 const char *bpmap_nl_name,
1452 const cpl_frame *masterbias,
1453 const cpl_frame *masterdark_vis,
1454 cpl_frameset *masterdark_nir,
1455 const cpl_frame *p2pmap,
1456 const cpl_frame *sformat_frame,
1457 moo_sky_lines_list *sky_lines,
1458 const cpl_frame *airglow_group_frame,
1459 const cpl_frame *solflux_frame,
1460 const cpl_frame *airglow_var_frame,
1461 const cpl_frame *atmo_frame,
1462 const cpl_frame *resp_frame,
1463 const cpl_frame *tell_frame,
1464 moo_prepare_params *prepare_params,
1465 moo_correct_bias_params *correct_bias_params,
1466 moo_extract_params *extract_params,
1467 moo_wavesol_params *wavesol_params,
1468 moo_rebin_params *rbn_params,
1469 moo_target_table_params *target_table_params,
1470 moo_sub_sky_stare_params *sky_params,
1471 moo_products *products)
1474 int *skyindex = NULL;
1475 moo_loc *loc = NULL;
1476 moo_spectral_format *sformat = NULL;
1477 moo_map *wmap = NULL;
1478 moo_map *wmap_tuned = NULL;
1479 moo_extlist *obj_extlist = NULL;
1480 moo_extlist *sky_extlist = NULL;
1481 moo_extlist *wavemap_extlist = NULL;
1482 moo_ext *sum_ext = NULL;
1483 cpl_frameset *obj_frameset = NULL;
1484 cpl_frameset *sky_frameset = NULL;
1485 cpl_frameset *sky_det_frameset = NULL;
1486 cpl_frameset *obj_det_frameset = NULL;
1487 cpl_frameset *nod_det_frameset = NULL;
1489 cpl_frameset *sky_ext_frameset = NULL;
1490 cpl_frameset *obj_ext_frameset = NULL;
1492 cpl_frameset *obj_rbn_frameset = NULL;
1493 cpl_frameset *sky_rbn_frameset = NULL;
1494 cpl_frame *nod_rbn_frame = NULL;
1496 const cpl_frame *master_flat = NULL;
1497 const cpl_frame *fftrace = NULL;
1498 const cpl_frame *coeffs_cube = NULL;
1499 const cpl_frame *wmap_frame = NULL;
1500 const cpl_frame *flat_frame = NULL;
1501 const cpl_frame *f2f_frame = NULL;
1502 char *sum_ext_filename = NULL;
1503 const char *ref_filename = NULL;
1504 cpl_propertylist *ref_header = NULL;
1506 const char *mode_name = NULL;
1508 int wavemap_extlist_size = 0;
1510 char *wmap_tuned_filename = NULL;
1513 char *ttable_filename = NULL;
1515 cpl_errorstate prestate = cpl_errorstate_get();
1516 sky_frameset = cpl_frameset_new();
1517 obj_frameset = cpl_frameset_new();
1519 sky_det_frameset = cpl_frameset_new();
1520 obj_det_frameset = cpl_frameset_new();
1521 nod_det_frameset = cpl_frameset_new();
1523 sky_ext_frameset = cpl_frameset_new();
1524 obj_ext_frameset = cpl_frameset_new();
1526 obj_rbn_frameset = cpl_frameset_new();
1527 sky_rbn_frameset = cpl_frameset_new();
1529 moo_try_check(_moons_science_starenod2_check_sof_byoffset(
1530 frameset, obj_frameset, sky_frameset, &master_flat,
1531 &fftrace, &coeffs_cube, &wmap_frame, &flat_frame,
1532 &f2f_frame, extract_params, sky_params, &target_mode),
1534 cpl_frameset_join(ref_frameset, obj_frameset);
1536 int nb_sky = cpl_frameset_get_size(sky_frameset);
1537 int nb_obj = cpl_frameset_get_size(obj_frameset);
1539 cpl_frame *frame = cpl_frameset_get_position(obj_frameset, 0);
1540 ref_filename = cpl_frame_get_filename(frame);
1543 moo_try_check(ref_header = cpl_propertylist_load(ref_filename, 0),
" ");
1545 cpl_propertylist_delete(ref_header);
1547 cpl_msg_info(__func__,
"Do offset %d Use mode %s", offset, mode_name);
1549 for (
int i = 0; i < nb_sky; i++) {
1550 cpl_msg_info(__func__,
"---Prepare sky: %d/%d", i + 1, nb_sky);
1551 cpl_frame *sky_frame = NULL;
1552 moo_try_check(sky_frame = cpl_frameset_get_position(sky_frameset, i),
1555 _moons_starenod_prepare(i, mode_name, offset, sky_frame,
1556 bpmap_rp_name, bpmap_nl_name, masterbias,
1557 masterdark_vis, masterdark_nir, p2pmap,
1558 coeffs_cube, prepare_params,
1559 correct_bias_params, products, 1);
1560 cpl_frameset_insert(sky_det_frameset, cpl_frame_duplicate(result));
1563 for (
int i = 0; i < nb_obj; i++) {
1564 cpl_msg_info(__func__,
"---Prepare objects: %d/%d", i + 1, nb_obj);
1565 cpl_frame *obj_frame = NULL;
1566 moo_try_check(obj_frame = cpl_frameset_get_position(obj_frameset, i),
1569 _moons_starenod_prepare(i, mode_name, offset, obj_frame,
1570 bpmap_rp_name, bpmap_nl_name, masterbias,
1571 masterdark_vis, masterdark_nir, p2pmap,
1572 coeffs_cube, prepare_params,
1573 correct_bias_params, products, 0);
1574 cpl_frameset_insert(obj_det_frameset, cpl_frame_duplicate(result));
1578 skyindex = cpl_calloc(nb_obj,
sizeof(
int));
1579 for (
int i = 0; i < nb_obj; i++) {
1580 cpl_frame *obj_frame = NULL;
1581 cpl_frame *obj_det_frame = NULL;
1582 cpl_frame *sky_det_frame = NULL;
1583 moo_try_check(obj_frame =
1584 cpl_frameset_get_position(obj_frameset, i),
1586 skyindex[i] = _starenod_getsky_index(obj_frame, sky_frameset);
1587 moo_try_check(obj_det_frame =
1588 cpl_frameset_get_position(obj_det_frameset, i),
1590 moo_try_check(sky_det_frame =
1591 cpl_frameset_get_position(sky_det_frameset,
1594 cpl_msg_info(__func__,
1595 "---Prepare nod %d/%d using object:%s sky: %s", i + 1,
1596 nb_obj, cpl_frame_get_filename(obj_det_frame),
1597 cpl_frame_get_filename(sky_det_frame));
1599 _moons_starenod_subtractnod(i, mode_name, offset, obj_frame,
1600 obj_det_frame, sky_det_frame,
1602 cpl_frameset_insert(nod_det_frameset, cpl_frame_duplicate(result));
1605 int nb_nod = cpl_frameset_get_size(nod_det_frameset);
1606 moo_try_check(wmap = moo_map_load(wmap_frame),
" ");
1610 for (
int i = 0; i < nb_sky; i++) {
1611 cpl_frame *sky_frame = NULL;
1612 cpl_frame *sky_det_frame = NULL;
1613 cpl_msg_info(__func__,
"---Extract sky: %d/%d", i + 1, nb_sky);
1614 moo_try_check(sky_frame = cpl_frameset_get_position(sky_frameset, i),
1616 moo_try_check(sky_det_frame =
1617 cpl_frameset_get_position(sky_det_frameset, i),
1620 _moons_starenod_extract(i, mode_name, offset, sky_frame,
1621 sky_det_frame, loc, wmap, sformat,
1622 sky_lines, master_flat, flat_frame,
1623 f2f_frame, extract_params, products,
1625 cpl_frameset_insert(sky_ext_frameset, cpl_frame_duplicate(result));
1628 for (
int i = 0; i < nb_obj; i++) {
1629 cpl_frame *obj_frame = NULL;
1630 cpl_frame *obj_det_frame = NULL;
1631 cpl_msg_info(__func__,
"---Extract objects: %d/%d", i + 1, nb_obj);
1632 moo_try_check(obj_frame = cpl_frameset_get_position(obj_frameset, i),
1634 moo_try_check(obj_det_frame =
1635 cpl_frameset_get_position(obj_det_frameset, i),
1638 _moons_starenod_extract(i, mode_name, offset, obj_frame,
1639 obj_det_frame, loc, wmap, sformat,
1640 sky_lines, master_flat, flat_frame,
1641 f2f_frame, extract_params, products,
1643 cpl_frameset_insert(obj_ext_frameset, cpl_frame_duplicate(result));
1650 for (
int i = 0; i < nb_obj; i++) {
1653 wavemap_extlist_size++;
1655 for (
int i = 0; i < nb_sky; i++) {
1658 wavemap_extlist_size++;
1662 cpl_sprintf(
"STARENOD_EXT_SUM_OFFSET%d_%s.fits", offset, mode_name);
1664 cpl_frame *ref_frame = cpl_frameset_get_position(obj_frameset, 0);
1666 CPL_FRAME_LEVEL_TEMPORARY,
1667 MOONS_TAG_SCIENCE_STARENOD_EXTSPECTRA,
1668 sum_ext_filename, ref_frame),
1670 moo_map *used_wmap = NULL;
1671 const char *wavesol_control = wavesol_params->control;
1672 if ((strcmp(wavesol_control, MOO_WAVESOL_CONTROL_CHECK) == 0) ||
1673 (strcmp(wavesol_control, MOO_WAVESOL_CONTROL_UPDATE) == 0)) {
1674 const char *sky_lines_name = sky_lines->filename;
1675 moo_try_check(wmap_tuned =
moo_wavesol(sum_ext, sky_lines_name, sformat,
1676 loc, wmap, wavesol_params),
1678 if (strcmp(wavesol_control, MOO_WAVESOL_CONTROL_UPDATE) == 0) {
1679 used_wmap = wmap_tuned;
1680 wmap_tuned_filename =
1681 cpl_sprintf(
"STARENOD_WMAP_TUNED_OFFSET%d_%s.fits", offset,
1690 for (
int i = 0; i < nb_obj; i++) {
1691 cpl_frame *obj_frame = NULL;
1693 cpl_msg_info(__func__,
"---Rebin objects: %d/%d", i + 1, nb_obj);
1694 moo_try_check(obj_frame = cpl_frameset_get_position(obj_frameset, i),
1697 _moons_starenod_rebin(i, mode_name, offset, obj_ext, obj_frame,
1698 sformat, sky_lines, used_wmap, atmo_frame,
1699 resp_frame, tell_frame, rbn_params, products,
1701 cpl_frameset_insert(obj_rbn_frameset, cpl_frame_duplicate(result));
1704 for (
int i = 0; i < nb_sky; i++) {
1705 cpl_frame *sky_frame = NULL;
1707 cpl_msg_info(__func__,
"---Rebin sky: %d/%d", i + 1, nb_sky);
1708 moo_try_check(sky_frame = cpl_frameset_get_position(sky_frameset, i),
1711 _moons_starenod_rebin(i, mode_name, offset, sky_ext, sky_frame,
1712 sformat, sky_lines, used_wmap, atmo_frame,
1713 resp_frame, tell_frame, rbn_params, products,
1715 cpl_frameset_insert(sky_rbn_frameset, cpl_frame_duplicate(result));
1719 moo_try_check(nod_rbn_frame =
1720 _starenod_nod_rebin(nod_det_frameset, mode_name,
1721 offset, frame, loc, used_wmap,
1722 sformat, sky_lines, master_flat,
1723 flat_frame, f2f_frame, atmo_frame,
1724 resp_frame, tell_frame,
1725 extract_params, rbn_params,
1726 products,
"STARENOD_NOD"),
1731 for (
int i = 0; i < nb_obj; i++) {
1732 cpl_frame *obj_frame = NULL;
1733 cpl_frame *obj_rbn_frame = NULL;
1734 cpl_msg_info(__func__,
"---Create sci: %d/%d", i + 1, nb_obj);
1735 moo_try_check(obj_frame =
1736 cpl_frameset_get_position(obj_frameset, i),
1738 moo_try_check(obj_rbn_frame =
1739 cpl_frameset_get_position(obj_rbn_frameset, i),
1742 _moons_stare_sci(i, mode_name, offset, obj_frame, obj_rbn_frame,
1743 sky_lines, f2f_frame, airglow_group_frame,
1744 airglow_var_frame, solflux_frame,
1745 target_table_params, sky_params, products,
1747 cpl_frameset_insert(sci1d_frameset, cpl_frame_duplicate(result));
1751 cpl_frame *obj_rbn_frame = NULL;
1752 cpl_frame *sky_rbn_frame = NULL;
1753 cpl_frame *sci_frame = NULL;
1755 moo_try_check(obj_rbn_frame =
1756 cpl_frameset_get_position(obj_rbn_frameset, 0),
1758 moo_try_check(sky_rbn_frame =
1759 cpl_frameset_get_position(sky_rbn_frameset,
1762 moo_rbn *sky_rbn = NULL;
1763 moo_rbn *obj_rbn = NULL;
1768 moo_try_check(target_table =
1771 target_table_params),
1775 ttable_filename = cpl_sprintf(
"STARENOD_TARGET_TABLE_OFFSET%d_%s.fits",
1779 products, target_table, CPL_FRAME_LEVEL_INTERMEDIATE,
1780 MOONS_TAG_SCIENCE_STARENOD_TARGET_TABLE,
1781 ttable_filename, frame),
1784 moo_try_check(sci_frame =
1785 _moons_starenod_sci2d(mode_name, offset, ref_frame,
1786 nod_rbn_frame, sky_rbn_frameset,
1787 sky_lines, target_table,
1788 products,
"STARENOD_NOD"),
1790 cpl_frameset_insert(sci2d_frameset, cpl_frame_duplicate(sci_frame));
1792 for (
int i = 0; i < nb_nod; i++) {
1793 cpl_frame *obj_frame = NULL;
1795 moo_try_check(obj_frame =
1796 cpl_frameset_get_position(obj_frameset, i),
1798 moo_try_check(obj_rbn_frame =
1799 cpl_frameset_get_position(obj_rbn_frameset, i),
1801 moo_try_check(sky_rbn_frame =
1802 cpl_frameset_get_position(sky_rbn_frameset,
1807 "---Create sci1d: %d/%d using nod %s object:%s sky: %s", i + 1,
1808 nb_nod, cpl_frame_get_filename(nod_rbn_frame),
1809 cpl_frame_get_filename(obj_rbn_frame),
1810 cpl_frame_get_filename(sky_rbn_frame));
1812 moo_try_check(sci_frame = _moons_starenod_sci1d(
1813 i, mode_name, offset, obj_frame, obj_rbn_frame,
1814 sky_rbn_frame, sky_lines, f2f_frame,
1815 airglow_group_frame, airglow_var_frame,
1816 solflux_frame, target_table, sky_params, products,
1819 cpl_frameset_insert(sci1d_frameset, cpl_frame_duplicate(sci_frame));
1824 if (!cpl_errorstate_is_equal(prestate)) {
1825 cpl_propertylist_delete(ref_header);
1829 if (wavemap_extlist != NULL) {
1830 for (
int i = 0; i < wavemap_extlist_size; i++) {
1839 cpl_free(sum_ext_filename);
1840 cpl_free(wmap_tuned_filename);
1843 cpl_free(ttable_filename);
1846 cpl_frameset_delete(obj_rbn_frameset);
1847 cpl_frameset_delete(sky_rbn_frameset);
1848 cpl_frame_delete(nod_rbn_frame);
1850 cpl_frameset_delete(sky_det_frameset);
1851 cpl_frameset_delete(obj_det_frameset);
1852 cpl_frameset_delete(nod_det_frameset);
1854 cpl_frameset_delete(sky_ext_frameset);
1855 cpl_frameset_delete(obj_ext_frameset);
1857 cpl_frameset_delete(obj_frameset);
1858 cpl_frameset_delete(sky_frameset);
1862 return (
int)cpl_error_get_code();
1866_moons_science_starenod2(cpl_frameset *frameset,
1867 const cpl_parameterlist *parlist)
1870 moo_prepare_params *prepare_params = NULL;
1871 moo_correct_bias_params *correct_bias_params = NULL;
1872 moo_extract_params *extract_params = NULL;
1873 moo_wavesol_params *wavesol_params = NULL;
1874 moo_rebin_params *rbn_params = NULL;
1875 moo_target_table_params *target_table_params = NULL;
1876 moo_sub_sky_stare_params *sky_params = NULL;
1877 moo_coadd_params *coadd_params = NULL;
1878 moo_create_s1d_params *s1d_params = NULL;
1879 moo_scilist *sci1d_list = NULL;
1880 moo_sci *sci1d_coadd = NULL;
1881 moo_scilist *sci2d_list = NULL;
1882 moo_sci *sci2d_coadd = NULL;
1883 moo_sci *sci_coadd = NULL;
1884 moo_scilist *sci_list = NULL;
1885 cpl_frameset *offset_frameset = NULL;
1886 cpl_frameset *set = NULL;
1887 cpl_frameset *sci1d_set = NULL;
1888 cpl_frameset *sci2d_set = NULL;
1889 cpl_frameset *sci_set = NULL;
1890 cpl_frameset *ref_frameset = NULL;
1892 const char *bpmap_rp_name = NULL;
1893 const char *bpmap_nl_name = NULL;
1894 const cpl_frame *masterbias = NULL;
1895 const cpl_frame *masterdark_vis = NULL;
1896 cpl_frameset *masterdark_nir = NULL;
1897 const cpl_frame *p2pmap = NULL;
1898 const cpl_frame *sformat_frame = NULL;
1899 const cpl_frame *sky_lines_frame = NULL;
1900 const cpl_frame *atmo_frame = NULL;
1901 const cpl_frame *resp_frame = NULL;
1902 const cpl_frame *tell_frame = NULL;
1903 const cpl_frame *airglow_group_frame = NULL;
1904 const cpl_frame *solflux_frame = NULL;
1905 const cpl_frame *airglow_var_frame = NULL;
1906 const cpl_frame *ref_frame = NULL;
1908 cpl_size *selection = NULL;
1909 moo_sky_lines_list *skylines = NULL;
1910 char *coadd1d_filename = NULL;
1911 char *coadd2d_filename = NULL;
1912 char *coadd_filename = NULL;
1914 cpl_errorstate prestate = cpl_errorstate_get();
1916 moo_products *products =
1918 PACKAGE
"/" PACKAGE_VERSION);
1923 moo_try_check(correct_bias_params =
1929 moo_try_check(target_table_params =
1936 moo_try_check(wavesol_params =
1942 offset_frameset = cpl_frameset_new();
1943 sci_set = cpl_frameset_new();
1944 sci1d_set = cpl_frameset_new();
1945 sci2d_set = cpl_frameset_new();
1946 ref_frameset = cpl_frameset_new();
1947 masterdark_nir = cpl_frameset_new();
1949 moo_try_check(_moons_science_starenod2_check_sof(
1950 frameset, offset_frameset, &bpmap_rp_name, &bpmap_nl_name,
1951 &masterbias, &masterdark_vis, masterdark_nir, &p2pmap,
1952 &sformat_frame, &sky_lines_frame, &atmo_frame,
1953 &resp_frame, &tell_frame, &airglow_group_frame,
1954 &airglow_var_frame, &solflux_frame, sky_params),
1957 cpl_frameset_sort(offset_frameset, _moons_sort_mjdobs);
1959 moo_try_check(selection =
1960 cpl_frameset_labelise(offset_frameset,
1961 &_moons_compare_offset, &nsel),
1966 for (
int i = 0; i < nsel; i++) {
1967 moo_try_check(set = cpl_frameset_extract(offset_frameset, selection, i),
1970 moo_try_check(_moons_science_starenod2_byoffset(
1971 set, sci1d_set, sci2d_set, ref_frameset,
1972 bpmap_rp_name, bpmap_nl_name, masterbias,
1973 masterdark_vis, masterdark_nir, p2pmap, sformat_frame,
1974 skylines, airglow_group_frame, solflux_frame,
1975 airglow_var_frame, atmo_frame, resp_frame, tell_frame,
1976 prepare_params, correct_bias_params, extract_params,
1977 wavesol_params, rbn_params, target_table_params,
1978 sky_params, products),
1980 cpl_frameset_delete(set);
1984 moo_try_check(ref_frame = cpl_frameset_get_position_const(ref_frameset, 0),
1988 int sci1d_size = cpl_frameset_get_size(sci1d_set);
1989 if (sci1d_size > 0) {
1990 cpl_frame *result = NULL;
1992 cpl_msg_info(__func__,
"Create SCI1D products");
1994 cpl_sprintf(
"STARENOD2_SCI1D_%s_%s.fits",
1996 sci1d_coadd =
moo_coadd(sci1d_list, coadd_params, coadd1d_filename);
1998 moo_try_check(result =
2000 CPL_FRAME_LEVEL_INTERMEDIATE,
2001 MOONS_TAG_STARENOD_SKSSPECTRA,
2002 coadd1d_filename, ref_frame),
2004 cpl_frameset_insert(sci_set, cpl_frame_duplicate(result));
2006 int sci2d_size = cpl_frameset_get_size(sci2d_set);
2007 if (sci2d_size > 0) {
2008 cpl_frame *result = NULL;
2010 cpl_msg_info(__func__,
"Create SCI2D products");
2012 cpl_sprintf(
"STARENOD2_SCI2D_%s_%s.fits",
2015 sci2d_coadd =
moo_coadd(sci2d_list, coadd_params, coadd2d_filename);
2019 moo_try_check(result =
2021 CPL_FRAME_LEVEL_INTERMEDIATE,
2022 MOONS_TAG_STARENOD_SKSSPECTRA,
2023 coadd2d_filename, ref_frame),
2025 cpl_frameset_insert(sci_set, cpl_frame_duplicate(result));
2028 if (cpl_frameset_get_size(sci_set) > 0) {
2030 cpl_msg_info(__func__,
"Create final product");
2032 cpl_sprintf(
"%s_%s.fits", MOONS_TAG_STARENOD2_COMBINED_SPECTRA,
2034 sci_coadd =
moo_coadd(sci_list, coadd_params, coadd_filename);
2038 cpl_frame *sci_final = NULL;
2040 products, sci_coadd, CPL_FRAME_LEVEL_FINAL,
2041 MOONS_TAG_STARENOD2_COMBINED_SPECTRA, coadd_filename,
2045 MOONS_TAG_SCIENCE_STARENOD2_1DSPECTRUM, products);
2049 if (!cpl_errorstate_is_equal(prestate)) {
2050 cpl_frameset_delete(set);
2052 cpl_free(coadd1d_filename);
2053 cpl_free(coadd2d_filename);
2054 cpl_free(coadd_filename);
2055 cpl_free(selection);
2064 cpl_frameset_delete(sci_set);
2065 cpl_frameset_delete(sci1d_set);
2066 cpl_frameset_delete(sci2d_set);
2067 cpl_frameset_delete(ref_frameset);
2068 cpl_frameset_delete(offset_frameset);
2069 cpl_frameset_delete(masterdark_nir);
2071 moo_extract_params_delete(extract_params);
2072 moo_wavesol_params_delete(wavesol_params);
2073 moo_rebin_params_delete(rbn_params);
2074 moo_target_table_params_delete(target_table_params);
2076 moo_sub_sky_stare_params_delete(sky_params);
2077 moo_coadd_params_delete(coadd_params);
2078 moo_correct_bias_params_delete(correct_bias_params);
2080 moo_prepare_params_delete(prepare_params);
2081 moo_products_delete(products);
2082 return (
int)cpl_error_get_code();
moo_atm * moo_atm_load(const cpl_frame *frame)
Load a ATM frame and create a moo_atm.
void moo_atm_delete(moo_atm *self)
Delete a moo_atm.
moo_det * moo_det_create(const cpl_frame *frame)
Create a new moo_det from the given DET frame.
cpl_error_code moo_det_load(moo_det *self, unsigned int level)
Load all parts in DET.
void moo_det_delete(moo_det *self)
Delete a moo_det.
moo_single * moo_det_get_single(moo_det *self, moo_detector_type type, int num)
Get the type part in DET and return it.
moo_mode_type moo_mode_get(const cpl_frame *frame)
Get the name of a mode from a frame.
const char * moo_mode_get_name(moo_mode_type type)
Get the name of a mode.
moo_detlist * moo_detlist_create(cpl_frameset *frameset)
Create a new moo_detlist from the given DET frameset.
void moo_detlist_delete(moo_detlist *self)
Free all memory used by a moo_detlist object including the DET.
moo_ext * moo_ext_create(const cpl_frame *frame)
Create a new empty EXT filename.
void moo_ext_delete(moo_ext *self)
Delete a moo_ext.
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.
moo_ext * moo_extlist_get(moo_extlist *self, int i)
Get the DET at the position i in the list.
cpl_error_code moo_extlist_set(moo_extlist *self, moo_ext *ext, cpl_size pos)
Insert a DET into an moo_extlist.
moo_ext * moo_extlist_unset(moo_extlist *self, cpl_size pos)
Remove a DET from a DET list.
moo_ext * moo_extlist_sum(moo_extlist *self, const char *filename)
Sum EXT element from the list and save result in filename.
void moo_extlist_delete(moo_extlist *self)
Free all memory used by a moo_extlist object including the DET.
moo_extlist * moo_extlist_create(cpl_frameset *frameset)
Create a new moo_extlist from the given DET frameset.
moo_extlist * moo_extlist_new(void)
Create a new moo_extlist.
void moo_f2f_delete(moo_f2f *self)
Delete a moo_f2f.
moo_f2f * moo_f2f_load(const cpl_frame *f2f_frame)
Load a F2F table from a fits file.
moo_loc * moo_loc_load(const cpl_frame *locframe)
Load a LOC frame and create a moo_loc.
void moo_loc_delete(moo_loc *self)
Delete a moo_loc.
void moo_map_save(moo_map *self, const char *filename)
Save a moo_map to a FITS file.
void moo_map_delete(moo_map *self)
Delete a moo_map.
moo_coadd_params * moo_params_get_coadd(const moo_params *self, const cpl_parameterlist *list)
Get coadd parameters from moons parameters list.
cpl_error_code moo_params_add_create_s1d(moo_params *self, cpl_parameterlist *list)
Add default parameters for create_s1d.
void moo_create_s1d_params_delete(moo_create_s1d_params *self)
Delete a moo_create_s1d_params.
cpl_error_code moo_params_add_extract(moo_params *self, cpl_parameterlist *list)
Add default parameters for extraction.
cpl_error_code moo_params_add_sub_sky_stare(moo_params *self, cpl_parameterlist *list)
Add default parameters for moo_sub_sky_stare.
moo_create_s1d_params * moo_params_get_create_s1d(const moo_params *self, const cpl_parameterlist *list)
Get create s1d parameters from moons parameters list.
moo_prepare_params * moo_params_get_prepare(const moo_params *self, const cpl_parameterlist *list)
Get remove prepare parameters from moons parameters list.
moo_sub_sky_stare_params * moo_params_get_sub_sky_stare(const moo_params *self, const cpl_parameterlist *list)
Get sub sky stare parameters from moons parameters list.
cpl_error_code moo_params_add_target_table(moo_params *self, cpl_parameterlist *list, int value)
Add default parameters for moo_create_target_table.
moo_target_table_params * moo_params_get_target_table(const moo_params *self, const cpl_parameterlist *list)
Get target_table parameters from moons parameters list.
cpl_error_code moo_params_add_science_wavesol(moo_params *self, cpl_parameterlist *list)
Add default science parameters for moo_wavesol.
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.
moo_extract_params * moo_params_get_extract(const moo_params *self, const cpl_parameterlist *list)
Get extraction parameters from moons parameters list.
moo_wavesol_params * moo_params_get_science_wavesol(const moo_params *self, const cpl_parameterlist *list)
Get science_wavesol parameters from moons parameters list.
void moo_params_delete(moo_params *self)
Delete a moo_params.
cpl_error_code moo_params_add_correct_bias(moo_params *self, cpl_parameterlist *list, const char *method)
Add default parameters for correct_bias.
cpl_error_code moo_params_add_keep_temp(moo_params *self, cpl_parameterlist *list)
Add default parameters for keep-temp.
cpl_error_code moo_params_add_prepare(moo_params *self, cpl_parameterlist *list)
Add default parameters for prepare.
moo_rebin_params * moo_params_get_rebin(const moo_params *self, const cpl_parameterlist *list)
Get rebin parameters from moons parameters list.
cpl_error_code moo_params_add_coadd(moo_params *self, cpl_parameterlist *list)
Add default parameters for moo_coadd.
moo_params * moo_params_new(const char *pid, const char *recipe_id)
Create a new moo_params.
cpl_error_code moo_params_add_rebin(moo_params *self, cpl_parameterlist *list)
Add default parameters for moo_rebin.
void moo_psf_delete(moo_psf *self)
Delete a moo_psf.
moo_psf * moo_psf_load(const cpl_frame *psfframe)
Load a PSF frame and create a moo_psf.
void moo_rbn_delete(moo_rbn *self)
Delete a moo_rbn.
moo_rbn * moo_rbn_create(const cpl_frame *frame)
Create a new empty RBN filename.
cpl_error_code moo_rbn_compute_snr(moo_rbn *self, moo_sky_lines_list *skylines)
Compute SNR for targets in RBN.
void moo_rbnlist_delete(moo_rbnlist *self)
Free all memory used by a moo_rbnlist object including the RBN.
moo_rbnlist * moo_rbnlist_create(const cpl_frameset *frameset)
Create a new moo_rbnlist from the given RBN frameset.
void moo_resp_delete(moo_resp *self)
Delete a moo_resp.
moo_resp * moo_resp_load(const cpl_frame *frame)
Load a RESP frame and create a moo_resp.
void moo_sci_delete(moo_sci *self)
Delete a moo_sci.
cpl_error_code moo_sci_compute_snr(moo_sci *self, moo_sky_lines_list *skylines)
Compute SNR for all targets in SCI.
void moo_scilist_delete(moo_scilist *self)
Free all memory used by a moo_scilist object including the SCI.
moo_scilist * moo_scilist_create(cpl_frameset *frameset)
Create a new moo_scilist from the given SCI frameset.
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_target_table_delete(moo_target_table *self)
Delete a moo_target_table.
enum _moo_target_table_mode_ moo_target_table_mode
The type code type.
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.
moo_telluric * moo_telluric_load(const cpl_frame *frame)
Load a TELLURIC frame and create a moo_telluric.
void moo_telluric_delete(moo_telluric *self)
Delete a moo_telluric.
cpl_error_code moo_dfs_set_groups(cpl_frameset *set)
Set the group as RAW or CALIB in a frameset.
moo_det * moo_remove_CRH(moo_detlist *detlist, moo_masklist *cosmiclist, moo_crh_params *params)
Remove CRH in single frames or in a combination of multiple frames.
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
moo_rbn * moo_combine_sky(moo_rbnlist *rbnlist)
Combine RBN sky frames.
cpl_error_code moo_correct_tell(moo_rbn *rbn, moo_telluric *tell)
Apply the telluric correction to 1D rebinned spectra.
moo_sci * moo_coadd(moo_scilist *scilist, moo_coadd_params *params, const char *filename)
Co-add reduced science frames in SCI format.
moo_map * moo_wavesol(moo_ext *arc_ext, const char *lineCatname, moo_spectral_format *sformat, moo_loc *loc, moo_map *wmap, moo_wavesol_params *params)
Computes the wavelength solution from 1D extracted arc spectra.
cpl_error_code moo_apply_p2p(moo_det *flat, moo_det *p2pmap)
Divide DET by the pixel-to-pixel variation map.
cpl_error_code moo_create_s1d(cpl_frame *sci_frame, moo_create_s1d_params *params, const char *tag, moo_products *products)
Apply the telluric correction to SCI.
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.
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...
cpl_error_code moo_calib_flux(moo_rbn *rbn, moo_atm *atm, moo_resp *resp)
Apply the relative flux calibration to 1D rebinned spectra.
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.
moo_det * moo_subtract_nod(moo_det *object, moo_det *sky, const char *filename)
Sky from object subtraction.
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)....
int moo_pfits_get_ndit(const cpl_propertylist *plist)
find out the ESO DET NDIT value
double moo_pfits_get_dit(const cpl_propertylist *plist)
find out the DIT value
double moo_pfits_get_mjdobs(const cpl_propertylist *plist)
find out the MJD-OBS
int moo_pfits_get_slit_offset(const cpl_propertylist *plist)
find out the INS SLIT OFFSET value
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
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
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
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
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
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
const moo_params * moo_products_get_params(const moo_products *self)
get the moo_params object
const char * moo_get_license(void)
Get the pipeline copyright and license.
the different type of detectors