55#define MODULE_ID "XSH_DETECT_CONTINUUM"
75 280., 0.3, -0.0025 } ;
76static const double step = 40. ;
78static int nx = 400,
ny = 400 ;
91 cpl_propertylist * header = NULL ;
92 double residavg = 0. ;
94 xsh_msg(
" ====== verify_order_tables" ) ;
99 check( hname = cpl_frame_get_filename( result ) ) ;
100 check( header = cpl_propertylist_load( hname, 0 ) ) ;
102 CPL_TYPE_DOUBLE, &residavg ) ) ;
104 assure( residavg < 1., CPL_ERROR_ILLEGAL_INPUT,
"Error Too large" ) ;
105 xsh_msg(
" Orders Detected OK, RESIDAVG = %lf", residavg ) ;
116 cpl_polynomial * poly0 = NULL ;
117 cpl_polynomial * poly1 = NULL ;
118 cpl_polynomial * poly2 = NULL ;
119 cpl_image *image = NULL ;
120 cpl_image *bias = NULL;
121 cpl_frame * img_frame = NULL, * tbl_frame = NULL, * dtc_frame = NULL,
122 * result_frame = NULL ;
128 cpl_propertylist * img_header=NULL ;
129 cpl_frame* resid_frame=NULL;
149 poly0 = cpl_polynomial_new(
dimension ) ;
150 poly1 = cpl_polynomial_new(
dimension ) ;
151 poly2 = cpl_polynomial_new(
dimension ) ;
158 cpl_polynomial_set_coeff( poly0, &i,
poly0_coeff[i] ) ;
162 for( i = 1 ; i<=
degree ; i++ ) {
163 cpl_polynomial_set_coeff( poly0, &i,
poly0_coeff[i] ) ;
164 cpl_polynomial_set_coeff( poly1, &i,
poly0_coeff[i] ) ;
165 cpl_polynomial_set_coeff( poly2, &i,
poly0_coeff[i] ) ;
169 xsh_msg(
"Add to order list" ) ;
177 img_frame = cpl_frame_new() ;
181 cpl_image_save( image,
img_name, CPL_BPP_IEEE_DOUBLE, img_header,
184 cpl_frame_set_filename( img_frame,
img_name ) ;
185 cpl_frame_set_tag( img_frame,
"ORDERDEF_VIS_D2" );
186 cpl_frame_set_level( img_frame, CPL_FRAME_LEVEL_TEMPORARY);
187 cpl_frame_set_group( img_frame, CPL_FRAME_GROUP_RAW ) ;
194 "Cant save pre structure" ) ;
196 cpl_frame_set_tag( dtc_frame,
"ORDERDEF_UVB_D2" );
197 cpl_frame_set_level( dtc_frame, CPL_FRAME_LEVEL_TEMPORARY);
198 cpl_frame_set_group( dtc_frame, CPL_FRAME_GROUP_RAW ) ;
205 dcn_clipping.
sigma = 2.5 ;
206 dcn_clipping.
niter = 5 ;
207 dcn_clipping.
frac = 0.7 ;
247 if (cpl_error_get_code() != CPL_ERROR_NONE) {
static const char * tbl_name
static void verify_order_table(cpl_frame *result)
static const char * dtc_pre_name
static const double poly0_coeff[]
Unit test of XSH_DETECT_CONTINUUM.
static const char * img_name
static xsh_instrument * instrument
xsh_order_list * create_order_list(int norder, xsh_instrument *instrument)
void add_to_order_list(xsh_order_list *list, int order, int absorder, cpl_polynomial *poly, int xdelta, int starty, int endy)
cpl_image * xsh_test_create_bias_image(const char *name, int nx, int ny, xsh_instrument *instrument)
cpl_image * create_order_image(xsh_order_list *list, int nx, int ny)
cpl_propertylist * mkHeader(XSH_INSTRCONFIG *iconfig, int nx, int ny, double exptime)
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.
void xsh_order_list_dump(xsh_order_list *list, const char *fname)
void xsh_order_list_free(xsh_order_list **list)
free memory associated to an order_list
void xsh_pre_free(xsh_pre **pre)
Free a xsh_pre structure.
xsh_pre * xsh_pre_create(cpl_frame *raw, cpl_frame *bpmap, cpl_image *bias_data, xsh_instrument *instr, const int pre_overscan_corr, const bool flag_neg_and_thresh_pix)
Create a XSH_PRE from a raw frame.
cpl_frame * xsh_pre_save(const xsh_pre *pre, const char *filename, const char *tag, int temp)
Save PRE on disk.
cpl_frame * xsh_detect_continuum(cpl_frame *frame, cpl_frame *order_table, cpl_frame *spectral_frame, xsh_detect_continuum_param *detect_param, xsh_clipping_param *dcn_clipping, xsh_instrument *instr, cpl_frame **resid_frame)
Detect order and compute polynomial description of ordermin and order max. Uses a guess order table i...
#define assure(CONDITION, ERROR_CODE,...)
#define xsh_error_dump(level)
#define check_msg(COMMAND,...)
void xsh_instrument_set_mode(xsh_instrument *i, XSH_MODE mode)
Set a mode on instrument structure.
void xsh_instrument_set_recipe_id(xsh_instrument *instrument, const char *recipe_id)
Set the recipe_id into the instrument structure.
void xsh_instrument_set_arm(xsh_instrument *i, XSH_ARM arm)
Set an arm on instrument structure.
XSH_INSTRCONFIG * xsh_instrument_get_config(xsh_instrument *i)
Get the instrument default set of keywords.
void xsh_instrument_set_lamp(xsh_instrument *i, XSH_LAMP lamp)
Set a lamp on instrument structure.
void xsh_instrument_free(xsh_instrument **instrument)
free an instrument structure
xsh_instrument * xsh_instrument_new(void)
create new instrument structure
#define xsh_msg(...)
Print a message on info level.
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.
cpl_error_code xsh_get_property_value(const cpl_propertylist *plist, const char *keyword, cpl_type keywordtype, void *result)
Read a property value from a property list.
void xsh_free_frame(cpl_frame **f)
Deallocate a frame and set the pointer to NULL.
int xsh_debug_level_set(int level)
set debug level
void xsh_free_propertylist(cpl_propertylist **p)
Deallocate a property list and set the pointer to NULL.
#define TESTS_CLEAN_WORKSPACE(DRL_ID)
#define TESTS_INIT_WORKSPACE(DRL_ID)
#define TESTS_INIT(DRL_ID)
#define QC_ORD_ORDERPOS_RESIDAVG