00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 #ifdef HAVE_CONFIG_H
00031 #include <config.h>
00032 #endif
00033
00034 #include <cpl.h>
00035 #include <string.h>
00036
00037 #include "vircam_utils.h"
00038 #include "vircam_pfits.h"
00039
00040 static int vircam_pfits_get_float(const cpl_propertylist *plist,
00041 const char *key, float *fval);
00042 static int vircam_pfits_get_double(const cpl_propertylist *plist,
00043 const char *key, double *fval);
00044
00058
00066
00067
00068 extern int vircam_pfits_get_crval1(const cpl_propertylist *plist,
00069 double *crval1) {
00070
00071 return(vircam_pfits_get_double(plist,"CRVAL1",crval1));
00072
00073 }
00074
00075
00083
00084
00085 extern int vircam_pfits_get_crpix1(const cpl_propertylist *plist,
00086 double *crpix1) {
00087
00088 return(vircam_pfits_get_double(plist,"CRPIX1",crpix1));
00089
00090 }
00091
00092
00100
00101
00102 extern int vircam_pfits_get_crval2(const cpl_propertylist *plist,
00103 double *crval2) {
00104
00105 return(vircam_pfits_get_double(plist,"CRVAL2",crval2));
00106
00107 }
00108
00109
00117
00118
00119 extern int vircam_pfits_get_crpix2(const cpl_propertylist *plist,
00120 double *crpix2) {
00121
00122 return(vircam_pfits_get_double(plist,"CRPIX2",crpix2));
00123 }
00124
00125
00133
00134
00135 extern int vircam_pfits_get_cd11(const cpl_propertylist *plist, double *cd11) {
00136
00137 return(vircam_pfits_get_double(plist,"CD1_1",cd11));
00138 }
00139
00140
00148
00149
00150 extern int vircam_pfits_get_cd12(const cpl_propertylist *plist, double *cd12) {
00151
00152 return(vircam_pfits_get_double(plist,"CD1_2",cd12));
00153
00154 }
00155
00156
00164
00165
00166 extern int vircam_pfits_get_cd21(const cpl_propertylist *plist, double *cd21) {
00167
00168 return(vircam_pfits_get_double(plist,"CD2_1",cd21));
00169 }
00170
00171
00179
00180
00181 extern int vircam_pfits_get_cd22(const cpl_propertylist *plist, double *cd22) {
00182
00183 return(vircam_pfits_get_double(plist,"CD2_2",cd22));
00184
00185 }
00186
00187
00195
00196
00197 extern int vircam_pfits_get_pv21(const cpl_propertylist *plist, double *pv21) {
00198
00199 return(vircam_pfits_get_double(plist,"PV2_1",pv21));
00200
00201 }
00202
00203
00211
00212
00213 extern int vircam_pfits_get_pv23(const cpl_propertylist *plist, double *pv23) {
00214
00215 return(vircam_pfits_get_double(plist,"PV2_3",pv23));
00216
00217 }
00218
00219
00227
00228
00229 extern int vircam_pfits_get_pv25(const cpl_propertylist *plist, double *pv25) {
00230
00231 return(vircam_pfits_get_double(plist,"PV2_5",pv25));
00232
00233 }
00234
00235
00243
00244
00245 extern int vircam_pfits_get_exptime(const cpl_propertylist *plist,
00246 float *exptime) {
00247
00248 return(vircam_pfits_get_float(plist,"EXPTIME",exptime));
00249
00250 }
00251
00252
00260
00261
00262 extern int vircam_pfits_get_mindit(const cpl_propertylist *plist,
00263 float *mindit) {
00264
00265 return(vircam_pfits_get_float(plist,"ESO DET MINDIT",mindit));
00266
00267 }
00268
00269
00277
00278
00279 extern int vircam_pfits_get_ditdelay(const cpl_propertylist *plist,
00280 float *ditdelay) {
00281
00282 return(vircam_pfits_get_float(plist,"ESO DET DITDELAY",ditdelay));
00283
00284 }
00285
00286
00294
00295
00296 extern int vircam_pfits_get_naxis1(const cpl_propertylist *plist,
00297 long *naxis1) {
00298 int val;
00299
00300 val = cpl_propertylist_get_int(plist,"NAXIS1");
00301 if (cpl_error_get_code() == CPL_ERROR_NONE) {
00302 *naxis1 = (long)val;
00303 return(VIR_OK);
00304 } else {
00305 cpl_error_reset();
00306 *naxis1 = 0;
00307 return(VIR_FATAL);
00308 }
00309 }
00310
00311
00319
00320
00321 extern int vircam_pfits_get_naxis2(const cpl_propertylist *plist,
00322 long *naxis2) {
00323 int val;
00324
00325 val = cpl_propertylist_get_int(plist,"NAXIS2");
00326 if (cpl_error_get_code() == CPL_ERROR_NONE) {
00327 *naxis2 = (long)val;
00328 return(VIR_OK);
00329 } else {
00330 cpl_error_reset();
00331 *naxis2 = 0;
00332 return(VIR_FATAL);
00333 }
00334 }
00335
00336
00344
00345
00346 extern int vircam_pfits_get_chipno(const cpl_propertylist *plist,
00347 int *chipno) {
00348 int val;
00349
00350 val = cpl_propertylist_get_int(plist,"ESO DET CHIP NO");
00351 if (cpl_error_get_code() == CPL_ERROR_NONE) {
00352 *chipno = val;
00353 return(VIR_OK);
00354 } else {
00355 cpl_error_reset();
00356 *chipno = 0;
00357 return(VIR_FATAL);
00358 }
00359 }
00360
00361
00369
00370
00371 extern int vircam_pfits_get_jxoff(const cpl_propertylist *plist,
00372 float *xoff) {
00373
00374 return(vircam_pfits_get_float(plist,"ESO DRS XOFFDITHER",xoff));
00375
00376 }
00377
00378
00386
00387
00388 extern int vircam_pfits_get_jyoff(const cpl_propertylist *plist,
00389 float *yoff) {
00390
00391 return(vircam_pfits_get_float(plist,"ESO DRS YOFFDITHER",yoff));
00392
00393 }
00394
00395
00403
00404
00405 extern int vircam_pfits_get_airmass(const cpl_propertylist *plist,
00406 float *airmass) {
00407
00408 return(vircam_pfits_get_float(plist,"ESO TEL AIRM START",airmass));
00409
00410 }
00411
00412
00420
00421
00422 extern int vircam_pfits_get_nusteps(const cpl_propertylist *plist,
00423 int *nusteps) {
00424 int val;
00425
00426 val = cpl_propertylist_get_int(plist,"NUSTEP");
00427 if (cpl_error_get_code() == CPL_ERROR_NONE) {
00428 *nusteps = val;
00429 return(VIR_OK);
00430 } else {
00431 cpl_error_reset();
00432 *nusteps = 0;
00433 return(VIR_FATAL);
00434 }
00435
00436 }
00437
00438
00447
00448
00449 extern int vircam_pfits_get_ustepnum(const cpl_propertylist *plist,
00450 int *ustepnum) {
00451 int val;
00452
00453 val = cpl_propertylist_get_int(plist,"USTEPNUM");
00454 if (cpl_error_get_code() == CPL_ERROR_NONE) {
00455 *ustepnum = val;
00456 return(VIR_OK);
00457 } else {
00458 cpl_error_reset();
00459 *ustepnum = 0;
00460 return(VIR_FATAL);
00461 }
00462
00463 }
00464
00465
00474
00475
00476 extern int vircam_pfits_get_njsteps(const cpl_propertylist *plist,
00477 int *njsteps) {
00478 int val;
00479
00480 val = cpl_propertylist_get_int(plist,"NJITTER");
00481 if (cpl_error_get_code() == CPL_ERROR_NONE) {
00482 *njsteps = val;
00483 return(VIR_OK);
00484 } else {
00485 cpl_error_reset();
00486 *njsteps = 0;
00487 return(VIR_FATAL);
00488 }
00489
00490 }
00491
00492
00501
00502
00503 extern int vircam_pfits_get_jitternum(const cpl_propertylist *plist,
00504 int *jitternum) {
00505 int val;
00506
00507 val = cpl_propertylist_get_int(plist,"JITTRNUM");
00508 if (cpl_error_get_code() == CPL_ERROR_NONE) {
00509 *jitternum = val;
00510 return(VIR_OK);
00511 } else {
00512 cpl_error_reset();
00513 *jitternum = 0;
00514 return(VIR_FATAL);
00515 }
00516
00517 }
00518
00519
00528
00529
00530 extern int vircam_pfits_get_jitteri(const cpl_propertylist *plist,
00531 int *jitteri) {
00532 int val;
00533
00534 val = cpl_propertylist_get_int(plist,"JITTER_I");
00535 if (cpl_error_get_code() == CPL_ERROR_NONE) {
00536 *jitteri = val;
00537 return(VIR_OK);
00538 } else {
00539 cpl_error_reset();
00540 *jitteri = 0;
00541 return(VIR_FATAL);
00542 }
00543
00544 }
00545
00546
00554
00555
00556 extern int vircam_pfits_get_ndit(const cpl_propertylist *plist,
00557 int *ndit) {
00558 int val;
00559
00560 val = cpl_propertylist_get_int(plist,"ESO DET NDIT");
00561 if (cpl_error_get_code() == CPL_ERROR_NONE) {
00562 *ndit = val;
00563 return(VIR_OK);
00564 } else {
00565 cpl_error_reset();
00566 *ndit = 1;
00567 return(VIR_FATAL);
00568 }
00569 }
00570
00571
00579
00580
00581 extern int vircam_pfits_get_detlive(const cpl_propertylist *plist,
00582 int *detlive) {
00583 int val;
00584
00585 val = cpl_propertylist_get_bool(plist,"ESO DET CHIP LIVE");
00586 if (cpl_error_get_code() == CPL_ERROR_NONE) {
00587 *detlive = val;
00588 return(VIR_OK);
00589 } else {
00590 cpl_error_reset();
00591 *detlive = 1;
00592 return(VIR_FATAL);
00593 }
00594 }
00595
00596
00604
00605
00606 extern int vircam_pfits_get_filter(const cpl_propertylist *plist, char *filt) {
00607
00608 strcpy(filt,cpl_propertylist_get_string(plist,"ESO INS FILT1 NAME"));
00609 if (cpl_error_get_code() == CPL_ERROR_NONE) {
00610 return(VIR_OK);
00611 } else {
00612 cpl_error_reset();
00613 return(VIR_FATAL);
00614 }
00615 }
00616
00617
00625
00626
00627 extern int vircam_pfits_get_saturation(const cpl_propertylist *plist,
00628 float *saturation) {
00629
00630 return(vircam_pfits_get_float(plist,"ESO DET SATURATION",saturation));
00631
00632 }
00633
00634
00642
00643
00644 extern int vircam_pfits_get_gain(const cpl_propertylist *plist, float *gain) {
00645
00646 return(vircam_pfits_get_float(plist,"GAIN",gain));
00647
00648 }
00649
00650
00658
00659
00660 extern int vircam_pfits_get_mjd(const cpl_propertylist *plist, double *mjd) {
00661
00662 return(vircam_pfits_get_double(plist,"MJD-OBS",mjd));
00663
00664 }
00665
00666
00674
00675
00676 extern int vircam_pfits_get_ra(const cpl_propertylist *plist, double *ra) {
00677
00678 return(vircam_pfits_get_double(plist,"RA",ra));
00679
00680 }
00681
00682
00690
00691
00692 extern int vircam_pfits_get_dec(const cpl_propertylist *plist, double *dec) {
00693
00694 return(vircam_pfits_get_double(plist,"DEC",dec));
00695
00696 }
00697
00698
00707
00708
00709 static int vircam_pfits_get_float(const cpl_propertylist *plist,
00710 const char *key, float *fval) {
00711 cpl_type type;
00712 const char *fctid = "vircam_pfits_get_float";
00713
00714
00715
00716 type = cpl_propertylist_get_type(plist,key);
00717 if (cpl_error_get_code() != CPL_ERROR_NONE) {
00718 *fval = 0.0;
00719 cpl_error_reset();
00720 return(VIR_FATAL);
00721 }
00722
00723
00724
00725 switch (type) {
00726 case CPL_TYPE_FLOAT:
00727 *fval = cpl_propertylist_get_float(plist,key);
00728 break;
00729 case CPL_TYPE_DOUBLE:
00730 *fval = (float)cpl_propertylist_get_double(plist,key);
00731 break;
00732 default:
00733 *fval = 0.0;
00734 cpl_msg_error(fctid,"Keyword %s is not floating point in header",key);
00735 return(VIR_FATAL);
00736 }
00737 return(VIR_OK);
00738 }
00739
00740
00749
00750
00751 static int vircam_pfits_get_double(const cpl_propertylist *plist,
00752 const char *key, double *fval) {
00753 cpl_type type;
00754 const char *fctid = "vircam_pfits_get_float";
00755
00756
00757
00758 type = cpl_propertylist_get_type(plist,key);
00759 if (cpl_error_get_code() != CPL_ERROR_NONE) {
00760 *fval = 0.0;
00761 cpl_error_reset();
00762 return(VIR_FATAL);
00763 }
00764
00765
00766
00767 switch (type) {
00768 case CPL_TYPE_FLOAT:
00769 *fval = (double)cpl_propertylist_get_float(plist,key);
00770 break;
00771 case CPL_TYPE_DOUBLE:
00772 *fval = cpl_propertylist_get_double(plist,key);
00773 break;
00774 default:
00775 *fval = 0.0;
00776 cpl_msg_error(fctid,"Keyword %s is not floating point in header",key);
00777 return(VIR_FATAL);
00778 }
00779 return(VIR_OK);
00780 }
00781
00784
00785
00786
00787
00788
00789
00790
00791
00792
00793
00794
00795
00796
00797
00798
00799
00800
00801
00802
00803
00804
00805
00806
00807
00808
00809
00810
00811
00812
00813
00814
00815
00816
00817
00818
00819
00820
00821
00822
00823
00824
00825
00826
00827
00828
00829
00830
00831
00832
00833
00834
00835
00836
00837
00838
00839
00840
00841
00842
00843
00844
00845
00846
00847
00848
00849
00850
00851
00852
00853
00854
00855
00856
00857
00858
00859
00860
00861
00862
00863
00864
00865
00866
00867
00868
00869
00870
00871
00872
00873
00874
00875
00876
00877
00878
00879
00880
00881
00882
00883
00884
00885
00886
00887
00888
00889