31#include "moo_params.h"
33#include "moo_products.h"
34#include "moo_flat_shift_compute.h"
35#include "moo_compute_slitoffset.h"
43int cpl_plugin_get_info(cpl_pluginlist *list);
49static int _moons_mflat_create(cpl_plugin *plugin);
50static int _moons_mflat_exec(cpl_plugin *plugin);
51static int _moons_mflat_destroy(cpl_plugin *plugin);
53_moons_mflat(cpl_frameset *frameset,
const cpl_parameterlist *parlist);
59static const char *
const _moons_mflat_description[2] = {
60 "This recipe aims at creating the products necessary to locate and extract "
62 " spectra and correct from flat-field signatures. It can be used in three"
63 " different flows\n\n"
64 "Workflow 1: Localises the spectra from scratch and creates the guess"
65 " localisation traces and widths\n"
67 " * RawList n1>=3 files (RAW) with tag FLAT : "
69 " * RawOffList n2==n1 files (RAW) with tag FLAT_OFF : "
71 " * [OPTIONAL] ReferenceBadPixMask 1 file (QUA) with tag BP_MAP_RP : "
72 "cosmetic bad pixel map\n"
73 " * MasterBias 1 file (DET) with tag MASTER_BIAS : "
75 " * [OPTIONAL] MasterDarkVis 1 file (DET) with tag "
77 "master dark vis file\n"
78 " * [OPTIONAL] MasterDarkNir 1 file (DET) with tag "
80 "master dark nir file\n"
82 " * FF_TRACE_GUESS_OFFSET[offset]_[insmode].fits (LOC) with tag "
84 "the localisation trace stores the Y centroid values of the spectra traces"
85 " and the width of the spectra in Y direction at each centroid position "
87 "Workflow 2: Localises the spectra and creates the localisation traces"
88 " and widths. Creates the master and extracted flat-fields, and "
89 "the fibre-to-fibre relative response. Updates the bad-pixel mask.\n"
91 " * RawList n1>=3 files (RAW) with tag FLAT : "
93 " * RawOffList n2==n1 files (RAW) with tag FLAT_OFF : "
95 " * [OPTIONAL] ReferenceBadPixMask 1 file (QUA) with tag BP_MAP_RP : "
96 "cosmetic bad pixel map\n"
97 " * [OPTIONAL] NonLinearityBadPixMask 1 file (QUA) with tag BP_MAP_NL : "
98 "non linearity bad pixel map coming from linearity recipe\n"
99 " * MasterBias 1 file (DET) with tag MASTER_BIAS : "
101 " * [OPTIONAL] MasterDarkVis 1 file (DET) with tag "
103 "master dark vis file\n"
104 " * [OPTIONAL] MasterDarkNir 1 file (DET) with tag "
106 "master dark nir file\n"
107 " * [OPTIONAL] LinCoeffsCube 1 file (3D) with tag "
108 "LINEARITY_COEFF_CUBE : "
109 "linearity coefficients coming from linearity recipe\n"
110 " * [OPTIONAL] P2pMap 1 file (DET) with tag P2P_MAP : "
111 "the pixel to pixel variation map \n"
112 " * FfTraceGuess 1 file (LOC) with tag "
114 "localisation trace produced in workflow 1\n"
116 " * FF_TRACE_OFFSET[offset]_[insmode].fits (LOC) with tag FF_TRACE : "
117 "the localisation trace stores the Y centroid values of the spectra traces"
118 " and the width of the spectra in Y direction at each centroid position\n"
119 " * FF_EXTSPECTRA_OFFSET[offset]_[insmode].fits (EXT) with tag "
120 "FF_FF_EXTSPECTRA : "
121 "extracted flat-fields\n"
122 " * F2F_OFFSET[offset]_[insmode].fits (F2F) with tag F2F_TABLE "
124 "the fibre-to-fibre relative response\n"
125 "[if --extract-method==OPTIMAL]\n"
126 " * MASTER_FLAT_OFFSET[offset]_[insmode].fits (PSF) with tag "
128 "the master normalized flat product for given position\n"
130 "Workflow 3: Localises the spectra and creates the localisation traces"
131 " and widths. Creates the master and extracted flat-fields,"
132 " the pixel-to-pixel variation map and the fibre-to-fibre relative "
134 " Updates the bad-pixel mask\n"
136 " * RawList n1>=3 files (RAW) with tag FLAT : "
137 "flat files at offset 0\n"
138 " * RawList n2>=3 files (RAW) with tag FLAT : "
139 "flat files at offset 1\n"
140 " * RawOffList n2+n1 files (RAW) with tag FLAT_OFF : "
142 " * [OPTIONAL] ReferenceBadPixMask 1 file (QUA) with tag BP_MAP_RP : "
143 "cosmetic bad pixel map\n"
144 " * [OPTIONAL] NonLinearityBadPixMask 1 file (QUA) with tag BP_MAP_NL : "
145 "non linearity bad pixel map coming from linearity recipe\n"
146 " * MasterBias 1 file (DET) with tag MASTER_BIAS : "
148 " * [OPTIONAL] MasterDarkVis 1 file (DET) with tag "
150 "master dark vis file\n"
151 " * [OPTIONAL] MasterDarkNir 1 file (DET) with tag "
153 "master dark nir file\n"
154 " * [OPTIONAL] LinCoeffsCube1 1 file (3D) with tag "
155 "LINEARITY_COEFF_CUBE : "
156 "linearity coefficients coming from linearity recipe at offset 0\n"
157 " * [OPTIONAL] LinCoeffsCube2 1 file (3D) with tag "
158 "LINEARITY_COEFF_CUBE : "
159 "linearity coefficients coming from linearity recipe at offset 1\n"
160 " * FfTraceGuess1 1 file (LOC) with tag "
162 "localisation trace produced in workflow 1 at offset 0\n"
163 " * FfTraceGuess2 1 file (LOC) with tag "
165 "localisation trace produced in workflow 1 at offset 1\n"
167 " * P2P_[insmode].fits (DET) with tag P2P_MAP : "
168 "the pixel to pixel variation map \n\n"
169 "Workflow 4: Compute shift in fibre-to-fibre relative response."
171 " * FlatAttached (RAW) with tag FLAT_ATTACHED "
174 " * RawOff (RAW) with tag FLAT_OFF : "
176 " * [OPTIONAL] ReferenceBadPixMask 1 file (QUA) with tag BP_MAP_RP : "
177 "cosmetic bad pixel map\n"
178 " * [OPTIONAL] NonLinearityBadPixMask 1 file (QUA) with tag BP_MAP_NL : "
179 "non linearity bad pixel map coming from linearity recipe\n"
180 " * MasterBias 1 file (DET) with tag MASTER_BIAS : "
182 " * [OPTIONAL] MasterDarkVis 1 file (DET) with tag "
184 "master dark vis file\n"
185 " * [OPTIONAL] MasterDarkNir 1 file (DET) with tag "
187 "master dark nir file\n"
188 " * [OPTIONAL] LinCoeffsCube 1 file (3D) with tag "
189 "LINEARITY_COEFF_CUBE : "
190 "linearity coefficients coming from linearity recipe\n"
191 " * FfTrace 1 file (LOC): "
192 "localisation trace produced in workflow 2\n"
194 " * F2F_OFFSET[offset]_[insmode].fits (F2F) with tag F2F_TABLE "
196 "the fibre-to-fibre relative response\n"
216cpl_plugin_get_info(cpl_pluginlist *list)
218 cpl_recipe *recipe = cpl_calloc(1,
sizeof *recipe);
219 cpl_plugin *plugin = &recipe->interface;
221 cpl_size sz[2] = { strlen(_moons_mflat_description[0]),
222 strlen(_moons_mflat_description[1]) };
223 char *description = cpl_calloc(
sizeof(
char), sz[0] + sz[1] + 1);
227 for (idx = 0; idx < 2; ++idx) {
228 strncpy(&description[offset], _moons_mflat_description[idx], sz[idx]);
232 if (cpl_plugin_init(plugin, CPL_PLUGIN_API, MOONS_BINARY_VERSION,
233 CPL_PLUGIN_TYPE_RECIPE,
"moons_mflat",
234 "Create a master flat product", description,
236 _moons_mflat_create, _moons_mflat_exec,
237 _moons_mflat_destroy)) {
238 cpl_free(description);
239 cpl_msg_error(cpl_func,
"Plugin initialization failed");
240 (void)cpl_error_set_where(cpl_func);
243 cpl_free(description);
245 if (cpl_pluginlist_append(list, plugin)) {
246 cpl_msg_error(cpl_func,
"Error adding plugin to list");
247 (void)cpl_error_set_where(cpl_func);
266_moons_mflat_create(cpl_plugin *plugin)
271 if (cpl_error_get_code() != CPL_ERROR_NONE) {
272 cpl_msg_error(cpl_func,
"%s():%d: An error is already set: %s",
273 cpl_func, __LINE__, cpl_error_get_where());
274 return (
int)cpl_error_get_code();
277 if (plugin == NULL) {
278 cpl_msg_error(cpl_func,
"Null plugin");
279 cpl_ensure_code(0, (
int)CPL_ERROR_NULL_INPUT);
283 if (cpl_plugin_get_type(plugin) != CPL_PLUGIN_TYPE_RECIPE) {
284 cpl_msg_error(cpl_func,
"Plugin is not a recipe");
285 cpl_ensure_code(0, (
int)CPL_ERROR_TYPE_MISMATCH);
289 recipe = (cpl_recipe *)plugin;
292 recipe->parameters = cpl_parameterlist_new();
293 if (recipe->parameters == NULL) {
294 cpl_msg_error(cpl_func,
"Parameter list allocation failed");
295 cpl_ensure_code(0, (
int)CPL_ERROR_ILLEGAL_OUTPUT);
304 MOO_CORRECT_BIAS_METHOD_MASTER);
326_moons_mflat_exec(cpl_plugin *plugin)
330 cpl_errorstate initial_errorstate = cpl_errorstate_get();
333 if (cpl_error_get_code() != CPL_ERROR_NONE) {
334 cpl_msg_error(cpl_func,
"%s():%d: An error is already set: %s",
335 cpl_func, __LINE__, cpl_error_get_where());
336 return (
int)cpl_error_get_code();
339 if (plugin == NULL) {
340 cpl_msg_error(cpl_func,
"Null plugin");
341 cpl_ensure_code(0, (
int)CPL_ERROR_NULL_INPUT);
345 if (cpl_plugin_get_type(plugin) != CPL_PLUGIN_TYPE_RECIPE) {
346 cpl_msg_error(cpl_func,
"Plugin is not a recipe");
347 cpl_ensure_code(0, (
int)CPL_ERROR_TYPE_MISMATCH);
351 recipe = (cpl_recipe *)plugin;
354 if (recipe->parameters == NULL) {
355 cpl_msg_error(cpl_func,
"Recipe invoked with NULL parameter list");
356 cpl_ensure_code(0, (
int)CPL_ERROR_NULL_INPUT);
358 if (recipe->frames == NULL) {
359 cpl_msg_error(cpl_func,
"Recipe invoked with NULL frame set");
360 cpl_ensure_code(0, (
int)CPL_ERROR_NULL_INPUT);
364 recipe_status = _moons_mflat(recipe->frames, recipe->parameters);
367 if (cpl_dfs_update_product_header(recipe->frames)) {
369 recipe_status = (int)cpl_error_get_code();
372 if (!cpl_errorstate_is_equal(initial_errorstate)) {
375 cpl_errorstate_dump(initial_errorstate, CPL_FALSE, NULL);
378 return recipe_status;
391_moons_mflat_destroy(cpl_plugin *plugin)
395 if (plugin == NULL) {
396 cpl_msg_error(cpl_func,
"Null plugin");
397 cpl_ensure_code(0, (
int)CPL_ERROR_NULL_INPUT);
401 if (cpl_plugin_get_type(plugin) != CPL_PLUGIN_TYPE_RECIPE) {
402 cpl_msg_error(cpl_func,
"Plugin is not a recipe");
403 cpl_ensure_code(0, (
int)CPL_ERROR_TYPE_MISMATCH);
407 recipe = (cpl_recipe *)plugin;
409 cpl_parameterlist_delete(recipe->parameters);
434_moons_prepare(moo_products *products,
435 const cpl_frame *frame,
436 const cpl_frame *frame_off,
437 const char *bpmap_rp_name,
438 const char *bpmap_nl_name,
439 const cpl_frame *masterbias,
440 const cpl_frame *masterdark_vis,
441 const cpl_frame *masterdark_nir,
442 const cpl_frame *coeffs_cube,
443 moo_prepare_params *prepare_params,
444 moo_correct_bias_params *params,
449 cpl_frame *result = NULL;
450 cpl_frame *pframe = NULL;
451 char *detname1 = NULL;
452 char *detname2 = NULL;
453 char *detname3 = NULL;
455 moo_det *detoff = NULL;
457 cpl_ensure(frame != NULL, CPL_ERROR_NULL_INPUT, NULL);
458 cpl_ensure(frame_off != NULL, CPL_ERROR_NULL_INPUT, NULL);
459 cpl_errorstate prestate = cpl_errorstate_get();
461 moo_try_check(det =
moo_prepare(frame, bpmap_rp_name, bpmap_nl_name,
462 masterbias, coeffs_cube, prepare_params),
467 moo_try_check(detname1 = cpl_sprintf(
"%s_OFFSET%d_%s_%d.fits",
468 MOONS_TAG_FLAT_CORRECTBIAS, offset,
472 MOONS_TAG_FLAT_CORRECTBIAS, detname1, frame),
475 moo_try_check(detname2 = cpl_sprintf(
"%s_OFFSET%d_%s_%d.fits",
476 MOONS_TAG_FLATOFF_PREPARE, offset,
480 moo_try_check(detoff =
moo_prepare(frame_off, bpmap_rp_name, bpmap_nl_name,
481 masterbias, coeffs_cube, prepare_params),
485 CPL_FRAME_LEVEL_INTERMEDIATE,
486 MOONS_TAG_FLATOFF_PREPARE, detname2,
490 moo_try_check(
moo_correct_dark(det, detoff, masterdark_vis, masterdark_nir),
492 moo_try_check(detname3 = cpl_sprintf(
"%s_OFFSET%d_%s_%d.fits",
493 MOONS_TAG_FLAT_CORRECTDARK, offset,
497 CPL_FRAME_LEVEL_INTERMEDIATE,
498 MOONS_TAG_FLAT_CORRECTDARK,
502 moo_try_check(result = cpl_frame_duplicate(pframe),
" ");
505 if (!cpl_errorstate_is_equal(prestate)) {
506 cpl_frame_delete(result);
535_moons_prepare_set(cpl_frameset *raw_frames,
536 cpl_frameset *rawoff_frames,
537 const char *bpmap_rp_name,
538 const char *bpmap_nl_name,
539 const cpl_frame *masterbias,
540 const cpl_frame *masterdark_vis,
541 const cpl_frame *masterdark_nir,
542 const cpl_frame *coeffs_cube,
543 moo_prepare_params *prepare_params,
544 moo_correct_bias_params *params,
545 moo_products *products,
549 cpl_frameset *detframes = NULL;
551 moo_det *detoff = NULL;
553 cpl_ensure(raw_frames, CPL_ERROR_NULL_INPUT, NULL);
554 cpl_ensure(rawoff_frames, CPL_ERROR_NULL_INPUT, NULL);
555 cpl_ensure(products, CPL_ERROR_NULL_INPUT, NULL);
557 cpl_errorstate prestate = cpl_errorstate_get();
559 moo_try_check(detframes = cpl_frameset_new(),
" ");
563 for (i = 0; i < cpl_frameset_get_size(raw_frames); ++i) {
564 const cpl_frame *current_frame = NULL;
565 const cpl_frame *raw_off = NULL;
566 cpl_frame *pframe = NULL;
568 moo_try_check(current_frame =
569 cpl_frameset_get_position_const(raw_frames, i),
571 moo_try_check(raw_off =
572 cpl_frameset_get_position_const(rawoff_frames, i),
575 moo_try_check(pframe = _moons_prepare(products, current_frame, raw_off,
576 bpmap_rp_name, bpmap_nl_name,
577 masterbias, masterdark_vis,
578 masterdark_nir, coeffs_cube,
579 prepare_params, params, i, mode,
582 moo_try_check(cpl_frameset_insert(detframes, pframe),
" ");
586 if (!cpl_errorstate_is_equal(prestate)) {
589 cpl_frameset_delete(detframes);
607_moons_flat_check_header(
const cpl_frame *raw,
const cpl_frame *ff_trace)
609 cpl_ensure_code(raw != NULL, CPL_ERROR_NULL_INPUT);
610 cpl_ensure_code(ff_trace != NULL, CPL_ERROR_NULL_INPUT);
611 cpl_error_code status = CPL_ERROR_NONE;
612 const char *filename = NULL;
613 const char *trace_filename = NULL;
614 cpl_propertylist *raw_pheader = NULL;
615 cpl_propertylist *trace_pheader = NULL;
616 int raw_offset, trace_offset;
618 cpl_errorstate prestate = cpl_errorstate_get();
619 moo_try_check(filename = cpl_frame_get_filename(raw),
" ");
620 moo_try_check(trace_filename = cpl_frame_get_filename(ff_trace),
" ");
622 moo_try_check(raw_pheader = cpl_propertylist_load(filename, 0),
" ");
623 moo_try_check(trace_pheader = cpl_propertylist_load(trace_filename, 0),
629 if (raw_offset != trace_offset) {
630 cpl_msg_error(
"check_header",
631 "OFFSET keyword mismatch between FLAT file %s value %d "
632 "and FF_TRACE file %s value %d",
633 filename, raw_offset, trace_filename, trace_offset);
634 status = CPL_ERROR_ILLEGAL_INPUT;
635 cpl_error_set(
"check_header", status);
639 if (!cpl_errorstate_is_equal(prestate)) {
640 status = cpl_error_get_code();
642 cpl_propertylist_delete(raw_pheader);
643 cpl_propertylist_delete(trace_pheader);
666_moons_mflat_localise(cpl_frameset *raw_frames,
667 cpl_frameset *rawoff_frames,
668 const char *bpmap_rp_name,
669 const char *bpmap_nl_name,
670 const cpl_frame *masterbias,
671 const cpl_frame *masterdark_vis,
672 const cpl_frame *masterdark_nir,
673 const cpl_frame *coeffs_cube,
674 const cpl_frame *p2pmap,
675 const cpl_frame *ff_trace_guess,
676 moo_prepare_params *prepare_params,
677 moo_crh_params *crh_params,
678 moo_compute_slitoffset_params *compute_slitoffset_params,
679 moo_localise_params *localise_params,
680 moo_model_flat_params *modelflat_params,
681 moo_correct_bias_params *cbias_params,
684 moo_products *products,
687 const cpl_frame **ref_frame,
690 cpl_frame_level level)
693 cpl_frameset *detframes = NULL;
694 moo_detlist *detList = NULL;
695 char *locname = NULL;
696 char *flatname = NULL;
697 char *flatp2p_name = NULL;
700 cpl_ensure(loctag != NULL, CPL_ERROR_NULL_INPUT, NULL);
701 cpl_ensure(raw_frames != NULL, CPL_ERROR_NULL_INPUT, NULL);
702 cpl_ensure(rawoff_frames != NULL, CPL_ERROR_NULL_INPUT, NULL);
704 cpl_errorstate prestate = cpl_errorstate_get();
708 moo_try_check(nraw = cpl_frameset_get_size(raw_frames),
" ");
709 moo_try_check(nraw_off = cpl_frameset_get_size(rawoff_frames),
" ");
712 cpl_error_set_message(cpl_func, CPL_ERROR_DATA_NOT_FOUND,
713 "SOF does not have any file tagged "
720 cpl_msg_warning(cpl_func,
721 "SOF does not have enough files (%d<3) tagged "
723 nraw, MOONS_TAG_FLAT);
726 if (nraw_off != nraw) {
727 cpl_error_set_message(cpl_func, CPL_ERROR_DATA_NOT_FOUND,
728 "SOF does not have %d files tagged "
730 nraw, MOONS_TAG_FLAT_OFF);
734 if (masterbias == NULL) {
735 cpl_error_set_message(cpl_func, CPL_ERROR_DATA_NOT_FOUND,
736 "SOF does not have any file tagged "
738 MOONS_TAG_MASTER_BIAS);
742 if (ff_trace_guess != NULL) {
743 moo_try_check(_moons_flat_check_header(
744 cpl_frameset_get_position_const(raw_frames, 0),
749 moo_try_check(*ref_frame = cpl_frameset_get_position_const(raw_frames, 0),
755 moo_try_check(detframes = _moons_prepare_set(raw_frames, rawoff_frames,
756 bpmap_rp_name, bpmap_nl_name,
757 masterbias, masterdark_vis,
758 masterdark_nir, coeffs_cube,
759 prepare_params, cbias_params,
760 products, *mode, *offset),
764 moo_try_check(*medflat =
moo_remove_CRH(detList, NULL, crh_params),
" ");
765 moo_try_check(flatname = cpl_sprintf(
"%s_OFFSET%d_%s.fits",
766 MOONS_TAG_FLAT_REMOVECRH, (
int)*offset,
771 CPL_FRAME_LEVEL_INTERMEDIATE,
772 MOONS_TAG_FLAT_REMOVECRH, flatname,
776 if (p2pmap != NULL) {
780 cpl_sprintf(
"%s_OFFSET%d_%s.fits", MOONS_TAG_FLAT_APPLYP2P,
783 MOONS_TAG_FLAT_APPLYP2P, flatp2p_name, *ref_frame);
787 if (ff_trace_guess != NULL) {
791 for (
int i = 0; i < 6; i++) {
792 cpl_msg_info(
"test",
"Offsets[%d]=%f", i, offsets[i]);
797 moo_try_check(locname = cpl_sprintf(
"%s_OFFSET%d_%s.fits", loctag,
800 moo_try_check(loc =
moo_localise(*medflat, ff_trace_guess, localise_params,
805 localise_params->keep_points, level,
806 loctag, locname, *ref_frame),
811 cpl_sprintf(
"%s_OFFSET%d_%s.fits", MOONS_TAG_MASTER_FLAT,
814 moo_products_add_psf(products, *psf, level, MOONS_TAG_MASTER_FLAT,
815 psfname, *ref_frame);
820 cpl_frameset_delete(detframes);
823 cpl_free(flatp2p_name);
825 if (!cpl_errorstate_is_equal(prestate)) {
835_moons_mflat_fibtrans(moo_det *medflat,
838 moo_extract_params *extract_params,
839 moo_compute_fibtrans_params *fibtrans_params,
840 moo_products *products,
841 const cpl_frame *ref_frame,
847 char *flatname = NULL;
848 char *extname = NULL;
850 char *f2fname = NULL;
852 cpl_ensure_code(medflat != NULL, CPL_ERROR_NULL_INPUT);
853 cpl_msg_info(
"moons_mflat",
"Work on offset %d mode %s", (
int)offset,
856 extname = cpl_sprintf(
"%s_OFFSET%d_%s.fits", MOONS_TAG_FLAT_EXTSPECTRA,
859 moo_try_check(ext =
moo_extract(medflat, ff_trace, psf, extract_params,
863 MOONS_TAG_FLAT_EXTSPECTRA, extname, ref_frame);
866 ffname = cpl_sprintf(
"%s_OFFSET%d_%s.fits", MOONS_TAG_FF_EXTSPECTRA,
868 f2fname = cpl_sprintf(
"%s_OFFSET%d_%s.fits", MOONS_TAG_F2F_TABLE,
874 MOONS_TAG_FF_EXTSPECTRA, ffname, ref_frame);
875 moo_products_add_f2f(products, f2f, CPL_FRAME_LEVEL_FINAL,
876 MOONS_TAG_F2F_TABLE, f2fname, ref_frame);
887 return CPL_ERROR_NONE;
912_moons_mflat_wf1(cpl_frameset **raw_byoffset_set,
913 cpl_frameset *rawoff_frames,
914 const char *bpmap_rp_name,
915 const char *bpmap_nl_name,
916 const cpl_frame *masterbias,
917 const cpl_frame *masterdark_vis,
918 const cpl_frame *masterdark_nir,
919 const cpl_frame *coeffs_cube,
920 moo_prepare_params *prepare_params,
921 moo_crh_params *crh_params,
922 moo_localise_params *localise_params,
923 moo_correct_bias_params *cbias_params,
924 moo_products *products)
926 cpl_ensure_code(raw_byoffset_set != NULL, CPL_ERROR_NULL_INPUT);
927 cpl_ensure_code(raw_byoffset_set[0] != NULL, CPL_ERROR_NULL_INPUT);
928 cpl_ensure_code(raw_byoffset_set[1] != NULL, CPL_ERROR_NULL_INPUT);
932 cpl_frameset *raw_frames = NULL;
933 const cpl_frame *ref_frame = NULL;
934 moo_det *medflat = NULL;
935 moo_loc *guess_loc = NULL;
938 moo_try_check(size1 = cpl_frameset_get_size(raw_byoffset_set[0]),
" ");
939 moo_try_check(size2 = cpl_frameset_get_size(raw_byoffset_set[1]),
" ");
945 cpl_error_set_message(cpl_func, CPL_ERROR_ILLEGAL_INPUT,
946 "SOF have two different offset in input");
948 raw_frames = raw_byoffset_set[0];
951 raw_frames = raw_byoffset_set[1];
953 moo_try_assure(cpl_frameset_get_size(raw_frames) > 0,
954 CPL_ERROR_ILLEGAL_INPUT,
"No FLAT frames in input");
955 moo_try_check(guess_loc = _moons_mflat_localise(
956 raw_frames, rawoff_frames, bpmap_rp_name, bpmap_nl_name,
957 masterbias, masterdark_vis, masterdark_nir, coeffs_cube,
958 NULL, NULL, prepare_params, crh_params, NULL,
959 localise_params, NULL, cbias_params, 0,
960 MOONS_TAG_FF_TRACE_GUESS, products, &medflat, NULL,
961 &ref_frame, &offset, &mode, CPL_FRAME_LEVEL_FINAL),
967 return CPL_ERROR_NONE;
992_moons_mflat_wf4(
const cpl_frame *flat_attached_frame,
993 const cpl_frame *flat_off_frame,
994 const char *bpmap_rp_name,
995 const char *bpmap_nl_name,
996 const cpl_frame *masterbias,
997 const cpl_frame *masterdark_vis,
998 const cpl_frame *masterdark_nir,
999 const cpl_frame *coeffs_cube,
1000 const cpl_frame *ff_trace_frame,
1001 const cpl_frame *p2pmap,
1002 const cpl_frame *master_flat,
1003 moo_prepare_params *prepare_params,
1004 moo_extract_params *extract_params,
1005 moo_compute_fibtrans_params *fibtrans_params,
1006 moo_correct_bias_params *cbias_params,
1007 moo_products *products)
1009 cpl_ensure_code(flat_attached_frame != NULL, CPL_ERROR_NULL_INPUT);
1010 cpl_ensure_code(flat_off_frame != NULL, CPL_ERROR_NULL_INPUT);
1011 cpl_ensure_code(ff_trace_frame != NULL, CPL_ERROR_NULL_INPUT);
1013 moo_loc *ff_trace = NULL;
1016 char *detname1 = NULL;
1017 char *detname2 = NULL;
1018 char *detname3 = NULL;
1019 moo_det *det = NULL;
1020 moo_det *detoff = NULL;
1021 moo_f2f *f2f = NULL;
1022 moo_ext *ext = NULL;
1023 char *flatname = NULL;
1024 char *extname = NULL;
1025 char *f2fname = NULL;
1026 moo_det *p2p = NULL;
1027 moo_psf *psf = NULL;
1029 cpl_errorstate prestate = cpl_errorstate_get();
1031 if (masterbias == NULL) {
1032 cpl_error_set_message(cpl_func, CPL_ERROR_DATA_NOT_FOUND,
1033 "SOF does not have any file tagged "
1035 MOONS_TAG_MASTER_BIAS);
1036 return CPL_ERROR_NONE;
1039 if (ff_trace_frame != NULL) {
1040 moo_try_check(_moons_flat_check_header(flat_attached_frame,
1042 " Mismatch header");
1045 moo_try_check(mode =
moo_mode_get(flat_attached_frame),
" ");
1046 moo_try_check(offset =
moo_offset_get(flat_attached_frame),
" ");
1047 moo_try_check(det =
moo_prepare(flat_attached_frame, bpmap_rp_name,
1048 bpmap_nl_name, masterbias, coeffs_cube,
1052 moo_try_check(detoff =
1053 moo_prepare(flat_off_frame, bpmap_rp_name, bpmap_nl_name,
1054 masterbias, coeffs_cube, prepare_params),
1058 moo_try_check(detname1 = cpl_sprintf(
"%s_OFFSET%d_%s.fits",
1059 MOONS_TAG_FLAT_CORRECTBIAS, offset,
1062 moo_try_check(
moo_products_add(products, det, CPL_FRAME_LEVEL_INTERMEDIATE,
1063 MOONS_TAG_FLAT_CORRECTBIAS, detname1,
1064 flat_attached_frame),
1067 moo_try_check(detname2 = cpl_sprintf(
"%s_OFFSET%d_%s.fits",
1068 MOONS_TAG_FLATOFF_PREPARE, offset,
1073 CPL_FRAME_LEVEL_INTERMEDIATE,
1074 MOONS_TAG_FLATOFF_PREPARE, detname2,
1078 moo_try_check(
moo_correct_dark(det, detoff, masterdark_vis, masterdark_nir),
1080 moo_try_check(detname3 = cpl_sprintf(
"%s_OFFSET%d_%s.fits",
1081 MOONS_TAG_FLAT_CORRECTDARK, offset,
1084 moo_try_check(
moo_products_add(products, det, CPL_FRAME_LEVEL_INTERMEDIATE,
1085 MOONS_TAG_FLAT_CORRECTDARK, detname3,
1086 flat_attached_frame),
1089 if (p2pmap != NULL) {
1092 flatname = cpl_sprintf(
"%s_OFFSET%d_%s.fits", MOONS_TAG_FLAT_APPLYP2P,
1095 MOONS_TAG_FLAT_APPLYP2P, flatname,
1096 flat_attached_frame);
1105 moo_try_check(ff_trace =
moo_loc_load(ff_trace_frame),
" ");
1107 if (master_flat != NULL) {
1111 moo_extract(det, ff_trace, psf, extract_params, extname),
1115 extname, flat_attached_frame);
1123 moo_products_add_f2f(products, f2f, CPL_FRAME_LEVEL_FINAL,
1124 MOONS_TAG_F2F_TABLE, f2fname, flat_attached_frame);
1133 if (!cpl_errorstate_is_equal(prestate)) {
1144 return CPL_ERROR_NONE;
1173_moons_mflat_wf2(cpl_frameset **raw_byoffset_set,
1174 cpl_frameset *rawoff_frames,
1175 const char *bpmap_rp_name,
1176 const char *bpmap_nl_name,
1177 const cpl_frame *masterbias,
1178 const cpl_frame *masterdark_vis,
1179 const cpl_frame *masterdark_nir,
1180 const cpl_frame *coeffs_cube,
1181 const cpl_frame *ff_trace_guess,
1182 const cpl_frame *p2pmap,
1183 moo_prepare_params *prepare_params,
1184 moo_crh_params *crh_params,
1185 moo_localise_params *localise_params,
1186 moo_compute_slitoffset_params *compute_slitoffset_params,
1187 moo_extract_params *extract_params,
1188 moo_model_flat_params *modelflat_params,
1189 moo_compute_fibtrans_params *fibtrans_params,
1190 moo_correct_bias_params *cbias_params,
1191 moo_products *products)
1193 cpl_ensure_code(raw_byoffset_set != NULL, CPL_ERROR_NULL_INPUT);
1194 cpl_ensure_code(raw_byoffset_set[0] != NULL, CPL_ERROR_NULL_INPUT);
1195 cpl_ensure_code(raw_byoffset_set[1] != NULL, CPL_ERROR_NULL_INPUT);
1198 (strcmp(extract_params->method, MOO_EXTRACT_METHOD_OPTIMAL) == 0);
1200 const cpl_frame *ref_frame = NULL;
1201 cpl_frameset *raw_frames = NULL;
1202 moo_det *medflat = NULL;
1203 moo_loc *ff_trace = NULL;
1204 moo_psf *psf = NULL;
1210 moo_try_check(size1 = cpl_frameset_get_size(raw_byoffset_set[0]),
" ");
1211 moo_try_check(size2 = cpl_frameset_get_size(raw_byoffset_set[1]),
" ");
1215 return (
int)cpl_error_set_message(
1216 cpl_func, CPL_ERROR_ILLEGAL_INPUT,
1217 "SOF have two different offset in input ");
1219 raw_frames = raw_byoffset_set[0];
1222 raw_frames = raw_byoffset_set[1];
1225 moo_try_assure(cpl_frameset_get_size(raw_frames) > 0,
1226 CPL_ERROR_ILLEGAL_INPUT,
"No FLAT frames in input");
1229 moo_try_check(ff_trace = _moons_mflat_localise(
1230 raw_frames, rawoff_frames, bpmap_rp_name, bpmap_nl_name,
1231 masterbias, masterdark_vis, masterdark_nir, coeffs_cube,
1232 p2pmap, ff_trace_guess, prepare_params, crh_params,
1233 compute_slitoffset_params, localise_params,
1234 modelflat_params, cbias_params, domodel,
1235 MOONS_TAG_FF_TRACE, products, &medflat, &psf, &ref_frame,
1236 &offset, &mode, CPL_FRAME_LEVEL_FINAL),
1239 moo_try_check(_moons_mflat_fibtrans(medflat, ff_trace, psf, extract_params,
1240 fibtrans_params, products, ref_frame,
1249 return CPL_ERROR_NONE;
1253_moons_mflat_wf3(cpl_frameset **raw_byoffset_set,
1254 cpl_frameset *rawoff_frames,
1255 const char *bpmap_rp_name,
1256 const char *bpmap_nl_name,
1257 const cpl_frame *masterbias,
1258 const cpl_frame *masterdark_vis,
1259 const cpl_frame *masterdark_nir,
1260 cpl_frameset **cube_set,
1261 cpl_frameset **ff_trace_set,
1262 moo_prepare_params *prepare_params,
1263 moo_crh_params *crh_params,
1264 moo_compute_slitoffset_params *compute_slitoffset_params,
1265 moo_localise_params *localise_params,
1266 moo_model_flat_params *modelflat_params,
1267 moo_correct_bias_params *cbias_params,
1268 moo_products *products)
1270 moo_det *medflat1 = NULL;
1271 moo_loc *ff_trace1 = NULL;
1274 moo_psf *psf1 = NULL;
1275 const cpl_frame *coeffs_cube1 = NULL;
1276 const cpl_frame *coeffs_cube2 = NULL;
1277 const cpl_frame *ref_frame2 = NULL;
1279 moo_det *medflat2 = NULL;
1280 moo_loc *ff_trace2 = NULL;
1282 moo_psf *psf2 = NULL;
1283 moo_det *p2p = NULL;
1284 char *p2pname = NULL;
1286 int sff_trace1 = cpl_frameset_get_size(ff_trace_set[0]);
1287 int sff_trace2 = cpl_frameset_get_size(ff_trace_set[1]);
1289 cpl_ensure_code(sff_trace1 == 1, CPL_ERROR_ILLEGAL_INPUT);
1290 cpl_ensure_code(sff_trace2 == 1, CPL_ERROR_ILLEGAL_INPUT);
1292 const cpl_frame *ref_frame1 = NULL;
1293 cpl_frameset *raw_frames1 = raw_byoffset_set[0];
1294 const cpl_frame *ff_trace_guess1 =
1295 cpl_frameset_get_position_const(ff_trace_set[0], 0);
1296 cpl_frameset *raw_frames2 = raw_byoffset_set[1];
1297 int csize1 = cpl_frameset_get_size(cube_set[0]);
1298 int csize2 = cpl_frameset_get_size(cube_set[1]);
1300 coeffs_cube1 = cpl_frameset_get_position_const(cube_set[0], 0);
1303 coeffs_cube2 = cpl_frameset_get_position_const(cube_set[1], 0);
1306 const cpl_frame *ff_trace_guess2 =
1307 cpl_frameset_get_position_const(ff_trace_set[1], 0);
1308 moo_try_check(ff_trace1 = _moons_mflat_localise(
1309 raw_frames1, rawoff_frames, bpmap_rp_name, bpmap_nl_name,
1310 masterbias, masterdark_vis, masterdark_nir, coeffs_cube1,
1311 NULL, ff_trace_guess1, prepare_params, crh_params,
1312 compute_slitoffset_params, localise_params,
1313 modelflat_params, cbias_params, 1, MOONS_TAG_FF_TRACE,
1314 products, &medflat1, &psf1, &ref_frame1, &offset1, &mode,
1315 CPL_FRAME_LEVEL_INTERMEDIATE),
1316 "Can't localise offset1");
1318 moo_try_check(ff_trace2 = _moons_mflat_localise(
1319 raw_frames2, rawoff_frames, bpmap_rp_name, bpmap_nl_name,
1320 masterbias, masterdark_vis, masterdark_nir, coeffs_cube2,
1321 NULL, ff_trace_guess2, prepare_params, crh_params,
1322 compute_slitoffset_params, localise_params,
1323 modelflat_params, cbias_params, 1, MOONS_TAG_FF_TRACE,
1324 products, &medflat2, &psf2, &ref_frame2, &offset2, &mode,
1325 CPL_FRAME_LEVEL_INTERMEDIATE),
1326 "Can't localise offset 2");
1328 moo_try_check(p2p =
moo_compute_p2p(medflat1, ff_trace1, psf1, medflat2,
1330 "can't compute P2P");
1332 moo_try_check(p2pname = cpl_sprintf(
"%s_%s.fits", MOONS_TAG_P2P_MAP,
1337 p2pname, ref_frame1);
1349 return CPL_ERROR_NONE;
1370static cpl_error_code
1371_moons_mflat_check_sof(cpl_frameset *frameset,
1372 cpl_frameset **ff_trace_guess_frames,
1373 cpl_frameset **raw_frames,
1374 const cpl_frame **flat_attached,
1375 const cpl_frame **ff_trace,
1376 const cpl_frame **master_flat,
1377 cpl_frameset **rawoff_frames,
1378 const char **bpmap_rp_name,
1379 const char **bpmap_nl_name,
1380 const cpl_frame **master_bias,
1381 const cpl_frame **master_dark_vis,
1382 const cpl_frame **master_dark_nir,
1383 cpl_frameset **coeffs_cube_frames,
1384 const cpl_frame **p2pmap)
1386 cpl_errorstate prestate = cpl_errorstate_get();
1388 cpl_ensure_code(frameset != NULL, CPL_ERROR_NULL_INPUT);
1389 cpl_ensure_code(ff_trace_guess_frames != NULL, CPL_ERROR_NULL_INPUT);
1390 cpl_ensure_code(raw_frames != NULL, CPL_ERROR_NULL_INPUT);
1391 cpl_ensure_code(rawoff_frames != NULL, CPL_ERROR_NULL_INPUT);
1393 cpl_error_get_code());
1395 moo_try_check(*ff_trace_guess_frames = cpl_frameset_new(),
" ");
1396 moo_try_check(*coeffs_cube_frames = cpl_frameset_new(),
" ");
1397 moo_try_check(*raw_frames = cpl_frameset_new(),
" ");
1398 moo_try_check(*rawoff_frames = cpl_frameset_new(),
" ");
1401 moo_try_check(size = cpl_frameset_get_size(frameset),
" ");
1403 for (
int i = 0; i < size; ++i) {
1404 const cpl_frame *current_frame = NULL;
1406 moo_try_check(current_frame =
1407 cpl_frameset_get_position_const(frameset, i),
1410 if (!strcmp(cpl_frame_get_tag(current_frame), MOONS_TAG_FLAT)) {
1411 moo_try_check(cpl_frameset_insert(*raw_frames, cpl_frame_duplicate(
1415 else if (!strcmp(cpl_frame_get_tag(current_frame),
1416 MOONS_TAG_FLAT_ATTACHED)) {
1417 *flat_attached = current_frame;
1419 else if (!strcmp(cpl_frame_get_tag(current_frame),
1420 MOONS_TAG_FLAT_OFF)) {
1421 moo_try_check(cpl_frameset_insert(*rawoff_frames,
1422 cpl_frame_duplicate(
1426 else if (!strcmp(cpl_frame_get_tag(current_frame),
1427 MOONS_TAG_BP_MAP_RP)) {
1428 moo_try_check(*bpmap_rp_name =
1429 cpl_frame_get_filename(current_frame),
1432 else if (!strcmp(cpl_frame_get_tag(current_frame),
1433 MOONS_TAG_BP_MAP_NL)) {
1434 moo_try_check(*bpmap_nl_name =
1435 cpl_frame_get_filename(current_frame),
1438 else if (!strcmp(cpl_frame_get_tag(current_frame),
1439 MOONS_TAG_MASTER_BIAS)) {
1440 *master_bias = current_frame;
1442 else if (!strcmp(cpl_frame_get_tag(current_frame),
1443 MOONS_TAG_MASTER_DARK_VIS)) {
1444 *master_dark_vis = current_frame;
1446 else if (!strcmp(cpl_frame_get_tag(current_frame),
1447 MOONS_TAG_MASTER_DARK_NIR)) {
1448 *master_dark_nir = current_frame;
1450 else if (!strcmp(cpl_frame_get_tag(current_frame), MOONS_TAG_P2P_MAP)) {
1451 *p2pmap = current_frame;
1453 else if (!strcmp(cpl_frame_get_tag(current_frame),
1454 MOONS_TAG_FF_TRACE_GUESS)) {
1455 moo_try_check(cpl_frameset_insert(*ff_trace_guess_frames,
1456 cpl_frame_duplicate(
1460 else if (!strcmp(cpl_frame_get_tag(current_frame),
1461 MOONS_TAG_FF_TRACE)) {
1462 *ff_trace = current_frame;
1464 else if (!strcmp(cpl_frame_get_tag(current_frame),
1465 MOONS_TAG_MASTER_FLAT)) {
1466 *master_flat = current_frame;
1468 else if (!strcmp(cpl_frame_get_tag(current_frame),
1469 MOONS_TAG_LINEARITY_COEFF_CUBE)) {
1470 moo_try_check(cpl_frameset_insert(*coeffs_cube_frames,
1471 cpl_frame_duplicate(
1478 if (!cpl_errorstate_is_equal(prestate)) {
1479 cpl_frameset_delete(*ff_trace_guess_frames);
1480 cpl_frameset_delete(*raw_frames);
1481 cpl_frameset_delete(*rawoff_frames);
1482 *ff_trace_guess_frames = NULL;
1484 *rawoff_frames = NULL;
1486 return cpl_error_get_code();
1497_moons_mflat(cpl_frameset *frameset,
const cpl_parameterlist *parlist)
1500 moo_prepare_params *prepare_params = NULL;
1501 moo_correct_bias_params *correct_bias_params = NULL;
1502 moo_localise_params *localise_params = NULL;
1503 moo_crh_params *crh_params = NULL;
1504 moo_compute_slitoffset_params *compute_slitoffset_params = NULL;
1505 moo_extract_params *extract_params = NULL;
1506 moo_model_flat_params *model_flat_params = NULL;
1507 moo_compute_fibtrans_params *fibtrans_params = NULL;
1510 const char *bpmap_rp_name = NULL;
1511 const char *bpmap_nl_name = NULL;
1512 const cpl_frame *masterbias = NULL;
1513 const cpl_frame *masterdark_vis = NULL;
1514 const cpl_frame *masterdark_nir = NULL;
1515 const cpl_frame *p2pmap = NULL;
1516 cpl_frameset *coeffs_cube_frames = NULL;
1517 cpl_frameset *ff_trace_guess_frames = NULL;
1518 cpl_frameset *raw_frames = NULL;
1519 const cpl_frame *flat_attached = NULL;
1520 const cpl_frame *ff_trace = NULL;
1521 const cpl_frame *master_flat = NULL;
1522 cpl_frameset *rawoff_frames = NULL;
1523 cpl_frameset **raw_byoffset_set = NULL;
1525 moo_products *products =
moo_products_new(frameset, parlist,
"moons_mflat",
1526 PACKAGE
"/" PACKAGE_VERSION);
1533 moo_try_check(correct_bias_params =
1540 moo_try_check(compute_slitoffset_params =
1547 moo_try_check(model_flat_params =
1551 moo_try_check(fibtrans_params =
1556 moo_try_check(_moons_mflat_check_sof(frameset, &ff_trace_guess_frames,
1557 &raw_frames, &flat_attached, &ff_trace,
1558 &master_flat, &rawoff_frames,
1559 &bpmap_rp_name, &bpmap_nl_name,
1560 &masterbias, &masterdark_vis,
1561 &masterdark_nir, &coeffs_cube_frames,
1568 moo_try_check(csize = cpl_frameset_get_size(coeffs_cube_frames),
" ");
1569 moo_try_check(size = cpl_frameset_get_size(ff_trace_guess_frames),
" ");
1572 if (flat_attached != NULL) {
1573 cpl_msg_info(
"moons_mflat",
"Workflow 4 : create a F2F_TABLE");
1574 const cpl_frame *coeffs_cube = NULL;
1575 const cpl_frame *flat_off = NULL;
1577 moo_try_check(off_size = cpl_frameset_get_size(rawoff_frames),
" ");
1579 flat_off = cpl_frameset_get_position_const(rawoff_frames, 0);
1583 cpl_frameset_get_position_const(coeffs_cube_frames, 0);
1586 _moons_mflat_wf4(flat_attached, flat_off, bpmap_rp_name, bpmap_nl_name,
1587 masterbias, masterdark_vis, masterdark_nir,
1588 coeffs_cube, ff_trace, p2pmap, master_flat,
1589 prepare_params, extract_params, fibtrans_params,
1590 correct_bias_params, products);
1592 else if (size == 0) {
1593 cpl_msg_info(
"moons_mflat",
"Workflow 1 : create a FF_TRACE_GUESS");
1594 _moons_mflat_wf1(raw_byoffset_set, rawoff_frames, bpmap_rp_name,
1595 bpmap_nl_name, masterbias, masterdark_vis,
1596 masterdark_nir, NULL, prepare_params, crh_params,
1597 localise_params, correct_bias_params, products);
1599 else if (size == 1) {
1600 const cpl_frame *coeffs_cube = NULL;
1604 cpl_frameset_get_position_const(coeffs_cube_frames, 0);
1606 cpl_msg_info(
"moons_mflat",
"Workflow 2 : one offset reduction");
1607 const cpl_frame *ff_trace_guess =
1608 cpl_frameset_get_position_const(ff_trace_guess_frames, 0);
1609 _moons_mflat_wf2(raw_byoffset_set, rawoff_frames, bpmap_rp_name,
1610 bpmap_nl_name, masterbias, masterdark_vis,
1611 masterdark_nir, coeffs_cube, ff_trace_guess, p2pmap,
1612 prepare_params, crh_params, localise_params,
1613 compute_slitoffset_params, extract_params,
1614 model_flat_params, fibtrans_params,
1615 correct_bias_params, products);
1618 cpl_msg_info(
"moons_mflat",
"Workflow 3 : two offsets reduction");
1619 cpl_frameset **fftrace_byoffset_set =
1621 cpl_frameset **cube_byoffset_set =
1624 _moons_mflat_wf3(raw_byoffset_set, rawoff_frames, bpmap_rp_name,
1625 bpmap_nl_name, masterbias, masterdark_vis,
1626 masterdark_nir, cube_byoffset_set,
1627 fftrace_byoffset_set, prepare_params, crh_params,
1628 compute_slitoffset_params, localise_params,
1629 model_flat_params, correct_bias_params, products);
1630 for (
int i = 0; i < 2; i++) {
1631 cpl_frameset_delete(fftrace_byoffset_set[i]);
1633 cpl_free(fftrace_byoffset_set);
1635 for (
int i = 0; i < 2; i++) {
1636 cpl_frameset_delete(cube_byoffset_set[i]);
1638 cpl_free(cube_byoffset_set);
1642 if (raw_byoffset_set != NULL) {
1643 for (
int i = 0; i < 2; i++) {
1644 cpl_frameset_delete(raw_byoffset_set[i]);
1646 cpl_free(raw_byoffset_set);
1648 cpl_frameset_delete(raw_frames);
1649 cpl_frameset_delete(rawoff_frames);
1650 cpl_frameset_delete(coeffs_cube_frames);
1651 cpl_frameset_delete(ff_trace_guess_frames);
1652 moo_crh_params_delete(crh_params);
1653 moo_localise_params_delete(localise_params);
1654 moo_compute_slitoffset_params_delete(compute_slitoffset_params);
1655 moo_extract_params_delete(extract_params);
1656 moo_model_flat_params_delete(model_flat_params);
1657 moo_compute_fibtrans_params_delete(fibtrans_params);
1658 moo_prepare_params_delete(prepare_params);
1659 moo_correct_bias_params_delete(correct_bias_params);
1660 moo_products_delete(products);
1662 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.
int moo_offset_get(const cpl_frame *refframe)
Get the offset 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.
void moo_ext_delete(moo_ext *self)
Delete a moo_ext.
void moo_f2f_delete(moo_f2f *self)
Delete a moo_f2f.
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.
cpl_error_code moo_params_add_compute_fibtrans(moo_params *self, cpl_parameterlist *list)
Add default parameters for compute_fibtrans.
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_localise_params * moo_params_get_localise(const moo_params *self, const cpl_parameterlist *list)
Get localisation parameters from moons parameters list.
cpl_error_code moo_params_add_compute_slitoffset(moo_params *self, cpl_parameterlist *list)
Add default parameters for moo_sci_compute_slitoffset.
moo_compute_slitoffset_params * moo_params_get_compute_slitoffset(const moo_params *self, const cpl_parameterlist *list)
Get compute_slitoffset parameters from moons parameters list.
moo_model_flat_params * moo_params_get_model_flat(const moo_params *self, const cpl_parameterlist *list)
Get model flat parameters from moons parameters list.
moo_compute_fibtrans_params * moo_params_get_compute_fibtrans(const moo_params *self, const cpl_parameterlist *list)
Get compute fibtrans 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_localise(moo_params *self, cpl_parameterlist *list)
Add default parameters for localisation.
cpl_error_code moo_params_add_prepare(moo_params *self, cpl_parameterlist *list)
Add default parameters for prepare.
cpl_error_code moo_params_add_model_flat(moo_params *self, cpl_parameterlist *list)
Add default parameters for model flat.
moo_params * moo_params_new(const char *pid, const char *recipe_id)
Create a new moo_params.
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.
cpl_error_code moo_dfs_set_groups(cpl_frameset *set)
Set the group as RAW or CALIB in a frameset.
cpl_frameset ** moo_dfs_split_by_offset(cpl_frameset *set)
Get the EXPTIME from the frameset.
moo_det * moo_compute_p2p(moo_det *flat1, moo_loc *loc1, moo_psf *model_flat1, moo_det *flat2, moo_loc *loc2, moo_psf *model_flat2)
To compute pixel-to-pixel variation map.
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_psf * moo_model_flat(moo_det *det, moo_loc *loc, moo_model_flat_params *params, const char *filename)
To extract 2D FF and model it, resulting MASTER_FLAT.
float * moo_compute_slitoffset(moo_det *det, moo_loc *loc, moo_compute_slitoffset_params *params)
Compute slit offset in LOC.
cpl_error_code moo_apply_p2p(moo_det *flat, moo_det *p2pmap)
Divide DET by the pixel-to-pixel variation map.
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_flat_shift_compute(moo_det *det, moo_loc *ff_trace)
Compute the shift between FF_TRACE and FLAT.
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_f2f * moo_compute_fibtrans(moo_ext *ext, moo_compute_fibtrans_params *params, const char *filename)
Computes fibre-to-fibre relative transmission table.
moo_loc * moo_localise(moo_det *det, const cpl_frame *guess_loc, moo_localise_params *params, const char *locname)
To localise the centroid of fibre spectrum on frames.
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_loc(moo_products *self, moo_loc *loc, int keep_points, cpl_frame_level level, const char *tag, const char *filename, const cpl_frame *inherit_frame)
This function creates a product from a LOC structure.
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(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.