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 #ifndef XSH_DATA_RESID_TAB_H
00027 #define XSH_DATA_RESID_TAB_H
00028
00029 #include <cpl.h>
00030 #include <xsh_data_wavesol.h>
00031
00032 #define XSH_RESID_TAB_TABLE_NB_COL 20
00033
00034 #define XSH_RESID_TAB_TABLE_COLNAME_WAVELENGTH "Wavelength"
00035 #define XSH_RESID_TAB_TABLE_UNIT_WAVELENGTH "nm"
00036
00037 #define XSH_RESID_TAB_TABLE_COLNAME_SN "SN"
00038 #define XSH_RESID_TAB_TABLE_UNIT_SN "none"
00039
00040 #define XSH_RESID_TAB_TABLE_COLNAME_ORDER "Order"
00041 #define XSH_RESID_TAB_TABLE_UNIT_ORDER "none"
00042
00043 #define XSH_RESID_TAB_TABLE_COLNAME_SLITPOSITION "Slit_position"
00044 #define XSH_RESID_TAB_TABLE_UNIT_SLITPOSITION "arcsec"
00045
00046 #define XSH_RESID_TAB_TABLE_COLNAME_SLITINDEX "Slit_index"
00047 #define XSH_RESID_TAB_TABLE_UNIT_SLITINDEX "none"
00048
00049 #define XSH_RESID_TAB_TABLE_COLNAME_XTHPRE "Xthpre"
00050 #define XSH_RESID_TAB_TABLE_UNIT_XTHPRE "pixel"
00051
00052 #define XSH_RESID_TAB_TABLE_COLNAME_YTHPRE "Ythpre"
00053 #define XSH_RESID_TAB_TABLE_UNIT_YTHPRE "pixel"
00054
00055 #define XSH_RESID_TAB_TABLE_COLNAME_XTHCOR "Xthcor"
00056 #define XSH_RESID_TAB_TABLE_UNIT_XTHCOR "pixel"
00057
00058 #define XSH_RESID_TAB_TABLE_COLNAME_YTHCOR "Ythcor"
00059 #define XSH_RESID_TAB_TABLE_UNIT_YTHCOR "pixel"
00060
00061 #define XSH_RESID_TAB_TABLE_COLNAME_XGAUSS "XGauss"
00062 #define XSH_RESID_TAB_TABLE_UNIT_XGAUSS "pixel"
00063
00064 #define XSH_RESID_TAB_TABLE_COLNAME_YGAUSS "YGauss"
00065 #define XSH_RESID_TAB_TABLE_UNIT_YGAUSS "pixel"
00066
00067 #define XSH_RESID_TAB_TABLE_COLNAME_SIGMAXGAUSS "SigmaXGauss"
00068 #define XSH_RESID_TAB_TABLE_UNIT_SIGMAXGAUSS "pixel"
00069
00070 #define XSH_RESID_TAB_TABLE_COLNAME_SIGMAYGAUSS "SigmaYGauss"
00071 #define XSH_RESID_TAB_TABLE_UNIT_SIGMAYGAUSS "pixel"
00072
00073 #define XSH_RESID_TAB_TABLE_COLNAME_FWHMXGAUSS "FwhmXGauss"
00074 #define XSH_RESID_TAB_TABLE_UNIT_FWHMXGAUSS "pixel"
00075
00076 #define XSH_RESID_TAB_TABLE_COLNAME_FWHMYGAUSS "FwhmYGauss"
00077 #define XSH_RESID_TAB_TABLE_UNIT_FWHMYGAUSS "pixel"
00078
00079 #define XSH_RESID_TAB_TABLE_COLNAME_NORMGAUSS "NormGauss"
00080 #define XSH_RESID_TAB_TABLE_UNIT_NORMGAUSS "ADU"
00081
00082 #define XSH_RESID_TAB_TABLE_COLNAME_XPOLY "Xpoly"
00083 #define XSH_RESID_TAB_TABLE_UNIT_XPOLY "pixel"
00084
00085 #define XSH_RESID_TAB_TABLE_COLNAME_YPOLY "Ypoly"
00086 #define XSH_RESID_TAB_TABLE_UNIT_YPOLY "pixel"
00087
00088 #define XSH_RESID_TAB_TABLE_COLNAME_XTHANNEAL "Xthanneal"
00089 #define XSH_RESID_TAB_TABLE_UNIT_XTHANNEAL "pixel"
00090
00091 #define XSH_RESID_TAB_TABLE_COLNAME_YTHANNEAL "Ythanneal"
00092 #define XSH_RESID_TAB_TABLE_UNIT_YTHANNEAL "pixel"
00093
00094 #define XSH_RESID_TAB_TABLE_COLNAME_RESIDXPOLY "ResidXpoly"
00095 #define XSH_RESID_TAB_TABLE_UNIT_RESIDXPOLY "pixel"
00096
00097 #define XSH_RESID_TAB_TABLE_COLNAME_RESIDYPOLY "ResidYpoly"
00098 #define XSH_RESID_TAB_TABLE_UNIT_RESIDYPOLY "pixel"
00099
00100 #define XSH_RESID_TAB_TABLE_COLNAME_RESIDXMODEL "ResidXmodel"
00101 #define XSH_RESID_TAB_TABLE_UNIT_RESIDXMODEL "pixel"
00102
00103 #define XSH_RESID_TAB_TABLE_COLNAME_RESIDYMODEL "ResidYmodel"
00104 #define XSH_RESID_TAB_TABLE_UNIT_RESIDYMODEL "pixel"
00105
00106 #define XSH_RESID_TAB_TABLE_COLNAME_FLAG "Flag"
00107 #define XSH_RESID_TAB_TABLE_UNIT_FLAG "none"
00108
00109
00110 #define PROPERTY_GET( OBJECT, PROPERTY, TYPE, DEFAULT)\
00111 TYPE OBJECT##_get_##PROPERTY( OBJECT* obj)\
00112 {\
00113 TYPE result = DEFAULT;\
00114 \
00115 XSH_ASSURE_NOT_NULL( obj);\
00116 result = obj->PROPERTY;\
00117 \
00118 cleanup:\
00119 return result;\
00120 }
00121
00122
00123 #define RESID_TAB_PROPERTY_GET( PROPERTY, TYPE, DEFAULT)\
00124 PROPERTY_GET( xsh_resid_tab, PROPERTY, TYPE, DEFAULT)
00125
00126 typedef struct{
00127
00128 int solution_type;
00129
00130 double *lambda;
00131
00132 double *order;
00133
00134 double *slit;
00135 double *sn;
00136
00137 int* slit_index;
00138 double *thpre_x;
00139 double *thpre_y;
00140 double *thcor_x;
00141 double *thcor_y;
00142 double *xgauss;
00143 double *ygauss;
00144 double *sig_xgauss;
00145 double *sig_ygauss;
00146 double *fwhm_xgauss;
00147 double *fwhm_ygauss;
00148 double *norm_gauss;
00149 double *xpoly;
00150 double *ypoly;
00151 double *thanneal_x;
00152 double *thanneal_y;
00153 int* flag;
00154
00155 int size;
00156
00157 double median_diff_poly_fit_x;
00158
00159 double median_diff_poly_fit_y;
00160
00161 double mean_diff_poly_fit_x;
00162
00163 double mean_diff_poly_fit_y;
00164
00165 double stdev_diff_poly_fit_x;
00166
00167 double stdev_diff_poly_fit_y;
00168
00169
00170
00171 cpl_propertylist* header;
00172 }xsh_resid_tab;
00173
00174 xsh_resid_tab*
00175 xsh_resid_tab_create(int size, double *lambda, double *order,
00176 double *slit, double* sn, int *slit_index,
00177 double *thpre_x, double *thpre_y,
00178 double*corr_x, double* corr_y,
00179 double *gaussian_norm,
00180 double *gaussian_fit_x, double *gaussian_fit_y,
00181 double *gaussian_sigma_x, double *gaussian_sigma_y,
00182 double *gaussian_fwhm_x, double *gaussian_fwhm_y, int* flag,
00183 xsh_wavesol *wavesol, int wavesol_type);
00184
00185
00186 xsh_resid_tab*
00187 xsh_resid_tab_create_not_flagged(int size, double *lambda, double *order,
00188 double *slit, double* sn, int *slit_index,
00189 double *thpre_x, double *thpre_y,
00190 double*corr_x, double* corr_y,
00191 double *gaussian_norm,
00192 double *gaussian_fit_x, double *gaussian_fit_y,
00193 double *gaussian_sigma_x, double *gaussian_sigma_y,
00194 double *gaussian_fwhm_x, double *gaussian_fwhm_y, int* flag,
00195 xsh_wavesol *wavesol, int wavesol_type);
00196
00197 xsh_resid_tab* xsh_resid_tab_load( cpl_frame* resid_tab_frame);
00198 int xsh_resid_tab_get_size( xsh_resid_tab *resid);
00199 double * xsh_resid_tab_get_lambda_data(xsh_resid_tab *resid) ;
00200 double * xsh_resid_tab_get_order_data(xsh_resid_tab *resid) ;
00201 double * xsh_resid_tab_get_slitpos_data(xsh_resid_tab *resid) ;
00202 int* xsh_resid_tab_get_slit_index( xsh_resid_tab *resid);
00203 double * xsh_resid_tab_get_thpre_x_data(xsh_resid_tab *resid) ;
00204 double * xsh_resid_tab_get_thpre_y_data(xsh_resid_tab *resid) ;
00205 double * xsh_resid_tab_get_xgauss_data(xsh_resid_tab *resid) ;
00206 double * xsh_resid_tab_get_ygauss_data(xsh_resid_tab *resid) ;
00207
00208 void xsh_resid_tab_free( xsh_resid_tab **resid);
00209 cpl_frame* xsh_resid_tab_save( xsh_resid_tab *resid, const char *filename,
00210 xsh_instrument* instr,const char* tag);
00211 void xsh_resid_tab_log( xsh_resid_tab* resid, const char *filename) ;
00212 cpl_frame* xsh_resid_tab_erase_flagged( cpl_frame* resid,const char* name);
00213
00214 cpl_error_code
00215 xsh_frame_table_resid_merge(cpl_frame* self, cpl_frame* right,
00216 const int solution_type);
00217
00218 #endif