32 #include "muse_twilight_z.h" 49 cpl_ensure_code(aImage && aList, CPL_ERROR_NULL_INPUT);
51 cpl_msg_debug(__func__,
"Adding QC keywords for IFU %hhu", ifu);
53 unsigned stats = CPL_STATS_MEDIAN | CPL_STATS_MEAN | CPL_STATS_STDEV
54 | CPL_STATS_MIN | CPL_STATS_MAX;
59 char *keyword = cpl_sprintf(QC_TWILIGHTm_PREFIXi, ifu, k+1);
61 aImage->
header, keyword, stats);
63 keyword = cpl_sprintf(QC_TWILIGHTm_PREFIXi
" "QC_BASIC_NSATURATED, ifu, k+1);
66 cpl_propertylist_update_int(aImage->
header, keyword, nsaturated);
71 char *kw = cpl_sprintf(QC_TWILIGHTm_MASTER_PREFIX, ifu);
72 stats |= CPL_STATS_FLUX;
75 return CPL_ERROR_NONE;
130 muse_combinepar *aCPars,
133 cpl_ensure(aProcessing && aParams, CPL_ERROR_NULL_INPUT, NULL);
136 cpl_ensure(lmax > lmin, CPL_ERROR_ILLEGAL_INPUT, NULL);
139 cpl_ensure(geo, CPL_ERROR_FILE_NOT_FOUND, NULL);
143 #pragma omp parallel for default(none) \ 144 shared(aBPars, aCPars, aProcessing, geo, pts) 145 for (nifu = 1; nifu <= kMuseNumIFUs; nifu++) {
148 if (!trace || !wavecal) {
149 cpl_msg_warning(__func__,
"Calibrations could not be loaded for IFU " 150 "%2hhu:%s%s", nifu, !trace ?
" "MUSE_TAG_TRACE_TABLE :
"",
151 !wavecal ?
" "MUSE_TAG_WAVECAL_TABLE :
"");
152 cpl_table_delete(trace);
153 cpl_table_delete(wavecal);
157 cpl_msg_debug(__func__,
"load raw files of IFU %2hhu", nifu);
160 cpl_msg_warning(__func__,
"Basic processing failed for IFU %2hhu: %s",
161 nifu, cpl_error_get_message());
162 cpl_table_delete(trace);
163 cpl_table_delete(wavecal);
170 cpl_msg_debug(__func__,
"combine raw files of IFU %2hhu", nifu);
172 muse_twilight_qc_header(masterimage, images);
175 cpl_msg_warning(__func__,
"Combining individual images failed for IFU %2hhu: %s",
176 nifu, cpl_error_get_message());
177 cpl_table_delete(tattached);
178 cpl_table_delete(trace);
179 cpl_table_delete(wavecal);
188 cpl_detector_interpolate_rejected(masterimage->
data);
190 cpl_detector_interpolate_rejected(masterimage->
stat);
192 cpl_msg_debug(__func__,
"interpolated over %d bad pixels in IFU %2hhu",
196 cpl_msg_debug(__func__,
"create pixel table for IFU %2hhu", nifu);
198 cpl_table_delete(trace);
199 cpl_table_delete(wavecal);
202 cpl_propertylist_copy_property_regexp(pts[nifu - 1]->header,
204 QC_TWILIGHT_REGEXP, 0);
210 cpl_table_delete(tattached);
217 cpl_table_delete(geo);
222 cpl_error_set_message(__func__, CPL_ERROR_ILLEGAL_OUTPUT,
223 "After cutting to %.2f..%.2f Angstrom in wavelength " 224 "no pixels for cube reconstruction are left!", lmin,
226 for (nifu = 1; nifu <= kMuseNumIFUs; nifu++) {
233 cpl_array *scales = NULL;
234 if (getenv(
"MUSE_TWILIGHT_SCALES")) {
236 double scale = atof(cpl_array_get_string(scales, 0));
239 int nscales = cpl_array_get_size(scales);
240 if (nscales != kMuseNumIFUs) {
241 cpl_msg_warning(__func__,
"%d external scales found instead of %d! Not " 242 "using them.", nscales, kMuseNumIFUs);
243 cpl_array_delete(scales);
246 cpl_msg_info(__func__,
"Using %d external scales.", nscales);
249 cpl_array_dump(scales, 0, 30, stdout);
256 cpl_msg_debug(__func__,
"pixel table of IFU 1, fluxref = %e, %"CPL_SIZE_FORMAT
261 cpl_propertylist_append_double(pt->
header, MUSE_HDR_FLAT_FLUX_SKY
"1", fluxref);
262 char *kw = cpl_sprintf(QC_TWILIGHTm_INTFLUX, (
unsigned char)1);
263 cpl_propertylist_append_float(pt->
header, kw, fluxref);
265 for (nifu = 2; nifu <= kMuseNumIFUs; nifu++) {
266 if (!pts[nifu - 1]) {
277 scale = atof(cpl_array_get_string(scales, nifu - 1));
279 flux = scale * fluxref;
281 scale = flux / fluxref;
283 kw = cpl_sprintf(MUSE_HDR_FLAT_FLUX_SKY
"%hhu", nifu);
284 cpl_propertylist_append_double(pt->
header, kw, flux);
286 cpl_msg_debug(__func__,
"merging pixel table of IFU %2hhu, flux = %e, scale = %f",
292 cpl_propertylist_copy_property_regexp(pt->
header, pts[nifu - 1]->
header,
293 QC_TWILIGHT_REGEXP, 0);
295 kw = cpl_sprintf(QC_TWILIGHTm_INTFLUX, nifu);
296 cpl_propertylist_append_float(pt->
header, kw, flux);
303 cpl_array_delete(scales);
314 cube->
recnames = cpl_array_new(1, CPL_TYPE_STRING);
316 cpl_array_set_string(cube->
recnames, 0,
"white");
350 muse_twilight_image_normalize_and_fit(
muse_image *aImage,
351 unsigned int aXOrder,
352 unsigned int aYOrder,
353 const cpl_mask *aBPM,
354 const cpl_mask *aVign)
356 cpl_ensure(aImage && aImage->
data, CPL_ERROR_NULL_INPUT, NULL);
360 cpl_image_reject_from_mask(aImage->
data, aBPM);
362 cpl_image_reject_value(aImage->
data, CPL_VALUE_NOTFINITE | CPL_VALUE_ZERO);
366 cpl_image *filtered = cpl_image_duplicate(aImage->
data);
367 cpl_mask *mask = cpl_mask_new(5, 7);
369 cpl_errorstate prestate = cpl_errorstate_get();
370 cpl_image_filter_mask(filtered, aImage->
data, mask, CPL_FILTER_MEDIAN,
372 cpl_mask_delete(mask);
373 if (!cpl_errorstate_is_equal(prestate)) {
374 cpl_msg_warning(__func__,
"filtering cube plane failed: %s",
375 cpl_error_get_message());
379 cpl_image *filtered2 = cpl_image_duplicate(filtered);
381 cpl_image_filter(filtered2, filtered, gauss, CPL_FILTER_LINEAR,
383 cpl_matrix_delete(gauss);
384 if (!cpl_errorstate_is_equal(prestate)) {
385 cpl_msg_warning(__func__,
"filtering 2 failed: %s", cpl_error_get_message());
387 cpl_image_reject_from_mask(filtered2, bpm2);
388 cpl_image_fill_rejected(filtered2, 1.);
390 "TWILIGHT_IMAGE2_SMOOTHED" );
391 cpl_detector_interpolate_rejected(filtered2);
393 "TWILIGHT_IMAGE2_INTERPOLATED" );
395 cpl_image_delete(filtered2);
399 double mean = cpl_image_get_mean(filtered);
400 cpl_msg_debug(__func__,
"mean = %f", mean);
401 cpl_image_multiply_scalar(filtered, 1. / mean);
404 cpl_mask *bpm = cpl_image_get_bpm(filtered);
406 cpl_mask_or(bpm, aVign);
411 mean = cpl_image_get_mean(fit);
412 cpl_msg_debug(__func__,
"mean(fit) = %f", mean);
413 cpl_image_multiply_scalar(fit, 1. / mean);
414 cpl_image_delete(filtered);
432 cubefit->data = cpl_imagelist_new();
433 if (getenv(
"MUSE_TWILIGHT_SKIP")) {
434 char *fn = getenv(
"MUSE_TWILIGHT_SKIP");
436 cpl_msg_warning(__func__,
"Skipping active: loaded previously generated " 437 "cube from \"%s\"", fn);
442 cube->
recnames = cpl_array_new(1, CPL_TYPE_STRING);
445 cpl_array_set_string(cube->
recnames, 0,
"white");
448 strncmp(
"white", cpl_array_get_string(cube->
recnames, 0), 6))) {
452 cpl_array_set_string(cube->
recnames, 0,
"white");
457 aProcessing->
intags, -1, 0);
458 cpl_size iframe, nframes = cpl_frameset_get_size(frames);
459 for (iframe = 0; iframe < nframes; iframe++) {
460 cpl_frame *frame = cpl_frameset_get_position(frames, iframe);
463 cpl_frameset_delete(frames);
464 cpl_msg_warning(__func__,
"Skipping active: faked used frames using only " 466 cpl_frameset_dump(aProcessing->
usedframes, stdout);
468 cubefit->header = cpl_propertylist_duplicate(cube->
header);
471 cpl_error_code rc = CPL_ERROR_NONE;
474 "muse.muse_twilight");
476 "muse.muse_twilight");
482 rp->dlambda = aParams->
dlambda;
486 cube = muse_twilight_reconstruct(aProcessing, aParams, bpars, cpars, rp);
495 cubefit->header = cpl_propertylist_duplicate(cube->
header);
497 MUSE_TAG_CUBE_SKYFLAT,
500 cpl_propertylist_erase_regexp(cubefit->header, QC_TWILIGHT_REGEXP, 0);
509 cpl_error_set_message(__func__, CPL_ERROR_ILLEGAL_OUTPUT,
510 "White-light image is missing!");
514 cpl_image *white = cpl_image_duplicate(wmuse->
data);
515 cpl_image_reject_value(white, CPL_VALUE_NOTFINITE | CPL_VALUE_ZERO);
516 cpl_mask *bpm = cpl_image_get_bpm(white),
517 *bpm2 = cpl_mask_duplicate(bpm);
519 cpl_mask *border = cpl_mask_new(1, cpl_mask_get_size_y(bpm2));
520 cpl_mask_not(border);
521 cpl_mask_copy(bpm2, border, 1, 1);
522 cpl_mask_copy(bpm2, border, cpl_mask_get_size_x(bpm2), 1);
523 cpl_mask_delete(border);
526 cpl_mask *kernel = cpl_mask_new(5, 1);
527 cpl_mask_not(kernel);
528 cpl_mask_filter(bpm2, bpm, kernel, CPL_FILTER_DILATION, CPL_BORDER_NOP);
529 cpl_mask_delete(kernel);
530 bpm = cpl_image_set_bpm(white, bpm2);
531 cpl_mask_delete(bpm);
540 cpl_imagelist_get(cube->
data, 0));
541 cpl_mask_delete(maskimage->
mask);
542 maskimage->
mask = mask;
544 #if 0 // only for smoothing in wavelength direction (see below) 549 cpl_propertylist *pbla = cpl_propertylist_new();
550 cpl_propertylist_copy_property_regexp(pbla, cube->
header,
"^C", 0);
551 cpl_propertylist_dump(pbla, stdout);
553 cpl_msg_debug(__func__,
"%f %f %f", crpix3, crval3, cd33);
554 cpl_vector *pos = cpl_vector_new(npl);
558 int ipl, npl = cpl_imagelist_get_size(cube->
data);
559 for (ipl = 0; ipl < npl; ipl++) {
560 image->
data = cpl_imagelist_get(cube->
data, ipl);
561 image->
stat = cpl_imagelist_get(cube->
stat, ipl);
562 cpl_mask *vignmask = maskimage ? maskimage->
mask : NULL;
563 cpl_image *fit = muse_twilight_image_normalize_and_fit(image,
567 cpl_imagelist_set(cubefit->data, fit, ipl);
568 #if 0 // only for smoothing in wavelength direction (see below) 570 cpl_vector_set(pos, ipl, ipl+1);
578 #if 0 // XXX try to smooth with a fit in wavelenth direction? 579 cpl_image *error = cpl_image_new(cpl_image_get_size_x(white),
580 cpl_image_get_size_y(white),
582 cpl_imagelist *cubefit2 = cpl_fit_imagelist_polynomial(pos, cubefit->data,
584 CPL_TYPE_DOUBLE, error);
585 cpl_vector_dump(pos, stdout);
587 cpl_vector_delete(pos);
589 cpl_image_delete(error);
591 cpl_imagelist_save(cubefit2,
"cubefit2.fits", CPL_TYPE_UNSPECIFIED, NULL, CPL_IO_CREATE);
592 cpl_imagelist_delete(cubefit2);
601 cpl_image_delete(whitefit->
dq);
603 cpl_propertylist_update_string(whitefit->
header,
"OBJECT",
604 "white from global fit");
607 cubefit->recnames = cpl_array_new(1, CPL_TYPE_STRING);
608 cpl_array_set_string(cubefit->recnames, 0,
"white_global_fit");
612 double mean = cpl_image_get_mean(white);
613 cpl_image_divide_scalar(white, mean);
614 cpl_image *wdiv = cpl_image_divide_create(white, whitefit->
data);
617 image->
header = cpl_propertylist_new();
618 cpl_propertylist_append_string(image->
header,
"OBJECT",
"normalized " 619 "white-light divided by white global fit");
620 cpl_propertylist_append_string(image->
header,
"BUNIT",
"1");
622 image->
dq = cpl_image_new_from_mask(cpl_image_get_bpm(wdiv));
625 cpl_array_set_size(cubefit->recnames,
626 cpl_array_get_size(cubefit->recnames) + 1);
627 cpl_array_set_string(cubefit->recnames, cpl_array_get_size(cubefit->recnames) - 1,
630 cpl_mask *fovmask = cpl_mask_duplicate(cpl_image_get_bpm(white));
632 bpm = cpl_image_get_bpm(white);
633 cpl_mask_or(bpm, maskimage->
mask);
635 cpl_image_delete(white);
640 cpl_mask *vignmask = cpl_mask_duplicate(fovmask);
641 cpl_mask_not(maskimage->
mask);
642 cpl_mask_or(vignmask, maskimage->
mask);
643 cpl_image *wdiv2 = cpl_image_duplicate(wdiv);
644 cpl_image_reject_from_mask(wdiv2, vignmask);
648 cpl_msg_info(__func__,
"Excluding strong edges (stronger than %.1f%%) " 650 cpl_image *wdivX = cpl_image_duplicate(wdiv2);
651 cpl_mask *wdivXmask = cpl_mask_duplicate(cpl_image_get_bpm(wdivX));
652 cpl_image_fill_rejected(wdivX, 1.);
653 cpl_image_accept_all(wdivX);
654 int i, nx = cpl_image_get_size_x(wdivX),
655 j, ny = cpl_image_get_size_y(wdivX);
657 for (i = 1; i <= nx; i++) {
658 for (j = 2; j <= ny; j++) {
660 double v1 = cpl_image_get(wdivX, i, j - 1, &err),
661 v2 = cpl_image_get(wdivX, i, j, &err);
666 cpl_msg_debug(__func__,
"%03d %03d v1 %f V2 %f --> delta %f",
667 i, j, v1, v2, fabs(v2 - v1));
668 double dv1 = fabs(v1 - 1.),
671 cpl_mask_set(wdivXmask, i, j - 1, CPL_BINARY_1);
673 cpl_mask_set(wdivXmask, i, j, CPL_BINARY_1);
678 for (j = 1; j <= ny; j++) {
679 for (i = 2; i <= nx; i++) {
681 double v1 = cpl_image_get(wdivX, i - 1, j, &err),
682 v2 = cpl_image_get(wdivX, i, j, &err);
687 cpl_msg_debug(__func__,
"%03d %03d v1 %f V2 %f --> delta %f",
688 i, j, v1, v2, fabs(v2 - v1));
689 double dv1 = fabs(v1 - 1.),
692 cpl_mask_set(wdivXmask, i - 1, j, CPL_BINARY_1);
694 cpl_mask_set(wdivXmask, i, j, CPL_BINARY_1);
699 cpl_image_reject_from_mask(wdiv2, wdivXmask);
703 image->
header = cpl_propertylist_new();
704 cpl_propertylist_append_string(image->
header,
"OBJECT",
705 "white-light divided by white global, mask excl edges");
706 cpl_propertylist_append_string(image->
header,
"BUNIT",
"1");
708 image->
dq = cpl_image_new_from_mask(wdivXmask);
709 cpl_mask_delete(wdivXmask);
712 cpl_array_set_size(cubefit->recnames,
713 cpl_array_get_size(cubefit->recnames) + 1);
714 cpl_array_set_string(cubefit->recnames, cpl_array_get_size(cubefit->recnames) - 1,
715 "white_div_global_excl_edges");
719 cpl_image *fit = NULL;
720 if (aParams->
vignsmooth == MUSE_TWILIGHT_PARAM_VIGNSMOOTH_GAUSSIAN) {
723 cpl_msg_info(__func__,
"Running %.1f pix FWHM Gaussian filter...", fwhm);
724 fit = cpl_image_duplicate(wdiv2);
726 int hw = lround(fwhm);
727 hw = hw % 2 ? hw : hw + 1;
728 cpl_msg_debug(__func__,
"using width 2 x %d + 1 for Gaussian matrix", hw);
730 fwhm * CPL_MATH_SIG_FWHM);
731 cpl_errorstate prestate = cpl_errorstate_get();
732 cpl_image_filter(fit, wdiv2, gauss, CPL_FILTER_LINEAR, CPL_BORDER_FILTER);
733 cpl_matrix_delete(gauss);
734 cpl_image_reject_from_mask(fit, cpl_image_get_bpm(wdiv2));
736 cpl_image_threshold(fit, 1., FLT_MAX, 1., FLT_MAX);
737 if (!cpl_errorstate_is_equal(prestate)) {
738 cpl_msg_warning(__func__,
"filtering vignetted area failed: %s",
739 cpl_error_get_message());
744 cpl_msg_info(__func__,
"Running Gaussian filter on extended region...");
746 fit = cpl_image_duplicate(wdiv2);
749 cpl_image *wdiv3 = cpl_image_duplicate(wdiv2);
750 cpl_image_fill_rejected(wdiv3, 1.);
751 cpl_mask *masktest = cpl_mask_load(
"masktest3.fits", 0, 0);
752 cpl_image_reject_from_mask(wdiv3, masktest);
753 cpl_mask_delete(masktest);
758 10. * CPL_MATH_SIG_FWHM);
759 cpl_errorstate prestate = cpl_errorstate_get();
760 cpl_image_filter(fit, wdiv3, gauss, CPL_FILTER_LINEAR, CPL_BORDER_FILTER);
761 cpl_image_delete(wdiv3);
762 cpl_matrix_delete(gauss);
763 cpl_image_reject_from_mask(fit, cpl_image_get_bpm(wdiv2));
765 cpl_image_threshold(fit, 1., FLT_MAX, 1., FLT_MAX);
766 if (!cpl_errorstate_is_equal(prestate)) {
767 cpl_msg_warning(__func__,
"filtering vignetted area failed: %s",
768 cpl_error_get_message());
771 }
else if (aParams->
vignsmooth == MUSE_TWILIGHT_PARAM_VIGNSMOOTH_MEDIAN) {
772 cpl_msg_info(__func__,
"Running %dx%d median filter...",
774 fit = cpl_image_duplicate(wdiv2);
777 cpl_errorstate prestate = cpl_errorstate_get();
778 cpl_image_filter_mask(fit, wdiv2, mask, CPL_FILTER_MEDIAN,
780 cpl_mask_delete(mask);
782 cpl_image_threshold(fit, 1., FLT_MAX, 1., FLT_MAX);
783 if (!cpl_errorstate_is_equal(prestate)) {
784 cpl_msg_warning(__func__,
"filtering vignetted ared failed: %s",
785 cpl_error_get_message());
788 cpl_msg_info(__func__,
"Running polyfit...");
791 cpl_image *wdiv3 = cpl_image_duplicate(wdiv2);
792 cpl_image_threshold(wdiv3, 1., FLT_MAX, 1., FLT_MAX);
797 cpl_image_delete(wdiv3);
799 cpl_image_threshold(fit, 1., FLT_MAX, 1., FLT_MAX);
803 cpl_image_reject_from_mask(fit, vignmask);
806 cpl_image_fill_rejected(fit, 1.);
810 image->
header = cpl_propertylist_new();
811 cpl_propertylist_append_string(image->
header,
"OBJECT",
"vignetting fit");
813 cpl_propertylist_append_string(image->
header,
"BUNIT",
"");
815 image->
dq = cpl_image_new_from_mask(cpl_image_get_bpm(fit));
818 cpl_array_set_size(cubefit->recnames,
819 cpl_array_get_size(cubefit->recnames) + 1);
820 cpl_array_set_string(cubefit->recnames, cpl_array_get_size(cubefit->recnames) - 1,
825 image->
header = cpl_propertylist_new();
826 cpl_propertylist_append_string(image->
header,
"OBJECT",
827 "white image corrected by vignetting fit");
829 cpl_propertylist_append_string(image->
header,
"BUNIT",
"count");
830 image->
data = cpl_image_divide_create(wdiv2, fit);
831 image->
dq = cpl_image_new_from_mask(cpl_image_get_bpm(image->
data));
834 cpl_array_set_size(cubefit->recnames,
835 cpl_array_get_size(cubefit->recnames) + 1);
836 cpl_array_set_string(cubefit->recnames, cpl_array_get_size(cubefit->recnames) - 1,
838 cpl_image_delete(wdiv2);
841 cpl_msg_info(__func__,
"Combining smooth field of view and vignetted corner" 842 " in %d planes", npl);
843 for (ipl = 0; ipl < npl; ipl++) {
844 cpl_image *cimage = cpl_imagelist_get(cubefit->data, ipl);
847 cpl_image_accept_all(cimage);
848 double mean1 = cpl_image_get_mean(cimage);
849 cpl_image_multiply(cimage, fit);
852 cpl_image_accept_all(cimage);
853 double mean2 = cpl_image_get_mean(cimage);
854 cpl_image_multiply_scalar(cimage, 1. / mean2);
855 double mean3 = cpl_image_get_mean(cimage);
856 if (fabs(mean3 - 1.) > FLT_EPSILON) {
857 cpl_msg_warning(__func__,
"normalization failed in plane %d: mean(" 858 "plane) = %f -> %f -> %f", ipl + 1, mean1, mean2, mean3);
861 cpl_mask_delete(vignmask);
863 cpl_mask_delete(fovmask);
867 MUSE_TAG_TWILIGHT_CUBE,
871 return rc == CPL_ERROR_NONE ? 0 : -1;
double crsigma
Sigma rejection factor to use for cosmic ray rejection during final resampling. A zero or negative va...
int muse_processing_save_cimage(muse_processing *aProcessing, int aIFU, cpl_image *aImage, cpl_propertylist *aHeader, const char *aTag)
Save a computed FITS image to disk.
muse_imagelist * muse_basicproc_load(muse_processing *aProcessing, unsigned char aIFU, muse_basicproc_params *aBPars)
Load the raw input files from disk and do basic processing.
Structure definition of a MUSE datacube.
Structure definition for a collection of muse_images.
void muse_image_delete(muse_image *aImage)
Deallocate memory associated to a muse_image object.
double muse_pfits_get_cd(const cpl_propertylist *aHeaders, unsigned int aAxisI, unsigned int aAxisJ)
find out the WCS coordinate at the reference point
double muse_pfits_get_crval(const cpl_propertylist *aHeaders, unsigned int aAxis)
find out the WCS coordinate at the reference point
unsigned char muse_utils_get_ifu(const cpl_propertylist *aHeaders)
Find out the IFU/channel from which this header originated.
cpl_image * data
the data extension
cpl_size muse_pixtable_get_nrow(const muse_pixtable *aPixtable)
get the number of rows within the pixel table
void muse_mask_delete(muse_mask *aMask)
Deallocate memory associated to a muse_mask object.
muse_datacube * muse_datacube_load(const char *aFilename)
Load header, DATA and optionally STAT and DQ extensions as well as the reconstructed images of a MUSE...
muse_resampling_crstats_type muse_postproc_get_cr_type(const char *aCRTypeString)
Select correct cosmic ray rejection type for crtype string.
muse_datacube * muse_resampling_cube(muse_pixtable *aPixtable, muse_resampling_params *aParams, muse_pixgrid **aGrid)
Resample a pixel table onto a regular grid structure representing a FITS NAXIS=3 datacube.
cpl_image * stat
the statistics extension
void muse_datacube_delete(muse_datacube *aCube)
Deallocate memory associated to a muse_datacube object.
void muse_imagelist_delete(muse_imagelist *aList)
Free the memory of the MUSE image list.
const char * crtype_s
Type of statistics used for detection of cosmic rays during final resampling. "iraf" uses the varianc...
muse_basicproc_params * muse_basicproc_params_new(cpl_parameterlist *aParameters, const char *aPrefix)
Create a new structure of basic processing parameters.
muse_image * muse_combine_images(muse_combinepar *aCPars, muse_imagelist *aImages)
Combine several images into one.
Structure definition of MUSE three extension FITS file.
cpl_array * recnames
the reconstructed image filter names
cpl_table * table
The pixel table.
void muse_basicproc_params_delete(muse_basicproc_params *aBPars)
Free a structure of basic processing parameters.
cpl_propertylist * header
the FITS header
#define MUSE_PIXTABLE_DATA
unsigned int muse_imagelist_get_size(muse_imagelist *aList)
Return the number of stored images.
cpl_frameset * usedframes
void muse_combinepar_delete(muse_combinepar *aCPars)
Clear the combination parameters.
muse_resampling_crstats_type crtype
cpl_image * dq
the data quality extension
cpl_error_code muse_pixtable_restrict_wavelength(muse_pixtable *aPixtable, double aLow, double aHigh)
Restrict a pixel table to a certain wavelength range.
double muse_pfits_get_crpix(const cpl_propertylist *aHeaders, unsigned int aAxis)
find out the WCS reference point
cpl_array * muse_cplarray_new_from_delimited_string(const char *aString, const char *aDelim)
Convert a delimited string into an array of strings.
Structure definition of MUSE pixel table.
cpl_error_code muse_datacube_convert_dq(muse_datacube *aCube)
Convert the DQ extension of a datacube to NANs in DATA and STAT.
muse_image * muse_imagelist_get(muse_imagelist *aList, unsigned int aIdx)
Get the muse_image of given list index.
int vignxpar
Parameter used by the vignetting smoothing: x order for polyfit (default, recommended 4)...
double vignmaskedges
Pixels on edges stronger than this fraction in the normalized image are excluded from the fit to the ...
int vignypar
Parameter used by the vignetting smoothing: y order for polyfit (default, recommended 4)...
muse_resampling_params * muse_resampling_params_new(muse_resampling_type aMethod)
Create the resampling parameters structure.
Structure to hold the parameters of the muse_twilight recipe.
cpl_error_code muse_processing_save_cube(muse_processing *aProcessing, int aIFU, void *aCube, const char *aTag, muse_cube_type aType)
Save a MUSE datacube to disk.
double dlambda
Sampling for twilight reconstruction, this should result in planes of equal wavelength coverage...
int vignsmooth
Type of smoothing to use for the vignetted region given by the VIGNETTING_MASK; gaussian uses (vignxp...
muse_combinepar * muse_combinepar_new(cpl_parameterlist *aParameters, const char *aPrefix)
Create a new set of combination parameters.
double lambdamin
Minimum wavelength for twilight reconstruction.
cpl_imagelist * data
the cube containing the actual data values
void muse_processing_append_used(muse_processing *aProcessing, cpl_frame *aFrame, cpl_frame_group aGroup, int aDuplicate)
Add a frame to the set of used frames.
int yorder
Polynomial order to use in y direction to fit the full field of view.
muse_mask * muse_processing_load_mask(muse_processing *aProcessing, const char *aTag)
Load a mask file and its FITS header.
int xorder
Polynomial order to use in x direction to fit the full field of view.
muse_pixtable * muse_pixtable_create(muse_image *aImage, cpl_table *aTrace, cpl_table *aWave, cpl_table *aGeoTable)
Create the pixel table for one CCD.
cpl_error_code muse_basicproc_stats_append_header(cpl_image *aImage, cpl_propertylist *aHeader, const char *aPrefix, unsigned aStats)
Compute image statistics of an image and add them to a header.
cpl_table * muse_basicproc_get_illum(muse_imagelist *aImages, cpl_table *aTrace, cpl_table *aWave, cpl_table *aGeo)
Get an illum/attached flat-field from an imagelist and prepare it for use.
cpl_propertylist * header
the FITS header
cpl_table * muse_processing_load_ctable(muse_processing *aProcessing, const char *aTag, unsigned char aIFU)
Load a CPL table according to its tag and IFU/channel number.
muse_resampling_type muse_postproc_get_resampling_type(const char *aResampleString)
Select correct resampling type for resample string.
#define MUSE_PIXTABLE_STAT
cpl_image * muse_utils_image_fit_polynomial(const cpl_image *aImage, unsigned short aXOrder, unsigned short aYOrder)
Create a smooth version of a 2D image by fitting it with a 2D polynomial.
Handling of "mask" files.
muse_imagelist * muse_imagelist_new(void)
Create a new (empty) MUSE image list.
cpl_error_code muse_basicproc_mask_notch_filter(muse_pixtable *aPT, unsigned char aIFU)
Mask the range of the NaD notch filter in the given pixel table.
Structure of basic processing parameters.
muse_resampling_type
Resampling types.
void muse_resampling_params_delete(muse_resampling_params *aParams)
Delete a resampling parameters structure.
muse_image * muse_datacube_collapse(muse_datacube *aCube, const muse_table *aFilter)
Integrate a FITS NAXIS=3 datacube along the wavelength direction.
muse_image * muse_image_new(void)
Allocate memory for a new muse_image object.
cpl_matrix * muse_matrix_new_gaussian_2d(int aXHalfwidth, int aYHalfwidth, double aSigma)
Create a matrix that contains a normalized 2D Gaussian.
cpl_error_code muse_basicproc_apply_illum(muse_pixtable *aPT, cpl_table *aAttached)
Apply an illum/attached flat-field to a pixel table.
double lambdamax
Maximum wavelength for twilight reconstruction.
cpl_mask * mask
The mask data.
void muse_pixtable_delete(muse_pixtable *aPixtable)
Deallocate memory associated to a pixel table object.
cpl_error_code muse_imagelist_set(muse_imagelist *aList, muse_image *aImage, unsigned int aIdx)
Set the muse_image of given list index.
cpl_error_code muse_pixtable_compute_limits(muse_pixtable *aPixtable)
(Re-)Compute the limits of the coordinate columns of a pixel table.
int muse_quality_image_reject_using_dq(cpl_image *aData, cpl_image *aDQ, cpl_image *aStat)
Reject pixels of one or two images on a DQ image.
muse_ins_mode muse_pfits_get_mode(const cpl_propertylist *aHeaders)
find out the observation mode
muse_imagelist * recimages
the reconstructed image data
cpl_mask * muse_cplmask_adapt_to_image(const cpl_mask *aMask, const cpl_image *aImage)
Adapt mask with masked region in one quadrant to size of an image.
cpl_parameterlist * parameters
cpl_imagelist * stat
the cube containing the data variance
cpl_propertylist * header
The FITS header.
cpl_frameset * muse_frameset_find_tags(const cpl_frameset *aFrames, const cpl_array *aTags, unsigned char aIFU, cpl_boolean aInvert)
return frameset containing data from an IFU/channel with the given tag(s)
const char * resample_s
The resampling technique to use for the final output cube. (as string)