36 #include "muse_skyflat_z.h"
52 cpl_msg_debug(__func__,
"Adding QC keywords");
54 unsigned stats = CPL_STATS_MEDIAN | CPL_STATS_MEAN | CPL_STATS_STDEV
55 | CPL_STATS_MIN | CPL_STATS_MAX;
60 char *keyword = cpl_sprintf(QC_SKYFLAT_PREFIXi, i+1);
62 aImage->
header, keyword, stats);
64 keyword = cpl_sprintf(QC_SKYFLAT_PREFIXi
" "QC_BASIC_NSATURATED, i+1);
67 cpl_propertylist_update_int(aImage->
header, keyword, nsaturated);
72 stats |= CPL_STATS_FLUX;
74 QC_SKYFLAT_MASTER_PREFIX, stats);
94 muse_skyflat_qc_integrate_flux(
muse_image *aImage, cpl_table *aTrace,
97 cpl_msg_debug(__func__,
"Adding flux statistics for QC, from %.1f to %.1f "
102 cpl_detector_interpolate_rejected(aImage->
data);
107 cpl_error_set(__func__, CPL_ERROR_ILLEGAL_INPUT);
119 for (i = 0; i < nslice; i++) {
120 double flux = cpl_table_get_column_mean(slicepts[i]->table,
127 char *keyword = cpl_sprintf(QC_SKYFLAT_MASTER_SLICEj_INTFLUX, i+1);
128 cpl_propertylist_update_float(aImage->
header, keyword, flux);
131 cpl_propertylist_update_float(aImage->
header, QC_SKYFLAT_MASTER_INTFLUX, intflux);
135 return intflux / nint;
151 "muse.muse_skyflat");
154 cpl_ensure(images, cpl_error_get_code(), -1);
157 "muse.muse_skyflat");
161 cpl_msg_error(__func__,
"Combining input frames failed!");
165 cpl_propertylist_erase_regexp(masterimage->
header, MUSE_WCS_KEYS, 0);
167 muse_skyflat_qc_header(masterimage, images);
170 cpl_table *tracetable =
muse_table_load(aProcessing, MUSE_TAG_TRACE_TABLE,
172 cpl_table *wavecaltable =
muse_table_load(aProcessing, MUSE_TAG_WAVECAL_TABLE,
174 if (!tracetable || !wavecaltable) {
175 cpl_msg_error(__func__,
"Calibration could not be loaded:%s%s",
176 !tracetable ?
" "MUSE_TAG_TRACE_TABLE :
"",
177 !wavecaltable ?
" "MUSE_TAG_WAVECAL_TABLE :
"");
180 cpl_table_delete(tracetable);
181 cpl_table_delete(wavecaltable);
184 double mean = muse_skyflat_qc_integrate_flux(masterimage, tracetable,
185 wavecaltable, aParams);
186 cpl_table_delete(tracetable);
187 cpl_table_delete(wavecaltable);
189 cpl_msg_error(__func__,
"Flux integration failed: %s",
190 cpl_error_get_message());
200 cpl_propertylist_erase(masterimage->
header,
"EXPTIME");
206 MUSE_TAG_MASTER_SKYFLAT);
208 return rc == CPL_ERROR_NONE ? 0 : -1;
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 to hold the parameters of the muse_skyflat recipe.
Structure definition for a collection of muse_images.
void muse_image_delete(muse_image *aImage)
Deallocate memory associated to a muse_image object.
void muse_pixtable_extracted_delete(muse_pixtable **aPixtables)
Delete a pixel table array.
int muse_image_scale(muse_image *aImage, double aScale)
Scale a muse_image with correct treatment of variance.
cpl_size muse_pixtable_extracted_get_size(muse_pixtable **aPixtables)
Get the size of an array of extracted pixel tables.
cpl_size muse_pixtable_get_nrow(muse_pixtable *aPixtable)
get the number of rows within the pixel table
muse_pixtable ** muse_pixtable_extracted_get_slices(muse_pixtable *aPixtable)
Extract one pixel table per IFU and slice.
cpl_image * data
the data extension
void muse_imagelist_delete(muse_imagelist *aList)
Free the memory of the MUSE image list.
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.
void muse_basicproc_params_delete(muse_basicproc_params *aBPars)
Free a structure of basic processing parameters.
cpl_propertylist * header
the FITS header
unsigned int muse_imagelist_get_size(muse_imagelist *aList)
Return the number of stored images.
void muse_combinepar_delete(muse_combinepar *aCPars)
Clear the combination parameters.
cpl_error_code muse_pixtable_restrict_wavelength(muse_pixtable *aPixtable, double aLow, double aHigh)
Restrict a pixel table to a certain wavelength range.
Structure definition of MUSE pixel table.
muse_image * muse_imagelist_get(muse_imagelist *aList, unsigned int aIdx)
Get the muse_image of given list index.
muse_combinepar * muse_combinepar_new(cpl_parameterlist *aParameters, const char *aPrefix)
Create a new set of combination parameters.
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.
int muse_processing_save_image(muse_processing *aProcessing, int aIFU, muse_image *aImage, const char *aTag)
Save a computed MUSE image to disk.
cpl_error_code muse_image_reject_from_dq(muse_image *aImage)
Reject pixels of a muse_image depending on its DQ data.
cpl_table * muse_table_load(muse_processing *aProcessing, const char *aTag, unsigned char aIFU)
load a table according to its tag and IFU/channel number
Structure of basic processing parameters.
int normalize
Normalize the master skyflat to the flux integrated over the given wavelength range.
void muse_pixtable_delete(muse_pixtable *aPixtable)
Deallocate memory associated to a pixel table object.
int nifu
IFU to handle. If set to 0, all IFUs are processed serially. If set to -1, all IFUs are processed in ...
double lambdamax
Maximum wavelength to use for flux integration.
double lambdamin
Minimum wavelength to use for flux integration.
cpl_parameterlist * parameters
cpl_error_code muse_basicproc_qc_saturated(muse_image *aImage, const char *aPrefix)
Add QC parameter about saturated pixels to a muse_image.