35 #include "muse_dark_z.h" 49 #define DARK_HALFSIZE 9 50 #define DARK_NSAMPLES 300 52 muse_dark_qc_header(
muse_image *aImage,
int aBad,
double aNorm,
55 cpl_msg_debug(__func__,
"Adding QC keywords");
60 char *keyword = cpl_sprintf(QC_DARK_PREFIXi
" "QC_BASIC_NSATURATED, k+1);
63 cpl_propertylist_update_int(aImage->
header, keyword, nsaturated);
68 cpl_propertylist_append_int(aImage->
header, QC_DARK_MASTER_NBADPIX, aBad);
70 unsigned stats = CPL_STATS_MEDIAN | CPL_STATS_MEAN | CPL_STATS_STDEV
71 | CPL_STATS_MIN | CPL_STATS_MAX;
73 QC_DARK_MASTER_PREFIX, stats);
76 double dval = 0., derr = 0.;
77 cpl_flux_get_bias_window(aImage->
data, NULL, DARK_HALFSIZE, DARK_NSAMPLES,
81 dval *= 3600. / exptime;
82 derr *= 3600. / exptime;
83 cpl_propertylist_append_float(aImage->
header, QC_DARK_MASTER_DARKVALUE, dval);
84 cpl_propertylist_append_float(aImage->
header, QC_DARK_MASTER_DARKERROR, derr);
87 if (dval < 0. || dval > 10.) {
88 cpl_msg_warning(__func__,
"Could not determine reliable dark current " 89 "(found %.3f+/-%.3f count/pix/h)", dval, derr);
91 cpl_msg_warning(__func__,
"May be due to low dark time (%.2f s)",
98 cpl_msg_info(__func__,
"Dark current is %.3f+/-%.3f count/pix/h",
117 cpl_ensure(images, cpl_error_get_code(), -1);
128 cpl_msg_error(__func__,
"Combining input frames failed!");
138 cpl_msg_info(__func__,
"Normalize master dark image to %.3fs",
140 double f = exptime0 / aParams->
normalize;
142 cpl_propertylist_update_double(masterimage->
header,
"EXPTIME",
144 char *comment = cpl_sprintf(
"[s] Master dark normalized to %.3fs exposure " 146 cpl_propertylist_set_comment(masterimage->
header,
"EXPTIME", comment);
150 muse_dark_qc_header(masterimage, nbad, exptime0, images);
154 MUSE_TAG_MASTER_DARK);
157 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 definition for a collection of muse_images.
void muse_image_delete(muse_image *aImage)
Deallocate memory associated to a muse_image object.
int muse_image_scale(muse_image *aImage, double aScale)
Scale a muse_image with correct treatment of variance.
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.
#define MUSE_WCS_KEYS
regular expression for WCS properties
muse_image * muse_imagelist_get(muse_imagelist *aList, unsigned int aIdx)
Get the muse_image of given list index.
double hotsigma
Sigma level, in terms of median deviation above the median dark level, above which a pixel is detecte...
Structure to hold the parameters of the muse_dark recipe.
muse_combinepar * muse_combinepar_new(cpl_parameterlist *aParameters, const char *aPrefix)
Create a new set of combination parameters.
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.
int muse_quality_dark_badpix(muse_image *aDark, double aSigmaLo, double aSigmaHi)
Find bad (especially hot) pixels (in a master dark).
int nifu
IFU to handle. If set to 0, all IFUs are processed serially. If set to -1, all IFUs are processed in ...
double muse_pfits_get_exptime(const cpl_propertylist *aHeaders)
find out the exposure time
double normalize
Normalize the master dark to this exposure time (in seconds). To disable normalization, set this to a negative value.
Structure of basic processing parameters.
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.