35 #include "muse_bias_z.h" 46 #define RON_HALFSIZE 9 47 #define RON_NSAMPLES 100 61 muse_bias_qc_header(
muse_image *aImage, cpl_bivector *aRON,
64 cpl_ensure_code(aImage && aRON && aList, CPL_ERROR_NULL_INPUT);
65 cpl_msg_debug(__func__,
"Adding QC parameters");
70 char *keyword = cpl_sprintf(QC_BIAS_PREFIXi
" "QC_BASIC_NSATURATED, k+1);
73 cpl_propertylist_update_int(aImage->
header, keyword, nsaturated);
78 cpl_vector *vmedians = cpl_vector_new(aList->
size);
79 const double *ron = cpl_bivector_get_x_data_const(aRON),
80 *ronerr = cpl_bivector_get_y_data_const(aRON);
82 for (n = 1; n <= 4; n++) {
87 char keyword[KEYWORD_LENGTH];
88 snprintf(keyword, KEYWORD_LENGTH, QC_BIAS_MASTER_RON, n);
89 cpl_propertylist_append_float(aImage->
header, keyword, ron[n-1]);
91 snprintf(keyword, KEYWORD_LENGTH, QC_BIAS_MASTER_RONERR, n);
92 cpl_propertylist_append_float(aImage->
header, keyword, ronerr[n-1]);
94 snprintf(keyword, KEYWORD_LENGTH, QC_BIAS_MASTERn_PREFIX, n);
95 unsigned stats = CPL_STATS_MEDIAN | CPL_STATS_MEAN | CPL_STATS_STDEV
96 | CPL_STATS_MIN | CPL_STATS_MAX;
98 keyword, stats, window[0],
99 window[2], window[1], window[3]);
103 snprintf(keyword, KEYWORD_LENGTH, QC_BIAS_MASTER_SLOPEX, n);
104 cpl_propertylist_append_float(aImage->
header, keyword,
105 cpl_vector_get(slopes, 0));
106 snprintf(keyword, KEYWORD_LENGTH, QC_BIAS_MASTER_SLOPEY, n);
107 cpl_propertylist_append_float(aImage->
header, keyword,
108 cpl_vector_get(slopes, 1));
109 cpl_vector_delete(slopes);
114 for (k = 0; k < aList->
size; k++) {
115 snprintf(keyword, KEYWORD_LENGTH, MUSE_HDR_TMP_QUADnMED, n);
118 cpl_vector_set(vmedians, k, val);
120 snprintf(keyword, KEYWORD_LENGTH, QC_BIAS_LEVELi_MEAN, n);
121 cpl_propertylist_update_float(aImage->
header, keyword,
122 cpl_vector_get_mean(vmedians));
123 snprintf(keyword, KEYWORD_LENGTH, QC_BIAS_LEVELi_STDEV, n);
124 cpl_propertylist_update_float(aImage->
header, keyword,
125 cpl_vector_get_stdev(vmedians));
126 snprintf(keyword, KEYWORD_LENGTH, QC_BIAS_LEVELi_MEDIAN, n);
127 cpl_propertylist_update_float(aImage->
header, keyword,
128 cpl_vector_get_median(vmedians));
130 cpl_vector_delete(vmedians);
131 return CPL_ERROR_NONE;
152 cpl_ensure(images, cpl_error_get_code(), -1);
163 cpl_msg_error(__func__,
"Combining input frames failed!");
165 cpl_bivector_delete(bron);
170 muse_bias_qc_header(masterimage, bron, images);
172 cpl_bivector_delete(bron);
176 cpl_propertylist_append_int(masterimage->
header, QC_BIAS_MASTER_NBADPIX,
181 masterimage, MUSE_TAG_MASTER_BIAS);
183 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.
cpl_size * muse_quadrants_get_window(const muse_image *aImage, unsigned char aQuadrant)
Determine the data window of a given quadrant on the CCD.
cpl_image * data
the data extension
double hisigmabadpix
High sigma to find bright columns in the combined bias.
int muse_quality_bad_columns(muse_image *aBias, double aLow, double aHigh)
Find bad columns (in a master bias).
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.
int nifu
IFU to handle. If set to 0, all IFUs are processed serially. If set to -1, all IFUs are processed in ...
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.
double losigmabadpix
Low sigma to find dark columns in the combined bias.
#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.
cpl_error_code muse_basicproc_stats_append_header_window(cpl_image *aImage, cpl_propertylist *aHeader, const char *aPrefix, unsigned aStats, int aX1, int aY1, int aX2, int aY2)
Compute image statistics of an image window and add them to a header.
muse_combinepar * muse_combinepar_new(cpl_parameterlist *aParameters, const char *aPrefix)
Create a new set of combination parameters.
cpl_vector * muse_cplimage_slope_window(const cpl_image *aImage, const cpl_size *aWindow)
Compute slopes of an image, both horizontally and vertically.
int muse_processing_save_image(muse_processing *aProcessing, int aIFU, muse_image *aImage, const char *aTag)
Save a computed MUSE image to disk.
cpl_bivector * muse_imagelist_compute_ron(muse_imagelist *aList, int aHalfsize, int aNSamples)
Compute the read-out noise from bias images in an imagelist.
Structure of basic processing parameters.
Structure to hold the parameters of the muse_bias recipe.
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.