ERIS Pipeline Reference Manual 1.8.15
eris_pfits.c
1/* $Id: eris_pfits.c,v 1.14 2013-03-25 11:46:49 cgarcia Exp $
2 *
3 * This file is part of the ERIS 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20
21/*
22 * $Author: cgarcia $
23 * $Date: 2013-03-25 11:46:49 $
24 * $Revision: 1.14 $
25 * $Name: not supported by cvs2svn $
26 */
27
28#ifdef HAVE_CONFIG_H
29#include <config.h>
30#endif
31
32/*-----------------------------------------------------------------------------
33 Includes
34 -----------------------------------------------------------------------------*/
35
36#include <cpl.h>
37
38#include "eris_pfits.h"
39
40/*----------------------------------------------------------------------------*/
45/*----------------------------------------------------------------------------*/
46
49/*-----------------------------------------------------------------------------
50 Function codes
51 -----------------------------------------------------------------------------*/
52
53
54/*----------------------------------------------------------------------------*/
62/*----------------------------------------------------------------------------*/
63//TODO: why we reset the error in function below?
64const char *
65eris_pfits_get_ancestor(const cpl_propertylist *aHeaders)
66{
67 cpl_ensure(aHeaders, CPL_ERROR_NULL_INPUT, NULL);
68 cpl_errorstate prestate = cpl_errorstate_get();
69 const char *value = cpl_propertylist_get_string(aHeaders, "ESO PRO ANCESTOR");
70 cpl_errorstate_set(prestate);
71 return value;
72}
73
74
75/*----------------------------------------------------------------------------*/
81/*----------------------------------------------------------------------------*/
82const char * eris_pfits_get_arcfile(const cpl_propertylist * plist)
83{
84 const char * value = cpl_propertylist_get_string(plist, "ARCFILE");
85
86 cpl_ensure(value != NULL, cpl_error_get_code(), NULL);
87
88 return value;
89}
90
91/*----------------------------------------------------------------------------*/
97/*----------------------------------------------------------------------------*/
98double eris_pfits_get_dit(const cpl_propertylist * plist)
99{
100 cpl_errorstate prestate = cpl_errorstate_get();
101 const double value = cpl_propertylist_get_double(plist, "ESO DET SEQ1 DIT");
102
103 /* Check for a change in the CPL error state */
104 /* - if it did change then propagate the error and return */
105 cpl_ensure(cpl_errorstate_is_equal(prestate), cpl_error_get_code(), 0.0);
106
107 return value;
108}
109
110/*----------------------------------------------------------------------------*/
116/*----------------------------------------------------------------------------*/
117int eris_pfits_get_ndit(const cpl_propertylist * plist)
118{
119 cpl_errorstate prestate = cpl_errorstate_get();
120 const int value = cpl_propertylist_get_int(plist, "ESO DET NDIT");
121
122 /* Check for a change in the CPL error state */
123 /* - if it did change then propagate the error and return */
124 cpl_ensure(cpl_errorstate_is_equal(prestate), cpl_error_get_code(), 0);
125
126 return value;
127}
128
129
130/*---------------------------------------------------------------------------*/
136/*---------------------------------------------------------------------------*/
137double eris_pfits_get_exptime(const char * filename)
138{
139 double exptime ;
140 cpl_propertylist* plist = NULL;
141 plist = cpl_propertylist_load(filename, 0);
142 exptime = cpl_propertylist_get_double(plist, "EXPTIME");
143 cpl_propertylist_delete(plist);
144
145 return exptime;
146}
147
148/*---------------------------------------------------------------------------*/
154/*---------------------------------------------------------------------------*/
155int eris_pfits_get_naxis1(const cpl_propertylist * plist)
156{
157 return cpl_propertylist_get_int(plist, "NAXIS1");
158}
159
160
161/*---------------------------------------------------------------------------*/
167/*---------------------------------------------------------------------------*/
168int eris_pfits_get_naxis2(const cpl_propertylist * plist)
169{
170 return cpl_propertylist_get_int(plist, "NAXIS2");
171}
172
173cpl_propertylist*
174eris_ifu_plist_extract_wcs2D(const cpl_propertylist* applist)
175{
176 cpl_ensure(applist != NULL, CPL_ERROR_NULL_INPUT, NULL);
177 cpl_propertylist* result = cpl_propertylist_new();
178 double double_value;
179 const char* string_value;
180 if(cpl_propertylist_has(applist,"CRPIX1")) {
181 if (cpl_propertylist_get_type(applist, "CRPIX1") == CPL_TYPE_DOUBLE) {
182 double_value = cpl_propertylist_get_double(applist,"CRPIX1");
183 cpl_propertylist_append_double(result,"CRPIX1", double_value);
184 } else {
185 cpl_error_set(cpl_func,CPL_ERROR_TYPE_MISMATCH);
186 return result;
187 }
188 }
189 if(cpl_propertylist_has(applist,"CRPIX2")) {
190 if (cpl_propertylist_get_type(applist, "CRPIX2") == CPL_TYPE_DOUBLE) {
191 double_value = cpl_propertylist_get_double(applist,"CRPIX2");
192 cpl_propertylist_append_double(result,"CRPIX2", double_value);
193 } else {
194 cpl_error_set(cpl_func,CPL_ERROR_TYPE_MISMATCH);
195 return result;
196 }
197 }
198
199 if(cpl_propertylist_has(applist,"CRVAL1")) {
200 if (cpl_propertylist_get_type(applist, "CRVAL1") == CPL_TYPE_DOUBLE) {
201 double_value = cpl_propertylist_get_double(applist,"CRVAL1");
202 cpl_propertylist_append_double(result,"CRVAL1", double_value);
203 } else {
204 cpl_error_set(cpl_func,CPL_ERROR_TYPE_MISMATCH);
205 return result;
206 }
207 }
208 if(cpl_propertylist_has(applist,"CRVAL2")) {
209 if (cpl_propertylist_get_type(applist, "CRVAL2") == CPL_TYPE_DOUBLE) {
210 double_value = cpl_propertylist_get_double(applist,"CRVAL2");
211 cpl_propertylist_append_double(result,"CRVAL2", double_value);
212 } else {
213 cpl_error_set(cpl_func,CPL_ERROR_TYPE_MISMATCH);
214 return result;
215 }
216 }
217
218 if(cpl_propertylist_has(applist,"CDELT1")) {
219 if (cpl_propertylist_get_type(applist, "CDELT1") == CPL_TYPE_DOUBLE) {
220 double_value = cpl_propertylist_get_double(applist,"CDELT1");
221 cpl_propertylist_append_double(result,"CDELT1", double_value);
222 } else {
223 cpl_error_set(cpl_func,CPL_ERROR_TYPE_MISMATCH);
224 return result;
225 }
226 }
227 if(cpl_propertylist_has(applist,"CDELT2")) {
228 if (cpl_propertylist_get_type(applist, "CDELT2") == CPL_TYPE_DOUBLE) {
229 double_value = cpl_propertylist_get_double(applist,"CDELT2");
230 cpl_propertylist_append_double(result,"CDELT2", double_value);
231 } else {
232 cpl_error_set(cpl_func,CPL_ERROR_TYPE_MISMATCH);
233 return result;
234 }
235 }
236
237 if(cpl_propertylist_has(applist,"CTYPE1")) {
238 if (cpl_propertylist_get_type(applist, "CTYPE1") == CPL_TYPE_STRING) {
239 string_value = cpl_propertylist_get_string(applist,"CTYPE1");
240 cpl_propertylist_append_string(result,"CTYPE1", string_value);
241 } else {
242 cpl_error_set(cpl_func,CPL_ERROR_TYPE_MISMATCH);
243 return result;
244 }
245 }
246 if(cpl_propertylist_has(applist,"CTYPE2")) {
247 if (cpl_propertylist_get_type(applist, "CTYPE2") == CPL_TYPE_STRING) {
248 string_value = cpl_propertylist_get_string(applist,"CTYPE2");
249 cpl_propertylist_append_string(result,"CTYPE2", string_value);
250 } else {
251 cpl_error_set(cpl_func,CPL_ERROR_TYPE_MISMATCH);
252 return result;
253 }
254 }
255
256 if(cpl_propertylist_has(applist,"CUNIT1")) {
257 if (cpl_propertylist_get_type(applist, "CUNIT1") == CPL_TYPE_STRING) {
258 string_value = cpl_propertylist_get_string(applist,"CUNIT1");
259 cpl_propertylist_append_string(result,"CUNIT1", string_value);
260 } else {
261 cpl_error_set(cpl_func,CPL_ERROR_TYPE_MISMATCH);
262 return result;
263 }
264 }
265 if(cpl_propertylist_has(applist,"CUNIT2")) {
266 if (cpl_propertylist_get_type(applist, "CUNIT2") == CPL_TYPE_STRING) {
267 string_value = cpl_propertylist_get_string(applist,"CUNIT2");
268 cpl_propertylist_append_string(result,"CUNIT2", string_value);
269 } else {
270 cpl_error_set(cpl_func,CPL_ERROR_TYPE_MISMATCH);
271 return result;
272 }
273 }
274
275
276 if(cpl_propertylist_has(applist,"CD1_1")) {
277 if (cpl_propertylist_get_type(applist, "CD1_1") == CPL_TYPE_DOUBLE) {
278 double_value = cpl_propertylist_get_double(applist,"CD1_1");
279 cpl_propertylist_append_double(result,"CD1_1", double_value);
280 } else {
281 cpl_error_set(cpl_func,CPL_ERROR_TYPE_MISMATCH);
282 return result;
283 }
284 }
285 if(cpl_propertylist_has(applist,"CD1_2")) {
286 if (cpl_propertylist_get_type(applist, "CD1_2") == CPL_TYPE_DOUBLE) {
287 double_value = cpl_propertylist_get_double(applist,"CD1_2");
288 cpl_propertylist_append_double(result,"CD1_2", double_value);
289 } else {
290 cpl_error_set(cpl_func,CPL_ERROR_TYPE_MISMATCH);
291 return result;
292 }
293 }
294
295 if(cpl_propertylist_has(applist,"CD2_1")) {
296 if (cpl_propertylist_get_type(applist, "CD2_1") == CPL_TYPE_DOUBLE) {
297 double_value = cpl_propertylist_get_double(applist,"CD2_1");
298 cpl_propertylist_append_double(result,"CD2_1", double_value);
299 } else {
300 cpl_error_set(cpl_func,CPL_ERROR_TYPE_MISMATCH);
301 return result;
302 }
303 }
304
305 if(cpl_propertylist_has(applist,"CD2_2")) {
306 if (cpl_propertylist_get_type(applist, "CD2_2") == CPL_TYPE_DOUBLE) {
307 double_value = cpl_propertylist_get_double(applist,"CD2_2");
308 cpl_propertylist_append_double(result,"CD2_2", double_value);
309 } else {
310 cpl_error_set(cpl_func,CPL_ERROR_TYPE_MISMATCH);
311 return result;
312 }
313 }
314
315
316 return result;
317}
318
319cpl_propertylist*
320eris_ifu_plist_extract_wcs3D(const cpl_propertylist* applist)
321{
322
323 cpl_ensure(applist != NULL, CPL_ERROR_NULL_INPUT, NULL);
324 cpl_propertylist* result = cpl_propertylist_new();
325 double double_value;
326 const char* string_value;
327
328 if(cpl_propertylist_has(applist,"CRPIX3")) {
329 if (cpl_propertylist_get_type(applist, "CRPIX3") == CPL_TYPE_DOUBLE) {
330 double_value = cpl_propertylist_get_double(applist,"CRPIX3");
331 cpl_propertylist_append_double(result,"CRPIX3", double_value);
332 } else {
333 cpl_error_set(cpl_func,CPL_ERROR_TYPE_MISMATCH);
334 return result;
335 }
336 }
337
338 if(cpl_propertylist_has(applist,"CRVAL3")) {
339 if (cpl_propertylist_get_type(applist, "CRVAL3") == CPL_TYPE_DOUBLE) {
340 double_value = cpl_propertylist_get_double(applist,"CRVAL3");
341 cpl_propertylist_append_double(result,"CRVAL3", double_value);
342 } else {
343 cpl_error_set(cpl_func,CPL_ERROR_TYPE_MISMATCH);
344 return result;
345 }
346 }
347
348 if(cpl_propertylist_has(applist,"CDELT3")) {
349 if (cpl_propertylist_get_type(applist, "CDELT3") == CPL_TYPE_DOUBLE) {
350 double_value = cpl_propertylist_get_double(applist,"CDELT3");
351 cpl_propertylist_append_double(result,"CDELT3", double_value);
352 } else {
353 cpl_error_set(cpl_func,CPL_ERROR_TYPE_MISMATCH);
354 return result;
355 }
356 }
357
358 if(cpl_propertylist_has(applist,"CTYPE3")) {
359 if (cpl_propertylist_get_type(applist, "CTYPE3") == CPL_TYPE_STRING) {
360 string_value = cpl_propertylist_get_string(applist,"CTYPE3");
361 cpl_propertylist_append_string(result,"CTYPE3", string_value);
362 } else {
363 cpl_error_set(cpl_func,CPL_ERROR_TYPE_MISMATCH);
364 return result;
365 }
366 }
367
368 if(cpl_propertylist_has(applist,"CUNIT3")) {
369 if (cpl_propertylist_get_type(applist, "CUNIT3") == CPL_TYPE_STRING) {
370 string_value = cpl_propertylist_get_string(applist,"CUNIT3");
371 cpl_propertylist_append_string(result,"CUNIT3", string_value);
372 } else {
373 cpl_error_set(cpl_func,CPL_ERROR_TYPE_MISMATCH);
374 return result;
375 }
376 }
377
378
379 if(cpl_propertylist_has(applist,"CD1_3")) {
380 if (cpl_propertylist_get_type(applist, "CD1_3") == CPL_TYPE_DOUBLE) {
381 double_value = cpl_propertylist_get_double(applist,"CD1_3");
382 cpl_propertylist_append_double(result,"CD1_3", double_value);
383 } else {
384 cpl_error_set(cpl_func,CPL_ERROR_TYPE_MISMATCH);
385 return result;
386 }
387 }
388
389 if(cpl_propertylist_has(applist,"CD3_1")) {
390 if (cpl_propertylist_get_type(applist, "CD3_1") == CPL_TYPE_DOUBLE) {
391 double_value = cpl_propertylist_get_double(applist,"CD3_1");
392 cpl_propertylist_append_double(result,"CD3_1", double_value);
393 } else {
394 cpl_error_set(cpl_func,CPL_ERROR_TYPE_MISMATCH);
395 return result;
396 }
397 }
398
399 if(cpl_propertylist_has(applist,"CD2_3")) {
400 if (cpl_propertylist_get_type(applist, "CD2_3") == CPL_TYPE_DOUBLE) {
401 double_value = cpl_propertylist_get_double(applist,"CD2_3");
402 cpl_propertylist_append_double(result,"CD2_3", double_value);
403 } else {
404 cpl_error_set(cpl_func,CPL_ERROR_TYPE_MISMATCH);
405 return result;
406 }
407 }
408 if(cpl_propertylist_has(applist,"CD3_2")) {
409 if (cpl_propertylist_get_type(applist, "CD3_2") == CPL_TYPE_DOUBLE) {
410 double_value = cpl_propertylist_get_double(applist,"CD3_2");
411 cpl_propertylist_append_double(result,"CD3_2", double_value);
412 } else {
413 cpl_error_set(cpl_func,CPL_ERROR_TYPE_MISMATCH);
414 return result;
415 }
416 }
417 if(cpl_propertylist_has(applist,"CD3_3")) {
418 if (cpl_propertylist_get_type(applist, "CD3_3") == CPL_TYPE_DOUBLE) {
419 double_value = cpl_propertylist_get_double(applist,"CD3_3");
420 cpl_propertylist_append_double(result,"CD3_3", double_value);
421 } else {
422 cpl_error_set(cpl_func,CPL_ERROR_TYPE_MISMATCH);
423 return result;
424 }
425 }
426
427
428
429 return result;
430}
431cpl_propertylist*
432eris_ifu_plist_extract_wcs(cpl_propertylist* applist)
433{
434
435 cpl_propertylist* result = cpl_propertylist_new();
436
437 cpl_propertylist* tmp = eris_ifu_plist_extract_wcs2D(applist);
438 cpl_propertylist_append(result, tmp);
439 cpl_propertylist_delete(tmp);
440
441 tmp = eris_ifu_plist_extract_wcs3D(applist);
442 cpl_propertylist_append(result, tmp);
443 cpl_propertylist_delete(tmp);
444
445 return result;
446}
447
448cpl_error_code
449eris_pfits_erase_wcs2D(cpl_propertylist* applist)
450{
451
452 if(cpl_propertylist_has(applist,"CRPIX1")) {
453 cpl_propertylist_erase(applist,"CRPIX1");
454 }
455 if(cpl_propertylist_has(applist,"CRPIX2")) {
456 cpl_propertylist_erase(applist,"CRPIX2");
457 }
458
459 if(cpl_propertylist_has(applist,"CRVAL1")) {
460 cpl_propertylist_erase(applist,"CRVAL1");
461 }
462 if(cpl_propertylist_has(applist,"CRVAL2")) {
463 cpl_propertylist_erase(applist,"CRVAL2");
464 }
465
466 if(cpl_propertylist_has(applist,"CDELT1")) {
467 cpl_propertylist_erase(applist,"CDELT1");
468 }
469 if(cpl_propertylist_has(applist,"CDELT2")) {
470 cpl_propertylist_erase(applist,"CDELT2");
471 }
472
473 if(cpl_propertylist_has(applist,"CTYPE1")) {
474 cpl_propertylist_erase(applist,"CTYPE1");
475 }
476 if(cpl_propertylist_has(applist,"CTYPE2")) {
477 cpl_propertylist_erase(applist,"CTYPE2");
478 }
479
480 if(cpl_propertylist_has(applist,"CUNIT1")) {
481 cpl_propertylist_erase(applist,"CUNIT1");
482 }
483 if(cpl_propertylist_has(applist,"CUNIT2")) {
484 cpl_propertylist_erase(applist,"CUNIT2");
485 }
486
487
488 if(cpl_propertylist_has(applist,"CD1_1")) {
489 cpl_propertylist_erase(applist,"CD1_1");
490 }
491 if(cpl_propertylist_has(applist,"CD1_2")) {
492 cpl_propertylist_erase(applist,"CD1_2");
493 }
494
495 if(cpl_propertylist_has(applist,"CD2_1")) {
496 cpl_propertylist_erase(applist,"CD2_1");
497 }
498
499 if(cpl_propertylist_has(applist,"CD2_2")) {
500 cpl_propertylist_erase(applist,"CD2_2");
501 }
502
503 return cpl_error_get_code();
504}
505
506cpl_error_code
507eris_ifu_plist_erase_wcs3D(cpl_propertylist* applist)
508{
509
510
511 if(cpl_propertylist_has(applist,"CRPIX3")) {
512 cpl_propertylist_erase(applist,"CRPIX3");
513 }
514 if(cpl_propertylist_has(applist,"CRVAL3")) {
515 cpl_propertylist_erase(applist,"CRVAL3");
516 }
517 if(cpl_propertylist_has(applist,"CDELT3")) {
518 cpl_propertylist_erase(applist,"CDELT3");
519 }
520
521 if(cpl_propertylist_has(applist,"CTYPE3")) {
522 cpl_propertylist_erase(applist,"CTYPE3");
523 }
524 if(cpl_propertylist_has(applist,"CUNIT3")) {
525 cpl_propertylist_erase(applist,"CUNIT3");
526 }
527
528
529 if(cpl_propertylist_has(applist,"CD1_3")) {
530 cpl_propertylist_erase(applist,"CD1_3");
531 }
532 if(cpl_propertylist_has(applist,"CD3_1")) {
533 cpl_propertylist_erase(applist,"CD3_1");
534 }
535 if(cpl_propertylist_has(applist,"CD2_3")) {
536 cpl_propertylist_erase(applist,"CD2_3");
537 }
538 if(cpl_propertylist_has(applist,"CD3_2")) {
539 cpl_propertylist_erase(applist,"CD3_2");
540 }
541 if(cpl_propertylist_has(applist,"CD3_3")) {
542 cpl_propertylist_erase(applist,"CD3_3");
543 }
544
545
546
547 return cpl_error_get_code();
548}
549
550cpl_error_code
551eris_ifu_plist_erase_expmap_extra_keys(cpl_propertylist* applist)
552{
553
554
555 if(cpl_propertylist_has(applist,"HDUCLASS")) {
556 cpl_propertylist_erase(applist,"HDUCLASS");
557 }
558 if(cpl_propertylist_has(applist,"HDUDOC")) {
559 cpl_propertylist_erase(applist,"HDUDOC");
560 }
561 if(cpl_propertylist_has(applist,"HDUVERS")) {
562 cpl_propertylist_erase(applist,"HDUVERS");
563 }
564
565 if(cpl_propertylist_has(applist, "HDUCLAS1")) {
566 cpl_propertylist_erase(applist,"HDUCLAS1");
567 }
568 if(cpl_propertylist_has(applist,"HDUCLAS2")) {
569 cpl_propertylist_erase(applist,"HDUCLAS2");
570 }
571
572
573 if(cpl_propertylist_has(applist,"ERRDATA")) {
574 cpl_propertylist_erase(applist,"ERRDATA");
575 }
576 if(cpl_propertylist_has(applist,"QUALDATA")) {
577 cpl_propertylist_erase(applist,"QUALDATA");
578 }
579
580
581 return cpl_error_get_code();
582}
583
584
585cpl_error_code
586eris_ifu_plist_erase_wcs(cpl_propertylist* applist)
587{
588
589 eris_pfits_erase_wcs2D(applist);
590 eris_ifu_plist_erase_wcs3D(applist);
591
592 return cpl_error_get_code();
593}
594
595
596
597/*----------------------------------------------------------------------------*/
606/*----------------------------------------------------------------------------*/
607// TODO: why following function reset error code?
608const char *
609eris_pfits_get_raw_filename(const cpl_propertylist *aHeaders, unsigned int idx)
610{
611 cpl_ensure(aHeaders, CPL_ERROR_NULL_INPUT, NULL);
612 char *key = cpl_sprintf("ESO PRO REC1 RAW%-u NAME", idx);
613 cpl_errorstate prestate = cpl_errorstate_get();
614 const char *value = cpl_propertylist_get_string(aHeaders, key);
615 cpl_errorstate_set(prestate);
616 cpl_free(key);
617 return value;
618}
619/*----------------------------------------------------------------------------*/
627/*----------------------------------------------------------------------------*/
628double
629eris_pfits_get_ia_fwhmlin(const cpl_propertylist *aHeaders)
630{
631 cpl_errorstate prestate = cpl_errorstate_get();
632 const double value = cpl_propertylist_get_double(aHeaders, "ESO TEL IA FWHMLIN");
633 cpl_ensure(cpl_errorstate_is_equal(prestate), cpl_error_get_code(), 0.0);
634 return value;
635}
636
637
638/*----------------------------------------------------------------------------*/
646/*----------------------------------------------------------------------------*/
647//TODO strange error code setting in case of value < 0
648double
649eris_pfits_get_fwhm_start(const cpl_propertylist *aHeaders)
650{
651 cpl_errorstate prestate = cpl_errorstate_get();
652 const double value = cpl_propertylist_get_double(aHeaders, "ESO TEL AMBI FWHM START");
653 cpl_ensure(cpl_errorstate_is_equal(prestate) && value > 0.,
654 cpl_error_get_code(), 0.0);
655 return value;
656}
657
658/*----------------------------------------------------------------------------*/
666/*----------------------------------------------------------------------------*/
667//TODO strange error code setting in case of value < 0
668double
669eris_pfits_get_fwhm_end(const cpl_propertylist *aHeaders)
670{
671 cpl_errorstate prestate = cpl_errorstate_get();
672 const double value = cpl_propertylist_get_double(aHeaders, "ESO TEL AMBI FWHM END");
673 cpl_ensure(cpl_errorstate_is_equal(prestate) && value > 0.,
674 cpl_error_get_code(), 0.0);
675 return value;
676}
677
678
679/*---------------------------------------------------------------------------*/
685/*---------------------------------------------------------------------------*/
686double eris_pfits_get_cd33(const cpl_propertylist * plist)
687{
688 return cpl_propertylist_get_double(plist,"CD3_3");
689}
690
691
692/*---------------------------------------------------------------------------*/
698/*---------------------------------------------------------------------------*/
699double eris_pfits_get_crval3(const cpl_propertylist * plist)
700{
701 return cpl_propertylist_get_double(plist,"CRVAL3");
702}
703/*---------------------------------------------------------------------------*/
709/*---------------------------------------------------------------------------*/
710double eris_pfits_get_cdelt3(const cpl_propertylist * plist)
711{
712 return cpl_propertylist_get_double(plist,"CDELT3");
713}
714
715
716/*---------------------------------------------------------------------------*/
722/*---------------------------------------------------------------------------*/
723double eris_pfits_get_crpix3(const cpl_propertylist * plist)
724{
725 return cpl_propertylist_get_double(plist,"CRPIX3");
726}
727
728
729/*---------------------------------------------------------------------------*/
735/*---------------------------------------------------------------------------*/
736double eris_pfits_get_crpix2(const cpl_propertylist * plist)
737{
738 return cpl_propertylist_get_double(plist,"CRPIX2");
739}
740
741/*---------------------------------------------------------------------------*/
747/*---------------------------------------------------------------------------*/
748double eris_pfits_get_crpix1(const cpl_propertylist * plist)
749{
750 return cpl_propertylist_get_double(plist,"CRPIX1");
751}
752
753
754
755/*----------------------------------------------------------------------------*/
763/*----------------------------------------------------------------------------*/
764double
765eris_pfits_get_airmass_start(const cpl_propertylist *aHeaders)
766{
767 cpl_errorstate prestate = cpl_errorstate_get();
768 const double value = cpl_propertylist_get_double(aHeaders, "ESO TEL AIRM START");
769 cpl_ensure(cpl_errorstate_is_equal(prestate) && value > 0., cpl_error_get_code(), 0.0);
770 return value;
771}
772
773/*----------------------------------------------------------------------------*/
781/*----------------------------------------------------------------------------*/
782double
783eris_pfits_get_airmass_end(const cpl_propertylist *aHeaders)
784{
785 cpl_errorstate prestate = cpl_errorstate_get();
786 const double value = cpl_propertylist_get_double(aHeaders, "ESO TEL AIRM END");
787 cpl_ensure(cpl_errorstate_is_equal(prestate) && value > 0., cpl_error_get_code(), 0.0);
788 return value;
789}
790
791
792double
793eris_pfits_get_airmass(const cpl_propertylist *aHeaders)
794{
795
796 return 0.5 * (eris_pfits_get_airmass_start(aHeaders) +
798}
799
800
801/*----------------------------------------------------------------------------*/
809/*----------------------------------------------------------------------------*/
810double
811eris_pfits_get_mjdobs(const cpl_propertylist *aHeaders)
812{
813 cpl_errorstate prestate = cpl_errorstate_get();
814 const double value = cpl_propertylist_get_double(aHeaders, "MJD-OBS");
815 cpl_ensure(cpl_errorstate_is_equal(prestate), cpl_error_get_code(), 0.0);
816 return value;
817}
818
819/*----------------------------------------------------------------------------*/
827/*----------------------------------------------------------------------------*/
828const char *
829eris_pfits_get_progid(const cpl_propertylist *aHeaders)
830{
831 cpl_errorstate prestate = cpl_errorstate_get();
832 const char *value = cpl_propertylist_get_string(aHeaders, "ESO OBS PROG ID");
833 cpl_ensure(cpl_errorstate_is_equal(prestate), cpl_error_get_code(), NULL);
834 return value;
835}
836
837
838/*----------------------------------------------------------------------------*/
846/*----------------------------------------------------------------------------*/
847long
848eris_pfits_get_obsid(const cpl_propertylist *aHeaders)
849{
850 cpl_errorstate prestate = cpl_errorstate_get();
851 const long value = cpl_propertylist_get_long(aHeaders, "ESO OBS ID");
852 cpl_ensure(cpl_errorstate_is_equal(prestate), cpl_error_get_code(), -1);
853 return value;
854}
855
856
857/*----------------------------------------------------------------------------*/
865/*----------------------------------------------------------------------------*/
866const char*
867eris_pfits_get_pipefile(const cpl_propertylist *aHeaders)
868{
869 cpl_errorstate prestate = cpl_errorstate_get();
870 const char* value = NULL;
871 if(cpl_propertylist_has(aHeaders, "PIPEFILE")) {
872 value = cpl_propertylist_get_string(aHeaders, "PIPEFILE");
873 }
874 cpl_ensure(cpl_errorstate_is_equal(prestate), cpl_error_get_code(), value);
875 return value;
876}
877/*----------------------------------------------------------------------------*/
885/*----------------------------------------------------------------------------*/
886const char*
887eris_pfits_get_datamd5(const cpl_propertylist *aHeaders)
888{
889 cpl_errorstate prestate = cpl_errorstate_get();
890 const char* value = NULL;
891 if(cpl_propertylist_has(aHeaders, "DATAMD5")) {
892 value = cpl_propertylist_get_string(aHeaders, "DATAMD5");
893 }
894 cpl_ensure(cpl_errorstate_is_equal(prestate), cpl_error_get_code(), value);
895 return value;
896}
897
898
899cpl_error_code
900eris_pfits_clean_header(cpl_propertylist *header, const cpl_boolean clean_extra)
901{
902 cpl_ensure_code(header != NULL, CPL_ERROR_NULL_INPUT);
903 cpl_errorstate prestate = cpl_errorstate_get();
904
905 cpl_propertylist_erase(header,"TELESCOP");
906 cpl_propertylist_erase(header,"INSTRUME");
907 cpl_propertylist_erase(header,"ARCFILE");
908 cpl_propertylist_erase(header,"DATAMD5");
909 cpl_propertylist_erase(header,"PIPEFILE");
910 cpl_propertylist_erase(header,"OBJECT");
911 /* TODO: cannot be removed else fluxcal has problems
912 We probably need to put proper RA,DEC MJD-OBS in
913 primary header of each data cube
914 */
915
916 cpl_propertylist_erase(header,"EXPTIME");
917 cpl_propertylist_erase(header,"EQUINOX");
918
919 cpl_propertylist_erase(header,"DATE-OBS");
920 cpl_propertylist_erase(header,"UTC");
921 cpl_propertylist_erase(header,"LST");
922 cpl_propertylist_erase(header,"PI-COI");
923 cpl_propertylist_erase(header,"OBSERVER");
924 cpl_propertylist_erase(header,"RADESYS");
925 if(cpl_propertylist_has(header,"PRODCATG")) {
926 cpl_propertylist_erase(header,"PRODCATG");
927 }
928 if(cpl_propertylist_has(header,"COMMENT")) {
929 cpl_propertylist_erase(header,"COMMENT");
930 }
931 if(clean_extra) {
932 cpl_propertylist_erase_regexp(header, "ESO ADA *", 0);
933 cpl_propertylist_erase_regexp(header, "ESO AOS *", 0);
934 cpl_propertylist_erase_regexp(header, "ESO INS* *", 0);
935 cpl_propertylist_erase_regexp(header, "ESO DET *", 0);
936 cpl_propertylist_erase_regexp(header, "ESO DPR *", 0);
937 cpl_propertylist_erase_regexp(header, "ESO LGS* *", 0);
938 cpl_propertylist_erase_regexp(header, "ESO OCS *", 0);
939 cpl_propertylist_erase_regexp(header, "ESO OBS *", 0);
940 cpl_propertylist_erase_regexp(header, "ESO PRO *", 0);
941 cpl_propertylist_erase_regexp(header, "ESO SEQ *", 0);
942 cpl_propertylist_erase_regexp(header, "ESO TEL *", 0);
943 cpl_propertylist_erase_regexp(header, "ESO TPL *", 0);
944 }
945 cpl_ensure(cpl_errorstate_is_equal(prestate), cpl_error_get_code(), -1);
946 return cpl_error_get_code();
947}
948cpl_error_code
949eris_pfits_clean_header_ra_dec_mjd_obs(cpl_propertylist *header)
950{
951 cpl_propertylist_erase(header,"RA");
952 cpl_propertylist_erase(header,"DEC");
953 cpl_propertylist_erase(header,"MJD-OBS");
954 return cpl_error_get_code();
955}
956cpl_error_code
957eris_pfits_clean_comment(cpl_propertylist *header)
958{
959 cpl_propertylist_erase(header,"COMMENT");
960
961 return cpl_error_get_code();
962}
963
double eris_pfits_get_mjdobs(const cpl_propertylist *aHeaders)
find out the Julian Date of the observation
Definition: eris_pfits.c:811
double eris_pfits_get_exptime(const char *filename)
find out the character string associated to the EXPTIME keyword
Definition: eris_pfits.c:137
double eris_pfits_get_cdelt3(const cpl_propertylist *plist)
find out the character string associated to the CDELT3 keyword
Definition: eris_pfits.c:710
double eris_pfits_get_crpix2(const cpl_propertylist *plist)
find out the character string associated to the CRPIX2 keyword
Definition: eris_pfits.c:736
int eris_pfits_get_naxis2(const cpl_propertylist *plist)
find out the character string associated to the NAXIS2 keyword
Definition: eris_pfits.c:168
const char * eris_pfits_get_raw_filename(const cpl_propertylist *aHeaders, unsigned int idx)
find out the i-th raw file name.
Definition: eris_pfits.c:609
const char * eris_pfits_get_arcfile(const cpl_propertylist *plist)
find out the arcfile
Definition: eris_pfits.c:82
double eris_pfits_get_fwhm_start(const cpl_propertylist *aHeaders)
find out the ambient seeing at start of exposure (in arcsec)
Definition: eris_pfits.c:649
const char * eris_pfits_get_datamd5(const cpl_propertylist *aHeaders)
find out the PIPEFILE id
Definition: eris_pfits.c:887
int eris_pfits_get_naxis1(const cpl_propertylist *plist)
find out the character string associated to the NAXIS1 keyword
Definition: eris_pfits.c:155
double eris_pfits_get_cd33(const cpl_propertylist *plist)
find out the character string associated to the CDELT3 keyword
Definition: eris_pfits.c:686
double eris_pfits_get_airmass_start(const cpl_propertylist *aHeaders)
find out the airmass at start of exposure
Definition: eris_pfits.c:765
double eris_pfits_get_fwhm_end(const cpl_propertylist *aHeaders)
find out the ambient seeing at end of exposure (in arcsec)
Definition: eris_pfits.c:669
double eris_pfits_get_ia_fwhmlin(const cpl_propertylist *aHeaders)
find out the image analysis FWHM from a linear fit (in arcsec)
Definition: eris_pfits.c:629
const char * eris_pfits_get_pipefile(const cpl_propertylist *aHeaders)
find out the PIPEFILE id
Definition: eris_pfits.c:867
double eris_pfits_get_crpix1(const cpl_propertylist *plist)
find out the character string associated to the CRPIX1 keyword
Definition: eris_pfits.c:748
int eris_pfits_get_ndit(const cpl_propertylist *plist)
find out the DIT value
Definition: eris_pfits.c:117
double eris_pfits_get_crval3(const cpl_propertylist *plist)
find out the character string associated to the CVRVAL3 keyword
Definition: eris_pfits.c:699
double eris_pfits_get_airmass_end(const cpl_propertylist *aHeaders)
find out the airmass at end of exposure
Definition: eris_pfits.c:783
const char * eris_pfits_get_ancestor(const cpl_propertylist *aHeaders)
find out the ancestor of a file.
Definition: eris_pfits.c:65
const char * eris_pfits_get_progid(const cpl_propertylist *aHeaders)
find out the ESO program identification
Definition: eris_pfits.c:829
long eris_pfits_get_obsid(const cpl_propertylist *aHeaders)
find out the observation block id
Definition: eris_pfits.c:848
double eris_pfits_get_dit(const cpl_propertylist *plist)
find out the DIT value
Definition: eris_pfits.c:98
double eris_pfits_get_crpix3(const cpl_propertylist *plist)
find out the character string associated to the CRPIX3 keyword
Definition: eris_pfits.c:723