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
00099
00100
00101 extern int vircam_pfits_get_crval2(const cpl_propertylist *plist,
00102 double *crval2) {
00103
00104 return(vircam_pfits_get_double(plist,"CRVAL2",crval2));
00105
00106 }
00107
00108
00115
00116
00117 extern int vircam_pfits_get_crpix2(const cpl_propertylist *plist,
00118 double *crpix2) {
00119
00120 return(vircam_pfits_get_double(plist,"CRPIX2",crpix2));
00121 }
00122
00123
00130
00131
00132 extern int vircam_pfits_get_cd11(const cpl_propertylist *plist, double *cd11) {
00133
00134 return(vircam_pfits_get_double(plist,"CD1_1",cd11));
00135 }
00136
00137
00144
00145
00146 extern int vircam_pfits_get_cd12(const cpl_propertylist *plist, double *cd12) {
00147
00148 return(vircam_pfits_get_double(plist,"CD1_2",cd12));
00149
00150 }
00151
00152
00159
00160
00161 extern int vircam_pfits_get_cd21(const cpl_propertylist *plist, double *cd21) {
00162
00163 return(vircam_pfits_get_double(plist,"CD2_1",cd21));
00164 }
00165
00166
00173
00174
00175 extern int vircam_pfits_get_cd22(const cpl_propertylist *plist, double *cd22) {
00176
00177 return(vircam_pfits_get_double(plist,"CD2_2",cd22));
00178
00179 }
00180
00181
00188
00189
00190 extern int vircam_pfits_get_pv21(const cpl_propertylist *plist, double *pv21) {
00191
00192 return(vircam_pfits_get_double(plist,"PV2_1",pv21));
00193
00194 }
00195
00196
00203
00204
00205 extern int vircam_pfits_get_pv23(const cpl_propertylist *plist, double *pv23) {
00206
00207 return(vircam_pfits_get_double(plist,"PV2_3",pv23));
00208
00209 }
00210
00211
00218
00219
00220 extern int vircam_pfits_get_exptime(const cpl_propertylist *plist,
00221 float *exptime) {
00222
00223 return(vircam_pfits_get_float(plist,"EXPTIME",exptime));
00224
00225 }
00226
00227
00234
00235
00236 extern int vircam_pfits_get_mindit(const cpl_propertylist *plist,
00237 float *mindit) {
00238
00239 return(vircam_pfits_get_float(plist,"ESO DET MINDIT",mindit));
00240
00241 }
00242
00243
00250
00251
00252 extern int vircam_pfits_get_ditdelay(const cpl_propertylist *plist,
00253 float *ditdelay) {
00254
00255 return(vircam_pfits_get_float(plist,"ESO DET DITDELAY",ditdelay));
00256
00257 }
00258
00259
00266
00267
00268 extern int vircam_pfits_get_naxis1(const cpl_propertylist *plist,
00269 long *naxis1) {
00270 int val;
00271
00272 val = cpl_propertylist_get_int(plist,"NAXIS1");
00273 if (cpl_error_get_code() == CPL_ERROR_NONE) {
00274 *naxis1 = (long)val;
00275 return(VIR_OK);
00276 } else {
00277 cpl_error_reset();
00278 *naxis1 = 0;
00279 return(VIR_FATAL);
00280 }
00281 }
00282
00283
00290
00291
00292 extern int vircam_pfits_get_naxis2(const cpl_propertylist *plist,
00293 long *naxis2) {
00294 int val;
00295
00296 val = cpl_propertylist_get_int(plist,"NAXIS2");
00297 if (cpl_error_get_code() == CPL_ERROR_NONE) {
00298 *naxis2 = (long)val;
00299 return(VIR_OK);
00300 } else {
00301 cpl_error_reset();
00302 *naxis2 = 0;
00303 return(VIR_FATAL);
00304 }
00305 }
00306
00307
00314
00315
00316 extern int vircam_pfits_get_chipno(const cpl_propertylist *plist,
00317 int *chipno) {
00318 int val;
00319
00320 val = cpl_propertylist_get_int(plist,"ESO DET CHIP NO");
00321 if (cpl_error_get_code() == CPL_ERROR_NONE) {
00322 *chipno = val;
00323 return(VIR_OK);
00324 } else {
00325 cpl_error_reset();
00326 *chipno = 0;
00327 return(VIR_FATAL);
00328 }
00329 }
00330
00331
00338
00339
00340 extern int vircam_pfits_get_jxoff(const cpl_propertylist *plist,
00341 float *xoff) {
00342
00343 return(vircam_pfits_get_float(plist,"ESO DRS XOFFDITHER",xoff));
00344
00345 }
00346
00347
00354
00355
00356 extern int vircam_pfits_get_jyoff(const cpl_propertylist *plist,
00357 float *yoff) {
00358
00359 return(vircam_pfits_get_float(plist,"ESO DRS YOFFDITHER",yoff));
00360
00361 }
00362
00363
00370
00371
00372 extern int vircam_pfits_get_airmass(const cpl_propertylist *plist,
00373 float *airmass) {
00374
00375 return(vircam_pfits_get_float(plist,"ESO TEL AIRM START",airmass));
00376
00377 }
00378
00379
00386
00387
00388 extern int vircam_pfits_get_nusteps(const cpl_propertylist *plist,
00389 int *nusteps) {
00390 int val;
00391
00392 val = cpl_propertylist_get_int(plist,"NUSTEP");
00393 if (cpl_error_get_code() == CPL_ERROR_NONE) {
00394 *nusteps = val;
00395 return(VIR_OK);
00396 } else {
00397 cpl_error_reset();
00398 *nusteps = 0;
00399 return(VIR_FATAL);
00400 }
00401
00402 }
00403
00404
00412
00413
00414 extern int vircam_pfits_get_ustepnum(const cpl_propertylist *plist,
00415 int *ustepnum) {
00416 int val;
00417
00418 val = cpl_propertylist_get_int(plist,"USTEPNUM");
00419 if (cpl_error_get_code() == CPL_ERROR_NONE) {
00420 *ustepnum = val;
00421 return(VIR_OK);
00422 } else {
00423 cpl_error_reset();
00424 *ustepnum = 0;
00425 return(VIR_FATAL);
00426 }
00427
00428 }
00429
00430
00438
00439
00440 extern int vircam_pfits_get_jitternum(const cpl_propertylist *plist,
00441 int *jitternum) {
00442 int val;
00443
00444 val = cpl_propertylist_get_int(plist,"JITTRNUM");
00445 if (cpl_error_get_code() == CPL_ERROR_NONE) {
00446 *jitternum = val;
00447 return(VIR_OK);
00448 } else {
00449 cpl_error_reset();
00450 *jitternum = 0;
00451 return(VIR_FATAL);
00452 }
00453
00454 }
00455
00456
00463
00464
00465 extern int vircam_pfits_get_ndit(const cpl_propertylist *plist,
00466 int *ndit) {
00467 int val;
00468
00469 val = cpl_propertylist_get_int(plist,"ESO DET NDIT");
00470 if (cpl_error_get_code() == CPL_ERROR_NONE) {
00471 *ndit = val;
00472 return(VIR_OK);
00473 } else {
00474 cpl_error_reset();
00475 *ndit = 1;
00476 return(VIR_FATAL);
00477 }
00478 }
00479
00480
00487
00488
00489 extern int vircam_pfits_get_detlive(const cpl_propertylist *plist,
00490 int *detlive) {
00491 int val;
00492
00493 val = cpl_propertylist_get_bool(plist,"ESO DET CHIP LIVE");
00494 if (cpl_error_get_code() == CPL_ERROR_NONE) {
00495 *detlive = val;
00496 return(VIR_OK);
00497 } else {
00498 cpl_error_reset();
00499 *detlive = 1;
00500 return(VIR_FATAL);
00501 }
00502 }
00503
00504
00511
00512
00513 extern int vircam_pfits_get_filter(const cpl_propertylist *plist, char *filt) {
00514
00515 strcpy(filt,cpl_propertylist_get_string(plist,"ESO INS FILT1 NAME"));
00516 if (cpl_error_get_code() == CPL_ERROR_NONE) {
00517 return(VIR_OK);
00518 } else {
00519 cpl_error_reset();
00520 return(VIR_FATAL);
00521 }
00522 }
00523
00524
00531
00532
00533 extern int vircam_pfits_get_saturation(const cpl_propertylist *plist,
00534 float *saturation) {
00535 int ival;
00536
00537 ival = cpl_propertylist_get_int(plist,"ESO DET SATURATION");
00538 if (cpl_error_get_code() == CPL_ERROR_NONE) {
00539 *saturation = (float)ival;
00540 return(VIR_OK);
00541 } else {
00542 cpl_error_reset();
00543 *saturation = 65535.0;
00544 return(VIR_FATAL);
00545 }
00546
00547
00548 }
00549
00550
00557
00558
00559 extern int vircam_pfits_get_gain(const cpl_propertylist *plist, float *gain) {
00560
00561 return(vircam_pfits_get_float(plist,"ESO DRS GAIN",gain));
00562
00563 }
00564
00565
00572
00573
00574 extern int vircam_pfits_get_mjd(const cpl_propertylist *plist, double *mjd) {
00575
00576 return(vircam_pfits_get_double(plist,"MJD-OBS",mjd));
00577
00578 }
00579
00580
00589
00590
00591 static int vircam_pfits_get_float(const cpl_propertylist *plist,
00592 const char *key, float *fval) {
00593 cpl_type type;
00594 const char *fctid = "vircam_pfits_get_float";
00595
00596
00597
00598 type = cpl_propertylist_get_type(plist,key);
00599 if (cpl_error_get_code() != CPL_ERROR_NONE) {
00600 *fval = 0.0;
00601 cpl_error_reset();
00602 return(VIR_FATAL);
00603 }
00604
00605
00606
00607 switch (type) {
00608 case CPL_TYPE_FLOAT:
00609 *fval = cpl_propertylist_get_float(plist,key);
00610 break;
00611 case CPL_TYPE_DOUBLE:
00612 *fval = (float)cpl_propertylist_get_double(plist,key);
00613 break;
00614 default:
00615 *fval = 0.0;
00616 cpl_msg_error(fctid,"Keyword %s is not floating point in header",key);
00617 return(VIR_FATAL);
00618 }
00619 return(VIR_OK);
00620 }
00621
00622
00631
00632
00633 static int vircam_pfits_get_double(const cpl_propertylist *plist,
00634 const char *key, double *fval) {
00635 cpl_type type;
00636 const char *fctid = "vircam_pfits_get_float";
00637
00638
00639
00640 type = cpl_propertylist_get_type(plist,key);
00641 if (cpl_error_get_code() != CPL_ERROR_NONE) {
00642 *fval = 0.0;
00643 cpl_error_reset();
00644 return(VIR_FATAL);
00645 }
00646
00647
00648
00649 switch (type) {
00650 case CPL_TYPE_FLOAT:
00651 *fval = (double)cpl_propertylist_get_float(plist,key);
00652 break;
00653 case CPL_TYPE_DOUBLE:
00654 *fval = cpl_propertylist_get_double(plist,key);
00655 break;
00656 default:
00657 *fval = 0.0;
00658 cpl_msg_error(fctid,"Keyword %s is not floating point in header",key);
00659 return(VIR_FATAL);
00660 }
00661 return(VIR_OK);
00662 }
00663
00666
00667
00668
00669
00670
00671
00672
00673
00674
00675
00676
00677
00678
00679
00680
00681
00682
00683
00684
00685
00686
00687
00688
00689
00690
00691
00692
00693
00694
00695
00696
00697
00698
00699
00700
00701
00702
00703
00704
00705
00706
00707
00708
00709
00710
00711
00712
00713
00714
00715
00716
00717
00718
00719
00720
00721
00722
00723
00724
00725
00726
00727
00728
00729
00730
00731
00732
00733
00734
00735
00736
00737
00738
00739
00740
00741
00742
00743
00744
00745
00746
00747
00748
00749