32 #include "omega_recipe.h"
60 static int omega_shutter_create(cpl_plugin *);
61 static int omega_shutter_exec(cpl_plugin *);
62 static int omega_shutter_destroy(cpl_plugin *);
63 static int omega_shutter(cpl_frameset *, cpl_parameterlist *);
69 static void omega_shutter_init(
void);
70 static void omega_shutter_tidy(
void);
71 static cpl_error_code omega_shutter_basicsteps(cpl_frameset * frameset,
72 cpl_image * mbias, cpl_imagelist * ilist_shortexp_up,
73 float exptime_lower,
float exptime_upper,
74 const char * direction,
int extension);
75 static cpl_matrix * omega_fill_ccdlayout(
void);
76 static cpl_error_code omega_average_ccd_table(cpl_imagelist * ilist_in,
77 cpl_table * table_out );
78 static cpl_error_code omega_table_insert_xcoordinates(cpl_table * table);
79 static float omega_get_exptime_limit(cpl_frameset * frameset);
88 }omega_shutter_config;
94 const cpl_frame *mbframe;
95 cpl_frameset *domelist;
103 #define RECIPE "omega_shutter"
105 static char omega_shutter_man[] =
107 "This recipe tests illumination variations due to inhomogeneities "
108 "in the \nshutter blade speed.\n"
111 " DO category: Type: Explanation: Required: \n"
112 " DOME_SHUTTERTEST Raw Domeflat Y \n"
114 " MASTER_BIAS Raw Master bias Y \n\n"
116 " DO category: Data type: Explanation: \n"
117 " SHUTTER_DOWN Products: Collapsed CCD array \n"
119 " SHUTTER_UP Products: Collapsed CCD array \n\n";
121 #define omega_shutter_exit(message) \
123 if (message) cpl_msg_error(cpl_func, message); \
124 cpl_imagelist_delete(ilist_shortexp_up); \
125 cpl_imagelist_delete(ilist_longexp_up); \
126 cpl_imagelist_delete(ilist_shortexp_down); \
127 cpl_imagelist_delete(ilist_longexp_down); \
128 cpl_imagelist_delete(ilist_up); \
129 cpl_imagelist_delete(ilist_down); \
130 cpl_image_delete(mbias); \
131 cpl_table_delete(table_up); \
132 cpl_table_delete(table_down); \
133 cpl_propertylist_delete(plistHeader); \
134 cpl_msg_indent_less(); \
138 #define omega_average_ccd_table_exit(message) \
140 if (message) cpl_msg_error(cpl_func, message); \
141 cpl_matrix_delete(ccd_mapping); \
142 cpl_imagelist_delete(ilist_tmp); \
143 cpl_image_delete(image_tmp); \
144 cpl_image_delete(image_collapsed); \
145 cpl_table_delete(table_local); \
146 cpl_msg_indent_less(); \
147 return cpl_error_set(cpl_func, cpl_error_get_code()); \
150 #define omega_shutter_basicsteps_exit(message) \
152 if (message) cpl_msg_error(cpl_func, message); \
153 cpl_propertylist_delete(plist); \
154 cpl_image_delete(image_local); \
155 cpl_image_delete(image_local_collapsed); \
156 cpl_free(direction_local); \
157 cpl_msg_indent_less(); \
158 return cpl_error_set(cpl_func, cpl_error_get_code()); \
172 cpl_recipe * recipe = cpl_calloc(1,
sizeof(*recipe)) ;
173 cpl_plugin * plugin = &recipe->interface ;
175 if (cpl_plugin_init(plugin,
177 OMEGA_BINARY_VERSION,
178 CPL_PLUGIN_TYPE_RECIPE,
180 "OMEGA - Test the shutter homogeneity",
185 omega_shutter_create,
187 omega_shutter_destroy)) {
188 cpl_msg_error(cpl_func,
"Plugin initialization failed");
189 (void)cpl_error_set_where(cpl_func);
193 if (cpl_pluginlist_append(list, plugin)) {
194 cpl_msg_error(cpl_func,
"Error adding plugin to list");
195 (void)cpl_error_set_where(cpl_func);
212 static int omega_shutter_create(cpl_plugin * plugin)
218 if (cpl_error_get_code() != CPL_ERROR_NONE) {
219 cpl_msg_error(cpl_func,
"%s():%d: An error is already set: %s",
220 cpl_func, __LINE__, cpl_error_get_where());
221 return (
int)cpl_error_get_code();
224 if (plugin == NULL) {
225 cpl_msg_error(cpl_func,
"Null plugin");
226 cpl_ensure_code(0, (
int)CPL_ERROR_NULL_INPUT);
230 if (cpl_plugin_get_type(plugin) != CPL_PLUGIN_TYPE_RECIPE) {
231 cpl_msg_error(cpl_func,
"Plugin is not a recipe");
232 cpl_ensure_code(0, (
int)CPL_ERROR_TYPE_MISMATCH);
236 recipe = (cpl_recipe *)plugin;
239 recipe->parameters = cpl_parameterlist_new() ;
241 if (recipe->parameters == NULL) {
242 cpl_msg_error(cpl_func,
"Parameter list allocation failed");
243 cpl_ensure_code(0, (
int)CPL_ERROR_ILLEGAL_OUTPUT);
251 p = cpl_parameter_new_range(
"omega.omega_shutter.OverscanMethod",
253 "Overscan Correction Method",
256 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI,
"oc-meth") ;
257 cpl_parameterlist_append(recipe->parameters, p) ;
259 p = cpl_parameter_new_value(
"omega.omega_shutter.ExtensionNumber",
261 "DUMMY parameter to ensure Paranal DFS compatibility!!",
265 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI,
"ext") ;
266 cpl_parameterlist_append(recipe->parameters, p) ;
280 static int omega_shutter_exec(cpl_plugin * plugin)
284 cpl_errorstate initial_errorstate = cpl_errorstate_get();
287 if (cpl_error_get_code() != CPL_ERROR_NONE) {
288 cpl_msg_error(cpl_func,
"%s():%d: An error is already set: %s",
289 cpl_func, __LINE__, cpl_error_get_where());
290 return (
int)cpl_error_get_code();
293 if (plugin == NULL) {
294 cpl_msg_error(cpl_func,
"Null plugin");
295 cpl_ensure_code(0, (
int)CPL_ERROR_NULL_INPUT);
299 if (cpl_plugin_get_type(plugin) != CPL_PLUGIN_TYPE_RECIPE) {
300 cpl_msg_error(cpl_func,
"Plugin is not a recipe");
301 cpl_ensure_code(0, (
int)CPL_ERROR_TYPE_MISMATCH);
305 recipe = (cpl_recipe *)plugin;
308 if (recipe->parameters == NULL) {
309 cpl_msg_error(cpl_func,
"Recipe invoked with NULL parameter list");
310 cpl_ensure_code(0, (
int)CPL_ERROR_NULL_INPUT);
312 if (recipe->frames == NULL) {
313 cpl_msg_error(cpl_func,
"Recipe invoked with NULL frame set");
314 cpl_ensure_code(0, (
int)CPL_ERROR_NULL_INPUT);
318 recipe_status = omega_shutter(recipe->frames, recipe->parameters);
321 if (cpl_dfs_update_product_header(recipe->frames)) {
322 if (!recipe_status) recipe_status = (int)cpl_error_get_code();
325 if (!cpl_errorstate_is_equal(initial_errorstate)) {
328 cpl_errorstate_dump(initial_errorstate, CPL_FALSE, NULL);
331 return recipe_status;
342 static int omega_shutter_destroy(cpl_plugin * plugin)
346 if (plugin == NULL) {
347 cpl_msg_error(cpl_func,
"Null plugin");
348 cpl_ensure_code(0, (
int)CPL_ERROR_NULL_INPUT);
352 if (cpl_plugin_get_type(plugin) != CPL_PLUGIN_TYPE_RECIPE) {
353 cpl_msg_error(cpl_func,
"Plugin is not a recipe");
354 cpl_ensure_code(0, (
int)CPL_ERROR_TYPE_MISMATCH);
358 recipe = (cpl_recipe *)plugin;
360 cpl_parameterlist_delete(recipe->parameters);
365 static int omega_shutter(cpl_frameset *set, cpl_parameterlist *pars)
372 cpl_parameter *par =NULL;
373 cpl_imagelist * ilist_shortexp_up =NULL;
374 cpl_imagelist * ilist_longexp_up =NULL;
375 cpl_imagelist * ilist_shortexp_down =NULL;
376 cpl_imagelist * ilist_longexp_down =NULL;
377 cpl_imagelist * ilist_up =NULL;
378 cpl_imagelist * ilist_down =NULL;
379 cpl_image * mbias=NULL;
380 cpl_table * table_up=NULL;
381 cpl_table * table_down=NULL;
382 cpl_propertylist * plistHeader=NULL;
383 float shutter_explimit=0.;
389 cpl_msg_error (cpl_func,
"Parameters list not found");
393 if (cpl_frameset_is_empty(set) == 1) {
394 cpl_msg_error (cpl_func,
"Frameset not found");
399 par = cpl_parameterlist_find(pars,
"omega.omega_shutter.OverscanMethod") ;
400 omega_shutter_config.oc = cpl_parameter_get_int(par) ;
403 if (oc_dfs_set_groups(set)) {
404 cpl_msg_error(cpl_func,
"Cannot identify RAW and CALIB frames") ;
409 omega_shutter_init();
414 cpl_msg_error(cpl_func,
"Cannot labelise the input frameset");
415 omega_shutter_tidy();
419 SHUTTER_RAW)) == NULL) {
420 cpl_msg_error(cpl_func,
"Cannot find dome frames in input frameset");
421 omega_shutter_tidy();
425 nflats = cpl_frameset_count_tags(ps.domelist, SHUTTER_RAW);
427 cpl_msg_error (cpl_func,
"Need at least 4 (%s) frames to run "
428 "this recipe", SHUTTER_RAW);
429 omega_shutter_tidy();
433 cpl_msg_info (cpl_func,
"There are %d %s in frame set",nflats, SHUTTER_RAW);
437 ps.mbframe = cpl_frameset_find_const(set, OMEGA_CALIB_BIAS);
438 if (ps.mbframe == NULL) {
439 cpl_msg_error (cpl_func,
"Need at least 1 (%s) frames to run "
440 "this recipe", OMEGA_CALIB_BIAS);
441 omega_shutter_tidy();
445 cpl_msg_info(cpl_func,
"Using %s %s",OMEGA_CALIB_BIAS,
446 cpl_frame_get_filename(ps.mbframe));
455 ilist_shortexp_up =cpl_imagelist_new();
456 ilist_longexp_up =cpl_imagelist_new();
457 ilist_shortexp_down =cpl_imagelist_new();
458 ilist_longexp_down =cpl_imagelist_new();
460 shutter_explimit=omega_get_exptime_limit(ps.domelist);
461 cpl_msg_info(cpl_func,
"Limit to discriminate long and short exposures:"
462 " %f second",shutter_explimit);
464 for (j = jst; j <= jfn; j++) {
465 cpl_msg_info(cpl_func,
"Beginning work on extension %02d",j);
466 cpl_msg_indent_more();
469 if(ps.mbframe != NULL){
471 if(oscan1 != omega_shutter_config.oc) {
472 cpl_msg_warning (cpl_func,
"Overscan correction mode for Master"
473 " Bias (oc = %d) differs from the one used here "
474 "(oc = %d)", oscan1, omega_shutter_config.oc);
479 mbias = cpl_image_load(cpl_frame_get_filename(ps.mbframe),
482 cpl_msg_error (cpl_func,
"Unable to load extension %d of the master"
483 " bias file %s", j, cpl_frame_get_filename(ps.mbframe));
484 omega_shutter_tidy();
485 omega_shutter_exit(NULL);
490 if(omega_shutter_basicsteps(ps.domelist, mbias, ilist_shortexp_up ,
491 FLT_MIN , shutter_explimit,
"up" ,j) != CPL_ERROR_NONE) {
492 cpl_msg_error (cpl_func,
"Unable to perform basic image calibration"
493 " on extension %d ", j);
494 omega_shutter_tidy();
495 omega_shutter_exit(NULL);
498 if(omega_shutter_basicsteps(ps.domelist, mbias, ilist_longexp_up ,
499 shutter_explimit, FLT_MAX ,
"up" ,j) != CPL_ERROR_NONE){
500 cpl_msg_error (cpl_func,
"Unable to perform basic image calibration"
501 " on extension %d ", j);
502 omega_shutter_tidy();
503 omega_shutter_exit(NULL);
506 if(omega_shutter_basicsteps(ps.domelist, mbias, ilist_shortexp_down,
507 FLT_MIN , shutter_explimit,
"down",j)!= CPL_ERROR_NONE){
508 cpl_msg_error (cpl_func,
"Unable to perform basic image calibration"
509 " on extension %d ", j);
510 omega_shutter_tidy();
511 omega_shutter_exit(NULL);
514 if(omega_shutter_basicsteps(ps.domelist, mbias, ilist_longexp_down ,
515 shutter_explimit, FLT_MAX ,
"down",j)!= CPL_ERROR_NONE){
516 cpl_msg_error (cpl_func,
"Unable to perform basic image calibration"
517 " on extension %d ", j);
518 omega_shutter_tidy();
519 omega_shutter_exit(NULL);
522 cpl_image_delete(mbias); mbias=NULL;
523 cpl_msg_indent_less();
528 cpl_msg_info(cpl_func,
"Dividing long exposures through short exposures");
530 if(cpl_imagelist_divide(ilist_shortexp_up,ilist_longexp_up)!=
532 omega_shutter_tidy();
533 omega_shutter_exit(
"Can not divide long exposure through short exposure");
536 if(cpl_imagelist_divide(ilist_shortexp_down,ilist_longexp_down)!=
538 omega_shutter_tidy();
539 omega_shutter_exit(
"Can not divide long exposure through short exposure");
543 ilist_up=cpl_imagelist_new();
544 ilist_down=cpl_imagelist_new();
545 table_up=cpl_table_new(0);
546 table_down=cpl_table_new(0);
548 cpl_table_new_column(table_up,
"RowAveraged",CPL_TYPE_FLOAT);
549 cpl_table_new_column(table_down,
"RowAveraged",CPL_TYPE_FLOAT);
552 cpl_msg_info(cpl_func,
"Final average-collapsing the full CCD array in "
555 if(omega_average_ccd_table(ilist_shortexp_up, table_up)!= CPL_ERROR_NONE){
556 omega_shutter_tidy();
557 omega_shutter_exit(
"Can not collapse CCD array in y-direction");
560 if(omega_average_ccd_table(ilist_shortexp_down, table_down)!=CPL_ERROR_NONE){
561 omega_shutter_tidy();
562 omega_shutter_exit(
"Can not collapse CCD array in y-direction");
565 if(omega_table_insert_xcoordinates(table_up)!= CPL_ERROR_NONE ||
566 omega_table_insert_xcoordinates(table_down)!= CPL_ERROR_NONE){
567 omega_shutter_tidy();
568 omega_shutter_exit(
"Can not insert x-coordinates in the product table");
572 plistHeader=cpl_propertylist_new();
573 cpl_propertylist_append_string(plistHeader, CPL_DFS_PRO_CATG,
"SHUTTER_UP");
575 if(cpl_dfs_save_table(set, NULL, pars, set, NULL, table_up, NULL,
576 "omega_shutter", plistHeader, NULL, PACKAGE
"/" PACKAGE_VERSION ,
577 "omega_shutter_up.fits") != CPL_ERROR_NONE){
578 omega_shutter_tidy();
579 omega_shutter_exit(
"Can not save the product SHUTTER_UP");
582 cpl_propertylist_update_string(plistHeader, CPL_DFS_PRO_CATG,
"SHUTTER_DOWN");
583 if (cpl_dfs_save_table(set, NULL, pars, set, NULL, table_down, NULL,
584 "omega_shutter", plistHeader, NULL, PACKAGE
"/" PACKAGE_VERSION ,
585 "omega_shutter_down.fits")!=CPL_ERROR_NONE){
586 omega_shutter_tidy();
587 omega_shutter_exit(
"Can not save the product SHUTTER_DOWN");
589 cpl_propertylist_delete(plistHeader); plistHeader=NULL;
592 cpl_imagelist_delete(ilist_shortexp_up); ilist_shortexp_up=NULL;
593 cpl_imagelist_delete(ilist_longexp_up); ilist_longexp_up=NULL;
594 cpl_imagelist_delete(ilist_shortexp_down); ilist_shortexp_down=NULL;
595 cpl_imagelist_delete(ilist_longexp_down); ilist_longexp_down=NULL;
596 cpl_imagelist_delete(ilist_up); ilist_up=NULL;
597 cpl_imagelist_delete(ilist_down); ilist_down=NULL;
598 cpl_table_delete(table_up); table_up=NULL;
599 cpl_table_delete(table_down); table_down=NULL;
600 omega_shutter_tidy();
614 static cpl_error_code omega_average_ccd_table(cpl_imagelist * ilist_in,
615 cpl_table * table_out ){
617 cpl_matrix * ccd_mapping=NULL;
618 cpl_imagelist * ilist_tmp=NULL;
619 cpl_image * image_tmp=NULL;
620 cpl_image * image_collapsed=NULL;
621 cpl_table * table_local=NULL;;
622 int nrow=0, ncol=0, row=0, col=0;
624 cpl_errorstate prestate=cpl_errorstate_get();
626 ccd_mapping=omega_fill_ccdlayout();
628 if (!cpl_errorstate_is_equal(prestate)){
629 omega_average_ccd_table_exit(NULL);
632 nrow=cpl_matrix_get_nrow(ccd_mapping);
633 ncol=cpl_matrix_get_ncol(ccd_mapping);
634 if (!cpl_errorstate_is_equal(prestate)){
635 omega_average_ccd_table_exit(NULL);
638 for (col=0; col<ncol;col++){
639 cpl_msg_debug(cpl_func,
"working on column: %d", col);
640 cpl_msg_indent_more();
641 ilist_tmp=cpl_imagelist_new();
642 for (row=0; row<nrow;row++){
643 cpl_msg_debug(cpl_func,
"working on row: %d", row);
644 ccd_index=cpl_matrix_get(ccd_mapping,row,col)-1;
645 cpl_msg_debug(cpl_func,
"fits file extension: %d", ccd_index+1);
646 image_tmp=cpl_image_duplicate(cpl_imagelist_get(ilist_in,ccd_index));
647 cpl_imagelist_set(ilist_tmp,image_tmp,row);
649 if (!cpl_errorstate_is_equal(prestate)){
650 omega_average_ccd_table_exit(NULL);
653 image_collapsed=cpl_imagelist_collapse_create(ilist_tmp);
654 if (!cpl_errorstate_is_equal(prestate)){
655 omega_average_ccd_table_exit(NULL);
657 table_local=cpl_table_new(cpl_image_get_size_x(image_collapsed));
658 cpl_table_new_column(table_local,
"RowAveraged",CPL_TYPE_FLOAT);
659 cpl_table_copy_data_float(table_local,
"RowAveraged",
660 cpl_image_get_data_float(image_collapsed));
661 if (!cpl_errorstate_is_equal(prestate)){
662 omega_average_ccd_table_exit(NULL);
665 cpl_table_insert(table_out, table_local, cpl_table_get_nrow(table_out));
666 cpl_table_delete(table_local); table_local=NULL;
667 cpl_image_delete(image_collapsed); image_collapsed=NULL;
668 cpl_imagelist_delete(ilist_tmp); ilist_tmp=NULL;
669 cpl_msg_indent_less();
672 cpl_matrix_delete(ccd_mapping); ccd_mapping=NULL;
675 return cpl_error_set(cpl_func, cpl_error_get_code());
687 static cpl_matrix * omega_fill_ccdlayout(
void){
688 cpl_matrix * ccd=NULL;
691 ccd=cpl_matrix_new(4,8);
693 cpl_matrix_set(ccd,0,0 ,1 );
694 cpl_matrix_set(ccd,0,1 ,2 );
695 cpl_matrix_set(ccd,0,2 ,3 );
696 cpl_matrix_set(ccd,0,3 ,4 );
697 cpl_matrix_set(ccd,0,4 ,17);
698 cpl_matrix_set(ccd,0,5 ,18);
699 cpl_matrix_set(ccd,0,6 ,19);
700 cpl_matrix_set(ccd,0,7 ,20);
702 cpl_matrix_set(ccd,1,0 ,5 );
703 cpl_matrix_set(ccd,1,1 ,6 );
704 cpl_matrix_set(ccd,1,2 ,7 );
705 cpl_matrix_set(ccd,1,3 ,8 );
706 cpl_matrix_set(ccd,1,4 ,21);
707 cpl_matrix_set(ccd,1,5 ,22);
708 cpl_matrix_set(ccd,1,6 ,23);
709 cpl_matrix_set(ccd,1,7 ,24);
711 cpl_matrix_set(ccd,2,0 ,9);
712 cpl_matrix_set(ccd,2,1 ,10);
713 cpl_matrix_set(ccd,2,2 ,11);
714 cpl_matrix_set(ccd,2,3 ,12);
715 cpl_matrix_set(ccd,2,4 ,25);
716 cpl_matrix_set(ccd,2,5 ,26);
717 cpl_matrix_set(ccd,2,6 ,27);
718 cpl_matrix_set(ccd,2,7 ,28);
721 cpl_matrix_set(ccd,3,0 ,13);
722 cpl_matrix_set(ccd,3,1 ,14);
723 cpl_matrix_set(ccd,3,2 ,15);
724 cpl_matrix_set(ccd,3,3 ,16);
725 cpl_matrix_set(ccd,3,4 ,29);
726 cpl_matrix_set(ccd,3,5 ,30);
727 cpl_matrix_set(ccd,3,6 ,31);
728 cpl_matrix_set(ccd,3,7 ,32);
749 static cpl_error_code omega_shutter_basicsteps(cpl_frameset * frameset,
750 cpl_image * mbias, cpl_imagelist * ilist,
float exptime_lower,
751 float exptime_upper,
const char * direction,
int extension)
753 char * direction_local=NULL;
754 double local_TMOPEN=0.;
755 float exptime_local=0;
756 cpl_propertylist * plist=NULL;
757 cpl_image * image_local=NULL;
758 cpl_image * image_local_collapsed=NULL;
759 cpl_frame * cur_frame=NULL;
760 cpl_errorstate prestate = cpl_errorstate_get();
767 nframes = cpl_frameset_get_size(frameset) ;
770 for (i=0 ; i<nframes ; i++)
772 cur_frame=cpl_frameset_get_position(frameset, i) ;
773 cpl_free(direction_local); direction_local=NULL;
774 plist=cpl_propertylist_load(cpl_frame_get_filename(cur_frame),0);
775 local_TMOPEN=cpl_propertylist_get_double(plist,
776 "ESO DET SHUT TMOPEN");
777 if(cpl_error_get_code() != CPL_ERROR_NONE)
779 omega_shutter_basicsteps_exit(
"Missing keyword "
780 "ESO DET SHUT TMOPEN in scientific header");
782 cpl_msg_debug(cpl_func,
"ESO DET SHUT TMOPEN: %g", local_TMOPEN);
784 direction_local= cpl_sprintf(
"up");
787 direction_local= cpl_sprintf(
"down");
790 exptime_local=cpl_propertylist_get_float(plist,
"EXPTIME");
792 if ((cpl_error_get_code() != CPL_ERROR_NONE) || (exptime_local <=0)){
793 cpl_error_set(cpl_func,CPL_ERROR_ILLEGAL_INPUT);
794 omega_shutter_basicsteps_exit(
"Missing keyword "
795 "EXPTIME in scientific header or EXPTIME <= ZERO");
798 if(strcmp(direction_local,direction)==0 && exptime_local >exptime_lower
799 && exptime_local <=exptime_upper)
801 cpl_msg_debug(cpl_func,
"Loop: ESO DET SHUT TMOPEN: %g", local_TMOPEN);
802 cpl_msg_debug(cpl_func,
"Loop: direction_local: %s", direction_local);
803 cpl_msg_debug(cpl_func,
"Loop: direction: %s", direction);
805 cpl_msg_info(cpl_func,
"Trimming and overscan correcting");
810 if(image_local==NULL){
811 omega_shutter_basicsteps_exit(
"Can not trim and correct the "
816 cpl_msg_info(cpl_func,
"Subtracting the bias");
817 cpl_image_subtract(image_local,mbias);
818 if (!cpl_errorstate_is_equal(prestate)){
819 omega_shutter_basicsteps_exit(
"Can not subtract the bias");
823 cpl_msg_info(cpl_func,
"Median collapsing in y-direction");
824 image_local_collapsed=cpl_image_collapse_median_create(
825 image_local, 0, 0, 0);
826 if (!cpl_errorstate_is_equal(prestate)){
827 omega_shutter_basicsteps_exit(
"Can not collapse the image in "
832 cpl_msg_info(cpl_func,
"Normalizing the exposure time to 1 sec");
833 cpl_image_divide_scalar(image_local_collapsed,exptime_local);
834 if (!cpl_errorstate_is_equal(prestate)){
835 omega_shutter_basicsteps_exit(
"can not normalize the exposure "
840 cpl_imagelist_set(ilist,image_local_collapsed,extension-1);
843 cpl_image_delete(image_local); image_local=NULL;
846 cpl_propertylist_delete(plist); plist=NULL;
847 cpl_free(direction_local); direction_local=NULL;
851 if (cpl_imagelist_get_size(ilist)<1){
852 cpl_error_set_message(cpl_func,CPL_ERROR_ILLEGAL_INPUT,
"Imagelist is "
853 "empty! Please check the input raw frames");
857 return cpl_error_set(cpl_func, cpl_error_get_code());
867 static cpl_error_code omega_table_insert_xcoordinates(cpl_table * intable)
870 int * ptablecol=NULL;
872 cpl_errorstate prestate = cpl_errorstate_get();
874 cpl_table_new_column(intable,
"x_coordinate", CPL_TYPE_INT);
875 cpl_table_fill_column_window_int(intable,
"x_coordinate", 0,
876 cpl_table_get_nrow(intable), 0);
877 ptablecol = cpl_table_get_data_int(intable,
"x_coordinate");
879 if (!cpl_errorstate_is_equal(prestate)){
880 return cpl_error_set(cpl_func, cpl_error_get_code());
884 for(i = 0; i < cpl_table_get_nrow(intable); i++){
885 ptablecol[i] = i + 1;
889 return cpl_error_set(cpl_func, cpl_error_get_code());
893 static void omega_shutter_init(
void) {
901 static void omega_shutter_tidy(
void) {
902 freespace(ps.labels);
903 freeframeset(ps.domelist);
915 static float omega_get_exptime_limit(cpl_frameset * frameset){
917 cpl_vector * exptime_vector=NULL;
918 cpl_propertylist * plist=NULL;
919 cpl_frame * cur_frame=NULL;
921 float exptime_limit=0;
922 cpl_frameset_iterator * it = NULL;
925 exptime_vector=cpl_vector_new(cpl_frameset_get_size(frameset));
927 it = cpl_frameset_iterator_new(frameset);
931 while((cur_frame = cpl_frameset_iterator_get(it)))
933 plist=cpl_propertylist_load(cpl_frame_get_filename(cur_frame),0);
934 if(!cpl_propertylist_has(plist,
"EXPTIME"))
936 cpl_msg_warning(cpl_func,
"Can not find EXPTIME in file %s",
937 cpl_frame_get_filename(cur_frame));
938 cpl_propertylist_delete(plist);
939 cpl_vector_delete(exptime_vector);
940 cpl_frameset_iterator_delete(it);
944 cpl_vector_set(exptime_vector, i,
945 cpl_propertylist_get_float(plist,
"EXPTIME"));
946 cpl_propertylist_delete(plist);
948 cpl_frameset_iterator_advance(it, 1);
950 cpl_frameset_iterator_delete(it);
952 exptime_limit=(cpl_vector_get_min(exptime_vector)+
953 cpl_vector_get_max(exptime_vector))/2.;
954 cpl_vector_delete(exptime_vector);
956 return exptime_limit;
int omega_pfits_get_overscan(const cpl_frame *frame, int xn)
Get the DRS keyword of the overscan method used to reduce the image.
cpl_image * TrimOscanCorrect(const cpl_frame *frame, int oscan, int extn)
This method loads a raw image, trims it and (optionally) performs an overscan correction, using the statistics of the pre and overscan regions. This can be done with a single value for the whole image or on a per-row basis.
int omega_compare_tags(const cpl_frame *frame1, const cpl_frame *frame2)
int cpl_plugin_get_info(cpl_pluginlist *list)
Build the list of available plugins, for this module.
const char * omega_get_license(void)
Get the pipeline copyright and license.
cpl_frameset * omega_frameset_subgroup(cpl_frameset *frameset, cpl_size *labels, cpl_size nlab, const char *tag)