37#include "visir_recipe.h"
44#define VISIR_LIMIT_FOR_BAD_PIXELS 32000.0
46#define RECIPE_STRING "visir_img_trans"
52static cpl_error_code visir_img_trans_save(cpl_frameset *,
53 const cpl_parameterlist *,
56VISIR_RECIPE_DEFINE(visir_img_trans, 0,
"Instrument Transmission recipe",
57 "This recipe computes the transmission at different "
59 "comparing the flux of a bright star for different "
61 "The files listed in the Set Of Frames (sof-file) "
63 "VISIR-transmission-file.fits IM_TEC_TRANS\n"
64 "The resuts are given in a table.\n");
84static int visir_img_trans(cpl_frameset * framelist,
85 const cpl_parameterlist * parlist)
87 irplib_framelist * allframes = NULL;
88 irplib_framelist * rawframes = NULL;
89 cpl_imagelist * loaded = NULL;
92 cpl_table * tab = NULL;
93 cpl_table * tab2 = NULL;
101 allframes = irplib_framelist_cast(framelist);
102 skip_if(allframes == NULL);
103 rawframes = irplib_framelist_extract(allframes, VISIR_IMG_TRANS_RAW);
104 skip_if (rawframes == NULL);
106 skip_if(irplib_framelist_load_propertylist_all(rawframes, 0,
107 visir_property_regexp,
112 cpl_msg_info(cpl_func,
"Load the input frames");
114 cpl_msg_error(cpl_func,
"Could not load the input frames");
118 nfiles = cpl_imagelist_get_size(loaded);
120 skip_if( nfiles <= 0);
123 for (i=0 ; i < nfiles ; i++) {
124 cpl_mask * map = cpl_mask_threshold_image_create(
125 cpl_imagelist_get(loaded, i),
126 VISIR_LIMIT_FOR_BAD_PIXELS,
128 if (map == NULL)
continue;
129 cpl_image_reject_from_mask(cpl_imagelist_get(loaded, i), map);
130 cpl_mask_delete(map);
136 cpl_msg_info(cpl_func,
"Get the wavelengths from the input headers");
137 if ((wls = visir_utils_get_wls(rawframes)) == NULL) {
138 cpl_msg_error(cpl_func,
"Could not get wavelengths");
143 tab = visir_table_new_xypos(loaded,
"FLUX");
144 skip_if (tab == NULL);
146 tab2 = cpl_table_new(nfiles);
147 skip_if (tab2 == NULL);
150 skip_if (cpl_table_move_column(tab2,
"FLUX", tab));
152 skip_if (cpl_table_wrap_double(tab, wls,
"WAVELENGTH"));
155 skip_if (cpl_table_move_column(tab,
"FLUX", tab2));
158 for (i=0; i < nfiles; i++) {
159 if (cpl_table_get_double(tab,
"FLUX", i, NULL) > 0)
continue;
160 skip_if (cpl_table_set_double(tab,
"FLUX", i,
161 cpl_image_get_median(cpl_imagelist_get(loaded, i))));
165 skip_if (cpl_table_divide_scalar(tab,
"FLUX",
166 cpl_table_get_column_max(tab,
"FLUX")));
169 cpl_msg_info(cpl_func,
"Save the products");
170 skip_if (visir_img_trans_save(framelist, parlist, tab));
174 irplib_framelist_delete(allframes);
175 irplib_framelist_delete(rawframes);
177 cpl_table_delete(tab);
178 cpl_table_delete(tab2);
179 cpl_imagelist_delete(loaded);
181 return cpl_error_get_code();
193static cpl_error_code visir_img_trans_save(cpl_frameset * set,
194 const cpl_parameterlist * parlist,
195 const cpl_table * tab)
198 skip_if(irplib_dfs_save_table(set, parlist, set, tab, NULL, RECIPE_STRING,
199 VISIR_IMG_TRANS_TAB_PROCATG, NULL, NULL,
200 visir_pipe_id, RECIPE_STRING CPL_DFS_FITS));
204 return cpl_error_get_code();
cpl_error_code visir_dfs_check_framelist_tag(const irplib_framelist *self)
Check the tags in a frameset (group raw only)
int visir_dfs_set_groups(cpl_frameset *set)
Set the group as RAW or CALIB in a frameset.