00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef MUSE_PIXTABLE_H
00023 #define MUSE_PIXTABLE_H
00024
00025
00026
00027
00028 #include <cpl.h>
00029 #include <stdint.h>
00030
00031 #include "muse_dfs.h"
00032 #include "muse_image.h"
00033 #include "muse_imagelist.h"
00034 #include "muse_mask.h"
00035 #include "muse_cplwrappers.h"
00036
00037
00038
00039
00040 #if !HAVE_UINT32_T
00041 typedef unsigned int uint32_t;
00042 #endif
00043
00044
00045 #define MUSE_PIXTABLE_DATA "data"
00046 #define MUSE_PIXTABLE_DQ "dq"
00047 #define MUSE_PIXTABLE_STAT "stat"
00048 #define MUSE_PIXTABLE_XPOS "xpos"
00049 #define MUSE_PIXTABLE_YPOS "ypos"
00050 #define MUSE_PIXTABLE_LAMBDA "lambda"
00051 #define MUSE_PIXTABLE_ORIGIN "origin"
00052
00053 #define MUSE_PIXTABLE_WEIGHT "weight"
00054
00055 extern const muse_cpltable_def muse_pixtable_def[];
00056
00068 #define MUSE_HDR_PT_IFU_SLICE_OFFSET "ESO DRS MUSE PIXTABLE EXP%u IFU%02hu SLICE%02hu XOFFSET"
00069 #define MUSE_HDR_PT_IFU_SLICE_OFFSET_COMMENT "x-offset of given slice in given IFU of given exposure"
00070
00077 #define MUSE_HDR_PT_TYPE "ESO DRS MUSE PIXTABLE TYPE"
00078 #define MUSE_PIXTABLE_STRING_SIMPLE "SIMPLE"
00079 #define MUSE_PIXTABLE_STRING_FULL "GEOFULL"
00080 #define MUSE_PIXTABLE_COMMENT_SIMPLE "pixel table without y coordinates"
00081 #define MUSE_PIXTABLE_COMMENT_FULL "pixel table with full geometry information"
00082
00087 #define MUSE_HDR_PT_EXP_FST "ESO DRS MUSE PIXTABLE EXP%u FIRST"
00088
00092 #define MUSE_HDR_PT_EXP_LST "ESO DRS MUSE PIXTABLE EXP%u LAST"
00093 #define MUSE_HDR_PT_EXP_FST_COMMENT "Exposure %u first row index"
00094 #define MUSE_HDR_PT_EXP_LST_COMMENT "Exposure %u last row index"
00095 #define MUSE_HDR_PT_EXP_REGEXP "ESO DRS MUSE PIXTABLE EXP[0-9]+ (FIRST|LAST)"
00096
00098 #define MUSE_HDR_PT_ILLUMi "ESO DRS MUSE PIXTABLE ILLUM%hu"
00099
00100 #define MUSE_HDR_PT_ILLUM_MEAN "ESO DRS MUSE PIXTABLE ILLUM MEAN"
00101
00102 #define MUSE_HDR_PT_ILLUM_STDEV "ESO DRS MUSE PIXTABLE ILLUM STDEV"
00103
00104 #define MUSE_HDR_PT_ILLUM_REGEXP "^ESO DRS MUSE PIXTABLE ILLUM"
00105
00106
00111 #define MUSE_HDR_PT_XLO "ESO DRS MUSE PIXTABLE LIMITS X LOW"
00112
00116 #define MUSE_HDR_PT_XHI "ESO DRS MUSE PIXTABLE LIMITS X HIGH"
00117
00121 #define MUSE_HDR_PT_YLO "ESO DRS MUSE PIXTABLE LIMITS Y LOW"
00122
00126 #define MUSE_HDR_PT_YHI "ESO DRS MUSE PIXTABLE LIMITS Y HIGH"
00127
00131 #define MUSE_HDR_PT_LLO "ESO DRS MUSE PIXTABLE LIMITS LAMBDA LOW"
00132
00136 #define MUSE_HDR_PT_LHI "ESO DRS MUSE PIXTABLE LIMITS LAMBDA HIGH"
00137
00141 #define MUSE_HDR_PT_ILO "ESO DRS MUSE PIXTABLE LIMITS IFU LOW"
00142
00146 #define MUSE_HDR_PT_IHI "ESO DRS MUSE PIXTABLE LIMITS IFU HIGH"
00147
00151 #define MUSE_HDR_PT_SLO "ESO DRS MUSE PIXTABLE LIMITS SLICE LOW"
00152
00156 #define MUSE_HDR_PT_SHI "ESO DRS MUSE PIXTABLE LIMITS SLICE HIGH"
00157
00158 #define MUSE_HDR_PT_LIMITS_REGEXP "^ESO DRS MUSE PIXTABLE LIMITS "
00159
00160
00162 #define MUSE_HDR_PT_PREDAR_XLO "ESO DRS MUSE PIXTABLE PREDAR LIMITS XLO"
00163
00164 #define MUSE_HDR_PT_PREDAR_XHI "ESO DRS MUSE PIXTABLE PREDAR LIMITS XHI"
00165
00166 #define MUSE_HDR_PT_PREDAR_YLO "ESO DRS MUSE PIXTABLE PREDAR LIMITS YLO"
00167
00168 #define MUSE_HDR_PT_PREDAR_YHI "ESO DRS MUSE PIXTABLE PREDAR LIMITS YHI"
00169
00170
00172 #define MUSE_HDR_PT_MERGED "ESO DRS MUSE PIXTABLE MERGED"
00173 #define MUSE_HDR_PT_MERGED_COMMENT "Merged IFUs that went into this pixel table"
00174
00175 #define MUSE_HDR_PT_SKYSUB "ESO DRS MUSE PIXTABLE SKYSUB"
00176 #define MUSE_HDR_PT_SKYSUB_COMMENT "Pixel table was sky-subtracted"
00177
00179 #define MUSE_HDR_PT_DAR_NAME "ESO DRS MUSE PIXTABLE DAR CORRECT"
00180 #define MUSE_HDR_PT_DAR_COMMENT "[Angstrom] ref. lambda for DAR correction"
00181 #define MUSE_HDR_PT_DAR_C_SKIP "skipped DAR correction!"
00182
00183 #define MUSE_HDR_PT_DAR_CHECK "ESO DRS MUSE PIXTABLE DAR CHECK"
00184 #define MUSE_HDR_PT_DAR_CHECK_C "[arcsec] maximum residual DAR offsets found"
00185
00186 #define MUSE_HDR_PT_DAR_CORR "ESO DRS MUSE PIXTABLE DAR CORRECT RESIDUAL"
00187 #define MUSE_HDR_PT_DAR_CORR_C "[Angstrom] ref. lambda for residual DAR correction"
00188
00189 #define MUSE_HDR_PT_RVCORR "ESO DRS MUSE PIXTABLE RVCORR"
00190 #define MUSE_HDR_PT_RVCORR_C "[km/s] %scentric correction was applied"
00191
00192 #define MUSE_HDR_PT_FLUXCAL "ESO DRS MUSE PIXTABLE FLUXCAL"
00193 #define MUSE_HDR_PT_FLUXCAL_COMMENT "Pixel table was flux-calibrated"
00194
00195 #define MUSE_HDR_PT_WCS "ESO DRS MUSE PIXTABLE WCS"
00196
00197 #define MUSE_HDR_PT_WCS_PROJ "projected (intermediate)"
00198 #define MUSE_HDR_PT_WCS_COMMENT_PROJ "Gnomonic projection applied to this pixel table"
00199
00200 #define MUSE_HDR_PT_WCS_POSI "positioned (final)"
00201 #define MUSE_HDR_PT_WCS_COMMENT_POSI "Positioned this pixel table to sky coordinates"
00202
00203 #define MUSE_HDR_PT_WEIGHTED "ESO DRS MUSE PIXTABLE WEIGHTED"
00204 #define MUSE_HDR_PT_WEIGHTED_COMMENT "Pixel table was weighted relative to other exposures"
00205
00206 #define MUSE_HDR_PT_COMBINED "ESO DRS MUSE PIXTABLE COMBINED"
00207 #define MUSE_HDR_PT_COMBINED_COMMENT "Combined exposures that went into this pixel table"
00208
00209 #define MUSE_HDR_PT_SPEC_TYPE "ESO DRS MUSE PIXTABLE SPECTYPE"
00210 #define MUSE_HDR_PT_SPEC_TYPE_COMMENT "FITS spectral type code of wavelength"
00211
00212
00213
00214 #define MUSE_HDR_PT_REGEXP "^ESO DRS MUSE PIXTABLE "
00215
00216
00217
00218
00219
00220
00227
00228 typedef struct {
00234 cpl_table *table;
00235
00242 cpl_propertylist *header;
00243 } muse_pixtable;
00244
00245
00249
00250 enum muse_pixtable_type {
00252 MUSE_PIXTABLE_TYPE_UNKNOWN = 0,
00254 MUSE_PIXTABLE_TYPE_SIMPLE,
00256 MUSE_PIXTABLE_TYPE_FULL
00257 };
00258
00259
00263
00264 typedef enum {
00266 MUSE_PIXTABLE_WCS_UNKNOWN = 0,
00268 MUSE_PIXTABLE_WCS_PIXEL,
00270 MUSE_PIXTABLE_WCS_NATSPH,
00272 MUSE_PIXTABLE_WCS_CELSPH
00273 } muse_pixtable_wcs;
00274
00277
00278
00279
00280
00281 uint32_t muse_pixtable_origin_encode(unsigned int, unsigned int, unsigned short, unsigned short, unsigned int);
00282 unsigned int muse_pixtable_origin_get_x(uint32_t, muse_pixtable *, cpl_size);
00283 unsigned int muse_pixtable_origin_get_y(uint32_t);
00284 unsigned short muse_pixtable_origin_get_ifu(uint32_t);
00285 unsigned short muse_pixtable_origin_get_slice(uint32_t);
00286 unsigned int muse_pixtable_origin_set_offset(muse_pixtable *, cpl_polynomial *, unsigned short, unsigned short);
00287 unsigned int muse_pixtable_origin_get_offset(muse_pixtable *, unsigned int, unsigned short, unsigned short);
00288 cpl_error_code muse_pixtable_origin_copy_offsets(muse_pixtable *, muse_pixtable *, unsigned int);
00289 unsigned int muse_pixtable_get_expnum(muse_pixtable *, cpl_size);
00290
00291
00292 muse_pixtable *muse_pixtable_create(muse_image *, cpl_table *, cpl_table *, cpl_table *);
00293 muse_pixtable *muse_pixtable_duplicate(muse_pixtable *);
00294 void muse_pixtable_delete(muse_pixtable *);
00295 cpl_error_code muse_pixtable_save(muse_pixtable *, const char *);
00296 muse_pixtable *muse_pixtable_load_window(const char *, cpl_size, cpl_size);
00297 muse_pixtable *muse_pixtable_load(const char *);
00298 muse_pixtable *muse_pixtable_load_restricted_wavelength(const char *, double, double);
00299 muse_pixtable *muse_pixtable_load_merge_channels(cpl_table *, double, double);
00300
00301
00302 int muse_pixtable_get_type(muse_pixtable *);
00303 cpl_size muse_pixtable_get_nrow(const muse_pixtable *);
00304 cpl_error_code muse_pixtable_compute_limits(muse_pixtable *);
00305 cpl_error_code muse_pixtable_flux_multiply(muse_pixtable *, double);
00306
00307 cpl_error_code muse_pixtable_restrict_wavelength(muse_pixtable *, double, double);
00308 cpl_error_code muse_pixtable_restrict_xpos(muse_pixtable *, double, double);
00309 cpl_error_code muse_pixtable_restrict_ypos(muse_pixtable *, double, double);
00310 cpl_error_code muse_pixtable_erase_ifu_slice(muse_pixtable *, unsigned char, unsigned short);
00311 cpl_error_code muse_pixtable_and_selected_mask(muse_pixtable *, muse_mask *);
00312
00313 cpl_error_code muse_pixtable_dump(muse_pixtable *, cpl_size, cpl_size, unsigned char);
00314 muse_pixtable_wcs muse_pixtable_wcs_check(muse_pixtable *);
00315 cpl_boolean muse_pixtable_is_fluxcal(muse_pixtable *);
00316 cpl_boolean muse_pixtable_is_skysub(muse_pixtable *);
00317 cpl_boolean muse_pixtable_is_rvcorr(muse_pixtable *);
00318
00319 cpl_error_code muse_pixtable_reset_dq(muse_pixtable *, unsigned int);
00320
00321 muse_imagelist *muse_pixtable_to_imagelist(muse_pixtable *);
00322 cpl_error_code muse_pixtable_from_imagelist(muse_pixtable *, muse_imagelist *);
00323
00324 muse_pixtable **muse_pixtable_extracted_get_slices(muse_pixtable *);
00325 cpl_size muse_pixtable_extracted_get_size(muse_pixtable **);
00326 void muse_pixtable_extracted_delete(muse_pixtable **);
00327
00328 #endif