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
00029
00030 #ifdef HAVE_CONFIG_H
00031 #include <config.h>
00032 #endif
00033
00034 #include <stdio.h>
00035 #include <cpl.h>
00036 #include <math.h>
00037 #include <string.h>
00038
00039 #include "vircam_utils.h"
00040 #include "vircam_mask.h"
00041 #include "vircam_dfs.h"
00042 #include "vircam_stats.h"
00043 #include "vircam_pfits.h"
00044 #include "vircam_paf.h"
00045
00046
00047
00048 static int vircam_detector_noise_create(cpl_plugin *) ;
00049 static int vircam_detector_noise_exec(cpl_plugin *) ;
00050 static int vircam_detector_noise_destroy(cpl_plugin *) ;
00051 static int vircam_detector_noise(cpl_parameterlist *, cpl_frameset *) ;
00052 static int vircam_detector_noise_save(cpl_frameset *framelist,
00053 cpl_parameterlist *parlist);
00054 static void vircam_detector_noise_init(void);
00055 static void vircam_detector_noise_tidy(void);
00056
00057
00058
00059 static struct {
00060
00061
00062
00063 float thresh;
00064 int extenum;
00065
00066
00067
00068 float gain;
00069 float readnoise;
00070 float counts;
00071 float lampflux;
00072 } vircam_detector_noise_config ;
00073
00074 static struct {
00075 int *labels;
00076 cpl_frameset *darklist;
00077 cpl_frameset *domelist;
00078 cpl_frame *inherit;
00079 cpl_image *darkim1;
00080 cpl_image *darkim2;
00081 cpl_image *domeim1;
00082 cpl_image *domeim2;
00083 vir_mask *master_mask;
00084 cpl_propertylist *ph;
00085 cpl_propertylist *eh;
00086 cpl_propertylist *phupaf;
00087 } ps;
00088
00089 static cpl_frame *product_frame = NULL;
00090 static int isfirst;
00091 static int dummy;
00092
00093 #define BUZZ_OFF {vircam_detector_noise_tidy(); return(-1);}
00094
00095 static char vircam_detector_noise_description[] =
00096 "vircam_detector_noise -- VIRCAM readnoise and gain recipe.\n\n"
00097 "Measures the read noise and gain of a chip using two dome flat exposures\n"
00098 "and two dark exposures. The flats should have the same illumination.\n"
00099 "All four frames should have the same exposure time. If the SOF\n"
00100 "contains more than two files of a given type, the others are ignored.\n\n"
00101 "The program requires the following files in the SOF:\n\n"
00102 " Tag Description\n"
00103 " -----------------------------------------------------------------------\n"
00104 " %-21s A list of two raw dark images\n"
00105 " %-21s A list of two raw dome flat image\n"
00106 " %-21s Optional master bad pixel map or\n"
00107 " %-21s Optional master confidence map\n"
00108 "\n";
00109
00175
00176
00177
00185
00186
00187 int cpl_plugin_get_info(cpl_pluginlist *list) {
00188 cpl_recipe *recipe = cpl_calloc(1,sizeof(*recipe));
00189 cpl_plugin *plugin = &recipe->interface;
00190 char alldesc[SZ_ALLDESC];
00191 (void)snprintf(alldesc,SZ_ALLDESC,vircam_detector_noise_description,
00192 VIRCAM_NOISE_DARK_RAW,VIRCAM_NOISE_FLAT_RAW,VIRCAM_CAL_BPM,
00193 VIRCAM_CAL_CONF);
00194
00195 cpl_plugin_init(plugin,
00196 CPL_PLUGIN_API,
00197 VIRCAM_BINARY_VERSION,
00198 CPL_PLUGIN_TYPE_RECIPE,
00199 "vircam_detector_noise",
00200 "VIRCAM recipe to determine readout noise and gain",
00201 alldesc,
00202 "Jim Lewis",
00203 "jrl@ast.cam.ac.uk",
00204 vircam_get_license(),
00205 vircam_detector_noise_create,
00206 vircam_detector_noise_exec,
00207 vircam_detector_noise_destroy);
00208
00209 cpl_pluginlist_append(list,plugin);
00210
00211 return(0);
00212 }
00213
00214
00215
00224
00225
00226 static int vircam_detector_noise_create(cpl_plugin *plugin) {
00227 cpl_recipe *recipe;
00228 cpl_parameter *p;
00229
00230
00231
00232 if (cpl_plugin_get_type(plugin) == CPL_PLUGIN_TYPE_RECIPE)
00233 recipe = (cpl_recipe *)plugin;
00234 else
00235 return(-1);
00236
00237
00238
00239 recipe->parameters = cpl_parameterlist_new();
00240
00241
00242
00243 p = cpl_parameter_new_value("vircam.vircam_detector_noise.thresh",
00244 CPL_TYPE_DOUBLE,
00245 "Rejection threshold in sigma above background", "vircam.vircam_detector_noise",5.0);
00246 cpl_parameter_set_alias(p,CPL_PARAMETER_MODE_CLI,"thresh");
00247 cpl_parameterlist_append(recipe->parameters,p);
00248
00249
00250
00251 p = cpl_parameter_new_range("vircam.vircam_detector_noise.extenum",
00252 CPL_TYPE_INT,
00253 "Extension number to be done, 0 == all",
00254 "vircam.vircam_detector_noise",
00255 1,0,16);
00256 cpl_parameter_set_alias(p,CPL_PARAMETER_MODE_CLI,"ext");
00257 cpl_parameterlist_append(recipe->parameters,p);
00258
00259
00260
00261 return(0);
00262 }
00263
00264
00270
00271
00272 static int vircam_detector_noise_destroy(cpl_plugin *plugin) {
00273 cpl_recipe *recipe ;
00274
00275
00276
00277 if (cpl_plugin_get_type(plugin) == CPL_PLUGIN_TYPE_RECIPE)
00278 recipe = (cpl_recipe *)plugin;
00279 else
00280 return(-1);
00281
00282 cpl_parameterlist_delete(recipe->parameters);
00283 return(0);
00284 }
00285
00286
00292
00293
00294 static int vircam_detector_noise_exec(cpl_plugin *plugin) {
00295 cpl_recipe *recipe;
00296
00297
00298
00299 if (cpl_plugin_get_type(plugin) == CPL_PLUGIN_TYPE_RECIPE)
00300 recipe = (cpl_recipe *)plugin;
00301 else
00302 return(-1);
00303
00304 return(vircam_detector_noise(recipe->parameters,recipe->frames));
00305 }
00306
00307
00314
00315
00316 static int vircam_detector_noise(cpl_parameterlist *parlist,
00317 cpl_frameset *framelist) {
00318 const char *fctid="vircam_detector_noise";
00319 cpl_parameter *p;
00320 int nlab,j,jst,jfn,retval,nx,ny,live;
00321 long nptsdark;
00322 float meandark1,meandome1,meandark2,meandome2,sigdark,lcut,hcut;
00323 float meandarkdiff,sigdarkdiff,counts;
00324 float meandomediff,sigdomediff,gain,readnoise,exptime;
00325 cpl_frame *dark1,*dark2,*dome1,*dome2;
00326 cpl_propertylist *plist;
00327 unsigned char *bpm;
00328
00329
00330
00331 if (framelist == NULL || cpl_frameset_get_size(framelist) <= 0) {
00332 cpl_msg_error(fctid,"Input framelist NULL or has no input data\n");
00333 return(-1);
00334 }
00335
00336
00337
00338 if (vircam_frameset_fexists(framelist) != VIR_OK) {
00339 cpl_msg_error(fctid,"Input frameset is missing files. Check SOF");
00340 return(-1);
00341 }
00342
00343
00344
00345 vircam_detector_noise_init();
00346
00347
00348
00349 p = cpl_parameterlist_find(parlist,"vircam.vircam_detector_noise.thresh");
00350 vircam_detector_noise_config.thresh = (float)cpl_parameter_get_double(p);
00351 p = cpl_parameterlist_find(parlist,"vircam.vircam_detector_noise.extenum");
00352 vircam_detector_noise_config.extenum = cpl_parameter_get_int(p);
00353
00354
00355
00356 if (vircam_dfs_set_groups(framelist) != VIR_OK) {
00357 cpl_msg_error(fctid,"Cannot identify RAW and CALIB frames");
00358 vircam_detector_noise_tidy();
00359 return(-1);
00360 }
00361
00362
00363
00364 if ((ps.labels = cpl_frameset_labelise(framelist,vircam_compare_tags,
00365 &nlab)) == NULL) {
00366 cpl_msg_error(fctid,"Cannot labelise the input frameset");
00367 BUZZ_OFF
00368 }
00369 if ((ps.darklist = vircam_frameset_subgroup(framelist,ps.labels,nlab,
00370 VIRCAM_NOISE_DARK_RAW)) == NULL) {
00371 cpl_msg_error(fctid,"Cannot find dark frames in input frameset");
00372 BUZZ_OFF
00373 }
00374 if (cpl_frameset_get_size(ps.darklist) < 2) {
00375 cpl_msg_error(fctid,"Dark frameset doesn't have enough frames");
00376 BUZZ_OFF
00377 }
00378 if ((ps.domelist = vircam_frameset_subgroup(framelist,ps.labels,nlab,
00379 VIRCAM_NOISE_FLAT_RAW)) == NULL) {
00380 cpl_msg_error(fctid,"Cannot find dome flat frames in input frameset");
00381 BUZZ_OFF
00382 }
00383 if (cpl_frameset_get_size(ps.domelist) < 2) {
00384 cpl_msg_error(fctid,"Dome flat frameset doesn't have enough frames");
00385 BUZZ_OFF
00386 }
00387
00388
00389
00390
00391 ps.master_mask = vircam_mask_define(framelist,ps.labels,nlab);
00392
00393
00394
00395 dark1 = cpl_frameset_get_frame(ps.darklist,0);
00396 dark2 = cpl_frameset_get_frame(ps.darklist,1);
00397 dome1 = cpl_frameset_get_frame(ps.domelist,0);
00398 dome2 = cpl_frameset_get_frame(ps.domelist,1);
00399 ps.inherit = dome1;
00400
00401
00402
00403 ps.ph = cpl_propertylist_load(cpl_frame_get_filename(dome1),0);
00404 (void)vircam_pfits_get_exptime((const cpl_propertylist *)ps.ph,&exptime);
00405
00406
00407
00408 vircam_exten_range(vircam_detector_noise_config.extenum,
00409 (const cpl_frame *)dark1,&jst,&jfn);
00410 if (jst == -1 || jfn == -1) {
00411 cpl_msg_error(fctid,"Unable to continue");
00412 vircam_detector_noise_tidy();
00413 return(-1);
00414 }
00415 for (j = jst; j <= jfn; j++) {
00416 cpl_msg_info(fctid,"Beginning work on extension %d",j);
00417 isfirst = (j == jst);
00418 vircam_detector_noise_config.readnoise = 0.0;
00419 vircam_detector_noise_config.gain = 0.0;
00420 vircam_detector_noise_config.counts = 0.0;
00421 vircam_detector_noise_config.lampflux = 0.0;
00422 dummy = 1;
00423
00424
00425
00426 ps.darkim1 = cpl_image_load(cpl_frame_get_filename(dark1),
00427 CPL_TYPE_FLOAT,0,j);
00428 ps.darkim2 = cpl_image_load(cpl_frame_get_filename(dark2),
00429 CPL_TYPE_FLOAT,0,j);
00430 ps.domeim1 = cpl_image_load(cpl_frame_get_filename(dome1),
00431 CPL_TYPE_FLOAT,0,j);
00432 ps.domeim2 = cpl_image_load(cpl_frame_get_filename(dome2),
00433 CPL_TYPE_FLOAT,0,j);
00434 if (ps.darkim1 == NULL || ps.darkim2 == NULL || ps.domeim1 == NULL ||
00435 ps.domeim2 == NULL) {
00436 cpl_error_reset();
00437 cpl_msg_error(fctid,"NULL image input for extension %d",j);
00438 retval = vircam_detector_noise_save(framelist,parlist);
00439 freeimage(ps.darkim1);
00440 freeimage(ps.darkim2);
00441 freeimage(ps.domeim1);
00442 freeimage(ps.domeim2);
00443 continue;
00444 }
00445
00446
00447
00448 ps.eh = cpl_propertylist_load(cpl_frame_get_filename(dome1),j);
00449
00450
00451
00452 plist = cpl_propertylist_load(cpl_frame_get_filename(dark1),j);
00453 vircam_pfits_get_detlive(plist,&live);
00454 if (! live) {
00455 cpl_msg_warning(fctid,"First dark image detector not live");
00456 retval = vircam_detector_noise_save(framelist,parlist);
00457 cpl_propertylist_delete(plist);
00458 freeimage(ps.darkim1);
00459 freeimage(ps.darkim2);
00460 freeimage(ps.domeim1);
00461 freeimage(ps.domeim2);
00462 freepropertylist(ps.eh);
00463 continue;
00464 }
00465 cpl_propertylist_delete(plist);
00466 plist = cpl_propertylist_load(cpl_frame_get_filename(dark2),j);
00467 vircam_pfits_get_detlive(plist,&live);
00468 if (! live) {
00469 cpl_msg_warning(fctid,"Second dark image detector not live");
00470 retval = vircam_detector_noise_save(framelist,parlist);
00471 cpl_propertylist_delete(plist);
00472 freeimage(ps.darkim1);
00473 freeimage(ps.darkim2);
00474 freeimage(ps.domeim1);
00475 freeimage(ps.domeim2);
00476 freepropertylist(ps.eh);
00477 continue;
00478 }
00479 cpl_propertylist_delete(plist);
00480 plist = cpl_propertylist_load(cpl_frame_get_filename(dome1),j);
00481 vircam_pfits_get_detlive(plist,&live);
00482 if (! live) {
00483 cpl_msg_warning(fctid,"First dome image detector not live");
00484 retval = vircam_detector_noise_save(framelist,parlist);
00485 cpl_propertylist_delete(plist);
00486 freeimage(ps.darkim1);
00487 freeimage(ps.darkim2);
00488 freeimage(ps.domeim1);
00489 freeimage(ps.domeim2);
00490 freepropertylist(ps.eh);
00491 continue;
00492 }
00493 cpl_propertylist_delete(plist);
00494 plist = cpl_propertylist_load(cpl_frame_get_filename(dome2),j);
00495 vircam_pfits_get_detlive(plist,&live);
00496 if (! live) {
00497 cpl_msg_warning(fctid,"Second dome image detector not live");
00498 retval = vircam_detector_noise_save(framelist,parlist);
00499 cpl_propertylist_delete(plist);
00500 freeimage(ps.darkim1);
00501 freeimage(ps.darkim2);
00502 freeimage(ps.domeim1);
00503 freeimage(ps.domeim2);
00504 freepropertylist(ps.eh);
00505 continue;
00506 }
00507 cpl_propertylist_delete(plist);
00508
00509
00510
00511 nx = cpl_image_get_size_x(ps.darkim1);
00512 ny = cpl_image_get_size_y(ps.darkim1);
00513 nptsdark = (long)(nx*ny);
00514
00515
00516
00517 if (vircam_mask_load(ps.master_mask,j,nx,ny) == VIR_FATAL) {
00518 cpl_msg_info(fctid,"Unable to load mask image %s[%d]",
00519 vircam_mask_get_filename(ps.master_mask),j);
00520 cpl_msg_info(fctid,"Forcing all pixels to be good from now on");
00521 vircam_mask_force(ps.master_mask,nx,ny);
00522 }
00523 bpm = vircam_mask_get_data(ps.master_mask);
00524
00525
00526
00527 vircam_medmad((float *)cpl_image_get_data(ps.darkim1),bpm,
00528 nptsdark,&meandark1,&sigdark);
00529 sigdark *= 1.48;
00530 lcut = meandark1 - vircam_detector_noise_config.thresh*sigdark;
00531 hcut = meandark1 + vircam_detector_noise_config.thresh*sigdark;
00532 vircam_medmadcut((float *)cpl_image_get_data(ps.darkim1),bpm,
00533 nptsdark,lcut,hcut,&meandark1,&sigdark);
00534 vircam_medmad((float *)cpl_image_get_data(ps.domeim1),bpm,
00535 nptsdark,&meandome1,&sigdark);
00536 sigdark *= 1.48;
00537 lcut = meandome1 - vircam_detector_noise_config.thresh*sigdark;
00538 hcut = meandome1 + vircam_detector_noise_config.thresh*sigdark;
00539 vircam_medmadcut((float *)cpl_image_get_data(ps.domeim1),bpm,
00540 nptsdark,lcut,hcut,&meandome1,&sigdark);
00541
00542
00543
00544 vircam_medmad((float *)cpl_image_get_data(ps.darkim2),bpm,
00545 nptsdark,&meandark2,&sigdark);
00546 sigdark *= 1.48;
00547 lcut = meandark2 - vircam_detector_noise_config.thresh*sigdark;
00548 hcut = meandark2 + vircam_detector_noise_config.thresh*sigdark;
00549 vircam_medmadcut((float *)cpl_image_get_data(ps.darkim2),bpm,
00550 nptsdark,lcut,hcut,&meandark2,&sigdark);
00551 vircam_medmad((float *)cpl_image_get_data(ps.domeim2),bpm,
00552 nptsdark,&meandome2,&sigdark);
00553 sigdark *= 1.48;
00554 lcut = meandome2 - vircam_detector_noise_config.thresh*sigdark;
00555 hcut = meandome2 + vircam_detector_noise_config.thresh*sigdark;
00556 vircam_medmadcut((float *)cpl_image_get_data(ps.domeim2),bpm,
00557 nptsdark,lcut,hcut,&meandome2,&sigdark);
00558
00559
00560
00561 cpl_image_subtract(ps.darkim1,ps.darkim2);
00562 cpl_image_subtract(ps.domeim1,ps.domeim2);
00563
00564
00565
00566 vircam_medmad((float *)cpl_image_get_data(ps.darkim1),bpm,
00567 nptsdark,&meandarkdiff,&sigdarkdiff);
00568 sigdarkdiff *= 1.48;
00569 lcut = meandarkdiff - vircam_detector_noise_config.thresh*sigdarkdiff;
00570 hcut = meandarkdiff + vircam_detector_noise_config.thresh*sigdarkdiff;
00571 vircam_medmadcut((float *)cpl_image_get_data(ps.darkim1),bpm,
00572 nptsdark,lcut,hcut,&meandarkdiff,&sigdarkdiff);
00573 sigdarkdiff *= 1.48;
00574 vircam_medmad((float *)cpl_image_get_data(ps.domeim1),bpm,
00575 nptsdark,&meandomediff,&sigdomediff);
00576 sigdomediff *= 1.48;
00577 lcut = meandomediff - vircam_detector_noise_config.thresh*sigdomediff;
00578 hcut = meandomediff + vircam_detector_noise_config.thresh*sigdomediff;
00579 vircam_medmadcut((float *)cpl_image_get_data(ps.domeim1),bpm,
00580 nptsdark,lcut,hcut,&meandomediff,&sigdomediff);
00581 sigdomediff *= 1.48;
00582
00583
00584
00585 counts = (meandome1 + meandome2) - (meandark1 + meandark2);
00586 vircam_detector_noise_config.counts = 0.5*counts;
00587 vircam_detector_noise_config.lampflux = 0.5*counts/exptime;
00588 gain = counts/(sigdomediff*sigdomediff - sigdarkdiff*sigdarkdiff);
00589 vircam_detector_noise_config.gain = gain;
00590
00591
00592
00593 readnoise = gain*sigdarkdiff/sqrt(2.0);
00594 vircam_detector_noise_config.readnoise = readnoise;
00595 dummy = 0;
00596
00597
00598
00599 retval = vircam_detector_noise_save(framelist,parlist);
00600 if (retval != 0) {
00601 cpl_msg_error(fctid,"Error saving results");
00602 BUZZ_OFF
00603 }
00604
00605
00606
00607 freeimage(ps.darkim1);
00608 freeimage(ps.darkim2);
00609 freeimage(ps.domeim1);
00610 freeimage(ps.domeim2);
00611 vircam_mask_clear(ps.master_mask);
00612 freepropertylist(ps.eh);
00613 }
00614 vircam_detector_noise_tidy();
00615 return(0);
00616 }
00617
00618
00625
00626
00627 static int vircam_detector_noise_save(cpl_frameset *framelist,
00628 cpl_parameterlist *parlist) {
00629 const char *fctid = "vircam_detector_noise_save";
00630 const char *outpaf = "vircam_detector_noise";
00631 const char *outfile = "detector_noise.fits";
00632 const char *recipeid = "vircam_detector_noise";
00633 cpl_propertylist *plist,*p;
00634 cpl_table *o;
00635
00636
00637
00638 if (isfirst) {
00639
00640
00641
00642 product_frame = cpl_frame_new();
00643 cpl_frame_set_filename(product_frame,outfile);
00644 cpl_frame_set_tag(product_frame,VIRCAM_PRO_READGAINFILE);
00645 cpl_frame_set_type(product_frame,CPL_FRAME_TYPE_IMAGE);
00646 cpl_frame_set_group(product_frame,CPL_FRAME_GROUP_PRODUCT);
00647 cpl_frame_set_level(product_frame,CPL_FRAME_LEVEL_FINAL);
00648
00649
00650
00651 plist = cpl_propertylist_duplicate(ps.ph);
00652 ps.phupaf = vircam_paf_phu_items(plist);
00653 vircam_dfs_set_product_primary_header(plist,product_frame,framelist,
00654 parlist,(char *)recipeid,
00655 "PRO-1.15",ps.inherit,0);
00656 vircam_paf_append(ps.phupaf,plist,"ESO PRO CATG");
00657 vircam_paf_append(ps.phupaf,plist,"ESO INS FILT1 NAME");
00658
00659
00660
00661 if (cpl_image_save(NULL,outfile,CPL_BPP_8_UNSIGNED,plist,
00662 CPL_IO_DEFAULT) != CPL_ERROR_NONE) {
00663 cpl_msg_error(fctid,"Cannot save product PHU");
00664 cpl_frame_delete(product_frame);
00665 cpl_propertylist_delete(plist);
00666 return(-1);
00667 }
00668 cpl_propertylist_delete(plist);
00669 cpl_frameset_insert(framelist,product_frame);
00670 }
00671
00672
00673
00674 plist = cpl_propertylist_duplicate(ps.eh);
00675
00676
00677
00678 cpl_propertylist_update_float(plist,"ESO QC READNOISE",
00679 vircam_detector_noise_config.readnoise);
00680 cpl_propertylist_set_comment(plist,"ESO QC READNOISE",
00681 "[e-] Calculated detector readnoise");
00682 cpl_propertylist_update_float(plist,"ESO QC CONAD",
00683 vircam_detector_noise_config.gain);
00684 cpl_propertylist_set_comment(plist,"ESO QC CONAD",
00685 "[e-/ADU] Calculated detector gain");
00686 cpl_propertylist_update_float(plist,"ESO QC COUNTS",
00687 vircam_detector_noise_config.counts);
00688 cpl_propertylist_set_comment(plist,"ESO QC COUNTS",
00689 "[ADU] Dark corrected dome counts");
00690 cpl_propertylist_update_float(plist,"ESO QC LAMPFLUX",
00691 vircam_detector_noise_config.lampflux);
00692 cpl_propertylist_set_comment(plist,"ESO QC LAMPFLUX",
00693 "[ADU/sec] Dark corrected flux level");
00694
00695
00696
00697 vircam_dfs_set_product_exten_header(plist,product_frame,framelist,
00698 parlist,(char *)recipeid,
00699 "PRO-1.15",ps.inherit);
00700 if (dummy)
00701 vircam_dummy_property(plist);
00702
00703
00704
00705 o = cpl_table_new(1);
00706 cpl_table_new_column(o,"EXTNAME",CPL_TYPE_STRING);
00707 cpl_table_new_column(o,"READNOISE",CPL_TYPE_FLOAT);
00708 cpl_table_new_column(o,"GAIN",CPL_TYPE_FLOAT);
00709
00710
00711
00712 cpl_table_set_string(o,"EXTNAME",0,
00713 cpl_propertylist_get_string(plist,"EXTNAME"));
00714 cpl_table_set_float(o,"READNOISE",0,
00715 vircam_detector_noise_config.readnoise);
00716 cpl_table_set_float(o,"GAIN",0,vircam_detector_noise_config.gain);
00717
00718
00719
00720 if (cpl_table_save(o,NULL,plist,outfile,CPL_IO_EXTEND) != CPL_ERROR_NONE) {
00721 cpl_msg_error(fctid,"Cannot save product");
00722 cpl_propertylist_delete(plist);
00723 cpl_frame_delete(product_frame);
00724 freetable(o);
00725 return(-1);
00726 }
00727 freetable(o);
00728
00729
00730
00731 p = vircam_paf_req_items(plist);
00732 vircam_merge_propertylists(p,ps.phupaf);
00733 if (vircam_paf_print((char *)outpaf,"VIRCAM/vircam_detector_noise",
00734 "QC file",p) != VIR_OK)
00735 cpl_msg_warning(fctid,"Unable to write PAF\n");
00736 cpl_propertylist_delete(p);
00737
00738
00739
00740 freepropertylist(plist);
00741 return(0);
00742 }
00743
00744
00748
00749
00750 static void vircam_detector_noise_init(void) {
00751 ps.labels = NULL;
00752 ps.darklist = NULL;
00753 ps.domelist = NULL;
00754 ps.darkim1 = NULL;
00755 ps.darkim2 = NULL;
00756 ps.domeim1 = NULL;
00757 ps.domeim2 = NULL;
00758 ps.master_mask = NULL;
00759 ps.inherit = NULL;
00760 ps.ph = NULL;
00761 ps.eh = NULL;
00762 ps.phupaf = NULL;
00763 return;
00764 }
00765
00766
00770
00771
00772 static void vircam_detector_noise_tidy(void) {
00773 freespace(ps.labels);
00774 freeframeset(ps.darklist);
00775 freeframeset(ps.domelist);
00776 freeimage(ps.darkim1);
00777 freeimage(ps.darkim2);
00778 freeimage(ps.domeim1);
00779 freeimage(ps.domeim2);
00780 freemask(ps.master_mask);
00781 freepropertylist(ps.ph);
00782 freepropertylist(ps.eh);
00783 freepropertylist(ps.phupaf);
00784 return;
00785 }
00786
00790
00791
00792
00793
00794
00795
00796
00797
00798
00799
00800
00801
00802
00803
00804
00805
00806
00807
00808
00809
00810
00811
00812
00813
00814
00815
00816
00817
00818
00819
00820
00821
00822
00823
00824
00825
00826
00827
00828
00829
00830
00831
00832
00833
00834
00835
00836
00837
00838
00839
00840
00841
00842
00843
00844
00845
00846
00847
00848
00849
00850
00851
00852
00853
00854
00855
00856
00857
00858
00859
00860
00861
00862
00863
00864
00865
00866
00867
00868
00869
00870
00871
00872
00873
00874
00875
00876
00877
00878
00879
00880
00881
00882
00883
00884
00885
00886
00887
00888
00889
00890
00891
00892
00893
00894
00895
00896
00897
00898
00899
00900
00901
00902
00903
00904
00905
00906
00907
00908
00909
00910
00911
00912
00913
00914
00915
00916
00917
00918
00919
00920
00921
00922
00923
00924
00925
00926
00927
00928
00929
00930
00931
00932
00933
00934
00935
00936
00937
00938
00939
00940
00941
00942
00943
00944
00945
00946
00947
00948
00949
00950
00951
00952
00953
00954
00955
00956
00957
00958
00959
00960
00961
00962
00963
00964
00965
00966
00967
00968
00969
00970
00971