58#define HALF_SLIC_WINDOW 5
85 cpl_image* mflat=NULL;
86 const char* name=NULL;
87 const char* name_o=NULL;
89 cpl_image* filter_x=NULL;
90 cpl_propertylist* plist=NULL;
95 cpl_vector* vsliclo=NULL;
96 cpl_vector* vslicup=NULL;
97 cpl_vector* vedgelo=NULL;
98 cpl_vector* vedgeup=NULL;
99 cpl_vector* vypos=NULL;
104 double* pcenterx=NULL;
105 double* pcentery=NULL;
108 double* pedgelo=NULL;
109 double* pedgeup=NULL;
110 double* psliceup=NULL;
111 double* pslicelo=NULL;
112 double* psliceup_resx=NULL;
113 double* pslicelo_resx=NULL;
115 double* pedgeup_resx=NULL;
116 double* pedgelo_resx=NULL;
119 double* pedgelof=NULL;
120 double* pedgeupf=NULL;
121 double* psliceupf=NULL;
122 double* pslicelof=NULL;
123 double* psliceupthresf=NULL;
124 double* pslicelothresf=NULL;
150 cpl_polynomial* sliclopoly=NULL;
151 cpl_polynomial* slicuppoly=NULL;
152 cpl_polynomial* edgelopoly=NULL;
153 cpl_polynomial* edgeuppoly=NULL;
156 check(name=cpl_frame_get_filename(frame));
157 check(mflat=cpl_image_load(name,CPL_TYPE_FLOAT,0,0));
164 check(sx=cpl_image_get_size_x(mflat));
165 check(sy=cpl_image_get_size_y(mflat));
167 if(strcmp(
method,
"sobel") == 0) {
175 check(
max=cpl_image_get_max(filter_x));
176 check(cpl_image_divide_scalar(filter_x,
max));
177 check(cpl_image_abs(filter_x));
180 if(strcmp(
method,
"sobel") == 0) {
181 check(cpl_image_save(filter_x,
"sobel_lx_n.fits",CPL_BPP_IEEE_FLOAT,
182 NULL,CPL_IO_DEFAULT));
184 check(cpl_image_save(filter_x,
"scharr_x_n.fits",CPL_BPP_IEEE_FLOAT,
185 NULL,CPL_IO_DEFAULT));
190 check(tbl=cpl_table_new(nrows));
191 check(cpl_table_new_column(tbl,
"ORDER",CPL_TYPE_INT));
192 check(cpl_table_new_column(tbl,
"ABSORDER",CPL_TYPE_INT));
194 check(cpl_table_new_column(tbl,
"CENTERX",CPL_TYPE_DOUBLE));
195 check(cpl_table_new_column(tbl,
"CENTERY",CPL_TYPE_DOUBLE));
196 check(cpl_table_new_column(tbl,
"EDGELOX",CPL_TYPE_DOUBLE));
197 check(cpl_table_new_column(tbl,
"EDGEUPX",CPL_TYPE_DOUBLE));
199 check(cpl_table_fill_column_window_int(tbl,
"ORDER",0,nrows,-1));
200 check(cpl_table_fill_column_window_int(tbl,
"ABSORDER",0,nrows,-1));
202 check(cpl_table_fill_column_window_double(tbl,
"CENTERX",0,nrows,-1));
203 check(cpl_table_fill_column_window_double(tbl,
"CENTERY",0,nrows,-1));
204 check(cpl_table_fill_column_window_double(tbl,
"EDGELOX",0,nrows,-1));
205 check(cpl_table_fill_column_window_double(tbl,
"EDGEUPX",0,nrows,-1));
208 check(porder=cpl_table_get_data_int(tbl,
"ORDER"));
209 check(pabsorder=cpl_table_get_data_int(tbl,
"ABSORDER"));
211 check(pcenterx=cpl_table_get_data_double(tbl,
"CENTERX"));
212 check(pcentery=cpl_table_get_data_double(tbl,
"CENTERY"));
213 check(pedgelo=cpl_table_get_data_double(tbl,
"EDGELOX"));
214 check(pedgeup=cpl_table_get_data_double(tbl,
"EDGEUPX"));
219 xsh_msg(
"Detect Order Edges in IFU mode");
220 check(cpl_table_new_column(tbl,
"SLICELOX",CPL_TYPE_DOUBLE));
221 check(cpl_table_new_column(tbl,
"SLICEUPX",CPL_TYPE_DOUBLE));
222 check(cpl_table_new_column(tbl,
"SLICELOTHRESFX",CPL_TYPE_DOUBLE));
223 check(cpl_table_new_column(tbl,
"SLICEUPTHRESFX",CPL_TYPE_DOUBLE));
225 check(pslicelothresf=cpl_table_get_data_double(tbl,
"SLICELOTHRESFX"));
226 check(psliceupthresf=cpl_table_get_data_double(tbl,
"SLICEUPTHRESFX"));
227 check(cpl_table_fill_column_window_double(tbl,
"SLICELOTHRESFX",0,nrows,-1));
228 check(cpl_table_fill_column_window_double(tbl,
"SLICEUPTHRESFX",0,nrows,-1));
230 check(pslicelo=cpl_table_get_data_double(tbl,
"SLICELOX"));
231 check(psliceup=cpl_table_get_data_double(tbl,
"SLICEUPX"));
232 check(cpl_table_fill_column_window_double(tbl,
"SLICELOX",0,nrows,-1));
233 check(cpl_table_fill_column_window_double(tbl,
"SLICEUPX",0,nrows,-1));
237 xsh_msg(
"Detect Order Edges in SLIT mode");
241 for(i=0; i< list->
size; i++){
261 for(
y=img_starty;
y<img_endy;
y++){
262 double xl = 0, xu = 0, xc=0, xsl=0, xsu=0;
271 if((
llx>0) && (
urx< sx)) {
273 check( cpl_image_get_maxpos_window( filter_x,
llx,
y,
urx,
y, &px, &py));
275 pedgelo[k]*=list->
bin_x;
283 if((
llx>0) && (
urx< sx)) {
285 check( cpl_image_get_maxpos_window( filter_x,
llx,
y,
urx,
y, &px, &py));
287 pedgeup[k]*=list->
bin_x;
294 pcenterx[k]=xc*list->
bin_y;
303 pslicelothresf[k] = xsl;
307 if((
llx>0) && (
urx)< sx) {
310 check( cpl_image_get_maxpos_window( filter_x,
llx,
y,
urx,
y, &px, &py));
312 pslicelo[k]*=list->
bin_x;
321 psliceupthresf[k] = xsu;
325 if((
llx>0) && (
urx)< sx) {
328 check( cpl_image_get_maxpos_window( filter_x,
llx,
y,
urx,
y, &px, &py));
330 psliceup[k]*=list->
bin_x;
345 check(num=cpl_table_and_selected_int(tbl,
"ORDER",CPL_GREATER_THAN,-1));
346 check(res=cpl_table_extract_selected(tbl));
350 cpl_table_select_all(res);
353 check(cpl_table_new_column(res,
"EDGELOFX",CPL_TYPE_DOUBLE));
354 check(cpl_table_new_column(res,
"EDGEUPFX",CPL_TYPE_DOUBLE));
355 check(cpl_table_fill_column_window_double(res,
"EDGELOFX",0,num,-1));
356 check(cpl_table_fill_column_window_double(res,
"EDGEUPFX",0,num,-1));
358 check(cpl_table_new_column(res,
"EDGELO_RESX",CPL_TYPE_DOUBLE));
359 check(cpl_table_new_column(res,
"EDGEUP_RESX",CPL_TYPE_DOUBLE));
360 check(cpl_table_fill_column_window_double(res,
"EDGELO_RESX",0,num,-1));
361 check(cpl_table_fill_column_window_double(res,
"EDGEUP_RESX",0,num,-1));
363 check(pedgelof=cpl_table_get_data_double(res,
"EDGELOFX"));
364 check(pedgeupf=cpl_table_get_data_double(res,
"EDGEUPFX"));
365 check(pedgelo_resx=cpl_table_get_data_double(res,
"EDGELO_RESX"));
366 check(pedgeup_resx=cpl_table_get_data_double(res,
"EDGEUP_RESX"));
369 check(cpl_table_new_column(res,
"SLICELOFX",CPL_TYPE_DOUBLE));
370 check(cpl_table_new_column(res,
"SLICEUPFX",CPL_TYPE_DOUBLE));
372 check(cpl_table_fill_column_window_double(res,
"SLICELOFX",0,num,-1));
373 check(cpl_table_fill_column_window_double(res,
"SLICEUPFX",0,num,-1));
374 check(pslicelof=cpl_table_get_data_double(res,
"SLICELOFX"));
375 check(psliceupf=cpl_table_get_data_double(res,
"SLICEUPFX"));
377 check(cpl_table_new_column(res,
"SLICELO_RESX",CPL_TYPE_DOUBLE));
378 check(cpl_table_new_column(res,
"SLICEUP_RESX",CPL_TYPE_DOUBLE));
379 check(cpl_table_fill_column_window_double(res,
"SLICELO_RESX",0,num,-1));
380 check(cpl_table_fill_column_window_double(res,
"SLICEUP_RESX",0,num,-1));
381 check(pslicelo_resx=cpl_table_get_data_double(res,
"SLICELO_RESX"));
382 check(psliceup_resx=cpl_table_get_data_double(res,
"SLICEUP_RESX"));
388 for(i=0; i< list->
size; i++){
402 check(nsel=cpl_table_and_selected_int(res,
"ABSORDER",CPL_EQUAL_TO,
405 check(tbl=cpl_table_extract_selected(res));
407 check(ypos=cpl_table_get_data_double(tbl,
"CENTERY"));
408 check(vypos = cpl_vector_wrap( nsel, ypos ));
411 check(edgelo=cpl_table_get_data_double(tbl,
"EDGELOX"));
412 check(edgeup=cpl_table_get_data_double(tbl,
"EDGEUPX"));
414 check(vedgelo = cpl_vector_wrap( nsel, edgelo ));
415 check(vedgeup = cpl_vector_wrap( nsel, edgeup ));
443 for(
y=0;
y< nsel;
y++){
444 check( pedgelof[k+
y] = cpl_polynomial_eval_1d(edgelopoly,ypos[
y],NULL));
445 check( pedgeupf[k+
y] = cpl_polynomial_eval_1d(edgeuppoly,ypos[
y],NULL));
447 pedgelo_resx[k+
y] = pedgelof[k+
y] - edgelo[
y];
448 pedgeup_resx[k+
y] = pedgeupf[k+
y] - edgeup[
y];
451 check( cpl_vector_unwrap(vedgeup )) ;
452 check( cpl_vector_unwrap(vedgelo )) ;
456 check(sliclo=cpl_table_get_data_double(tbl,
"SLICELOX"));
457 check(slicup=cpl_table_get_data_double(tbl,
"SLICEUPX"));
458 check( vslicup = cpl_vector_wrap( nsel, slicup )) ;
459 check( vsliclo = cpl_vector_wrap( nsel, sliclo )) ;
486 for(
y=0;
y< nsel;
y++){
487 check( pslicelof[k+
y] = cpl_polynomial_eval_1d(sliclopoly,ypos[
y],NULL));
488 check( psliceupf[k+
y] = cpl_polynomial_eval_1d(slicuppoly,ypos[
y],NULL));
489 pslicelo_resx[k+
y] = pslicelof[k+
y] - sliclo[
y];
490 psliceup_resx[k+
y] = psliceupf[k+
y] - slicup[
y];
492 check( cpl_vector_unwrap(vslicup )) ;
493 check( cpl_vector_unwrap(vsliclo )) ;
497 cpl_vector_unwrap(vypos );
500 cpl_table_select_all(res);
527 sprintf(name_t,
"%s%s",name_o,
".fits");
528 check(plist=cpl_propertylist_load(name,0));
529 check(cpl_table_save(res,plist,NULL,name_t,CPL_IO_DEFAULT));
568 int chunk_y_hsize,
int x_hsize,
const int decode_bp,
double *flux,
double *noise)
571 float *
data = NULL, *errs = NULL;
575 int nb_good_pixels=0;
584 res_size = x_hsize*2+1;
593 check( errs = cpl_image_get_data_float( pre->
errs));
594 check( qual = cpl_image_get_data_int( pre->
qual));
597 for(i=0; i< res_size; i++){
603 for(i=xc-x_hsize; i <= (xc+x_hsize); i++){
605 int pix_val=i-xc+x_hsize;
607 for(j=yc-chunk_y_hsize; j <= (yc+chunk_y_hsize); j++){
608 int j_nx_plus_i=j*
nx+i;
609 if ( (qual[j_nx_plus_i] & decode_bp) == 0){
610 flux[pix_val]+=
data[j_nx_plus_i];
611 noise[pix_val]+=errs[j_nx_plus_i]*errs[j_nx_plus_i];
615 if(nb_good_pixels>0) {
616 flux[pix_val] /= nb_good_pixels;
617 noise[pix_val]= sqrt(noise[pix_val])/nb_good_pixels;
642 cpl_polynomial *cen_poly,
660 check( qual = cpl_image_get_data_int( pre->
qual));
662 for(
y=cen_start+chunk_hsize;
y<= cen_end-chunk_hsize;
y++){
671 if ( flux > flux_max ){
672 if ( (qual[
x-1+(
y-1)*pre->
nx] & decode_bp) == 0 ){
709 cpl_polynomial *cen_poly,
727 float min = 0.0, noise = 0.0, sdivn = 0.0;
729 int j = 0, xmin = 0,xmax = 0;
747 window_size = window_hsize*2+1;
751 xmin =
x-window_hsize;
753 xmax =
x+window_hsize;
756 if (xmin >= 1 && xmax <= pre->
nx) {
761 res_flux, res_noise));
763 noise = res_noise[window_hsize+1];
764 sdivn = res_flux[window_hsize+1]/noise;
765 *x_cen_sdivn = sdivn;
767 if ( sdivn > min_snr ){
771 min = res_flux[window_hsize+1];
772 for(j = window_hsize+1; j<window_size; j++) {
773 if (min > res_flux[j]){
792 threshold = (res_flux[window_hsize+1]-min) * flux_frac;
795 while( (j < window_size-1) && ((res_flux[j]-min) >=
threshold)){
802 xsh_msg(
"WARNING UP edge not detected. Increase window size");
807 min = res_flux[window_hsize+1];
810 for(j=0; j<=window_hsize+1; j++) {
811 if (min > res_flux[j]){
834 threshold = (res_flux[window_hsize+1]-min) * flux_frac;
836 while( (j > 0) && ( (res_flux[j]-min) >=
threshold)){
842 xsh_msg(
"WARNING LOW edge not detected. Increase window size");
845 if ( (*xup-*xlow) < min_size_x){
847 "to small %d < %d",
y, *xup-*xlow, min_size_x);
864 double min_low,
double min_up,
int xlow,
int xup,
865 double *ratio_low,
double *ratio_up)
867 double avg_cen = 0., avg_lo=0., avg_up=0.;
880 center = window_hsize+1;
885 avg_cen += res_flux[j];
890 center = window_hsize+1-
size;
893 avg_lo += res_flux[j];
898 center = window_hsize+1+
size;
901 avg_up += res_flux[j];
907 *ratio_up = (avg_up-min_up)/(avg_cen-min_up);
908 *ratio_low = (avg_lo-min_low)/(avg_cen-min_low);
932 cpl_frame * result = NULL;
936 double* positions = NULL;
937 double* uppervalues = NULL;
938 double* lowervalues = NULL;
939 double * slicup = NULL;
940 double * sliclow = NULL;
941 cpl_vector* xpos = NULL;
942 cpl_vector* upper = NULL;
943 cpl_vector* lower = NULL;
944 cpl_vector * vslicup = NULL;
945 cpl_vector * vsliclow = NULL;
949 int size = 0, i = 0, k = 0;
952 const char * tag = NULL;
955 int window_size, min_order_size_x, chunk_hsize, window_hsize;
956 double min_snr, slitlet_up_factor, slitlet_low_factor;
957 double *res_flux = NULL, *res_noise = NULL;
960 const char*
method = NULL;
962 cpl_table* tab_edges_res = NULL;
972 window_size = window_hsize * 2 + 1;
976 min_snr = detectorder_par->
min_sn;
984 assure(window_size > 0, CPL_ERROR_ILLEGAL_INPUT,
985 "window_size=%d (window_size=window_hsize*2+1) < 0 "
986 "parameter detectorder-edges-search-window-half-size=%d "
987 "may have been set to a too large value", window_size, window_hsize);
992 " Window: %d,flux-Thresh: %.2f, S/N: %.2f", window_size, flux_frac, min_snr);
994 " min-size-x: %d, Slitlet-low-factor: %.2f\
995 Slitlet-up-factor: %.2f chunk-half-size %d", min_order_size_x, slitlet_low_factor, slitlet_up_factor, chunk_hsize);
1004 min_order_size_x > 0 && min_order_size_x < (floor) (pre->
nx / list->
size),
1005 CPL_ERROR_ILLEGAL_INPUT,
"parameter detectorder-min-order-size-x=%d "
1006 "has been set to a too small or too large value", min_order_size_x);
1021 xsh_msg(
"Detect Order Edges in IFU mode");
1023 xsh_msg(
"Detect Order Edges in SLIT mode");
1041 for (i = 0; i < list->
size; i++) {
1042 int mean_size_up = 0;
1043 int mean_size_low = 0;
1044 int mean_size_slic_low = 0;
1045 int mean_size_slic_up = 0;
1046 double ratio_low = 0., ratio_up = 0.;
1055 if (is_ifu && !fixed_slice) {
1057 float min_lo = 0.0, min_up = 0.0, sdivn = 0.0;
1059 int upperval = 0, lowval = 0;
1070 xsh_detect_edges( list, max_y, list->
list[i].
cenpoly, pre, window_hsize, res_flux, res_noise, chunk_hsize, min_snr, flux_frac, min_order_size_x,decode_bp, &xmin, &sdivn, &upperval, &lowval, &min_lo, &min_up));
1084 for (
y = 1 + chunk_hsize;
y <= pre->
ny - chunk_hsize;
y++) {
1087 float min_lo = 0.0, min_up = 0.0, sdivn = 0.0;
1088 int j = 0, xmin = 0;
1089 int upperval = 0, lowval = 0;
1090 double xslicup = 0.;
1091 double xsliclow = 0.;
1095 xsh_detect_edges( list,
y, list->
list[i].
cenpoly, pre, window_hsize, res_flux, res_noise, chunk_hsize, min_snr, flux_frac, min_order_size_x,decode_bp, &xmin, &sdivn, &upperval, &lowval, &min_lo, &min_up));
1106 if ((sdivn > min_snr) && is_ifu) {
1108 int slit_size = ceil((upperval - lowval + 1) / 3.0);
1110 xsliclow = lowval + slit_size;
1111 xslicup = upperval - slit_size;
1121 max = (avg - min_up) * slitlet_up_factor * ratio_up;
1123 for (j = window_hsize + 1; j <= upperval; j++) {
1124 if ((res_flux[j] - min_up) <
max) {
1131 max = (avg - min_lo) * slitlet_low_factor * ratio_low;
1132 for (j = window_hsize + 1; j >= lowval; j--) {
1133 if ((res_flux[j] - min_lo) <
max) {
1142 if ((sdivn > min_snr) && (upperval - lowval) >= min_order_size_x) {
1144 positions[
size] =
y;
1145 lowervalues[
size] = lowval + xmin;
1146 uppervalues[
size] = upperval + xmin;
1147 mean_size_low += window_hsize + 1 - lowval;
1148 mean_size_up += upperval - (window_hsize + 1);
1150 }
else if (xslicup != 0 && xsliclow != 0) {
1152 positions[
size] =
y;
1153 lowervalues[
size] = lowval + xmin;
1154 uppervalues[
size] = upperval + xmin;
1155 mean_size_low += window_hsize + 1 - lowval;
1156 mean_size_up += upperval - (window_hsize + 1);
1157 slicup[
size] = xslicup + xmin;
1158 sliclow[
size] = xsliclow + xmin;
1159 mean_size_slic_low += window_hsize + 1 - xsliclow;
1160 mean_size_slic_up += xslicup - (window_hsize + 1);
1165 "Order %d edge detection: sn (%g) < sn_threshold (%g) or order size (%d) < min order size min (%d)", list->
list[i].
absorder, sdivn, min_snr, (upperval - lowval), min_order_size_x);
1171 if (bad_points > 1) {
1173 "Order %d edge detection summary: ", list->
list[i].
absorder);
1175 "%d out of %d not matching user defined min S/N (%g), or minimum order size", bad_points, pre->
ny-2*chunk_hsize, min_snr);
1179 if (size <= 3 && detectorder_par->qc_mode == CPL_TRUE) {
1192 "%d out of %d not matching user defined min S/N (%g), or minimum order size", bad_points, pre->
ny-2*chunk_hsize, min_snr);
1199 CPL_ERROR_ILLEGAL_INPUT,
1200 "can't fit polynomial solution of degree %d to only %d data points "
1201 "parameter detectorder-edges-search-window-half-size=%d "
1202 "may have a too small value "
1203 "or parameter detectorder-min-sn value may be too big "
1204 "or parameter detectorder-chunk-half-size=%d "
1205 "may have been set to a too small or too large large value "
1206 "or parameter detectorder-edges-flux-thresh=%g "
1207 "may have been set to a too small or too large large value", list->
list[i].
pol_degree,
size, window_hsize, chunk_hsize, flux_frac);
1209 list->
list[i].
starty = positions[0] - chunk_hsize;
1210 list->
list[i].
endy = positions[
size - 1] + chunk_hsize;
1213 mean_size_up = mean_size_up /
size;
1214 mean_size_low = mean_size_low /
size;
1217 mean_size_slic_low = mean_size_slic_low /
size;
1218 mean_size_slic_up = mean_size_slic_up /
size;
1221 "mean size Slitlets up %d low %d", mean_size_slic_up, mean_size_slic_low);
1231 positions[
size] =
y;
1232 lowervalues[
size] = x_center - mean_size_low;
1233 uppervalues[
size] = x_center + mean_size_up;
1235 sliclow[
size] = x_center - mean_size_slic_low;
1236 slicup[
size] = x_center + mean_size_slic_up;
1245 positions[
size] =
y;
1246 lowervalues[
size] = x_center - mean_size_low;
1247 uppervalues[
size] = x_center + mean_size_up;
1250 sliclow[
size] = x_center - mean_size_slic_low;
1251 slicup[
size] = x_center + mean_size_slic_up;
1258 FILE* debug_out = NULL;
1263 sprintf(openmode,
"w");
1265 sprintf(openmode,
"a");
1268debug_out = fopen(fname, openmode);
1270 for (newi = 0; newi <
size; newi++) {
1271 fprintf(debug_out,
"%f %f %f\n", lowervalues[newi], uppervalues[newi],
1277debug_out = fopen(fname, openmode);
1279 for (newi = 0; newi <
size; newi++) {
1280 fprintf(debug_out,
"%f %f %f\n", sliclow[newi], slicup[newi],
1290 for (k = 0; k <
size; k++) {
1291 lowervalues[k] *= list->
bin_x;
1292 uppervalues[k] *= list->
bin_x;
1293 positions[k] *= list->
bin_y;
1295 sliclow[k] *= list->
bin_x;
1296 slicup[k] *= list->
bin_x;
1300 check(xpos = cpl_vector_wrap(
size,positions));
1301 check(upper = cpl_vector_wrap(
size,uppervalues));
1302 check(lower = cpl_vector_wrap(
size,lowervalues));
1304 check( vslicup = cpl_vector_wrap(
size, slicup ));
1305 check( vsliclow = cpl_vector_wrap(
size, sliclow ));
1339 if (strcmp(
method,
"fixed") != 0) {
1348 if (strcmp(
method,
"fixed") != 0) {
1349 check(cpl_table_save(tab_edges_res, NULL, NULL, fname, CPL_IO_EXTEND));
1354 cleanup:
if (cpl_error_get_code() != CPL_ERROR_NONE) {
static void xsh_detect_edges(xsh_order_list *list, int y, cpl_polynomial *cen_poly, xsh_pre *pre, int window_hsize, double *res_flux, double *res_noise, int chunk_hsize, double min_snr, double flux_frac, int min_size_x, const int decode_bp, int *x_min, float *x_cen_sdivn, int *xup, int *xlow, float *min_low, float *min_up)
Detect order edges: at each y position determines low (left) and upper (right) order edges.
static cpl_table * xsh_compute_flat_edges(cpl_frame *frame, xsh_order_list *list, xsh_instrument *instrument, const char *method)
Measure flat edges (and eventually IFU slices) on master bias using Scharr X filter.
static void xsh_detect_slitlet_ratio(double *res_flux, int window_hsize, double min_low, double min_up, int xlow, int xup, double *ratio_low, double *ratio_up)
static void xsh_detect_max_y(xsh_order_list *list, int chunk_hsize, cpl_polynomial *cen_poly, int cen_start, int cen_end, xsh_pre *pre, const int decode_bp, int *maxy)
Detect Y position where flux is max.
cpl_frame * xsh_detect_order_edge(cpl_frame *frame, cpl_frame *cen_order_tab_frame, xsh_detect_order_param *detectorder_par, xsh_instrument *instrument)
Detect order edges and compute polynomial description of ordermin and order max.
static void xsh_eval_y_avg_chunk(xsh_pre *pre, int xc, int yc, int chunk_y_hsize, int x_hsize, const int decode_bp, double *flux, double *noise)
Evaluate by chunk in Y the total and mean flux and the corresponding errors around x,...
static xsh_instrument * instrument
cpl_frame * xsh_order_list_save(xsh_order_list *order_list, xsh_instrument *instrument, const char *filename, const char *tag, const int ny)
Save an order list to a frame.
int xsh_order_list_eval_int(xsh_order_list *list, cpl_polynomial *poly, double y)
Evaluate an order list poly but return the central pixel position rounding the polynomial.
xsh_order_list * xsh_order_list_load(cpl_frame *frame, xsh_instrument *instr)
load an order list from a frame
int xsh_order_list_get_starty(xsh_order_list *list, int i)
get position on Y axis of first pixel detected on order
int xsh_order_list_get_endy(xsh_order_list *list, int i)
get position on Y axis of last pixel detected on order
void xsh_order_list_free(xsh_order_list **list)
free memory associated to an order_list
double xsh_order_list_eval(xsh_order_list *list, cpl_polynomial *poly, double y)
Evaluate an order list poly.
xsh_pre * xsh_pre_load(cpl_frame *frame, xsh_instrument *instr)
Load a xsh_pre structure from a frame.
void xsh_pre_free(xsh_pre **pre)
Free a xsh_pre structure.
#define XSH_REGDEBUG(...)
#define XSH_ASSURE_NOT_ILLEGAL(cond)
#define assure(CONDITION, ERROR_CODE,...)
#define XSH_ASSURE_NOT_NULL(pointer)
XSH_MODE xsh_instrument_get_mode(xsh_instrument *i)
Get a mode on instrument structure.
#define xsh_msg_dbg_medium(...)
#define xsh_msg_error(...)
Print an error message.
#define xsh_msg(...)
Print a message on info level.
#define xsh_msg_dbg_high(...)
void xsh_unwrap_vector(cpl_vector **v)
Unwrap a vector and set the pointer to NULL.
void xsh_free_polynomial(cpl_polynomial **p)
Deallocate a polynomial and set the pointer to NULL.
void xsh_free_image(cpl_image **i)
Deallocate an image and set the pointer to NULL.
int xsh_debug_level_get(void)
get debug level
void xsh_free_table(cpl_table **t)
Deallocate a table and set the pointer to NULL.
void xsh_free_propertylist(cpl_propertylist **p)
Deallocate a property list and set the pointer to NULL.
double slitlet_low_factor
cpl_propertylist * header
cpl_polynomial * edguppoly
cpl_polynomial * edglopoly
cpl_polynomial * slicuppoly
cpl_polynomial * sliclopoly
#define XSH_NAME_LAMP_MODE_ARM(name, id, ext, instr)
#define XSH_MEASURE_FLAT_QTH_SLIT_EDGES_UVB
#define XSH_MEASURE_FLAT_IFU_EDGES
#define XSH_ORDER_TAB_EDGES
#define XSH_MEASURE_FLAT_D2_SLIT_EDGES_UVB
#define XSH_MEASURE_FLAT_QTH_IFU_EDGES_UVB
#define XSH_MEASURE_FLAT_SLIT_EDGES
#define XSH_GET_TAG_FROM_ARM(TAG, instr)
#define XSH_MEASURE_FLAT_D2_IFU_EDGES_UVB
#define XSH_GET_TAG_FROM_LAMP(TAG, instr)
#define BOOLEAN_TO_STRING(boolean)
#define XSH_NEW_PROPERTYLIST(POINTER)
#define XSH_FREE(POINTER)
#define XSH_CALLOC(POINTER, TYPE, SIZE)
cpl_image * xsh_sobel_lx(cpl_image *in)
Compute X Sobel filter transformation.
cpl_image * xsh_scharr_x(cpl_image *in)
Compute X Scharr filter transformation.
cpl_polynomial * xsh_polynomial_fit_1d_create(const cpl_vector *x_pos, const cpl_vector *values, int degree, double *mse)