30#include "moo_params.h"
32#include "moo_products.h"
42int cpl_plugin_get_info(cpl_pluginlist *list);
48static int _moons_wavecal_create(cpl_plugin *plugin);
49static int _moons_wavecal_exec(cpl_plugin *plugin);
50static int _moons_wavecal_destroy(cpl_plugin *plugin);
52_moons_wavecal(cpl_frameset *frameset,
const cpl_parameterlist *parlist);
58static const char *
const _moons_wavecal_description =
59 "This recipe aims at creating the products necessary to calibrate in"
60 " wavelength the extracted 1D spectra and rebin them. It can be used to"
61 " produce first the guess wavelength map, or to produce the final one,"
62 " from the guess map.\n"
64 " * Arc 1 file (RAW) with tag ARC : "
66 " * Arc_off 1 file (RAW) with tag ARC_OFF : "
68 " * [OPTIONAL] ReferenceBadPixMask 1 file (QUA) with tag BP_MAP_RP : "
69 "cosmetic bad pixel map\n"
70 " * [OPTIONAL] NonLinearityBadPixMask 1 file (QUA) with tag BP_MAP_NL : "
71 "cosmetic bad pixel map coming from linearity recipe\n"
72 " * MasterBias 1 file (DET) with tag MASTER_BIAS : "
74 " * [OPTIONAL] P2pMap 1 file (DET) with tag P2P_MAP : "
75 "pixel to pixel map\n"
76 " * LocTab 1 file (LOC) with tag FF_TRACE : "
77 "the localisation table\n"
79 "the extracted flat field\n"
80 " * F2f 1 file (F2F) with tag F2F_TABLE "
82 "the fibre-to-fibre relative response\n"
83 " * LineCat 1 file (CAT) with tag "
85 "the reference line list\n"
86 " * SFormat 1 file (FMT) with tag "
88 "the spectral format table\n"
89 " * [OPTIONAL] WaveMapGuess 1 file (EXT) with tag "
91 "the first guess wavelength map\n"
93 " * ARC_EXTSPECTRA[_GUESS]_OFFSET[offset]_[insmode].fits (EXT) with tag "
95 "Arc extracted spectra\n"
96 " * WAVE_MAP[_GUESS]_OFFSET[offset]_[insmode].fits (EXT) with tag "
99 " * ARC_RBNSPECTRA[_GUESS]_OFFSET[offset]_[insmode].fits (RBN) with tag "
101 "Arc extracted spectra\n"
121cpl_plugin_get_info(cpl_pluginlist *list)
123 cpl_recipe *recipe = cpl_calloc(1,
sizeof *recipe);
124 cpl_plugin *plugin = &recipe->interface;
126 if (cpl_plugin_init(plugin, CPL_PLUGIN_API, MOONS_BINARY_VERSION,
127 CPL_PLUGIN_TYPE_RECIPE,
"moons_wavecal",
128 "Produces the wavelength solution",
129 _moons_wavecal_description,
"Regis Haigron",
131 _moons_wavecal_create, _moons_wavecal_exec,
132 _moons_wavecal_destroy)) {
133 cpl_msg_error(cpl_func,
"Plugin initialization failed");
134 (void)cpl_error_set_where(cpl_func);
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);
158_moons_wavecal_create(cpl_plugin *plugin)
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();
169 if (plugin == NULL) {
170 cpl_msg_error(cpl_func,
"Null plugin");
171 cpl_ensure_code(0, (
int)CPL_ERROR_NULL_INPUT);
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);
181 recipe = (cpl_recipe *)plugin;
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);
196 MOO_CORRECT_BIAS_METHOD_MASTER);
216_moons_wavecal_exec(cpl_plugin *plugin)
220 cpl_errorstate initial_errorstate = cpl_errorstate_get();
223 if (cpl_error_get_code() != CPL_ERROR_NONE) {
224 cpl_msg_error(cpl_func,
"%s():%d: An error is already set: %s",
225 cpl_func, __LINE__, cpl_error_get_where());
226 return (
int)cpl_error_get_code();
229 if (plugin == NULL) {
230 cpl_msg_error(cpl_func,
"Null plugin");
231 cpl_ensure_code(0, (
int)CPL_ERROR_NULL_INPUT);
235 if (cpl_plugin_get_type(plugin) != CPL_PLUGIN_TYPE_RECIPE) {
236 cpl_msg_error(cpl_func,
"Plugin is not a recipe");
237 cpl_ensure_code(0, (
int)CPL_ERROR_TYPE_MISMATCH);
241 recipe = (cpl_recipe *)plugin;
244 if (recipe->parameters == NULL) {
245 cpl_msg_error(cpl_func,
"Recipe invoked with NULL parameter list");
246 cpl_ensure_code(0, (
int)CPL_ERROR_NULL_INPUT);
248 if (recipe->frames == NULL) {
249 cpl_msg_error(cpl_func,
"Recipe invoked with NULL frame set");
250 cpl_ensure_code(0, (
int)CPL_ERROR_NULL_INPUT);
254 recipe_status = _moons_wavecal(recipe->frames, recipe->parameters);
257 if (cpl_dfs_update_product_header(recipe->frames)) {
259 recipe_status = (int)cpl_error_get_code();
262 if (!cpl_errorstate_is_equal(initial_errorstate)) {
265 cpl_errorstate_dump(initial_errorstate, CPL_FALSE, NULL);
268 return recipe_status;
280_moons_wavecal_destroy(cpl_plugin *plugin)
284 if (plugin == NULL) {
285 cpl_msg_error(cpl_func,
"Null plugin");
286 cpl_ensure_code(0, (
int)CPL_ERROR_NULL_INPUT);
290 if (cpl_plugin_get_type(plugin) != CPL_PLUGIN_TYPE_RECIPE) {
291 cpl_msg_error(cpl_func,
"Plugin is not a recipe");
292 cpl_ensure_code(0, (
int)CPL_ERROR_TYPE_MISMATCH);
296 recipe = (cpl_recipe *)plugin;
298 cpl_parameterlist_delete(recipe->parameters);
304_moons_wavecal_check_sof(cpl_frameset *frameset,
305 cpl_frameset **arc_frameset,
306 cpl_frameset **arc_off_frameset,
307 const char **bpmap_rp_name,
308 const char **bpmap_nl_name,
309 const cpl_frame **masterbias,
310 const cpl_frame **masterdark_vis,
311 const cpl_frame **masterdark_nir,
312 const cpl_frame **p2pmap,
313 const cpl_frame **fftrace,
314 const cpl_frame **arc_line_list,
315 const cpl_frame **sformat,
316 const cpl_frame **wmap_guess,
317 const cpl_frame **flat_frame,
318 const cpl_frame **f2f_frame)
321 cpl_error_get_code());
325 *arc_frameset = cpl_frameset_new();
326 *arc_off_frameset = cpl_frameset_new();
329 for (i = 0; i < cpl_frameset_get_size(frameset); ++i) {
330 cpl_frame *current_frame = cpl_frameset_get_position(frameset, i);
331 if (!strcmp(cpl_frame_get_tag(current_frame), MOONS_TAG_ARC)) {
332 cpl_frame *new_frame = cpl_frame_duplicate(current_frame);
333 cpl_frameset_insert(*arc_frameset, new_frame);
336 else if (!strcmp(cpl_frame_get_tag(current_frame), MOONS_TAG_ARC_OFF)) {
337 cpl_frame *new_frame = cpl_frame_duplicate(current_frame);
338 cpl_frameset_insert(*arc_off_frameset, new_frame);
341 else if (!strcmp(cpl_frame_get_tag(current_frame),
342 MOONS_TAG_BP_MAP_RP)) {
343 *bpmap_rp_name = cpl_frame_get_filename(current_frame);
345 else if (!strcmp(cpl_frame_get_tag(current_frame),
346 MOONS_TAG_BP_MAP_NL)) {
347 *bpmap_nl_name = cpl_frame_get_filename(current_frame);
349 else if (!strcmp(cpl_frame_get_tag(current_frame),
350 MOONS_TAG_MASTER_BIAS)) {
351 *masterbias = current_frame;
353 else if (!strcmp(cpl_frame_get_tag(current_frame),
354 MOONS_TAG_MASTER_DARK_VIS)) {
355 *masterdark_vis = current_frame;
357 else if (!strcmp(cpl_frame_get_tag(current_frame),
358 MOONS_TAG_MASTER_DARK_NIR)) {
359 *masterdark_nir = current_frame;
361 else if (!strcmp(cpl_frame_get_tag(current_frame), MOONS_TAG_P2P_MAP)) {
362 *p2pmap = current_frame;
364 else if (!strcmp(cpl_frame_get_tag(current_frame),
365 MOONS_TAG_FF_TRACE)) {
366 *fftrace = current_frame;
368 else if (!strcmp(cpl_frame_get_tag(current_frame),
369 MOONS_TAG_ARC_LINE_LIST)) {
370 *arc_line_list = current_frame;
372 else if (!strcmp(cpl_frame_get_tag(current_frame),
373 MOONS_TAG_SPECTRAL_FORMAT)) {
374 *sformat = current_frame;
376 else if (!strcmp(cpl_frame_get_tag(current_frame),
377 MOONS_TAG_WAVEMAP_GUESS)) {
378 *wmap_guess = current_frame;
380 else if (!strcmp(cpl_frame_get_tag(current_frame),
381 MOONS_TAG_FF_EXTSPECTRA)) {
382 *flat_frame = current_frame;
384 else if (!strcmp(cpl_frame_get_tag(current_frame),
385 MOONS_TAG_F2F_TABLE)) {
386 *f2f_frame = current_frame;
391 return (
int)cpl_error_set_message(cpl_func, CPL_ERROR_DATA_NOT_FOUND,
392 "SOF does not have any file tagged "
397 return (
int)cpl_error_set_message(cpl_func, CPL_ERROR_DATA_NOT_FOUND,
398 "SOF does not have any file tagged "
402 if (nraw != nraw_off) {
403 return (
int)cpl_error_set_message(
404 cpl_func, CPL_ERROR_DATA_NOT_FOUND,
405 "SOF does not have same number of file with %s (%d) and %s (%d)",
406 MOONS_TAG_ARC, nraw, MOONS_TAG_ARC_OFF, nraw_off);
408 if (*fftrace == NULL) {
409 return (
int)cpl_error_set_message(cpl_func, CPL_ERROR_DATA_NOT_FOUND,
410 "SOF does not have any file tagged "
414 if (*arc_line_list == NULL) {
415 return (
int)cpl_error_set_message(cpl_func, CPL_ERROR_DATA_NOT_FOUND,
416 "SOF does not have any file tagged "
418 MOONS_TAG_ARC_LINE_LIST);
421 if (*sformat == NULL) {
422 return (
int)cpl_error_set_message(cpl_func, CPL_ERROR_DATA_NOT_FOUND,
423 "SOF does not have any file tagged "
425 MOONS_TAG_SPECTRAL_FORMAT);
427 return CPL_ERROR_NONE;
431_moons_p2pmap(moo_det *arc,
const cpl_frame *p2pmap)
433 cpl_error_code status = CPL_ERROR_NONE;
436 if (p2pmap != NULL) {
446_moons_apply_flat(moo_ext *ext,
447 const cpl_frame *flat_frame,
448 const cpl_frame *f2f_frame)
450 cpl_error_code status = CPL_ERROR_NONE;
451 moo_ext *flat = NULL;
454 if (flat_frame != NULL) {
456 if (f2f_frame != NULL) {
469_moons_get_offset(
const cpl_frame *frame)
471 const char *filename = NULL;
472 cpl_propertylist *header = NULL;
475 cpl_ensure(frame != NULL, CPL_ERROR_NULL_INPUT, 0);
477 moo_try_check(filename = cpl_frame_get_filename(frame),
" ");
478 moo_try_check(header = cpl_propertylist_load(filename, 0),
" ");
482 cpl_propertylist_delete(header);
502_moons_prepare(moo_products *products,
503 const cpl_frame *arc_frame,
504 const cpl_frame *arc_off_frame,
505 const char *bpmap_rp_name,
506 const char *bpmap_nl_name,
507 const cpl_frame *masterbias,
508 const cpl_frame *masterdark_vis,
509 const cpl_frame *masterdark_nir,
510 moo_prepare_params *prepare_params,
511 moo_correct_bias_params *correct_bias_params,
514 cpl_frame *result = NULL;
515 cpl_frame *pframe = NULL;
516 char *detname1 = NULL;
517 moo_det *det_arc = NULL;
518 moo_det *det_arc_off = NULL;
520 cpl_ensure(arc_frame != NULL, CPL_ERROR_NULL_INPUT, NULL);
521 cpl_errorstate prestate = cpl_errorstate_get();
523 moo_try_check(det_arc =
moo_prepare(arc_frame, bpmap_rp_name, bpmap_nl_name,
524 masterbias, NULL, prepare_params),
527 moo_try_check(det_arc_off =
528 moo_prepare(arc_off_frame, bpmap_rp_name, bpmap_nl_name,
529 masterbias, NULL, prepare_params),
534 moo_try_check(detname1 =
535 cpl_sprintf(
"%s_%d.fits", MOONS_TAG_ARC_CORRECTBIAS, i),
539 CPL_FRAME_LEVEL_INTERMEDIATE,
540 MOONS_TAG_ARC_CORRECTBIAS, detname1,
545 moo_try_check(detname1 =
546 cpl_sprintf(
"%s_%d.fits", MOONS_TAG_ARCOFF_PREPARE, i),
549 CPL_FRAME_LEVEL_INTERMEDIATE,
550 MOONS_TAG_ARCOFF_PREPARE, detname1,
558 moo_try_check(detname1 =
559 cpl_sprintf(
"%s_%d.fits", MOONS_TAG_ARC_CORRECTDARK, i),
562 CPL_FRAME_LEVEL_INTERMEDIATE,
563 MOONS_TAG_ARC_CORRECTDARK, detname1,
567 moo_try_check(result = cpl_frame_duplicate(pframe),
" ");
570 if (!cpl_errorstate_is_equal(prestate)) {
571 cpl_frame_delete(result);
596_moons_prepare_set(cpl_frameset *raw_frames,
597 cpl_frameset *raw_off_frames,
598 const char *bpmap_rp_name,
599 const char *bpmap_nl_name,
600 const cpl_frame *masterbias,
601 const cpl_frame *masterdark_vis,
602 const cpl_frame *masterdark_nir,
603 moo_prepare_params *prepare_params,
604 moo_correct_bias_params *params,
605 moo_products *products)
607 cpl_frameset *detframes = NULL;
609 cpl_ensure(raw_frames, CPL_ERROR_NULL_INPUT, NULL);
610 cpl_ensure(raw_off_frames, CPL_ERROR_NULL_INPUT, NULL);
611 cpl_ensure(products, CPL_ERROR_NULL_INPUT, NULL);
613 cpl_errorstate prestate = cpl_errorstate_get();
615 moo_try_check(detframes = cpl_frameset_new(),
" ");
617 for (
int i = 0; i < cpl_frameset_get_size(raw_frames); ++i) {
618 const cpl_frame *current_frame = NULL;
619 const cpl_frame *current_off_frame = NULL;
620 cpl_frame *frame = NULL;
622 moo_try_check(current_frame =
623 cpl_frameset_get_position_const(raw_frames, i),
625 moo_try_check(current_off_frame =
626 cpl_frameset_get_position_const(raw_off_frames, i),
629 moo_try_check(frame = _moons_prepare(products, current_frame,
630 current_off_frame, bpmap_rp_name,
631 bpmap_nl_name, masterbias,
632 masterdark_vis, masterdark_nir,
633 prepare_params, params, i),
636 moo_try_check(cpl_frameset_insert(detframes, frame),
" ");
639 if (!cpl_errorstate_is_equal(prestate)) {
640 cpl_frameset_delete(detframes);
655_moons_wavecal(cpl_frameset *frameset,
const cpl_parameterlist *parlist)
658 moo_prepare_params *prepare_params = NULL;
659 moo_correct_bias_params *correct_bias_params = NULL;
660 moo_crh_params *crh_params = NULL;
661 moo_extract_params *extract_params = NULL;
662 moo_wavesol_params *wavesol_params = NULL;
663 moo_rebin_params *rbn_params = NULL;
664 moo_detlist *arc_det_list = NULL;
665 moo_det *arc_det_med = NULL;
666 moo_spectral_format *sformat = NULL;
669 moo_map *wmap_guess = NULL;
670 moo_map *wmap_refit = NULL;
671 moo_map *wmap = NULL;
673 moo_rbn *refit_rbn = NULL;
674 moo_rbn *ppm_rbn = NULL;
677 char *ext_filename = NULL;
678 char *ffext_filename = NULL;
679 char *ppm_rbn_filename = NULL;
680 char *ppm_wave_filename = NULL;
681 char *refit_rbn_filename = NULL;
682 char *refit_wave_filename = NULL;
683 char *rbn_filename = NULL;
684 char *wave_filename = NULL;
687 cpl_frameset *arc_frameset = NULL;
688 cpl_frameset *arc_off_frameset = NULL;
689 cpl_frameset *arc_det_frameset = NULL;
690 const char *bpmap_rp_name = NULL;
691 const char *bpmap_nl_name = NULL;
692 const cpl_frame *masterbias = NULL;
693 const cpl_frame *masterdark_vis = NULL;
694 const cpl_frame *masterdark_nir = NULL;
695 const cpl_frame *p2pmap = NULL;
696 const cpl_frame *fftrace = NULL;
697 const cpl_frame *flat_frame = NULL;
698 const cpl_frame *f2f_frame = NULL;
700 const cpl_frame *arc_line_list = NULL;
701 const cpl_frame *sformat_frame = NULL;
702 const cpl_frame *wmap_frame = NULL;
704 moo_products *products =
706 PACKAGE
"/" PACKAGE_VERSION);
711 moo_try_check(correct_bias_params =
717 if (strcmp(extract_params->method, MOO_EXTRACT_METHOD_SUM) != 0) {
718 cpl_msg_info(__func__,
719 "Extract method %s not supported : use %s instead",
720 extract_params->method, MOO_EXTRACT_METHOD_SUM);
721 extract_params->method = MOO_EXTRACT_METHOD_SUM;
727 moo_try_check(_moons_wavecal_check_sof(frameset, &arc_frameset,
728 &arc_off_frameset, &bpmap_rp_name,
729 &bpmap_nl_name, &masterbias,
730 &masterdark_vis, &masterdark_nir,
731 &p2pmap, &fftrace, &arc_line_list,
732 &sformat_frame, &wmap_frame,
733 &flat_frame, &f2f_frame),
736 cpl_frame *arc_frame = cpl_frameset_get_position(arc_frameset, 0);
739 moo_try_check(offset = _moons_get_offset(arc_frame),
" ");
743 moo_try_check(arc_det_frameset =
744 _moons_prepare_set(arc_frameset, arc_off_frameset,
745 bpmap_rp_name, bpmap_nl_name,
746 masterbias, masterdark_vis,
747 masterdark_nir, prepare_params,
748 correct_bias_params, products),
753 moo_try_check(arc_det_med =
moo_remove_CRH(arc_det_list, NULL, crh_params),
756 const char *arc_filename = MOONS_TAG_ARC_REMOVECRH
".fits";
758 CPL_FRAME_LEVEL_INTERMEDIATE,
759 MOONS_TAG_ARC_REMOVECRH, arc_filename,
763 moo_try_check(_moons_p2pmap(arc_det_med, p2pmap),
" ");
769 const char *wtag = MOONS_TAG_WAVEMAP_GUESS;
770 const char *arc_line_list_name = cpl_frame_get_filename(arc_line_list);
772 if (wmap_frame != NULL) {
774 cpl_sprintf(
"%s_OFFSET%d_%s.fits", MOONS_TAG_ARC_EXTSPECTRA, offset,
777 moo_try_check(ext =
moo_extract(arc_det_med, loc, NULL, extract_params,
781 MOONS_TAG_ARC_EXTSPECTRA,
782 ext_filename, arc_frame),
784 moo_try_check(_moons_apply_flat(ext, flat_frame, f2f_frame),
" ");
785 if (flat_frame != NULL) {
787 cpl_sprintf(
"%s_OFFSET%d_%s.fits", MOONS_TAG_ARC_FFEXTSPECTRA,
791 CPL_FRAME_LEVEL_FINAL,
792 MOONS_TAG_ARC_FFEXTSPECTRA,
793 ffext_filename, arc_frame),
796 moo_try_check(wmap_guess = moo_map_load(wmap_frame),
" ");
797 wtag = MOONS_TAG_WAVEMAP;
799 cpl_sprintf(
"%s_OFFSET%d_%s.fits", MOONS_TAG_ARC_RBNSPECTRA, offset,
801 wave_filename = cpl_sprintf(
"%s_OFFSET%d_%s.fits", wtag, offset,
803 moo_try_check(wmap =
moo_wavesol(ext, arc_line_list_name, sformat, loc,
804 wmap_guess, wavesol_params),
807 moo_try_check(rbn =
moo_rebin(ext, wmap, sformat, rbn_params,
812 MOONS_TAG_ARC_RBNSPECTRA,
813 rbn_filename, arc_frame),
817 CPL_FRAME_LEVEL_FINAL, wtag,
818 wave_filename, arc_frame, rbn),
819 "can't create wave map product");
823 cpl_sprintf(
"%s_OFFSET%d_%s.fits", MOONS_TAG_ARC_EXTSPECTRA_GUESS,
826 moo_try_check(ext =
moo_extract(arc_det_med, loc, NULL, extract_params,
830 MOONS_TAG_ARC_EXTSPECTRA_GUESS,
831 ext_filename, arc_frame),
833 moo_try_check(_moons_apply_flat(ext, flat_frame, f2f_frame),
" ");
834 if (flat_frame != NULL) {
836 cpl_sprintf(
"%s_OFFSET%d_%s.fits", MOONS_TAG_ARC_FFEXTSPECTRA,
840 CPL_FRAME_LEVEL_FINAL,
841 MOONS_TAG_ARC_FFEXTSPECTRA,
842 ffext_filename, arc_frame),
846 cpl_sprintf(
"%s_OFFSET%d_%s.fits", MOONS_TAG_WAVEMAP_PPM, offset,
849 cpl_sprintf(
"%s_OFFSET%d_%s.fits", MOONS_TAG_ARC_RBNSPECTRA_PPM,
851 refit_wave_filename =
852 cpl_sprintf(
"%s_OFFSET%d_%s.fits", MOONS_TAG_WAVEMAP_REFIT, offset,
855 cpl_sprintf(
"%s_OFFSET%d_%s.fits", MOONS_TAG_ARC_RBNSPECTRA_REFIT,
858 cpl_sprintf(
"%s_OFFSET%d_%s.fits", MOONS_TAG_WAVEMAP_GUESS, offset,
861 cpl_sprintf(
"%s_OFFSET%d_%s.fits", MOONS_TAG_ARC_RBNSPECTRA_GUESS,
864 moo_try_check(wmap_guess =
moo_wavesol(ext, arc_line_list_name, sformat,
865 loc, NULL, wavesol_params),
867 moo_try_check(wmap_refit =
moo_wavesol(ext, arc_line_list_name, sformat,
868 loc, wmap_guess, wavesol_params),
871 if (wmap_refit != NULL) {
872 moo_try_check(ppm_rbn =
moo_rebin(ext, wmap_guess, sformat,
873 rbn_params, ppm_rbn_filename),
875 moo_try_check(refit_rbn =
moo_rebin(ext, wmap_refit, sformat,
876 rbn_params, refit_rbn_filename),
880 CPL_FRAME_LEVEL_INTERMEDIATE,
881 MOONS_TAG_ARC_RBNSPECTRA_PPM,
882 ppm_rbn_filename, arc_frame),
886 CPL_FRAME_LEVEL_INTERMEDIATE,
887 MOONS_TAG_WAVEMAP_PPM,
888 ppm_wave_filename, arc_frame,
890 "can't create wave map product");
893 CPL_FRAME_LEVEL_INTERMEDIATE,
894 MOONS_TAG_ARC_RBNSPECTRA_REFIT,
895 refit_rbn_filename, arc_frame),
899 CPL_FRAME_LEVEL_INTERMEDIATE,
900 MOONS_TAG_WAVEMAP_REFIT,
901 refit_wave_filename, arc_frame,
903 "can't create wave map product");
905 for (
int i = 0; i < 6; i++) {
906 wavesol_params->linefit_winhsize[i] =
907 wavesol_params->linedetect_winhsize[i];
909 wavesol_params->isrefit = 2;
911 moo_try_check(wmap =
moo_wavesol(ext, arc_line_list_name, sformat,
912 loc, wmap_refit, wavesol_params),
915 moo_try_check(rbn =
moo_rebin(ext, wmap, sformat, rbn_params,
919 CPL_FRAME_LEVEL_FINAL,
920 MOONS_TAG_ARC_RBNSPECTRA_GUESS,
921 rbn_filename, arc_frame),
925 CPL_FRAME_LEVEL_FINAL, wtag,
926 wave_filename, arc_frame, rbn),
927 "can't create wave map product");
930 moo_try_check(rbn =
moo_rebin(ext, wmap_guess, sformat, rbn_params,
935 CPL_FRAME_LEVEL_FINAL, wtag,
936 wave_filename, arc_frame, rbn),
937 "can't create wave map product");
940 CPL_FRAME_LEVEL_FINAL,
941 MOONS_TAG_ARC_RBNSPECTRA,
942 rbn_filename, arc_frame),
948 cpl_free(ext_filename);
949 cpl_free(ffext_filename);
950 cpl_free(rbn_filename);
951 cpl_free(wave_filename);
952 cpl_free(refit_rbn_filename);
953 cpl_free(refit_wave_filename);
954 cpl_free(ppm_rbn_filename);
955 cpl_free(ppm_wave_filename);
967 cpl_frameset_delete(arc_frameset);
968 cpl_frameset_delete(arc_off_frameset);
970 cpl_frameset_delete(arc_det_frameset);
971 moo_extract_params_delete(extract_params);
972 moo_wavesol_params_delete(wavesol_params);
973 moo_rebin_params_delete(rbn_params);
974 moo_crh_params_delete(crh_params);
975 moo_correct_bias_params_delete(correct_bias_params);
976 moo_prepare_params_delete(prepare_params);
977 moo_products_delete(products);
978 return (
int)cpl_error_get_code();
moo_det * moo_det_create(const cpl_frame *frame)
Create a new moo_det from the given DET frame.
void moo_det_delete(moo_det *self)
Delete a moo_det.
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.
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_delete(moo_map *self)
Delete a moo_map.
cpl_error_code moo_params_add_extract(moo_params *self, cpl_parameterlist *list)
Add default parameters for extraction.
moo_prepare_params * moo_params_get_prepare(const moo_params *self, const cpl_parameterlist *list)
Get remove prepare parameters from moons parameters list.
moo_wavesol_params * moo_params_get_wavesol(const moo_params *self, const cpl_parameterlist *list)
Get wavesol parameters from moons parameters list.
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.
cpl_error_code moo_params_add_crh(moo_params *self, cpl_parameterlist *list, const char *method)
Add default parameters for remove crh.
moo_extract_params * moo_params_get_extract(const moo_params *self, const cpl_parameterlist *list)
Get extraction parameters from moons parameters list.
void moo_params_delete(moo_params *self)
Delete a moo_params.
moo_crh_params * moo_params_get_crh(const moo_params *self, const cpl_parameterlist *list)
Get remove crh parameters from moons parameters list.
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_wavesol(moo_params *self, cpl_parameterlist *list)
Add default parameters for moo_wavesol.
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.
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_rbn_delete(moo_rbn *self)
Delete a moo_rbn.
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_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.
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_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.
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_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_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_map(moo_products *self, moo_map *map, cpl_frame_level level, const char *tag, const char *filename, const cpl_frame *inherit_frame, moo_rbn *rbn)
create a product from a EXT 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.