30#include "cr2res_utils.h"
31#include "cr2res_calib.h"
32#include "cr2res_pfits.h"
33#include "cr2res_dfs.h"
34#include "cr2res_bpm.h"
35#include "cr2res_trace.h"
36#include "cr2res_extract.h"
44#define RECIPE_STRING "cr2res_obs_2d"
50int cpl_plugin_get_info(cpl_pluginlist * list);
56static hdrl_image ** cr2res_obs_2d_average_sky(
57 const cpl_frameset * skyframes) ;
58static int cr2res_obs_2d_check_inputs_validity(
59 const cpl_frame * rawframe) ;
60static int cr2res_obs_2d_reduce(
61 const cpl_frame * rawframe_obj,
62 const cpl_frame * rawframe_sky,
63 const hdrl_image ** sky_average,
64 const cpl_frame * trace_wave_frame,
65 const cpl_frame * detlin_frame,
66 const cpl_frame * master_dark_frame,
67 const cpl_frame * master_flat_frame,
68 const cpl_frame * bpm_frame,
69 int subtract_nolight_rows,
70 int subtract_interorder_column,
75 hdrl_image ** calibrated,
77 cpl_propertylist ** ext_plist) ;
78static int cr2res_obs_2d_create(cpl_plugin *);
79static int cr2res_obs_2d_exec(cpl_plugin *);
80static int cr2res_obs_2d_destroy(cpl_plugin *);
81static int cr2res_obs_2d(cpl_frameset *,
const cpl_parameterlist *);
87static char cr2res_obs_2d_description[] =
"\
89 This recipe is meant for extended objects. In each trace, the pixels \n\
90 are calibrated, and stored in the output table. \n\
93 raw.fits " CR2RES_OBS_2D_OBJECT_RAW
" [1 to n] \n\
94 and " CR2RES_OBS_2D_SKY_RAW
" [0 to n] \n\
95 trace.fits " CR2RES_CAL_FLAT_TW_PROCATG
" [1] \n\
96 or " CR2RES_CAL_FLAT_TW_MERGED_PROCATG
" \n\
97 or " CR2RES_UTIL_TRACE_TW_PROCATG
" \n\
98 or " CR2RES_UTIL_WAVE_TW_PROCATG
" \n\
99 or " CR2RES_CAL_WAVE_TW_PROCATG
" \n\
100 or " CR2RES_UTIL_SLIT_CURV_TW_PROCATG
" \n\
101 detlin.fits " CR2RES_CAL_DETLIN_COEFFS_PROCATG
" [0 to 1] \n\
102 bpm.fits " CR2RES_CAL_DARK_BPM_PROCATG
" [0 to 1] \n\
103 or " CR2RES_CAL_FLAT_BPM_PROCATG
" \n\
104 or " CR2RES_CAL_DETLIN_BPM_PROCATG
" \n\
105 or " CR2RES_UTIL_BPM_MERGE_PROCATG
" \n\
106 or " CR2RES_UTIL_BPM_SPLIT_PROCATG
" \n\
107 master_dark.fits " CR2RES_CAL_DARK_MASTER_PROCATG
" [0 to 1] \n\
108 master_flat.fits " CR2RES_CAL_FLAT_MASTER_PROCATG
" [0 to 1] \n\
111 cr2res_obs_2d_frame_<nb>_extracted.fits "
112 CR2RES_OBS_2D_EXTRACT_PROCATG
"\n\
113 cr2res_obs_2d_frame_<nb>_calibrated.fits "
114 CR2RES_OBS_2D_CALIBRATED_PROCATG
"\n\
117 loop on raw frames f: \n\
118 loop on detectors d: \n\
119 cr2res_obs_2d_reduce() \n\
123 cr2res_obs_2d_reduce() \n\
124 Load the input image \n\
125 Apply the calibrations to the image \n\
126 Load the trace wave table \n\
127 Call cr2res_extract2d_traces() \n\
130 Library Functions used \n\
131 cr2res_io_find_TRACE_WAVE() \n\
132 cr2res_io_find_BPM() \n\
133 cr2res_obs_2d_reduce() \n\
134 cr2res_obs_2d_check_inputs_validity() \n\
135 cr2res_pfits_get_dit() \n\
136 cr2res_io_load_image() \n\
137 cr2res_calib_image() \n\
138 cr2res_io_load_TRACE_WAVE() \n\
139 cr2res_extract2d_traces() \n\
140 cr2res_io_save_EXTRACT_2D() \n\
141 cr2res_io_save_CALIBRATED() \n\
159int cpl_plugin_get_info(cpl_pluginlist * list)
161 cpl_recipe * recipe = cpl_calloc(1,
sizeof *recipe );
162 cpl_plugin * plugin = &recipe->interface;
164 if (cpl_plugin_init(plugin,
166 CR2RES_BINARY_VERSION,
167 CPL_PLUGIN_TYPE_RECIPE,
169 "2D Observation recipe",
170 cr2res_obs_2d_description,
171 CR2RES_PIPELINE_AUTHORS,
174 cr2res_obs_2d_create,
176 cr2res_obs_2d_destroy)) {
177 cpl_msg_error(cpl_func,
"Plugin initialization failed");
178 (void)cpl_error_set_where(cpl_func);
182 if (cpl_pluginlist_append(list, plugin)) {
183 cpl_msg_error(cpl_func,
"Error adding plugin to list");
184 (void)cpl_error_set_where(cpl_func);
200static int cr2res_obs_2d_create(cpl_plugin * plugin)
202 cpl_recipe * recipe ;
206 if (cpl_plugin_get_type(plugin) == CPL_PLUGIN_TYPE_RECIPE)
207 recipe = (cpl_recipe *)plugin;
212 recipe->parameters = cpl_parameterlist_new();
215 p = cpl_parameter_new_value(
"cr2res.cr2res_obs_2d.subtract_nolight_rows",
217 "Subtract median row from baffled region at detector bottom",
218 "cr2res.cr2res_obs_2d", FALSE);
219 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI,
"subtract_nolight_rows");
220 cpl_parameter_disable(p, CPL_PARAMETER_MODE_ENV);
221 cpl_parameterlist_append(recipe->parameters, p);
223 p = cpl_parameter_new_value(
224 "cr2res.cr2res_obs_2d.subtract_interorder_column", CPL_TYPE_BOOL,
225 "Subtract column-by-column fit to the pixel values between"
227 "cr2res.cr2res_obs_2d", TRUE);
228 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI,
229 "subtract_interorder_column");
230 cpl_parameter_disable(p, CPL_PARAMETER_MODE_ENV);
231 cpl_parameterlist_append(recipe->parameters, p);
233 p = cpl_parameter_new_value(
"cr2res.cr2res_obs_2d.cosmics",
234 CPL_TYPE_BOOL,
"Find and mark cosmic rays hits as bad",
235 "cr2res.cr2res_obs_2d", FALSE);
236 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI,
"cosmics");
237 cpl_parameter_disable(p, CPL_PARAMETER_MODE_ENV);
238 cpl_parameterlist_append(recipe->parameters, p);
240 p = cpl_parameter_new_value(
"cr2res.cr2res_obs_2d.detector",
241 CPL_TYPE_INT,
"Only reduce the specified detector",
242 "cr2res.cr2res_obs_2d", 0);
243 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI,
"detector");
244 cpl_parameter_disable(p, CPL_PARAMETER_MODE_ENV);
245 cpl_parameterlist_append(recipe->parameters, p);
247 p = cpl_parameter_new_value(
"cr2res.cr2res_obs_2d.order",
248 CPL_TYPE_INT,
"Only reduce the specified order",
249 "cr2res.cr2res_obs_2d", -1);
250 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI,
"order");
251 cpl_parameter_disable(p, CPL_PARAMETER_MODE_ENV);
252 cpl_parameterlist_append(recipe->parameters, p);
254 p = cpl_parameter_new_value(
"cr2res.cr2res_obs_2d.trace_nb",
255 CPL_TYPE_INT,
"Only reduce the specified trace number",
256 "cr2res.cr2res_obs_2d", -1);
257 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI,
"trace_nb");
258 cpl_parameter_disable(p, CPL_PARAMETER_MODE_ENV);
259 cpl_parameterlist_append(recipe->parameters, p);
271static int cr2res_obs_2d_exec(cpl_plugin * plugin)
276 if (cpl_plugin_get_type(plugin) == CPL_PLUGIN_TYPE_RECIPE)
277 recipe = (cpl_recipe *)plugin;
280 return cr2res_obs_2d(recipe->frames, recipe->parameters);
290static int cr2res_obs_2d_destroy(cpl_plugin * plugin)
295 if (cpl_plugin_get_type(plugin) == CPL_PLUGIN_TYPE_RECIPE)
296 recipe = (cpl_recipe *)plugin;
299 cpl_parameterlist_delete(recipe->parameters);
311static int cr2res_obs_2d(
312 cpl_frameset * frameset,
313 const cpl_parameterlist * parlist)
315 const cpl_parameter * param ;
316 int reduce_det, reduce_order, reduce_trace, cosmics,
317 subtract_nolight_rows, subtract_interorder_column ;
318 cpl_frameset * rawframes_obj ;
319 cpl_frameset * used_frameset ;
320 cpl_frameset * rawframes_sky ;
321 cpl_frame * rawframe_sky ;
322 const cpl_frame * detlin_frame ;
323 const cpl_frame * master_dark_frame ;
324 const cpl_frame * master_flat_frame ;
325 const cpl_frame * bpm_frame ;
326 const cpl_frame * trace_wave_frame ;
327 hdrl_image ** sky_average ;
328 cpl_propertylist * qc_main ;
329 cpl_propertylist * ext_plist[CR2RES_NB_DETECTORS] ;
330 hdrl_image * calibrated[CR2RES_NB_DETECTORS] ;
331 cpl_table * extract[CR2RES_NB_DETECTORS] ;
333 cpl_table * eop_table ;
334 cpl_propertylist * plist ;
335 double ra, dec, mjd_obs, mjd_cen, geolon, geolat, geoelev,
337 cpl_size nsky, nobj ;
343 param = cpl_parameterlist_find_const(parlist,
344 "cr2res.cr2res_obs_2d.detector");
345 reduce_det = cpl_parameter_get_int(param);
346 param = cpl_parameterlist_find_const(parlist,
347 "cr2res.cr2res_obs_2d.subtract_nolight_rows");
348 subtract_nolight_rows = cpl_parameter_get_bool(param);
349 param = cpl_parameterlist_find_const(parlist,
350 "cr2res.cr2res_obs_2d.subtract_interorder_column");
351 subtract_interorder_column = cpl_parameter_get_bool(param);
352 param = cpl_parameterlist_find_const(parlist,
353 "cr2res.cr2res_obs_2d.cosmics");
354 cosmics = cpl_parameter_get_bool(param);
355 param = cpl_parameterlist_find_const(parlist,
356 "cr2res.cr2res_obs_2d.order");
357 reduce_order = cpl_parameter_get_int(param);
358 param = cpl_parameterlist_find_const(parlist,
359 "cr2res.cr2res_obs_2d.trace_nb");
360 reduce_trace = cpl_parameter_get_int(param);
364 cpl_msg_error(__func__,
"Cannot identify RAW and CALIB frames") ;
365 cpl_error_set(__func__, CPL_ERROR_ILLEGAL_INPUT) ;
371 if (trace_wave_frame == NULL) {
372 cpl_msg_error(__func__,
"Could not find TRACE_WAVE frame") ;
375 detlin_frame = cpl_frameset_find_const(frameset,
376 CR2RES_CAL_DETLIN_COEFFS_PROCATG);
377 master_dark_frame = cpl_frameset_find_const(frameset,
378 CR2RES_CAL_DARK_MASTER_PROCATG) ;
379 master_flat_frame = cpl_frameset_find_const(frameset,
380 CR2RES_CAL_FLAT_MASTER_PROCATG) ;
385 if (rawframes_obj == NULL) {
386 cpl_msg_error(__func__,
"Could not find RAW frames") ;
389 nobj = cpl_frameset_get_size(rawframes_obj) ;
398 if (rawframes_sky == NULL) {
401 nsky = cpl_frameset_get_size(rawframes_sky);
405 cpl_msg_info(__func__,
"No Sky Correction") ;
406 if (rawframes_sky != NULL) cpl_frameset_delete(rawframes_sky) ;
407 rawframes_sky = NULL ;
409 }
else if (nsky > 0 && nsky != nobj) {
410 cpl_msg_info(__func__,
"Sky Correction using Average") ;
412 sky_average = cr2res_obs_2d_average_sky(rawframes_sky) ;
413 if (rawframes_sky != NULL) cpl_frameset_delete(rawframes_sky) ;
414 rawframes_sky = NULL ;
415 }
else if (nsky == nobj) {
416 cpl_msg_info(__func__,
"Sky Correction using Individual Frames") ;
420 if (rawframes_sky != NULL) cpl_frameset_delete(rawframes_sky) ;
421 rawframes_sky = NULL ;
425 for (i = 0; i < cpl_frameset_get_size(rawframes_obj); i++) {
426 cpl_frame *rawframe_obj;
428 rawframe_obj = cpl_frameset_get_position(rawframes_obj, i);
430 cpl_msg_info(__func__,
"Process Frame %s",
431 cpl_frame_get_filename(rawframe_obj)) ;
432 cpl_msg_indent_more() ;
435 if (rawframes_sky != NULL) {
436 rawframe_sky = cpl_frameset_get_position(rawframes_sky, i);
437 cpl_msg_info(__func__,
"Use SKY Frame %s",
438 cpl_frame_get_filename(rawframe_sky)) ;
440 rawframe_sky = NULL ;
444 for (det_nr=1 ; det_nr<=CR2RES_NB_DETECTORS ; det_nr++) {
446 calibrated[det_nr-1] = NULL ;
447 extract[det_nr-1] = NULL ;
448 ext_plist[det_nr-1] = NULL ;
451 if (reduce_det != 0 && det_nr != reduce_det) continue ;
453 cpl_msg_info(__func__,
"Process Detector %d", det_nr) ;
454 cpl_msg_indent_more() ;
457 if (cr2res_obs_2d_reduce(rawframe_obj, rawframe_sky,
458 (
const hdrl_image**)sky_average,
459 trace_wave_frame, detlin_frame, master_dark_frame,
460 master_flat_frame, bpm_frame, subtract_nolight_rows,
461 subtract_interorder_column, cosmics, det_nr,
462 reduce_order, reduce_trace,
463 &(calibrated[det_nr-1]),
464 &(extract[det_nr-1]),
465 &(ext_plist[det_nr-1])) == -1) {
466 cpl_msg_warning(__func__,
"Failed to reduce detector %d",
470 cpl_msg_indent_less() ;
472 cpl_msg_indent_less() ;
477 qc_main = cpl_propertylist_new();
478 cpl_propertylist_append_double(qc_main,
479 CR2RES_HEADER_DRS_TMID,
484 if (eop_table != NULL) {
485 plist=cpl_propertylist_load(cpl_frame_get_filename(
486 cpl_frameset_get_position_const(rawframes_obj, 0)), 0) ;
488 ra = cpl_propertylist_get_double(plist,
"RA") ;
489 dec = cpl_propertylist_get_double(plist,
"DEC") ;
490 mjd_obs = cpl_propertylist_get_double(plist,
"MJD-OBS") ;
491 geolon = cpl_propertylist_get_double(plist,
"ESO TEL GEOLON") ;
492 geolat = cpl_propertylist_get_double(plist,
"ESO TEL GEOLAT") ;
493 geoelev = cpl_propertylist_get_double(plist,
"ESO TEL GEOELEV") ;
495 cpl_propertylist_delete(plist) ;
498 if (!cpl_error_get_code()) {
501 (mjd_cen-mjd_obs)*24*3600, geolon, geolat, geoelev,
502 0.0, 0.0, 0.0, 0.0, &barycorr);
504 cpl_msg_info(__func__,
"Barycentric correction: %g m/s",
507 cpl_msg_info(__func__,
"Cannot derive Barycentric correction");
510 cpl_table_delete(eop_table) ;
511 cpl_propertylist_append_double(qc_main, CR2RES_HEADER_DRS_BARYCORR,
516 cpl_propertylist_append_int(qc_main,
517 CR2RES_HEADER_QC_NUMSAT,
521 used_frameset = cpl_frameset_new() ;
522 cpl_frameset_insert(used_frameset, cpl_frame_duplicate(rawframe_obj)) ;
523 if (rawframe_sky != NULL)
524 cpl_frameset_insert(used_frameset,
525 cpl_frame_duplicate(rawframe_sky)) ;
526 if (trace_wave_frame!= NULL)
527 cpl_frameset_insert(used_frameset,
528 cpl_frame_duplicate(trace_wave_frame)) ;
529 if (detlin_frame!= NULL)
530 cpl_frameset_insert(used_frameset,
531 cpl_frame_duplicate(detlin_frame)) ;
532 if (master_dark_frame!= NULL)
533 cpl_frameset_insert(used_frameset,
534 cpl_frame_duplicate(master_dark_frame)) ;
535 if (master_flat_frame!= NULL)
536 cpl_frameset_insert(used_frameset,
537 cpl_frame_duplicate(master_flat_frame)) ;
538 if (bpm_frame!= NULL)
539 cpl_frameset_insert(used_frameset,
540 cpl_frame_duplicate(bpm_frame)) ;
543 out_file = cpl_sprintf(
"%s_frame_%d_calibrated.fits",
544 RECIPE_STRING, i+1) ;
546 calibrated, qc_main, ext_plist,
547 CR2RES_OBS_2D_CALIBRATED_PROCATG, RECIPE_STRING) ;
551 out_file = cpl_sprintf(
"%s_frame_%d_extracted.fits",
552 RECIPE_STRING, i+1) ;
554 extract, qc_main, ext_plist, CR2RES_OBS_2D_EXTRACT_PROCATG,
557 cpl_frameset_delete(used_frameset);
560 cpl_propertylist_delete(qc_main) ;
561 for (det_nr=1 ; det_nr<=CR2RES_NB_DETECTORS ; det_nr++) {
562 if (calibrated[det_nr-1] != NULL)
564 if (extract[det_nr-1] != NULL)
565 cpl_table_delete(extract[det_nr-1]) ;
566 if (ext_plist[det_nr-1] != NULL)
567 cpl_propertylist_delete(ext_plist[det_nr-1]) ;
569 cpl_msg_indent_less() ;
571 cpl_frameset_delete(rawframes_obj) ;
572 if (sky_average != NULL) {
573 for (det_nr=1 ; det_nr<=CR2RES_NB_DETECTORS ; det_nr++)
574 if (sky_average[det_nr-1] != NULL)
576 cpl_free(sky_average) ;
578 if (rawframes_sky != NULL) cpl_frameset_delete(rawframes_sky) ;
580 return (
int)cpl_error_get_code();
606static int cr2res_obs_2d_reduce(
607 const cpl_frame * rawframe_obj,
608 const cpl_frame * rawframe_sky,
609 const hdrl_image ** sky_average,
610 const cpl_frame * trace_wave_frame,
611 const cpl_frame * detlin_frame,
612 const cpl_frame * master_dark_frame,
613 const cpl_frame * master_flat_frame,
614 const cpl_frame * bpm_frame,
615 int subtract_nolight_rows,
616 int subtract_interorder_column,
621 hdrl_image ** calibrated,
622 cpl_table ** extract,
623 cpl_propertylist ** ext_plist)
626 hdrl_image * in_calib ;
627 hdrl_image * in_sky ;
628 hdrl_image * in_sky_calib ;
629 cpl_table * trace_wave ;
630 cpl_propertylist * plist ;
631 double dit, dit_sky ;
633 cpl_table * extracted ;
634 int * order_idx_values ;
635 int nb_order_idx_values, order_zp;
638 if (extract == NULL || calibrated == NULL || ext_plist == NULL ||
639 rawframe_obj == NULL || trace_wave_frame == NULL)
return -1 ;
642 if (cr2res_obs_2d_check_inputs_validity(rawframe_obj) != 1) {
643 cpl_msg_error(__func__,
"Invalid Inputs") ;
648 if ((plist = cpl_propertylist_load(cpl_frame_get_filename(trace_wave_frame),
650 cpl_msg_error(__func__,
"Cannot read the ORDER_ZP from the input TW") ;
653 order_zp = cr2res_pfits_get_order_zp(plist) ;
654 cpl_propertylist_delete(plist) ;
655 if (cpl_error_get_code()) {
656 cpl_msg_error(__func__,
"Missing ORDER_ZP in the header - Skip") ;
663 plist = cpl_propertylist_load(cpl_frame_get_filename(rawframe_obj), 0) ;
666 cpl_propertylist_delete(plist);
667 if (cpl_error_get_code()) {
668 cpl_msg_error(__func__,
"Cannot read the DIT & NDIT") ;
671 cpl_msg_debug(__func__,
"DIT value : %g", dit) ;
675 reduce_det)) == NULL) {
676 cpl_msg_error(__func__,
"Cannot load image") ;
682 subtract_nolight_rows, subtract_interorder_column, cosmics,
683 master_flat_frame, master_dark_frame, bpm_frame,
684 detlin_frame, dit, ndit)) == NULL) {
685 cpl_msg_error(__func__,
"Failed to apply the calibrations") ;
692 if (sky_average != NULL && sky_average[reduce_det-1] != NULL) {
695 }
else if (rawframe_sky != NULL) {
699 plist = cpl_propertylist_load(cpl_frame_get_filename(rawframe_sky), 0) ;
702 cpl_propertylist_delete(plist);
703 if (cpl_error_get_code()) {
704 cpl_msg_error(__func__,
"Cannot read the DIT from the sky") ;
708 cpl_msg_debug(__func__,
"SKY DIT value : %g", dit) ;
712 reduce_det)) == NULL) {
713 cpl_msg_error(__func__,
"Cannot load sky image") ;
720 subtract_nolight_rows, subtract_interorder_column, cosmics,
721 master_flat_frame, master_dark_frame, bpm_frame, detlin_frame,
722 dit_sky, ndit_sky)) == NULL) {
723 cpl_msg_error(__func__,
724 "Failed to apply the calibrations to SKY") ;
735 cpl_msg_warning(__func__,
"No Sky Correction") ;
739 cpl_msg_info(__func__,
"Load the TRACE WAVE") ;
741 cpl_frame_get_filename(trace_wave_frame),
742 reduce_det)) == NULL) {
743 cpl_msg_error(__func__,
"Failed to Load the traces file") ;
749 cpl_msg_info(__func__,
"Spectra Extraction 2D") ;
751 reduce_trace, &extracted) == -1) {
752 cpl_msg_error(__func__,
"Failed to extract");
754 cpl_table_delete(trace_wave) ;
759 plist = cpl_propertylist_load(
760 cpl_frame_get_filename(rawframe_obj),
771 &nb_order_idx_values);
774 for (i = 0; i < nb_order_idx_values; i++) {
775 int order_real, order_idx, order_idxp;
777 order_idx = order_idx_values[i] ;
780 key_name = cpl_sprintf(CR2RES_HEADER_QC_REAL_ORDER, order_idxp) ;
781 cpl_propertylist_append_int(plist, key_name, order_real) ;
784 cpl_free(order_idx_values) ;
786 cpl_table_delete(trace_wave) ;
789 *extract = extracted ;
790 *calibrated = in_calib ;
803static int cr2res_obs_2d_check_inputs_validity(
804 const cpl_frame * rawframe)
809 if (rawframe == NULL)
return -1 ;
820static hdrl_image ** cr2res_obs_2d_average_sky(
821 const cpl_frameset * skyframes)
823 hdrl_image ** sky_average ;
825 cpl_image * contrib ;
829 if (skyframes == NULL)
return NULL ;
832 sky_average = cpl_malloc(CR2RES_NB_DETECTORS *
sizeof(hdrl_image *)) ;
833 for (det_nr=1 ; det_nr<=CR2RES_NB_DETECTORS ; det_nr++)
834 sky_average[det_nr-1] = NULL ;
837 for (det_nr=1 ; det_nr<=CR2RES_NB_DETECTORS ; det_nr++) {
838 hdrl_imagelist *sky_list;
846 cpl_image_delete(contrib) ;
849 if (cpl_error_get_code() == CPL_ERROR_NONE) {
850 sky_average[det_nr-1] = avg ;
hdrl_image * cr2res_calib_image(const hdrl_image *in, int chip, int clean_bad, int subtract_nolight_rows, int subtract_interorder_column, int cosmics_corr, const cpl_frame *flat, const cpl_frame *dark, const cpl_frame *bpm, const cpl_frame *detlin, double dit, int ndit)
The images calibration routine for a given chip.
cpl_error_code cr2res_dfs_set_groups(cpl_frameset *set)
Set the group as RAW or CALIB in a frameset.
const cpl_frame * cr2res_io_find_BPM(const cpl_frameset *in)
Get the first CR2RES_BPM_DRSTYPE frame from a frameset.
const cpl_frame * cr2res_io_find_TRACE_WAVE(const cpl_frameset *in)
Get the first CR2RES_TW_DRSTYPE frame from a frameset.
int cr2res_io_convert_order_idx_to_idxp(int order_idx)
Convert the order_idx to the order_idxp.
int cr2res_io_save_EXTRACT_2D(const char *filename, cpl_frameset *allframes, cpl_frameset *inframes, const cpl_parameterlist *parlist, cpl_table **tables, const cpl_propertylist *qc_list, cpl_propertylist **ext_plist, const char *procatg, const char *recipe)
Save a 2D extracted spectrum.
hdrl_imagelist * cr2res_io_load_image_list_from_set(const cpl_frameset *in, int detector)
Load an hdrl image list from an images frameset.
cpl_table * cr2res_io_get_eop_table()
Get the eop_table.
int cr2res_io_get_ext_idx(const char *filename, int detector, int data)
Get the wished extension number for a detector.
hdrl_image * cr2res_io_load_image(const char *in, int detector)
Load an hdrl image from a image file.
int cr2res_io_save_CALIBRATED(const char *filename, cpl_frameset *allframes, cpl_frameset *inframes, const cpl_parameterlist *parlist, hdrl_image **calib_collapsed, const cpl_propertylist *qc_list, cpl_propertylist **ext_plist, const char *procatg, const char *recipe)
Save a CALIBRATED frame.
cpl_table * cr2res_io_load_TRACE_WAVE(const char *filename, int detector)
Load a table from a TRACE_WAVE.
double cr2res_pfits_get_dit(const cpl_propertylist *plist)
find out the DIT value
int cr2res_pfits_get_ndit(const cpl_propertylist *plist)
find out the NDIT value
int cr2res_qc_numsat(const cpl_frameset *frameset)
Calculate the number of saturated pixels.
int * cr2res_trace_get_order_idx_values(const cpl_table *trace, int *nb_order_idx_values)
Count and return the different order_idx values from a TW table.
int cr2res_order_idx_to_real(int order_idx, int order_zp)
Convert the order_idx into order_real.
double cr2res_utils_get_center_mjd(const cpl_frameset *frameset)
Calculate the middle of the exposures in the frameset.
cpl_frameset * cr2res_extract_frameset(const cpl_frameset *in, const char *tag)
Extract the frames with the given tag from a frameset.
const char * cr2res_get_license(void)
Get the pipeline copyright and license.
cpl_error_code hdrl_barycorr_compute(double ra, double dec, const cpl_table *eop_table, double mjdobs, double time_to_mid_exposure, double longitude, double latitude, double elevation, double pressure, double temperature, double humidity, double wavelength, double *barycorr)
Derives the barycentric correction using the erfa function eraApco13(). The latter For a terrestrial ...
cpl_error_code hdrl_image_sub_image(hdrl_image *self, const hdrl_image *other)
Subtract two images, store the result in the first image.
void hdrl_image_delete(hdrl_image *himg)
delete hdrl_image
cpl_error_code hdrl_imagelist_collapse_mean(const hdrl_imagelist *himlist, hdrl_image **out, cpl_image **contrib)
Mean collapsing of image list.
void hdrl_imagelist_delete(hdrl_imagelist *himlist)
Free all memory used by a hdrl_imagelist object including the images.