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 #ifndef XSH_UTILS_TABLE_H
00028 #define XSH_UTILS_TABLE_H
00029
00030
00031
00032
00033
00034 #include <cpl.h>
00035 #include <xsh_error.h>
00036
00037
00038
00039
00040 #define XSH_TABLE_LOAD( TABLE, NAME) \
00041 check_msg( TABLE = cpl_table_load( NAME, 1, 0),\
00042 "Can't load %s FITS table", NAME)
00043
00044 #define XSH_TABLE_FREE( TABLE)\
00045 if (TABLE != NULL){\
00046 cpl_table_delete ( TABLE);\
00047 TABLE = NULL;\
00048 }
00049
00050
00051 #define XSH_TABLE_GET_ARRAY( TYPE) \
00052 void xsh_table_get_array_##TYPE( cpl_table* table, const char* colname, \
00053 TYPE* pointer, int nb)\
00054 {\
00055 const cpl_array* array = NULL;\
00056 int array_size = 0, k=0;\
00057 const TYPE* data = NULL;\
00058 \
00059 XSH_ASSURE_NOT_NULL( pointer);\
00060 check( array = cpl_table_get_array( table, colname, 0));\
00061 check( array_size = cpl_array_get_size( array));\
00062 XSH_ASSURE_NOT_ILLEGAL( nb == array_size);\
00063 check( data = cpl_array_get_data_##TYPE##_const( array));\
00064 for( k=0; k< array_size; k++){\
00065 pointer[k] = data[k];\
00066 }\
00067 cleanup:\
00068 return;\
00069 }
00070
00071
00072
00073
00074 cpl_error_code xsh_get_table_value(const cpl_table* table,
00075 const char *colname, cpl_type coltype, int i, void *result);
00076 void xsh_table_get_array_int( cpl_table* table, const char* colname,
00077 int* pointer, int nb);
00078 void xsh_table_get_array_float( cpl_table* table, const char* colname,
00079 float* pointer, int nb);
00080 void xsh_table_get_array_double( cpl_table* table, const char* colname,
00081 double* pointer, int nb);
00082
00083 cpl_error_code xsh_sort_table_1(cpl_table *t, const char *column1,
00084 cpl_boolean reverse1);
00085 cpl_error_code xsh_sort_table_2(cpl_table *t, const char *column1,
00086 const char *column2, cpl_boolean reverse1,
00087 cpl_boolean reverse2);
00088
00089
00090 double
00091 xsh_data_interpolate(
00092 double wav,
00093 int nrow,
00094 double* pw,
00095 double* pe
00096 );
00097
00098 double
00099 xsh_table_interpolate(cpl_table* tbl,
00100 double wav,
00101 const char* colx,
00102 const char* coly);
00103
00104
00105 cpl_error_code
00106 xsh_frame_table_monitor_flux_qc(cpl_frame* frm,
00107 const char* colw,
00108 const char* colf,
00109 const char* prefix,
00110 xsh_instrument* instrument);
00111 cpl_error_code
00112 xsh_wavecal_qclog_intmon(cpl_frame* table_check,
00113 const cpl_frame *line_intmon,
00114 const double exptime,
00115 xsh_instrument* inst);
00116
00117 cpl_error_code
00118 xsh_table_merge_clean_and_resid_tabs(cpl_frame* frm_resid,cpl_frame* frm_clean);
00119
00120 cpl_table*
00121 xsh_table_shift_rv(cpl_table* orig, const char* col_wave,const double offset);
00122 #endif