X-shooter Pipeline Reference Manual 3.8.15
xsh_utils_table.h
Go to the documentation of this file.
1/* *
2 * This file is part of the ESO X-shooter Pipeline *
3 * Copyright (C) 2006 European Southern Observatory *
4 * *
5 * This library is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) any later version. *
9 * *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
14 * *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the Free Software *
17 * Foundation, 51 Franklin St, Fifth Floor, Boston, MA 02111-1307 USA *
18 * */
19
20/*
21 * $Author: amodigli $
22 * $Date: 2012-07-10 16:17:40 $
23 * $Revision: 1.10 $
24 * $Name: not supported by cvs2svn $
25 */
26
27#ifndef XSH_UTILS_TABLE_H
28#define XSH_UTILS_TABLE_H
29
30/*----------------------------------------------------------------------------
31 Includes
32 ----------------------------------------------------------------------------*/
33
34#include <cpl.h>
35#include <xsh_error.h>
36
37/*----------------------------------------------------------------------------
38 Macros
39 ----------------------------------------------------------------------------*/
40#define XSH_TABLE_LOAD( TABLE, NAME) \
41 check_msg( TABLE = cpl_table_load( NAME, 1, 0),\
42 "Can't load %s FITS table", NAME)
43
44#define XSH_TABLE_FREE( TABLE)\
45 if (TABLE != NULL){\
46 cpl_table_delete ( TABLE);\
47 TABLE = NULL;\
48 }
49
50
51#define XSH_TABLE_GET_ARRAY( TYPE) \
52 void xsh_table_get_array_##TYPE( cpl_table* table, const char* colname, \
53 TYPE* pointer, int nb)\
54 {\
55 const cpl_array* array = NULL;\
56 int array_size = 0, k=0;\
57 const TYPE* data = NULL;\
58 \
59 XSH_ASSURE_NOT_NULL( pointer);\
60 check( array = cpl_table_get_array( table, colname, 0));\
61 check( array_size = cpl_array_get_size( array));\
62 XSH_ASSURE_NOT_ILLEGAL( nb == array_size);\
63 check( data = cpl_array_get_data_##TYPE##_const( array));\
64 for( k=0; k< array_size; k++){\
65 pointer[k] = data[k];\
66 }\
67 cleanup:\
68 return;\
69 }
70
71/*----------------------------------------------------------------------------
72 Prototypes
73 ----------------------------------------------------------------------------*/
74cpl_error_code xsh_get_table_value(const cpl_table* table,
75 const char *colname, cpl_type coltype, int i, void *result);
76void xsh_table_get_array_int( cpl_table* table, const char* colname,
77 int* pointer, int nb);
78void xsh_table_get_array_float( cpl_table* table, const char* colname,
79 float* pointer, int nb);
80void xsh_table_get_array_double( cpl_table* table, const char* colname,
81 double* pointer, int nb);
82
83cpl_error_code xsh_sort_table_1(cpl_table *t, const char *column1,
84 cpl_boolean reverse1);
85cpl_error_code xsh_sort_table_2(cpl_table *t, const char *column1,
86 const char *column2, cpl_boolean reverse1,
87 cpl_boolean reverse2);
88
89cpl_error_code
90xsh_sort_table_3(cpl_table *t,
91 const char *column1, const char *column2, const char *column3,
92 cpl_boolean reverse1, cpl_boolean reverse2,cpl_boolean reverse3);
93double
95 double wav,
96 int nrow,
97 double* pw,
98 double* pe
99 );
100
101double
102xsh_table_interpolate(cpl_table* tbl,
103 double wav,
104 const char* colx,
105 const char* coly);
106
107
108cpl_error_code
110 const char* colw,
111 const char* colf,
112 const char* prefix,
114cpl_error_code
115xsh_wavecal_qclog_intmon(cpl_frame* table_check,
116 const cpl_frame *line_intmon,
117 const double exptime,
118 xsh_instrument* inst);
119
120cpl_error_code
121xsh_table_merge_clean_and_resid_tabs(cpl_frame* frm_resid,cpl_frame* frm_clean);
122
123cpl_table*
124xsh_table_shift_rv(cpl_table* orig, const char* col_wave,const double offset);
125
126
127cpl_table*
128xsh_histogram(const cpl_table* data, const char* cname, const int nbins,
129 const double min, const double max);
130
131#endif
static double exptime
static xsh_instrument * instrument
cpl_error_code xsh_wavecal_qclog_intmon(cpl_frame *table_check, const cpl_frame *line_intmon, const double exptime, xsh_instrument *inst)
computes intmon QC log
cpl_error_code xsh_table_merge_clean_and_resid_tabs(cpl_frame *frm_resid, cpl_frame *frm_clean)
cpl_error_code xsh_sort_table_2(cpl_table *t, const char *column1, const char *column2, cpl_boolean reverse1, cpl_boolean reverse2)
Sort a table by two columns.
cpl_error_code xsh_sort_table_1(cpl_table *t, const char *column1, cpl_boolean reverse1)
Sort a table by one column.
double xsh_data_interpolate(double wav, int nrow, double *pw, double *pe)
Interpolate data points.
cpl_table * xsh_table_shift_rv(cpl_table *orig, const char *col_wave, const double offset)
cpl_table * xsh_histogram(const cpl_table *data, const char *cname, const int nbins, const double min, const double max)
cpl_error_code xsh_frame_table_monitor_flux_qc(cpl_frame *frm, const char *colw, const char *colf, const char *prefix, xsh_instrument *instrument)
Computes statistics on spectrum for QC.
double xsh_table_interpolate(cpl_table *tbl, double wav, const char *colx, const char *coly)
Interpolate table columns.
cpl_error_code xsh_get_table_value(const cpl_table *table, const char *colname, cpl_type coltype, int i, void *result)
Read a table value from a fits table.
cpl_error_code xsh_sort_table_3(cpl_table *t, const char *column1, const char *column2, const char *column3, cpl_boolean reverse1, cpl_boolean reverse2, cpl_boolean reverse3)
Sort a table by two columns.
#define max(a, b)
void xsh_table_get_array_double(cpl_table *table, const char *colname, double *pointer, int nb)
void xsh_table_get_array_float(cpl_table *table, const char *colname, float *pointer, int nb)
void xsh_table_get_array_int(cpl_table *table, const char *colname, int *pointer, int nb)