12#include "irplib_ksigma_clip.h"
20#include "moo_params.h"
22#include "moo_badpix.h"
23#include "moo_products.h"
24#include "moo_prepare.h"
26#include "moo_telluric.h"
27#include "moo_target_table.h"
54 const cpl_parameterlist *parlist,
56 const char *pipeline_id)
58 cpl_ensure(framelist != NULL, CPL_ERROR_NULL_INPUT, NULL);
59 cpl_ensure(parlist != NULL, CPL_ERROR_NULL_INPUT, NULL);
60 cpl_ensure(recid != NULL, CPL_ERROR_NULL_INPUT, NULL);
61 cpl_ensure(pipeline_id != NULL, CPL_ERROR_NULL_INPUT, NULL);
63 moo_products *res = cpl_calloc(1,
sizeof(moo_products));
64 res->framelist = framelist;
65 res->temporarylist = cpl_frameset_new();
66 res->parlist = parlist;
68 res->pipeline_id = pipeline_id;
89 cpl_ensure(self != NULL, CPL_ERROR_NULL_INPUT, NULL);
106_moo_products_create_frame(
const moo_products *self,
107 cpl_propertylist *header,
108 cpl_frame_level level,
110 const char *filename,
111 const cpl_frame *inherit_frame,
114 cpl_frame *product_frame = cpl_frame_new();
116 cpl_frame_set_type(product_frame, CPL_FRAME_TYPE_ANY);
117 cpl_frame_set_group(product_frame, CPL_FRAME_GROUP_PRODUCT);
118 cpl_frame_set_level(product_frame, level);
119 cpl_frame_set_tag(product_frame, tag);
121 if (filename != NULL) {
122 cpl_frame_set_filename(product_frame, filename);
125 char *name = cpl_sprintf(
"%s.fits", tag);
126 cpl_frame_set_filename(product_frame, name);
129 cpl_error_code status =
130 cpl_dfs_setup_product_header(header, product_frame, self->framelist,
131 self->parlist, self->recid,
132 self->pipeline_id, DICTIONARY_ID,
134 if (status != CPL_ERROR_NONE) {
135 cpl_frame_delete(product_frame);
136 product_frame = NULL;
145 int ecode = cpl_propertylist_erase_regexp(header, filter, 0);
147 cpl_frame_delete(product_frame);
148 product_frame = NULL;
151 return product_frame;
169 cpl_error_code status = CPL_ERROR_NONE;
170 cpl_ensure_code(self != NULL, CPL_ERROR_ILLEGAL_INPUT);
171 cpl_ensure_code(frame != NULL, CPL_ERROR_ILLEGAL_INPUT);
173 cpl_frame_level level = cpl_frame_get_level(frame);
175 if (level == CPL_FRAME_LEVEL_TEMPORARY) {
176 status = cpl_frameset_insert(self->temporarylist, frame);
178 else if (level == CPL_FRAME_LEVEL_INTERMEDIATE && self->keep_temp == 0) {
179 status = cpl_frameset_insert(self->temporarylist, frame);
182 status = cpl_frameset_insert(self->framelist, frame);
205 cpl_frame_level level,
207 const char *filename,
208 const cpl_frame *inherit_frame)
210 cpl_ensure(self != NULL, CPL_ERROR_NULL_INPUT, NULL);
211 cpl_ensure(det != NULL, CPL_ERROR_NULL_INPUT, NULL);
212 cpl_ensure(det->primary_header != NULL, CPL_ERROR_NULL_INPUT, NULL);
214 cpl_errorstate prestate = cpl_errorstate_get();
215 cpl_frame *product_frame = NULL;
216 const char *pname = NULL;
218 moo_try_check(product_frame =
219 _moo_products_create_frame(self, det->primary_header,
220 level, tag, filename,
221 inherit_frame, NULL),
223 moo_try_check(pname = cpl_frame_get_filename(product_frame),
" ");
228 if (!cpl_errorstate_is_equal(prestate)) {
229 cpl_frame_delete(product_frame);
231 return product_frame;
235moo_products_add_det(moo_products *self,
237 cpl_frame_level level,
239 const char *filename,
240 const cpl_frame *inherit_frame,
243 cpl_ensure(self != NULL, CPL_ERROR_NULL_INPUT, NULL);
244 cpl_ensure(det != NULL, CPL_ERROR_NULL_INPUT, NULL);
245 cpl_ensure(det->primary_header != NULL, CPL_ERROR_NULL_INPUT, NULL);
247 cpl_errorstate prestate = cpl_errorstate_get();
248 cpl_frame *product_frame = NULL;
249 const char *pname = NULL;
251 moo_try_check(product_frame =
252 _moo_products_create_frame(self, det->primary_header,
253 level, tag, filename,
254 inherit_frame, filter),
256 moo_try_check(pname = cpl_frame_get_filename(product_frame),
" ");
261 if (!cpl_errorstate_is_equal(prestate)) {
262 cpl_frame_delete(product_frame);
264 return product_frame;
280 cpl_frame_level level,
282 const char *filename,
283 const cpl_frame *inherit_frame)
285 cpl_ensure(self != NULL, CPL_ERROR_NULL_INPUT, NULL);
286 cpl_ensure(loc != NULL, CPL_ERROR_NULL_INPUT, NULL);
287 cpl_ensure(loc->primary_header != NULL, CPL_ERROR_NULL_INPUT, NULL);
289 cpl_frame *product_frame = cpl_frame_new();
291 cpl_frame_set_type(product_frame, CPL_FRAME_TYPE_ANY);
292 cpl_frame_set_group(product_frame, CPL_FRAME_GROUP_PRODUCT);
293 cpl_frame_set_level(product_frame, level);
294 cpl_frame_set_tag(product_frame, tag);
295 cpl_frame_set_filename(product_frame, filename);
297 cpl_dfs_setup_product_header(loc->primary_header, product_frame,
298 self->framelist, self->parlist, self->recid,
299 self->pipeline_id, DICTIONARY_ID,
304 if (level == CPL_FRAME_LEVEL_TEMPORARY) {
305 cpl_frameset_insert(self->temporarylist, product_frame);
307 else if (level == CPL_FRAME_LEVEL_INTERMEDIATE && self->keep_temp == 0) {
308 cpl_frameset_insert(self->temporarylist, product_frame);
311 cpl_frameset_insert(self->framelist, product_frame);
314 return product_frame;
335 cpl_frame_level level,
337 const char *filename,
338 const cpl_frame *inherit_frame)
340 cpl_ensure(self != NULL, CPL_ERROR_NULL_INPUT, NULL);
341 cpl_ensure(ext != NULL, CPL_ERROR_NULL_INPUT, NULL);
342 cpl_ensure(ext->primary_header != NULL, CPL_ERROR_NULL_INPUT, NULL);
344 cpl_frame *product_frame = NULL;
345 const char *pname = NULL;
347 moo_try_check(product_frame =
348 _moo_products_create_frame(self, ext->primary_header,
349 level, tag, filename,
350 inherit_frame, NULL),
352 moo_try_check(pname = cpl_frame_get_filename(product_frame),
" ");
356 return product_frame;
378 cpl_frame_level level,
380 const char *filename,
381 const cpl_frame *inherit_frame)
383 cpl_ensure(self != NULL, CPL_ERROR_NULL_INPUT, NULL);
384 cpl_ensure(rbn != NULL, CPL_ERROR_NULL_INPUT, NULL);
385 cpl_ensure(rbn->primary_header != NULL, CPL_ERROR_NULL_INPUT, NULL);
387 cpl_frame *product_frame = NULL;
388 const char *pname = NULL;
390 moo_try_check(product_frame =
391 _moo_products_create_frame(self, rbn->primary_header,
392 level, tag, filename,
393 inherit_frame, NULL),
395 moo_try_check(pname = cpl_frame_get_filename(product_frame),
" ");
400 return product_frame;
422 cpl_frame_level level,
424 const char *filename,
425 const cpl_frame *inherit_frame)
427 cpl_ensure(self != NULL, CPL_ERROR_NULL_INPUT, NULL);
428 cpl_ensure(sci != NULL, CPL_ERROR_NULL_INPUT, NULL);
429 cpl_ensure(sci->primary_header != NULL, CPL_ERROR_NULL_INPUT, NULL);
431 cpl_frame *product_frame = NULL;
432 const char *pname = NULL;
434 moo_try_check(product_frame =
435 _moo_products_create_frame(self, sci->primary_header,
436 level, tag, filename,
437 inherit_frame, NULL),
439 moo_try_check(pname = cpl_frame_get_filename(product_frame),
" ");
444 return product_frame;
466 cpl_frame_level level,
468 const char *filename,
469 const cpl_frame *inherit_frame)
471 cpl_ensure(self != NULL, CPL_ERROR_NULL_INPUT, NULL);
472 cpl_ensure(resp != NULL, CPL_ERROR_NULL_INPUT, NULL);
473 cpl_ensure(resp->primary_header != NULL, CPL_ERROR_NULL_INPUT, NULL);
475 cpl_frame *product_frame = NULL;
476 const char *pname = NULL;
478 moo_try_check(product_frame =
479 _moo_products_create_frame(self, resp->primary_header,
480 level, tag, filename,
481 inherit_frame, NULL),
483 moo_try_check(pname = cpl_frame_get_filename(product_frame),
" ");
488 return product_frame;
510 cpl_frame_level level,
512 const char *filename,
513 const cpl_frame *inherit_frame)
515 cpl_frame *product_frame = NULL;
516 cpl_ensure(self != NULL, CPL_ERROR_NULL_INPUT, NULL);
517 cpl_ensure(tell != NULL, CPL_ERROR_NULL_INPUT, NULL);
518 cpl_ensure(tell->primary_header != NULL, CPL_ERROR_NULL_INPUT, NULL);
520 const char *pname = NULL;
522 moo_try_check(product_frame =
523 _moo_products_create_frame(self, tell->primary_header,
524 level, tag, filename,
525 inherit_frame, NULL),
528 moo_try_check(pname = cpl_frame_get_filename(product_frame),
" ");
533 return product_frame;
556 cpl_frame_level level,
558 const char *filename,
559 const cpl_frame *inherit_frame,
562 cpl_ensure(self != NULL, CPL_ERROR_NULL_INPUT, NULL);
563 cpl_ensure(map != NULL, CPL_ERROR_NULL_INPUT, NULL);
564 cpl_ensure(map->primary_header != NULL, CPL_ERROR_NULL_INPUT, NULL);
566 cpl_frame *product_frame = NULL;
567 const char *pname = NULL;
569 moo_try_check(product_frame =
570 _moo_products_create_frame(self, map->primary_header,
571 level, tag, filename,
572 inherit_frame, NULL),
574 moo_try_check(pname = cpl_frame_get_filename(product_frame),
" ");
575 moo_map_update_linetable(map, rbn);
580 return product_frame;
601 moo_molectable *mtable,
602 cpl_frame_level level,
604 const char *filename,
605 const cpl_frame *inherit_frame)
607 cpl_ensure(self != NULL, CPL_ERROR_NULL_INPUT, NULL);
608 cpl_ensure(mtable != NULL, CPL_ERROR_NULL_INPUT, NULL);
609 cpl_ensure(mtable->primary_header != NULL, CPL_ERROR_NULL_INPUT, NULL);
611 cpl_frame *product_frame = NULL;
612 const char *pname = NULL;
614 moo_try_check(product_frame =
615 _moo_products_create_frame(self, mtable->primary_header,
616 level, tag, filename,
617 inherit_frame, NULL),
619 moo_try_check(pname = cpl_frame_get_filename(product_frame),
" ");
624 return product_frame;
645 cpl_frame_level level,
647 const char *filename,
648 const cpl_frame *inherit_frame)
650 cpl_ensure(self != NULL, CPL_ERROR_NULL_INPUT, NULL);
651 cpl_ensure(bpm != NULL, CPL_ERROR_NULL_INPUT, NULL);
652 cpl_ensure(bpm->primary_header != NULL, CPL_ERROR_NULL_INPUT, NULL);
654 cpl_frame *product_frame = NULL;
655 const char *pname = NULL;
657 moo_try_check(product_frame =
658 _moo_products_create_frame(self, bpm->primary_header,
659 level, tag, filename,
660 inherit_frame, NULL),
662 moo_try_check(pname = cpl_frame_get_filename(product_frame),
" ");
667 return product_frame;
688 moo_saturate_map *saturate,
689 cpl_frame_level level,
691 const char *filename,
692 const cpl_frame *inherit_frame)
694 cpl_ensure(self != NULL, CPL_ERROR_NULL_INPUT, NULL);
695 cpl_ensure(saturate != NULL, CPL_ERROR_NULL_INPUT, NULL);
696 cpl_ensure(saturate->primary_header != NULL, CPL_ERROR_NULL_INPUT, NULL);
698 cpl_frame *product_frame = NULL;
699 const char *pname = NULL;
701 moo_try_check(product_frame =
702 _moo_products_create_frame(self, saturate->primary_header,
703 level, tag, filename,
704 inherit_frame, NULL),
706 moo_try_check(pname = cpl_frame_get_filename(product_frame),
" ");
711 return product_frame;
733 cpl_frame_level level,
735 const char *filename,
736 const cpl_frame *inherit_frame)
738 cpl_ensure(self != NULL, CPL_ERROR_NULL_INPUT, NULL);
739 cpl_ensure(cube != NULL, CPL_ERROR_NULL_INPUT, NULL);
740 cpl_ensure(cube->primary_header != NULL, CPL_ERROR_NULL_INPUT, NULL);
742 cpl_frame *product_frame = NULL;
743 const char *pname = NULL;
745 moo_try_check(product_frame =
746 _moo_products_create_frame(self, cube->primary_header,
747 level, tag, filename,
748 inherit_frame, NULL),
750 moo_try_check(pname = cpl_frame_get_filename(product_frame),
" ");
755 return product_frame;
776 cpl_frame_level level,
778 const char *filename,
779 const cpl_frame *inherit_frame)
781 cpl_ensure(self != NULL, CPL_ERROR_NULL_INPUT, NULL);
782 cpl_ensure(ttable != NULL, CPL_ERROR_NULL_INPUT, NULL);
783 cpl_ensure(ttable->primary_header != NULL, CPL_ERROR_NULL_INPUT, NULL);
785 cpl_frame *product_frame = NULL;
786 const char *pname = NULL;
788 moo_try_check(product_frame =
789 _moo_products_create_frame(self, ttable->primary_header,
790 level, tag, filename,
791 inherit_frame, NULL),
793 moo_try_check(pname = cpl_frame_get_filename(product_frame),
" ");
795 moo_try_check(moo_target_table_save(ttable, pname),
" ");
800 return product_frame;
804moo_products_add_f2f(moo_products *self,
806 cpl_frame_level level,
808 const char *filename,
809 const cpl_frame *inherit_frame)
811 cpl_ensure(self != NULL, CPL_ERROR_NULL_INPUT, NULL);
812 cpl_ensure(f2f != NULL, CPL_ERROR_NULL_INPUT, NULL);
813 cpl_ensure(f2f->primary_header != NULL, CPL_ERROR_NULL_INPUT, NULL);
815 cpl_frame *product_frame = cpl_frame_new();
817 cpl_frame_set_type(product_frame, CPL_FRAME_TYPE_ANY);
818 cpl_frame_set_group(product_frame, CPL_FRAME_GROUP_PRODUCT);
819 cpl_frame_set_level(product_frame, level);
820 cpl_frame_set_tag(product_frame, tag);
821 cpl_frame_set_filename(product_frame, filename);
823 cpl_dfs_setup_product_header(f2f->primary_header, product_frame,
824 self->framelist, self->parlist, self->recid,
825 self->pipeline_id, DICTIONARY_ID,
828 moo_f2f_save(f2f, filename);
830 if (level == CPL_FRAME_LEVEL_TEMPORARY) {
831 cpl_frameset_insert(self->temporarylist, product_frame);
833 else if (level == CPL_FRAME_LEVEL_INTERMEDIATE && self->keep_temp == 0) {
834 cpl_frameset_insert(self->temporarylist, product_frame);
837 cpl_frameset_insert(self->framelist, product_frame);
840 return product_frame;
844moo_products_add_psf(moo_products *self,
846 cpl_frame_level level,
848 const char *filename,
849 const cpl_frame *inherit_frame)
851 cpl_ensure(self != NULL, CPL_ERROR_NULL_INPUT, NULL);
852 cpl_ensure(psf != NULL, CPL_ERROR_NULL_INPUT, NULL);
853 cpl_ensure(psf->primary_header != NULL, CPL_ERROR_NULL_INPUT, NULL);
855 cpl_frame *product_frame = cpl_frame_new();
857 cpl_frame_set_type(product_frame, CPL_FRAME_TYPE_ANY);
858 cpl_frame_set_group(product_frame, CPL_FRAME_GROUP_PRODUCT);
859 cpl_frame_set_level(product_frame, level);
860 cpl_frame_set_tag(product_frame, tag);
861 cpl_frame_set_filename(product_frame, filename);
863 cpl_dfs_setup_product_header(psf->primary_header, product_frame,
864 self->framelist, self->parlist, self->recid,
865 self->pipeline_id, DICTIONARY_ID,
870 if (level == CPL_FRAME_LEVEL_TEMPORARY) {
871 cpl_frameset_insert(self->temporarylist, product_frame);
873 else if (level == CPL_FRAME_LEVEL_INTERMEDIATE && self->keep_temp == 0) {
874 cpl_frameset_insert(self->temporarylist, product_frame);
877 cpl_frameset_insert(self->framelist, product_frame);
880 return product_frame;
884moo_products_add_raw(moo_products *self,
886 cpl_frame_level level,
888 const char *filename,
889 const cpl_frame *inherit_frame)
891 cpl_ensure(self != NULL, CPL_ERROR_NULL_INPUT, NULL);
892 cpl_ensure(raw != NULL, CPL_ERROR_NULL_INPUT, NULL);
893 cpl_ensure(raw->primary_header != NULL, CPL_ERROR_NULL_INPUT, NULL);
895 cpl_frame *product_frame = cpl_frame_new();
897 cpl_frame_set_type(product_frame, CPL_FRAME_TYPE_ANY);
898 cpl_frame_set_group(product_frame, CPL_FRAME_GROUP_PRODUCT);
899 cpl_frame_set_level(product_frame, level);
900 cpl_frame_set_tag(product_frame, tag);
901 cpl_frame_set_filename(product_frame, filename);
903 cpl_dfs_setup_product_header(raw->primary_header, product_frame,
904 self->framelist, self->parlist, self->recid,
905 self->pipeline_id, DICTIONARY_ID,
908 if (level == CPL_FRAME_LEVEL_TEMPORARY) {
909 cpl_frameset_insert(self->temporarylist, product_frame);
911 else if (level == CPL_FRAME_LEVEL_INTERMEDIATE && self->keep_temp == 0) {
912 cpl_frameset_insert(self->temporarylist, product_frame);
915 cpl_frameset_insert(self->framelist, product_frame);
917 return product_frame;
921moo_products_delete(moo_products *self)
925 int size = cpl_frameset_get_size(self->temporarylist);
927 for (i = 0; i < size; i++) {
929 cpl_frameset_get_position_const(self->temporarylist, i);
930 const char *name = cpl_frame_get_filename(f);
933 cpl_frameset_delete(self->temporarylist);
940moo_region_ron(hdrl_imagelist *biaslist,
947 double ron = 0.0, mean = 0.0, stdev = 0.0;
949 double sks_iter = 10;
950 int nbias = hdrl_imagelist_get_size(biaslist);
951 cpl_vector *region_ron = cpl_vector_new(nbias - 1);
953 for (
int i = 0; i < nbias - 1; i++) {
954 const hdrl_image *h1 = hdrl_imagelist_get_const(biaslist, i);
955 const hdrl_image *h2 = hdrl_imagelist_get_const(biaslist, i + 1);
956 const cpl_image *i1 = hdrl_image_get_image_const(h1);
957 const cpl_image *i2 = hdrl_image_get_image_const(h2);
958 cpl_image *diff = cpl_image_subtract_create(i1, i2);
959 if (strcmp(method, MOO_RON_ESTIMATION_METHOD_LOCAL) == 0) {
963 cpl_error_code error;
965 error = irplib_ksigma_clip(diff, llx, lly, urx, ury, sks_low,
966 sks_iter, 1e-5, &mean, &stdev);
968 cpl_ensure_code(!error, error);
970 ron = stdev / sqrt(2);
971 cpl_vector_set(region_ron, i, ron);
972 cpl_image_delete(diff);
974 ron = cpl_vector_get_mean(region_ron);
975 cpl_vector_delete(region_ron);
996 moo_detlist *bias_list,
997 moo_bias_params *bias_params,
998 moo_products *products)
1000 cpl_ensure_code(det != NULL, CPL_ERROR_NULL_INPUT);
1001 cpl_ensure_code(det->primary_header != NULL, CPL_ERROR_NULL_INPUT);
1002 cpl_ensure_code(bias_list != NULL, CPL_ERROR_NULL_INPUT);
1003 cpl_ensure_code(bias_params != NULL, CPL_ERROR_NULL_INPUT);
1008 cpl_msg_indent_more();
1010 cpl_msg_info(__func__,
"Use method %s for estimate RON",
1011 bias_params->ron_estimation_method);
1013 for (i = 0; i < 2; i++) {
1014 moo_single *s = det->ri[i];
1018 hdrl_imagelist *ilist =
1021 cpl_propertylist *header = moo_single_get_header(s);
1023 moo_outputs *outputs = moo_outputs_load(header,
MOO_TYPE_RI);
1026 for (
int ri = 0; ri < outputs->nb; ri++) {
1027 int llx = outputs->outputs[ri].x;
1028 int lly = outputs->outputs[ri].y;
1029 int urx = outputs->outputs[ri].x + outputs->outputs[ri].nx - 1;
1030 int ury = outputs->outputs[ri].y + outputs->outputs[ri].ny - 1;
1033 hdrl_image_extract(s->image, llx, lly, urx, ury);
1034 hdrl_value mean = hdrl_image_get_mean(image);
1035 double stdev = hdrl_image_get_stdev(image);
1038 median = cpl_image_get_mad(hdrl_image_get_image(image), &mad);
1039 hdrl_image_delete(image);
1046 moo_region_ron(ilist, llx, lly, urx, ury,
1047 bias_params->ron_estimation_method);
1049 cpl_msg_info(__func__,
"RI_%d OUT%d RON RAW : %f e-(%f ADU)",
1050 i + 1, ri + 1, ron_raw,
1051 ron_raw * outputs->outputs[ri].gain);
1052 double ron_master = mad * CPL_MATH_STD_MAD;
1054 cpl_msg_info(__func__,
1055 "RI_%d OUT%d RON MASTER : %f e- (%f ADU)", i + 1,
1057 ron_master * outputs->outputs[ri].gain);
1059 moo_outputs_delete(outputs);
1060 hdrl_imagelist_unwrap(ilist);
1065 cpl_msg_indent_less();
1066 moo_products_add_det(products, det, CPL_FRAME_LEVEL_FINAL,
1067 MOONS_TAG_MASTER_BIAS, NULL, NULL,
"ESO INS SLIT .*");
1068 return CPL_ERROR_NONE;
1089 cpl_ensure_code(det != NULL, CPL_ERROR_NULL_INPUT);
1090 cpl_ensure_code(det->primary_header != NULL, CPL_ERROR_NULL_INPUT);
1097 for (i = 0; i < 2; i++) {
1098 moo_single *s = det->ri[i];
1101 cpl_msg_info(__func__,
"Normalizing RI_%d by exptime %f", i + 1,
1105 cpl_image *image = hdrl_image_get_image(s->image);
1106 cpl_mask *mask = cpl_image_set_bpm(image, NULL);
1107 hdrl_image_div_scalar(s->image, (hdrl_value){exptime, 0.});
1108 cpl_image_set_bpm(image, mask);
1113 hdrl_value mean = hdrl_image_get_mean(s->image);
1114 hdrl_value median = hdrl_image_get_median(s->image);
1115 double stdev = hdrl_image_get_stdev(s->image);
1120 double mdark_current = MOO_TO_ADU(mean.data, gain) * 3600.0;
1122 cpl_msg_info(__func__,
"RI%d MDARK CURRENT %f", i + 1,
1130 hdrl_value mean = hdrl_image_get_mean(s->image);
1131 hdrl_value median = hdrl_image_get_median(s->image);
1132 double stdev = hdrl_image_get_stdev(s->image);
1138 (dit * ndit) * 3600.0);
1145 hdrl_value mean = hdrl_image_get_mean(s->image);
1146 hdrl_value median = hdrl_image_get_median(s->image);
1147 double stdev = hdrl_image_get_stdev(s->image);
1153 (dit * ndit) * 3600.0);
1158 moo_products_add_det(products, det, CPL_FRAME_LEVEL_FINAL,
1159 MOONS_TAG_MASTER_DARK_VIS, NULL, NULL,
1163 moo_products_add_det(products, det, CPL_FRAME_LEVEL_FINAL,
1164 MOONS_TAG_MASTER_DARK_NIR, NULL, NULL,
1167 return CPL_ERROR_NONE;
1188 const cpl_frame *inherit_frame)
1190 cpl_ensure(self != NULL, CPL_ERROR_NULL_INPUT, NULL);
1191 cpl_ensure(s1d != NULL, CPL_ERROR_NULL_INPUT, NULL);
1192 cpl_ensure(s1d->primary_header != NULL, CPL_ERROR_NULL_INPUT, NULL);
1194 cpl_frame *product_frame = NULL;
1196 moo_try_check(product_frame =
1197 _moo_products_create_frame(self, s1d->primary_header,
1198 CPL_FRAME_LEVEL_FINAL, tag,
1199 s1d->filename, inherit_frame,
1206 return product_frame;
#define MOO_BADPIX_NON_LINEAR
#define MOO_BADPIX_OUTSIDE_DATA_RANGE
#define MOO_BADPIX_COSMETIC
void moo_bpm_save(moo_bpm *self, const char *filename)
Save a moo_bpm to a FITS file.
void moo_cube_save(moo_cube *self, const char *filename)
Save a moo_cube to a FITS file.
void moo_det_save(moo_det *self, const char *filename)
Save a moo_det to a FITS file.
hdrl_imagelist * moo_detlist_get_image(const moo_detlist *self, moo_detector_type type, int num)
Get the all the images of the type part in the detlist.
cpl_error_code moo_detlist_free_single(const moo_detlist *self, moo_detector_type type, int num)
Free the type part for all DET in the detlist.
cpl_error_code moo_detlist_load_single(const moo_detlist *self, moo_detector_type type, int num, int level)
Load the type part for all DET in the detlist.
void moo_ext_save(moo_ext *self, const char *filename)
Save a moo_ext to a FITS file.
void moo_loc_save(moo_loc *self, const char *filename, int keep_points)
Save a moo_loc to a FITS file.
void moo_map_save(moo_map *self, const char *filename)
Save a moo_map to a FITS file.
void moo_molectable_save(moo_molectable *self, const char *filename)
Save a moo_molectable to a FITS file.
int moo_params_get_keep_temp(const moo_params *self, const cpl_parameterlist *list)
Get keep-temp parameter from moons parameters list.
void moo_params_delete(moo_params *self)
Delete a moo_params.
moo_params * moo_params_new(const char *pid, const char *recipe_id)
Create a new moo_params.
void moo_psf_save(moo_psf *self, const char *filename)
Save a moo_psf to a FITS file.
void moo_rbn_save(moo_rbn *self, const char *filename)
Save a moo_rbn to a FITS file.
void moo_resp_save(moo_resp *self, const char *filename)
Save a moo_resp to a FITS file.
void moo_s1d_save(moo_s1d *self)
Save a moo_s1d to a FITS file.
void moo_saturate_map_save(moo_saturate_map *self, const char *filename)
Save a moo_saturate_map to a FITS file.
void moo_sci_save(moo_sci *self, const char *filename)
Save a moo_sci to a FITS file.
cpl_error_code moo_single_load(moo_single *self, unsigned int level)
Load data in a single structure.
void moo_telluric_save(moo_telluric *self, const char *filename)
Save a moo_telluric to a FITS file.
int moo_pfits_get_ndit(const cpl_propertylist *plist)
find out the ESO DET NDIT value
cpl_error_code moo_pfits_update_exptime(cpl_propertylist *plist, double value)
Set the EXPTIME value.
double moo_pfits_get_dit(const cpl_propertylist *plist)
find out the DIT value
float moo_pfits_get_det_chip_outi_gain(const cpl_propertylist *plist, int i)
find out the ESO DET OUTI CHIP GAIN value
float moo_pfits_get_det_outi_gain(const cpl_propertylist *plist, int i)
find out the ESO DET OUTI GAIN value
double moo_pfits_get_exptime(const cpl_propertylist *plist)
find out the EXPTIME 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_s1d(moo_products *self, moo_s1d *s1d, const char *tag, const cpl_frame *inherit_frame)
create a product from a MOLECTABLE object
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_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_molectable(moo_products *self, moo_molectable *mtable, cpl_frame_level level, const char *tag, const char *filename, const cpl_frame *inherit_frame)
create a product from a MOLECTABLE object
cpl_error_code moo_products_add_frame(const moo_products *self, cpl_frame *frame)
add a frame to the recipe products
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_saturate_map(moo_products *self, moo_saturate_map *saturate, cpl_frame_level level, const char *tag, const char *filename, const cpl_frame *inherit_frame)
create a product from a SATURATE MAP object
cpl_frame * moo_products_add_resp(moo_products *self, moo_resp *resp, cpl_frame_level level, const char *tag, const char *filename, const cpl_frame *inherit_frame)
create a product from a RESP 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_cube(moo_products *self, moo_cube *cube, cpl_frame_level level, const char *tag, const char *filename, const cpl_frame *inherit_frame)
create a product from a CUBE object
cpl_frame * moo_products_add_bpm(moo_products *self, moo_bpm *bpm, cpl_frame_level level, const char *tag, const char *filename, const cpl_frame *inherit_frame)
create a product from a BPM object
cpl_error_code moo_masterdark(moo_det *det, moo_products *products, int mode)
This function creates the master dark frame as a product and essentially produces a standard output a...
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
cpl_error_code moo_masterbias(moo_det *det, moo_detlist *bias_list, moo_bias_params *bias_params, moo_products *products)
This function creates the master bias frame as a product and essentially produces a standard output a...
const moo_params * moo_products_get_params(const moo_products *self)
get the moo_params object
cpl_frame * moo_products_add_telluric(moo_products *self, moo_telluric *tell, cpl_frame_level level, const char *tag, const char *filename, const cpl_frame *inherit_frame)
create a product from a TELLURIC object
cpl_error_code moo_qc_set_mdark_normalise_factor(cpl_propertylist *plist, double val)
Set the QC.MDARK.NORMALISE.FACTOR value.
cpl_error_code moo_qc_set_ron_raw(cpl_propertylist *plist, int i, double val)
Set the QC.RON.RAW value.
cpl_error_code moo_qc_set_mbias_mad(cpl_propertylist *plist, int i, double val)
Set the QC.MBIAS.MAD value.
cpl_error_code moo_qc_set_mdark_rms(cpl_propertylist *plist, double val)
Set the QC.MDARK.RMS value.
cpl_error_code moo_qc_set_mdark_avg(cpl_propertylist *plist, double val)
Set the QC.MDARK.AVG value.
cpl_error_code moo_qc_set_mbias_med(cpl_propertylist *plist, int i, double val)
Set the QC.MBIAS.MED value.
cpl_error_code moo_qc_set_mdark_current(cpl_propertylist *plist, double val)
Set the QC.MEAN.DARK.CURRENT value.
cpl_error_code moo_qc_set_ron_master(cpl_propertylist *plist, int i, double val)
Set the QC.RON.MASTER value.
cpl_error_code moo_qc_set_mbias_avg(cpl_propertylist *plist, int i, double val)
Set the QC.MBIAS.AVG value.
cpl_error_code moo_qc_set_mdark_med(cpl_propertylist *plist, double val)
Set the QC.MDARK.MED value.
cpl_error_code moo_qc_set_mbias_rms(cpl_propertylist *plist, int i, double val)
Set the QC.MBIAS.AVG value.
cpl_error_code moo_raw_save(moo_raw *self, const char *filename)
Save a moo_raw to a FITS file.
double moo_image_get_ron(cpl_image *diff, int llx, int lly, int urx, int ury, int nb_boxes, int box_hsize, double max_error_frac, int max_niter)
compute ron in a diff image using boxes
the different type of detectors