76 limit = exp(-expectedValue);
77 x = (double)rand() / (double)INT_MAX;
80 x *= (double)rand() / (double)INT_MAX;
92 cpl_image* res = NULL;
93 cpl_propertylist* header = NULL;
103 conad = config->
conad;
104 ron_adu = ron / conad;
107 header = cpl_propertylist_new();
111 cpl_image_fill_noise_uniform ( res, medval-ron_adu, medval+ron_adu);
124 cpl_propertylist *header = NULL;
125 cpl_image *
data = NULL;
126 cpl_frame *frame = NULL;
135 header = cpl_propertylist_new();
139 cpl_image_fill_gaussian(
data,
145 pdata=cpl_image_get_data_float(
data);
146 for(j=0;j<
size;j++) {
153 frame = cpl_frame_new();
154 cpl_frame_set_filename(frame,name);
155 cpl_frame_set_group(frame,group);
156 cpl_frame_set_tag(frame,tag);
175 cpl_parameter *p = NULL;
177 p = cpl_parameterlist_get_first(parlist);
179 bool parameter_is_set = cpl_parameter_get_default_flag(p);
181 if (!parameter_is_set) {
182 cpl_type ptype = cpl_parameter_get_type(p);
185 cpl_parameter_set_bool(p, cpl_parameter_get_default_bool(p));
188 cpl_parameter_set_int(p, cpl_parameter_get_default_int(p));
190 case CPL_TYPE_DOUBLE:
191 cpl_parameter_set_double(p, cpl_parameter_get_default_double(p));
193 case CPL_TYPE_STRING:
194 cpl_parameter_set_string(p, cpl_parameter_get_default_string(p));
197 assure(
false, CPL_ERROR_ILLEGAL_INPUT,
198 "Unknown type of parameter '%s'", cpl_parameter_get_name(p));
201 p = cpl_parameterlist_get_next(parlist);
224 cpl_propertylist * header = cpl_propertylist_new() ;
229 "Cant append CRPIX1" ) ;
231 "Cant append CRPIX2" ) ;
233 "Cant append CRVAL1" ) ;
235 "Cant append CRVAL2" ) ;
243 "Cant append OVSCX" ) ;
245 "Cant append OVSCY" ) ;
247 "Cant append PRSCX" ) ;
249 "Cant append PRSCY" ) ;
251 "Cant append RON" ) ;
254 "Cant append CONAD" ) ;
256 "Cant append PSZX" ) ;
258 "Cant append PSZY" ) ;
260 "Cant append EXPTIME" ) ;
262 "Cant append GAIN" ) ;
264 "Cant append BINX" ) ;
266 "Cant append BINY" ) ;
268 "Cant append DPR CATG" ) ;
270 "Cant append DPR TYPE" ) ;
300 "Cant append BINX" ) ;
302 "Cant append BINY" ) ;
310 "Cant append PSZX" ) ;
312 "Cant append PSZY" ) ;
314 "Cant append EXPTIME" ) ;
316 "Cant append GAIN" ) ;
319 "Cant append OVSCX" ) ;
321 "Cant append OVSCY" ) ;
323 "Cant append PRSCX" ) ;
325 "Cant append PRSCY" ) ;
327 "Cant append RON" ) ;
330 "Cant append CONAD" ) ;
332 "Cant append DPR CATG" ) ;
334 "Cant append DPR TYPE" ) ;
336 if ( iconfig->
bitpix == 32){
339 "Cant append PXSPACE keyword" ) ;
365 double pixmax = 100. ;
366 cpl_image * image = NULL ;
368 check( image = cpl_image_new(
nx,
ny, CPL_TYPE_DOUBLE ) ) ;
370 for( i = 0 ; i<list->
size ; i++ ) {
372 int ixl, ixu, ixc, iy;
377 cxl = cpl_polynomial_get_coeff( list->
list[i].
edglopoly, &zero ) ;
378 cxu = cpl_polynomial_get_coeff( list->
list[i].
edguppoly, &zero ) ;
379 pixstep = (2*pixmax)/(cxu-cxl) ;
383 for( iy = list->
list[i].
starty ; iy < list->list[i].endy ;
389 ixc = cpl_polynomial_eval_1d( list->
list[i].
cenpoly,
397 for( pixval = 0., k = ixl ; k<ixc ; k++, pixval += pixstep) {
398 cpl_image_set( image, k, iy, pixval ) ;
400 cpl_image_set( image, ixc+1, iy+1, pixmax ) ;
401 for( pixval = pixval, k = ixc ; k<=ixu ; k++, pixval -= pixstep) {
402 cpl_image_set( image, k, iy, pixval ) ;
421 if (cpl_error_get_code() != CPL_ERROR_NONE) {
434 cpl_polynomial *poly,
int xdelta,
440 coeff0 = cpl_polynomial_get_coeff( poly, &i ) ;
447 coeff0 + (
double)xdelta ) ;
450 coeff0 - (
double)xdelta ) ;
458#define FIRST_LAMBDA 500.0
459#define LAST_LAMBDA 510.0
466#define COEFF0_PLUS 30.
467#define COEFF1_PLUS 0.03
470#define COEFF0_MINUS 10.
471#define COEFF1_MINUS 0.03
477 20., 40., 100., 40., 20. } ;
485 int i, j, k, nb,
order ;
489 const char * tag = NULL ;
490 cpl_frame * res_frame = NULL ;
498 order <= instr->config->order_max ;
513 for ( i = 0 ; i<
NB_LAMBDA ; i++, plambda++ )
519 for ( i = 0 ; i<
NB_SLIT ; i++, pslit++ )
540 for( j = 0 ; j<
NB_LAMBDA ; j++, plambda++ ) {
541 float datump, datumm ;
544 check( datump = cpl_polynomial_eval_1d(
poly_plus, (
double)j, NULL ) ) ;
545 check( datumm = cpl_polynomial_eval_1d(
poly_minus, (
double)j, NULL ) ) ;
549 if ( sign > 0 ) val =
Flux[k] ;
550 else val = -
Flux[k] ;
555 if ( sign > 0 ) val = -
Flux[k] ;
566 check(cpl_frame_set_tag(res_frame, tag )) ;
569 if (cpl_error_get_code() != CPL_ERROR_NONE) {
578 FILE *sof_file = NULL;
579 cpl_frameset *result = NULL;
584 check( result = cpl_frameset_new());
586 sof_file = fopen( sof_name,
"r");
588 if (sof_file != NULL){
590 while ( fgets( sof_line, 200, sof_file)){
593 cpl_frame *frame = NULL;
595 if ( sof_line[0] ==
'#'){
596 xsh_msg(
"skip line %s", sof_line);
601 sscanf( sof_line,
"%199s %199s", name, tag);
602 check( frame = cpl_frame_new());
603 check( cpl_frame_set_filename( frame, name));
604 check( cpl_frame_set_tag( frame, tag));
605 check( cpl_frameset_insert( result, frame));
611 xsh_msg(
"File %s not found", sof_name);
616 if (cpl_error_get_code() != CPL_ERROR_NONE) {
625 cpl_propertylist *header = NULL;
626 const char *catg = NULL;
628 check( header = cpl_propertylist_load( filename, 0));
633 if (strstr( catg,
"UVB") != NULL){
637 if (strstr( catg,
"VIS") != NULL){
641 if (strstr( catg,
"NIR") != NULL){
static xsh_instrument * instrument
xsh_order_list * create_order_list(int norder, xsh_instrument *instrument)
static int xsh_poisson_random(double expectedValue)
generates random data with Poisson distribution
static cpl_polynomial * poly_minus
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_frameset * sof_to_frameset(const char *sof_name)
cpl_propertylist * mkHeader(XSH_INSTRCONFIG *iconfig, int nx, int ny, double exptime)
static cpl_polynomial * poly_plus
xsh_instrument * create_instrument(const char *filename)
void setHeader(cpl_propertylist *header, XSH_INSTRCONFIG *iconfig, int nx, int ny, double exptime)
void tests_set_defaults(cpl_parameterlist *parlist)
Set unset parameters to default value.
cpl_frame * xsh_test_create_frame(const char *name, int nx, int ny, const char *tag, cpl_frame_group group, xsh_instrument *instrument)
cpl_frame * create_rectify_nod_list(int sign, const char *fname, xsh_instrument *instr)
void xsh_order_list_free(xsh_order_list **list)
free memory associated to an order_list
cpl_frame * xsh_rec_list_save(xsh_rec_list *list, const char *filename, const char *tag, int is_temp)
Save a rec list in a frame.
void xsh_rec_list_free(xsh_rec_list **list)
free memory associated to a rec_list
#define assure(CONDITION, ERROR_CODE,...)
#define check_msg(COMMAND,...)
#define XSH_ASSURE_NOT_NULL(pointer)
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.
xsh_instrument * xsh_instrument_new(void)
create new instrument structure
#define xsh_msg(...)
Print a message on info level.
#define xsh_msg_dbg_high(...)
const char * xsh_pfits_get_pcatg(const cpl_propertylist *plist)
find out the pcatg
void xsh_free_image(cpl_image **i)
Deallocate an image and set the pointer to NULL.
void xsh_free_frameset(cpl_frameset **f)
Deallocate a frame set and set the pointer to NULL.
void xsh_free_propertylist(cpl_propertylist **p)
Deallocate a property list and set the pointer to NULL.
xsh_instrument * instrument
cpl_propertylist * header
cpl_polynomial * edguppoly
cpl_polynomial * edglopoly
xsh_instrument * instrument
cpl_propertylist * header
#define XSH_PRE_DATA_TYPE
#define XSH_GET_TAG_FROM_ARM(TAG, instr)
#define XSH_NEW_PROPERTYLIST(POINTER)
#define XSH_CALLOC(POINTER, TYPE, SIZE)