File: flames_add_extra_des.c

package info (click to toggle)
cpl-plugin-uves 6.1.3+dfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, sid
  • size: 23,128 kB
  • sloc: ansic: 171,056; sh: 4,359; python: 3,002; makefile: 1,322
file content (165 lines) | stat: -rw-r--r-- 7,562 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
/*                                                                            *
 *   This file is part of the ESO UVES Pipeline                               *
 *   Copyright (C) 2004,2005 European Southern Observatory                    *
 *                                                                            *
 *   This library is free software; you can redistribute it and/or modify     *
 *   it under the terms of the GNU General Public License as published by     *
 *   the Free Software Foundation; either version 2 of the License, or        *
 *   (at your option) any later version.                                      *
 *                                                                            *
 *   This program is distributed in the hope that it will be useful,          *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of           *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the            *
 *   GNU General Public License for more details.                             *
 *                                                                            *
 *   You should have received a copy of the GNU General Public License        *
 *   along with this program; if not, write to the Free Software              *
 *   Foundation, 51 Franklin St, Fifth Floor, Boston, MA  02111-1307  USA     *
 *                                                                           */
/*
 * $Author: amodigli $
 * $Date: 2013-07-22 07:24:32 $
 * $Revision: 1.11 $
 * $Name: not supported by cvs2svn $
 */
#ifdef HAVE_CONFIG_H
#  include <config.h>
#endif

/*---------------------------------------------------------------------------*/
/**
 * @defgroup flames_add_extra_des  copy descriptors
 */
/*---------------------------------------------------------------------------*/

/*-----------------------------------------------------------------------------
  Includes
  ----------------------------------------------------------------------------*/

#include <flames_add_extra_des.h>

#include <uves_dfs.h>
#include <uves_utils_wrappers.h>
#include <uves_dump.h>
#include <uves_pfits.h>
#include <uves_error.h>
#include <uves_msg.h>
#include <string.h>
/*-----------------------------------------------------------------------------
  Functions prototypes
  ----------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/
/**
   @brief    copy all descriptors from in_frm to out_frm

   @param    ref_frm        source
   @param    out_frm        destination table
  
**/
/*---------------------------------------------------------------------------*/
void
flames_add_extra_des(const cpl_frame *ref_frm,
                     cpl_frame *out_frm)
{

  const char *dprtype;
  uves_propertylist *ref_frm_header = NULL;
  uves_propertylist *out_frm_header = NULL;
  cpl_table *t = NULL;
  cpl_image *image = NULL;

  check( ref_frm_header = uves_propertylist_load(cpl_frame_get_filename(ref_frm), 0),
	 "Could not load %s header", cpl_frame_get_filename(ref_frm));

  check( out_frm_header = uves_propertylist_load(cpl_frame_get_filename(out_frm), 0),
	 "Could not load %s header", cpl_frame_get_filename(out_frm));

  check_nomsg( dprtype = uves_pfits_get_dpr_type(ref_frm_header));

  uves_msg_debug("Propagating keywords from %s to %s...",
		 cpl_frame_get_filename(ref_frm),
		 cpl_frame_get_filename(out_frm));

  check_nomsg( uves_copy_if_possible(out_frm_header, ref_frm_header, "ORIGIN"));
  check_nomsg( uves_copy_if_possible(out_frm_header, ref_frm_header, UVES_DATE));
  check_nomsg( uves_copy_if_possible(out_frm_header, ref_frm_header, "TELESCOPE"));
  check_nomsg( uves_copy_if_possible(out_frm_header, ref_frm_header, "TELESCOP"));

  check_nomsg( uves_copy_if_possible(out_frm_header, ref_frm_header, "INSTRUME"));
  check_nomsg( uves_copy_if_possible(out_frm_header, ref_frm_header, UVES_OBJECT));
  check_nomsg( uves_copy_if_possible(out_frm_header, ref_frm_header, UVES_RA));
  check_nomsg( uves_copy_if_possible(out_frm_header, ref_frm_header, UVES_DEC));
  check_nomsg( uves_copy_if_possible(out_frm_header, ref_frm_header, "EQUINOX"));//O_POS
  check_nomsg( uves_copy_if_possible(out_frm_header, ref_frm_header, "RADECSYS"));
  check_nomsg( uves_copy_if_possible(out_frm_header, ref_frm_header, UVES_EXPTIME));
  check_nomsg( uves_copy_if_possible(out_frm_header, ref_frm_header, "DATE-OBS"));//O_TIME
  check_nomsg( uves_copy_if_possible(out_frm_header, ref_frm_header, UVES_AIRMASS));//O_AIRM
  check_nomsg( uves_copy_if_possible(out_frm_header, ref_frm_header, "EPOCH"));//O_POS
  check_nomsg( uves_copy_if_possible(out_frm_header, ref_frm_header, UVES_UTC));
  check_nomsg( uves_copy_if_possible(out_frm_header, ref_frm_header, "LST"));
  check_nomsg( uves_copy_if_possible(out_frm_header, ref_frm_header, UVES_UT));
  check_nomsg( uves_copy_if_possible(out_frm_header, ref_frm_header, UVES_ST));

  check_nomsg( uves_copy_if_possible(out_frm_header, ref_frm_header, "PI-COI"));
  check_nomsg( uves_copy_if_possible(out_frm_header, ref_frm_header, "OBSERVER"));
  check_nomsg( uves_copy_if_possible(out_frm_header, ref_frm_header, UVES_CTYPE1));
  check_nomsg( uves_copy_if_possible(out_frm_header, ref_frm_header, UVES_CTYPE2));
  check_nomsg( uves_copy_if_possible(out_frm_header, ref_frm_header, UVES_CRVAL1));
  check_nomsg( uves_copy_if_possible(out_frm_header, ref_frm_header, UVES_CRVAL2));
  check_nomsg( uves_copy_if_possible(out_frm_header, ref_frm_header, UVES_CRPIX1));
  check_nomsg( uves_copy_if_possible(out_frm_header, ref_frm_header, UVES_CRPIX2));
  check_nomsg( uves_copy_if_possible(out_frm_header, ref_frm_header, UVES_CDELT1));
  check_nomsg( uves_copy_if_possible(out_frm_header, ref_frm_header, UVES_CDELT2));
  check_nomsg( uves_copy_if_possible(out_frm_header, ref_frm_header, "EXTEND"));
  check_nomsg( uves_copy_if_possible(out_frm_header, ref_frm_header, "ARCFILE"));
  check_nomsg( uves_copy_if_possible(out_frm_header, ref_frm_header, "ORIGFILE"));

  check( uves_propertylist_copy_property_regexp(
						out_frm_header, ref_frm_header, "^ESO.*", 0),
	 "Could propagate ESO.* keywords");

  if (strstr(dprtype, "SimCal") != NULL) {
    check_nomsg( uves_pfits_set_ocs_simcal(out_frm_header, 1));
  }

  /* Save the header */
  switch(cpl_frame_get_type(out_frm)) {
  case CPL_FRAME_TYPE_TABLE:
    check( t = cpl_table_load(cpl_frame_get_filename(out_frm), 1, 1),
	   "Could not load table %s", cpl_frame_get_filename(out_frm));
    check( uves_table_save(t,
			   out_frm_header,
			   NULL,
			   cpl_frame_get_filename(out_frm),
			   CPL_IO_DEFAULT),
	   "Could not update table %s header", cpl_frame_get_filename(out_frm));
    break;
  case CPL_FRAME_TYPE_IMAGE:
    check( image = uves_load_image(out_frm,
				   0, 0, NULL),
	   "Could not load image %s", cpl_frame_get_filename(out_frm));
    check( uves_save_image(image, cpl_frame_get_filename(out_frm), 
			   out_frm_header, true, true),
	   "Could not update image %s header", cpl_frame_get_filename(out_frm));
    break;
  default:
    assure( false, CPL_ERROR_UNSUPPORTED_MODE,
	    "Frame type is %s", 
	    uves_tostring_cpl_frame_type(cpl_frame_get_type(out_frm)));
    break;
  }
    
  uves_msg_debug("Done propagating keywords from %s to %s...",
		 cpl_frame_get_filename(ref_frm),
		 cpl_frame_get_filename(out_frm));


 cleanup:
  uves_free_table(&t);
  uves_free_image(&image);
  uves_free_propertylist(&ref_frm_header);
  uves_free_propertylist(&out_frm_header);
  return;
}

/**@}*/