GRAVI Pipeline Reference Manual 1.10.1
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_projected_baseline_start (const cpl_propertylist * plist, int tel1, int tel2)
795{
796 char name[90];
797
798 /* Projected baseline between telescopes tel1 and tel2 at start of observation */
799 sprintf (name, "ESO ISS PBL%i%i START", tel1, tel2);
800 double pbl = cpl_propertylist_get_double (plist, name);
801
802 return pbl;
803}
804
805double gravi_pfits_get_projected_baseline_end (const cpl_propertylist * plist, int tel1, int tel2)
806{
807 char name[90];
808
809 /* Projected baseline between telescopes tel1 and tel2 at end of observation */
810 sprintf (name, "ESO ISS PBL%i%i END", tel1, tel2);
811 double pbl = cpl_propertylist_get_double (plist, name);
812
813 return pbl;
814}
815
816double gravi_pfits_get_northangle_acqcam (const cpl_propertylist * plist, int tel)
817{
818 double fangle = 0.0;
819
820 char name[90];
821 sprintf (name, "ESO INS DROTOFF%i", tel+1);
822
823 if (cpl_propertylist_has(plist, "ESO ACQ NORTHANG"))
824 {
825 fangle = cpl_propertylist_get_double (plist, "ESO ACQ NORTHANG");
826 cpl_msg_warning( cpl_func, "Using ACQ Camera North angle from header" );
827 cpl_msg_warning (cpl_func, "North angle = %.2f [deg] / NorthACQ in Y to X", fangle);
828 }
829 else
830 {
831 if (cpl_propertylist_has (plist, "ESO INS SOBJ X") &&
832 cpl_propertylist_has (plist, "ESO INS SOBJ Y") &&
833 cpl_propertylist_has (plist, name)) {
834
835 /* Angle of binary on ACQ image */
836 double drottoff = cpl_propertylist_get_double (plist, name);
837
838 /* Position angle of binary */
839 double dx = cpl_propertylist_get_double (plist, "ESO INS SOBJ X");
840 double dy = cpl_propertylist_get_double (plist, "ESO INS SOBJ Y");
841
842 /* If in a mapping template, remove dithering offset */
843 double posangle = 0.0;
844 if (cpl_propertylist_has(plist, "ESO INS SOBJ OFFX") &&
845 cpl_propertylist_has(plist, "ESO INS SOBJ OFFY")) {
846
847 dx -= gravi_pfits_get_double_default (plist, "ESO INS SOBJ OFFX", 0.0);
848 dy -= gravi_pfits_get_double_default (plist, "ESO INS SOBJ OFFY", 0.0);
849 }
850 if ((fabs(dx)>0.0) || (fabs(dy)>0.0))
851 posangle = atan2 (dx, dy) * CPL_MATH_DEG_RAD;
852
853 /* Angle of North in ACQ image, from vertical (y+) to right (x+) */
854 fangle = - posangle - drottoff + 270;
855 if (fangle >= 180) fangle -= 360.0;
856 if (fangle < -180) fangle += 360.0;
857 if (fangle >= 180) fangle -= 360.0;
858 if (fangle < -180) fangle += 360.0;
859
860 cpl_msg_info (cpl_func, "Acquisition camera North angle (tel=%i) = %.2f [deg] / NorthACQ in Y to X", (tel+1), fangle);
861 }
862 else
863 {
864 cpl_msg_warning (cpl_func, "Cannot compute North angle: fangle = 0.0");
865 }
866 }
867
868 return fangle;
869}
870
871
872double gravi_pfits_get_zenithangle_beamb_acqcam (const cpl_propertylist * plist, int tel, int n, int nrow)
873{
874 double zangle = 0.0;
875
876 char pupilrot_start_name[90];
877 char pupilrot_end_name[90];
878 char drot_enc_start_name[90];
879 char drot_enc_end_name[90];
880 char kmiroff_name[90];
881 char rotoff_name[90];
882
883 sprintf (pupilrot_start_name, "ESO ISS IP%i PUPILROT START", 7-tel*2);
884 sprintf (pupilrot_end_name, "ESO ISS IP%i PUPILROT END", 7-tel*2);
885 sprintf (drot_enc_start_name, "ESO INS DROT%i ENC START", tel+1);
886 sprintf (drot_enc_end_name, "ESO INS DROT%i ENC END", tel+1);
887 sprintf (kmiroff_name, "ESO INS KMIRROROFFSET%i", tel+1);
888 sprintf (rotoff_name, "ESO INS ROTATIONOFFSET%i", tel+1);
889
890
891 if (cpl_propertylist_has (plist, pupilrot_start_name) &&
892 cpl_propertylist_has (plist, pupilrot_end_name) &&
893 cpl_propertylist_has (plist, drot_enc_start_name) &&
894 cpl_propertylist_has (plist, drot_enc_end_name) &&
895 cpl_propertylist_has (plist, kmiroff_name) &&
896 cpl_propertylist_has (plist, rotoff_name)) {
897
898 /* VLTI Lab image rotation */
899 double pupilrot1 = cpl_propertylist_get_double(plist, pupilrot_start_name);
900 double pupilrot2 = cpl_propertylist_get_double(plist, pupilrot_end_name);
901
902 double prdif = pupilrot2 - pupilrot1;
903 if (prdif > 180)
904 prdif -= 360;
905 if (prdif < -180)
906 prdif += 360;
907 double pupilrot = pupilrot1 + prdif*n/(nrow-1);
908
909 /* Derotator encoder values */
910 int drotenc1 = cpl_propertylist_get_int(plist, drot_enc_start_name);
911 int drotenc2 = cpl_propertylist_get_int(plist, drot_enc_end_name);
912
913 double drotencdif = (double)drotenc2 - (double)drotenc1;
914 double posenc = (double)drotenc1 + drotencdif*n/(nrow-1);
915
916 /* K-mirror offset angle */
917 double kmirroroffset = cpl_propertylist_get_double(plist, kmiroff_name);
918
919 /* ISS offset angle */
920 double rotoff = cpl_propertylist_get_double(plist, rotoff_name);
921
922 zangle = pupilrot + 90. - posenc / 200. - kmirroroffset - rotoff + 180.;
923 if (zangle >= 180) zangle -= 360.0;
924 if (zangle < -180) zangle += 360.0;
925
926 cpl_msg_info (cpl_func, "Acquisition camera Zenith angle Beam B (tel=%i) = %.2f [deg] / ZenithACQ in Y to X", (tel+1), zangle);
927 }
928 else
929 {
930 cpl_msg_warning (cpl_func, "Cannot compute Zenith angle for Beam B: zangle = 0.0");
931 }
932
933 return zangle;
934}
935
936
937const char * gravi_pfits_get_insname (const cpl_propertylist * plist)
938{
939 const char * value = cpl_propertylist_get_string(plist, "INSNAME");
940 cpl_ensure (value != NULL, cpl_error_get_code(), NULL);
941 return value;
942}
943
944/*---------------------------------------------------------------------------*/
950/*---------------------------------------------------------------------------*/
951
952double gravi_pfits_get_ft_gain (const cpl_propertylist * plist)
953{
954 double gain = 0.0;
955
956 if ( cpl_propertylist_has (plist, "MJD-OBS") &&
957 cpl_propertylist_has (plist, "ESO INS DET3 GAIN") &&
958 cpl_propertylist_get_double (plist, "MJD-OBS") >= 57584.83 &&
959 cpl_propertylist_get_double (plist, "MJD-OBS") < 57617.0) {
960
961 /* Between 57584.83 and 57617.0, the keyword is valid but written
962 * in [adu/e] and the value 3.0 shall be replaced by 1.7 [adu/e] */
963 gain = cpl_propertylist_get_double (plist, "ESO INS DET3 GAIN");
964 if (gain == 3.0) gain = 1.7;
965 cpl_msg_warning (cpl_func,"Use FT gain of %.3f [adu/e] (wrong units and value in header)", gain);
966 } else if ( cpl_propertylist_has (plist, "MJD-OBS") &&
967 cpl_propertylist_has (plist, "ESO INS DET3 GAIN") &&
968 cpl_propertylist_get_double (plist, "MJD-OBS") >= 57617.0) {
969
970 /* After 57617.0, the keyword is valid and written in [e/adu] */
971 gain = 1. / cpl_propertylist_get_double (plist, "ESO INS DET3 GAIN");
972 cpl_msg_info (cpl_func,"Use FT gain of %.3f [adu/e] from header", gain);
973 } else {
974 /* The keyword is not valid at all */
975 gain = 25.0;
976 cpl_msg_warning (cpl_func,"Force FT gain to %.3f [adu/e] (wrong value or no value in header)", gain);
977 }
978
979 /* gain in ADU/e */
980 return gain;
981}
982
983/*---------------------------------------------------------------------------*/
989/*---------------------------------------------------------------------------*/
990
991double gravi_pfits_get_sc_gain (const cpl_propertylist * plist)
992{
993 double gain = 0.0;
994
995 if ( cpl_propertylist_has (plist, "MJD-OBS") &&
996 cpl_propertylist_has (plist, "ESO INS DET2 GAIN") &&
997 cpl_propertylist_get_double (plist, "MJD-OBS") > 57617.0) {
998
999 /* After 57617.0, the keyword is valid and written in [e/adu] */
1000 gain = 1. / cpl_propertylist_get_double (plist, "ESO INS DET2 GAIN");
1001 cpl_msg_info (cpl_func,"Use SC gain of %.3f [adu/e] from header", gain);
1002 } else {
1003 /* The keyword is not valid at all */
1004 gain = 0.5;
1005 cpl_msg_warning (cpl_func,"Force SC gain to %.3f [adu/e]", gain);
1006 }
1007
1008 /* gain in ADU/e */
1009 return gain;
1010}
1011
1012
1013
1014/*-----------------------------------------------------------------------------
1015 Extract sub-set of propertylist
1016 -----------------------------------------------------------------------------*/
1017
1018/*-----------------------------------------------------------------------------*/
1024/*-----------------------------------------------------------------------------*/
1025
1026cpl_propertylist * gravi_plist_get_oifits_keywords (cpl_propertylist * header)
1027{
1029
1030 cpl_propertylist * o_plist = cpl_propertylist_new ();
1031
1032 /* CONTENT */
1033 cpl_propertylist_update_string (o_plist, "CONTENT", "OIFITS2");
1034 cpl_propertylist_update_string (o_plist, "REFERENC", "2001PASP..112.1133P");
1035
1036 /* OBSERVER */
1037 const char * observer = gravi_pfits_get_string_default (header, "ESO ISS OPER", "Unknown");
1038 cpl_propertylist_update_string (o_plist, "OBSERVER", observer);
1039
1040 /* PROG_ID */
1041 const char * prog_id = gravi_pfits_get_string_default (header, "ESO OBS PROG ID", "Unknown");
1042 cpl_propertylist_update_string (o_plist, "PROG_ID", prog_id);
1043
1044 /* PROCSOFT */
1045 char * procsoft = cpl_sprintf("GRAVITY pipeline %s", PACKAGE_VERSION);
1046 cpl_propertylist_update_string (o_plist, "PROCSOFT", procsoft);
1047 FREE (cpl_free, procsoft);
1048
1049 /* OBJECT -- may be overwritten by ESO esorex mechanism */
1050 const char * sc_object = gravi_pfits_get_sobj (header);
1051 const char * ft_object = gravi_pfits_get_robj (header);
1052 char * object = cpl_sprintf ("%s,%s", sc_object, ft_object);
1053 cpl_propertylist_update_string (o_plist, "OBJECT", object);
1054 FREE (cpl_free, object);
1055
1056 /* INSMODE */
1057 char * mode;
1058 mode = cpl_sprintf ("%s,%s,%s,%s",
1063 cpl_propertylist_update_string (o_plist, "INSMODE", mode);
1064 FREE (cpl_free, mode);
1065
1066 CPLCHECK_NUL ("Cannot fill the OIFITS2 specific keywords");
1067
1069 return o_plist;
1070}
1071
1072/*-----------------------------------------------------------------------------*/
1079/*-----------------------------------------------------------------------------*/
1080cpl_parameter * gravi_pfits_get_extrapixel_param(const cpl_propertylist * header)
1081{
1082 /* Check inputs */
1083 cpl_ensure (header, CPL_ERROR_NULL_INPUT, NULL);
1084
1085 int key_index = 1;
1086 const char* param_value=NULL;
1087 const char * param_name = "extra-pixel-ft";
1088 char key[100];
1089
1090 sprintf (key, "ESO PRO REC1 PARAM%d NAME",key_index);
1091 while (cpl_propertylist_has(header, key)){
1092 if (!strcmp(cpl_propertylist_get_string(header, key), param_name))
1093 {
1094 sprintf (key, "ESO PRO REC1 PARAM%d VALUE",key_index);
1095 param_value = cpl_propertylist_get_string(header, key);
1096 cpl_msg_info (cpl_func, "Retrieve the extra-pixel-ft option from the p2vm: [%s] ", param_value);
1097 }
1098 sprintf (key, "ESO PRO REC1 PARAM%d NAME", ++key_index);
1099 }
1100
1101 cpl_parameter * p = cpl_parameter_new_value ("gravity.preproc.extra-pixel-ft", CPL_TYPE_BOOL,
1102 "Include the 6th pixels ot the FT",
1103 "gravity.preproc", TRUE);
1104 cpl_parameter_set_alias (p, CPL_PARAMETER_MODE_CLI, "extra-pixel-ft");
1105
1106 if (param_value != NULL && !strcmp(param_value, "true"))
1107 cpl_parameter_set_bool(p, 1);
1108 else
1109 cpl_parameter_set_bool(p, 0);
1110
1111 cpl_msg_info(cpl_func, "Set extra-pixel-ft option : [%d] ", cpl_parameter_get_bool(p));
1112 return p;
1113}
1114
1115/*-----------------------------------------------------------------------------*/
1121/*-----------------------------------------------------------------------------*/
1122
1123cpl_propertylist * gravi_plist_get_qc (cpl_propertylist * header)
1124{
1125 const char * qc = " QC ";
1126
1127 /* Check inputs */
1128 cpl_ensure (header, CPL_ERROR_NULL_INPUT, NULL);
1129
1130 /* Research all the qc parameter inside the primary header of the data */
1131 cpl_propertylist * applist = cpl_propertylist_new();
1132 cpl_size size = cpl_propertylist_get_size (header);
1133 for (cpl_size i = 0; i < size; i++) {
1134 cpl_property * p = cpl_propertylist_get (header, i);
1135 const char * p_name = cpl_property_get_name (p);
1136 if ( (strstr(p_name, qc) != NULL) ||
1137 (strstr(p_name, GRAVI_NIGHT_OBS) != NULL) ) {
1138 cpl_type type_qc = cpl_property_get_type (p);
1139 switch (type_qc) {
1140 case CPL_TYPE_FLOAT :
1141 if (cpl_property_get_float (p) != NAN)
1142 cpl_propertylist_append_property(applist, p);
1143 else
1144 cpl_msg_warning(cpl_func, "The parameter %s is not correct", cpl_property_get_name (p));
1145 break;
1146 case CPL_TYPE_DOUBLE :
1147 if (cpl_property_get_double (p) != NAN)
1148 cpl_propertylist_append_property(applist, p);
1149 else
1150 cpl_msg_warning(cpl_func, "The parameter %s is not correct", cpl_property_get_name (p));
1151 break;
1152 case CPL_TYPE_INT :
1153 if (cpl_property_get_int (p) != NAN)
1154 cpl_propertylist_append_property(applist, p);
1155 else
1156 cpl_msg_warning(cpl_func, "The parameter %s is not correct", cpl_property_get_name (p));
1157 break;
1158 case CPL_TYPE_STRING :
1159 if (cpl_property_get_string (p))
1160 cpl_propertylist_append_property(applist, p);
1161 else
1162 cpl_msg_warning(cpl_func, "The parameter %s is not correct", cpl_property_get_name (p));
1163 break;
1164 case CPL_TYPE_CHAR :
1165 if (cpl_property_get_char (p))
1166 cpl_propertylist_append_property(applist, p);
1167 else
1168 cpl_msg_warning(cpl_func, "The parameter %s is not correct", cpl_property_get_name (p));
1169 break;
1170 case CPL_TYPE_BOOL :
1171 cpl_propertylist_append_property (applist, p);
1172 break;
1173 default :
1174 cpl_msg_error (cpl_func,"'%s' is an invalid type of property",p_name);
1175 cpl_error_set_message(cpl_func, CPL_ERROR_INVALID_TYPE,
1176 "invalid type of property");
1177 return NULL;
1178 }
1179 }
1180 }
1181 return applist;
1182}
1183
1184/*-----------------------------------------------------------------------------
1185 Function to convert string
1186 -----------------------------------------------------------------------------*/
1187
1188double gravi_convert_to_mjd (const char * start)
1189{
1190 cpl_ensure (start, CPL_ERROR_NULL_INPUT, 0.0);
1191
1192 /* Cut the string: 2015-04-01T20:36:59.380228
1193 * and convert each in int or double */
1194 char * str = cpl_strdup (start);
1195
1196 str[4] = '\n';
1197 str[7] = '\n';
1198 str[10] = '\n';
1199 str[13] = '\n';
1200 str[16] = '\n';
1201
1202 int iy = atoi (str+0); // YYYY
1203 int im = atoi (str+5); // MM
1204 int id = atoi (str+8); // DD
1205 double dhr = atof (str+11); // hh
1206 double dmin = atof (str+14); // mm
1207 double dsec = atof (str+17); // ss.ss
1208 cpl_free (str);
1209
1210 /* Get the MJD at 00:00 with ERFA [d] */
1211 double dmjd0, dmjd;
1212 eraCal2jd (iy, im, id, &dmjd0, &dmjd);
1213
1214 /* Return the full MJD [d] */
1215 return dmjd + (dhr + (dmin + dsec/60.0)/60.0)/24.0;
1216}
1217
1219{
1220 int year, month, day, hour, minute;
1221 double fraction, second;
1222
1223 eraJd2cal (2400000.5, mjd, &year, &month, &day, &fraction);
1224
1225 hour = (int)(fraction/3600.0);
1226 fraction -= hour*3600.0;
1227 minute = (int)(fraction/60.0);
1228 fraction -= minute*60.0;
1229 second = fraction;
1230
1231 return cpl_sprintf ("%04i-%02i-%02iT%02i:%02i:%06.3f", year, month, day, hour, minute, second);
1232}
1233
1234double gravi_pfits_get_decep (const cpl_propertylist * plist, double coef)
1235{
1236 cpl_ensure (plist, CPL_ERROR_NULL_INPUT, 0.0);
1237 cpl_ensure (coef >= 0 && coef <= 1, CPL_ERROR_ILLEGAL_INPUT, 0.0);
1238
1239 /* Get RA and DEC in [rad] */
1240 // double raz = gravi_pfits_get_robj_raep (plist);
1241 double decz = gravi_pfits_get_robj_decep (plist);
1242
1243 /* Get and convert the offsets from [mas] to [rad] */
1244 double xi = gravi_pfits_get_sobj_x (plist) / 3600000. * CPL_MATH_RAD_DEG * coef;
1245 double eta = gravi_pfits_get_sobj_y (plist) / 3600000. * CPL_MATH_RAD_DEG * coef;
1246
1247 double sdecz = sin(decz);
1248 double cdecz = cos(decz);
1249 double denom = cdecz - eta * sdecz;
1250
1251 /* Compute new coordinates in [rad] */
1252 double dec = atan2 (sdecz+eta*cdecz, sqrt(xi*xi + denom*denom));
1253
1254 /* Return in [rad] */
1255 return dec;
1256}
1257
1258double gravi_ra_to_rad (const char *stri)
1259{
1260 cpl_ensure (stri, CPL_ERROR_NULL_INPUT, 0.0);
1261
1262 /* Assume the format is HH MM SS.SSSS */
1263 char * str = cpl_strdup (stri);
1264 str[2] = '\0';
1265 str[5] = '\0';
1266
1267 /* Ra in [hours] */
1268 double out = 0.0;
1269 out += atof(str+0);
1270 out += atof(str+3) / 60;
1271 out += atof(str+6) / 3600;
1272
1273 cpl_free (str);
1274 return out / 12 * CPL_MATH_PI;
1275}
1276
1277double gravi_dec_to_rad (const char *stri)
1278{
1279 cpl_ensure (stri, CPL_ERROR_NULL_INPUT, 0.0);
1280
1281 /* Assume the format is +DD MM SS.SSSS */
1282 char * str = cpl_strdup (stri);
1283 str[3] = '\0';
1284 str[6] = '\0';
1285
1286 /* Ra in [hours] */
1287 double out = 0.0;
1288 out += atof(str+1);
1289 out += atof(str+4) / 60;
1290 out += atof(str+7) / 3600;
1291
1292 out *= (str[0]=='-' ? -1.0 : 1.0);
1293
1294 cpl_free (str);
1295 return out / 180 * CPL_MATH_PI;
1296}
1297
1298
1299/*-----------------------------------------------------------------------------
1300 Function to read the target coordinates
1301 -----------------------------------------------------------------------------*/
1302
1303double gravi_pfits_get_raep(const cpl_propertylist * plist, double coef)
1304{
1305 cpl_ensure (plist, CPL_ERROR_NULL_INPUT, 0.0);
1306 cpl_ensure (coef >= 0 && coef <= 1, CPL_ERROR_ILLEGAL_INPUT, 0.0);
1307
1308 /* Get RA and DEC in [rad] */
1309 double raz = gravi_pfits_get_robj_raep (plist);
1310 double decz = gravi_pfits_get_robj_decep (plist);
1311
1312 /* Get and convert the offsets from [mas] to [rad] */
1313 double xi = gravi_pfits_get_sobj_x (plist) / 3600000. * CPL_MATH_RAD_DEG * coef;
1314 double eta = gravi_pfits_get_sobj_y (plist) / 3600000. * CPL_MATH_RAD_DEG * coef;
1315
1316 double sdecz = sin(decz);
1317 double cdecz = cos(decz);
1318 double denom = cdecz - eta * sdecz;
1319
1320 /* Compute new coordinates in [rad] */
1321 double ra = atan2 (xi,denom) + raz;
1322
1323 /* Make ra within 0-2pi */
1324 ra = fmod (ra, CPL_MATH_2PI);
1325 if ( ra < 0.0 ) ra += CPL_MATH_2PI;
1326
1327 /* Return in [rad] */
1328 return ra;
1329}
1330
1331double gravi_pfits_get_robj_raep(const cpl_propertylist * plist)
1332{
1333 cpl_ensure (plist, CPL_ERROR_NULL_INPUT, 99.);
1334 cpl_errorstate prestate = cpl_errorstate_get();
1335 char tmp[15];
1336
1337 /* Read the parameter as string */
1338 const char * str_value;
1339 str_value = gravi_pfits_get_string_default (plist, "ESO FT ROBJ ALPHA", "000000.00");
1340
1341 double value = 99.;
1342
1343 /* Read of the form '043555.24' */
1344 cpl_msg_debug( cpl_func, "Found '%s'", str_value );
1345
1346 /* Read 2 first chars */
1347 strncpy(tmp, str_value, 2);
1348 tmp[2] = '\0';
1349 cpl_msg_debug( cpl_func, "Found tmp '%s' -> %f", tmp, atof(tmp) );
1350 value = atof(tmp);
1351
1352 /* Read 2 more chars */
1353 strncpy(tmp, str_value+2, 4);
1354 tmp[2] = '\0';
1355 cpl_msg_debug( cpl_func, "Found tmp '%s' -> %f", tmp, atof(tmp) );
1356 value += atof(tmp) / 60.0;
1357
1358 /* Read remaining data */
1359 strcpy(tmp, str_value+4);
1360 cpl_msg_debug( cpl_func, "Found tmp '%s' -> %f", tmp, atof(tmp) );
1361 value += atof(tmp) / 3600.0;
1362
1363 /* Convert hours to deg */
1364 value *= 360. / 24;
1365
1366 /* Verbose */
1367 cpl_msg_debug( cpl_func, "Convert RA='%s' into RA=%fdeg", str_value, value);
1368
1369 if (cpl_error_get_code() == CPL_ERROR_DATA_NOT_FOUND) {
1370 cpl_errorstate_set (prestate);
1371 cpl_msg_warning(cpl_func, "rarp doesn't exist in this file.");
1372 value=0;
1373 }
1374
1375 /* Check for a change in the CPL error state */
1376 /* - if it did change then propagate the error and return */
1377 cpl_ensure(cpl_errorstate_is_equal(prestate), cpl_error_get_code(), 0.0);
1378
1379 /* Convert in [rad] */
1380 return value * CPL_MATH_RAD_DEG;
1381}
1382
1383double gravi_pfits_get_robj_decep (const cpl_propertylist * plist)
1384{
1385 cpl_ensure (plist, CPL_ERROR_NULL_INPUT, 99.);
1386
1387 cpl_errorstate prestate = cpl_errorstate_get();
1388 double value = 99.;
1389 char tmp[15];
1390 double sign;
1391
1392 const char * str_value;
1393 str_value = gravi_pfits_get_string_default (plist, "ESO FT ROBJ DELTA", "+000000.00");
1394
1395 /* Read of the form '163033.49' -- issue with +/- */
1396 cpl_msg_debug( cpl_func, "Found '%s'", str_value );
1397
1398 /* Check the first digit is a sign + or -
1399 and discard it */
1400 if ( str_value[0] == '-' ) {
1401 sign = -1.0;
1402 str_value = str_value + 1;
1403 } else if ( str_value[0] == '+' ) {
1404 sign = +1.0;
1405 str_value = str_value + 1;
1406 } else {
1407 sign = +1.0;
1408 }
1409
1410 /* Read 2 first chars */
1411 strncpy(tmp, str_value, 2);
1412 tmp[2] = '\0';
1413 cpl_msg_debug( cpl_func, "Found tmp '%s' -> %f", tmp, atof(tmp) );
1414 value = atof(tmp);
1415
1416 /* Read 2 more chars */
1417 strncpy(tmp, str_value+2, 4);
1418 tmp[2] = '\0';
1419 cpl_msg_debug( cpl_func, "Found tmp '%s' -> %f", tmp, atof(tmp) );
1420 value += atof(tmp) / 60.0;
1421
1422 /* Read remaining data */
1423 strcpy(tmp, str_value+4);
1424 cpl_msg_debug( cpl_func, "Found tmp '%s' -> %f", tmp, atof(tmp) );
1425 value += atof(tmp) / 3600.0;
1426
1427 /* Apply sign */
1428 value *= sign;
1429
1430 /* Verbose */
1431 cpl_msg_debug( cpl_func, "Convert DEC='%s' into DEC=%fdeg", str_value, value);
1432
1433 if (cpl_error_get_code() == CPL_ERROR_DATA_NOT_FOUND) {
1434 cpl_errorstate_set (prestate);
1435 cpl_msg_warning(cpl_func, "decep doesn't exist in this file.");
1436
1437 value=0;
1438 }
1439
1440 /* Check for a change in the CPL error state */
1441 /* - if it did change then propagate the error and return */
1442 cpl_ensure(cpl_errorstate_is_equal(prestate), cpl_error_get_code(), 0.0);
1443
1444 /* Convert in [rad] */
1445 return value * CPL_MATH_RAD_DEG;
1446}
1447
1448/*-----------------------------------------------------------------------------
1449 Test function codes
1450 -----------------------------------------------------------------------------*/
1451
1452int gravi_pfits_is_calib (const cpl_propertylist * plist)
1453{
1454 cpl_ensure (plist, CPL_ERROR_NULL_INPUT, 0);
1455 const char * opt1 = "ESO INS OPTI1 NAME";
1456
1457 if ( !cpl_propertylist_has (plist, opt1) ) return 0;
1458
1459 const char * value = cpl_propertylist_get_string (plist, opt1);
1460 if ( !strcmp (value,"CALIB") ) return 1;
1461
1462 return 0;
1463}
1464
1465
1466/*----------------------------------------------------------------------------
1467 Generic functions to read and set keyword
1468 ----------------------------------------------------------------------------*/
1469
1470
1471/*----------------------------------------------------------------------------*/
1482/*----------------------------------------------------------------------------*/
1483
1484double gravi_pfits_get_double (const cpl_propertylist * self, const char * name)
1485{
1486 cpl_ensure (self, CPL_ERROR_NULL_INPUT, 0);
1487 cpl_ensure (name, CPL_ERROR_NULL_INPUT, 0);
1488 cpl_ensure (cpl_propertylist_has (self, name), CPL_ERROR_DATA_NOT_FOUND, 0);
1489
1490 cpl_type type = cpl_propertylist_get_type (self, name);
1491 switch (type) {
1492 case CPL_TYPE_CHAR:
1493 case CPL_TYPE_UCHAR:
1494 case CPL_TYPE_BOOL:
1495 case CPL_TYPE_SHORT:
1496 case CPL_TYPE_USHORT:
1497 case CPL_TYPE_INT:
1498 case CPL_TYPE_UINT:
1499 case CPL_TYPE_LONG:
1500 case CPL_TYPE_LONG_LONG:
1501 case CPL_TYPE_ULONG:
1502 case CPL_TYPE_SIZE:
1503 return cpl_propertylist_get_long(self, name);
1504 case CPL_TYPE_FLOAT:
1505 case CPL_TYPE_DOUBLE:
1506 return cpl_propertylist_get_double(self, name);
1507 case CPL_TYPE_STRING:
1508 cpl_msg_debug (cpl_func,"FITS card %s is string '%s' to double %f",
1509 name,cpl_propertylist_get_string(self, name),atof(cpl_propertylist_get_string(self, name)));
1510 return atof(cpl_propertylist_get_string(self, name));
1511 default:
1512 cpl_error_set(cpl_func, CPL_ERROR_TYPE_MISMATCH);
1513 return 0.;
1514 }
1515 return 0.;
1516}
1517
1518cpl_error_code gravi_pfits_ensure_double (cpl_propertylist * self, const char * name)
1519{
1520 cpl_ensure_code (self, CPL_ERROR_NULL_INPUT);
1521 cpl_ensure_code (name, CPL_ERROR_NULL_INPUT);
1522
1523 /* Get value and comment */
1524 double value = gravi_pfits_get_double (self, name);
1525 char * comment = cpl_sprintf ("%s", cpl_propertylist_get_comment (self, name));
1526
1527 /* Delete card and set back to double */
1528 cpl_propertylist_erase (self, name);
1529 cpl_propertylist_append_double (self, name, value );
1530 cpl_propertylist_set_comment (self, name, comment);
1531 cpl_free (comment);
1532
1533 return cpl_error_get_code();
1534}
1535
1536/*
1537 * Set the header keyword NAME+EXT to value
1538 * protected from nan
1539 */
1540cpl_error_code gravi_pfits_update_double (cpl_propertylist * plist,
1541 const char * full_name, double 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(value) )
1550 else
1551 cpl_propertylist_update_double (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
1562cpl_error_code gravi_pfits_update_int (cpl_propertylist * plist,
1563 const char * full_name, int value)
1564{
1565 cpl_error_code code;
1566 cpl_ensure_code (plist, CPL_ERROR_NULL_INPUT);
1567 cpl_ensure_code (full_name, CPL_ERROR_NULL_INPUT);
1568
1569 /* Set value with check for nan */
1570 if ( isnan((double)value) )
1571 cpl_propertylist_update_int (plist, full_name, GRAVI_NAN_INT);
1572 else
1573 cpl_propertylist_update_int (plist, full_name, value);
1574
1575 /* Check */
1576 if ( (code=cpl_error_get_code()) ) {
1577 cpl_msg_warning (cpl_func, "Cannot set keyword: %s", full_name);
1578 return cpl_error_set_message(cpl_func, code, "Cannot set keyword: %s", full_name);
1579 }
1580
1581 return CPL_ERROR_NONE;
1582}
1583
1584const char * gravi_pfits_get_string_default (const cpl_propertylist * plist,
1585 const char *name,
1586 const char *def)
1587{
1588 cpl_ensure (plist, CPL_ERROR_NULL_INPUT, def);
1589 cpl_ensure (name, CPL_ERROR_NULL_INPUT, def);
1590
1591 const char *output;
1592
1593 if (cpl_propertylist_has(plist, name)) {
1594 /* Try to read this keyword */
1595 output = cpl_propertylist_get_string(plist, name);
1596 } else {
1597 /* Get the default and add warning only if not CALIB */
1598 output = def;
1599
1601 cpl_msg_warning (cpl_func, "Can't find keyword %s (use '%s')", name, def);
1602 else
1603 cpl_msg_info (cpl_func, "Can't find keyword %s (use '%s')", name, def);
1604 }
1605
1606 return output;
1607}
1608
1609double gravi_pfits_get_double_default (const cpl_propertylist * plist,
1610 const char *name,
1611 double def)
1612{
1613 cpl_ensure (plist, CPL_ERROR_NULL_INPUT, def);
1614 cpl_ensure (name, CPL_ERROR_NULL_INPUT, def);
1615
1616 double output;
1617
1618 if (cpl_propertylist_has(plist, name)) {
1619 /* Try to read this keyword as a double */
1620 output = gravi_pfits_get_double(plist, name);
1621 } else {
1622 /* Get the default and add warning only if not CALIB */
1623 output = def;
1624
1626 cpl_msg_warning (cpl_func, "Can't find keyword %s (use '%f')", name, def);
1627 else
1628 cpl_msg_info (cpl_func, "Can't find keyword %s (use '%f')", name, def);
1629 }
1630
1631 return output;
1632}
1633
1634double gravi_pfits_get_double_silentdefault (const cpl_propertylist * plist,
1635 const char *name,
1636 double def)
1637{
1638 cpl_ensure (plist, CPL_ERROR_NULL_INPUT, def);
1639 cpl_ensure (name, CPL_ERROR_NULL_INPUT, def);
1640 double output;
1641
1642 if (cpl_propertylist_has(plist, name))
1643 output = gravi_pfits_get_double (plist, name);
1644 else
1645 output = def;
1646
1647 return output;
1648}
1649
1650/*---------------------------------------------------------------------------*/
1663/*---------------------------------------------------------------------------*/
1664
1665cpl_error_code gravi_pfits_add_check (cpl_propertylist * header, const char *msg)
1666{
1668 cpl_ensure_code (header, CPL_ERROR_NULL_INPUT);
1669 cpl_ensure_code (msg, CPL_ERROR_NULL_INPUT);
1670
1671 /* Increment counter */
1672 int i = 1;
1673 if (cpl_propertylist_has (header, "ESO QC CHECK FLAGS"))
1674 i = cpl_propertylist_get_int (header, "ESO QC CHECK FLAGS") + 1;
1675
1676 cpl_propertylist_update_int (header, "ESO QC CHECK FLAGS", i);
1677 /* CPLCHECK_MSG ("Cannot add check flags2..."); */
1678
1679 /* Set message */
1680 char qc_name[80];
1681 sprintf (qc_name, "ESO QC CHECK MSG%i", i);
1682
1683 cpl_msg_warning (cpl_func, "%s = '%s'", qc_name, msg);
1684 cpl_propertylist_append_string (header, qc_name, msg);
1685
1686 CPLCHECK_MSG ("Cannot add check msg...");
1687
1689 return CPL_ERROR_NONE;
1690}
1691
1692/*---------------------------------------------------------------------------*/
1703/*---------------------------------------------------------------------------*/
1704
1705cpl_error_code gravi_pfits_add_pipe_build (cpl_propertylist * header)
1706{
1708 cpl_ensure_code (header, CPL_ERROR_NULL_INPUT);
1709
1710 char name[100];
1711 char value[100];
1712
1713 /* Increment counter until empty slot */
1714 int i = 0;
1715 do {
1716 i++;
1717 sprintf (name, "ESO PRO REC%i PIPE LAST_BUILD", i);
1718 } while (cpl_propertylist_has (header, name));
1719
1720 /* Define the last build string */
1721 sprintf (value, "%s %s", __DATE__,__TIME__);
1722 cpl_msg_info (cpl_func, "%s = '%s'", name, value);
1723
1724 /* Write into header */
1725 cpl_propertylist_update_string (header, name, value);
1726 cpl_propertylist_set_comment (header, name, "Last 'make clean all install'");
1727 CPLCHECK_MSG ("Cannot add PIPE LAST_BUILD...");
1728
1730 return CPL_ERROR_NONE;
1731}
1732
1733
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:872
const char * gravi_pfits_get_insname(const cpl_propertylist *plist)
Definition: gravi_pfits.c:937
cpl_propertylist * gravi_plist_get_oifits_keywords(cpl_propertylist *header)
Create OIFITS keywords to satisfy standar.
Definition: gravi_pfits.c:1026
cpl_propertylist * gravi_plist_get_qc(cpl_propertylist *header)
Extract QC parameters.
Definition: gravi_pfits.c:1123
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:1540
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:1562
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
double gravi_pfits_get_projected_baseline_end(const cpl_propertylist *plist, int tel1, int tel2)
Definition: gravi_pfits.c:805
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:1188
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:1665
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:1518
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:1080
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:1452
double gravi_pfits_get_robj_raep(const cpl_propertylist *plist)
Definition: gravi_pfits.c:1331
double gravi_pfits_get_dit_sc(const cpl_propertylist *plist)
Definition: gravi_pfits.c:664
double gravi_pfits_get_projected_baseline_start(const cpl_propertylist *plist, int tel1, int tel2)
Definition: gravi_pfits.c:794
double gravi_dec_to_rad(const char *stri)
Definition: gravi_pfits.c:1277
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:1584
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:816
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:952
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:1705
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:1218
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:1484
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:991
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:1234
double gravi_pfits_get_double_silentdefault(const cpl_propertylist *plist, const char *name, double def)
Definition: gravi_pfits.c:1634
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:1303
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:1258
double gravi_pfits_get_robj_decep(const cpl_propertylist *plist)
Definition: gravi_pfits.c:1383
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:1609
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