00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #ifdef HAVE_CONFIG_H
00029 #include <config.h>
00030 #endif
00031
00032
00033
00034
00035
00036 #include <cpl.h>
00037 #include "sinfo_irplib_cpl_wrp.h"
00038
00039 #include "sinfo_msg.h"
00040 #include "sinfo_utils_wrappers.h"
00041 #include "sinfo_error.h"
00042
00043
00044 #define SINFO_LINGAIN_ON_RAW "LINEARITY_LAMP_ON"
00045 #define SINFO_LINGAIN_OFF_RAW "LINEARITY_LAMP_OFF"
00046
00047 #define RECIPE_NAME "sinfo_rec_lingain"
00048
00049
00050 #define INSTREGEXP "ESO INS SETUP ID"
00051
00052 #define PAFREGEXP "^(" REGEXP "|" INSTREGEXP ")$"
00053 #define NIR TRUE
00054 #define SINFO_BPMBIN 1
00055 #define SINFO_KAPPA 9
00056
00057
00058
00059
00060
00061
00062
00066
00069 cpl_error_code
00070 sinfo_lingain_fill_parlist_default(cpl_parameterlist * parlist);
00071
00072 CPL_RECIPE_DEFINE(sinfo_rec_lingain, SINFONI_BINARY_VERSION,
00073
00074
00075 sinfo_lingain_fill_parlist_default(recipe->parameters),
00076
00077
00078 "Lander de Bilbao", "lbilbao@eso.org", "2008",
00079 "Linearity/Gain recipe for the IR domain",
00080 LG_DESCR(RECIPE_NAME, "SINFONI",
00081 SINFO_LINGAIN_ON_RAW,
00082 SINFO_LINGAIN_OFF_RAW));
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093 static int sinfo_rec_lingain(cpl_frameset * frameset,
00094 const cpl_parameterlist * parlist)
00095 {
00096 const char* name_o=NULL;
00097 cpl_frame* frm=NULL;
00098 cpl_image* ima=NULL;
00099 cpl_error_code error = CPL_ERROR_NONE;
00100 cpl_propertylist* plist=NULL;
00101 cpl_propertylist * lintbl;
00102 cpl_propertylist * gaintbl;
00103 cpl_propertylist * coeffscube;
00104 cpl_propertylist * bpm;
00105 cpl_propertylist * corr;
00106 cpl_propertylist * diff_flat;
00107
00108
00109 lintbl = DETMON_FILL_PROLIST("DET_LIN_INFO", "TYPE", "TECH", CPL_TRUE);
00110 gaintbl = DETMON_FILL_PROLIST("GAIN_INFO", "TYPE", "TECH", CPL_TRUE);
00111 coeffscube = DETMON_FILL_PROLIST("COEFFS_CUBE", "TYPE", "TECH", CPL_TRUE);
00112 bpm = DETMON_FILL_PROLIST("BP_MAP_NL", "TYPE", "TECH", CPL_TRUE);
00113 corr = DETMON_FILL_PROLIST("AUTOCORR", "TYPE", "TECH", CPL_TRUE);
00114 diff_flat = DETMON_FILL_PROLIST("DIFF_FLAT", "TYPE", "TECH", CPL_TRUE);
00115
00116 error = DETMON_LG(frameset,
00117 parlist,
00118 SINFO_LINGAIN_ON_RAW,
00119 SINFO_LINGAIN_OFF_RAW,
00120 RECIPE_NAME,
00121 PACKAGE_TARNAME,
00122 PAFREGEXP,
00123 lintbl, gaintbl,
00124 coeffscube, bpm,
00125 corr, diff_flat,
00126 PACKAGE "/" PACKAGE_VERSION,
00127 NULL, NULL, NIR);
00128 sinfo_free_propertylist(&lintbl);
00129 sinfo_free_propertylist(&gaintbl);
00130 sinfo_free_propertylist(&coeffscube);
00131 sinfo_free_propertylist(&bpm);
00132 sinfo_free_propertylist(&corr);
00133 sinfo_free_propertylist(&diff_flat);
00134
00135 check_nomsg(frm=cpl_frameset_find(frameset,"BP_MAP_NL"));
00136 check_nomsg(name_o=cpl_frame_get_filename(frm));
00137 check_nomsg(plist=cpl_propertylist_load(name_o,0));
00138 check_nomsg(ima=cpl_image_load(name_o,CPL_TYPE_FLOAT,0,0));
00139 check_nomsg(cpl_image_threshold(ima,0.1,0.9,1,0));
00140 check_nomsg(cpl_image_save(ima,name_o,CPL_BPP_IEEE_FLOAT,plist,CPL_IO_DEFAULT));
00141
00142 cleanup:
00143 sinfo_free_propertylist(&plist);
00144 sinfo_free_image(&ima);
00145
00146
00147 cpl_ensure_code(!error, error);
00148
00149 return CPL_ERROR_NONE;
00150 }
00151
00152 cpl_error_code
00153 sinfo_lingain_fill_parlist_default(cpl_parameterlist * parlist)
00154 {
00155
00156 cpl_error_code error = CPL_ERROR_NONE;
00157 cpl_parameter * p;
00158 error = DETMON_LG_FILL_PARLIST_NIR_DEFAULT(parlist,RECIPE_NAME,
00159 PACKAGE_TARNAME);
00160 cpl_ensure_code(!error, error);
00161 p = cpl_parameterlist_find(parlist, PACKAGE_TARNAME "." RECIPE_NAME ".bpmbin");
00162 cpl_ensure_code(p != NULL, CPL_ERROR_DATA_NOT_FOUND);
00163 error = cpl_parameter_set_default_bool(p, SINFO_BPMBIN);
00164 p = cpl_parameterlist_find(parlist, PACKAGE_TARNAME "." RECIPE_NAME ".kappa");
00165 cpl_ensure_code(p != NULL, CPL_ERROR_DATA_NOT_FOUND);
00166 error = cpl_parameter_set_default_double(p, SINFO_KAPPA);
00167 cpl_ensure_code(!error, error);
00168 return error;
00169
00170 }
00171