33 #include "muse_cplwrappers.h" 34 #include "muse_data_format_z.h" 35 #include "muse_quality.h" 36 #include "muse_mask.h" 37 #include "muse_pfits.h" 56 {
"lambda", CPL_TYPE_DOUBLE,
"Angstrom",
"%7.2f",
"wavelength", CPL_TRUE},
57 {
"flux", CPL_TYPE_DOUBLE,
"erg/(s cm^2 arcsec^2)",
"%e",
"Flux", CPL_TRUE},
58 { NULL, 0, NULL, NULL, NULL, CPL_FALSE }
71 unsigned count = cpl_imagelist_get_size(aCube->
data);
77 cpl_mask *nmask = cpl_mask_duplicate(aMask);
79 for (i = 0; i < count; i++) {
80 cpl_table_set(spectrum,
"lambda", i, crval3 + (i + 1 - crpix3) * cdelt3);
82 cpl_image *img = cpl_imagelist_get(aCube->
data, i);
83 cpl_mask *bpm = cpl_image_get_bpm(img);
84 cpl_mask_or(bpm, nmask);
85 if (aCube->
dq != NULL) {
86 cpl_image *dq = cpl_imagelist_get(aCube->
dq, i);
87 cpl_mask *dq_mask = cpl_mask_threshold_image_create(dq, -0.5, 0.5);
88 cpl_mask_not(dq_mask);
89 cpl_mask_or(bpm, dq_mask);
90 cpl_mask_delete(dq_mask);
92 double dev = cpl_image_get_stdev(img);
93 double mean = cpl_image_get_mean(img);
94 cpl_table_set(spectrum,
"data", i, mean);
95 cpl_table_set(spectrum,
"stat", i, dev / sqrt(cpl_mask_count(bpm)));
96 cpl_table_set(spectrum,
"dq", i, (cpl_mask_count(bpm) < 3));
98 cpl_mask_delete(nmask);
121 const char *aQCPrefix)
123 cpl_ensure(aImage, CPL_ERROR_NULL_INPUT, NULL);
129 aFraction = aMinFraction + aFraction * (1-aMinFraction);
135 cpl_msg_info(__func__,
"Creating sky mask for pixels between minimum (%g) and" 136 " threshold (%g)", t0, t1);
140 selectedRegions->
mask = cpl_mask_threshold_image_create(aImage->
data, t0, t1);
141 cpl_mask_not(selectedRegions->
mask);
142 cpl_mask_or(selectedRegions->
mask, cpl_image_get_bpm(aImage->
data));
143 cpl_mask_not(selectedRegions->
mask);
146 selectedRegions->
header = cpl_propertylist_duplicate(aImage->
header);
147 char keyword[KEYWORD_LENGTH];
148 snprintf(keyword, KEYWORD_LENGTH,
"%s THRESHOLD", aQCPrefix);
149 cpl_propertylist_append_double(selectedRegions->
header, keyword, t1);
151 return selectedRegions;
170 const cpl_table *aContinuum, cpl_propertylist *aHeader)
172 cpl_ensure_code(aProcessing && aContinuum && aHeader, CPL_ERROR_NULL_INPUT);
175 CPL_FRAME_TYPE_TABLE);
176 cpl_ensure_code(frame, CPL_ERROR_ILLEGAL_INPUT);
177 const char *filename = cpl_frame_get_filename(frame);
178 cpl_error_code rc = cpl_propertylist_save(aHeader, filename, CPL_IO_CREATE);
180 "CONTINUUM", muse_fluxspectrum_def);
181 if (rc == CPL_ERROR_NONE) {
182 #pragma omp critical(muse_processing_output_frames) 183 cpl_frameset_insert(aProcessing->
outframes, frame);
185 cpl_frame_delete(frame);
Structure definition of a MUSE datacube.
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
cpl_image * data
the data extension
cpl_table * muse_sky_spectrum_from_cube(muse_datacube *aCube, const cpl_mask *aMask)
Create a spectrum out of a cube by applying a mask.
Structure definition of MUSE three extension FITS file.
cpl_propertylist * header
the FITS header
cpl_table * muse_cpltable_new(const muse_cpltable_def *aDef, cpl_size aLength)
Create an empty table according to the specified definition.
double muse_pfits_get_crpix(const cpl_propertylist *aHeaders, unsigned int aAxis)
find out the WCS reference point
cpl_frame * muse_processing_new_frame(muse_processing *aProcessing, int aIFU, cpl_propertylist *aHeader, const char *aTag, cpl_frame_type aType)
Create a new frame for a result file.
double muse_cplimage_get_percentile(const cpl_image *aImage, double aFraction)
Get the percentile of an image.
cpl_imagelist * data
the cube containing the actual data values
const muse_cpltable_def muse_fluxspectrum_def[]
Definition of the flux spectrum table structure.
cpl_imagelist * dq
the optional cube containing the bad pixel status
muse_mask * muse_mask_new(void)
Allocate memory for a new muse object.
cpl_propertylist * header
the FITS header
Handling of "mask" files.
cpl_error_code muse_image_reject_from_dq(muse_image *aImage)
Reject pixels of a muse_image depending on its DQ data.
muse_mask * muse_sky_create_skymask(muse_image *aImage, double aMinFraction, double aFraction, const char *aQCPrefix)
Select spaxels to be considered as sky.
cpl_propertylist * header
the FITS header
Definition of a cpl table structure.
cpl_mask * mask
The mask data.
cpl_error_code muse_cpltable_append_file(const cpl_table *aTable, const char *aFile, const char *aExtension, const muse_cpltable_def aDefinition[])
Save a table to disk (into a FITS extension)
cpl_error_code muse_sky_save_continuum(muse_processing *aProcessing, const cpl_table *aContinuum, cpl_propertylist *aHeader)
Save sky continuum table to file.