37 #include "sinfo_irplib_cpl_wrp.h"
39 #include "sinfo_msg.h"
40 #include "sinfo_utils_wrappers.h"
41 #include "sinfo_error.h"
44 #define SINFO_LINGAIN_ON_RAW "LINEARITY_LAMP_ON"
45 #define SINFO_LINGAIN_OFF_RAW "LINEARITY_LAMP_OFF"
47 #define RECIPE_NAME "sinfo_rec_lingain"
50 #define INSTREGEXP "ESO INS SETUP ID"
52 #define PAFREGEXP "^(" REGEXP "|" INSTREGEXP ")$"
54 #define SINFO_BPMBIN 1
70 sinfo_lingain_fill_parlist_default(cpl_parameterlist * parlist);
72 CPL_RECIPE_DEFINE(sinfo_rec_lingain, SINFONI_BINARY_VERSION,
75 sinfo_lingain_fill_parlist_default(recipe->parameters),
78 "Lander de Bilbao",
"lbilbao@eso.org",
"2008",
79 "Linearity/Gain recipe for the IR domain",
80 LG_DESCR(RECIPE_NAME,
"SINFONI",
82 SINFO_LINGAIN_OFF_RAW));
93 static int sinfo_rec_lingain(cpl_frameset * frameset,
94 const cpl_parameterlist * parlist)
96 const char* name_o=NULL;
99 cpl_error_code error = CPL_ERROR_NONE;
100 cpl_propertylist* plist=NULL;
101 cpl_propertylist * lintbl;
102 cpl_propertylist * gaintbl;
103 cpl_propertylist * coeffscube;
104 cpl_propertylist * bpm;
105 cpl_propertylist * corr;
106 cpl_propertylist * diff_flat;
109 lintbl = DETMON_FILL_PROLIST(
"DET_LIN_INFO",
"TYPE",
"TECH", CPL_TRUE);
110 gaintbl = DETMON_FILL_PROLIST(
"GAIN_INFO",
"TYPE",
"TECH", CPL_TRUE);
111 coeffscube = DETMON_FILL_PROLIST(
"COEFFS_CUBE",
"TYPE",
"TECH", CPL_TRUE);
112 bpm = DETMON_FILL_PROLIST(
"BP_MAP_NL",
"TYPE",
"TECH", CPL_TRUE);
113 corr = DETMON_FILL_PROLIST(
"AUTOCORR",
"TYPE",
"TECH", CPL_TRUE);
114 diff_flat = DETMON_FILL_PROLIST(
"DIFF_FLAT",
"TYPE",
"TECH", CPL_TRUE);
116 error = DETMON_LG(frameset,
118 SINFO_LINGAIN_ON_RAW,
119 SINFO_LINGAIN_OFF_RAW,
126 PACKAGE
"/" PACKAGE_VERSION,
128 sinfo_free_propertylist(&lintbl);
129 sinfo_free_propertylist(&gaintbl);
130 sinfo_free_propertylist(&coeffscube);
131 sinfo_free_propertylist(&bpm);
132 sinfo_free_propertylist(&corr);
133 sinfo_free_propertylist(&diff_flat);
135 check_nomsg(frm=cpl_frameset_find(frameset,
"BP_MAP_NL"));
136 check_nomsg(name_o=cpl_frame_get_filename(frm));
137 check_nomsg(plist=cpl_propertylist_load(name_o,0));
138 check_nomsg(ima=cpl_image_load(name_o,CPL_TYPE_FLOAT,0,0));
139 check_nomsg(cpl_image_threshold(ima,0.1,0.9,1,0));
140 check_nomsg(cpl_image_save(ima,name_o,CPL_BPP_IEEE_FLOAT,plist,CPL_IO_DEFAULT));
143 sinfo_free_propertylist(&plist);
144 sinfo_free_image(&ima);
147 cpl_ensure_code(!error, error);
149 return CPL_ERROR_NONE;
153 sinfo_lingain_fill_parlist_default(cpl_parameterlist * parlist)
156 cpl_error_code error = CPL_ERROR_NONE;
158 error = DETMON_LG_FILL_PARLIST_NIR_DEFAULT(parlist,RECIPE_NAME,
160 cpl_ensure_code(!error, error);
161 p = cpl_parameterlist_find(parlist, PACKAGE_TARNAME
"." RECIPE_NAME
".bpmbin");
162 cpl_ensure_code(p != NULL, CPL_ERROR_DATA_NOT_FOUND);
163 error = cpl_parameter_set_default_bool(p, SINFO_BPMBIN);
164 p = cpl_parameterlist_find(parlist, PACKAGE_TARNAME
"." RECIPE_NAME
".kappa");
165 cpl_ensure_code(p != NULL, CPL_ERROR_DATA_NOT_FOUND);
166 error = cpl_parameter_set_default_double(p, SINFO_KAPPA);
167 cpl_ensure_code(!error, error);