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]) {
279 kw = cpl_sprintf(MUSE_HDR_FLAT_FLUX_SKY
"%hhu", 23);
280 double flux23 = cpl_propertylist_get_double(pt->
header, kw);
282 cpl_msg_debug(__func__,
"NFM: using flux (%.3g) from CHAN23 for " 283 "normalization (instead of %.3g)", flux23, flux);
287 scale = atof(cpl_array_get_string(scales, nifu - 1));
289 flux = scale * fluxref;
291 scale = flux / fluxref;
293 kw = cpl_sprintf(MUSE_HDR_FLAT_FLUX_SKY
"%hhu", nifu);
294 cpl_propertylist_append_double(pt->
header, kw, flux);
296 cpl_msg_debug(__func__,
"merging pixel table of IFU %2hhu, flux = %e, scale = %f",
302 cpl_propertylist_copy_property_regexp(pt->
header, pts[nifu - 1]->
header,
303 QC_TWILIGHT_REGEXP, 0);
305 kw = cpl_sprintf(QC_TWILIGHTm_INTFLUX, nifu);
306 cpl_propertylist_append_float(pt->
header, kw, flux);
313 cpl_array_delete(scales);
324 cube->
recnames = cpl_array_new(1, CPL_TYPE_STRING);
326 cpl_array_set_string(cube->
recnames, 0,
"white");
360 muse_twilight_image_normalize_and_fit(
muse_image *aImage,
361 unsigned int aXOrder,
362 unsigned int aYOrder,
363 const cpl_mask *aBPM,
364 const cpl_mask *aVign)
366 cpl_ensure(aImage && aImage->
data, CPL_ERROR_NULL_INPUT, NULL);
370 cpl_image_reject_from_mask(aImage->
data, aBPM);
372 cpl_image_reject_value(aImage->
data, CPL_VALUE_NOTFINITE | CPL_VALUE_ZERO);
376 cpl_image *filtered = cpl_image_duplicate(aImage->
data);
377 cpl_mask *mask = cpl_mask_new(5, 7);
379 cpl_errorstate prestate = cpl_errorstate_get();
380 cpl_image_filter_mask(filtered, aImage->
data, mask, CPL_FILTER_MEDIAN,
382 cpl_mask_delete(mask);
383 if (!cpl_errorstate_is_equal(prestate)) {
384 cpl_msg_warning(__func__,
"filtering cube plane failed: %s",
385 cpl_error_get_message());
389 double mean = cpl_image_get_mean(filtered);
390 cpl_msg_debug(__func__,
"mean = %f", mean);
391 cpl_image_multiply_scalar(filtered, 1. / mean);
394 cpl_mask *bpm = cpl_image_get_bpm(filtered);
396 cpl_mask_or(bpm, aVign);
401 mean = cpl_image_get_mean(fit);
402 cpl_msg_debug(__func__,
"mean(fit) = %f", mean);
403 cpl_image_multiply_scalar(fit, 1. / mean);
404 cpl_image_delete(filtered);
422 cubefit->data = cpl_imagelist_new();
423 if (getenv(
"MUSE_TWILIGHT_SKIP")) {
424 char *fn = getenv(
"MUSE_TWILIGHT_SKIP");
426 cpl_msg_warning(__func__,
"Skipping active: loaded previously generated " 427 "cube from \"%s\"", fn);
432 cube->
recnames = cpl_array_new(1, CPL_TYPE_STRING);
435 cpl_array_set_string(cube->
recnames, 0,
"white");
438 strncmp(
"white", cpl_array_get_string(cube->
recnames, 0), 6))) {
442 cpl_array_set_string(cube->
recnames, 0,
"white");
447 aProcessing->
intags, -1, 0);
448 cpl_size iframe, nframes = cpl_frameset_get_size(frames);
449 for (iframe = 0; iframe < nframes; iframe++) {
450 cpl_frame *frame = cpl_frameset_get_position(frames, iframe);
453 cpl_frameset_delete(frames);
454 cpl_msg_warning(__func__,
"Skipping active: faked used frames using only " 456 cpl_frameset_dump(aProcessing->
usedframes, stdout);
458 cubefit->header = cpl_propertylist_duplicate(cube->
header);
461 cpl_error_code rc = CPL_ERROR_NONE;
464 "muse.muse_twilight");
466 "muse.muse_twilight");
472 rp->dlambda = aParams->
dlambda;
476 cube = muse_twilight_reconstruct(aProcessing, aParams, bpars, cpars, rp);
485 cubefit->header = cpl_propertylist_duplicate(cube->
header);
487 MUSE_TAG_CUBE_SKYFLAT,
490 cpl_propertylist_erase_regexp(cubefit->header, QC_TWILIGHT_REGEXP, 0);
499 cpl_error_set_message(__func__, CPL_ERROR_ILLEGAL_OUTPUT,
500 "White-light image is missing!");
504 cpl_image *white = cpl_image_duplicate(wmuse->
data);
505 cpl_image_reject_value(white, CPL_VALUE_NOTFINITE | CPL_VALUE_ZERO);
506 cpl_mask *bpm = cpl_image_get_bpm(white),
507 *bpm2 = cpl_mask_duplicate(bpm);
509 cpl_mask *border = cpl_mask_new(1, cpl_mask_get_size_y(bpm2));
510 cpl_mask_not(border);
511 cpl_mask_copy(bpm2, border, 1, 1);
512 cpl_mask_copy(bpm2, border, cpl_mask_get_size_x(bpm2), 1);
513 cpl_mask_delete(border);
516 cpl_mask *kernel = cpl_mask_new(5, 1);
517 cpl_mask_not(kernel);
518 cpl_mask_filter(bpm2, bpm, kernel, CPL_FILTER_DILATION, CPL_BORDER_NOP);
519 cpl_mask_delete(kernel);
520 bpm = cpl_image_set_bpm(white, bpm2);
521 cpl_mask_delete(bpm);
531 cpl_msg_debug(__func__,
"WFM: use given %s, if any...", MUSE_TAG_VIGN_MASK);
537 cpl_imagelist_get(cube->
data, 0));
538 cpl_mask_delete(maskimage->
mask);
539 maskimage->
mask = mask;
544 cpl_msg_info(__func__,
"NFM: creating internal %s...", MUSE_TAG_VIGN_MASK);
546 int nx = cpl_image_get_size_x(white),
547 ny = cpl_image_get_size_y(white),
550 maskimage->
header = cpl_propertylist_duplicate(cube->
header);
551 maskimage->
mask = cpl_mask_new(nx, ny);
554 for (j = ny - nmasktop; j <= ny; j++) {
556 for (i = 1; i <= nx; i++) {
557 cpl_mask_set(maskimage->
mask, i, j, CPL_BINARY_1);
563 int ipl, npl = cpl_imagelist_get_size(cube->
data);
564 for (ipl = 0; ipl < npl; ipl++) {
565 image->
data = cpl_imagelist_get(cube->
data, ipl);
566 image->
stat = cpl_imagelist_get(cube->
stat, ipl);
567 cpl_mask *vignmask = maskimage ? maskimage->
mask : NULL;
568 cpl_image *fit = muse_twilight_image_normalize_and_fit(image,
572 cpl_imagelist_set(cubefit->data, fit, ipl);
585 cpl_image_delete(whitefit->
dq);
587 cpl_propertylist_update_string(whitefit->
header,
"OBJECT",
588 "white from global fit");
591 cubefit->recnames = cpl_array_new(1, CPL_TYPE_STRING);
592 cpl_array_set_string(cubefit->recnames, 0,
"white_global_fit");
596 double mean = cpl_image_get_mean(white);
597 cpl_image_divide_scalar(white, mean);
598 cpl_image *wdiv = cpl_image_divide_create(white, whitefit->
data);
601 image->
header = cpl_propertylist_new();
602 cpl_propertylist_append_string(image->
header,
"OBJECT",
"normalized " 603 "white-light divided by white global fit");
604 cpl_propertylist_append_string(image->
header,
"BUNIT",
"1");
606 image->
dq = cpl_image_new_from_mask(cpl_image_get_bpm(wdiv));
609 cpl_array_set_size(cubefit->recnames,
610 cpl_array_get_size(cubefit->recnames) + 1);
611 cpl_array_set_string(cubefit->recnames, cpl_array_get_size(cubefit->recnames) - 1,
614 cpl_mask *fovmask = cpl_mask_duplicate(cpl_image_get_bpm(white));
616 bpm = cpl_image_get_bpm(white);
617 cpl_mask_or(bpm, maskimage->
mask);
619 cpl_image_delete(white);
624 cpl_mask *vignmask = cpl_mask_duplicate(fovmask);
625 cpl_mask_not(maskimage->
mask);
626 cpl_mask_or(vignmask, maskimage->
mask);
627 cpl_image *wdiv2 = cpl_image_duplicate(wdiv);
628 cpl_image_reject_from_mask(wdiv2, vignmask);
632 cpl_msg_info(__func__,
"Excluding strong edges (stronger than %.1f%%) " 634 cpl_image *wdivX = cpl_image_duplicate(wdiv2);
635 cpl_mask *wdivXmask = cpl_mask_duplicate(cpl_image_get_bpm(wdivX));
636 cpl_image_fill_rejected(wdivX, 1.);
637 cpl_image_accept_all(wdivX);
638 int i, nx = cpl_image_get_size_x(wdivX),
639 j, ny = cpl_image_get_size_y(wdivX);
641 for (i = 1; i <= nx; i++) {
642 for (j = 2; j <= ny; j++) {
644 double v1 = cpl_image_get(wdivX, i, j - 1, &err),
645 v2 = cpl_image_get(wdivX, i, j, &err);
650 cpl_msg_debug(__func__,
"%03d %03d v1 %f V2 %f --> delta %f",
651 i, j, v1, v2, fabs(v2 - v1));
652 double dv1 = fabs(v1 - 1.),
655 cpl_mask_set(wdivXmask, i, j - 1, CPL_BINARY_1);
657 cpl_mask_set(wdivXmask, i, j, CPL_BINARY_1);
662 for (j = 1; j <= ny; j++) {
663 for (i = 2; i <= nx; i++) {
665 double v1 = cpl_image_get(wdivX, i - 1, j, &err),
666 v2 = cpl_image_get(wdivX, i, j, &err);
671 cpl_msg_debug(__func__,
"%03d %03d v1 %f V2 %f --> delta %f",
672 i, j, v1, v2, fabs(v2 - v1));
673 double dv1 = fabs(v1 - 1.),
676 cpl_mask_set(wdivXmask, i - 1, j, CPL_BINARY_1);
678 cpl_mask_set(wdivXmask, i, j, CPL_BINARY_1);
683 cpl_image_reject_from_mask(wdiv2, wdivXmask);
687 image->
header = cpl_propertylist_new();
688 cpl_propertylist_append_string(image->
header,
"OBJECT",
689 "white-light divided by white global, mask excl edges");
690 cpl_propertylist_append_string(image->
header,
"BUNIT",
"1");
692 image->
dq = cpl_image_new_from_mask(wdivXmask);
693 cpl_mask_delete(wdivXmask);
696 cpl_array_set_size(cubefit->recnames,
697 cpl_array_get_size(cubefit->recnames) + 1);
698 cpl_array_set_string(cubefit->recnames, cpl_array_get_size(cubefit->recnames) - 1,
699 "white_div_global_excl_edges");
703 cpl_image *fit = NULL;
704 if (aParams->
vignsmooth == MUSE_TWILIGHT_PARAM_VIGNSMOOTH_GAUSSIAN) {
714 cpl_msg_info(__func__,
"Running %.1f pix FWHM Gaussian filter...", fwhm);
715 fit = cpl_image_duplicate(wdiv2);
717 int hw = lround(fwhm);
718 hw = hw % 2 ? hw : hw + 1;
719 cpl_msg_debug(__func__,
"using width 2 x %d + 1 for Gaussian matrix", hw);
721 fwhm * CPL_MATH_SIG_FWHM);
722 cpl_errorstate prestate = cpl_errorstate_get();
723 cpl_image_filter(fit, wdiv2, gauss, CPL_FILTER_LINEAR, CPL_BORDER_FILTER);
724 cpl_matrix_delete(gauss);
725 cpl_image_reject_from_mask(fit, cpl_image_get_bpm(wdiv2));
728 cpl_image_threshold(fit, 1., FLT_MAX, 1., FLT_MAX);
731 cpl_image_threshold(fit, -FLT_MAX, 1., -FLT_MAX, 1.);
733 if (!cpl_errorstate_is_equal(prestate)) {
734 cpl_msg_warning(__func__,
"filtering vignetted area failed: %s",
735 cpl_error_get_message());
737 }
else if (aParams->
vignsmooth == MUSE_TWILIGHT_PARAM_VIGNSMOOTH_MEDIAN) {
745 cpl_msg_info(__func__,
"Running %dx%d median filter...",
747 fit = cpl_image_duplicate(wdiv2);
750 cpl_errorstate prestate = cpl_errorstate_get();
751 cpl_image_filter_mask(fit, wdiv2, mask, CPL_FILTER_MEDIAN,
753 cpl_mask_delete(mask);
756 cpl_image_threshold(fit, 1., FLT_MAX, 1., FLT_MAX);
758 cpl_image_threshold(fit, -FLT_MAX, 1., -FLT_MAX, 1.);
760 if (!cpl_errorstate_is_equal(prestate)) {
761 cpl_msg_warning(__func__,
"filtering vignetted ared failed: %s",
762 cpl_error_get_message());
771 cpl_msg_info(__func__,
"Running polyfit (orders %dx%d) ...",
776 cpl_image *wdiv3 = cpl_image_duplicate(wdiv2);
778 cpl_image_threshold(wdiv3, 1., FLT_MAX, 1., FLT_MAX);
780 cpl_image_threshold(wdiv3, -FLT_MAX, 1., -FLT_MAX, 1.);
786 cpl_image_delete(wdiv3);
788 cpl_image_threshold(fit, 1., FLT_MAX, 1., FLT_MAX);
790 cpl_image_threshold(fit, -FLT_MAX, 1., -FLT_MAX, 1.);
796 cpl_image_reject_from_mask(fit, vignmask);
801 cpl_mask *mask = cpl_mask_duplicate(maskimage->
mask);
804 int j, nx = cpl_mask_get_size_x(mask),
805 ny = cpl_mask_get_size_y(mask);
806 double maxval = -DBL_MAX;
807 for (j = ny; j >= 1; j--) {
808 int nmasked = cpl_mask_count_window(mask, 1, j, nx, j);
812 double avg = cpl_image_get_mean_window(fit, 1, j, nx, j),
813 stdev = cpl_image_get_stdev_window(fit, 1, j, nx, j),
814 median = cpl_image_get_median_window(fit, 1, j, nx, j);
815 cpl_msg_debug(__func__,
"row %d (%d): %.5f +/- %.5f (%.5f)", j, nmasked,
820 if (fabs(maxval - 1.) < 0.1 && avg < maxval) {
821 cpl_msg_debug(__func__,
" (below max, removing from mask)");
823 for (i = 1; i <= nx; i++) {
824 cpl_mask_set(mask, i, j, CPL_BINARY_0);
830 cpl_image_reject_from_mask(fit, mask);
831 cpl_mask_delete(mask);
835 cpl_image_fill_rejected(fit, 1.);
839 image->
header = cpl_propertylist_new();
840 cpl_propertylist_append_string(image->
header,
"OBJECT",
"vignetting fit");
842 cpl_propertylist_append_string(image->
header,
"BUNIT",
"");
844 image->
dq = cpl_image_new_from_mask(cpl_image_get_bpm(fit));
847 cpl_array_set_size(cubefit->recnames,
848 cpl_array_get_size(cubefit->recnames) + 1);
849 cpl_array_set_string(cubefit->recnames, cpl_array_get_size(cubefit->recnames) - 1,
854 image->
header = cpl_propertylist_new();
855 cpl_propertylist_append_string(image->
header,
"OBJECT",
856 "white image corrected by vignetting fit");
858 cpl_propertylist_append_string(image->
header,
"BUNIT",
"count");
859 image->
data = cpl_image_divide_create(wdiv2, fit);
860 image->
dq = cpl_image_new_from_mask(cpl_image_get_bpm(image->
data));
863 cpl_array_set_size(cubefit->recnames,
864 cpl_array_get_size(cubefit->recnames) + 1);
865 cpl_array_set_string(cubefit->recnames, cpl_array_get_size(cubefit->recnames) - 1,
867 cpl_image_delete(wdiv2);
870 cpl_msg_info(__func__,
"Combining smooth field of view and vignetted region" 871 " in %d planes", npl);
872 for (ipl = 0; ipl < npl; ipl++) {
873 cpl_image *cimage = cpl_imagelist_get(cubefit->data, ipl);
874 cpl_image_accept_all(cimage);
875 double mean1 = cpl_image_get_mean(cimage);
876 cpl_image_multiply(cimage, fit);
879 cpl_image_accept_all(cimage);
880 double mean2 = cpl_image_get_mean(cimage);
881 cpl_image_multiply_scalar(cimage, 1. / mean2);
882 double mean3 = cpl_image_get_mean(cimage);
883 if (fabs(mean3 - 1.) > FLT_EPSILON) {
884 cpl_msg_warning(__func__,
"normalization failed in plane %d: mean(" 885 "plane) = %f -> %f -> %f", ipl + 1, mean1, mean2, mean3);
888 cpl_mask_delete(vignmask);
890 cpl_mask_delete(fovmask);
894 MUSE_TAG_TWILIGHT_CUBE,
898 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...
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.
int vignnfmmask
The height of the vignetted region at the top of the MUSE field in NFM. This is the region modeled se...
Structure definition for a collection of muse_images.
void muse_image_delete(muse_image *aImage)
Deallocate memory associated to a muse_image object.
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.
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 (for WFM...
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.
muse_mask * muse_mask_new(void)
Allocate memory for a new muse object.
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.
cpl_propertylist * header
the FITS header
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)