73#define RECIPE_ID "xsh_mflat"
74#define RECIPE_AUTHOR "P.Goldoni, L.Guglielmi, R. Haigron, F. Royer, D. Bramich, A. Modigliani"
75#define RECIPE_CONTACT "amodigli@eso.org"
90static void xsh_mflat(cpl_parameterlist *, cpl_frameset *);
99"Create the master flat and the orders edges traces table frames";
102"This recipe creates the master flat and the orders edges traces table frames.\n\
104 - [UVB] A set of n RAW frames (Format = RAW, n>=3,\
105 Tag = FLAT_D2_mode_UVB, mode=SLIT/IFU)\n\
106 - [UVB] A set of n RAW frames (Format = RAW, n>=3,\
107 Tag = FLAT_QTH_mode_UVB)\n\
108 - [VIS] A set of n RAW frames (Format = RAW, n>=3,\
109 Tag = FLAT_mode_VIS)\n\
110 - [NIR] A set of n x n RAW frames ((Format = RAW, n>=3,\
111 Tag = FLAT_mode_NIR_ON, FLAT_mode_NIR_OFF)\n\
112 - A spectral format table (Format = PRE, Tag = SPECTRAL_FORMAT_TAB_arm)\n\
113 - An order table (Format = TABLE, Tag = ORDER_TAB_CENTR_arm)\n\
114 - [UVB,VIS] A master bias (Format = PRE, Tag = MASTER_BIAS_arm)\n\
115 - [OPTIONAL] A map of reference bad pixel (Format = QUP,RAW, Tag = BP_MAP_RP_arm)\n\
116 - [OPTIONAL] A map of non linear pixel (Format = QUP,RAW, Tag = BP_MAP_NL_arm)\n\
117 - [OPTIONAL,UVB,VIS] A master dark (Format = PRE, Tag = MASTER_DARK_arm)\n\
119 - An updated order table with edge UP and edge LOW\
120 (Format = TABLE, TAG = ORDER_TAB_EDGES_mode_arm)\n\
121 - A master flat (Format = PRE, PRO.CATG = MASTER_FLAT_mode_arm)\n\
122 - The inter-order background frame (Format = PRE, PRO.CATG = MFLAT_BACK_mode_arm)\n\
123 - The inter-order background sampling points grid table\n\
124 (Format = PRE, PRO.CATG = MFLAT_GRID_BACK_mode_arm)\n\
125 Prepare the flat frames.\n\
126 Stack and sigma clip all the flat frames.\n\
127 Subtract master bias.\n\
128 Subtract master dark.\n\
129 Detect order edge.\n\
130 Subtract background.\n\
131 Create the Master Flat.\n";
148 cpl_recipe *recipe = NULL;
149 cpl_plugin *plugin = NULL;
151 recipe = cpl_calloc(1,
sizeof(*recipe));
152 if ( recipe == NULL ){
156 plugin = &recipe->interface ;
158 cpl_plugin_init(plugin,
161 CPL_PLUGIN_TYPE_RECIPE,
172 cpl_pluginlist_append(list, plugin);
174 return (cpl_error_get_code() != CPL_ERROR_NONE);
190 cpl_recipe *recipe = NULL;
197 assure( plugin != NULL, CPL_ERROR_NULL_INPUT,
"Null plugin");
200 assure( cpl_plugin_get_type(plugin) == CPL_PLUGIN_TYPE_RECIPE,
201 CPL_ERROR_TYPE_MISMATCH,
202 "Plugin is not a recipe");
204 recipe = (cpl_recipe *)plugin;
207 recipe->parameters = cpl_parameterlist_new();
208 assure( recipe->parameters != NULL,
209 CPL_ERROR_ILLEGAL_OUTPUT,
210 "Memory allocation failed!");
221 recipe->parameters));
225 recipe->parameters));
229 recipe->parameters));
232 if ( cpl_error_get_code() != CPL_ERROR_NONE ){
250 cpl_recipe *recipe = NULL;
253 assure( plugin != NULL, CPL_ERROR_NULL_INPUT,
"Null plugin" );
256 assure( cpl_plugin_get_type(plugin) == CPL_PLUGIN_TYPE_RECIPE,
257 CPL_ERROR_TYPE_MISMATCH,
"Plugin is not a recipe");
259 recipe = (cpl_recipe *)plugin;
262 xsh_mflat(recipe->parameters, recipe->frames);
265 if ( cpl_error_get_code() != CPL_ERROR_NONE ) {
285 cpl_recipe *recipe = NULL;
288 assure( plugin != NULL, CPL_ERROR_NULL_INPUT,
"Null plugin" );
291 assure( cpl_plugin_get_type(plugin) == CPL_PLUGIN_TYPE_RECIPE,
292 CPL_ERROR_TYPE_MISMATCH,
"Plugin is not a recipe");
294 recipe = (cpl_recipe *)plugin;
299 if (cpl_error_get_code() != CPL_ERROR_NONE)
311 cpl_frameset *off_set, cpl_frame *bpmap_frame, cpl_frame *master_bias_frame,
312 cpl_frame *master_dark_frame, cpl_frame *cen_order_tab_frame,
314 const int pre_overscan_corr) {
316 cpl_frame *rmdark = NULL;
317 cpl_frameset *onoff_set = NULL;
327 cpl_frameset *sub_bias_set = NULL;
328 cpl_frameset *sub_dark_set = NULL;
329 cpl_frame* frm = NULL;
330 cpl_frame* sub = NULL;
334 if (master_bias_frame != NULL) {
337 sub_bias_set = cpl_frameset_new();
338 nraws = cpl_frameset_get_size(raw_set);
340 for (i = 0; i < nraws; i++) {
341 sprintf(prefix,
"FLAT_SUB_%d_", i);
342 frm = cpl_frameset_get_frame(raw_set, i);
346 pre_overscan_corr, 1);
347 cpl_frameset_insert(sub_bias_set, sub);
350 sub_bias_set = cpl_frameset_duplicate(raw_set);
353 if (master_dark_frame != NULL) {
356 sub_dark_set = cpl_frameset_new();
357 nraws = cpl_frameset_get_size(sub_bias_set);
359 for (i = 0; i < nraws; i++) {
360 sprintf(prefix,
"FLAT_SUBTRACT_DARK_%d.fits", i);
361 frm = cpl_frameset_get_frame(sub_bias_set, i);
364 cpl_frameset_insert(sub_dark_set, sub);
368 sub_dark_set = cpl_frameset_duplicate(sub_bias_set);
402 cpl_frameset *on_set,
403 cpl_frameset *off_set,
404 cpl_frame *bpmap_frame,
405 cpl_frame *master_bias_frame,
406 cpl_frame *master_dark_frame,
407 cpl_frame *cen_order_tab_frame,
408 cpl_frame *qc_cen_order_tab_frame,
411 const int pre_overscan_corr,
412 cpl_frame **edges_order_tab_frame,
419 master_dark_frame,cen_order_tab_frame,
instrument,stack_par,pre_overscan_corr));
428 cen_order_tab_frame, detectorder_par,
instrument));
451 cpl_frame* frame=NULL;
452 const char* name=NULL;
453 cpl_propertylist* plist=NULL;
457 check(frame=cpl_frameset_get_frame(raws,0));
458 check(name=cpl_frame_get_filename(frame));
459 check(plist=cpl_propertylist_load(name,0));
483 return cpl_error_get_code();
493 cpl_parameter* p=NULL;
496 if(cpl_parameter_get_int(p) <= 0) {
505 if(cpl_parameter_get_double(p) <= 0) {
526 if(strcmp(cpl_parameter_get_string(p),
"auto") == 0) {
528 cpl_parameter_set_default_string(p,
"sobel");
530 cpl_parameter_set_default_string(p,
"fixed");
536 return cpl_error_get_code();
545 int nfiles = cpl_frameset_get_size(fset);
547 cpl_array* amax = cpl_array_new(nfiles,CPL_TYPE_DOUBLE);
548 cpl_array* amean = cpl_array_new(nfiles,CPL_TYPE_DOUBLE);
549 cpl_array* amed = cpl_array_new(nfiles,CPL_TYPE_DOUBLE);
551 for (
int f = 0; f < nfiles; f++) {
552 cpl_frame* frm = cpl_frameset_get_frame(fset, f);
553 const char* fname = cpl_frame_get_filename(frm);
554 cpl_image* img = cpl_image_load(fname,CPL_TYPE_DOUBLE,0,0);
555 cpl_propertylist* hdr = cpl_propertylist_load(fname,0);
557 double thresh = 60000.0;
561 cpl_array_set_double(amax,f,cpl_image_get_max(img));
562 cpl_array_set_double(amean,f,cpl_image_get_mean(img));
563 cpl_array_set_double(amed,f,cpl_image_get_median(img));
565 double* idata = cpl_image_get_data_double(img);
567 int nx = cpl_image_get_size_x(img);
568 int ny = cpl_image_get_size_y(img);
569 for(
int i=0;i<
nx*
ny;i++){
570 if(idata[i] > thresh){
578 cpl_image_delete(img);
579 cpl_propertylist_delete(hdr);
583 cpl_propertylist_update_int(qclist,
"ESO QC NUM SAT",nsat_max);
585 cpl_propertylist_update_double(qclist,
"ESO QC RAW MAX AVG",cpl_array_get_max(amax));
586 double ratio = cpl_array_get_stdev(amax);
587 double mean = cpl_array_get_mean(amax);
589 ratio = ratio / mean;
591 cpl_propertylist_update_double(qclist,
"ESO QC RAW MAX STD",ratio);
593 ratio = cpl_array_get_stdev(amed);
594 mean = cpl_array_get_mean(amed);
596 ratio = ratio / mean;
598 cpl_propertylist_update_double(qclist,
"ESO QC MED STD",ratio);
599 ratio = cpl_array_get_stdev(amean);
600 mean = cpl_array_get_mean(amean);
602 ratio = ratio / mean;
604 cpl_propertylist_update_double(qclist,
"ESO QC MEAN STD",ratio);
607 return cpl_error_get_code();
613 cpl_propertylist* qh = cpl_propertylist_load(cpl_frame_get_filename(q),0);
614 cpl_propertylist* dh = cpl_propertylist_load(cpl_frame_get_filename(d),0);
616 if(qh != NULL && cpl_propertylist_has(qh,
"ESO QC FLUX MAX") && cpl_propertylist_has(qh,
"EXPTIME")){
617 double fmax = cpl_propertylist_get_double(qh,
"ESO QC FLUX MAX");
618 double exp = cpl_propertylist_get_double(qh,
"EXPTIME");
620 cpl_propertylist_update_double(qclist,
"ESO QC FLUX NORM1",fmax/exp);
623 if(dh != NULL && cpl_propertylist_has(dh,
"ESO QC FLUX MAX") && cpl_propertylist_has(dh,
"EXPTIME")){
624 double fmax = cpl_propertylist_get_double(dh,
"ESO QC FLUX MAX");
625 double exp = cpl_propertylist_get_double(dh,
"EXPTIME");
627 cpl_propertylist_update_double(qclist,
"ESO QC FLUX NORM2",fmax/exp);
630 cpl_propertylist_delete(qh);
631 cpl_propertylist_delete(dh);
633 return cpl_error_get_code();
640 int nfiles = cpl_frameset_get_size(fset);
641 cpl_array* amax = cpl_array_new(nfiles,CPL_TYPE_DOUBLE);
643 for (
int f = 0; f < nfiles; f++) {
644 cpl_frame* frm = cpl_frameset_get_frame(fset, f);
645 const char* fname = cpl_frame_get_filename(frm);
646 cpl_image* img = cpl_image_load(fname,CPL_TYPE_DOUBLE,0,0);
648 cpl_array_set_double(amax,f,cpl_image_get_max(img));
650 cpl_image_delete(img);
654 cpl_propertylist_update_double(qclist,
"ESO QC RAW 2MAX AVG",cpl_array_get_max(amax));
655 cpl_propertylist_update_double(qclist,
"ESO QC RAW 2MAX STD",cpl_array_get_stdev(amax)/cpl_array_get_mean(amax));
657 return cpl_error_get_code();
710 int xa1 = (int)(x1+0.2*(x2-x1));
711 int xa2 = (int)(x2-0.2*(x2-x1));
714 xa1 = (int)(x1+0.4*(x2-x1));
715 xa2 = (int)(x2-0.4*(x2-x1));
723 cpl_image* dup = cpl_image_duplicate(pre->
data);
725 cpl_image_delete(dup);
744 s1r=cpl_image_get_median_window(pre->
data,1454,1500,1467,1600);
745 s2r=cpl_image_get_median_window(pre->
data,1479,1500,1491,1600);
746 s3r=cpl_image_get_median_window(pre->
data,1503,1500,1516,1600);
748 s1b=cpl_image_get_median_window(pre->
data,515,2330,530,2380);
749 s2b=cpl_image_get_median_window(pre->
data,541,2330,555,2380);
750 s3b=cpl_image_get_median_window(pre->
data,566,2330,579,2380);
752 r2r=cpl_image_get_stdev_window(pre->
data,1479,1500,1491,1600);
753 r2b=cpl_image_get_stdev_window(pre->
data,541,2330,555,2380);
757 s1r=cpl_image_get_median_window(pre->
data,1652,2050,1664,2100);
758 s2r=cpl_image_get_median_window(pre->
data,1674,2050,1684,2100);
759 s3r=cpl_image_get_median_window(pre->
data,1697,2050,1711,2100);
761 s1b=cpl_image_get_median_window(pre->
data,426,2650,444,2757);
762 s2b=cpl_image_get_median_window(pre->
data,452,2650,470,2757);
763 s3b=cpl_image_get_median_window(pre->
data,477,2650,496,2757);
765 r2r=cpl_image_get_stdev_window(pre->
data,1674,2050,1684,2100);
766 r2b=cpl_image_get_stdev_window(pre->
data,452,2650,470,2757);
770 s1r=cpl_image_get_median_window(pre->
data,620,1133,630,1175);
771 s2r=cpl_image_get_median_window(pre->
data,636,1133,646,1175);
772 s3r=cpl_image_get_median_window(pre->
data,653,1133,663,1175);
774 s1b=cpl_image_get_median_window(pre->
data,125,1080,133,1111);
775 s2b=cpl_image_get_median_window(pre->
data,141,1080,150,1111);
776 s3b=cpl_image_get_median_window(pre->
data,158,1080,167,1111);
778 r2r=cpl_image_get_stdev_window(pre->
data,636,1133,646,1175);
779 r2b=cpl_image_get_stdev_window(pre->
data,141,1080,150,1111);
782 cpl_array* bvals = cpl_array_new(3,CPL_TYPE_DOUBLE);
783 cpl_array* rvals = cpl_array_new(3,CPL_TYPE_DOUBLE);
785 cpl_array_set_double(bvals,0,s1b);
786 cpl_array_set_double(bvals,1,s2b);
787 cpl_array_set_double(bvals,2,s3b);
789 cpl_array_set_double(rvals,0,s1r);
790 cpl_array_set_double(rvals,1,s2r);
791 cpl_array_set_double(rvals,2,s3r);
794 double A=(s2r-s2b)/s2r;
803 double RD=((s1r-s3r)/(s1r+s3r))*2.0;
812 double BD=(s1b-s3b)/(s1b+s3b)*2.0;
815 cpl_propertylist_append_double(pre->
data_header,
"ESO QC SLICE RMS",cpl_array_get_stdev(rvals));
816 cpl_propertylist_append_double(pre->
data_header,
"ESO QC SLICE2 RMS",cpl_array_get_stdev(bvals));
818 cpl_propertylist_append_double(pre->
data_header,
"ESO QC SLICE S DIFF",RD);
819 cpl_propertylist_append_double(pre->
data_header,
"ESO QC SLICE2 S DIFF",BD);
821 cpl_propertylist_append_double(pre->
data_header,
"ESO QC FLUX ORDER RATIO",A);
823 cpl_propertylist_append_double(pre->
data_header,
"ESO QC SPEC RMS R",r2r);
824 cpl_propertylist_append_double(pre->
data_header,
"ESO QC SPEC RMS B",r2b);
832 cpl_array_delete(bvals);
833 cpl_array_delete(rvals);
836 xsh_pre_save(pre,cpl_frame_get_filename(mflat),cpl_frame_get_tag(mflat),0);
840 return cpl_error_get_code();
854static void xsh_mflat(cpl_parameterlist* parameters, cpl_frameset* frameset)
856 const char* recipe_tags[1] = {
XSH_FLAT};
857 int recipe_tags_size = 1;
860 cpl_frameset* raws = NULL;
861 cpl_frameset* calib = NULL;
862 cpl_frameset* on = NULL;
863 cpl_frameset* off = NULL;
864 cpl_frameset* qth = NULL;
865 cpl_frameset* d2 = NULL;
868 cpl_frame* spectralformat_frame = NULL;
869 cpl_frame* bpmap = NULL;
870 cpl_frame* master_bias = NULL;
871 cpl_frame* master_dark = NULL;
872 cpl_frame* cen_order_tab_frame = NULL;
874 cpl_frame* edges_order_tab_frame = NULL;
875 cpl_frame* master_flat_frame = NULL;
876 cpl_frame* master_bkg_frame = NULL;
878 cpl_frame *qth_edges_order_tab_frame = NULL;
879 cpl_frame *qth_master_flat_frame = NULL;
880 cpl_frame *d2_edges_order_tab_frame = NULL;
881 cpl_frame* d2_master_flat_frame = NULL;
887 cpl_frame *qth_cen_order_tab_frame = NULL;
888 cpl_frame *d2_cen_order_tab_frame = NULL;
893 cpl_table* grid_tab1=NULL;
894 cpl_table* grid_tab2=NULL;
895 cpl_propertylist* plist=NULL;
896 cpl_frame* rmbackground=NULL;
897 cpl_frame* qth_rmbackground=NULL;
898 cpl_frame* d2_rmbackground=NULL;
899 cpl_frame* grid_backg=NULL;
900 cpl_frame* d2_grid_backg=NULL;
901 cpl_frame* qth_grid_backg=NULL;
902 cpl_frame* frame_backg=NULL;
903 cpl_frame* d2_frame_backg=NULL;
904 cpl_frame* qth_frame_backg=NULL;
905 int pre_overscan_corr=0;
908 cpl_frame *rmdark = NULL;
909 cpl_frame *qth_rmdark = NULL;
910 cpl_frame *d2_rmdark = NULL;
912 cpl_propertylist* qclist = cpl_propertylist_new();
918 recipe_tags, recipe_tags_size,
993 spectralformat_frame));
999 "pre-overscan-corr"));
1002 parameters,parameters));
1021 master_dark, cen_order_tab_frame,
1022 cen_order_tab_frame,stack_par,
1025 &edges_order_tab_frame, &rmdark,
1029 xsh_msg(
"Subtract inter-order background");
1031 edges_order_tab_frame,
1035 &frame_backg,1,1,0));
1041 xsh_msg(
"Detect dead-saturated pixels");
1069 &qth_cen_order_tab_frame, &d2_cen_order_tab_frame,
instrument));
1075 master_dark, qth_cen_order_tab_frame,
1076 cen_order_tab_frame,stack_par,
1079 &qth_edges_order_tab_frame,
1088 master_dark, d2_cen_order_tab_frame,
1089 cen_order_tab_frame,stack_par,
1092 &d2_edges_order_tab_frame,
1104 xsh_msg(
"Subtract inter-order background");
1106 edges_order_tab_frame,
1110 &qth_frame_backg,1,1,0));
1130 xsh_msg(
"name=%s tag=%s",cpl_frame_get_filename(qth_grid_backg),cpl_frame_get_tag(qth_grid_backg));
1148 xsh_msg(
"Subtract inter-order background");
1150 edges_order_tab_frame,
1154 &d2_frame_backg,1,1,0));
1161 sprintf(fname_d2,
"MFLAT_D2_GRID_BACK_%s_%s.fits",
1165 sprintf(fname_qth,
"MFLAT_QTH_GRID_BACK_%s_%s.fits",
1211 xsh_msg(
"name=%s tag=%s",cpl_frame_get_filename(d2_grid_backg),cpl_frame_get_tag(d2_grid_backg));
1223 qth_edges_order_tab_frame,
1224 d2_master_flat_frame,
1225 d2_edges_order_tab_frame,
1226 qth_frame_backg,d2_frame_backg,
1227 &master_flat_frame, &master_bkg_frame,
1235 xsh_msg(
"Detect dead-saturated pixels");
1254 xsh_msg(
"xsh_mflat success!!");
1257 cpl_propertylist_delete(qclist);
cpl_frame * xsh_create_master_flat2(cpl_frameset *set, cpl_frame *order_tab_cen, xsh_stack_param *stack_par, xsh_instrument *inst)
Combine master frames.
cpl_frame * xsh_create_master_flat_with_mask(cpl_frame *frame, cpl_frame *edges, xsh_instrument *instr)
cpl_frame * xsh_detect_order_edge(cpl_frame *frame, cpl_frame *cen_order_tab_frame, xsh_detect_order_param *detectorder_par, xsh_instrument *instrument)
Detect order edges and compute polynomial description of ordermin and order max.
static xsh_instrument * instrument
void xsh_order_split_qth_d2(cpl_frame *order_tab_frame, cpl_frame *spectralformat_frame, cpl_frame **qth_order_tab_frame, cpl_frame **d2_order_tab_frame, xsh_instrument *instr)
xsh_pre * xsh_pre_load(cpl_frame *frame, xsh_instrument *instr)
Load a xsh_pre structure from a frame.
void xsh_pre_free(xsh_pre **pre)
Free a xsh_pre structure.
cpl_frame * xsh_pre_save(const xsh_pre *pre, const char *filename, const char *tag, int temp)
Save PRE on disk.
void xsh_prepare(cpl_frameset *frames, cpl_frame *bpmap, cpl_frame *mbias, const char *prefix, xsh_instrument *instr, const int pre_overscan_corr, const bool flag_neg_and_thresh_pix)
This function transform RAW frames dataset in PRE frames dataset attaching the default bad pixel map ...
#define assure(CONDITION, ERROR_CODE,...)
#define xsh_error_dump(level)
#define xsh_error_reset()
#define XSH_ASSURE_NOT_ILLEGAL_MSG(cond, msg)
cpl_frame * xsh_flat_merge_qth_d2_tabs(cpl_frame *qth_edges_tab, cpl_frame *d2_edges_tab, xsh_instrument *instrument)
Merge two order edges tables according the spectral format.
void xsh_flat_merge_qth_d2(cpl_frame *qth_frame, cpl_frame *qth_order_tab_frame, cpl_frame *d2_frame, cpl_frame *d2_order_tab_frame, cpl_frame *qth_bkg_frame, cpl_frame *d2_bkg_frame, cpl_frame **qth_d2_flat_frame, cpl_frame **qth_d2_bkg_frame, cpl_frame **qth_d2_order_tab_frame, xsh_instrument *instrument)
Merge two master flat fields and order tables according the spectral format.
const char * xsh_instrument_mode_tostring(xsh_instrument *i)
Get the string associated with a mode.
cpl_error_code xsh_instrument_nir_corr_if_JH(cpl_frameset *raws, xsh_instrument *instr)
void xsh_instrument_update_from_spectralformat(xsh_instrument *i, cpl_frame *spectralformat_frame)
const char * xsh_instrument_arm_tostring(xsh_instrument *i)
Get the string associated with an arm.
void xsh_instrument_update_lamp(xsh_instrument *i, XSH_LAMP lamp)
XSH_MODE xsh_instrument_get_mode(xsh_instrument *i)
Get a mode on instrument structure.
XSH_ARM xsh_instrument_get_arm(xsh_instrument *i)
Get an arm on instrument structure.
void xsh_instrument_free(xsh_instrument **instrument)
free an instrument structure
static cpl_error_code xsh_qc_flats_uvb_exp_norm(cpl_frame *q, cpl_frame *d, xsh_instrument *instrument, cpl_propertylist *qclist)
static void xsh_combine_flats_and_detect_edges(cpl_frameset *raw_set, cpl_frameset *on_set, cpl_frameset *off_set, cpl_frame *bpmap_frame, cpl_frame *master_bias_frame, cpl_frame *master_dark_frame, cpl_frame *cen_order_tab_frame, cpl_frame *qc_cen_order_tab_frame, xsh_stack_param *stack_par, xsh_detect_order_param *detectorder_par, const int pre_overscan_corr, cpl_frame **edges_order_tab_frame, cpl_frame **rmdark, xsh_instrument *instrument)
int cpl_plugin_get_info(cpl_pluginlist *list)
Build the list of available plugins, for this module.
static cpl_error_code xsh_params_set_defaults(cpl_parameterlist *pars, xsh_instrument *inst, xsh_detect_order_param *det_order, xsh_background_param *backg)
static cpl_frame * xsh_mflat_combine_flats(cpl_frameset *raw_set, cpl_frameset *on_set, cpl_frameset *off_set, cpl_frame *bpmap_frame, cpl_frame *master_bias_frame, cpl_frame *master_dark_frame, cpl_frame *cen_order_tab_frame, xsh_instrument *instrument, xsh_stack_param *stack_par, const int pre_overscan_corr)
static int xsh_mflat_destroy(cpl_plugin *)
Destroy what has been created by the 'create' function.
static char xsh_mflat_description_short[]
static char xsh_mflat_description[]
static void xsh_mflat(cpl_parameterlist *, cpl_frameset *)
Interpret the command line options and execute the data processing.
static int xsh_mflat_exec(cpl_plugin *)
Execute the plugin instance given by the interface.
static cpl_error_code xsh_qc_flats_raw(cpl_frameset *fset, xsh_instrument *instrument, cpl_propertylist *qclist)
static cpl_error_code xsh_qc_flats_raw_subset(cpl_frameset *fset, xsh_instrument *instrument, cpl_propertylist *qclist)
static cpl_error_code xsh_qc_write_to_flat(cpl_frame *mflat, xsh_instrument *instrument, cpl_propertylist *qclist)
static int xsh_mflat_create(cpl_plugin *)
Setup the recipe options.
static cpl_error_code xsh_params_bin_scale(cpl_frameset *raws, xsh_background_param *backg, xsh_detect_order_param *det_order)
Rescale parameters for binning.
#define xsh_msg_warning(...)
Print an warning message.
#define xsh_msg(...)
Print a message on info level.
int xsh_pfits_get_binx(const cpl_propertylist *plist)
find out the BINX value
int xsh_pfits_get_biny(const cpl_propertylist *plist)
find out the BINY value
cpl_frame * xsh_subtract_background(cpl_frame *frame, cpl_frame *ordertable, xsh_background_param *bckg, xsh_instrument *instr, const char *prefix, cpl_frame **grid_frame, cpl_frame **frame_backg, const int save_bkg, const int save_grid, const int save_sub_bkg)
Subtract the inter-order background from PRE frame.
cpl_frameset * xsh_subtract_nir_on_off(cpl_frameset *on, cpl_frameset *off, xsh_instrument *instr)
(NIR only) subtract the OFF set of files from the On set of files
cpl_frame * xsh_subtract_bias(cpl_frame *frame, cpl_frame *bias, xsh_instrument *instr, const char *type, const int pre_overscan_corr, const int save_tmp)
Subtract the master bias frame from PRE frame.
cpl_frame * xsh_subtract_dark(cpl_frame *frame, cpl_frame *dark, const char *filename, xsh_instrument *instr)
subtract the master dark frame from PRE frame
void xsh_free_parameterlist(cpl_parameterlist **p)
Deallocate a parameter list and set the pointer to NULL.
void xsh_free_frame(cpl_frame **f)
Deallocate a frame and set the pointer to NULL.
void xsh_free_frameset(cpl_frameset **f)
Deallocate a frame set and set the pointer to NULL.
cpl_error_code xsh_monitor_flux(cpl_frame *frm_ima, const cpl_frame *frm_tab, xsh_instrument *instrument, const char *qc_key_prefix)
Monitor Flux level along the orders traces given by an input table
cpl_error_code calc_flat_slit_qc(cpl_image *im, int xa1, int xa2, cpl_propertylist *qclist)
const char * xsh_get_license(void)
Get the pipeline copyright and license.
void xsh_init(void)
Reset library state.
cpl_error_code xsh_begin(cpl_frameset *frames, const cpl_parameterlist *parameters, xsh_instrument **instrument, cpl_frameset **raws, cpl_frameset **calib, const char *tag_list[], int tag_list_size, const char *recipe_id, unsigned int binary_version, const char *short_descr)
Recipe initialization.
void xsh_free_table(cpl_table **t)
Deallocate a table and set the pointer to NULL.
void xsh_free_propertylist(cpl_propertylist **p)
Deallocate a property list and set the pointer to NULL.
cpl_error_code xsh_end(const char *recipe_id, cpl_frameset *frames, cpl_parameterlist *parameters)
Recipe termination.
cpl_propertylist * data_header
void xsh_dfs_split_qth_d2(cpl_frameset *input, cpl_frameset **qth, cpl_frameset **d2)
Extracts QTH and D2 frames from input frameset.
cpl_frame * xsh_find_order_tab_centr(cpl_frameset *frames, xsh_instrument *instr)
Find an order tab CENTR.
void xsh_add_product_pre(cpl_frame *frame, cpl_frameset *frameset, const cpl_parameterlist *parameters, const char *recipe_id, xsh_instrument *instr, cpl_propertylist *qclist)
Add DFS keywords to a product frame.
void xsh_add_product_image(cpl_frame *frame, cpl_frameset *frameset, const cpl_parameterlist *parameters, const char *recipe_id, xsh_instrument *instrument, const char *final_prefix)
void xsh_add_product_table(cpl_frame *frame, cpl_frameset *frameset, const cpl_parameterlist *parameters, const char *recipe_id, xsh_instrument *instrument, const char *final_prefix)
Save Table product (input frame has several extensions, 1 table per extension)
void xsh_dfs_split_nir(cpl_frameset *input, cpl_frameset **on, cpl_frameset **off)
split input RAW NIR sof in ON and OFF
cpl_frame * xsh_find_frame_with_tag(cpl_frameset *frames, const char *tag, xsh_instrument *instr)
Find frame with a given tag.
#define XSH_SPECTRAL_FORMAT
cpl_frame * xsh_check_load_master_bpmap(cpl_frameset *calib, xsh_instrument *inst, const char *rec_id)
cpl_parameter * xsh_parameters_find(cpl_parameterlist *list, const char *recipe_id, const char *name)
find a parameter
void xsh_parameters_pre_overscan(const char *recipe_id, cpl_parameterlist *plist)
void xsh_parameters_stack_create(const char *recipe_id, cpl_parameterlist *list, xsh_stack_param sp)
create the RON determination parameters in a parameters list
xsh_stack_param * xsh_stack_frames_get(const char *recipe_id, cpl_parameterlist *list)
get the detect arclines parameters in a parameters list
cpl_error_code xsh_parameters_decode_bp(const char *recipe_id, cpl_parameterlist *plist, const int ival)
void xsh_parameters_d2_detect_order_create(const char *recipe_id, cpl_parameterlist *list)
Create the d2 detect order parameters in a parameters list.
void xsh_parameters_background_create(const char *recipe_id, cpl_parameterlist *list)
create the subtract background parameters in a parameters list
int xsh_parameters_get_int(const cpl_parameterlist *list, const char *recipe_id, const char *name)
void xsh_parameters_generic(const char *recipe_id, cpl_parameterlist *plist)
cpl_error_code xsh_recipe_params_check(cpl_parameterlist *parameters, xsh_instrument *instrument, const char *rec_id)
xsh_detect_order_param * xsh_parameters_detect_order_get(const char *recipe_id, cpl_parameterlist *list, cpl_parameterlist *drs)
Get the detect orders parameters in a parameters list.
xsh_d2_detect_order_param * xsh_parameters_d2_detect_order_get(const char *recipe_id, cpl_parameterlist *list)
Get the d2 detect orders parameters in a parameters list.
void xsh_parameters_detect_order_create(const char *recipe_id, cpl_parameterlist *list)
Create the detect order parameters in a parameters list.
xsh_background_param * xsh_parameters_background_get(const char *recipe_id, cpl_parameterlist *list)
get the background parameters in a parameters list
#define XSH_FREE(POINTER)
cpl_error_code xsh_image_mflat_detect_blemishes(cpl_frame *flat_frame, xsh_instrument *instrument)
Flag blemishes in a flat image.