61#define MODULE_ID "XSH_COMPUTE_NOISE_MAP"
85 cpl_frameset * newset = NULL ;
86 int ix = 10, iy = 10 ;
89 float avg = 0., noise ;
91 cpl_frame_group group ;
96 current = cpl_frameset_get_first( set ) ;
97 assure( current != NULL, cpl_error_get_code(),
98 "Cant get current" ) ;
100 group = cpl_frame_get_group( current ) ;
108 assure( pre != NULL, cpl_error_get_code(),
112 val = cpl_image_get( pre->
data, ix, iy, &rej ) ;
113 xsh_msg(
"Current value (%d): %f", i, val ) ;
117 }
while( (current = cpl_frameset_get_next( set )) != NULL ) ;
123 current = cpl_frameset_get_first( set ) ;
124 newset = cpl_frameset_new();
125 assure( newset != NULL, cpl_error_get_code(),
126 "Cant create new framesey" ) ;
132 cpl_frame * noisy = NULL ;
135 cpl_image_set( pre->
data, ix, iy, noise ) ;
136 xsh_msg(
" --> new value (%d): %f", i, noise ) ;
137 sprintf( fname,
"noisy_%d.fits", i ) ;
138 sprintf( tag,
"noisy_%d", i ) ;
139 xsh_msg(
"Save frame %s", fname ) ;
141 assure( noisy != NULL, cpl_error_get_code(),
142 "Cant save %s", fname ) ;
143 cpl_frame_set_filename( noisy, fname);
144 cpl_frame_set_group( noisy, group);
145 cpl_frame_set_tag( noisy, tag);
150 check_msg( cpl_frameset_insert( newset, noisy ),
151 "Cant insert noisy frame into newset" ) ;
152 }
while( (current = cpl_frameset_get_next( set ) ) != NULL ) ;
159 const char* tag, cpl_frame_group group,
165 cpl_propertylist* header = NULL;
166 cpl_image*
data = NULL;
167 cpl_frame *frame = NULL;
170 header = cpl_propertylist_new();
178 "Cant append GAIN" ) ;
181 cpl_image_fill_gaussian(
data,
189 frame = cpl_frame_new();
190 cpl_frame_set_filename(frame,name);
191 cpl_frame_set_group(frame,group);
192 cpl_frame_set_tag(frame,tag);
208 assure( pre != NULL, cpl_error_get_code(),
213 xsh_msg(
"Number of bad pixels: %d (should be 1)", count ) ;
217 if ( count == 1 )
return 0;
224 cpl_frameset* set = NULL;
225 cpl_frameset *newset = NULL ;
226 cpl_frame* medFrame = NULL;
227 cpl_frame* Master = NULL;
228 cpl_frame* frame = NULL;
229#if defined(PICKUP_NOISE_HOT_PIXEL_MAP)
230 cpl_frame * noise_map = NULL ;
234 cpl_imagelist *Liste ;
236 int nx = 100,
ny = 100 ;
251 set = cpl_frameset_new();
253 for(i=0;i<nframes;i++){
255 sprintf(framename,
"frame%d.fits",i);
259 cpl_frameset_insert(set,frame);
275 noise_clipping.
sigma = 5. ;
276 noise_clipping.
niter = 3 ;
277 noise_clipping.
frac = 0.7 ;
278 noise_clipping.
diff = 0.7 ;
288#if defined(PICKUP_NOISE_HOT_PIXEL_MAP)
313 if (cpl_error_get_code() != CPL_ERROR_NONE) {
static cpl_frame * create_frame(const char *name, int nx, int ny, const char *tag, cpl_frame_group group, xsh_instrument *instrument, int norm)
int verify_noisy(cpl_frame *frame, xsh_instrument *instrument)
cpl_frameset * add_noisy_pixels(cpl_frameset *set, xsh_instrument *instrument)
Unit test of XSH_SUBTRACT.
static xsh_instrument * instrument
static xsh_clipping_param crh_clipping
void setHeader(cpl_propertylist *header, XSH_INSTRCONFIG *iconfig, int nx, int ny, double exptime)
int xsh_bpmap_count(cpl_image *bpmap, int nx, int ny)
cpl_frame * xsh_compute_noise_map(cpl_imagelist *dataList, cpl_frame *medFrame, xsh_clipping_param *noise_clipping, xsh_instrument *instr, cpl_frame **noisyFrame)
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.
cpl_frame * xsh_pre_save(const xsh_pre *pre, const char *filename, const char *tag, int temp)
Save PRE on disk.
void xsh_prepare(cpl_frameset *frames, cpl_frame *bpmap, cpl_frame *mbias, const char *prefix, xsh_instrument *instr, const int pre_overscan_corr, const bool flag_neg_and_thresh_pix)
This function transform RAW frames dataset in PRE frames dataset attaching the default bad pixel map ...
#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_free(xsh_instrument **instrument)
free an instrument structure
xsh_instrument * xsh_instrument_new(void)
create new instrument structure
void xsh_instrument_set_decode_bp(xsh_instrument *i, const int decode_bp)
Set bad pixel code.
#define xsh_msg(...)
Print a message on info level.
void xsh_pfits_set_dit(cpl_propertylist *plist, double dit)
Write the DIT value.
void xsh_pfits_set_ndit(cpl_propertylist *plist, int ndit)
Write the NDIT value.
cpl_frame * xsh_remove_crh_multiple(cpl_frameset *rawFrames, const char *name, xsh_stack_param *stack_param, xsh_clipping_param *crh_clipping, xsh_instrument *inst, cpl_imagelist **, cpl_image **, const int save_tmp)
void xsh_free_image(cpl_image **i)
Deallocate an image and set the pointer to NULL.
void xsh_free_frame(cpl_frame **f)
Deallocate a frame 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_temporary_files(void)
Free temprary files list.
void xsh_free_propertylist(cpl_propertylist **p)
Deallocate a property list and set the pointer to NULL.
void xsh_free_imagelist(cpl_imagelist **i)
Deallocate an image list and set the pointer to NULL.
const char * stack_method
#define TESTS_CLEAN_WORKSPACE(DRL_ID)
#define TESTS_INIT_WORKSPACE(DRL_ID)
#define TESTS_INIT(DRL_ID)
#define QFLAG_OUTSIDE_DATA_RANGE
#define XSH_PRE_DATA_TYPE