37 #include "visir_recipe.h"
44 #define VISIR_LIMIT_FOR_BAD_PIXELS 32000.0
46 #define RECIPE_STRING "visir_img_trans"
52 static cpl_error_code visir_img_trans_save(cpl_frameset *,
53 const cpl_parameterlist *,
56 VISIR_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");
84 static 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;
102 skip_if(allframes == NULL);
104 skip_if (rawframes == NULL);
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));
177 cpl_table_delete(tab);
178 cpl_table_delete(tab2);
179 cpl_imagelist_delete(loaded);
181 return cpl_error_get_code();
193 static cpl_error_code visir_img_trans_save(cpl_frameset * set,
194 const cpl_parameterlist * parlist,
195 const cpl_table * tab)
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)
cpl_error_code irplib_dfs_save_table(cpl_frameset *allframes, const cpl_parameterlist *parlist, const cpl_frameset *usedframes, const cpl_table *table, const cpl_propertylist *tablelist, const char *recipe, const char *procat, const cpl_propertylist *applist, const char *remregexp, const char *pipe_id, const char *filename)
Save a table as a DFS-compliant pipeline product.
cpl_error_code irplib_framelist_load_propertylist_all(irplib_framelist *self, int ind, const char *regexp, cpl_boolean invert)
Load the propertylists of all frames in the framelist.
irplib_framelist * irplib_framelist_extract(const irplib_framelist *self, const char *tag)
Extract the frames with the given tag from a framelist.
int visir_dfs_set_groups(cpl_frameset *set)
Set the group as RAW or CALIB in a frameset.
void irplib_framelist_delete(irplib_framelist *self)
Deallocate an irplib_framelist with its frames and properties.
irplib_framelist * irplib_framelist_cast(const cpl_frameset *frameset)
Create an irplib_framelist from a cpl_framelist.