30#include "cr2res_pfits.h"
31#include "cr2res_utils.h"
56 sval = cpl_propertylist_get_string(plist, CR2RES_HEADER_NODPOS);
60 return CR2RES_NODDING_NONE ;
62 if (sval[0] ==
'A')
return CR2RES_NODDING_A ;
63 if (sval[0] ==
'B')
return CR2RES_NODDING_B ;
64 return CR2RES_NODDING_NONE ;
74const char * cr2res_pfits_get_procatg(
const cpl_propertylist * plist)
76 return (
const char *) cpl_propertylist_get_string(plist, CPL_DFS_PRO_CATG);
88 return (
const char *) cpl_propertylist_get_string(plist,
89 CR2RES_HEADER_DRS_TYPE);
100 return (
const char *) cpl_propertylist_get_string(plist,
111const char * cr2res_pfits_get_arcfile(
const cpl_propertylist * plist)
113 return (
const char *) cpl_propertylist_get_string(plist,
114 CR2RES_HEADER_ARCFILE);
126 return (
const char *) cpl_propertylist_get_string(plist,
127 CR2RES_HEADER_PROG_ID);
139 return (
const char *) cpl_propertylist_get_string(plist,
140 CR2RES_HEADER_WLEN_ID);
152 return cpl_propertylist_get_double(plist,
"DEC") ;
164 return cpl_propertylist_get_double(plist,
"RA") ;
176 return cpl_propertylist_get_double(plist, CR2RES_HEADER_DROT_POSANG) ;
188 return cpl_propertylist_get_double(plist, CR2RES_HEADER_NODTHROW) ;
202 val = cpl_propertylist_get_double(plist, CR2RES_HEADER_DIT) ;
203 if (cpl_error_get_code() == CPL_ERROR_TYPE_MISMATCH){
205 val = (double) cpl_propertylist_get_int(plist, CR2RES_HEADER_DIT);
219 return cpl_propertylist_get_double(plist, CR2RES_HEADER_MJDOBS) ;
231 return cpl_propertylist_get_double(plist, CR2RES_HEADER_WLEN_CWLEN) ;
243 return cpl_propertylist_get_string(plist, CR2RES_HEADER_POL_TYPE) ;
261 if (plist == NULL)
return -1.0 ;
268 key_name = cpl_sprintf(CR2RES_HEADER_WLEN_BEGIN, order_idxp) ;
271 val = cpl_propertylist_get_double(plist, key_name) ;
292 if (plist == NULL)
return -1.0 ;
299 key_name = cpl_sprintf(CR2RES_HEADER_WLEN_END, order_idxp) ;
302 val = cpl_propertylist_get_double(plist, key_name) ;
315int cr2res_pfits_get_naxis1(
const cpl_propertylist * plist)
317 return cpl_propertylist_get_int(plist, CR2RES_HEADER_NAXIS1) ;
327int cr2res_pfits_get_naxis2(
const cpl_propertylist * plist)
329 return cpl_propertylist_get_int(plist, CR2RES_HEADER_NAXIS2) ;
339int cr2res_pfits_get_nexp(
const cpl_propertylist * plist)
341 return cpl_propertylist_get_int(plist, CR2RES_HEADER_NEXP) ;
351int cr2res_pfits_get_expno(
const cpl_propertylist * plist)
353 return cpl_propertylist_get_int(plist, CR2RES_HEADER_EXPNO) ;
365 return cpl_propertylist_get_int(plist, CR2RES_HEADER_NDIT) ;
377 return cpl_propertylist_get_int(plist, CR2RES_HEADER_OBS_ID) ;
387int cr2res_pfits_get_order(
const cpl_propertylist * plist)
389 return cpl_propertylist_get_int(plist, CR2RES_HEADER_GRAT1_ORDER) ;
399int cr2res_pfits_get_order_zp(
const cpl_propertylist * plist)
401 return cpl_propertylist_get_int(plist, CR2RES_HEADER_GRAT1_ZPORD) ;
413 const cpl_propertylist * plist,
417 int order_idx = -1000 ;
418 int min_order_idx = -49 ;
419 int max_order_idx = 50 ;
421 double best_diff = CR2RES_DETECTOR_SIZE;
424 if (plist == NULL)
return -1 ;
425 if (yposition < 1)
return -1 ;
426 if (cpl_error_get_code() != CPL_ERROR_NONE) {
427 cpl_msg_error(__func__,
"Error already set - abort") ;
431 for (i = min_order_idx; i <= max_order_idx; i++) {
436 key_name = cpl_sprintf(CR2RES_HEADER_WLEN_CENY, order_idxp) ;
437 ycen = cpl_propertylist_get_double(plist, key_name);
439 if (cpl_error_get_code() != CPL_ERROR_NONE) {
443 curr_diff = fabs(yposition - ycen );
444 if (curr_diff < best_diff){
445 best_diff = curr_diff;
450 cpl_msg_debug(__func__,
451 "Order %d identified with %.1f pix difference from expectation",
452 order_idx, best_diff);
453 if (best_diff > 100.0)
454 cpl_msg_warning(__func__,
455 "Order %d identified with large difference of %.1f pix",
456 order_idx, best_diff);
470 decker_value = cpl_propertylist_get_int(plist, CR2RES_HEADER_DECKER_POS);
471 if (cpl_error_get_code() != CPL_ERROR_NONE) {
473 return CR2RES_DECKER_INVALID ;
476 if (decker_value == 3)
return CR2RES_DECKER_NONE ;
477 if (decker_value == 1)
return CR2RES_DECKER_1_3 ;
478 if (decker_value == 2)
return CR2RES_DECKER_2_4 ;
479 return CR2RES_DECKER_INVALID ;
int cr2res_io_convert_order_idx_to_idxp(int order_idx)
Convert the order_idx to the order_idxp.
cr2res_decker cr2res_pfits_get_decker_position(const cpl_propertylist *plist)
find out the decker position
int cr2res_pfits_get_order_idx(const cpl_propertylist *plist, double yposition)
find out the order_idx closest to the passed y position
const char * cr2res_pfits_get_wlen_id(const cpl_propertylist *plist)
find out the Setting
const char * cr2res_pfits_get_progid(const cpl_propertylist *plist)
find out the PROG ID
double cr2res_pfits_get_wstrt(const cpl_propertylist *plist, int order_idx)
find out the Start wavelength for an order_idx (current detector)
double cr2res_pfits_get_wend(const cpl_propertylist *plist, int order_idx)
find out the End wavelength for an order_idx (current detector)
const char * cr2res_pfits_get_protype(const cpl_propertylist *plist)
find out the PRO.TYPE
double cr2res_pfits_get_dit(const cpl_propertylist *plist)
find out the DIT value
double cr2res_pfits_get_mjd_obs(const cpl_propertylist *plist)
find out the MJD-OBS value
double cr2res_pfits_get_dec(const cpl_propertylist *plist)
find out the DEC
double cr2res_pfits_get_drot_posang(const cpl_propertylist *plist)
find out the DROT POSANG value
double cr2res_pfits_get_nodthrow(const cpl_propertylist *plist)
find out the NODTHROW value
int cr2res_pfits_get_ndit(const cpl_propertylist *plist)
find out the NDIT value
const char * cr2res_pfits_get_drstype(const cpl_propertylist *plist)
find out the DRS.TYPE
cr2res_nodding_pos cr2res_pfits_get_nodding_pos(const cpl_propertylist *plist)
find out the nodding position
double cr2res_pfits_get_ra(const cpl_propertylist *plist)
find out the RA
double cr2res_pfits_get_cwlen(const cpl_propertylist *plist)
find out the CWLEN value
const char * cr2res_pfits_get_poltype(const cpl_propertylist *plist)
find out the POL TYPE value
int cr2res_pfits_get_obs_id(const cpl_propertylist *plist)
find out the OBS ID value