VIRCAM Pipeline  1.3.4
vircam_jitter_microstep_process.c
1 /* $Id: vircam_jitter_microstep_process.c,v 1.70 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.70 $
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 <string.h>
36 #include <cpl.h>
37 #include <math.h>
38 
39 #include "vircam_utils.h"
40 #include "vircam_mask.h"
41 #include "vircam_pfits.h"
42 #include "vircam_dfs.h"
43 #include "vircam_mods.h"
44 #include "vircam_fits.h"
45 #include "vircam_tfits.h"
46 #include "vircam_jmp_utils.h"
47 #include "vircam_paf.h"
48 
49 /* Function prototypes */
50 
51 static int vircam_jitter_microstep_process_create(cpl_plugin *);
52 static int vircam_jitter_microstep_process_exec(cpl_plugin *);
53 static int vircam_jitter_microstep_process_destroy(cpl_plugin *);
54 static int vircam_jitter_microstep_process(cpl_parameterlist *,
55  cpl_frameset *);
56 static cpl_propertylist *vircam_jitter_microstep_process_dummyqc(int type);
57 
58 
59 static char vircam_jitter_microstep_process_description[] =
60 "vircam_jitter_microstep_process -- VIRCAM science product recipe.\n\n"
61 "Process a complete pawprint for VIRCAM data. Remove instrumental\n"
62 "signature, interleave microstep sequences (if done), combine jitters\n"
63 "photometrically and astrometrically calibrate the pawprint image\n\n"
64 "The program accepts the following files in the SOF:\n\n"
65 " Tag Description\n"
66 " -----------------------------------------------------------------------\n"
67 " %-21s A list of raw science images or\n"
68 " %-21s A list of raw science images (extended)\n"
69 " %-21s A list of offset sky exposures (optional)\n"
70 " %-21s A master dark frame\n"
71 " %-21s A master twilight flat frame\n"
72 " %-21s A master sky frame (optional)\n"
73 " %-21s A channel table\n"
74 " %-21s A photometric calibration table\n"
75 " %-21s A readnoise/gain file\n"
76 " %-21s A master confidence map or\n"
77 " %-21s A master bad pixel mask\n"
78 " %-21s A master standard star index\n"
79 "All of the above are required\n"
80 "\n";
81 
219 /* Function code */
220 
221 /*---------------------------------------------------------------------------*/
229 /*---------------------------------------------------------------------------*/
230 
231 int cpl_plugin_get_info(cpl_pluginlist *list) {
232  cpl_recipe *recipe = cpl_calloc(1,sizeof(*recipe));
233  cpl_plugin *plugin = &recipe->interface;
234  char alldesc[SZ_ALLDESC];
235  (void)snprintf(alldesc,SZ_ALLDESC,
236  vircam_jitter_microstep_process_description,
237  VIRCAM_SCI_OBJECT_RAW,VIRCAM_SCI_OBJECT_EXT_RAW,
238  VIRCAM_OFFSET_SKY_RAW,VIRCAM_CAL_DARK,
239  VIRCAM_CAL_TWILIGHT_FLAT,VIRCAM_CAL_SKY,VIRCAM_CAL_CHANTAB,
240  VIRCAM_CAL_PHOTTAB,VIRCAM_CAL_READGAINFILE,VIRCAM_CAL_CONF,
241  VIRCAM_CAL_BPM,VIRCAM_CAL_2MASS);
242 
243  cpl_plugin_init(plugin,
244  CPL_PLUGIN_API,
245  VIRCAM_BINARY_VERSION,
246  CPL_PLUGIN_TYPE_RECIPE,
247  "vircam_jitter_microstep_process",
248  "VIRCAM jitter microstep recipe",
249  alldesc,
250  "Jim Lewis",
251  "jrl@ast.cam.ac.uk",
253  vircam_jitter_microstep_process_create,
254  vircam_jitter_microstep_process_exec,
255  vircam_jitter_microstep_process_destroy);
256 
257  cpl_pluginlist_append(list,plugin);
258 
259  return(0);
260 }
261 
262 /*---------------------------------------------------------------------------*/
271 /*---------------------------------------------------------------------------*/
272 
273 static int vircam_jitter_microstep_process_create(cpl_plugin *plugin) {
274  cpl_recipe *recipe;
275  cpl_parameter *p;
276 
277  /* Get the recipe out of the plugin */
278 
279  if (cpl_plugin_get_type(plugin) == CPL_PLUGIN_TYPE_RECIPE)
280  recipe = (cpl_recipe *)plugin;
281  else
282  return(-1);
283 
284  /* Create the parameters list in the cpl_recipe object */
285 
286  recipe->parameters = cpl_parameterlist_new();
287 
288  /* Fill in the minimum object size */
289 
290  p = cpl_parameter_new_value("vircam.vircam_jitter_microstep_process.ipix",
291  CPL_TYPE_INT,
292  "Minimum pixel area for each detected object",
293  "vircam.vircam_jitter_microstep_process",5);
294  cpl_parameter_set_alias(p,CPL_PARAMETER_MODE_CLI,"ipix");
295  cpl_parameterlist_append(recipe->parameters,p);
296 
297  /* Fill in the detection threshold parameter */
298 
299  p = cpl_parameter_new_value("vircam.vircam_jitter_microstep_process.thresh",
300  CPL_TYPE_DOUBLE,
301  "Detection threshold in sigma above sky",
302  "vircam.vircam_jitter_microstep_process",2.0);
303  cpl_parameter_set_alias(p,CPL_PARAMETER_MODE_CLI,"thr");
304  cpl_parameterlist_append(recipe->parameters,p);
305 
306  /* Fill in flag to use deblending software or not */
307 
308  p = cpl_parameter_new_value("vircam.vircam_jitter_microstep_process.icrowd",
309  CPL_TYPE_BOOL,"Use deblending?",
310  "vircam.vircam_jitter_microstep_process",1);
311  cpl_parameter_set_alias(p,CPL_PARAMETER_MODE_CLI,"icrowd");
312  cpl_parameterlist_append(recipe->parameters,p);
313 
314  /* Fill in core radius */
315 
316  p = cpl_parameter_new_value("vircam.vircam_jitter_microstep_process.rcore",
317  CPL_TYPE_DOUBLE,"Value of Rcore in pixels",
318  "vircam.vircam_jitter_microstep_process",3.0);
319  cpl_parameter_set_alias(p,CPL_PARAMETER_MODE_CLI,"rcore");
320  cpl_parameterlist_append(recipe->parameters,p);
321 
322  /* Fill in background smoothing box size */
323 
324  p = cpl_parameter_new_value("vircam.vircam_jitter_microstep_process.nbsize",
325  CPL_TYPE_INT,"Background smoothing box size",
326  "vircam.vircam_jitter_microstep_process",64);
327  cpl_parameter_set_alias(p,CPL_PARAMETER_MODE_CLI,"nb");
328  cpl_parameterlist_append(recipe->parameters,p);
329 
330  /* Fill in flag to use save the output catalogue */
331 
332  p = cpl_parameter_new_value("vircam.vircam_jitter_microstep_process.savecat",
333  CPL_TYPE_BOOL,"Save catalogue?",
334  "vircam.vircam_jitter_microstep_process",1);
335  cpl_parameter_set_alias(p,CPL_PARAMETER_MODE_CLI,"savecat");
336  cpl_parameterlist_append(recipe->parameters,p);
337 
338 
339  /* Fill in flag to destripe the images */
340 
341  p = cpl_parameter_new_value("vircam.vircam_jitter_microstep_process.destripe",
342  CPL_TYPE_BOOL,"Destripe images?",
343  "vircam.vircam_jitter_microstep_process",1);
344  cpl_parameter_set_alias(p,CPL_PARAMETER_MODE_CLI,"destripe");
345  cpl_parameterlist_append(recipe->parameters,p);
346 
347  /* Fill in flag to correct sky background */
348 
349  p = cpl_parameter_new_value("vircam.vircam_jitter_microstep_process.skycor",
350  CPL_TYPE_BOOL,"Do a sky subtraction?",
351  "vircam.vircam_jitter_microstep_process",1);
352  cpl_parameter_set_alias(p,CPL_PARAMETER_MODE_CLI,"skycor");
353  cpl_parameterlist_append(recipe->parameters,p);
354 
355  /* Fill in flag to save simple images */
356 
357  p = cpl_parameter_new_value("vircam.vircam_jitter_microstep_process.savesimple",
358  CPL_TYPE_BOOL,"Save simple images?",
359  "vircam.vircam_jitter_microstep_process",0);
360  cpl_parameter_set_alias(p,CPL_PARAMETER_MODE_CLI,"savesimple");
361  cpl_parameterlist_append(recipe->parameters,p);
362 
363  /* Extension number of input frames to use */
364 
365  p = cpl_parameter_new_range("vircam.vircam_jitter_microstep_process.extenum",
366  CPL_TYPE_INT,
367  "Extension number to be done, 0 == all",
368  "vircam.vircam_jitter_microstep_process",
369  1,0,16);
370  cpl_parameter_set_alias(p,CPL_PARAMETER_MODE_CLI,"ext");
371  cpl_parameterlist_append(recipe->parameters,p);
372 
373  /* Get out of here */
374 
375  return(0);
376 }
377 
378 
379 /*---------------------------------------------------------------------------*/
385 /*---------------------------------------------------------------------------*/
386 
387 static int vircam_jitter_microstep_process_exec(cpl_plugin *plugin) {
388  cpl_recipe *recipe;
389 
390  /* Get the recipe out of the plugin */
391 
392  if (cpl_plugin_get_type(plugin) == CPL_PLUGIN_TYPE_RECIPE)
393  recipe = (cpl_recipe *)plugin;
394  else
395  return(-1);
396 
397  return(vircam_jitter_microstep_process(recipe->parameters,recipe->frames));
398 }
399 
400 /*---------------------------------------------------------------------------*/
406 /*---------------------------------------------------------------------------*/
407 
408 static int vircam_jitter_microstep_process_destroy(cpl_plugin *plugin) {
409  cpl_recipe *recipe ;
410 
411  /* Get the recipe out of the plugin */
412 
413  if (cpl_plugin_get_type(plugin) == CPL_PLUGIN_TYPE_RECIPE)
414  recipe = (cpl_recipe *)plugin;
415  else
416  return(-1);
417 
418  cpl_parameterlist_delete(recipe->parameters);
419  return(0);
420 }
421 
422 /*---------------------------------------------------------------------------*/
429 /*---------------------------------------------------------------------------*/
430 
431 static int vircam_jitter_microstep_process(cpl_parameterlist *parlist,
432  cpl_frameset *framelist) {
433  const char *fctid="vircam_jitter_microstep_process";
434  cpl_parameter *p;
435  int jst,jfn,status,j,i,retval,nusteps,isconf,live,ndit;
436  cpl_size nlab;
437  float readnoise,gain,gaincor_fac;
438  vir_fits *ff;
439  cpl_frame *catindex;
440  cpl_propertylist *pp;
441 
442  /* Check validity of input frameset */
443 
444  if (framelist == NULL || cpl_frameset_get_size(framelist) <= 0) {
445  cpl_msg_error(fctid,"Input framelist NULL or has no input data");
446  return(-1);
447  }
448 
449  /* Check the files in the frameset */
450 
451  if (vircam_frameset_fexists(framelist) != VIR_OK) {
452  cpl_msg_error(fctid,"Input frameset is missing files. Check SOF");
453  return(-1);
454  }
455 
456  /* Initialise some things */
457 
458  vircam_jmp_init();
459  (void)strncpy(vircam_recipename,fctid,VIRCAM_PATHSZ);
460  (void)snprintf(vircam_recipepaf,VIRCAM_PATHSZ,"VIRCAM/%s",fctid);
461  recflag = RECSCI;
462 
463  /* Get the parameters */
464 
465  p = cpl_parameterlist_find(parlist,
466  "vircam.vircam_jitter_microstep_process.ipix");
467  vircam_jmp_config.ipix = cpl_parameter_get_int(p);
468  p = cpl_parameterlist_find(parlist,
469  "vircam.vircam_jitter_microstep_process.thresh");
470  vircam_jmp_config.threshold = (float)cpl_parameter_get_double(p);
471  p = cpl_parameterlist_find(parlist,
472  "vircam.vircam_jitter_microstep_process.icrowd");
473  vircam_jmp_config.icrowd = cpl_parameter_get_bool(p);
474  p = cpl_parameterlist_find(parlist,
475  "vircam.vircam_jitter_microstep_process.rcore");
476  vircam_jmp_config.rcore = (float)cpl_parameter_get_double(p);
477  p = cpl_parameterlist_find(parlist,
478  "vircam.vircam_jitter_microstep_process.nbsize");
479  vircam_jmp_config.nbsize = cpl_parameter_get_int(p);
480  p = cpl_parameterlist_find(parlist,
481  "vircam.vircam_jitter_microstep_process.savecat");
482  vircam_jmp_config.savecat = cpl_parameter_get_bool(p);
483  p = cpl_parameterlist_find(parlist,
484  "vircam.vircam_jitter_microstep_process.destripe");
485  vircam_jmp_config.destripe = cpl_parameter_get_bool(p);
486  p = cpl_parameterlist_find(parlist,
487  "vircam.vircam_jitter_microstep_process.skycor");
488  vircam_jmp_config.skycor = cpl_parameter_get_bool(p);
489  p = cpl_parameterlist_find(parlist,
490  "vircam.vircam_jitter_microstep_process.savesimple");
491  vircam_jmp_config.savesimple = cpl_parameter_get_bool(p);
492  p = cpl_parameterlist_find(parlist,
493  "vircam.vircam_jitter_microstep_process.extenum");
494  vircam_jmp_config.extenum = cpl_parameter_get_int(p);
495 
496  /* Sort out raw from calib frames */
497 
498  if (vircam_dfs_set_groups(framelist) != VIR_OK) {
499  cpl_msg_error(fctid,"Cannot identify RAW and CALIB frames");
500  vircam_jmp_tidy(0);
501  return(-1);
502  }
503 
504  /* Label the input frames */
505 
506  if ((ps.labels = cpl_frameset_labelise(framelist,vircam_compare_tags,
507  &nlab)) == NULL) {
508  cpl_msg_error(fctid,"Cannot labelise the input frames");
509  vircam_jmp_tidy(0);
510  return(-1);
511  }
512 
513  /* Get the input science frames */
514 
515  if ((ps.science_frames =
516  vircam_frameset_subgroup(framelist,ps.labels,nlab,
517  VIRCAM_SCI_OBJECT_RAW)) == NULL) {
518  if ((ps.science_frames =
519  vircam_frameset_subgroup(framelist,ps.labels,nlab,
520  VIRCAM_SCI_OBJECT_EXT_RAW)) == NULL) {
521  cpl_msg_error(fctid,"No science images to process!");
522  vircam_jmp_tidy(0);
523  return(-1);
524  }
525  }
526 
527  /* Get the offset sky frames */
528 
529  if ((ps.master_sky = vircam_frameset_subgroup_1(framelist,ps.labels,nlab,
530  VIRCAM_CAL_SKY)) == NULL) {
531  if ((ps.offset_skies =
532  vircam_frameset_subgroup(framelist,ps.labels,nlab,
533  VIRCAM_OFFSET_SKY_RAW)) == NULL)
534  offsky = 0;
535  else
536  offsky = 1;
537  } else {
538  offsky = -1;
539  }
540 
541  /* Check to see if there is a master dark frame */
542 
543  if ((ps.master_dark =
544  vircam_frameset_subgroup_1(framelist,ps.labels,nlab,
545  VIRCAM_CAL_DARK)) == NULL) {
546  cpl_msg_error(fctid,"No master dark found");
547  vircam_jmp_tidy(0);
548  return(-1);
549  }
550 
551  /* Check to see if there is a master twilight flat frame */
552 
553  if ((ps.master_twilight_flat =
554  vircam_frameset_subgroup_1(framelist,ps.labels,nlab,
555  VIRCAM_CAL_TWILIGHT_FLAT)) == NULL) {
556  cpl_msg_error(fctid,"No master twilight flat found");
557  vircam_jmp_tidy(0);
558  return(-1);
559  }
560 
561  /* Get the gain corrections */
562 
563  status = VIR_OK;
564  if (vircam_gaincor_calc(ps.master_twilight_flat,&i,&(ps.gaincors),
565  &status) != VIR_OK) {
566  cpl_msg_error(fctid,"Error calculating gain corrections");
567  vircam_jmp_tidy(0);
568  return(-1);
569  }
570 
571  /* Check to see if there is a readgain file */
572 
573  if ((ps.readgain_file =
574  vircam_frameset_subgroup_1(framelist,ps.labels,nlab,
575  VIRCAM_CAL_READGAINFILE)) == NULL) {
576  cpl_msg_error(fctid,"No master readnoise/gain file found");
577  vircam_jmp_tidy(0);
578  return(-1);
579  }
580 
581  /* Check to see if there is a master confidence map. If there isn't
582  then look for a bad pixel mask that can be converted into a
583  confidence map (in an emergency) */
584 
585  isconf = 1;
586  if ((ps.master_conf =
587  vircam_frameset_subgroup_1(framelist,ps.labels,nlab,
588  VIRCAM_CAL_CONF)) == NULL) {
589  isconf = 0;
590  if ((ps.master_conf =
591  vircam_frameset_subgroup_1(framelist,ps.labels,nlab,
592  VIRCAM_CAL_BPM)) == NULL) {
593  cpl_msg_error(fctid,"No master confidence map found");
594  vircam_jmp_tidy(0);
595  return(-1);
596  }
597  }
598  ps.mask = vircam_mask_define(framelist,ps.labels,nlab);
599 
600  /* Check to see if there is a channel table */
601 
602  if ((ps.chantab = vircam_frameset_subgroup_1(framelist,ps.labels,nlab,
603  VIRCAM_CAL_CHANTAB)) == NULL) {
604  cpl_msg_error(fctid,"No channel table found");
605  vircam_jmp_tidy(0);
606  return(-1);
607  }
608 
609  /* Check to see if there is a photometric table */
610 
611  if ((ps.phottab = vircam_frameset_subgroup_1(framelist,ps.labels,nlab,
612  VIRCAM_CAL_PHOTTAB)) == NULL) {
613  cpl_msg_error(fctid,"No photometric table found");
614  vircam_jmp_tidy(0);
615  return(-1);
616  }
617  if ((ps.tphottab = cpl_table_load(cpl_frame_get_filename(ps.phottab),1,0)) == NULL) {
618  cpl_msg_error(fctid,"Unable to load photometric table");
619  vircam_jmp_tidy(0);
620  return(-1);
621  }
622 
623  /* Is the 2mass index file specified? */
624 
625  if ((catindex = vircam_frameset_subgroup_1(framelist,ps.labels,nlab,
626  VIRCAM_CAL_2MASS)) == NULL) {
627  cpl_msg_info(fctid,"No 2MASS index found -- cannot continue");
628  vircam_jmp_tidy(0);
629  return(-1);
630  }
631 
632  /* Get catalogue parameters */
633 
634  if (vircam_catpars(catindex,&(ps.catpath),&(ps.catname)) == VIR_FATAL) {
635  vircam_jmp_tidy(0);
636  cpl_frame_delete(catindex);
637  return(-1);
638  }
639  cpl_frame_delete(catindex);
640 
641  /* Set up the photometric calibration catalogue data */
642 
643  (void)strcpy(current_catpath,ps.catpath);
644  (void)strcpy(current_cat,ps.catname);
645 
646  /* Get the number of DITs */
647 
648  pp = cpl_propertylist_load(cpl_frame_get_filename(cpl_frameset_get_frame(ps.science_frames,0)),0);
649  if (vircam_pfits_get_ndit(pp,&ndit) != VIR_OK) {
650  cpl_msg_error(fctid,"No value for NDIT available");
651  freepropertylist(pp);
652  vircam_jmp_tidy(0);
653  return(-1);
654  }
655  cpl_propertylist_delete(pp);
656 
657  /* Now, how many image extensions do we want to do? If the extension
658  number is zero, then we loop for all possible extensions. If it
659  isn't then we just do the extension specified */
660 
661  vircam_exten_range(vircam_jmp_config.extenum,
662  (const cpl_frame *)cpl_frameset_get_frame(ps.science_frames,0),
663  &jst,&jfn);
664  if (jst == -1 || jfn == -1) {
665  cpl_msg_error(fctid,"Unable to continue");
666  vircam_jmp_tidy(0);
667  return(-1);
668  }
669 
670  /* Now loop for all the extensions... */
671 
672  status = VIR_OK;
673  for (j = jst; j <= jfn; j++) {
674  isfirst = (j == jst);
675  gaincor_fac = (ps.gaincors)[j-1];
676  cpl_msg_info(fctid,"Beginning extension [%" CPL_SIZE_FORMAT "]",
677  (cpl_size)j);
678 
679  /* Load up the calibration frames into vir_fits/vir_tfits structures
680  It is a fatal error if any one of them can't load properly */
681 
682  ps.fdark = vircam_fits_load(ps.master_dark,CPL_TYPE_FLOAT,j);
683  if (ps.fdark == NULL) {
684  cpl_msg_error(fctid,
685  "Error loading master dark %s[%" CPL_SIZE_FORMAT "]\n%s",
686  cpl_frame_get_filename(ps.master_dark),(cpl_size)j,
687  cpl_error_get_message());
688  vircam_jmp_tidy(0);
689  return(-1);
690  }
691  ps.fflat = vircam_fits_load(ps.master_twilight_flat,CPL_TYPE_FLOAT,j);
692  if (ps.fflat == NULL) {
693  cpl_msg_error(fctid,
694  "Error loading master flat %s[%" CPL_SIZE_FORMAT "]\n%s",
695  cpl_frame_get_filename(ps.master_twilight_flat),
696  (cpl_size)j,cpl_error_get_message());
697  vircam_jmp_tidy(0);
698  return(-1);
699  }
700  ps.fconf = vircam_fits_load(ps.master_conf,CPL_TYPE_INT,j);
701  if (ps.fconf == NULL) {
702  cpl_msg_error(fctid,
703  "Error loading master conf %s[%" CPL_SIZE_FORMAT "]\n%s",
704  cpl_frame_get_filename(ps.master_conf),(cpl_size)j,
705  cpl_error_get_message());
706  vircam_jmp_tidy(0);
707  return(-1);
708  }
709  if (! isconf)
711  if (vircam_mask_load(ps.mask,j,
712  (int)cpl_image_get_size_x(vircam_fits_get_image(ps.fconf)),
713  (int)cpl_image_get_size_y(vircam_fits_get_image(ps.fconf))) != VIR_OK) {
714  cpl_msg_error(fctid,
715  "Error loading mask from master conf %s[%" CPL_SIZE_FORMAT "]\n%s",
716  cpl_frame_get_filename(ps.master_conf),(cpl_size)j,
717  cpl_error_get_message());
718  vircam_jmp_tidy(0);
719  return(-1);
720  }
721  if (offsky == -1) {
722  ps.fsky = vircam_fits_load(ps.master_sky,CPL_TYPE_FLOAT,j);
723  if (ps.fsky == NULL) {
724  cpl_msg_error(fctid,
725  "Error loading master sky %s[%" CPL_SIZE_FORMAT "]\n%s",
726  cpl_frame_get_filename(ps.master_sky),(cpl_size)j,
727  cpl_error_get_message());
728  vircam_jmp_tidy(0);
729  return(-1);
730  }
731  }
732  ps.fchantab = vircam_tfits_load(ps.chantab,j);
733  if (ps.fchantab == NULL) {
734  cpl_msg_error(fctid,
735  "Error loading channel table %s[%" CPL_SIZE_FORMAT "]\n%s",
736  cpl_frame_get_filename(ps.chantab),(cpl_size)j,
737  cpl_error_get_message());
738  vircam_jmp_tidy(0);
739  return(-1);
740  }
741 
742  /* Load up the vir_fits structures for the science images */
743 
744  ps.nscience = cpl_frameset_get_size(ps.science_frames);
745  ps.sci_fits = vircam_fits_load_list(ps.science_frames,CPL_TYPE_FLOAT,j);
746  if (ps.sci_fits == NULL) {
747  cpl_msg_error(fctid,
748  "Error loading science frames extension %" CPL_SIZE_FORMAT ": %s",
749  (cpl_size)j,cpl_error_get_message());
750  vircam_jmp_tidy(0);
751  return(-1);
752  }
753 
754  /* Set up something for the PAFs */
755 
756  ps.phupaf = vircam_paf_phu_items(vircam_fits_get_phu(ps.sci_fits[0]));
757 
758  /* Load up the vir_fits structures for the offset skies (if needed) */
759 
760  if (offsky == 1) {
761  ps.noffsets = cpl_frameset_get_size(ps.offset_skies);
762  ps.offsky_fits = vircam_fits_load_list(ps.offset_skies,
763  CPL_TYPE_FLOAT,j);
764  if (ps.offsky_fits == NULL) {
765  cpl_msg_error(fctid,
766  "Error loading offset skies extension %" CPL_SIZE_FORMAT ": %s",
767  (cpl_size)j,cpl_error_get_message());
768  vircam_jmp_tidy(0);
769  return(-1);
770  }
771  } else {
772  ps.noffsets = 0;
773  ps.offsky_fits = NULL;
774  }
775 
776  /* Loop through and mark the frames where the header says the detector
777  wasn't live. Also check to see if the CRVAL == 0 problem is
778  present. Check for live detectors in the offset skies too */
779 
780  for (i = 0; i < ps.nscience; i++) {
781  ff = ps.sci_fits[i];
783  if (! live)
784  vircam_fits_set_error(ff,VIR_FATAL);
786  vircam_fits_get_ehu(ff)) != VIR_OK) {
787  cpl_msg_error(fctid,"Unable to correct CRVAL in %s",
789  vircam_jmp_tidy(0);
790  return(-1);
791  }
792  }
793  for (i = 0; i < ps.noffsets; i++) {
794  ff = ps.offsky_fits[i];
796  if (! live)
797  vircam_fits_set_error(ff,VIR_FATAL);
798  }
799 
800  /* Get the readnoise and gain estimate for this extension */
801 
802  vircam_jmp_get_readnoise_gain(j,&readnoise,&gain);
803 
804  /* Loop for all the science frames and do the 2d corrections. Then
805  do it for the offset skies */
806 
807  cpl_msg_info(fctid,"Doing stage1 corrections");
808  for (i = 0; i < ps.nscience; i++) {
809  ff = ps.sci_fits[i];
810  cpl_propertylist_update_float(vircam_fits_get_ehu(ff),"READNOIS",
811  readnoise);
812  cpl_propertylist_set_comment(vircam_fits_get_ehu(ff),"READNOIS",
813  "[e-] Readnoise used in processing");
814  cpl_propertylist_update_float(vircam_fits_get_ehu(ff),"GAIN",gain);
815  cpl_propertylist_set_comment(vircam_fits_get_ehu(ff),"GAIN",
816  "[e-/adu] Gain used in processing");
817  if (vircam_fits_get_status(ff) == VIR_FATAL) {
818  cpl_msg_info(fctid,"Detector is flagged dead in %s",
820  continue;
821  }
822  status = VIR_OK;
823  (void)vircam_darkcor(ff,ps.fdark,1.0,&status);
824  (void)vircam_lincor(ff,ps.fchantab,1,ndit,&status);
825  (void)vircam_nditcor(ff,ndit,&status);
826  (void)vircam_flatcor(ff,ps.fflat,&status);
827  (void)vircam_gaincor(ff,gaincor_fac,&status);
828  vircam_fits_set_error(ff,status);
829  }
830  for (i = 0; i < ps.noffsets; i++) {
831  ff = ps.offsky_fits[i];
832  if (vircam_fits_get_status(ff) == VIR_FATAL) {
833  cpl_msg_info(fctid,"Detector is flagged dead in %s",
835  continue;
836  }
837  status = VIR_OK;
838  (void)vircam_darkcor(ff,ps.fdark,1.0,&status);
839  (void)vircam_lincor(ff,ps.fchantab,1,ndit,&status);
840  (void)vircam_nditcor(ff,ndit,&status);
841  (void)vircam_flatcor(ff,ps.fflat,&status);
842  (void)vircam_gaincor(ff,gaincor_fac,&status);
843  vircam_fits_set_error(ff,status);
844  }
845 
846  /* Do a simple sky correction if requested */
847 
848  if (vircam_jmp_config.skycor) {
849  cpl_msg_info(fctid,"Doing sky correction");
851  } else {
852  for (i = 0; i < ps.nscience; i++) {
853  pp = vircam_fits_get_ehu(ps.sci_fits[i]);
854  cpl_propertylist_update_string(pp,"ESO DRS SKYCOR","none");
855  cpl_propertylist_set_comment(pp,"ESO DRS SKYCOR",
856  "Sky correction method");
857  }
858  }
859 
860  /* Do destripe if requested */
861 
862  if (vircam_jmp_config.destripe) {
863  for (i = 0; i < ps.nscience; i++) {
864  ff = ps.sci_fits[i];
865  (void)vircam_destripe(ff,ps.mask,&status);
866  vircam_fits_set_error(ff,status);
867  }
868  for (i = 0; i < ps.noffsets; i++) {
869  ff = ps.offsky_fits[i];
870  (void)vircam_destripe(ff,ps.mask,&status);
871  vircam_fits_set_error(ff,status);
872  }
873  }
874 
875  /* Look at the first frame in the list and see if the number of
876  microsteps is greater than 1. If so, then we'll have to go
877  through interleaving. */
878 
879  retval = vircam_pfits_get_nusteps(vircam_fits_get_phu(ps.sci_fits[0]),
880  &nusteps);
881  if (retval != VIR_OK) {
882  cpl_msg_warning(fctid,"Unable to get nusteps from header.\nAssuming no microstepping");
883  nusteps = 1;
884  }
885 
886  /* If the number of microsteps is 1 then copy over the good frames
887  into a fits list for dithering. */
888 
889  ps.ndith = 0;
890  if (nusteps < 4) {
891  if (nusteps == 1)
892  cpl_msg_info(fctid,"No interleaving will be done");
893  else
894  cpl_msg_warning(fctid,"Illegal number of microsteps: %" CPL_SIZE_FORMAT "\nNo interleaving will be done",
895  (cpl_size)nusteps);
896  ps.dith_input = cpl_malloc(ps.nscience*sizeof(vir_fits *));
897  ps.dithc_input = cpl_malloc(sizeof(vir_fits *));
898  for (i = 0; i < ps.nscience; i++) {
899  if (vircam_fits_get_status(ps.sci_fits[i]) == VIR_OK)
900  ps.dith_input[ps.ndith++] = ps.sci_fits[i];
901  }
902  ps.dithc_input[0] = ps.fconf;
903  ps.ndithc = 1;
904  interlv = 0;
905 
906  /* If the number of microsteps is more than 1, then we need
907  to do interleaving. The interleaving routine define
908  ps.dith_input. */
909 
910  } else {
911  cpl_msg_info(fctid,"Interleaving");
913  interlv = 1;
914  }
915 
916  /* Work out the jitter offsets and the stack the jitter frame */
917 
918  cpl_msg_info(fctid,"Working out jitter offsets");
920  cpl_msg_info(fctid,"Stacking jittered frame");
922 
923  /* Do a catalogue generation */
924 
925  cpl_msg_info(fctid,"Doing object extraction");
927 
928  /* Create a matched standards table */
929 
930  cpl_msg_info(fctid,"Matching objects with 2mass standards");
932 
933  /* Do a WCS fit for the dithered image */
934 
935  cpl_msg_info(fctid,"Fitting a WCS");
937 
938  /* Finally do the photometric zeropoint fit */
939 
940  cpl_msg_info(fctid,"Doing photometric zeropoint calculation");
942 
943  /* Save the simple images */
944 
945  if (vircam_jmp_config.savesimple) {
946  cpl_msg_info(fctid,"Saving simple images");
947  if (vircam_jmp_save_simple(framelist,parlist) != 0) {
948  vircam_jmp_tidy(0);
949  return(-1);
950  }
951  }
952  if (offsky == 1) {
953  if (vircam_jmp_config.savesimple) {
954  cpl_msg_info(fctid,"Saving offset sky simple images");
955  if (vircam_jmp_save_simple_offsets(framelist,parlist) != 0) {
956  vircam_jmp_tidy(0);
957  return(-1);
958  }
959  }
960  cpl_msg_info(fctid,"Saving mean offset sky image");
961  if (vircam_jmp_save_offsky(framelist,parlist) != 0) {
962  vircam_jmp_tidy(0);
963  return(-1);
964  }
965  }
966  vircam_mask_clear(ps.mask);
967 
968  /* Save super frames */
969 
970  if (interlv) {
971  cpl_msg_info(fctid,"Saving superframe images");
972  if (vircam_jmp_save_super(framelist,parlist) != 0) {
973  vircam_jmp_tidy(0);
974  return(-1);
975  }
976  }
977 
978  /* Save the dithered images */
979 
980  cpl_msg_info(fctid,"Saving stacked image");
981  dummyqc = vircam_jitter_microstep_process_dummyqc(1);
982  if (vircam_jmp_save_stack(framelist,parlist) != 0) {
983  vircam_jmp_tidy(0);
984  freepropertylist(dummyqc);
985  return(-1);
986  }
987  freepropertylist(dummyqc);
988  if (vircam_jmp_config.savecat) {
989  cpl_msg_info(fctid,"Saving stacked image catalogue");
990  dummyqc = vircam_jitter_microstep_process_dummyqc(2);
991  if (vircam_jmp_save_catalogue(framelist,parlist) != 0) {
992  vircam_jmp_tidy(0);
993  freepropertylist(dummyqc);
994  return(-1);
995  }
996  freepropertylist(dummyqc);
997  }
998 
999  /* Clean up on aisle 12! */
1000 
1001  vircam_jmp_tidy(1);
1002  }
1003 
1004  /* Final cleanup */
1005 
1006  vircam_jmp_tidy(0);
1007  return(0);
1008 }
1009 
1010 static cpl_propertylist *vircam_jitter_microstep_process_dummyqc(int type) {
1011  cpl_propertylist *p;
1012 
1013  /* Get an empty property list */
1014 
1015  p = cpl_propertylist_new();
1016 
1017  /* Now switch for the various products */
1018 
1019  switch (type) {
1020 
1021  /* Stack images */
1022 
1023  case 1:
1024  cpl_propertylist_update_double(p,"ESO QC WCS_DCRVAL1",0.0);
1025  cpl_propertylist_set_comment(p,"ESO QC WCS_DCRVAL1",
1026  "[deg] change in crval1");
1027  cpl_propertylist_update_double(p,"ESO QC WCS_DCRVAL2",0.0);
1028  cpl_propertylist_set_comment(p,"ESO QC WCS_DCRVAL2",
1029  "[deg] change in crval2");
1030  cpl_propertylist_update_double(p,"ESO QC WCS_DTHETA",0.0);
1031  cpl_propertylist_set_comment(p,"ESO QC WCS_DTHETA",
1032  "[deg] change in rotation");
1033  cpl_propertylist_update_double(p,"ESO QC WCS_SCALE",0.0);
1034  cpl_propertylist_set_comment(p,"ESO QC WCS_SCALE",
1035  "[arcsec] mean plate scale");
1036  cpl_propertylist_update_double(p,"ESO QC WCS_SHEAR",0.0);
1037  cpl_propertylist_set_comment(p,"ESO QC WCS_SHEAR",
1038  "[deg] abs(xrot) - abs(yrot)");
1039  cpl_propertylist_update_double(p,"ESO QC WCS_RMS",0.0);
1040  cpl_propertylist_set_comment(p,"ESO QC WCS_RMS",
1041  "[arcsec] Average error in WCS fit");
1042  cpl_propertylist_update_float(p,"ESO QC MAGZPT",0.0);
1043  cpl_propertylist_set_comment(p,"ESO QC MAGZPT",
1044  "[mag] photometric zeropoint");
1045  cpl_propertylist_update_float(p,"ESO QC MAGZERR",0.0);
1046  cpl_propertylist_set_comment(p,"ESO QC MAGZERR",
1047  "[mag] photometric zeropoint error");
1048  cpl_propertylist_update_int(p,"ESO QC MAGNZPT",0);
1049  cpl_propertylist_set_comment(p,"ESO QC MAGNZPT",
1050  "number of stars in magzpt calc");
1051  cpl_propertylist_update_int(p,"ESO QC MAGNCUT",0);
1052  cpl_propertylist_set_comment(p,"ESO QC MAGNCUT",
1053  "number of stars cut from magzpt calc");
1054  cpl_propertylist_update_float(p,"ESO QC LIMITING_MAG",0.0);
1055  cpl_propertylist_set_comment(p,"ESO QC LIMITING_MAG",
1056  "[mag] 5 sigma limiting mag");
1057  break;
1058 
1059  /* Catalogues */
1060 
1061  case 2:
1062  cpl_propertylist_update_float(p,"ESO QC SATURATION",0.0);
1063  cpl_propertylist_set_comment(p,"ESO QC SATURATION",
1064  "[adu] Saturation level");
1065  cpl_propertylist_update_float(p,"ESO QC MEAN_SKY",0.0);
1066  cpl_propertylist_set_comment(p,"ESO QC MEAN_SKY",
1067  "[adu] Median sky brightness");
1068  cpl_propertylist_update_float(p,"ESO QC SKY_NOISE",0.0);
1069  cpl_propertylist_set_comment(p,"ESO QC SKY_NOISE",
1070  "[adu] Pixel noise at sky level");
1071  cpl_propertylist_update_float(p,"ESO QC IMAGE_SIZE",0.0);
1072  cpl_propertylist_set_comment(p,"ESO QC IMAGE_SIZE",
1073  "[pixels] Average FWHM of stellar objects")
1074 ;
1075  cpl_propertylist_update_float(p,"ESO QC ELLIPTICITY",0.0);
1076  cpl_propertylist_set_comment(p,"ESO QC ELLIPTICITY",
1077  "Average stellar ellipticity (1-b/a)");
1078  cpl_propertylist_update_float(p,"ESO QC APERTURE_CORR",0.0);
1079  cpl_propertylist_set_comment(p,"ESO QC APERTURE_CORR",
1080  "Stellar ap-corr 1x core flux");
1081  cpl_propertylist_update_int(p,"ESO QC NOISE_OBJ",0);
1082  cpl_propertylist_set_comment(p,"ESO QC NOISE_OBJ",
1083  "Number of noise objects");
1084  break;
1085  default:
1086  break;
1087  }
1088 
1089  /* Get out of here */
1090 
1091  return(p);
1092 }
1093 
1096 /*
1097 
1098 $Log: not supported by cvs2svn $
1099 Revision 1.69 2012/01/15 17:40:09 jim
1100 Minor modifications to take into accout the changes in cpl API for v6
1101 
1102 Revision 1.68 2011/05/09 09:58:10 jim
1103 Cosmetic changes to stop compiler warnings
1104 
1105 Revision 1.67 2010/12/09 13:19:44 jim
1106 Modified comments
1107 
1108 Revision 1.66 2010/09/13 11:43:13 jim
1109 Added flag DRS SKYCOR if background correction isn't being done
1110 
1111 Revision 1.65 2010/09/10 11:25:19 jim
1112 Modified so that a master sky can now be used.
1113 
1114 Revision 1.64 2010/09/09 12:15:35 jim
1115 Added new QC parameter MAGNCUT
1116 
1117 Revision 1.63 2010/06/03 11:30:40 jim
1118 Modified so that object deblending is done by default. Also fixed bug where
1119 offset sky images were saved when --savesimple was switched off
1120 
1121 Revision 1.62 2010/03/21 06:47:42 jim
1122 Added code to trap for problems in saving products
1123 
1124 Revision 1.61 2010/03/12 10:44:07 lbilbao
1125 Added missing header inclusion.
1126 
1127 Revision 1.60 2010/02/08 16:35:26 jim
1128 Moved the definition of propertylist ps.phupaf to the recipes so that
1129 this doesn't fail when we don't save the simple images
1130 
1131 Revision 1.59 2010/01/31 18:57:15 jim
1132 Now simple images are only saved when you really want them
1133 
1134 Revision 1.58 2009/12/11 06:52:56 jim
1135 Minor mods to documentation
1136 
1137 Revision 1.57 2009/09/22 12:29:37 jim
1138 Modified to do offset sky exposures
1139 
1140 Revision 1.56 2009/07/03 12:30:04 jim
1141 Default value of rcore is now 3
1142 
1143 Revision 1.55 2009/02/04 09:23:29 jim
1144 Moved destriping to after sky subtraction
1145 
1146 Revision 1.54 2009/01/19 14:36:02 jim
1147 Added vircam_nditcor
1148 
1149 Revision 1.53 2008/12/08 06:38:41 jim
1150 Added trap for crval==0 error. Also added a trap for illegal 2x1 microstep
1151 sequences
1152 
1153 Revision 1.52 2008/11/27 09:14:47 jim
1154 Fixed PRO CATG keyword values for interleaved confidence maps in docs
1155 
1156 Revision 1.51 2008/11/25 18:55:59 jim
1157 took out extra sky stuff
1158 
1159 Revision 1.50 2008/11/25 12:03:21 jim
1160 Fixed doc
1161 
1162 Revision 1.49 2008/11/25 11:53:50 jim
1163 Changed type for 'skycor' parameter to an enum. Recipe now allows for standard
1164 or object masked sky estimate
1165 
1166 Revision 1.48 2008/10/01 04:59:13 jim
1167 Added call to vircam_frameset_fexists to check input frameset
1168 
1169 Revision 1.47 2008/05/06 12:15:20 jim
1170 Changed to use new version of vircam_catpars
1171 
1172 Revision 1.46 2007/11/26 09:59:06 jim
1173 Recipe now takes ndit into account when doing linearity correction
1174 
1175 Revision 1.45 2007/10/25 18:39:22 jim
1176 Altered to remove some lint messages
1177 
1178 Revision 1.44 2007/10/19 06:55:06 jim
1179 Modifications made to use new method for directing the recipes to the
1180 standard catalogues using the sof
1181 
1182 Revision 1.43 2007/07/09 13:21:55 jim
1183 Modified to use new version of vircam_exten_range
1184 
1185 Revision 1.42 2007/06/13 08:11:27 jim
1186 Modified docs to reflect changes in DFS tags
1187 
1188 Revision 1.41 2007/05/15 08:55:19 jim
1189 Moved the saving of the products to later in the loop so that the jitter
1190 and microstep offsets will be written to the product headers
1191 
1192 Revision 1.40 2007/05/08 21:31:15 jim
1193 fixed typo
1194 
1195 Revision 1.39 2007/05/08 10:42:44 jim
1196 Added gain correction
1197 
1198 Revision 1.38 2007/04/04 16:05:59 jim
1199 Modified to make paf information a bit more correct
1200 
1201 Revision 1.37 2007/04/04 10:36:18 jim
1202 Modified to use new dfs tags
1203 
1204 Revision 1.36 2007/03/29 12:19:38 jim
1205 Little changes to improve documentation
1206 
1207 Revision 1.35 2007/03/14 14:49:13 jim
1208 Fixed problem with missing paf files in jmp recipes if detlive = F. Also
1209 fixed problem where extra dummy products were being created
1210 
1211 Revision 1.34 2007/03/06 12:00:48 jim
1212 Fixed stupid typo in header
1213 
1214 Revision 1.33 2007/03/01 12:41:49 jim
1215 Modified slightly after code checking
1216 
1217 Revision 1.32 2007/02/07 10:12:39 jim
1218 Removed calls to vircam_ndit_correct as this is now no longer necessary
1219 
1220 Revision 1.31 2006/12/19 13:31:27 jim
1221 Fixed path2mass alias name. Also detectors flagged as dead now only generate
1222 an INFO message
1223 
1224 Revision 1.30 2006/11/29 12:28:45 jim
1225 Modified so that the correct recipe names would appear in the headers of
1226 data products
1227 
1228 Revision 1.29 2006/11/27 12:17:25 jim
1229 Almost all support routines are now in vircam/vircam_jmp_utils.c
1230 
1231 Revision 1.28 2006/11/22 21:57:06 jim
1232 Modified how readnoise and gain are read
1233 
1234 Revision 1.27 2006/11/10 09:23:06 jim
1235 Added sky correction and destriping along with the relevant command line
1236 parameters. Also fixed save routines so that dummy products will get the
1237 IMADUMMY flag.
1238 
1239 Revision 1.26 2006/09/09 16:49:40 jim
1240 Header comment update
1241 
1242 Revision 1.25 2006/08/07 14:21:03 jim
1243 Made a few more changes to make sure that if things fail then it doesn't try
1244 and run further processing steps
1245 
1246 Revision 1.24 2006/08/07 12:59:52 jim
1247 Fixed DET LIVE problem (I think)
1248 
1249 Revision 1.23 2006/08/01 11:28:14 jim
1250 Modified to use new smoothing kernel width parameter in imcore
1251 
1252 Revision 1.22 2006/07/19 10:42:50 jim
1253 Fixed a bug where the product frame lists were being deleted too early
1254 
1255 Revision 1.21 2006/07/17 12:51:48 jim
1256 Plugged a great number of memory leaks (mainly to do with propertylists)
1257 
1258 Revision 1.20 2006/07/17 09:31:24 jim
1259 Fixed a small memory leak and a bug in vircam_jmp_dither_offsets
1260 
1261 Revision 1.19 2006/07/11 14:56:17 jim
1262 Changes in the interleaving and jitter routines so that missing data
1263 and frames that are flagged as bad are dealt with properly
1264 
1265 Revision 1.18 2006/07/07 09:34:21 jim
1266 Fixed a few bugs relating to interleaving
1267 
1268 Revision 1.17 2006/07/04 09:19:03 jim
1269 replaced all sprintf statements with snprintf
1270 
1271 Revision 1.16 2006/06/20 19:07:01 jim
1272 Corrects for ndit != 1
1273 
1274 Revision 1.15 2006/06/19 20:50:35 jim
1275 Put a better algorithm for working out an output file name into
1276 vircam_jmp_save_smple
1277 
1278 Revision 1.14 2006/06/15 09:58:58 jim
1279 Minor changes to docs
1280 
1281 Revision 1.13 2006/06/14 14:17:13 jim
1282 minor documentation fix
1283 
1284 Revision 1.12 2006/06/13 21:28:39 jim
1285 Uses new VIRCAM_CALIB_READGAIN_FILE as an input now.
1286 
1287 Revision 1.11 2006/06/13 14:10:59 jim
1288 Fixed routine that saves catalogues to remove WCS stuff from extension header.
1289 
1290 Revision 1.10 2006/06/09 22:25:06 jim
1291 tidied up a few bugs
1292 
1293 Revision 1.9 2006/06/09 11:26:25 jim
1294 Small changes to keep lint happy
1295 
1296 Revision 1.8 2006/06/08 14:52:52 jim
1297 Fixed a few little bugs
1298 
1299 Revision 1.7 2006/06/06 13:03:30 jim
1300 Added QC parameters to docs
1301 
1302 Revision 1.6 2006/06/01 14:34:06 jim
1303 Now accepts a bad pixel mask in place of a confidence map for emergency use
1304 
1305 Revision 1.5 2006/05/30 14:27:54 jim
1306 Added illcor parameter to call for photcal
1307 
1308 Revision 1.4 2006/05/30 12:15:42 jim
1309 Cosmetic changes
1310 
1311 Revision 1.3 2006/05/27 21:25:49 jim
1312 Added some more docs
1313 
1314 Revision 1.2 2006/05/26 15:06:06 jim
1315 Fixed lots of little bugs
1316 
1317 Revision 1.1 2006/05/24 13:39:29 jim
1318 First cut
1319 
1320 
1321 */
const char * vircam_get_license(void)
Definition: vircam_utils.c:92
int vircam_compare_tags(const cpl_frame *frame1, const cpl_frame *frame2)
Definition: vircam_utils.c:141
void vircam_jmp_dither_offsets(void)
vir_fits ** vircam_fits_load_list(cpl_frameset *f, cpl_type type, int exten)
Definition: vircam_fits.c:231
void vircam_jmp_interleave(void)
int vircam_jmp_save_simple_offsets(cpl_frameset *framelist, cpl_parameterlist *parlist)
int vircam_gaincor(vir_fits *infile, float gainscl, int *status)
Gain correct input data frame.
cpl_frame * vircam_frameset_subgroup_1(cpl_frameset *frameset, cpl_size *labels, cpl_size nlab, const char *tag)
Definition: vircam_utils.c:247
void vircam_mask_clear(vir_mask *m)
Definition: vircam_mask.c:349
void vircam_jmp_dither_images(void)
int vircam_gaincor_calc(cpl_frame *frame, int *n, float **cors, int *status)
void vircam_jmp_bpm2conf(void)
void vircam_jmp_get_readnoise_gain(int jext, float *readnoise, float *gain)
int vircam_fits_get_status(vir_fits *p)
Definition: vircam_fits.c:591
void vircam_jmp_catalogue(void)
int vircam_lincor(vir_fits *infile, vir_tfits *lchantab, int kconst, int ndit, int *status)
Apply linearity curves to data.
void vircam_jmp_init(void)
int vircam_mask_load(vir_mask *m, int nexten, int nx, int ny)
Definition: vircam_mask.c:210
char * vircam_fits_get_fullname(vir_fits *p)
Definition: vircam_fits.c:560
int vircam_destripe(vir_fits *in, vir_mask *inbpm, int *status)
Remove stripes from the background of an image.
cpl_image * vircam_fits_get_image(vir_fits *p)
Definition: vircam_fits.c:349
int vircam_darkcor(vir_fits *infile, vir_fits *darksrc, float darkscl, int *status)
Correct input data for dark current.
cpl_frameset * vircam_frameset_subgroup(cpl_frameset *frameset, cpl_size *labels, cpl_size nlab, const char *tag)
Definition: vircam_utils.c:193
void vircam_jmp_tidy(int level)
int vircam_fits_set_error(vir_fits *p, int status)
Definition: vircam_fits.c:627
int vircam_catpars(cpl_frame *indx, char **catpath, char **catname)
void vircam_jmp_wcsfit(void)
int vircam_pfits_get_nusteps(const cpl_propertylist *plist, int *nusteps)
Get the value of the number of microsteps in a sequence.
Definition: vircam_pfits.c:422
int vircam_jmp_save_simple(cpl_frameset *framelist, cpl_parameterlist *parlist)
void vircam_jmp_skycor(void)
int vircam_check_crval(cpl_propertylist *phu, cpl_propertylist *ehu)
int vircam_pfits_get_ndit(const cpl_propertylist *plist, int *ndit)
Get the value of NDIT.
Definition: vircam_pfits.c:583
int vircam_jmp_save_super(cpl_frameset *framelist, cpl_parameterlist *parlist)
cpl_propertylist * vircam_fits_get_phu(vir_fits *p)
Definition: vircam_fits.c:416
int vircam_jmp_save_offsky(cpl_frameset *framelist, cpl_parameterlist *parlist)
vir_fits * vircam_fits_load(cpl_frame *frame, cpl_type type, int nexten)
Definition: vircam_fits.c:80
vir_tfits * vircam_tfits_load(cpl_frame *table, int nexten)
Definition: vircam_tfits.c:78
int vircam_jmp_save_catalogue(cpl_frameset *framelist, cpl_parameterlist *parlist)
int vircam_nditcor(vir_fits *infile, int ndit, int *status)
Correct input data for dark current.
void vircam_jmp_matched_stds(void)
cpl_propertylist * vircam_fits_get_ehu(vir_fits *p)
Definition: vircam_fits.c:457
void vircam_jmp_photcal(void)
int vircam_frameset_fexists(cpl_frameset *frameset)
Definition: vircam_utils.c:285
vir_mask * vircam_mask_define(cpl_frameset *framelist, cpl_size *labels, cpl_size nlab)
Definition: vircam_mask.c:86
int vircam_pfits_get_detlive(const cpl_propertylist *plist, int *detlive)
Get the value of DET_LIVE.
Definition: vircam_pfits.c:624
int vircam_flatcor(vir_fits *infile, vir_fits *flatsrc, int *status)
Correct input data for flat field response.
void vircam_exten_range(int inexten, const cpl_frame *fr, int *out1, int *out2)
Definition: vircam_utils.c:353
int vircam_jmp_save_stack(cpl_frameset *framelist, cpl_parameterlist *parlist)
int vircam_dfs_set_groups(cpl_frameset *set)
Definition: vircam_dfs.c:87