GRAVI Pipeline Reference Manual 1.7.2
Loading...
Searching...
No Matches
gravi_pfits.c
Go to the documentation of this file.
1/* $Id: gravi_pfits.c,v 1.12 2011/04/31 06:10:40 nazouaoui Exp $
2 *
3 * This file is part of the GRAVI Pipeline
4 * Copyright (C) 2002,2003 European Southern Observatory
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
32/*
33 * History :
34 * 10/01/2019 EKW fix Warning : unused parameter : power
35 * 06/11/2019 EkW commit for FE : make use of dedicated keyword introduced Oct 2019
36 * 08/11/2019 EkW correct uninitilized parameter (PIPE-8072)
37 */
38/*-----------------------------------------------------------------------------
39 Includes
40 -----------------------------------------------------------------------------*/
41
42#ifdef HAVE_CONFIG_H
43#include <config.h>
44#endif
45
46#include <cpl.h>
47#include <stdio.h>
48#include <string.h>
49#include <time.h>
50#include <math.h>
51#include <erfa.h>
52
53#include "gravi_pfits.h"
54#include "gravi_utils.h"
55
56/*-----------------------------------------------------------------------------
57 Function codes
58 -----------------------------------------------------------------------------*/
59
60/*----------------------------------------------------------------------------*/
66/*----------------------------------------------------------------------------*/
67
68int gravi_pfits_get_startx (const cpl_propertylist * plist)
69{
70 cpl_errorstate prestate = cpl_errorstate_get();
71 int value = cpl_propertylist_get_int(plist, PROFILE_STARTX);
72 cpl_ensure (cpl_errorstate_is_equal(prestate), cpl_error_get_code(), 0);
73 return value;
74}
75
76int gravi_pfits_get_fullstartx (const cpl_propertylist * plist)
77{
78 cpl_errorstate prestate = cpl_errorstate_get();
79 int value = cpl_propertylist_get_int(plist, PROFILE_FULLSTARTX);
80 cpl_ensure (cpl_errorstate_is_equal(prestate), cpl_error_get_code(), 0);
81 return value;
82}
83
84int gravi_pfits_get_nx (const cpl_propertylist * plist)
85{
86 cpl_errorstate prestate = cpl_errorstate_get();
87 int value = cpl_propertylist_get_int(plist, PROFILE_NX);
88 cpl_ensure (cpl_errorstate_is_equal(prestate), cpl_error_get_code(), 0);
89 return value;
90}
91
92int gravi_pfits_get_window_start (const cpl_propertylist * plist)
93{
94 cpl_errorstate prestate = cpl_errorstate_get();
95 int value = cpl_propertylist_get_int(plist, "ESO DET2 FRAM STRX");
96 cpl_ensure (cpl_errorstate_is_equal(prestate), cpl_error_get_code(), 0.0);
97 return value;
98}
99
100double gravi_pfits_get_diameter (const cpl_propertylist * plist, int type_data)
101{
102 cpl_errorstate prestate = cpl_errorstate_get();
103 double value = 0.0;
104
105 const char * keyword = ( type_data == GRAVI_FT ? "ESO FT ROBJ "
106 "DIAMETER" : "ESO INS SOBJ DIAMETER" );
107 if (cpl_propertylist_has (plist, keyword)) {
108 value = cpl_propertylist_get_double( plist, keyword );
109 }
110 else if ( !gravi_pfits_is_calib (plist)) {
111 cpl_msg_warning (cpl_func, "The keyword %s does not "
112 "exist in the propertylist", keyword);
113 }
114
115 cpl_ensure(cpl_errorstate_is_equal(prestate), cpl_error_get_code(), 0.0);
116 return value;
117}
118
119double gravi_pfits_get_pmra (const cpl_propertylist * plist)
120{
121 const char * keyword = "ESO FT ROBJ PMA";
122 double pma = gravi_pfits_get_double_silentdefault (plist, keyword, 0.);
123 return pma; // [as/year]
124}
125
126double gravi_pfits_get_pmdec (const cpl_propertylist * plist)
127{
128 const char * keyword = "ESO FT ROBJ PMD";
129 double pmd = gravi_pfits_get_double_silentdefault (plist, keyword, 0.);
130 return pmd; // [as/year]
131}
132
133double gravi_pfits_get_plx (const cpl_propertylist * plist)
134{
135 const char * keyword = "ESO FT ROBJ PARALLAX";
136 double plx = gravi_pfits_get_double_silentdefault (plist, keyword, 0.);
137 return plx; // [as]
138}
139
140const char * gravi_pfits_get_extname (const cpl_propertylist * plist)
141{
142 cpl_errorstate prestate = cpl_errorstate_get();
143 const char * value = cpl_propertylist_get_string(plist, "EXTNAME");
144 cpl_ensure (cpl_errorstate_is_equal(prestate), cpl_error_get_code(), "");
145 return value;
146}
147
148const char * gravi_pfits_get_dpr_type (const cpl_propertylist * plist)
149{
150 const char * value = cpl_propertylist_get_string(plist, "ESO DPR TYPE");
151 cpl_ensure (value != NULL, cpl_error_get_code(), NULL);
152 return value;
153}
154
155const char * gravi_pfits_get_resolution (const cpl_propertylist * plist)
156{
157 const char * value = cpl_propertylist_get_string(plist, "ESO INS FILT2 NAME");
158 cpl_ensure(value != NULL, cpl_error_get_code(), NULL);
159 return value;
160}
161
162const char * gravi_pfits_get_spec_res (const cpl_propertylist * plist)
163{
164 const char * value = cpl_propertylist_get_string(plist, "ESO INS SPEC RES");
165 cpl_ensure(value != NULL, cpl_error_get_code(), NULL);
166 return value;
167}
168
169const char * gravi_pfits_get_pola_mode (const cpl_propertylist * plist, int type_data )
170{
171 const char * keyword = ( type_data == GRAVI_FT ? "ESO FT POLA MODE" : "ESO INS POLA MODE");
172 const char * value = cpl_propertylist_get_string(plist, keyword);
173 cpl_ensure (value != NULL, cpl_error_get_code(), NULL);
174 return value;
175}
176
177int gravi_data_frame_get_mode (const cpl_frame * frame)
178{
179 cpl_ensure (frame, CPL_ERROR_NULL_INPUT, 0);
180 const char * value = cpl_frame_get_tag (frame);
181
182 cpl_ensure (value != NULL, cpl_error_get_code(), 0);
183 if (strstr(value,"SINGLE")) {
184 return MODE_SINGLE;
185 }
186 if (strstr(value, "DUAL")) {
187 return MODE_DUAL;
188 }
189
190 return 0;
191}
192
193int gravi_pfits_get_mode (const cpl_propertylist * plist)
194{
195 const char * type;
196
197 if (cpl_propertylist_has (plist, "ESO PRO CATG"))
198 type = cpl_propertylist_get_string (plist,"ESO PRO CATG");
199 else if (cpl_propertylist_has (plist, "ESO DPR TYPE"))
200 type = cpl_propertylist_get_string (plist,"ESO DPR TYPE");
201 else return -1;
202
203 if (strstr (type,"SINGLE")) {
204 return MODE_SINGLE;
205 }
206 if (strstr (type, "DUAL")) {
207 return MODE_DUAL;
208 }
209
210 return 0;
211}
212
213int gravi_pfits_get_axis (const cpl_propertylist * plist)
214{
215 const char * type=NULL;
216
217 /* FE 2019-10-31 now making use of dedicated keyword introduced Oct 2019
218 if not in header, use historic method (which is wrong, because the named
219 position of onaxis and offaxis are identical, and therefore ICS always
220 returns offaxis */
221
222 if (cpl_propertylist_has (plist, "ESO INS ROOF POS")) {
223 type = cpl_propertylist_get_string (plist,"ESO INS ROOF POS");
224 } else {
225 if (cpl_propertylist_has (plist, "ESO INS OPTI11 ID")) {
226 type = cpl_propertylist_get_string (plist,"ESO INS OPTI11 ID");
227 cpl_msg_warning (cpl_func,"Using ESO INS OPTI11 ID (making use of historic method)");
228 } else return -1;
229 }
230
231 if (type == NULL) return -1;
232 if (strstr (type,"OFFAXIS")) {
233 return MODE_OFFAXIS;
234 }
235 if (strstr (type, "ONAXIS")) {
236 return MODE_ONAXIS;
237 }
238
239 return 0;
240}
241
242const char * gravi_pfits_get_mode_name (const cpl_propertylist * plist)
243{
244 cpl_ensure (plist, CPL_ERROR_NULL_INPUT, NULL);
245 const char * type;
246
247 if (cpl_propertylist_has (plist, "ESO PRO CATG"))
248 type = cpl_propertylist_get_string (plist,"ESO PRO CATG");
249 else if (cpl_propertylist_has (plist, "ESO DPR TYPE"))
250 type = cpl_propertylist_get_string (plist,"ESO DPR TYPE");
251 else return "UNKNOWN";
252
253 if (strstr (type,"SINGLE")) {
254 return "SINGLE";
255 }
256 if (strstr (type, "DUAL")) {
257 return "DUAL";
258 }
259
260 return "UNKNOWN";
261}
262
263int gravi_pfits_get_pola_num (const cpl_propertylist * plist, int type_data )
264{
265 const char * keyword = ( type_data == GRAVI_FT ? "ESO FT POLA MODE" : "ESO INS POLA MODE");
266 const char * value = cpl_propertylist_get_string(plist, keyword);
267 cpl_ensure (value != NULL, cpl_error_get_code(), 0);
268 return ( !(strcmp(value,"SPLIT")) ? 2 : 1 );
269}
270
271int gravi_pfits_get_extension_type (const cpl_propertylist * plist)
272{
273 cpl_errorstate prestate = cpl_errorstate_get();
274
275 const char * value = cpl_propertylist_get_string (plist, "XTENSION");
276 cpl_ensure (value, CPL_ERROR_ILLEGAL_INPUT, 0);
277
278 int ext_type;
279
280 if (! strcmp(value, "IMAGE"))
281 ext_type = 3;
282 else if (! strcmp(value, "BINTABLE"))
283 ext_type = 2;
284 else if (! strcmp(value, "TABLE"))
285 ext_type = 2;
286 else {
287 cpl_error_set_message(cpl_func, CPL_ERROR_ILLEGAL_INPUT,
288 "Type extension is incorrect");
289 ext_type = 0;
290 }
291 cpl_ensure(cpl_errorstate_is_equal(prestate), cpl_error_get_code(), 0.0);
292 return ext_type;
293}
294
295double gravi_pfits_get_metfc_lockmjd (const cpl_propertylist * plist, int tel)
296{
297 cpl_errorstate prestate = cpl_errorstate_get();
298
299 char *lock = cpl_sprintf ("ESO OCS MET LKDT_FC%i", tel+1);
300 double value = gravi_convert_to_mjd (cpl_propertylist_get_string (plist, lock));
301
302 if (!cpl_errorstate_is_equal(prestate)) {
303 cpl_errorstate_set (prestate);
304 cpl_msg_warning (cpl_func, "Cannot read %s", lock);
305 value = 0.0;
306 }
307
308 cpl_free (lock);
309 return value;
310}
311
312double gravi_pfits_get_met_wavelength_mean (const cpl_propertylist * plist, cpl_table * met_table)
313{
314 double met_wavelength_ref = gravi_pfits_get_met_wavelength (plist)*1e-9;
315 double lambda_met_mean = met_wavelength_ref +
316 cpl_table_get_column_mean(met_table, "LAMBDA_LASER")*1e-9;
317
318 return (lambda_met_mean);
319}
320
321double gravi_pfits_get_met_wavelength (const cpl_propertylist * plist)
322{
323 cpl_errorstate prestate = cpl_errorstate_get();
324
325 /* double power; */
326 double wavelength = 0.0;
327
328 /*
329 * If cannot read MLC laser power
330 */
331 if (cpl_propertylist_has (plist, "ESO INS MLC POWER") == FALSE) {
332 wavelength = gravi_pfits_get_double(plist, "ESO INS MLC WAVELENG");
333 cpl_msg_warning (cpl_func, "Cannot read the laser POWER : use MLC wavelength : %f ", wavelength);
334 }
335 /*
336 * If MLC laser ON
337 */
338 else if (gravi_pfits_get_double(plist, "ESO INS MLC POWER") != 0) {
339 wavelength = gravi_pfits_get_double(plist, "ESO INS MLC WAVELENG");
340 cpl_msg_info(cpl_func, "Using laser MLC wavelength : %f ", wavelength);
341 }
342 /*
343 * If MLAS laser ON
344 */
345 else if (gravi_pfits_get_double(plist, "ESO INS MLAS LPOW") != 0) {
346 /* power=gravi_pfits_get_double(plist, "ESO INS MLAS LPOW"); */
347 wavelength = cpl_propertylist_get_double(plist, "ESO INS MLAS LWAV");
348 cpl_msg_info(cpl_func, "Using laser MLAS wavelength : %f ", wavelength);
349 }
350
351 if (!cpl_errorstate_is_equal(prestate)) {
352 cpl_msg_warning (cpl_func, "Cannot read the laser wavelength in the header : %s", cpl_error_get_message());
353 cpl_errorstate_set (prestate);
354 }
355
356 return wavelength;
357}
358
359int gravi_pfits_get_met_mode (const cpl_propertylist * plist)
360{
361 const char * value = gravi_pfits_get_string_default (plist, "ESO INS MET MODE","ON");
362
363 if ( !strcmp(value, "FAINT") ) {
364 return MET_FAINT_HEADER;
365 }
366 else{
367 return MET_NORMAL_HEADER;
368 }
369
370}
371
372/*-----------------------------------------------------------------------------*/
378/*-----------------------------------------------------------------------------*/
379
380cpl_vector * gravi_pfits_get_met_faint_params (const cpl_propertylist * plist)
381{
382 const char * faint_keys[]={"ESO INS ANLO3 RATE1",\
383 "ESO INS ANLO3 REPEAT1",\
384 "ESO INS ANLO3 TIMER1",\
385 "ESO INS ANLO3 RATE2",\
386 "ESO INS ANLO3 REPEAT2",\
387 "ESO INS ANLO3 TIMER2"};
388
389 cpl_vector * faint_params = cpl_vector_new(sizeof(faint_keys)/sizeof(faint_keys[0]));
390
391 cpl_vector_fill(faint_params, 0.0);
392
393 for(size_t i=0;i<sizeof(faint_keys)/sizeof(faint_keys[0]);i++)
394 {
395 cpl_errorstate prestate = cpl_errorstate_get();
396 cpl_type par_type = cpl_propertylist_get_type(plist, faint_keys[i]);
397 if(par_type==CPL_TYPE_INT)
398 {
399 cpl_vector_set(faint_params,i,(double) cpl_propertylist_get_int(plist, faint_keys[i]));
400 }
401 else
402 {
403 cpl_vector_set(faint_params,i,cpl_propertylist_get_double(plist, faint_keys[i]));
404 }
405 cpl_ensure(cpl_errorstate_is_equal(prestate), cpl_error_get_code(), faint_params);
406 }
407
408 return faint_params;
409}
410
411double gravi_pfits_get_geolat (const cpl_propertylist * plist)
412{
413 cpl_errorstate prestate = cpl_errorstate_get();
414 double value = cpl_propertylist_get_double(plist, "ESO ISS GEOLAT");
415 cpl_ensure(cpl_errorstate_is_equal(prestate), cpl_error_get_code(), 0.0);
416 return value;
417}
418
419double gravi_pfits_get_geolon (const cpl_propertylist * plist)
420{
421 cpl_errorstate prestate = cpl_errorstate_get();
422 double value = cpl_propertylist_get_double(plist, "ESO ISS GEOLON");
423 cpl_ensure(cpl_errorstate_is_equal(prestate), cpl_error_get_code(), 0.0);
424 return value;
425}
426
427double gravi_pfits_get_geoelev (const cpl_propertylist * plist)
428{
429 cpl_errorstate prestate = cpl_errorstate_get();
430 double value = cpl_propertylist_get_double (plist, "ESO ISS GEOELEV");
431 cpl_ensure(cpl_errorstate_is_equal(prestate), cpl_error_get_code(), 0.0);
432 return value;
433}
434
435const char * gravi_pfits_get_feed (const cpl_propertylist * plist)
436{
437 const char * value = gravi_pfits_get_string_default (plist, "ESO ISS FEED MODE", "SINGLE_STS");
438 return value;
439}
440
441const char * gravi_pfits_get_sobj (const cpl_propertylist * plist)
442{
443 const char * value = gravi_pfits_get_string_default (plist, "ESO INS SOBJ NAME", "UNKNOWN_SC");
444 return value;
445}
446
447double gravi_pfits_get_sobj_diam (const cpl_propertylist * plist)
448{
449 cpl_errorstate prestate = cpl_errorstate_get();
450 double value = cpl_propertylist_get_double (plist, "ESO INS SOBJ DIAMETER");
451 cpl_ensure(cpl_errorstate_is_equal(prestate), cpl_error_get_code(), 0.0);
452 return value;
453}
454
455double gravi_pfits_get_sobj_x (const cpl_propertylist * plist)
456{
457 double value = gravi_pfits_get_double_default (plist, "ESO INS SOBJ X", 0.0);
458 return value;
459}
460
461double gravi_pfits_get_sobj_y (const cpl_propertylist * plist)
462{
463 double value = gravi_pfits_get_double_default (plist, "ESO INS SOBJ Y", 0.0);
464 return value;
465}
466
467double gravi_pfits_get_sobj_offx (const cpl_propertylist * plist)
468{
469 double value = gravi_pfits_get_double_default (plist, "ESO INS SOBJ OFFX", 0.0);
470 return value;
471}
472
473double gravi_pfits_get_sobj_offy (const cpl_propertylist * plist)
474{
475 double value = gravi_pfits_get_double_default (plist, "ESO INS SOBJ OFFY", 0.0);
476 return value;
477}
478
479double gravi_pfits_get_gvctu_x (const cpl_propertylist * plist)
480{
481 double value_default = gravi_pfits_get_sobj_x(plist);
482 double value1 = gravi_pfits_get_double_default (plist, "ESO FT KAL SEPCTUX1", value_default);
483 double value2 = gravi_pfits_get_double_default (plist, "ESO FT KAL SEPCTUX2", value_default);
484 double value3 = gravi_pfits_get_double_default (plist, "ESO FT KAL SEPCTUX3", value_default);
485 double value4 = gravi_pfits_get_double_default (plist, "ESO FT KAL SEPCTUX4", value_default);
486 return (value1+value2+value3+value4)*0.25;
487}
488
489double gravi_pfits_get_gvctu_y (const cpl_propertylist * plist)
490{
491 double value_default = gravi_pfits_get_sobj_y(plist);
492 double value1 = gravi_pfits_get_double_default (plist, "ESO FT KAL SEPCTUY1", value_default);
493 double value2 = gravi_pfits_get_double_default (plist, "ESO FT KAL SEPCTUY2", value_default);
494 double value3 = gravi_pfits_get_double_default (plist, "ESO FT KAL SEPCTUY3", value_default);
495 double value4 = gravi_pfits_get_double_default (plist, "ESO FT KAL SEPCTUY4", value_default);
496 return (value1+value2+value3+value4)*0.25;
497}
498
499const char * gravi_pfits_get_robj (const cpl_propertylist * plist)
500{
501 const char * value = gravi_pfits_get_string_default (plist, "ESO FT ROBJ NAME", "UNKNOWN_FT");
502 return value;
503}
504
505double gravi_pfits_get_robj_diam (const cpl_propertylist * plist)
506{
507 cpl_errorstate prestate = cpl_errorstate_get();
508 double value = cpl_propertylist_get_double(plist, "ESO FT ROBJ DIAMETER");
509 cpl_ensure(cpl_errorstate_is_equal(prestate), cpl_error_get_code(), 0.0);
510 return value;
511}
512
513
514/*-----------------------------------------------------------------------------
515 TIMING
516 -----------------------------------------------------------------------------*/
517
518double gravi_pfits_get_fddlwindow (const cpl_propertylist * plist)
519{
520 cpl_errorstate prestate = cpl_errorstate_get();
521 double value = cpl_propertylist_get_double(plist, "ESO INS FDDL WINDOW");
522 cpl_ensure(cpl_errorstate_is_equal(prestate), cpl_error_get_code(), 0.0);
523 return value;
524}
525
526double gravi_pfits_get_mjd (const cpl_propertylist * plist)
527{
528 cpl_errorstate prestate = cpl_errorstate_get();
529 double value = cpl_propertylist_get_double(plist, "MJD-OBS");
530 cpl_ensure (cpl_errorstate_is_equal(prestate), cpl_error_get_code(), 0.0);
531 return value;
532}
533
534const char * gravi_pfits_get_met_ph (const cpl_propertylist * plist)
535{
536 const char * tim1_start = cpl_propertylist_get_string(plist, "ESO OCS MET PH_DATE");
537 cpl_ensure (tim1_start != NULL, cpl_error_get_code(), NULL);
538 return tim1_start;
539}
540
541int gravi_pfits_has_gdzero (const cpl_propertylist * plist,
542 int tel)
543{
544 cpl_ensure (plist, CPL_ERROR_NULL_INPUT, 0);
545
546 int return_val = 0;
547 char name[100];
548
549 sprintf (name, "ESO QC MET GD_ZERO_FC%i", tel);
550 if (cpl_propertylist_has(plist, name))
551 {
552 return_val = 1;
553 } else {
554 sprintf (name, "ESO PRO MET GD_ZERO_FC%i", tel);
555 if (cpl_propertylist_has(plist, name))
556 return_val = 1;
557 }
558
559 return return_val;
560}
561
562double gravi_pfits_get_gdzero (const cpl_propertylist * plist,
563 int tel)
564{
565 cpl_ensure (plist, CPL_ERROR_NULL_INPUT, 0);
566
567 double output;
568 char name[100];
569
570 sprintf (name, "ESO QC MET GD_ZERO_FC%i", tel);
571 if (cpl_propertylist_has(plist, name)) {
572 /* Try to read this keyword as a double */
573 output = gravi_pfits_get_double(plist, name);
574 } else {
575 sprintf (name, "ESO PRO MET GD_ZERO_FC%i", tel);
576 if (cpl_propertylist_has(plist, name)) {
577 /* Try to read this keyword as a double */
578 output = gravi_pfits_get_double(plist, name);
579 } else
580 output = 0;
581 }
582
583 return output;
584}
585
586int gravi_pfits_has_oplzero (const cpl_propertylist * plist,
587 int tel)
588{
589 cpl_ensure (plist, CPL_ERROR_NULL_INPUT, 0);
590
591 int return_val = 0;
592 char name[100];
593
594 sprintf (name, "ESO QC MET OPL_ZERO_FC%i", tel);
595 if (cpl_propertylist_has(plist, name)) {
596 return_val = 1;
597 } else {
598 sprintf (name,"ESO PRO MET OPL_ZERO_FC%i", tel);
599 if (cpl_propertylist_has(plist, name))
600 return_val = 1;
601 }
602
603 return return_val;
604}
605
606double gravi_pfits_get_oplzero (const cpl_propertylist * plist,
607 int tel)
608{
609 cpl_ensure (plist, CPL_ERROR_NULL_INPUT, 0);
610
611 double output;
612 char name[100];
613
614 sprintf (name, "ESO QC MET OPL_ZERO_FC%i", tel);
615 if (cpl_propertylist_has(plist, name)) {
616 /* Try to read this keyword as a double */
617 output = gravi_pfits_get_double(plist, name);
618 } else {
619 sprintf (name, "ESO PRO MET OPL_ZERO_FC%i", tel);
620 if (cpl_propertylist_has(plist, name)) {
621 /* Try to read this keyword as a double */
622 output = gravi_pfits_get_double(plist, name);
623 } else
624 output = 0;
625 }
626
627 return output;
628}
629
630
631const char * gravi_pfits_get_start_sc (const cpl_propertylist * plist)
632{
633 /* SC = TIM1 = DET2 */
634 const char * tim1_start = cpl_propertylist_get_string(plist, "ESO INS TIM1 START");
635 cpl_ensure (tim1_start != NULL, cpl_error_get_code(), NULL);
636 return tim1_start;
637}
638
639const char * gravi_pfits_get_start_acqcam (const cpl_propertylist * plist)
640{
641 /* ACQCAM = TIM2 = DET1 */
642 const char * tim1_start = cpl_propertylist_get_string(plist, "ESO INS TIM2 START");
643 cpl_ensure (tim1_start != NULL, cpl_error_get_code(), NULL);
644 return tim1_start;
645}
646
647const char * gravi_pfits_get_start_prcacq (const cpl_propertylist * plist)
648{
649 /* This is the recording start of RMN tables */
650 const char * acq_start = cpl_propertylist_get_string(plist, "ESO PCR ACQ START");
651 cpl_ensure (acq_start != NULL, cpl_error_get_code(), NULL);
652 return acq_start;
653}
654
655double gravi_pfits_get_dit_acqcam (const cpl_propertylist * plist)
656{
657 /* ACQCAM = TIM2 = DET1 */
658 cpl_errorstate prestate = cpl_errorstate_get();
659 double value = cpl_propertylist_get_double(plist, "ESO DET1 SEQ1 DIT");
660 cpl_ensure(cpl_errorstate_is_equal(prestate), cpl_error_get_code(), 0.0);
661 return value;
662}
663
664double gravi_pfits_get_dit_sc (const cpl_propertylist * plist)
665{
666 /* SC = TIM1 = DET2 */
667 cpl_errorstate prestate = cpl_errorstate_get();
668 double value = cpl_propertylist_get_double(plist, "ESO DET2 SEQ1 DIT");
669 cpl_ensure(cpl_errorstate_is_equal(prestate), cpl_error_get_code(), 0.0);
670 return value;
671}
672
673double gravi_pfits_get_dit_ft (const cpl_propertylist * plist)
674{
675 /* FT = PCRACQ = DET3 */
676 cpl_errorstate prestate = cpl_errorstate_get();
677 double value = cpl_propertylist_get_double(plist, "ESO DET3 SEQ1 DIT");
678 cpl_ensure(cpl_errorstate_is_equal(prestate), cpl_error_get_code(), 0.0);
679 return value;
680}
681
682double gravi_pfits_get_period_sc (const cpl_propertylist * plist)
683{
684 /* SC = TIM1 = DET2 */
685 cpl_errorstate prestate = cpl_errorstate_get();
686 double value = cpl_propertylist_get_double(plist, "ESO INS TIM1 PERIOD");
687 cpl_ensure(cpl_errorstate_is_equal(prestate), cpl_error_get_code(), 0.0);
688 return value;
689}
690
691double gravi_pfits_get_period_acqcam (const cpl_propertylist * plist)
692{
693 /* ACQCAM = TIM2 = DET1 */
694 cpl_errorstate prestate = cpl_errorstate_get();
695 double value = cpl_propertylist_get_double(plist, "ESO INS TIM2 PERIOD");
696 cpl_ensure(cpl_errorstate_is_equal(prestate), cpl_error_get_code(), 0.0);
697 return value;
698}
699
700/*---------------------------------------------------------------------------*/
708/*---------------------------------------------------------------------------*/
709
710double gravi_pfits_get_time_sc (const cpl_propertylist * header, cpl_size row)
711{
713 cpl_ensure (header, CPL_ERROR_NULL_INPUT, 0.0);
714 cpl_errorstate prestate = cpl_errorstate_get();
715
716 /* Time of the middle of the exposure in
717 * [us] with respect to PRC.ACQ.START. */
718 double window_time = gravi_pfits_get_fddlwindow (header);
719 double period = gravi_pfits_get_period_sc (header);
720
721 double extra_time_faint = 0.0;
723 extra_time_faint = 1.0;
724 }
725
726 double time = 86400 * 1e6 *
729 (period-window_time-extra_time_faint)/2. * 1e6 +
730 row * period * 1e6;
731
732 /* Return 0 if error */
733 cpl_ensure (cpl_errorstate_is_equal(prestate), cpl_error_get_code(), 0.0);
734
736 return time;
737}
738
739/*---------------------------------------------------------------------------*/
747/*---------------------------------------------------------------------------*/
748
749double gravi_pfits_get_time_acqcam (const cpl_propertylist * header, cpl_size row)
750{
752 cpl_ensure (header, CPL_ERROR_NULL_INPUT, 0.0);
753 cpl_ensure (row>=0, CPL_ERROR_ILLEGAL_INPUT, 0.0);
754 cpl_errorstate prestate = cpl_errorstate_get();
755
756 /* Time of the middle of the exposure in
757 * [us] with respect to PRC.ACQ.START. */
758 double period = gravi_pfits_get_period_acqcam (header);
759
760 double time = 86400 * 1e6 *
763 period/2. * 1e6 +
764 row * period * 1e6;
765
766 /* Return 0 if error */
767 cpl_ensure (cpl_errorstate_is_equal(prestate), cpl_error_get_code(), 0.0);
768
770 return time;
771}
772
773double gravi_pfits_get_ptfc_acqcam (const cpl_propertylist * plist, int spot)
774{
775 cpl_errorstate prestate = cpl_errorstate_get();
776 char name[90];
777 sprintf (name, "ESO ACQ PTFC REFPOS%i", spot);
778 double value = cpl_propertylist_get_double (plist, name);
779 cpl_ensure (cpl_errorstate_is_equal(prestate), cpl_error_get_code(), 0.0);
780 return value;
781}
782
783double gravi_pfits_get_drotoff (const cpl_propertylist * plist, int tel)
784{
785 char name[90];
786
787 /* Angle of binary on ACQ image */
788 sprintf (name, "ESO INS DROTOFF%i", tel+1);
789 double drottoff = cpl_propertylist_get_double (plist, name);
790
791 return drottoff;
792}
793
794double gravi_pfits_get_northangle_acqcam (const cpl_propertylist * plist, int tel)
795{
796 double fangle = 0.0;
797
798 char name[90];
799 sprintf (name, "ESO INS DROTOFF%i", tel+1);
800
801 if (cpl_propertylist_has(plist, "ESO ACQ NORTHANG"))
802 {
803 fangle = cpl_propertylist_get_double (plist, "ESO ACQ NORTHANG");
804 cpl_msg_warning( cpl_func, "Using ACQ Camera North angle from header" );
805 cpl_msg_warning (cpl_func, "North angle = %.2f [deg] / NorthACQ in Y to X", fangle);
806 }
807 else
808 {
809 if (cpl_propertylist_has (plist, "ESO INS SOBJ X") &&
810 cpl_propertylist_has (plist, "ESO INS SOBJ Y") &&
811 cpl_propertylist_has (plist, name)) {
812
813 /* Angle of binary on ACQ image */
814 double drottoff = cpl_propertylist_get_double (plist, name);
815
816 /* Position angle of binary */
817 double dx = cpl_propertylist_get_double (plist, "ESO INS SOBJ X");
818 double dy = cpl_propertylist_get_double (plist, "ESO INS SOBJ Y");
819
820 /* If in a mapping template, remove dithering offset */
821 double posangle = 0.0;
822 if (cpl_propertylist_has(plist, "ESO INS SOBJ OFFX") &&
823 cpl_propertylist_has(plist, "ESO INS SOBJ OFFY")) {
824
825 dx -= gravi_pfits_get_double_default (plist, "ESO INS SOBJ OFFX", 0.0);
826 dy -= gravi_pfits_get_double_default (plist, "ESO INS SOBJ OFFY", 0.0);
827 }
828 if ((fabs(dx)>0.0) || (fabs(dy)>0.0))
829 posangle = atan2 (dx, dy) * CPL_MATH_DEG_RAD;
830
831 /* Angle of North in ACQ image, from vertical (y+) to right (x+) */
832 fangle = - posangle - drottoff + 270;
833 if (fangle >= 180) fangle -= 360.0;
834 if (fangle < -180) fangle += 360.0;
835 if (fangle >= 180) fangle -= 360.0;
836 if (fangle < -180) fangle += 360.0;
837
838 cpl_msg_info (cpl_func, "Acquisition camera North angle (tel=%i) = %.2f [deg] / NorthACQ in Y to X", (tel+1), fangle);
839 }
840 else
841 {
842 cpl_msg_warning (cpl_func, "Cannot compute North angle: fangle = 0.0");
843 }
844 }
845
846 return fangle;
847}
848
849
850double gravi_pfits_get_zenithangle_beamb_acqcam (const cpl_propertylist * plist, int tel, int n, int nrow)
851{
852 double zangle = 0.0;
853
854 char pupilrot_start_name[90];
855 char pupilrot_end_name[90];
856 char drot_enc_start_name[90];
857 char drot_enc_end_name[90];
858 char kmiroff_name[90];
859 char rotoff_name[90];
860
861 sprintf (pupilrot_start_name, "ESO ISS IP%i PUPILROT START", 7-tel*2);
862 sprintf (pupilrot_end_name, "ESO ISS IP%i PUPILROT END", 7-tel*2);
863 sprintf (drot_enc_start_name, "ESO INS DROT%i ENC START", tel+1);
864 sprintf (drot_enc_end_name, "ESO INS DROT%i ENC END", tel+1);
865 sprintf (kmiroff_name, "ESO INS KMIRROROFFSET%i", tel+1);
866 sprintf (rotoff_name, "ESO INS ROTATIONOFFSET%i", tel+1);
867
868
869 if (cpl_propertylist_has (plist, pupilrot_start_name) &&
870 cpl_propertylist_has (plist, pupilrot_end_name) &&
871 cpl_propertylist_has (plist, drot_enc_start_name) &&
872 cpl_propertylist_has (plist, drot_enc_end_name) &&
873 cpl_propertylist_has (plist, kmiroff_name) &&
874 cpl_propertylist_has (plist, rotoff_name)) {
875
876 /* VLTI Lab image rotation */
877 double pupilrot1 = cpl_propertylist_get_double(plist, pupilrot_start_name);
878 double pupilrot2 = cpl_propertylist_get_double(plist, pupilrot_end_name);
879
880 double prdif = pupilrot2 - pupilrot1;
881 if (prdif > 180)
882 prdif -= 360;
883 if (prdif < -180)
884 prdif += 360;
885 double pupilrot = pupilrot1 + prdif*n/(nrow-1);
886
887 /* Derotator encoder values */
888 int drotenc1 = cpl_propertylist_get_int(plist, drot_enc_start_name);
889 int drotenc2 = cpl_propertylist_get_int(plist, drot_enc_end_name);
890
891 double drotencdif = (double)drotenc2 - (double)drotenc1;
892 double posenc = (double)drotenc1 + drotencdif*n/(nrow-1);
893
894 /* K-mirror offset angle */
895 double kmirroroffset = cpl_propertylist_get_double(plist, kmiroff_name);
896
897 /* ISS offset angle */
898 double rotoff = cpl_propertylist_get_double(plist, rotoff_name);
899
900 zangle = pupilrot + 90. - posenc / 200. - kmirroroffset - rotoff + 180.;
901 if (zangle >= 180) zangle -= 360.0;
902 if (zangle < -180) zangle += 360.0;
903
904 cpl_msg_info (cpl_func, "Acquisition camera Zenith angle Beam B (tel=%i) = %.2f [deg] / ZenithACQ in Y to X", (tel+1), zangle);
905 }
906 else
907 {
908 cpl_msg_warning (cpl_func, "Cannot compute Zenith angle for Beam B: zangle = 0.0");
909 }
910
911 return zangle;
912}
913
914
915const char * gravi_pfits_get_insname (const cpl_propertylist * plist)
916{
917 const char * value = cpl_propertylist_get_string(plist, "INSNAME");
918 cpl_ensure (value != NULL, cpl_error_get_code(), NULL);
919 return value;
920}
921
922/*---------------------------------------------------------------------------*/
928/*---------------------------------------------------------------------------*/
929
930double gravi_pfits_get_ft_gain (const cpl_propertylist * plist)
931{
932 double gain = 0.0;
933
934 if ( cpl_propertylist_has (plist, "MJD-OBS") &&
935 cpl_propertylist_has (plist, "ESO INS DET3 GAIN") &&
936 cpl_propertylist_get_double (plist, "MJD-OBS") >= 57584.83 &&
937 cpl_propertylist_get_double (plist, "MJD-OBS") < 57617.0) {
938
939 /* Between 57584.83 and 57617.0, the keyword is valid but written
940 * in [adu/e] and the value 3.0 shall be replaced by 1.7 [adu/e] */
941 gain = cpl_propertylist_get_double (plist, "ESO INS DET3 GAIN");
942 if (gain == 3.0) gain = 1.7;
943 cpl_msg_warning (cpl_func,"Use FT gain of %.3f [adu/e] (wrong units and value in header)", gain);
944 } else if ( cpl_propertylist_has (plist, "MJD-OBS") &&
945 cpl_propertylist_has (plist, "ESO INS DET3 GAIN") &&
946 cpl_propertylist_get_double (plist, "MJD-OBS") >= 57617.0) {
947
948 /* After 57617.0, the keyword is valid and written in [e/adu] */
949 gain = 1. / cpl_propertylist_get_double (plist, "ESO INS DET3 GAIN");
950 cpl_msg_info (cpl_func,"Use FT gain of %.3f [adu/e] from header", gain);
951 } else {
952 /* The keyword is not valid at all */
953 gain = 25.0;
954 cpl_msg_warning (cpl_func,"Force FT gain to %.3f [adu/e] (wrong value or no value in header)", gain);
955 }
956
957 /* gain in ADU/e */
958 return gain;
959}
960
961/*---------------------------------------------------------------------------*/
967/*---------------------------------------------------------------------------*/
968
969double gravi_pfits_get_sc_gain (const cpl_propertylist * plist)
970{
971 double gain = 0.0;
972
973 if ( cpl_propertylist_has (plist, "MJD-OBS") &&
974 cpl_propertylist_has (plist, "ESO INS DET2 GAIN") &&
975 cpl_propertylist_get_double (plist, "MJD-OBS") > 57617.0) {
976
977 /* After 57617.0, the keyword is valid and written in [e/adu] */
978 gain = 1. / cpl_propertylist_get_double (plist, "ESO INS DET2 GAIN");
979 cpl_msg_info (cpl_func,"Use SC gain of %.3f [adu/e] from header", gain);
980 } else {
981 /* The keyword is not valid at all */
982 gain = 0.5;
983 cpl_msg_warning (cpl_func,"Force SC gain to %.3f [adu/e]", gain);
984 }
985
986 /* gain in ADU/e */
987 return gain;
988}
989
990
991
992/*-----------------------------------------------------------------------------
993 Extract sub-set of propertylist
994 -----------------------------------------------------------------------------*/
995
996/*-----------------------------------------------------------------------------*/
1002/*-----------------------------------------------------------------------------*/
1003
1004cpl_propertylist * gravi_plist_get_oifits_keywords (cpl_propertylist * header)
1005{
1007
1008 cpl_propertylist * o_plist = cpl_propertylist_new ();
1009
1010 /* CONTENT */
1011 cpl_propertylist_update_string (o_plist, "CONTENT", "OIFITS2");
1012 cpl_propertylist_update_string (o_plist, "REFERENC", "2001PASP..112.1133P");
1013
1014 /* OBSERVER */
1015 const char * observer = gravi_pfits_get_string_default (header, "ESO ISS OPER", "Unknown");
1016 cpl_propertylist_update_string (o_plist, "OBSERVER", observer);
1017
1018 /* PROG_ID */
1019 const char * prog_id = gravi_pfits_get_string_default (header, "ESO OBS PROG ID", "Unknown");
1020 cpl_propertylist_update_string (o_plist, "PROG_ID", prog_id);
1021
1022 /* PROCSOFT */
1023 char * procsoft = cpl_sprintf("GRAVITY pipeline %s", PACKAGE_VERSION);
1024 cpl_propertylist_update_string (o_plist, "PROCSOFT", procsoft);
1025 FREE (cpl_free, procsoft);
1026
1027 /* OBJECT -- may be overwritten by ESO esorex mechanism */
1028 const char * sc_object = gravi_pfits_get_sobj (header);
1029 const char * ft_object = gravi_pfits_get_robj (header);
1030 char * object = cpl_sprintf ("%s,%s", sc_object, ft_object);
1031 cpl_propertylist_update_string (o_plist, "OBJECT", object);
1032 FREE (cpl_free, object);
1033
1034 /* INSMODE */
1035 char * mode;
1036 mode = cpl_sprintf ("%s,%s,%s,%s",
1041 cpl_propertylist_update_string (o_plist, "INSMODE", mode);
1042 FREE (cpl_free, mode);
1043
1044 CPLCHECK_NUL ("Cannot fill the OIFITS2 specific keywords");
1045
1047 return o_plist;
1048}
1049
1050/*-----------------------------------------------------------------------------*/
1057/*-----------------------------------------------------------------------------*/
1058cpl_parameter * gravi_pfits_get_extrapixel_param(const cpl_propertylist * header)
1059{
1060 /* Check inputs */
1061 cpl_ensure (header, CPL_ERROR_NULL_INPUT, NULL);
1062
1063 int key_index = 1;
1064 const char* param_value=NULL;
1065 const char * param_name = "extra-pixel-ft";
1066 char key[100];
1067
1068 sprintf (key, "ESO PRO REC1 PARAM%d NAME",key_index);
1069 while (cpl_propertylist_has(header, key)){
1070 if (!strcmp(cpl_propertylist_get_string(header, key), param_name))
1071 {
1072 sprintf (key, "ESO PRO REC1 PARAM%d VALUE",key_index);
1073 param_value = cpl_propertylist_get_string(header, key);
1074 cpl_msg_info (cpl_func, "Retrieve the extra-pixel-ft option from the p2vm: [%s] ", param_value);
1075 }
1076 sprintf (key, "ESO PRO REC1 PARAM%d NAME", ++key_index);
1077 }
1078
1079 cpl_parameter * p = cpl_parameter_new_value ("gravity.preproc.extra-pixel-ft", CPL_TYPE_BOOL,
1080 "Include the 6th pixels ot the FT",
1081 "gravity.preproc", TRUE);
1082 cpl_parameter_set_alias (p, CPL_PARAMETER_MODE_CLI, "extra-pixel-ft");
1083
1084 if (param_value != NULL && !strcmp(param_value, "true"))
1085 cpl_parameter_set_bool(p, 1);
1086 else
1087 cpl_parameter_set_bool(p, 0);
1088
1089 cpl_msg_info(cpl_func, "Set extra-pixel-ft option : [%d] ", cpl_parameter_get_bool(p));
1090 return p;
1091}
1092
1093/*-----------------------------------------------------------------------------*/
1099/*-----------------------------------------------------------------------------*/
1100
1101cpl_propertylist * gravi_plist_get_qc (cpl_propertylist * header)
1102{
1103 const char * qc = " QC ";
1104
1105 /* Check inputs */
1106 cpl_ensure (header, CPL_ERROR_NULL_INPUT, NULL);
1107
1108 /* Research all the qc parameter inside the primary header of the data */
1109 cpl_propertylist * applist = cpl_propertylist_new();
1110 cpl_size size = cpl_propertylist_get_size (header);
1111 for (cpl_size i = 0; i < size; i++) {
1112 cpl_property * p = cpl_propertylist_get (header, i);
1113 const char * p_name = cpl_property_get_name (p);
1114 if ( (strstr(p_name, qc) != NULL) ||
1115 (strstr(p_name, GRAVI_NIGHT_OBS) != NULL) ) {
1116 cpl_type type_qc = cpl_property_get_type (p);
1117 switch (type_qc) {
1118 case CPL_TYPE_FLOAT :
1119 if (cpl_property_get_float (p) != NAN)
1120 cpl_propertylist_append_property(applist, p);
1121 else
1122 cpl_msg_warning(cpl_func, "The parameter %s is not correct", cpl_property_get_name (p));
1123 break;
1124 case CPL_TYPE_DOUBLE :
1125 if (cpl_property_get_double (p) != NAN)
1126 cpl_propertylist_append_property(applist, p);
1127 else
1128 cpl_msg_warning(cpl_func, "The parameter %s is not correct", cpl_property_get_name (p));
1129 break;
1130 case CPL_TYPE_INT :
1131 if (cpl_property_get_int (p) != NAN)
1132 cpl_propertylist_append_property(applist, p);
1133 else
1134 cpl_msg_warning(cpl_func, "The parameter %s is not correct", cpl_property_get_name (p));
1135 break;
1136 case CPL_TYPE_STRING :
1137 if (cpl_property_get_string (p))
1138 cpl_propertylist_append_property(applist, p);
1139 else
1140 cpl_msg_warning(cpl_func, "The parameter %s is not correct", cpl_property_get_name (p));
1141 break;
1142 case CPL_TYPE_CHAR :
1143 if (cpl_property_get_char (p))
1144 cpl_propertylist_append_property(applist, p);
1145 else
1146 cpl_msg_warning(cpl_func, "The parameter %s is not correct", cpl_property_get_name (p));
1147 break;
1148 case CPL_TYPE_BOOL :
1149 cpl_propertylist_append_property (applist, p);
1150 break;
1151 default :
1152 cpl_msg_error (cpl_func,"'%s' is an invalid type of property",p_name);
1153 cpl_error_set_message(cpl_func, CPL_ERROR_INVALID_TYPE,
1154 "invalid type of property");
1155 return NULL;
1156 }
1157 }
1158 }
1159 return applist;
1160}
1161
1162/*-----------------------------------------------------------------------------
1163 Function to convert string
1164 -----------------------------------------------------------------------------*/
1165
1166double gravi_convert_to_mjd (const char * start)
1167{
1168 cpl_ensure (start, CPL_ERROR_NULL_INPUT, 0.0);
1169
1170 /* Cut the string: 2015-04-01T20:36:59.380228
1171 * and convert each in int or double */
1172 char * str = cpl_strdup (start);
1173
1174 str[4] = '\n';
1175 str[7] = '\n';
1176 str[10] = '\n';
1177 str[13] = '\n';
1178 str[16] = '\n';
1179
1180 int iy = atoi (str+0); // YYYY
1181 int im = atoi (str+5); // MM
1182 int id = atoi (str+8); // DD
1183 double dhr = atof (str+11); // hh
1184 double dmin = atof (str+14); // mm
1185 double dsec = atof (str+17); // ss.ss
1186 cpl_free (str);
1187
1188 /* Get the MJD at 00:00 with ERFA [d] */
1189 double dmjd0, dmjd;
1190 eraCal2jd (iy, im, id, &dmjd0, &dmjd);
1191
1192 /* Return the full MJD [d] */
1193 return dmjd + (dhr + (dmin + dsec/60.0)/60.0)/24.0;
1194}
1195
1197{
1198 int year, month, day, hour, minute;
1199 double fraction, second;
1200
1201 eraJd2cal (2400000.5, mjd, &year, &month, &day, &fraction);
1202
1203 hour = (int)(fraction/3600.0);
1204 fraction -= hour*3600.0;
1205 minute = (int)(fraction/60.0);
1206 fraction -= minute*60.0;
1207 second = fraction;
1208
1209 return cpl_sprintf ("%04i-%02i-%02iT%02i:%02i:%06.3f", year, month, day, hour, minute, second);
1210}
1211
1212double gravi_pfits_get_decep (const cpl_propertylist * plist, double coef)
1213{
1214 cpl_ensure (plist, CPL_ERROR_NULL_INPUT, 0.0);
1215 cpl_ensure (coef >= 0 && coef <= 1, CPL_ERROR_ILLEGAL_INPUT, 0.0);
1216
1217 /* Get RA and DEC in [rad] */
1218 // double raz = gravi_pfits_get_robj_raep (plist);
1219 double decz = gravi_pfits_get_robj_decep (plist);
1220
1221 /* Get and convert the offsets from [mas] to [rad] */
1222 double xi = gravi_pfits_get_sobj_x (plist) / 3600000. * CPL_MATH_RAD_DEG * coef;
1223 double eta = gravi_pfits_get_sobj_y (plist) / 3600000. * CPL_MATH_RAD_DEG * coef;
1224
1225 double sdecz = sin(decz);
1226 double cdecz = cos(decz);
1227 double denom = cdecz - eta * sdecz;
1228
1229 /* Compute new coordinates in [rad] */
1230 double dec = atan2 (sdecz+eta*cdecz, sqrt(xi*xi + denom*denom));
1231
1232 /* Return in [rad] */
1233 return dec;
1234}
1235
1236double gravi_ra_to_rad (const char *stri)
1237{
1238 cpl_ensure (stri, CPL_ERROR_NULL_INPUT, 0.0);
1239
1240 /* Assume the format is HH MM SS.SSSS */
1241 char * str = cpl_strdup (stri);
1242 str[2] = '\0';
1243 str[5] = '\0';
1244
1245 /* Ra in [hours] */
1246 double out = 0.0;
1247 out += atof(str+0);
1248 out += atof(str+3) / 60;
1249 out += atof(str+6) / 3600;
1250
1251 cpl_free (str);
1252 return out / 12 * CPL_MATH_PI;
1253}
1254
1255double gravi_dec_to_rad (const char *stri)
1256{
1257 cpl_ensure (stri, CPL_ERROR_NULL_INPUT, 0.0);
1258
1259 /* Assume the format is +DD MM SS.SSSS */
1260 char * str = cpl_strdup (stri);
1261 str[3] = '\0';
1262 str[6] = '\0';
1263
1264 /* Ra in [hours] */
1265 double out = 0.0;
1266 out += atof(str+1);
1267 out += atof(str+4) / 60;
1268 out += atof(str+7) / 3600;
1269
1270 out *= (str[0]=='-' ? -1.0 : 1.0);
1271
1272 cpl_free (str);
1273 return out / 180 * CPL_MATH_PI;
1274}
1275
1276
1277/*-----------------------------------------------------------------------------
1278 Function to read the target coordinates
1279 -----------------------------------------------------------------------------*/
1280
1281double gravi_pfits_get_raep(const cpl_propertylist * plist, double coef)
1282{
1283 cpl_ensure (plist, CPL_ERROR_NULL_INPUT, 0.0);
1284 cpl_ensure (coef >= 0 && coef <= 1, CPL_ERROR_ILLEGAL_INPUT, 0.0);
1285
1286 /* Get RA and DEC in [rad] */
1287 double raz = gravi_pfits_get_robj_raep (plist);
1288 double decz = gravi_pfits_get_robj_decep (plist);
1289
1290 /* Get and convert the offsets from [mas] to [rad] */
1291 double xi = gravi_pfits_get_sobj_x (plist) / 3600000. * CPL_MATH_RAD_DEG * coef;
1292 double eta = gravi_pfits_get_sobj_y (plist) / 3600000. * CPL_MATH_RAD_DEG * coef;
1293
1294 double sdecz = sin(decz);
1295 double cdecz = cos(decz);
1296 double denom = cdecz - eta * sdecz;
1297
1298 /* Compute new coordinates in [rad] */
1299 double ra = atan2 (xi,denom) + raz;
1300
1301 /* Make ra within 0-2pi */
1302 ra = fmod (ra, CPL_MATH_2PI);
1303 if ( ra < 0.0 ) ra += CPL_MATH_2PI;
1304
1305 /* Return in [rad] */
1306 return ra;
1307}
1308
1309double gravi_pfits_get_robj_raep(const cpl_propertylist * plist)
1310{
1311 cpl_ensure (plist, CPL_ERROR_NULL_INPUT, 99.);
1312 cpl_errorstate prestate = cpl_errorstate_get();
1313 char tmp[15];
1314
1315 /* Read the parameter as string */
1316 const char * str_value;
1317 str_value = gravi_pfits_get_string_default (plist, "ESO FT ROBJ ALPHA", "000000.00");
1318
1319 double value = 99.;
1320
1321 /* Read of the form '043555.24' */
1322 cpl_msg_debug( cpl_func, "Found '%s'", str_value );
1323
1324 /* Read 2 first chars */
1325 strncpy(tmp, str_value, 2);
1326 tmp[2] = '\0';
1327 cpl_msg_debug( cpl_func, "Found tmp '%s' -> %f", tmp, atof(tmp) );
1328 value = atof(tmp);
1329
1330 /* Read 2 more chars */
1331 strncpy(tmp, str_value+2, 4);
1332 tmp[2] = '\0';
1333 cpl_msg_debug( cpl_func, "Found tmp '%s' -> %f", tmp, atof(tmp) );
1334 value += atof(tmp) / 60.0;
1335
1336 /* Read remaining data */
1337 strcpy(tmp, str_value+4);
1338 cpl_msg_debug( cpl_func, "Found tmp '%s' -> %f", tmp, atof(tmp) );
1339 value += atof(tmp) / 3600.0;
1340
1341 /* Convert hours to deg */
1342 value *= 360. / 24;
1343
1344 /* Verbose */
1345 cpl_msg_debug( cpl_func, "Convert RA='%s' into RA=%fdeg", str_value, value);
1346
1347 if (cpl_error_get_code() == CPL_ERROR_DATA_NOT_FOUND) {
1348 cpl_errorstate_set (prestate);
1349 cpl_msg_warning(cpl_func, "rarp doesn't exist in this file.");
1350 value=0;
1351 }
1352
1353 /* Check for a change in the CPL error state */
1354 /* - if it did change then propagate the error and return */
1355 cpl_ensure(cpl_errorstate_is_equal(prestate), cpl_error_get_code(), 0.0);
1356
1357 /* Convert in [rad] */
1358 return value * CPL_MATH_RAD_DEG;
1359}
1360
1361double gravi_pfits_get_robj_decep (const cpl_propertylist * plist)
1362{
1363 cpl_ensure (plist, CPL_ERROR_NULL_INPUT, 99.);
1364
1365 cpl_errorstate prestate = cpl_errorstate_get();
1366 double value = 99.;
1367 char tmp[15];
1368 double sign;
1369
1370 const char * str_value;
1371 str_value = gravi_pfits_get_string_default (plist, "ESO FT ROBJ DELTA", "+000000.00");
1372
1373 /* Read of the form '163033.49' -- issue with +/- */
1374 cpl_msg_debug( cpl_func, "Found '%s'", str_value );
1375
1376 /* Check the first digit is a sign + or -
1377 and discard it */
1378 if ( str_value[0] == '-' ) {
1379 sign = -1.0;
1380 str_value = str_value + 1;
1381 } else if ( str_value[0] == '+' ) {
1382 sign = +1.0;
1383 str_value = str_value + 1;
1384 } else {
1385 sign = +1.0;
1386 }
1387
1388 /* Read 2 first chars */
1389 strncpy(tmp, str_value, 2);
1390 tmp[2] = '\0';
1391 cpl_msg_debug( cpl_func, "Found tmp '%s' -> %f", tmp, atof(tmp) );
1392 value = atof(tmp);
1393
1394 /* Read 2 more chars */
1395 strncpy(tmp, str_value+2, 4);
1396 tmp[2] = '\0';
1397 cpl_msg_debug( cpl_func, "Found tmp '%s' -> %f", tmp, atof(tmp) );
1398 value += atof(tmp) / 60.0;
1399
1400 /* Read remaining data */
1401 strcpy(tmp, str_value+4);
1402 cpl_msg_debug( cpl_func, "Found tmp '%s' -> %f", tmp, atof(tmp) );
1403 value += atof(tmp) / 3600.0;
1404
1405 /* Apply sign */
1406 value *= sign;
1407
1408 /* Verbose */
1409 cpl_msg_debug( cpl_func, "Convert DEC='%s' into DEC=%fdeg", str_value, value);
1410
1411 if (cpl_error_get_code() == CPL_ERROR_DATA_NOT_FOUND) {
1412 cpl_errorstate_set (prestate);
1413 cpl_msg_warning(cpl_func, "decep doesn't exist in this file.");
1414
1415 value=0;
1416 }
1417
1418 /* Check for a change in the CPL error state */
1419 /* - if it did change then propagate the error and return */
1420 cpl_ensure(cpl_errorstate_is_equal(prestate), cpl_error_get_code(), 0.0);
1421
1422 /* Convert in [rad] */
1423 return value * CPL_MATH_RAD_DEG;
1424}
1425
1426/*-----------------------------------------------------------------------------
1427 Test function codes
1428 -----------------------------------------------------------------------------*/
1429
1430int gravi_pfits_is_calib (const cpl_propertylist * plist)
1431{
1432 cpl_ensure (plist, CPL_ERROR_NULL_INPUT, 0);
1433 const char * opt1 = "ESO INS OPTI1 NAME";
1434
1435 if ( !cpl_propertylist_has (plist, opt1) ) return 0;
1436
1437 const char * value = cpl_propertylist_get_string (plist, opt1);
1438 if ( !strcmp (value,"CALIB") ) return 1;
1439
1440 return 0;
1441}
1442
1443
1444/*----------------------------------------------------------------------------
1445 Generic functions to read and set keyword
1446 ----------------------------------------------------------------------------*/
1447
1448
1449/*----------------------------------------------------------------------------*/
1460/*----------------------------------------------------------------------------*/
1461
1462double gravi_pfits_get_double (const cpl_propertylist * self, const char * name)
1463{
1464 cpl_ensure (self, CPL_ERROR_NULL_INPUT, 0);
1465 cpl_ensure (name, CPL_ERROR_NULL_INPUT, 0);
1466 cpl_ensure (cpl_propertylist_has (self, name), CPL_ERROR_DATA_NOT_FOUND, 0);
1467
1468 cpl_type type = cpl_propertylist_get_type (self, name);
1469 switch (type) {
1470 case CPL_TYPE_CHAR:
1471 case CPL_TYPE_UCHAR:
1472 case CPL_TYPE_BOOL:
1473 case CPL_TYPE_SHORT:
1474 case CPL_TYPE_USHORT:
1475 case CPL_TYPE_INT:
1476 case CPL_TYPE_UINT:
1477 case CPL_TYPE_LONG:
1478 case CPL_TYPE_LONG_LONG:
1479 case CPL_TYPE_ULONG:
1480 case CPL_TYPE_SIZE:
1481 return cpl_propertylist_get_long(self, name);
1482 case CPL_TYPE_FLOAT:
1483 case CPL_TYPE_DOUBLE:
1484 return cpl_propertylist_get_double(self, name);
1485 case CPL_TYPE_STRING:
1486 cpl_msg_debug (cpl_func,"FITS card %s is string '%s' to double %f",
1487 name,cpl_propertylist_get_string(self, name),atof(cpl_propertylist_get_string(self, name)));
1488 return atof(cpl_propertylist_get_string(self, name));
1489 default:
1490 cpl_error_set(cpl_func, CPL_ERROR_TYPE_MISMATCH);
1491 return 0.;
1492 }
1493 return 0.;
1494}
1495
1496cpl_error_code gravi_pfits_ensure_double (cpl_propertylist * self, const char * name)
1497{
1498 cpl_ensure_code (self, CPL_ERROR_NULL_INPUT);
1499 cpl_ensure_code (name, CPL_ERROR_NULL_INPUT);
1500
1501 /* Get value and comment */
1502 double value = gravi_pfits_get_double (self, name);
1503 char * comment = cpl_sprintf ("%s", cpl_propertylist_get_comment (self, name));
1504
1505 /* Delete card and set back to double */
1506 cpl_propertylist_erase (self, name);
1507 cpl_propertylist_append_double (self, name, value );
1508 cpl_propertylist_set_comment (self, name, comment);
1509 cpl_free (comment);
1510
1511 return cpl_error_get_code();
1512}
1513
1514/*
1515 * Set the header keyword NAME+EXT to value
1516 * protected from nan
1517 */
1518cpl_error_code gravi_pfits_update_double (cpl_propertylist * plist,
1519 const char * full_name, double value)
1520{
1521 cpl_error_code code;
1522 cpl_ensure_code (plist, CPL_ERROR_NULL_INPUT);
1523 cpl_ensure_code (full_name, CPL_ERROR_NULL_INPUT);
1524
1525 /* Set value with check for nan */
1526 if ( isnan(value) )
1528 else
1529 cpl_propertylist_update_double (plist, full_name, value);
1530
1531 /* Check */
1532 if ( (code=cpl_error_get_code()) ) {
1533 cpl_msg_warning (cpl_func, "Cannot set keyword: %s", full_name);
1534 return cpl_error_set_message(cpl_func, code, "Cannot set keyword: %s", full_name);
1535 }
1536
1537 return CPL_ERROR_NONE;
1538}
1539
1540cpl_error_code gravi_pfits_update_int (cpl_propertylist * plist,
1541 const char * full_name, int value)
1542{
1543 cpl_error_code code;
1544 cpl_ensure_code (plist, CPL_ERROR_NULL_INPUT);
1545 cpl_ensure_code (full_name, CPL_ERROR_NULL_INPUT);
1546
1547 /* Set value with check for nan */
1548 if ( isnan((double)value) )
1549 cpl_propertylist_update_int (plist, full_name, GRAVI_NAN_INT);
1550 else
1551 cpl_propertylist_update_int (plist, full_name, value);
1552
1553 /* Check */
1554 if ( (code=cpl_error_get_code()) ) {
1555 cpl_msg_warning (cpl_func, "Cannot set keyword: %s", full_name);
1556 return cpl_error_set_message(cpl_func, code, "Cannot set keyword: %s", full_name);
1557 }
1558
1559 return CPL_ERROR_NONE;
1560}
1561
1562const char * gravi_pfits_get_string_default (const cpl_propertylist * plist,
1563 const char *name,
1564 const char *def)
1565{
1566 cpl_ensure (plist, CPL_ERROR_NULL_INPUT, def);
1567 cpl_ensure (name, CPL_ERROR_NULL_INPUT, def);
1568
1569 const char *output;
1570
1571 if (cpl_propertylist_has(plist, name)) {
1572 /* Try to read this keyword */
1573 output = cpl_propertylist_get_string(plist, name);
1574 } else {
1575 /* Get the default and add warning only if not CALIB */
1576 output = def;
1577
1579 cpl_msg_warning (cpl_func, "Can't find keyword %s (use '%s')", name, def);
1580 else
1581 cpl_msg_info (cpl_func, "Can't find keyword %s (use '%s')", name, def);
1582 }
1583
1584 return output;
1585}
1586
1587double gravi_pfits_get_double_default (const cpl_propertylist * plist,
1588 const char *name,
1589 double def)
1590{
1591 cpl_ensure (plist, CPL_ERROR_NULL_INPUT, def);
1592 cpl_ensure (name, CPL_ERROR_NULL_INPUT, def);
1593
1594 double output;
1595
1596 if (cpl_propertylist_has(plist, name)) {
1597 /* Try to read this keyword as a double */
1598 output = gravi_pfits_get_double(plist, name);
1599 } else {
1600 /* Get the default and add warning only if not CALIB */
1601 output = def;
1602
1604 cpl_msg_warning (cpl_func, "Can't find keyword %s (use '%f')", name, def);
1605 else
1606 cpl_msg_info (cpl_func, "Can't find keyword %s (use '%f')", name, def);
1607 }
1608
1609 return output;
1610}
1611
1612double gravi_pfits_get_double_silentdefault (const cpl_propertylist * plist,
1613 const char *name,
1614 double def)
1615{
1616 cpl_ensure (plist, CPL_ERROR_NULL_INPUT, def);
1617 cpl_ensure (name, CPL_ERROR_NULL_INPUT, def);
1618 double output;
1619
1620 if (cpl_propertylist_has(plist, name))
1621 output = gravi_pfits_get_double (plist, name);
1622 else
1623 output = def;
1624
1625 return output;
1626}
1627
1628/*---------------------------------------------------------------------------*/
1641/*---------------------------------------------------------------------------*/
1642
1643cpl_error_code gravi_pfits_add_check (cpl_propertylist * header, const char *msg)
1644{
1646 cpl_ensure_code (header, CPL_ERROR_NULL_INPUT);
1647 cpl_ensure_code (msg, CPL_ERROR_NULL_INPUT);
1648
1649 /* Increment counter */
1650 int i = 1;
1651 if (cpl_propertylist_has (header, "ESO QC CHECK FLAGS"))
1652 i = cpl_propertylist_get_int (header, "ESO QC CHECK FLAGS") + 1;
1653
1654 cpl_propertylist_update_int (header, "ESO QC CHECK FLAGS", i);
1655 /* CPLCHECK_MSG ("Cannot add check flags2..."); */
1656
1657 /* Set message */
1658 char qc_name[80];
1659 sprintf (qc_name, "ESO QC CHECK MSG%i", i);
1660
1661 cpl_msg_warning (cpl_func, "%s = '%s'", qc_name, msg);
1662 cpl_propertylist_append_string (header, qc_name, msg);
1663
1664 CPLCHECK_MSG ("Cannot add check msg...");
1665
1667 return CPL_ERROR_NONE;
1668}
1669
1670/*---------------------------------------------------------------------------*/
1681/*---------------------------------------------------------------------------*/
1682
1683cpl_error_code gravi_pfits_add_pipe_build (cpl_propertylist * header)
1684{
1686 cpl_ensure_code (header, CPL_ERROR_NULL_INPUT);
1687
1688 char name[100];
1689 char value[100];
1690
1691 /* Increment counter until empty slot */
1692 int i = 0;
1693 do {
1694 i++;
1695 sprintf (name, "ESO PRO REC%i PIPE LAST_BUILD", i);
1696 } while (cpl_propertylist_has (header, name));
1697
1698 /* Define the last build string */
1699 sprintf (value, "%s %s", __DATE__,__TIME__);
1700 cpl_msg_info (cpl_func, "%s = '%s'", name, value);
1701
1702 /* Write into header */
1703 cpl_propertylist_update_string (header, name, value);
1704 cpl_propertylist_set_comment (header, name, "Last 'make clean all install'");
1705 CPLCHECK_MSG ("Cannot add PIPE LAST_BUILD...");
1706
1708 return CPL_ERROR_NONE;
1709}
1710
1711
cpl_msg_debug(cpl_func, "Spectra has <50 pixels -> don't flat")
cpl_propertylist * header
Definition: gravi_old.c:2004
cpl_propertylist * plist
Definition: gravi_old.c:2000
cpl_msg_info(cpl_func, "Compute WAVE_SCAN for %s", GRAVI_TYPE(type_data))
cpl_propertylist_update_double(header, "ESO QC MINWAVE SC", cpl_propertylist_get_double(plist, "ESO QC MINWAVE SC"))
#define GRAVI_NAN_DOUBLE
Definition: gravi_pfits.h:97
#define GRAVI_SC
Definition: gravi_pfits.h:165
#define GRAVI_NAN_INT
Definition: gravi_pfits.h:99
#define PROFILE_FULLSTARTX
Definition: gravi_pfits.h:146
#define GRAVI_NIGHT_OBS
Definition: gravi_pfits.h:36
#define PROFILE_NX
Definition: gravi_pfits.h:147
#define MODE_DUAL
Definition: gravi_pfits.h:178
#define MODE_OFFAXIS
Definition: gravi_pfits.h:180
#define PROFILE_STARTX
Definition: gravi_pfits.h:145
#define MET_NORMAL_HEADER
Definition: gravi_pfits.h:185
#define MET_FAINT_HEADER
Definition: gravi_pfits.h:186
#define MODE_SINGLE
Definition: gravi_pfits.h:177
#define GRAVI_FT
Definition: gravi_pfits.h:166
#define MODE_ONAXIS
Definition: gravi_pfits.h:179
#define gravi_msg_function_exit(flag)
Definition: gravi_utils.h:85
#define FREE(function, variable)
Definition: gravi_utils.h:69
#define CPLCHECK_NUL(msg)
Definition: gravi_utils.h:48
#define gravi_msg_function_start(flag)
Definition: gravi_utils.h:84
#define CPLCHECK_MSG(msg)
Definition: gravi_utils.h:45
int gravi_pfits_get_startx(const cpl_propertylist *plist)
find out the name of the propertylist
Definition: gravi_pfits.c:68
double gravi_pfits_get_sobj_offy(const cpl_propertylist *plist)
Definition: gravi_pfits.c:473
double gravi_pfits_get_zenithangle_beamb_acqcam(const cpl_propertylist *plist, int tel, int n, int nrow)
Definition: gravi_pfits.c:850
const char * gravi_pfits_get_insname(const cpl_propertylist *plist)
Definition: gravi_pfits.c:915
cpl_propertylist * gravi_plist_get_oifits_keywords(cpl_propertylist *header)
Create OIFITS keywords to satisfy standar.
Definition: gravi_pfits.c:1004
cpl_propertylist * gravi_plist_get_qc(cpl_propertylist *header)
Extract QC parameters.
Definition: gravi_pfits.c:1101
int gravi_pfits_get_pola_num(const cpl_propertylist *plist, int type_data)
Definition: gravi_pfits.c:263
const char * gravi_pfits_get_met_ph(const cpl_propertylist *plist)
Definition: gravi_pfits.c:534
cpl_error_code gravi_pfits_update_double(cpl_propertylist *plist, const char *full_name, double value)
Definition: gravi_pfits.c:1518
double gravi_pfits_get_sobj_offx(const cpl_propertylist *plist)
Definition: gravi_pfits.c:467
cpl_error_code gravi_pfits_update_int(cpl_propertylist *plist, const char *full_name, int value)
Definition: gravi_pfits.c:1540
double gravi_pfits_get_gvctu_x(const cpl_propertylist *plist)
Definition: gravi_pfits.c:479
const char * gravi_pfits_get_mode_name(const cpl_propertylist *plist)
Definition: gravi_pfits.c:242
double gravi_pfits_get_gdzero(const cpl_propertylist *plist, int tel)
Definition: gravi_pfits.c:562
double gravi_pfits_get_sobj_y(const cpl_propertylist *plist)
Definition: gravi_pfits.c:461
double gravi_pfits_get_robj_diam(const cpl_propertylist *plist)
Definition: gravi_pfits.c:505
int gravi_pfits_get_fullstartx(const cpl_propertylist *plist)
Definition: gravi_pfits.c:76
double gravi_pfits_get_geolon(const cpl_propertylist *plist)
Definition: gravi_pfits.c:419
const char * gravi_pfits_get_sobj(const cpl_propertylist *plist)
Definition: gravi_pfits.c:441
int gravi_pfits_get_mode(const cpl_propertylist *plist)
Definition: gravi_pfits.c:193
double gravi_pfits_get_metfc_lockmjd(const cpl_propertylist *plist, int tel)
Definition: gravi_pfits.c:295
const char * gravi_pfits_get_pola_mode(const cpl_propertylist *plist, int type_data)
Definition: gravi_pfits.c:169
double gravi_convert_to_mjd(const char *start)
Definition: gravi_pfits.c:1166
cpl_error_code gravi_pfits_add_check(cpl_propertylist *header, const char *msg)
Add a QC.CHECK keyword to the header.
Definition: gravi_pfits.c:1643
int gravi_data_frame_get_mode(const cpl_frame *frame)
Definition: gravi_pfits.c:177
double gravi_pfits_get_pmra(const cpl_propertylist *plist)
Definition: gravi_pfits.c:119
cpl_error_code gravi_pfits_ensure_double(cpl_propertylist *self, const char *name)
Definition: gravi_pfits.c:1496
int gravi_pfits_get_extension_type(const cpl_propertylist *plist)
Definition: gravi_pfits.c:271
double gravi_pfits_get_oplzero(const cpl_propertylist *plist, int tel)
Definition: gravi_pfits.c:606
double gravi_pfits_get_plx(const cpl_propertylist *plist)
Definition: gravi_pfits.c:133
cpl_parameter * gravi_pfits_get_extrapixel_param(const cpl_propertylist *header)
Extract parameters from a product header.
Definition: gravi_pfits.c:1058
const char * gravi_pfits_get_spec_res(const cpl_propertylist *plist)
Definition: gravi_pfits.c:162
double gravi_pfits_get_drotoff(const cpl_propertylist *plist, int tel)
Definition: gravi_pfits.c:783
int gravi_pfits_is_calib(const cpl_propertylist *plist)
Definition: gravi_pfits.c:1430
double gravi_pfits_get_robj_raep(const cpl_propertylist *plist)
Definition: gravi_pfits.c:1309
double gravi_pfits_get_dit_sc(const cpl_propertylist *plist)
Definition: gravi_pfits.c:664
double gravi_dec_to_rad(const char *stri)
Definition: gravi_pfits.c:1255
double gravi_pfits_get_dit_ft(const cpl_propertylist *plist)
Definition: gravi_pfits.c:673
const char * gravi_pfits_get_string_default(const cpl_propertylist *plist, const char *name, const char *def)
Definition: gravi_pfits.c:1562
const char * gravi_pfits_get_robj(const cpl_propertylist *plist)
Definition: gravi_pfits.c:499
int gravi_pfits_has_gdzero(const cpl_propertylist *plist, int tel)
Definition: gravi_pfits.c:541
double gravi_pfits_get_northangle_acqcam(const cpl_propertylist *plist, int tel)
Definition: gravi_pfits.c:794
double gravi_pfits_get_gvctu_y(const cpl_propertylist *plist)
Definition: gravi_pfits.c:489
double gravi_pfits_get_met_wavelength_mean(const cpl_propertylist *plist, cpl_table *met_table)
Definition: gravi_pfits.c:312
double gravi_pfits_get_dit_acqcam(const cpl_propertylist *plist)
Definition: gravi_pfits.c:655
cpl_vector * gravi_pfits_get_met_faint_params(const cpl_propertylist *plist)
Extract metrology faint settings.
Definition: gravi_pfits.c:380
double gravi_pfits_get_mjd(const cpl_propertylist *plist)
Definition: gravi_pfits.c:526
int gravi_pfits_get_axis(const cpl_propertylist *plist)
Definition: gravi_pfits.c:213
const char * gravi_pfits_get_resolution(const cpl_propertylist *plist)
Definition: gravi_pfits.c:155
const char * gravi_pfits_get_start_sc(const cpl_propertylist *plist)
Definition: gravi_pfits.c:631
double gravi_pfits_get_period_sc(const cpl_propertylist *plist)
Definition: gravi_pfits.c:682
double gravi_pfits_get_ft_gain(const cpl_propertylist *plist)
FT system gain in [ADU/e].
Definition: gravi_pfits.c:930
double gravi_pfits_get_geolat(const cpl_propertylist *plist)
Definition: gravi_pfits.c:411
double gravi_pfits_get_period_acqcam(const cpl_propertylist *plist)
Definition: gravi_pfits.c:691
const char * gravi_pfits_get_start_prcacq(const cpl_propertylist *plist)
Definition: gravi_pfits.c:647
double gravi_pfits_get_time_sc(const cpl_propertylist *header, cpl_size row)
Time of the middle of the SC exposure row in [us], counted from PRC.ACQ.START.
Definition: gravi_pfits.c:710
cpl_error_code gravi_pfits_add_pipe_build(cpl_propertylist *header)
Add the ESO PRO REC# PIPE LAST_BUILD in header.
Definition: gravi_pfits.c:1683
double gravi_pfits_get_sobj_diam(const cpl_propertylist *plist)
Definition: gravi_pfits.c:447
char * gravi_convert_to_timestamp(double mjd)
Definition: gravi_pfits.c:1196
double gravi_pfits_get_fddlwindow(const cpl_propertylist *plist)
Definition: gravi_pfits.c:518
int gravi_pfits_get_nx(const cpl_propertylist *plist)
Definition: gravi_pfits.c:84
double gravi_pfits_get_double(const cpl_propertylist *self, const char *name)
Get the double value of the given property list entry.
Definition: gravi_pfits.c:1462
const char * gravi_pfits_get_feed(const cpl_propertylist *plist)
Definition: gravi_pfits.c:435
const char * gravi_pfits_get_dpr_type(const cpl_propertylist *plist)
Definition: gravi_pfits.c:148
double gravi_pfits_get_sc_gain(const cpl_propertylist *plist)
SC system gain in [ADU/e].
Definition: gravi_pfits.c:969
int gravi_pfits_get_met_mode(const cpl_propertylist *plist)
Definition: gravi_pfits.c:359
double gravi_pfits_get_pmdec(const cpl_propertylist *plist)
Definition: gravi_pfits.c:126
const char * gravi_pfits_get_extname(const cpl_propertylist *plist)
Definition: gravi_pfits.c:140
int gravi_pfits_has_oplzero(const cpl_propertylist *plist, int tel)
Definition: gravi_pfits.c:586
double gravi_pfits_get_decep(const cpl_propertylist *plist, double coef)
Definition: gravi_pfits.c:1212
double gravi_pfits_get_double_silentdefault(const cpl_propertylist *plist, const char *name, double def)
Definition: gravi_pfits.c:1612
double gravi_pfits_get_sobj_x(const cpl_propertylist *plist)
Definition: gravi_pfits.c:455
double gravi_pfits_get_diameter(const cpl_propertylist *plist, int type_data)
Definition: gravi_pfits.c:100
double gravi_pfits_get_geoelev(const cpl_propertylist *plist)
Definition: gravi_pfits.c:427
double gravi_pfits_get_raep(const cpl_propertylist *plist, double coef)
Definition: gravi_pfits.c:1281
double gravi_pfits_get_met_wavelength(const cpl_propertylist *plist)
Definition: gravi_pfits.c:321
double gravi_ra_to_rad(const char *stri)
Definition: gravi_pfits.c:1236
double gravi_pfits_get_robj_decep(const cpl_propertylist *plist)
Definition: gravi_pfits.c:1361
double gravi_pfits_get_time_acqcam(const cpl_propertylist *header, cpl_size row)
Time of the middle of the ACQCAM exposure row in [us], counted from PRC.ACQ.START.
Definition: gravi_pfits.c:749
int gravi_pfits_get_window_start(const cpl_propertylist *plist)
Definition: gravi_pfits.c:92
double gravi_pfits_get_double_default(const cpl_propertylist *plist, const char *name, double def)
Definition: gravi_pfits.c:1587
double gravi_pfits_get_ptfc_acqcam(const cpl_propertylist *plist, int spot)
Definition: gravi_pfits.c:773
const char * gravi_pfits_get_start_acqcam(const cpl_propertylist *plist)
Definition: gravi_pfits.c:639