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 <string.h>
00036 #include <cpl.h>
00037 #include <math.h>
00038 #include "vircam_utils.h"
00039 #include "vircam_mask.h"
00040 #include "vircam_pfits.h"
00041 #include "vircam_dfs.h"
00042 #include "vircam_mods.h"
00043 #include "vircam_fits.h"
00044 #include "vircam_tfits.h"
00045 #include "vircam_jmp_utils.h"
00046
00047
00048
00049 static int vircam_jitter_microstep_process_create(cpl_plugin *);
00050 static int vircam_jitter_microstep_process_exec(cpl_plugin *);
00051 static int vircam_jitter_microstep_process_destroy(cpl_plugin *);
00052 static int vircam_jitter_microstep_process(cpl_parameterlist *,
00053 cpl_frameset *);
00054 static cpl_propertylist *vircam_jitter_microstep_process_dummyqc(int type);
00055
00056
00057 static char vircam_jitter_microstep_process_description[] =
00058 "vircam_jitter_microstep_process -- VIRCAM science product recipe.\n\n"
00059 "Process a complete pawprint for VIRCAM data. Remove instrumental\n"
00060 "signature, interleave microstep sequences (if done), combine jitters\n"
00061 "photometrically and astrometrically calibrate the pawprint image\n\n"
00062 "The program accepts the following files in the SOF:\n\n"
00063 " Tag Description\n"
00064 " -----------------------------------------------------------------------\n"
00065 " %-21s A list of raw science images or\n"
00066 " %-21s A list of raw science images (extended)\n"
00067 " %-21s A master dark frame\n"
00068 " %-21s A master twilight flat frame\n"
00069 " %-21s A channel table\n"
00070 " %-21s A photometric calibration table\n"
00071 " %-21s A readnoise/gain file\n"
00072 " %-21s A master confidence map or\n"
00073 " %-21s A master bad pixel mask\n"
00074 " %-21s A master standard star index\n"
00075 "All of the above are required\n"
00076 "\n";
00077
00203
00204
00205
00213
00214
00215 int cpl_plugin_get_info(cpl_pluginlist *list) {
00216 cpl_recipe *recipe = cpl_calloc(1,sizeof(*recipe));
00217 cpl_plugin *plugin = &recipe->interface;
00218 char alldesc[SZ_ALLDESC];
00219 (void)snprintf(alldesc,SZ_ALLDESC,
00220 vircam_jitter_microstep_process_description,
00221 VIRCAM_SCI_OBJECT_RAW,VIRCAM_SCI_OBJECT_EXT_RAW,
00222 VIRCAM_CAL_DARK,VIRCAM_CAL_TWILIGHT_FLAT,VIRCAM_CAL_CHANTAB,
00223 VIRCAM_CAL_PHOTTAB,VIRCAM_CAL_READGAINFILE,VIRCAM_CAL_CONF,
00224 VIRCAM_CAL_BPM,VIRCAM_CAL_2MASS);
00225
00226 cpl_plugin_init(plugin,
00227 CPL_PLUGIN_API,
00228 VIRCAM_BINARY_VERSION,
00229 CPL_PLUGIN_TYPE_RECIPE,
00230 "vircam_jitter_microstep_process",
00231 "VIRCAM jitter microstep recipe",
00232 alldesc,
00233 "Jim Lewis",
00234 "jrl@ast.cam.ac.uk",
00235 vircam_get_license(),
00236 vircam_jitter_microstep_process_create,
00237 vircam_jitter_microstep_process_exec,
00238 vircam_jitter_microstep_process_destroy);
00239
00240 cpl_pluginlist_append(list,plugin);
00241
00242 return(0);
00243 }
00244
00245
00254
00255
00256 static int vircam_jitter_microstep_process_create(cpl_plugin *plugin) {
00257 cpl_recipe *recipe;
00258 cpl_parameter *p;
00259
00260
00261
00262 if (cpl_plugin_get_type(plugin) == CPL_PLUGIN_TYPE_RECIPE)
00263 recipe = (cpl_recipe *)plugin;
00264 else
00265 return(-1);
00266
00267
00268
00269 recipe->parameters = cpl_parameterlist_new();
00270
00271
00272
00273 p = cpl_parameter_new_value("vircam.vircam_jitter_microstep_process.ipix",
00274 CPL_TYPE_INT,
00275 "Minimum pixel area for each detected object",
00276 "vircam.vircam_jitter_microstep_process",5);
00277 cpl_parameter_set_alias(p,CPL_PARAMETER_MODE_CLI,"ipix");
00278 cpl_parameterlist_append(recipe->parameters,p);
00279
00280
00281
00282 p = cpl_parameter_new_value("vircam.vircam_jitter_microstep_process.thresh",
00283 CPL_TYPE_DOUBLE,
00284 "Detection threshold in sigma above sky",
00285 "vircam.vircam_jitter_microstep_process",2.0);
00286 cpl_parameter_set_alias(p,CPL_PARAMETER_MODE_CLI,"thr");
00287 cpl_parameterlist_append(recipe->parameters,p);
00288
00289
00290
00291 p = cpl_parameter_new_value("vircam.vircam_jitter_microstep_process.icrowd",
00292 CPL_TYPE_BOOL,"Use deblending?",
00293 "vircam.vircam_jitter_microstep_process",0);
00294 cpl_parameter_set_alias(p,CPL_PARAMETER_MODE_CLI,"icrowd");
00295 cpl_parameterlist_append(recipe->parameters,p);
00296
00297
00298
00299 p = cpl_parameter_new_value("vircam.vircam_jitter_microstep_process.rcore",
00300 CPL_TYPE_DOUBLE,"Value of Rcore in pixels",
00301 "vircam.vircam_jitter_microstep_process",4.0);
00302 cpl_parameter_set_alias(p,CPL_PARAMETER_MODE_CLI,"rcore");
00303 cpl_parameterlist_append(recipe->parameters,p);
00304
00305
00306
00307 p = cpl_parameter_new_value("vircam.vircam_jitter_microstep_process.nbsize",
00308 CPL_TYPE_INT,"Background smoothing box size",
00309 "vircam.vircam_jitter_microstep_process",64);
00310 cpl_parameter_set_alias(p,CPL_PARAMETER_MODE_CLI,"nb");
00311 cpl_parameterlist_append(recipe->parameters,p);
00312
00313
00314
00315 p = cpl_parameter_new_value("vircam.vircam_jitter_microstep_process.savecat",
00316 CPL_TYPE_BOOL,"Save catalogue?",
00317 "vircam.vircam_jitter_microstep_process",1);
00318 cpl_parameter_set_alias(p,CPL_PARAMETER_MODE_CLI,"savecat");
00319 cpl_parameterlist_append(recipe->parameters,p);
00320
00321
00322
00323
00324 p = cpl_parameter_new_value("vircam.vircam_jitter_microstep_process.destripe",
00325 CPL_TYPE_BOOL,"Destripe images?",
00326 "vircam.vircam_jitter_microstep_process",1);
00327 cpl_parameter_set_alias(p,CPL_PARAMETER_MODE_CLI,"destripe");
00328 cpl_parameterlist_append(recipe->parameters,p);
00329
00330
00331
00332 p = cpl_parameter_new_value("vircam.vircam_jitter_microstep_process.skycor",
00333 CPL_TYPE_BOOL,"Sky correct images?",
00334 "vircam.vircam_jitter_microstep_process",1);
00335 cpl_parameter_set_alias(p,CPL_PARAMETER_MODE_CLI,"skycor");
00336 cpl_parameterlist_append(recipe->parameters,p);
00337
00338
00339
00340 p = cpl_parameter_new_range("vircam.vircam_jitter_microstep_process.extenum",
00341 CPL_TYPE_INT,
00342 "Extension number to be done, 0 == all",
00343 "vircam.vircam_jitter_microstep_process",
00344 1,0,16);
00345 cpl_parameter_set_alias(p,CPL_PARAMETER_MODE_CLI,"ext");
00346 cpl_parameterlist_append(recipe->parameters,p);
00347
00348
00349
00350 return(0);
00351 }
00352
00353
00354
00360
00361
00362 static int vircam_jitter_microstep_process_exec(cpl_plugin *plugin) {
00363 cpl_recipe *recipe;
00364
00365
00366
00367 if (cpl_plugin_get_type(plugin) == CPL_PLUGIN_TYPE_RECIPE)
00368 recipe = (cpl_recipe *)plugin;
00369 else
00370 return(-1);
00371
00372 return(vircam_jitter_microstep_process(recipe->parameters,recipe->frames));
00373 }
00374
00375
00381
00382
00383 static int vircam_jitter_microstep_process_destroy(cpl_plugin *plugin) {
00384 cpl_recipe *recipe ;
00385
00386
00387
00388 if (cpl_plugin_get_type(plugin) == CPL_PLUGIN_TYPE_RECIPE)
00389 recipe = (cpl_recipe *)plugin;
00390 else
00391 return(-1);
00392
00393 cpl_parameterlist_delete(recipe->parameters);
00394 return(0);
00395 }
00396
00397
00404
00405
00406 static int vircam_jitter_microstep_process(cpl_parameterlist *parlist,
00407 cpl_frameset *framelist) {
00408 const char *fctid="vircam_jitter_microstep_process";
00409 cpl_parameter *p;
00410 int nlab,jst,jfn,status,j,i,retval,nusteps,isconf,live,ndit;
00411 float readnoise,gain,gaincor_fac;
00412 vir_fits *ff;
00413 cpl_frame *catindex;
00414 cpl_propertylist *pp;
00415
00416
00417
00418 if (framelist == NULL || cpl_frameset_get_size(framelist) <= 0) {
00419 cpl_msg_error(fctid,"Input framelist NULL or has no input data\n");
00420 return(-1);
00421 }
00422
00423
00424
00425 vircam_jmp_init();
00426 (void)strncpy(vircam_recipename,fctid,VIRCAM_PATHSZ);
00427 (void)snprintf(vircam_recipepaf,VIRCAM_PATHSZ,"VIRCAM/%s",fctid);
00428 recflag = RECSCI;
00429
00430
00431
00432 p = cpl_parameterlist_find(parlist,
00433 "vircam.vircam_jitter_microstep_process.ipix");
00434 vircam_jmp_config.ipix = cpl_parameter_get_int(p);
00435 p = cpl_parameterlist_find(parlist,
00436 "vircam.vircam_jitter_microstep_process.thresh");
00437 vircam_jmp_config.threshold = (float)cpl_parameter_get_double(p);
00438 p = cpl_parameterlist_find(parlist,
00439 "vircam.vircam_jitter_microstep_process.icrowd");
00440 vircam_jmp_config.icrowd = cpl_parameter_get_bool(p);
00441 p = cpl_parameterlist_find(parlist,
00442 "vircam.vircam_jitter_microstep_process.rcore");
00443 vircam_jmp_config.rcore = (float)cpl_parameter_get_double(p);
00444 p = cpl_parameterlist_find(parlist,
00445 "vircam.vircam_jitter_microstep_process.nbsize");
00446 vircam_jmp_config.nbsize = cpl_parameter_get_int(p);
00447 p = cpl_parameterlist_find(parlist,
00448 "vircam.vircam_jitter_microstep_process.savecat");
00449 vircam_jmp_config.savecat = cpl_parameter_get_bool(p);
00450 p = cpl_parameterlist_find(parlist,
00451 "vircam.vircam_jitter_microstep_process.destripe");
00452 vircam_jmp_config.destripe = cpl_parameter_get_bool(p);
00453 p = cpl_parameterlist_find(parlist,
00454 "vircam.vircam_jitter_microstep_process.skycor");
00455 vircam_jmp_config.skycor = cpl_parameter_get_bool(p);
00456 p = cpl_parameterlist_find(parlist,
00457 "vircam.vircam_jitter_microstep_process.extenum");
00458 vircam_jmp_config.extenum = cpl_parameter_get_int(p);
00459
00460
00461
00462 if (vircam_dfs_set_groups(framelist) != VIR_OK) {
00463 cpl_msg_error(fctid,"Cannot identify RAW and CALIB frames");
00464 vircam_jmp_tidy(0);
00465 return(-1);
00466 }
00467
00468
00469
00470 if ((ps.labels = cpl_frameset_labelise(framelist,vircam_compare_tags,
00471 &nlab)) == NULL) {
00472 cpl_msg_error(fctid,"Cannot labelise the input frames");
00473 vircam_jmp_tidy(0);
00474 return(-1);
00475 }
00476
00477
00478
00479 if ((ps.science_frames =
00480 vircam_frameset_subgroup(framelist,ps.labels,nlab,
00481 VIRCAM_SCI_OBJECT_RAW)) == NULL) {
00482 if ((ps.science_frames =
00483 vircam_frameset_subgroup(framelist,ps.labels,nlab,
00484 VIRCAM_SCI_OBJECT_EXT_RAW)) == NULL) {
00485 cpl_msg_error(fctid,"No science images to process!");
00486 vircam_jmp_tidy(0);
00487 return(-1);
00488 }
00489 }
00490
00491
00492
00493 if ((ps.master_dark =
00494 vircam_frameset_subgroup_1(framelist,ps.labels,nlab,
00495 VIRCAM_CAL_DARK)) == NULL) {
00496 cpl_msg_error(fctid,"No master dark found");
00497 vircam_jmp_tidy(0);
00498 return(-1);
00499 }
00500
00501
00502
00503 if ((ps.master_twilight_flat =
00504 vircam_frameset_subgroup_1(framelist,ps.labels,nlab,
00505 VIRCAM_CAL_TWILIGHT_FLAT)) == NULL) {
00506 cpl_msg_error(fctid,"No master twilight flat found");
00507 vircam_jmp_tidy(0);
00508 return(-1);
00509 }
00510
00511
00512
00513 status = VIR_OK;
00514 if (vircam_gaincor_calc(ps.master_twilight_flat,&i,&(ps.gaincors),
00515 &status) != VIR_OK) {
00516 cpl_msg_error(fctid,"Error calculating gain corrections");
00517 vircam_jmp_tidy(0);
00518 return(-1);
00519 }
00520
00521
00522
00523 if ((ps.readgain_file =
00524 vircam_frameset_subgroup_1(framelist,ps.labels,nlab,
00525 VIRCAM_CAL_READGAINFILE)) == NULL) {
00526 cpl_msg_error(fctid,"No master readnoise/gain file found");
00527 vircam_jmp_tidy(0);
00528 return(-1);
00529 }
00530
00531
00532
00533
00534
00535 isconf = 1;
00536 if ((ps.master_conf =
00537 vircam_frameset_subgroup_1(framelist,ps.labels,nlab,
00538 VIRCAM_CAL_CONF)) == NULL) {
00539 isconf = 0;
00540 if ((ps.master_conf =
00541 vircam_frameset_subgroup_1(framelist,ps.labels,nlab,
00542 VIRCAM_CAL_BPM)) == NULL) {
00543 cpl_msg_error(fctid,"No master confidence map found");
00544 vircam_jmp_tidy(0);
00545 return(-1);
00546 }
00547 }
00548 ps.mask = vircam_mask_define(framelist,ps.labels,nlab);
00549
00550
00551
00552 if ((ps.chantab = vircam_frameset_subgroup_1(framelist,ps.labels,nlab,
00553 VIRCAM_CAL_CHANTAB)) == NULL) {
00554 cpl_msg_error(fctid,"No channel table found");
00555 vircam_jmp_tidy(0);
00556 return(-1);
00557 }
00558
00559
00560
00561 if ((ps.phottab = vircam_frameset_subgroup_1(framelist,ps.labels,nlab,
00562 VIRCAM_CAL_PHOTTAB)) == NULL) {
00563 cpl_msg_error(fctid,"No photometric table found");
00564 vircam_jmp_tidy(0);
00565 return(-1);
00566 }
00567 if ((ps.tphottab = cpl_table_load(cpl_frame_get_filename(ps.phottab),1,0)) == NULL) {
00568 cpl_msg_error(fctid,"Unable to load photometric table");
00569 vircam_jmp_tidy(0);
00570 return(-1);
00571 }
00572
00573
00574
00575 if ((catindex = vircam_frameset_subgroup_1(framelist,ps.labels,nlab,
00576 VIRCAM_CAL_2MASS)) == NULL) {
00577 cpl_msg_info(fctid,"No 2MASS index found -- cannot continue");
00578 vircam_jmp_tidy(0);
00579 return(-1);
00580 }
00581
00582
00583
00584 if (vircam_catpars(catindex,&(ps.catpath),&(ps.catname)) == VIR_FATAL) {
00585 vircam_jmp_tidy(0);
00586 cpl_frame_delete(catindex);
00587 return(-1);
00588 }
00589 cpl_frame_delete(catindex);
00590
00591
00592
00593 (void)strcpy(current_catpath,ps.catpath);
00594 (void)strcpy(current_cat,ps.catname);
00595
00596
00597
00598 pp = cpl_propertylist_load(cpl_frame_get_filename(cpl_frameset_get_frame(ps.science_frames,0)),0);
00599 if (vircam_pfits_get_ndit(pp,&ndit) != VIR_OK) {
00600 cpl_msg_error(fctid,"No value for NDIT available");
00601 freepropertylist(pp);
00602 vircam_jmp_tidy(0);
00603 return(-1);
00604 }
00605 cpl_propertylist_delete(pp);
00606
00607
00608
00609
00610
00611 vircam_exten_range(vircam_jmp_config.extenum,
00612 (const cpl_frame *)cpl_frameset_get_frame(ps.science_frames,0),
00613 &jst,&jfn);
00614 if (jst == -1 || jfn == -1) {
00615 cpl_msg_error(fctid,"Unable to continue");
00616 vircam_jmp_tidy(0);
00617 return(-1);
00618 }
00619
00620
00621
00622 status = VIR_OK;
00623 for (j = jst; j <= jfn; j++) {
00624 isfirst = (j == jst);
00625 gaincor_fac = (ps.gaincors)[j-1];
00626 cpl_msg_info(fctid,"Beginning extension [%d]",j);
00627
00628
00629
00630
00631 ps.fdark = vircam_fits_load(ps.master_dark,CPL_TYPE_FLOAT,j);
00632 if (ps.fdark == NULL) {
00633 cpl_msg_error(fctid,"Error loading master dark %s[%d]\n%s",
00634 cpl_frame_get_filename(ps.master_dark),j,
00635 cpl_error_get_message());
00636 vircam_jmp_tidy(0);
00637 return(-1);
00638 }
00639 ps.fflat = vircam_fits_load(ps.master_twilight_flat,CPL_TYPE_FLOAT,j);
00640 if (ps.fflat == NULL) {
00641 cpl_msg_error(fctid,"Error loading master flat %s[%d]\n%s",
00642 cpl_frame_get_filename(ps.master_twilight_flat),j,
00643 cpl_error_get_message());
00644 vircam_jmp_tidy(0);
00645 return(-1);
00646 }
00647 ps.fconf = vircam_fits_load(ps.master_conf,CPL_TYPE_INT,j);
00648 if (ps.fconf == NULL) {
00649 cpl_msg_error(fctid,"Error loading master conf %s[%d]\n%s",
00650 cpl_frame_get_filename(ps.master_conf),j,
00651 cpl_error_get_message());
00652 vircam_jmp_tidy(0);
00653 return(-1);
00654 }
00655 if (! isconf)
00656 vircam_jmp_bpm2conf();
00657 if (vircam_mask_load(ps.mask,j,
00658 cpl_image_get_size_x(vircam_fits_get_image(ps.fconf)),
00659 cpl_image_get_size_y(vircam_fits_get_image(ps.fconf))) != VIR_OK) {
00660 cpl_msg_error(fctid,"Error loading mask from master conf %s[%d]\n%s",
00661 cpl_frame_get_filename(ps.master_conf),j,
00662 cpl_error_get_message());
00663 vircam_jmp_tidy(0);
00664 return(-1);
00665 }
00666 ps.fchantab = vircam_tfits_load(ps.chantab,j);
00667 if (ps.fchantab == NULL) {
00668 cpl_msg_error(fctid,"Error loading channel table %s[%d]\n%s",
00669 cpl_frame_get_filename(ps.chantab),j,
00670 cpl_error_get_message());
00671 vircam_jmp_tidy(0);
00672 return(-1);
00673 }
00674
00675
00676
00677 ps.nscience = cpl_frameset_get_size(ps.science_frames);
00678 ps.sci_fits = vircam_fits_load_list(ps.science_frames,CPL_TYPE_FLOAT,j);
00679 if (ps.sci_fits == NULL) {
00680 cpl_msg_error(fctid,"Error loading science frames extension %d: %s",
00681 j,cpl_error_get_message());
00682 vircam_jmp_tidy(0);
00683 return(-1);
00684 }
00685
00686
00687
00688
00689 for (i = 0; i < ps.nscience; i++) {
00690 ff = ps.sci_fits[i];
00691 vircam_pfits_get_detlive(vircam_fits_get_ehu(ff),&live);
00692 if (! live)
00693 vircam_fits_set_error(ff,VIR_FATAL);
00694 }
00695
00696
00697
00698 vircam_jmp_get_readnoise_gain(j,&readnoise,&gain);
00699
00700
00701
00702 cpl_msg_info(fctid,"Doing stage1 corrections");
00703 for (i = 0; i < ps.nscience; i++) {
00704 ff = ps.sci_fits[i];
00705 cpl_propertylist_update_float(vircam_fits_get_ehu(ff),"READNOIS",
00706 readnoise);
00707 cpl_propertylist_set_comment(vircam_fits_get_ehu(ff),"READNOIS",
00708 "[e-] Readnoise used in processing");
00709 cpl_propertylist_update_float(vircam_fits_get_ehu(ff),"GAIN",gain);
00710 cpl_propertylist_set_comment(vircam_fits_get_ehu(ff),"GAIN",
00711 "[e-/adu] Gain used in processing");
00712 if (vircam_fits_get_status(ff) == VIR_FATAL) {
00713 cpl_msg_info(fctid,"Detector is flagged dead in %s",
00714 vircam_fits_get_fullname(ff));
00715 continue;
00716 }
00717 status = VIR_OK;
00718 (void)vircam_darkcor(ff,ps.fdark,1.0,&status);
00719 (void)vircam_lincor(ff,ps.fchantab,1,ndit,&status);
00720 (void)vircam_flatcor(ff,ps.fflat,&status);
00721 (void)vircam_gaincor(ff,gaincor_fac,&status);
00722 if (vircam_jmp_config.destripe)
00723 (void)vircam_destripe(ff,ps.mask,&status);
00724 vircam_fits_set_error(ff,status);
00725 }
00726
00727
00728
00729 if (vircam_jmp_config.skycor) {
00730 cpl_msg_info(fctid,"Doing sky correction");
00731 vircam_jmp_skycor();
00732 }
00733
00734
00735
00736
00737
00738 retval = vircam_pfits_get_nusteps(vircam_fits_get_phu(ps.sci_fits[0]),
00739 &nusteps);
00740 if (retval != VIR_OK) {
00741 cpl_msg_warning(fctid,"Unable to get nusteps from header.\nAssuming no microstepping");
00742 nusteps = 1;
00743 }
00744
00745
00746
00747
00748 ps.ndith = 0;
00749 if (nusteps == 1) {
00750 cpl_msg_info(fctid,"No interleaving will be done");
00751 ps.dith_input = cpl_malloc(ps.nscience*sizeof(vir_fits *));
00752 ps.dithc_input = cpl_malloc(sizeof(vir_fits *));
00753 for (i = 0; i < ps.nscience; i++) {
00754 if (vircam_fits_get_status(ps.sci_fits[i]) == VIR_OK)
00755 ps.dith_input[ps.ndith++] = ps.sci_fits[i];
00756 }
00757 ps.dithc_input[0] = ps.fconf;
00758 ps.ndithc = 1;
00759 interlv = 0;
00760
00761
00762
00763
00764
00765 } else {
00766 cpl_msg_info(fctid,"Interleaving");
00767 vircam_jmp_interleave();
00768 interlv = 1;
00769 }
00770
00771
00772
00773 cpl_msg_info(fctid,"Working out jitter offsets");
00774 vircam_jmp_dither_offsets();
00775 cpl_msg_info(fctid,"Stacking jittered frame");
00776 vircam_jmp_dither_images();
00777
00778
00779
00780 cpl_msg_info(fctid,"Doing object extraction");
00781 vircam_jmp_catalogue();
00782
00783
00784
00785 cpl_msg_info(fctid,"Matching objects with 2mass standards");
00786 vircam_jmp_matched_stds();
00787
00788
00789
00790 cpl_msg_info(fctid,"Fitting a WCS");
00791 vircam_jmp_wcsfit();
00792
00793
00794
00795 cpl_msg_info(fctid,"Doing photometric zeropoint calculation");
00796 vircam_jmp_photcal();
00797
00798
00799
00800 cpl_msg_info(fctid,"Saving simple images");
00801 vircam_jmp_save_simple(framelist,parlist);
00802 vircam_mask_clear(ps.mask);
00803
00804
00805
00806 if (interlv) {
00807 cpl_msg_info(fctid,"Saving superframe images");
00808 vircam_jmp_save_super(framelist,parlist);
00809 }
00810
00811
00812
00813 cpl_msg_info(fctid,"Saving stacked images");
00814 dummyqc = vircam_jitter_microstep_process_dummyqc(1);
00815 vircam_jmp_save_stack(framelist,parlist);
00816 freepropertylist(dummyqc);
00817 if (vircam_jmp_config.savecat) {
00818 cpl_msg_info(fctid,"Saving stacked image catalogues");
00819 dummyqc = vircam_jitter_microstep_process_dummyqc(2);
00820 vircam_jmp_save_catalogue(framelist,parlist);
00821 freepropertylist(dummyqc);
00822 }
00823
00824
00825
00826 vircam_jmp_tidy(1);
00827 }
00828
00829
00830
00831 vircam_jmp_tidy(0);
00832 return(0);
00833 }
00834
00835 static cpl_propertylist *vircam_jitter_microstep_process_dummyqc(int type) {
00836 cpl_propertylist *p;
00837
00838
00839
00840 p = cpl_propertylist_new();
00841
00842
00843
00844 switch (type) {
00845
00846
00847
00848 case 1:
00849 cpl_propertylist_update_double(p,"ESO QC WCS_DCRVAL1",0.0);
00850 cpl_propertylist_set_comment(p,"ESO QC WCS_DCRVAL1",
00851 "[deg] change in crval1");
00852 cpl_propertylist_update_double(p,"ESO QC WCS_DCRVAL2",0.0);
00853 cpl_propertylist_set_comment(p,"ESO QC WCS_DCRVAL2",
00854 "[deg] change in crval2");
00855 cpl_propertylist_update_double(p,"ESO QC WCS_DTHETA",0.0);
00856 cpl_propertylist_set_comment(p,"ESO QC WCS_DTHETA",
00857 "[deg] change in rotation");
00858 cpl_propertylist_update_double(p,"ESO QC WCS_SCALE",0.0);
00859 cpl_propertylist_set_comment(p,"ESO QC WCS_SCALE",
00860 "[arcsec] mean plate scale");
00861 cpl_propertylist_update_double(p,"ESO QC WCS_SHEAR",0.0);
00862 cpl_propertylist_set_comment(p,"ESO QC WCS_SHEAR",
00863 "[deg] abs(xrot) - abs(yrot)");
00864 cpl_propertylist_update_double(p,"ESO QC WCS_RMS",0.0);
00865 cpl_propertylist_set_comment(p,"ESO QC WCS_RMS",
00866 "[arcsec] Average error in WCS fit");
00867 cpl_propertylist_update_float(p,"ESO QC MAGZPT",0.0);
00868 cpl_propertylist_set_comment(p,"ESO QC MAGZPT",
00869 "[mag] photometric zeropoint");
00870 cpl_propertylist_update_float(p,"ESO QC MAGZERR",0.0);
00871 cpl_propertylist_set_comment(p,"ESO QC MAGZERR",
00872 "[mag] photometric zeropoint error");
00873 cpl_propertylist_update_int(p,"ESO QC MAGNZPT",0);
00874 cpl_propertylist_set_comment(p,"ESO QC MAGNZPT",
00875 "number of stars in magzpt calc");
00876 cpl_propertylist_update_float(p,"ESO QC LIMITING_MAG",0.0);
00877 cpl_propertylist_set_comment(p,"ESO QC LIMITING_MAG",
00878 "[mag] 5 sigma limiting mag");
00879 break;
00880
00881
00882
00883 case 2:
00884 cpl_propertylist_update_float(p,"ESO QC SATURATION",0.0);
00885 cpl_propertylist_set_comment(p,"ESO QC SATURATION",
00886 "[adu] Saturation level");
00887 cpl_propertylist_update_float(p,"ESO QC MEAN_SKY",0.0);
00888 cpl_propertylist_set_comment(p,"ESO QC MEAN_SKY",
00889 "[adu] Median sky brightness");
00890 cpl_propertylist_update_float(p,"ESO QC SKY_NOISE",0.0);
00891 cpl_propertylist_set_comment(p,"ESO QC SKY_NOISE",
00892 "[adu] Pixel noise at sky level");
00893 cpl_propertylist_update_float(p,"ESO QC IMAGE_SIZE",0.0);
00894 cpl_propertylist_set_comment(p,"ESO QC IMAGE_SIZE",
00895 "[pixels] Average FWHM of stellar objects")
00896 ;
00897 cpl_propertylist_update_float(p,"ESO QC ELLIPTICITY",0.0);
00898 cpl_propertylist_set_comment(p,"ESO QC ELLIPTICITY",
00899 "Average stellar ellipticity (1-b/a)");
00900 cpl_propertylist_update_float(p,"ESO QC APERTURE_CORR",0.0);
00901 cpl_propertylist_set_comment(p,"ESO QC APERTURE_CORR",
00902 "Stellar ap-corr 1x core flux");
00903 cpl_propertylist_update_int(p,"ESO QC NOISE_OBJ",0);
00904 cpl_propertylist_set_comment(p,"ESO QC NOISE_OBJ",
00905 "Number of noise objects");
00906 break;
00907 default:
00908 break;
00909 }
00910
00911
00912
00913 return(p);
00914 }
00915
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
00972
00973
00974
00975
00976
00977
00978
00979
00980
00981
00982
00983
00984
00985
00986
00987
00988
00989
00990
00991
00992
00993
00994
00995
00996
00997
00998
00999
01000
01001
01002
01003
01004
01005
01006
01007
01008
01009
01010
01011
01012
01013
01014
01015
01016
01017
01018
01019
01020
01021
01022
01023
01024
01025
01026
01027
01028
01029
01030
01031
01032
01033
01034
01035
01036
01037
01038
01039
01040
01041
01042
01043
01044
01045
01046
01047
01048
01049
01050
01051
01052
01053
01054
01055
01056
01057
01058
01059
01060
01061
01062
01063
01064
01065
01066
01067
01068
01069
01070
01071
01072
01073