VIRCAM Pipeline  1.3.3
vircam_dome_flat_combine.c
1 /* $Id: vircam_dome_flat_combine.c,v 1.58 2012-01-16 12:32:18 jim Exp $
2  *
3  * This file is part of the VIRCAM Pipeline
4  * Copyright (C) 2005 Cambridge Astronomy Survey Unit
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19  */
20 
21 /*
22  * $Author: jim $
23  * $Date: 2012-01-16 12:32:18 $
24  * $Revision: 1.58 $
25  * $Name: not supported by cvs2svn $
26  */
27 
28 /* Includes */
29 
30 #ifdef HAVE_CONFIG_H
31 #include <config.h>
32 #endif
33 
34 #include <stdio.h>
35 #include <cpl.h>
36 #include <math.h>
37 
38 #include "vircam_utils.h"
39 #include "vircam_mask.h"
40 #include "vircam_pfits.h"
41 #include "vircam_dfs.h"
42 #include "vircam_mods.h"
43 #include "vircam_stats.h"
44 #include "vircam_fits.h"
45 #include "vircam_tfits.h"
46 #include "vircam_channel.h"
47 #include "vircam_paf.h"
48 #include "vircam_wcsutils.h"
49 
50 /* Define values for bit mask that flags dummy results */
51 
52 #define MEANDOME 1
53 #define RATIMG 2
54 #define STATS_TAB 4
55 
56 /* Function prototypes */
57 
58 static int vircam_dome_flat_combine_create(cpl_plugin *) ;
59 static int vircam_dome_flat_combine_exec(cpl_plugin *) ;
60 static int vircam_dome_flat_combine_destroy(cpl_plugin *) ;
61 static int vircam_dome_flat_combine(cpl_parameterlist *, cpl_frameset *) ;
62 static int vircam_dome_flat_combine_save(cpl_frameset *framelist,
63  cpl_parameterlist *parlist);
64 static void vircam_dome_flat_combine_dummy_products(void);
65 static void vircam_dome_flat_combine_normal(int jext);
66 static int vircam_dome_flat_combine_lastbit(int jext, cpl_frameset *framelist,
67  cpl_parameterlist *parlist);
68 static void vircam_dome_flat_combine_init(void);
69 static void vircam_dome_flat_combine_tidy(int level);
70 
71 /* Static global variables */
72 
73 static struct {
74 
75  /* Input */
76 
77  float lthr;
78  float hthr;
79  int combtype;
80  int scaletype;
81  int xrej;
82  float thresh;
83  int ncells;
84  int extenum;
85 
86  /* Output */
87 
88  float flatrms;
89  float flatratio_med;
90  float flatratio_rms;
91  float minv;
92  float maxv;
93  float avev;
94 
95 } vircam_dome_flat_combine_config;
96 
97 
98 static struct {
99  cpl_size *labels;
100  cpl_frameset *domelist;
101  cpl_frame *master_dark;
102  cpl_frame *master_dome_flat;
103  cpl_frame *chantab;
104  vir_fits **good;
105  int ngood;
106  vir_mask *master_mask;
107  cpl_image *outimage;
108  vir_fits **domes;
109  int ndomes;
110  cpl_propertylist *drs;
111  unsigned char *rejmask;
112  unsigned char *rejplus;
113  vir_tfits *ctable;
114  vir_fits *mfimage;
115  vir_fits *mdark;
116  cpl_image *ratioimg;
117  cpl_table *ratioimstats;
118  cpl_propertylist *phupaf;
119 } ps;
120 
121 static int isfirst;
122 static cpl_frame *product_frame_mean_dome = NULL;
123 static cpl_frame *product_frame_ratioimg = NULL;
124 static cpl_frame *product_frame_ratioimg_stats = NULL;
125 static int we_expect;
126 static int we_get;
127 
128 static char vircam_dome_flat_combine_description[] =
129 "vircam_dome_flat_combine -- VIRCAM dome flat combine recipe.\n\n"
130 "Combine a list of dome flat frames into a mean frame. Optionally compare \n"
131 "the output frame to a master dome flat frame\n\n"
132 "The program accepts the following files in the SOF:\n\n"
133 " Tag Description\n"
134 " -----------------------------------------------------------------------\n"
135 " %-21s A list of raw dome flat images\n"
136 " %-21s A master dark frame\n"
137 " %-21s Optional reference dome flat frame\n"
138 " %-21s Optional channel table or\n"
139 " %-21s Optional initial channel table\n"
140 " %-21s Optional master bad pixel map or\n"
141 " %-21s Optional master confidence map\n"
142 "If no master dome flat is made available, then no comparison will be done\n"
143 "This means there will be no output ratio image. If a master dome is\n"
144 "available, but no channel table is, then a ratio image will be formed\n"
145 "but no stats will be written."
146 "\n";
147 
281 /* Function code */
282 
283 /*---------------------------------------------------------------------------*/
291 /*---------------------------------------------------------------------------*/
292 
293 int cpl_plugin_get_info(cpl_pluginlist *list) {
294  cpl_recipe *recipe = cpl_calloc(1,sizeof(*recipe));
295  cpl_plugin *plugin = &recipe->interface;
296  char alldesc[SZ_ALLDESC];
297  (void)snprintf(alldesc,SZ_ALLDESC,vircam_dome_flat_combine_description,
298  VIRCAM_DOME_RAW,VIRCAM_CAL_DARK,VIRCAM_REF_DOME_FLAT,
299  VIRCAM_CAL_CHANTAB,VIRCAM_CAL_CHANTAB_INIT,VIRCAM_CAL_BPM,
300  VIRCAM_CAL_CONF);
301 
302  cpl_plugin_init(plugin,
303  CPL_PLUGIN_API,
304  VIRCAM_BINARY_VERSION,
305  CPL_PLUGIN_TYPE_RECIPE,
306  "vircam_dome_flat_combine",
307  "VIRCAM dome flat combination recipe",
308  alldesc,
309  "Jim Lewis",
310  "jrl@ast.cam.ac.uk",
312  vircam_dome_flat_combine_create,
313  vircam_dome_flat_combine_exec,
314  vircam_dome_flat_combine_destroy);
315 
316  cpl_pluginlist_append(list,plugin);
317 
318  return(0);
319 }
320 
321 /*---------------------------------------------------------------------------*/
330 /*---------------------------------------------------------------------------*/
331 
332 static int vircam_dome_flat_combine_create(cpl_plugin *plugin) {
333  cpl_recipe *recipe;
334  cpl_parameter *p;
335 
336  /* Get the recipe out of the plugin */
337 
338  if (cpl_plugin_get_type(plugin) == CPL_PLUGIN_TYPE_RECIPE)
339  recipe = (cpl_recipe *)plugin;
340  else
341  return(-1);
342 
343  /* Create the parameters list in the cpl_recipe object */
344 
345  recipe->parameters = cpl_parameterlist_new();
346 
347  /* Lower threshold for rejecting underexposed images */
348 
349  p = cpl_parameter_new_value("vircam.vircam_dome_flat_combine.lthr",
350  CPL_TYPE_DOUBLE,
351  "Low rejection threshold for underexpsed images",
352  "vircam.vircam_dome_flat_combine",
353  0.0);
354  cpl_parameter_set_alias(p,CPL_PARAMETER_MODE_CLI,"lthr");
355  cpl_parameterlist_append(recipe->parameters,p);
356 
357  /* Upper threshold for rejecting overexposed images */
358 
359  p = cpl_parameter_new_value("vircam.vircam_dome_flat_combine.hthr",
360  CPL_TYPE_DOUBLE,
361  "High rejection threshold for overexposed images",
362  "vircam.vircam_dome_flat_combine",
363  65535.0);
364  cpl_parameter_set_alias(p,CPL_PARAMETER_MODE_CLI,"hthr");
365  cpl_parameterlist_append(recipe->parameters,p);
366 
367  /* Fill in the parameters. First the combination type */
368 
369  p = cpl_parameter_new_range("vircam.vircam_dome_flat_combine.combtype",
370  CPL_TYPE_INT,
371  "1 == Median,\n 2 == Mean",
372  "vircam.vircam_dome_flat_combine",
373  1,1,2);
374  cpl_parameter_set_alias(p,CPL_PARAMETER_MODE_CLI,"combtype");
375  cpl_parameterlist_append(recipe->parameters,p);
376 
377  /* The requested scaling */
378 
379  p = cpl_parameter_new_range("vircam.vircam_dome_flat_combine.scaletype",
380  CPL_TYPE_INT,
381  "0 == none,\n 1 == additive offset,\n 2 == multiplicative offset,\n 3 == exposure time scaling + additive offset",
382  "vircam.vircam_dome_flat_combine",
383  1,0,3);
384  cpl_parameter_set_alias(p,CPL_PARAMETER_MODE_CLI,"scaletype");
385  cpl_parameterlist_append(recipe->parameters,p);
386 
387  /* Extra rejection cycle */
388 
389  p = cpl_parameter_new_value("vircam.vircam_dome_flat_combine.xrej",
390  CPL_TYPE_BOOL,
391  "True if using extra rejection cycle",
392  "vircam.vircam_dome_flat_combine",
393  TRUE);
394  cpl_parameter_set_alias(p,CPL_PARAMETER_MODE_CLI,"xrej");
395  cpl_parameterlist_append(recipe->parameters,p);
396 
397  /* Rejection threshold */
398 
399  p = cpl_parameter_new_value("vircam.vircam_dome_flat_combine.thresh",
400  CPL_TYPE_DOUBLE,
401  "Rejection threshold in sigma above background",
402  "vircam.vircam_dome_flat_combine",5.0);
403  cpl_parameter_set_alias(p,CPL_PARAMETER_MODE_CLI,"thresh");
404  cpl_parameterlist_append(recipe->parameters,p);
405 
406  /* How many cells to divide each data channel */
407 
408  p = cpl_parameter_new_enum("vircam.vircam_dome_flat_combine.ncells",
409  CPL_TYPE_INT,
410  "Number of cells for data channel stats",
411  "vircam.vircam_dome_flat_combine",8,7,1,2,4,8,
412  16,32,64);
413  cpl_parameter_set_alias(p,CPL_PARAMETER_MODE_CLI,"ncells");
414  cpl_parameterlist_append(recipe->parameters,p);
415 
416  /* Extension number of input frames to use */
417 
418  p = cpl_parameter_new_range("vircam.vircam_dome_flat_combine.extenum",
419  CPL_TYPE_INT,
420  "Extension number to be done, 0 == all",
421  "vircam.vircam_dome_flat_combine",
422  1,0,16);
423  cpl_parameter_set_alias(p,CPL_PARAMETER_MODE_CLI,"ext");
424  cpl_parameterlist_append(recipe->parameters,p);
425 
426  /* Get out of here */
427 
428  return(0);
429 }
430 
431 
432 /*---------------------------------------------------------------------------*/
438 /*---------------------------------------------------------------------------*/
439 
440 static int vircam_dome_flat_combine_exec(cpl_plugin *plugin) {
441  cpl_recipe *recipe;
442 
443  /* Get the recipe out of the plugin */
444 
445  if (cpl_plugin_get_type(plugin) == CPL_PLUGIN_TYPE_RECIPE)
446  recipe = (cpl_recipe *)plugin;
447  else
448  return(-1);
449 
450  return(vircam_dome_flat_combine(recipe->parameters,recipe->frames));
451 }
452 
453 /*---------------------------------------------------------------------------*/
459 /*---------------------------------------------------------------------------*/
460 
461 static int vircam_dome_flat_combine_destroy(cpl_plugin *plugin) {
462  cpl_recipe *recipe ;
463 
464  /* Get the recipe out of the plugin */
465 
466  if (cpl_plugin_get_type(plugin) == CPL_PLUGIN_TYPE_RECIPE)
467  recipe = (cpl_recipe *)plugin;
468  else
469  return(-1);
470 
471  cpl_parameterlist_delete(recipe->parameters);
472  return(0);
473 }
474 
475 /*---------------------------------------------------------------------------*/
482 /*---------------------------------------------------------------------------*/
483 
484 static int vircam_dome_flat_combine(cpl_parameterlist *parlist,
485  cpl_frameset *framelist) {
486  const char *fctid="vircam_dome_flat_combine";
487  int j,jst,jfn,retval,status,live,nx,ny,ndit;
488  cpl_size nlab;
489  long i;
490  cpl_parameter *p;
491  cpl_propertylist *pp;
492  vir_fits *ff;
493 
494  /* Check validity of input frameset */
495 
496  if (framelist == NULL || cpl_frameset_get_size(framelist) <= 0) {
497  cpl_msg_error(fctid,"Input framelist NULL or has no input data");
498  return(-1);
499  }
500 
501  /* Check the files in the frameset */
502 
503  if (vircam_frameset_fexists(framelist) != VIR_OK) {
504  cpl_msg_error(fctid,"Input frameset is missing files. Check SOF");
505  return(-1);
506  }
507 
508  /* Initialise some things */
509 
510  vircam_dome_flat_combine_init();
511  we_expect = MEANDOME;
512 
513  /* Get the parameters */
514 
515  p = cpl_parameterlist_find(parlist,"vircam.vircam_dome_flat_combine.lthr");
516  vircam_dome_flat_combine_config.lthr = (float)cpl_parameter_get_double(p);
517  p = cpl_parameterlist_find(parlist,"vircam.vircam_dome_flat_combine.hthr");
518  vircam_dome_flat_combine_config.hthr = (float)cpl_parameter_get_double(p);
519  p = cpl_parameterlist_find(parlist,"vircam.vircam_dome_flat_combine.combtype");
520  vircam_dome_flat_combine_config.combtype = cpl_parameter_get_int(p);
521  p = cpl_parameterlist_find(parlist,"vircam.vircam_dome_flat_combine.scaletype");
522  vircam_dome_flat_combine_config.scaletype = cpl_parameter_get_int(p);
523  p = cpl_parameterlist_find(parlist,"vircam.vircam_dome_flat_combine.xrej");
524  vircam_dome_flat_combine_config.xrej = cpl_parameter_get_bool(p);
525  p = cpl_parameterlist_find(parlist,"vircam.vircam_dome_flat_combine.thresh");
526  vircam_dome_flat_combine_config.thresh = (float)cpl_parameter_get_double(p);
527  p = cpl_parameterlist_find(parlist,"vircam.vircam_dome_flat_combine.ncells");
528  vircam_dome_flat_combine_config.ncells = cpl_parameter_get_int(p);
529  p = cpl_parameterlist_find(parlist,"vircam.vircam_dome_flat_combine.extenum");
530  vircam_dome_flat_combine_config.extenum = cpl_parameter_get_int(p);
531 
532  /* Sort out raw from calib frames */
533 
534  if (vircam_dfs_set_groups(framelist) != VIR_OK) {
535  cpl_msg_error(fctid,"Cannot identify RAW and CALIB frames");
536  vircam_dome_flat_combine_tidy(2);
537  return(-1);
538  }
539 
540  /* Get the dome frames */
541 
542  if ((ps.labels = cpl_frameset_labelise(framelist,vircam_compare_tags,
543  &nlab)) == NULL) {
544  cpl_msg_error(fctid,"Cannot labelise the input frames");
545  vircam_dome_flat_combine_tidy(2);
546  return(-1);
547  }
548  if ((ps.domelist = vircam_frameset_subgroup(framelist,ps.labels,nlab,
549  VIRCAM_DOME_RAW)) == NULL) {
550  cpl_msg_error(fctid,"Cannot find dome frames in input frameset");
551  vircam_dome_flat_combine_tidy(2);
552  return(-1);
553  }
554  ps.ndomes = cpl_frameset_get_size(ps.domelist);
555 
556  /* Check to see if there is a master dark frame */
557 
558  if ((ps.master_dark = vircam_frameset_subgroup_1(framelist,ps.labels,nlab,
559  VIRCAM_CAL_DARK)) == NULL) {
560  cpl_msg_error(fctid,"No master dark found");
561  vircam_dome_flat_combine_tidy(2);
562  return(-1);
563  }
564 
565  /* Check to see if there is a master dome flat frame */
566 
567  if ((ps.master_dome_flat = vircam_frameset_subgroup_1(framelist,ps.labels,
568  nlab,VIRCAM_REF_DOME_FLAT)) == NULL)
569  cpl_msg_info(fctid,"No master dome flat found -- no ratio image will be formed");
570  else
571  we_expect |= RATIMG;
572 
573  /* Check to see if there is a master bad pixel map. If there isn't one
574  then look for a confidence map */
575 
576  ps.master_mask = vircam_mask_define(framelist,ps.labels,nlab);
577 
578  /* Check to see if there is a channel table */
579 
580  if ((ps.chantab = vircam_frameset_subgroup_1(framelist,ps.labels,nlab,
581  VIRCAM_CAL_CHANTAB)) == NULL) {
582  if ((ps.chantab = vircam_frameset_subgroup_1(framelist,ps.labels,nlab,
583  VIRCAM_CAL_CHANTAB_INIT)) == NULL) {
584  cpl_msg_info(fctid,"No channel table found -- no ratio image stats and no linearisation will be done");
585  } else {
586  cpl_msg_info(fctid,"Channel table is labelled INIT -- no linearisation will be done");
587  if (we_expect & RATIMG)
588  we_expect |= STATS_TAB;
589  }
590  } else if (we_expect & RATIMG) {
591  we_expect |= STATS_TAB;
592  }
593 
594  /* Now, how many image extensions do we want to do? If the extension
595  number is zero, then we loop for all possible extensions. If it
596  isn't then we just do the extension specified */
597 
598  vircam_exten_range(vircam_dome_flat_combine_config.extenum,
599  (const cpl_frame *)cpl_frameset_get_frame(ps.domelist,0),
600  &jst,&jfn);
601  if (jst == -1 || jfn == -1) {
602  cpl_msg_error(fctid,"Unable to continue");
603  vircam_dome_flat_combine_tidy(2);
604  return(-1);
605  }
606 
607  /* Get the number of DITs */
608 
609  pp = cpl_propertylist_load(cpl_frame_get_filename(cpl_frameset_get_frame(ps.domelist,0)),0);
610  if (vircam_pfits_get_ndit(pp,&ndit) != VIR_OK) {
611  cpl_msg_error(fctid,"No value for NDIT available");
612  freepropertylist(pp);
613  vircam_dome_flat_combine_tidy(2);
614  return(-1);
615  }
616  cpl_propertylist_delete(pp);
617 
618  /* Get some space for the good frames */
619 
620  ps.good = cpl_malloc(ps.ndomes*sizeof(vir_fits *));
621 
622  /* Now loop for all the extension... */
623 
624  for (j = jst; j <= jfn; j++) {
625  status = VIR_OK;
626  we_get = 0;
627  isfirst = (j == jst);
628 
629  /* Load the images and the master dark. */
630 
631  ps.domes = vircam_fits_load_list(ps.domelist,CPL_TYPE_FLOAT,j);
632  if (ps.domes == NULL) {
633  cpl_msg_info(fctid,
634  "Extension %" CPL_SIZE_FORMAT " domes wouldn't load",
635  (cpl_size)j);
636  retval = vircam_dome_flat_combine_lastbit(j,framelist,parlist);
637  if (retval != 0)
638  return(-1);
639  continue;
640  }
641 
642  /* Are any of these dome flats any good? */
643 
644  ps.ngood = 0;
645  for (i = 0; i < ps.ndomes; i++) {
646  ff = ps.domes[i];
648  if (! live) {
649  cpl_msg_info(fctid,"Detector flagged dead %s",
651  vircam_fits_set_error(ff,VIR_FATAL);
652  } else {
653  ps.good[ps.ngood] = ff;
654  ps.ngood += 1;
655  }
656  }
657 
658  /* If there are no good images, then signal that we need to create
659  dummy products and move on */
660 
661  if (ps.ngood == 0) {
662  cpl_msg_info(fctid,"All images flagged bad for this extension");
663  retval = vircam_dome_flat_combine_lastbit(j,framelist,parlist);
664  if (retval != 0)
665  return(-1);
666  continue;
667  }
668 
669  /* Load the mask */
670 
671  nx = (int)cpl_image_get_size_x(vircam_fits_get_image(ps.good[0]));
672  ny = (int)cpl_image_get_size_y(vircam_fits_get_image(ps.good[0]));
673  if (vircam_mask_load(ps.master_mask,j,nx,ny) == VIR_FATAL) {
674  cpl_msg_info(fctid,
675  "Unable to load mask image %s[%" CPL_SIZE_FORMAT "]",
676  vircam_mask_get_filename(ps.master_mask),(cpl_size)j);
677  cpl_msg_info(fctid,"Forcing all pixels to be good from now on");
678  vircam_mask_force(ps.master_mask,nx,ny);
679  }
680 
681  /* Sort out the images that are either over or under exposed */
682 
683  vircam_overexp(ps.good,&(ps.ngood),ndit,
684  vircam_dome_flat_combine_config.lthr,
685  vircam_dome_flat_combine_config.hthr,0,
686  &(vircam_dome_flat_combine_config.minv),
687  &(vircam_dome_flat_combine_config.maxv),
688  &(vircam_dome_flat_combine_config.avev));
689 
690  /* Check to see how many are left. If there aren't any, then
691  signal a major error */
692 
693  if (ps.ngood == 0) {
694  cpl_msg_info(fctid,"All images either under or overexposed");
695  retval = vircam_dome_flat_combine_lastbit(j,framelist,parlist);
696  if (retval != 0)
697  return(-1);
698  continue;
699  }
700 
701  /* Right, we want to dark correct, so we need to load the mean
702  dark and make sure it isn't a dummy */
703 
704  ps.mdark = vircam_fits_load(ps.master_dark,CPL_TYPE_FLOAT,j);
705  if (ps.mdark == NULL) {
706  cpl_msg_info(fctid,
707  "Can't load master dark for extension %" CPL_SIZE_FORMAT,
708  (cpl_size)j);
709  retval = vircam_dome_flat_combine_lastbit(j,framelist,parlist);
710  if (retval != 0)
711  return(-1);
712  continue;
713  } else if (vircam_is_dummy(vircam_fits_get_ehu(ps.mdark))) {
714  cpl_msg_info(fctid,
715  "Can't master dark extension %" CPL_SIZE_FORMAT " is a dummy",
716  (cpl_size)j);
717  retval = vircam_dome_flat_combine_lastbit(j,framelist,parlist);
718  if (retval != 0)
719  return(-1);
720  continue;
721  }
722 
723  /* Loop for each image and dark correct */
724 
725  cpl_msg_info(fctid,"Dark correcting extension %" CPL_SIZE_FORMAT,
726  (cpl_size)j);
727  for (i = 0; i < ps.ngood; i++)
728  vircam_darkcor((ps.good)[i],ps.mdark,1.0,&status);
729 
730  /* We need to load the channel table (if it exists) for linearisation
731  and for the ratio image stats table */
732 
733  if (ps.chantab != NULL) {
734  ps.ctable = vircam_tfits_load(ps.chantab,j);
735  if (ps.ctable == NULL) {
736  cpl_msg_info(fctid,
737  "Channel table extension %" CPL_SIZE_FORMAT " won't load",
738  (cpl_size)j);
739  } else if (vircam_chantab_verify(vircam_tfits_get_table(ps.ctable)) != VIR_OK) {
740  cpl_msg_info(fctid,
741  "Channel table extension %" CPL_SIZE_FORMAT " has errors",
742  (cpl_size)j);
743  freetfits(ps.ctable);
744  } else {
745  pp = cpl_propertylist_load(cpl_frame_get_filename(ps.chantab),
746  (cpl_size)j);
747  if (vircam_is_dummy(pp)) {
748  cpl_msg_info(fctid,
749  "Channel table extensions %" CPL_SIZE_FORMAT " is a dummy",
750  (cpl_size)j);
751  freetfits(ps.ctable);
752  }
753  freepropertylist(pp);
754  }
755  } else
756  ps.ctable = NULL;
757 
758  /* Loop for each of the input images and linearise it if there
759  is a channel table */
760 
761  if (ps.ctable != NULL) {
762  cpl_msg_info(fctid,"Linearising extension %" CPL_SIZE_FORMAT,
763  (cpl_size)j);
764  for (i = 0; i < ps.ngood; i++)
765  (void)vircam_lincor((ps.good)[i],ps.ctable,1,ndit,&status);
766  }
767 
768  /* Correct for ndit */
769 
770  for (i = 0; i < ps.ngood; i++)
771  (void)vircam_nditcor((ps.good)[i],ndit,&status);
772 
773  /* Call the combine module */
774 
775  cpl_msg_info(fctid,"Doing combination for extension %" CPL_SIZE_FORMAT,
776  (cpl_size)j);
777  (void)vircam_imcombine(ps.good,ps.ngood,
778  vircam_dome_flat_combine_config.combtype,
779  vircam_dome_flat_combine_config.scaletype,
780  vircam_dome_flat_combine_config.xrej,
781  vircam_dome_flat_combine_config.thresh,
782  &(ps.outimage),&(ps.rejmask),&(ps.rejplus),
783  &(ps.drs),&status);
784 
785  /* If these correction and combination routines failed at any stage
786  then get out of here */
787 
788  if (status == VIR_OK) {
789  we_get |= MEANDOME;
790  vircam_dome_flat_combine_normal(j);
791  } else {
792  cpl_msg_info(fctid,"A processing step failed");
793  }
794 
795  /* Create any dummies and save the products */
796 
797  retval = vircam_dome_flat_combine_lastbit(j,framelist,parlist);
798  if (retval != 0)
799  return(-1);
800 
801  }
802  vircam_dome_flat_combine_tidy(2);
803  return(0);
804 }
805 
806 
807 /*---------------------------------------------------------------------------*/
814 /*---------------------------------------------------------------------------*/
815 
816 static int vircam_dome_flat_combine_save(cpl_frameset *framelist,
817  cpl_parameterlist *parlist) {
818  cpl_propertylist *plist,*elist,*p,*paf;
819  int status;
820  float val;
821  const char *fctid = "vircam_dome_flat_combine_save";
822  const char *outfile = "domecomb.fits";
823  const char *outdiff = "domeratio.fits";
824  const char *outdimst = "domeratiotab.fits";
825  const char *outpaf = "domecomb";
826  const char *outdpaf = "domeratio";
827  const char *recipeid = "vircam_dome_flat_combine";
828 
829  /* If we need to make a PHU then do that now based on the first frame
830  in the input frame list */
831 
832  if (isfirst) {
833 
834  /* Create a new product frame object and define some tags */
835 
836  product_frame_mean_dome = cpl_frame_new();
837  cpl_frame_set_filename(product_frame_mean_dome,outfile);
838  cpl_frame_set_tag(product_frame_mean_dome,VIRCAM_PRO_DOME_FLAT);
839  cpl_frame_set_type(product_frame_mean_dome,CPL_FRAME_TYPE_IMAGE);
840  cpl_frame_set_group(product_frame_mean_dome,CPL_FRAME_GROUP_PRODUCT);
841  cpl_frame_set_level(product_frame_mean_dome,CPL_FRAME_LEVEL_FINAL);
842 
843  /* Set up the PHU header */
844 
845  plist = vircam_fits_get_phu(ps.domes[0]);
846  ps.phupaf = vircam_paf_phu_items(plist);
847  if (ps.master_dome_flat != NULL) {
848  cpl_propertylist_update_string(ps.phupaf,"REF_DOME",
849  cpl_frame_get_filename(ps.master_dome_flat));
850  cpl_propertylist_set_comment(ps.phupaf,"REF_DOME",
851  "Reference dome flat used");
852  }
853  vircam_dfs_set_product_primary_header(plist,product_frame_mean_dome,
854  framelist,parlist,
855  (char *)recipeid,
856  "PRO-1.15",NULL,0);
857 
858  /* 'Save' the PHU image */
859 
860  if (cpl_image_save(NULL,outfile,CPL_TYPE_UCHAR,plist,
861  CPL_IO_DEFAULT) != CPL_ERROR_NONE) {
862  cpl_msg_error(fctid,"Cannot save product PHU");
863  cpl_frame_delete(product_frame_mean_dome);
864  return(-1);
865  }
866  cpl_frameset_insert(framelist,product_frame_mean_dome);
867 
868  /* Create a new product frame object for the ratio image */
869 
870  if (we_expect & RATIMG) {
871  product_frame_ratioimg = cpl_frame_new();
872  cpl_frame_set_filename(product_frame_ratioimg,outdiff);
873  cpl_frame_set_tag(product_frame_ratioimg,
874  VIRCAM_PRO_RATIOIMG_DOME_FLAT);
875  cpl_frame_set_type(product_frame_ratioimg,CPL_FRAME_TYPE_IMAGE);
876  cpl_frame_set_group(product_frame_ratioimg,
877  CPL_FRAME_GROUP_PRODUCT);
878  cpl_frame_set_level(product_frame_ratioimg,CPL_FRAME_LEVEL_FINAL);
879 
880  /* Set up the PHU header */
881 
882  plist = vircam_fits_get_phu(ps.domes[0]);
883  vircam_dfs_set_product_primary_header(plist,product_frame_ratioimg,
884  framelist,parlist,
885  (char *)recipeid,
886  "PRO-1.15",NULL,0);
887 
888  /* 'Save' the PHU image */
889 
890  if (cpl_image_save(NULL,outdiff,CPL_TYPE_UCHAR,plist,
891  CPL_IO_DEFAULT) != CPL_ERROR_NONE) {
892  cpl_msg_error(fctid,"Cannot save product PHU");
893  cpl_frame_delete(product_frame_ratioimg);
894  return(-1);
895  }
896  cpl_frameset_insert(framelist,product_frame_ratioimg);
897  }
898 
899  /* Create a new product frame object for the difference image stats
900  table */
901 
902  if (we_expect & STATS_TAB) {
903  product_frame_ratioimg_stats = cpl_frame_new();
904  cpl_frame_set_filename(product_frame_ratioimg_stats,outdimst);
905  cpl_frame_set_tag(product_frame_ratioimg_stats,
906  VIRCAM_PRO_RATIOIMG_DOME_FLAT_STATS);
907  cpl_frame_set_type(product_frame_ratioimg_stats,
908  CPL_FRAME_TYPE_TABLE);
909  cpl_frame_set_group(product_frame_ratioimg_stats,
910  CPL_FRAME_GROUP_PRODUCT);
911  cpl_frame_set_level(product_frame_ratioimg_stats,
912  CPL_FRAME_LEVEL_FINAL);
913 
914  /* Set up the PHU header */
915 
916  plist = vircam_fits_get_phu(ps.domes[0]);
918  product_frame_ratioimg_stats,
919  framelist,parlist,
920  (char *)recipeid,
921  "PRO-1.15",NULL,0);
922 
923  /* Fiddle with the extension header now */
924 
925  elist = vircam_fits_get_ehu(ps.domes[0]);
926  p = cpl_propertylist_duplicate(elist);
927  vircam_merge_propertylists(p,ps.drs);
928  vircam_paf_append(p,vircam_fits_get_phu(ps.domes[0]),
929  "ESO INS FILT1 NAME");
930  if (! (we_get & STATS_TAB))
932  vircam_dfs_set_product_exten_header(p,product_frame_ratioimg_stats,
933  framelist,parlist,
934  (char *)recipeid,
935  "PRO-1.15",NULL);
936  status = VIR_OK;
937  vircam_removewcs(p,&status);
938 
939  /* And finally the difference image stats table */
940 
941  if (cpl_table_save(ps.ratioimstats,plist,p,outdimst,
942  CPL_IO_DEFAULT) != CPL_ERROR_NONE) {
943  cpl_msg_error(fctid,"Cannot save product table extension");
944  cpl_propertylist_delete(p);
945  return(-1);
946  }
947  cpl_propertylist_delete(p);
948  cpl_frameset_insert(framelist,product_frame_ratioimg_stats);
949  }
950  }
951 
952  /* Get the extension property list */
953 
954  plist = vircam_fits_get_ehu(ps.domes[0]);
955  cpl_propertylist_update_int(plist,"ESO PRO DATANCOM",ps.ngood);
956 
957  /* Fiddle with the header now. */
958 
959  vircam_merge_propertylists(plist,ps.drs);
960  p = cpl_propertylist_duplicate(plist);
961  if (! (we_get & MEANDOME))
963  vircam_dfs_set_product_exten_header(p,product_frame_mean_dome,
964  framelist,parlist,
965  (char *)recipeid,
966  "PRO-1.15",NULL);
967 
968  /* Now save the mean dome flat image extension */
969 
970  cpl_propertylist_update_float(p,"ESO QC FLATRMS",
971  vircam_dome_flat_combine_config.flatrms);
972  cpl_propertylist_set_comment(p,"ESO QC FLATRMS","RMS of output flat");
973  cpl_propertylist_update_float(p,"ESO QC FLATMIN",
974  vircam_dome_flat_combine_config.minv);
975  cpl_propertylist_set_comment(p,"ESO QC FLATMIN","Ensemble minimum");
976  cpl_propertylist_update_float(p,"ESO QC FLATMAX",
977  vircam_dome_flat_combine_config.maxv);
978  cpl_propertylist_set_comment(p,"ESO QC FLATMAX","Ensemble maximum");
979  cpl_propertylist_update_float(p,"ESO QC FLATAVG",
980  vircam_dome_flat_combine_config.avev);
981  cpl_propertylist_set_comment(p,"ESO QC FLATAVG","Ensemble average");
982  val = vircam_dome_flat_combine_config.maxv -
983  vircam_dome_flat_combine_config.minv;
984  cpl_propertylist_update_float(p,"ESO QC FLATRNG",val);
985  cpl_propertylist_set_comment(p,"ESO QC FLATRNG","Ensemble range");
986  if (cpl_image_save(ps.outimage,outfile,CPL_TYPE_FLOAT,p,
987  CPL_IO_EXTEND) != CPL_ERROR_NONE) {
988  cpl_propertylist_delete(p);
989  cpl_msg_error(fctid,"Cannot save product image extension");
990  return(-1);
991  }
992 
993  /* Write the PAF */
994 
995  paf = vircam_paf_req_items(p);
996  vircam_merge_propertylists(paf,ps.phupaf);
997  vircam_paf_append(paf,vircam_fits_get_phu(ps.domes[0]),
998  "ESO INS FILT1 NAME");
999  vircam_paf_append(paf,p,"ESO PRO CATG");
1000  vircam_paf_append(paf,p,"ESO PRO DATANCOM");
1001  if (vircam_paf_print((char *)outpaf,"VIRCAM/vircam_dome_flat_combine",
1002  "QC file",paf) != VIR_OK)
1003  cpl_msg_warning(fctid,"Unable to save PAF for mean dome");
1004  cpl_propertylist_delete(paf);
1005  cpl_propertylist_delete(p);
1006 
1007  /* Now save the dome ratio image extension */
1008 
1009  if (we_expect & RATIMG) {
1010  p = cpl_propertylist_duplicate(plist);
1011  if (! (we_get & RATIMG))
1013  cpl_propertylist_update_float(p,"ESO QC FLATRATIO_MED",
1014  vircam_dome_flat_combine_config.flatratio_med);
1015  cpl_propertylist_set_comment(p,"ESO QC FLATRATIO_MED",
1016  "Median of ratio map");
1017  cpl_propertylist_update_float(p,"ESO QC FLATRATIO_RMS",
1018  vircam_dome_flat_combine_config.flatratio_rms);
1019  cpl_propertylist_set_comment(p,"ESO QC FLATRATIO_RMS",
1020  "RMS of ratio map");
1021  vircam_dfs_set_product_exten_header(p,product_frame_ratioimg,
1022  framelist,parlist,
1023  (char *)recipeid,
1024  "PRO-1.15",NULL);
1025  if (cpl_image_save(ps.ratioimg,outdiff,CPL_TYPE_FLOAT,p,
1026  CPL_IO_EXTEND) != CPL_ERROR_NONE) {
1027  cpl_propertylist_delete(p);
1028  cpl_msg_error(fctid,"Cannot save product image extension");
1029  return(-1);
1030  }
1031 
1032  /* Write the PAF */
1033 
1034  paf = vircam_paf_req_items(p);
1035  vircam_merge_propertylists(paf,ps.phupaf);
1036  vircam_paf_append(paf,vircam_fits_get_phu(ps.domes[0]),
1037  "ESO INS FILT1 NAME");
1038  vircam_paf_append(paf,p,"ESO PRO CATG");
1039  if (vircam_paf_print((char *)outdpaf,"VIRCAM/vircam_dome_flat_combine",
1040  "QC file",paf) != VIR_OK)
1041  cpl_msg_warning(fctid,"Unable to save PAF for ratio image");
1042  cpl_propertylist_delete(paf);
1043  cpl_propertylist_delete(p);
1044  }
1045 
1046  /* Now any further ratio image stats tables */
1047 
1048  if (! isfirst && (we_expect & STATS_TAB)) {
1049  p = cpl_propertylist_duplicate(plist);
1050  if (! (we_get & STATS_TAB))
1052  vircam_dfs_set_product_exten_header(p,product_frame_ratioimg_stats,
1053  framelist,parlist,
1054  (char *)recipeid,
1055  "PRO-1.15",NULL);
1056  status = VIR_OK;
1057  vircam_removewcs(p,&status);
1058  if (cpl_table_save(ps.ratioimstats,NULL,p,outdimst,CPL_IO_EXTEND)
1059  != CPL_ERROR_NONE) {
1060  cpl_propertylist_delete(p);
1061  cpl_msg_error(fctid,"Cannot save product table extension");
1062  return(-1);
1063  }
1064  cpl_propertylist_delete(p);
1065  }
1066 
1067  /* Get out of here */
1068 
1069  return(0);
1070 }
1071 
1072 /*---------------------------------------------------------------------------*/
1076 /*---------------------------------------------------------------------------*/
1077 
1078 static void vircam_dome_flat_combine_dummy_products(void) {
1079 
1080  /* See if you even need to be here */
1081 
1082  if (we_get == we_expect)
1083  return;
1084 
1085  /* First an output combined dome frame */
1086 
1087  if (! (we_get & MEANDOME)) {
1088  ps.outimage = vircam_dummy_image(ps.domes[0]);
1089  vircam_dome_flat_combine_config.flatrms = 0.0;
1090  }
1091 
1092  /* Do a ratio image */
1093 
1094  if ((we_expect & RATIMG) && ! (we_get & RATIMG)) {
1095  vircam_dome_flat_combine_config.flatratio_med = 0.0;
1096  vircam_dome_flat_combine_config.flatratio_rms = 0.0;
1097  ps.ratioimg = vircam_dummy_image(ps.domes[0]);
1098  }
1099 
1100  /* If a ratio image stats table is required, then do that now */
1101 
1102  if ((we_expect & STATS_TAB) && ! (we_get & STATS_TAB))
1103  ps.ratioimstats = vircam_create_diffimg_stats(0);
1104 
1105  return;
1106 }
1107 
1108 /*---------------------------------------------------------------------------*/
1113 /*---------------------------------------------------------------------------*/
1114 
1115 static void vircam_dome_flat_combine_normal(int jext) {
1116  int nx,ny,ncells;
1117  long npi;
1118  unsigned char *bpm;
1119  float *idata,med,sig,gdiff,grms;
1120  const char *fctid="vircam_dome_flat_combine_normal";
1121 
1122  /* Load up a bad pixel mask */
1123 
1124  nx = (int)cpl_image_get_size_x(ps.outimage);
1125  ny = (int)cpl_image_get_size_y(ps.outimage);
1126  npi = nx*ny;
1127  bpm = vircam_mask_get_data(ps.master_mask);
1128 
1129  /* Work out the RMS of the mean dome frame */
1130 
1131  idata = cpl_image_get_data(ps.outimage);
1132  vircam_medsig(idata,bpm,npi,&med,&sig);
1133 
1134  /* Divide through by the median */
1135 
1136  cpl_image_divide_scalar(ps.outimage,med);
1137  vircam_medmad(idata,bpm,npi,&med,&sig);
1138  sig *= 1.48;
1139  vircam_dome_flat_combine_config.flatrms = sig;
1140 
1141  /* Load up the master dome flat */
1142 
1143  if (ps.master_dome_flat != NULL) {
1144  ps.mfimage = vircam_fits_load(ps.master_dome_flat,CPL_TYPE_FLOAT,jext);
1145  if (ps.mfimage == NULL) {
1146  cpl_msg_error(fctid,
1147  "Master dome extension %" CPL_SIZE_FORMAT " won't load",
1148  (cpl_size)jext);
1149  } else if (vircam_is_dummy(vircam_fits_get_ehu(ps.mfimage))) {
1150  cpl_msg_error(fctid,
1151  "Master dome extension %" CPL_SIZE_FORMAT " is a dummy",
1152  (cpl_size)jext);
1153  freefits(ps.mfimage);
1154  }
1155  } else
1156  ps.mfimage = NULL;
1157 
1158 
1159  /* Create a ratio image. NB: the difference image routine copes if the
1160  input mean image or the channel tables are null. Thus if either or
1161  both are null because of a failure to load, then the routine will do
1162  as much as it can and return, allowing you to fill in the rest with
1163  dummy products */
1164 
1165  vircam_dome_flat_combine_config.flatratio_med = 0.0;
1166  vircam_dome_flat_combine_config.flatratio_rms = 0.0;
1167  ncells = vircam_dome_flat_combine_config.ncells;
1168  vircam_difference_image(vircam_fits_get_image(ps.mfimage),ps.outimage,bpm,
1169  vircam_tfits_get_table(ps.ctable),ncells,2,
1170  &gdiff,&grms,&(ps.ratioimg),
1171  &(ps.ratioimstats));
1172  vircam_mask_clear(ps.master_mask);
1173  vircam_dome_flat_combine_config.flatratio_med = gdiff;
1174  vircam_dome_flat_combine_config.flatratio_rms = grms;
1175  if (ps.ratioimg != NULL)
1176  we_get |= RATIMG;
1177  if (ps.ratioimstats != NULL)
1178  we_get |= STATS_TAB;
1179  return;
1180 }
1181 
1182 /*---------------------------------------------------------------------------*/
1190 /*---------------------------------------------------------------------------*/
1191 
1192 static int vircam_dome_flat_combine_lastbit(int jext, cpl_frameset *framelist,
1193  cpl_parameterlist *parlist) {
1194  int retval;
1195  const char *fctid="vircam_dome_flat_combine_lastbit";
1196 
1197  /* Make whatever dummy products you need */
1198 
1199  vircam_dome_flat_combine_dummy_products();
1200 
1201  /* Save everything */
1202 
1203  cpl_msg_info(fctid,"Saving products for extension %" CPL_SIZE_FORMAT,
1204  (cpl_size)jext);
1205  retval = vircam_dome_flat_combine_save(framelist,parlist);
1206  if (retval != 0) {
1207  vircam_dome_flat_combine_tidy(2);
1208  return(-1);
1209  }
1210 
1211  /* Free some stuff up */
1212 
1213  vircam_dome_flat_combine_tidy(1);
1214  return(0);
1215 }
1216 
1217 /*---------------------------------------------------------------------------*/
1221 /*---------------------------------------------------------------------------*/
1222 
1223 static void vircam_dome_flat_combine_init(void) {
1224  ps.labels = NULL;
1225  ps.domelist = NULL;
1226  ps.domes = NULL;
1227  ps.good = NULL;
1228  ps.master_dark = NULL;
1229  ps.master_dome_flat = NULL;
1230  ps.master_mask = NULL;
1231  ps.chantab = NULL;
1232  ps.ctable = NULL;
1233  ps.outimage = NULL;
1234  ps.drs = NULL;
1235  ps.rejmask = NULL;
1236  ps.rejplus = NULL;
1237  ps.mfimage = NULL;
1238  ps.ratioimg = NULL;
1239  ps.ratioimstats = NULL;
1240  ps.phupaf = NULL;
1241 }
1242 
1243 /*---------------------------------------------------------------------------*/
1247 /*---------------------------------------------------------------------------*/
1248 
1249 static void vircam_dome_flat_combine_tidy(int level) {
1250  freeimage(ps.outimage);
1251  freefitslist(ps.domes,ps.ndomes);
1252  freepropertylist(ps.drs);
1253  freespace(ps.rejmask);
1254  freespace(ps.rejplus);
1255  freetfits(ps.ctable);
1256  freefits(ps.mfimage);
1257  freefits(ps.mdark);
1258  freeimage(ps.ratioimg);
1259  freetable(ps.ratioimstats);
1260  if (level == 1)
1261  return;
1262 
1263  freespace(ps.labels);
1264  freeframeset(ps.domelist);
1265  freeframe(ps.master_dark);
1266  freeframe(ps.master_dome_flat);
1267  freeframe(ps.chantab);
1268  freespace(ps.good);
1269  freemask(ps.master_mask);
1270  freepropertylist(ps.phupaf);
1271 
1272 }
1273 
1276 /*
1277 
1278 $Log: not supported by cvs2svn $
1279 Revision 1.57 2012/01/15 17:40:09 jim
1280 Minor modifications to take into accout the changes in cpl API for v6
1281 
1282 Revision 1.56 2010/09/09 12:15:01 jim
1283 Added QC parameters to give ensemble min, max, ave and range flats
1284 
1285 Revision 1.55 2010/03/21 06:48:21 jim
1286 Fixed bug where DATANCOM wasn't being updated in all products
1287 
1288 Revision 1.54 2010/03/09 14:27:40 jim
1289 Now updates ESO PRO DATANCOM to reflect the number of images used
1290 
1291 Revision 1.53 2010/02/05 09:42:22 jim
1292 Fixed call to non-existent cpl routine
1293 
1294 Revision 1.52 2010/01/31 18:53:41 jim
1295 Reference flat included in paf
1296 
1297 Revision 1.51 2009/09/21 11:59:06 jim
1298 modified to use new version of vircam_overexp
1299 
1300 Revision 1.50 2009/09/09 09:50:21 jim
1301 Modified to try and get headers right
1302 
1303 Revision 1.49 2008/12/05 13:28:32 jim
1304 Fixed save routine so that the correct version of PRO CATG is written to the
1305 paf file
1306 
1307 Revision 1.48 2008/10/01 04:59:13 jim
1308 Added call to vircam_frameset_fexists to check input frameset
1309 
1310 Revision 1.47 2008/09/30 11:33:23 jim
1311 Added PRO CATG to pafs
1312 
1313 Revision 1.46 2008/09/29 11:23:47 jim
1314 Defaults to form median flat now. Also fixed header writing bug
1315 
1316 Revision 1.45 2007/11/26 09:59:06 jim
1317 Recipe now takes ndit into account when doing linearity correction
1318 
1319 Revision 1.44 2007/10/19 09:25:09 jim
1320 Fixed problems with missing includes
1321 
1322 Revision 1.43 2007/10/15 12:53:26 jim
1323 Modified for compatibiliity with cpl_4.0
1324 
1325 Revision 1.42 2007/07/18 15:35:42 jim
1326 Added better error handling for missing or corrupt mask extensions
1327 
1328 Revision 1.41 2007/07/09 13:21:55 jim
1329 Modified to use new version of vircam_exten_range
1330 
1331 Revision 1.40 2007/04/30 09:40:17 jim
1332 Added more stuff to paf files
1333 
1334 Revision 1.39 2007/04/04 10:36:18 jim
1335 Modified to use new dfs tags
1336 
1337 Revision 1.38 2007/03/29 12:19:38 jim
1338 Little changes to improve documentation
1339 
1340 Revision 1.37 2007/03/02 12:37:16 jim
1341 Removed WCS stuff from table headers
1342 
1343 Revision 1.36 2007/03/01 12:41:49 jim
1344 Modified slightly after code checking
1345 
1346 Revision 1.35 2007/02/25 06:27:41 jim
1347 plugged a few memory leaks
1348 
1349 Revision 1.34 2007/02/15 11:54:09 jim
1350 Modified to make a distinction between initial channel table and one that
1351 has the proper linearity information
1352 
1353 Revision 1.33 2007/02/15 06:59:37 jim
1354 Added ability to write QC paf files
1355 
1356 Revision 1.32 2007/02/07 10:12:39 jim
1357 Removed calls to vircam_ndit_correct as this is now no longer necessary
1358 
1359 Revision 1.31 2007/02/06 13:11:12 jim
1360 Fixed entry for PRO dictionary in cpl_dfs_set_product_header
1361 
1362 Revision 1.30 2007/02/05 14:14:05 jim
1363 Input master frame is now tagged as REFERENCE. QC removed from stats table
1364 headers
1365 
1366 Revision 1.29 2007/01/08 19:09:11 jim
1367 Fixed memory leak
1368 
1369 Revision 1.28 2006/12/13 13:26:09 jim
1370 Fxied bad sigma estimate
1371 
1372 Revision 1.27 2006/11/27 12:13:21 jim
1373 Swapped calls to cpl_propertylist_append to cpl_propertylist_update
1374 
1375 Revision 1.26 2006/11/10 09:21:48 jim
1376 Fixed bug in save routine to get the correct propertylist written to product
1377 header. Also fixed memory deallocation error in tidy routine
1378 
1379 Revision 1.25 2006/09/29 11:19:31 jim
1380 changed aliases on parameter names
1381 
1382 Revision 1.24 2006/09/09 16:49:39 jim
1383 Header comment update
1384 
1385 Revision 1.23 2006/08/27 20:30:02 jim
1386 Major mods to structure of the main processing routine to deal with missing
1387 and dummy frames. Deals better with lower level failures too
1388 
1389 Revision 1.22 2006/07/11 14:55:12 jim
1390 Now checks for zeros in the output flat and replaces them
1391 
1392 Revision 1.21 2006/06/20 19:07:01 jim
1393 Corrects for ndit != 1
1394 
1395 Revision 1.20 2006/06/15 09:58:58 jim
1396 Minor changes to docs
1397 
1398 Revision 1.19 2006/06/09 11:26:25 jim
1399 Small changes to keep lint happy
1400 
1401 Revision 1.18 2006/06/06 13:01:39 jim
1402 Fixed so that the QC parameters go into the correct headers
1403 
1404 Revision 1.17 2006/05/26 19:38:20 jim
1405 Fixed recipe so that the output flat is normalised as it should be
1406 
1407 Revision 1.16 2006/05/17 14:43:58 jim
1408 Fixed problem in save routine which messed up the PRO CATG keywords
1409 
1410 Revision 1.15 2006/05/16 13:58:47 jim
1411 Fixed memory leaks that occur from not closing images at the end of
1412 the image extension loop
1413 
1414 Revision 1.14 2006/05/10 14:30:13 jim
1415 deleted ps.domes twice
1416 
1417 Revision 1.13 2006/05/04 11:53:15 jim
1418 Fixed the way the _save routine works to be more consistent with the
1419 standard CPL way of doing things
1420 
1421 Revision 1.12 2006/04/27 09:34:48 jim
1422 Fixed data type bug in parameter lthr and hthr. Modified headers to change the
1423 dfs keywords to the latest values. Removed confidence map part.
1424 
1425 Revision 1.11 2006/04/25 14:01:37 jim
1426 fixed bug in docs
1427 
1428 Revision 1.10 2006/04/25 13:45:56 jim
1429 Fixed to adhere to new calling sequence for vircam_dfs routines
1430 
1431 Revision 1.9 2006/04/20 11:32:10 jim
1432 Added new parameters to cull out over or under exposed images
1433 
1434 Revision 1.8 2006/03/23 21:18:45 jim
1435 Minor changes mainly to comment headers
1436 
1437 Revision 1.7 2006/03/22 14:02:51 jim
1438 cosmetic changes to keep lint happy
1439 
1440 Revision 1.6 2006/03/22 13:19:59 jim
1441 Added confidence map generation
1442 
1443 Revision 1.5 2006/03/22 12:13:51 jim
1444 Modified to use new vircam_mask capability
1445 
1446 Revision 1.4 2006/03/15 10:43:40 jim
1447 Fixed a few things
1448 
1449 Revision 1.3 2006/03/08 14:32:35 jim
1450 Lots of little mods
1451 
1452 Revision 1.2 2006/03/03 14:29:06 jim
1453 Now calls routines with vir_fits.
1454 
1455 Revision 1.1 2006/02/27 13:51:17 jim
1456 new routine
1457 
1458 
1459 */
1460