X-shooter Pipeline Reference Manual 3.8.15
Macros | Functions
xsh_utils_ifu.c File Reference
#include <math.h>
#include <string.h>
#include <xsh_error.h>
#include <xsh_utils_ifu.h>
#include <xsh_utils_image.h>
#include <xsh_utils_imagelist.h>
#include <xsh_utils_wrappers.h>
#include <xsh_utils_table.h>
#include <xsh_pfits.h>
#include <xsh_model_io.h>
#include <xsh_data_rec.h>
#include <xsh_data_spectrum.h>
#include <xsh_dfs.h>
#include <xsh_drl.h>
#include <xsh_globals.h>

Go to the source code of this file.

Macros

#define PI_NUMB   (3.1415926535897932384626433832795)
 

Functions

static double xsh_interpol (double x, double x1, double x2, double y1, double y2)
 
static void xsh_plist_set_coord1 (cpl_propertylist **plist, const double crpix1, const double crval1, const double cdelt1)
 set world coordinate system
 
static void xsh_plist_set_coord2 (cpl_propertylist **plist, const double crpix2, const double crval2, const double cdelt2)
 set world coordinate system
 
static void xsh_plist_set_coord3 (cpl_propertylist **plist, const int crpix3, const double crval3, const double cdelt3)
 set world coordinate system
 
static void xsh_plist_set_cd_matrix2 (cpl_propertylist **plist, const double cd1_1, const double cd1_2, const double cd2_1, const double cd2_2)
 set world coordinate system: CD matrix
 
static void xsh_plist_set_cd_matrix3 (cpl_propertylist **plist, const double cd1_3, const double cd2_3, const double cd3_1, const double cd3_2, const double cd3_3)
 set world coordinate system: CD matrix
 
xsh_change_plist_cube

set world coordinate system for a cube

Parameters
plistinput propertylist
namefile name
cenLambdacentral wawelength
dispersiondispersion
cenpixcentral pixel
center_xcenter x
center_ycenter y
cpl_error_code xsh_cube_set_wcs (cpl_propertylist *plist, float cenLambda, float disp_x, float disp_y, float disp_z, float center_x, float center_y, int center_z)
 
void xsh_edge_check (const int px, const int nx, const int rad_x, int *llx, int *urx)
 check edge values (llx,urx) fit in image size (1,nx)
 
void xsh_convert_xy_to_ws (double x_centroid, double *p_obj_cen, double *p_slit, double *p_wave, const int lly, const int nx, const int row, double *p_obj_cen_s, double *p_obj_cen_w)
 convert X-Y coordinates to Wavelengt Slit space
 
cpl_error_code xsh_table_edges_swap_low_upp (cpl_table **tab)
 swap lower and upper edge columns
 
cpl_table * xsh_table_edge_prepare (const char *name)
 Add to edges table columns to store LOW/CEN/UPP object positions.
 
cpl_error_code xsh_ifu_trace_object_calibrate (const char *ifu_object_ff_name, const char *order_tab_edges_ifu_name, const char *slit_map_name, const char *wave_map_name)
 Function to calibrate object traces in IFU mode.
 
cpl_error_code xsh_frame_check_model_cfg_is_proper_for_sci (cpl_frame *model_config_frame, cpl_frame *sci_frame, xsh_instrument *instrument)
 Check if a model configuration frame has been corrected for flexures.
 
cpl_error_code xsh_frame_check_model_cfg_is_afc_corrected (cpl_frame *model_config_frame)
 utility to check if a frame has been corrected for flexures
 
static cpl_error_code xsh_add_correct_coeff (cpl_table **table, cpl_propertylist *plist, const char *prefix, const int row, const char *col12, const char *col32)
 
static cpl_frame * xsh_crea_correct_coeff (cpl_frame *qc_trace_merged_frame, xsh_instrument *inst)
 
static cpl_frame * xsh_frame_build_sky_area (cpl_frame *slitmap_frame, const char *tag)
 
static cpl_frame * xsh_frame_build_sky_map (cpl_frame *slitmap_frame, const double value, const char *tag)
 
cpl_frame * xsh_build_ifu_map (cpl_frame *div_frame, cpl_frame *wavemap_frame, cpl_frame *slitmap_frame, xsh_instrument *instrument)
 Reconstruct IFU cube.
 
static cpl_error_code xsh_monitor_spectrum3D_flux_qc (cpl_imagelist *data, cpl_imagelist *errs, cpl_imagelist *qual, cpl_propertylist *phead, const double wave_s, const double wave_e, const int index)
 
static cpl_error_code xsh_monitor_spectrum3D_flux (cpl_imagelist *data, cpl_imagelist *errs, cpl_imagelist *qual, xsh_instrument *instrument, cpl_propertylist *phead)
 Computes flux, err, SNR on IFU cube over full range and sub intervals.
 
cpl_error_code xsh_build_ifu_cube (cpl_frame *div_frame, cpl_frame *ifu_cfg_tab_frame, cpl_frame *ifu_cfg_cor_frame, cpl_frame *spectral_format_frame, cpl_frame *model_config_frame, cpl_frame *wavesol_frame, xsh_instrument *instrument, cpl_frameset *frameset, cpl_parameterlist *parameters, xsh_rectify_param *rectify_par, const char *recipe_id, const char *rec_prefix, const int frame_is_object)
 Reconstruct IFU cube.
 
cpl_matrix * xsh_atrous (cpl_vector *spec, int nscales)
 Do a wavelet decomposition using atrous from IDL.
 
cpl_frameset * xsh_shift_offsettab (cpl_frameset *shiftifu_frameset, double offset_low, double offset_up)
 Do a wavelet decomposition using atrous from IDL.
 

Macro Definition Documentation

◆ PI_NUMB

#define PI_NUMB   (3.1415926535897932384626433832795)

Definition at line 46 of file xsh_utils_ifu.c.

Function Documentation

◆ xsh_add_correct_coeff()

static cpl_error_code xsh_add_correct_coeff ( cpl_table **  table,
cpl_propertylist *  plist,
const char *  prefix,
const int  row,
const char *  col12,
const char *  col32 
)
static

Definition at line 1077 of file xsh_utils_ifu.c.

References check.

Referenced by xsh_crea_correct_coeff().

◆ xsh_atrous()

cpl_matrix * xsh_atrous ( cpl_vector *  spec,
int  nscales 
)

Do a wavelet decomposition using atrous from IDL.

Parameters
[in]specspectrum
[in]nscalesnumber os scales
Returns
matrix of wavelet decomposition

Definition at line 2379 of file xsh_utils_ifu.c.

References check, filter, smooth(), XSH_ASSURE_NOT_ILLEGAL, XSH_ASSURE_NOT_NULL, XSH_CALLOC, XSH_FREE, xsh_free_matrix(), xsh_free_vector(), xsh_msg_dbg_medium, and xsh_unwrap_vector().

Referenced by main(), and xsh_localize_ifu_slitlet().

◆ xsh_build_ifu_cube()

cpl_error_code xsh_build_ifu_cube ( cpl_frame *  div_frame,
cpl_frame *  ifu_cfg_tab_frame,
cpl_frame *  ifu_cfg_cor_frame,
cpl_frame *  spectral_format_frame,
cpl_frame *  model_config_frame,
cpl_frame *  wavesol_frame,
xsh_instrument instrument,
cpl_frameset *  frameset,
cpl_parameterlist *  parameters,
xsh_rectify_param rectify_par,
const char *  recipe_id,
const char *  rec_prefix,
const int  frame_is_object 
)

Reconstruct IFU cube.

Parameters
[in]div_frameinput frame flat field corrected
[in]ifu_cfg_tab_frameIFU configuration frame
[in]ifu_cfg_cor_frameIFU configuration frame
[in]spectral_format_framespectral format frame
[in]model_config_framemodel configuration frame
[in]wavesol_framewavelength solution frame
[in]instrumentinstrument (arm) setting
[in]framesetinput frame set
[in]parametersinput parameter list
[in]rectify_parinput parameters to specify rectification
[in]recipe_idinput recipe id
[in]rec_prefixinput recipe prefix
[in]frame_is_objectflag to specify if input frame is object or sky
Returns
corrected table

Definition at line 1523 of file xsh_utils_ifu.c.

References xsh_instrument::arm, binx, biny, check, xsh_instrument::decode_bp, instrument, xsh_rectify_param::kernel_type, method, nx, ny, QFLAG_MISSING_DATA, xsh_rectify_param::rectif_bin_lambda, xsh_rectify_param::rectif_bin_space, xsh_rectify_param::rectif_radius, s, x, xsh_add_product_imagelist(), xsh_add_product_table(), xsh_add_temporary_file(), XSH_ARM_NIR, xsh_arm_tostring(), XSH_ARM_UVB, XSH_ARM_VIS, xsh_crea_correct_coeff(), xsh_cube_qc_trace_window(), xsh_cube_set_wcs(), xsh_frame_product(), xsh_free_frame(), xsh_free_image(), xsh_free_imagelist(), xsh_free_propertylist(), xsh_free_table(), xsh_free_vector(), xsh_imagelist_cut_dichroic_uvb(), xsh_iml_merge_wgt(), xsh_model_binxy(), xsh_model_config_load_best(), xsh_model_get_xy(), xsh_monitor_spectrum3D_flux(), xsh_msg, xsh_msg_debug, xsh_parameters_cut_uvb_spectrum_get(), xsh_pfits_get_binx(), xsh_pfits_get_biny(), xsh_pfits_set_extname(), xsh_pfits_set_pcatg(), xsh_plist_set_extra_keys(), XSH_PRE_DATA_TYPE, XSH_PRE_ERRS_TYPE, XSH_PRE_QUAL_TYPE, xsh_rec_list_create(), xsh_rec_list_free(), XSH_SPECTRUM_DATA_BPP, XSH_SPECTRUM_ERRS_BPP, XSH_SPECTRUM_QUAL_BPP, xsh_wavesol_eval_polx(), xsh_wavesol_eval_poly(), xsh_wavesol_load(), and y.

Referenced by xsh_scired_ifu_offset(), and xsh_scired_ifu_stare().

◆ xsh_build_ifu_map()

cpl_frame * xsh_build_ifu_map ( cpl_frame *  div_frame,
cpl_frame *  wavemap_frame,
cpl_frame *  slitmap_frame,
xsh_instrument instrument 
)

Reconstruct IFU cube.

Parameters
[in]div_frameinput frame flat field corrected
[in]wavemap_frameslit map frame
[in]slitmap_framewave map frame
[in]model_config_framemodel configuration frame
[in]instrumentinstrument (arm) setting
Returns
corrected table

Definition at line 1248 of file xsh_utils_ifu.c.

References check, instrument, xsh_add_temporary_file(), xsh_frame_build_sky_area(), xsh_frame_build_sky_map(), xsh_frame_image_save2ext(), xsh_frame_product(), xsh_free_image(), xsh_free_propertylist(), xsh_hms2deg(), XSH_IFU_MAP_SKY, xsh_instrument_arm_tostring(), xsh_pfits_get_tel_targ_alpha(), xsh_pfits_get_tel_targ_delta(), and xsh_sess2deg().

Referenced by xsh_scired_ifu_offset(), and xsh_scired_ifu_stare().

◆ xsh_convert_xy_to_ws()

void xsh_convert_xy_to_ws ( double  x_centroid,
double *  p_obj_cen,
double *  p_slit,
double *  p_wave,
const int  lly,
const int  nx,
const int  row,
double *  p_obj_cen_s,
double *  p_obj_cen_w 
)

convert X-Y coordinates to Wavelengt Slit space

Parameters
x_centroidcentrod position on X axis
p_obj_cen[IN] pointer to central object array
p_slit[IN] pointer to slit array
p_wave[IN] pointer to wave array
lly[IN] Lower left X
nx[IN] number of X points (vector size) l
row[IN] detector row position(Y)
p_obj_cen_s[OUT] pointer to object s position
p_obj_cen_w[OUT] pointer to object s position
Returns
void

Definition at line 460 of file xsh_utils_ifu.c.

References lly, nx, and xsh_interpol().

Referenced by xsh_ifu_trace_object_calibrate().

◆ xsh_crea_correct_coeff()

static cpl_frame * xsh_crea_correct_coeff ( cpl_frame *  qc_trace_merged_frame,
xsh_instrument inst 
)
static

◆ xsh_cube_set_wcs()

cpl_error_code xsh_cube_set_wcs ( cpl_propertylist *  plist,
float  cenLambda,
float  disp_x,
float  disp_y,
float  disp_z,
float  center_x,
float  center_y,
int  center_z 
)

◆ xsh_edge_check()

void xsh_edge_check ( const int  px,
const int  nx,
const int  rad_x,
int *  llx,
int *  urx 
)

check edge values (llx,urx) fit in image size (1,nx)

Parameters
px[IN] point position
nx[IN] x image size
rad_x[IN] x radii
llx[OUT] lower left X
urx[OUT] upper right X
Returns
void

Definition at line 428 of file xsh_utils_ifu.c.

References llx, nx, and urx.

Referenced by xsh_ifu_trace_object_calibrate().

◆ xsh_frame_build_sky_area()

static cpl_frame * xsh_frame_build_sky_area ( cpl_frame *  slitmap_frame,
const char *  tag 
)
static

Definition at line 1155 of file xsh_utils_ifu.c.

References check, xsh_free_image(), xsh_free_propertylist(), and XSH_PRE_DATA_BPP.

Referenced by xsh_build_ifu_map().

◆ xsh_frame_build_sky_map()

static cpl_frame * xsh_frame_build_sky_map ( cpl_frame *  slitmap_frame,
const double  value,
const char *  tag 
)
static

◆ xsh_frame_check_model_cfg_is_afc_corrected()

cpl_error_code xsh_frame_check_model_cfg_is_afc_corrected ( cpl_frame *  model_config_frame)

utility to check if a frame has been corrected for flexures

Parameters
model_config_frameinput frame
Returns
corrected table

Definition at line 1053 of file xsh_utils_ifu.c.

References check, xsh_free_propertylist(), xsh_msg_error, and xsh_pfits_get_raw1catg().

Referenced by xsh_check_afc(), and xsh_scired_ifu_stare().

◆ xsh_frame_check_model_cfg_is_proper_for_sci()

cpl_error_code xsh_frame_check_model_cfg_is_proper_for_sci ( cpl_frame *  model_config_frame,
cpl_frame *  sci_frame,
xsh_instrument instrument 
)

Check if a model configuration frame has been corrected for flexures.

Parameters
model_config_framemodel configuration frame
sci_framescience frame
instrumentinstrument setting
Returns
cpl error code

Definition at line 984 of file xsh_utils_ifu.c.

References check, instrument, xsh_free_propertylist(), xsh_msg_error, xsh_pfits_get_obs_id(), xsh_pfits_get_obs_targ_name(), and xsh_pfits_get_slit_value().

Referenced by xsh_check_afc(), and xsh_scired_ifu_stare().

◆ xsh_ifu_trace_object_calibrate()

cpl_error_code xsh_ifu_trace_object_calibrate ( const char *  ifu_object_ff_name,
const char *  order_tab_edges_ifu_name,
const char *  slit_map_name,
const char *  wave_map_name 
)

Function to calibrate object traces in IFU mode.

Parameters
ifu_object_ff_namename of input object frame (flat field corrected)
order_tab_edges_ifu_namename of input edge order table
slit_map_nameslit map filename
wave_map_namewave map filename
Returns
cpl error code

Definition at line 701 of file xsh_utils_ifu.c.

References biny, check, llx, lly, nx, ny, urx, ury, XSH_ARM_NIR, xsh_arm_tostring(), XSH_ARM_UNDEFINED, XSH_ARM_UVB, XSH_ARM_VIS, xsh_convert_xy_to_ws(), xsh_edge_check(), xsh_free_image(), xsh_free_propertylist(), xsh_image_fit_gaussian_max_pos_x_window(), xsh_msg, xsh_pfits_get_biny(), xsh_pfits_get_pcatg(), xsh_pfits_set_pcatg(), xsh_table_edge_prepare(), and xsh_table_edges_swap_low_upp().

Referenced by xsh_scired_ifu_stare().

◆ xsh_interpol()

static double xsh_interpol ( double  x,
double  x1,
double  x2,
double  y1,
double  y2 
)
static

Definition at line 49 of file xsh_utils_ifu.c.

References x.

Referenced by xsh_convert_xy_to_ws().

◆ xsh_monitor_spectrum3D_flux()

static cpl_error_code xsh_monitor_spectrum3D_flux ( cpl_imagelist *  data,
cpl_imagelist *  errs,
cpl_imagelist *  qual,
xsh_instrument instrument,
cpl_propertylist *  phead 
)
static

Computes flux, err, SNR on IFU cube over full range and sub intervals.

Parameters
[in]datacube
[in]errscube
[in]qualcube
[in]instrumentto specify detector's arm
[in/out]phead primary header to be updated
Note
wavelength is expected to increase along the cube Z axis
Returns
cpl_error_code

Definition at line 1458 of file xsh_utils_ifu.c.

References check, instrument, XSH_ARM_NIR, XSH_ARM_UVB, XSH_ARM_VIS, xsh_instrument_get_arm(), and xsh_monitor_spectrum3D_flux_qc().

Referenced by xsh_build_ifu_cube().

◆ xsh_monitor_spectrum3D_flux_qc()

static cpl_error_code xsh_monitor_spectrum3D_flux_qc ( cpl_imagelist *  data,
cpl_imagelist *  errs,
cpl_imagelist *  qual,
cpl_propertylist *  phead,
const double  wave_s,
const double  wave_e,
const int  index 
)
static

◆ xsh_plist_set_cd_matrix2()

static void xsh_plist_set_cd_matrix2 ( cpl_propertylist **  plist,
const double  cd1_1,
const double  cd1_2,
const double  cd2_1,
const double  cd2_2 
)
static

set world coordinate system: CD matrix

Parameters
plistinput propertylist
cd1_1value of CD1_1
cd1_2value of CD1_2
cd2_1value of CD2_1
cd2_2value of CD2_2
Returns
updated propertylist

Definition at line 220 of file xsh_utils_ifu.c.

References check.

Referenced by xsh_cube_set_wcs().

◆ xsh_plist_set_cd_matrix3()

static void xsh_plist_set_cd_matrix3 ( cpl_propertylist **  plist,
const double  cd1_3,
const double  cd2_3,
const double  cd3_1,
const double  cd3_2,
const double  cd3_3 
)
static

set world coordinate system: CD matrix

Parameters
plistinput propertylist
cd1_3value of CD1_3
cd2_3value of CD2_3
cd3_1value of CD3_1
cd3_2value of CD3_2
cd3_3value of CD3_3
Returns
updated propertylist

Definition at line 271 of file xsh_utils_ifu.c.

References check.

Referenced by xsh_cube_set_wcs().

◆ xsh_plist_set_coord1()

static void xsh_plist_set_coord1 ( cpl_propertylist **  plist,
const double  crpix1,
const double  crval1,
const double  cdelt1 
)
static

set world coordinate system

Parameters
plistinput propertylist
crpix1value of CRPIX1 (ref pixel axis 1 coord in pix coordinates)
crval1value of CRVAL1 (ref pixel axis 1 coord in sky coordinates)
cdelt1value of CDELT1 (ref pixel axis 1 size )
Returns
updated propertylist

Definition at line 99 of file xsh_utils_ifu.c.

Referenced by xsh_cube_set_wcs().

◆ xsh_plist_set_coord2()

static void xsh_plist_set_coord2 ( cpl_propertylist **  plist,
const double  crpix2,
const double  crval2,
const double  cdelt2 
)
static

set world coordinate system

Parameters
plistinput propertylist
crpix2value of CRPIX2 (ref pixel axis 2 coord in pix coordinates)
crval2value of CRVAL2 (ref pixel axis 2 coord in sky coordinates)
cdelt2value of CDELT2 (ref pixel axis 2 size )
Returns
updated propertylist

Definition at line 136 of file xsh_utils_ifu.c.

Referenced by xsh_cube_set_wcs().

◆ xsh_plist_set_coord3()

static void xsh_plist_set_coord3 ( cpl_propertylist **  plist,
const int  crpix3,
const double  crval3,
const double  cdelt3 
)
static

set world coordinate system

Parameters
plistinput propertylist
crpix3value of CRPIX3 (ref pixel axis 3 coord in pix coordinates)
crval3value of CRVAL3 (ref pixel axis 3 coord in sky coordinates)
cdelt3value of CDELT3 (ref pixel axis 3 size )
Returns
updated propertylist

Definition at line 175 of file xsh_utils_ifu.c.

Referenced by xsh_cube_set_wcs().

◆ xsh_shift_offsettab()

cpl_frameset * xsh_shift_offsettab ( cpl_frameset *  shiftifu_frameset,
double  offset_low,
double  offset_up 
)

Do a wavelet decomposition using atrous from IDL.

Parameters
[in]specspectrum
[in]nscalesnumber os scales
Returns
matrix of wavelet decomposition

Definition at line 2467 of file xsh_utils_ifu.c.

References check, size, xsh_frame_product(), xsh_free_frameset(), xsh_free_propertylist(), xsh_msg, XSH_SHIFTIFU_COLNAME_SHIFTSLIT, XSH_TABLE_FREE, and XSH_TABLE_LOAD.

Referenced by xsh_scired_ifu_offset(), and xsh_scired_ifu_stare().

◆ xsh_table_edge_prepare()

cpl_table * xsh_table_edge_prepare ( const char *  name)

Add to edges table columns to store LOW/CEN/UPP object positions.

Parameters
name[IN] input file name
Returns
corrected table

Definition at line 547 of file xsh_utils_ifu.c.

References check.

Referenced by xsh_ifu_trace_object_calibrate().

◆ xsh_table_edges_swap_low_upp()

cpl_error_code xsh_table_edges_swap_low_upp ( cpl_table **  tab)

swap lower and upper edge columns

Parameters
tab[INOUT] pointer to input/output table
Returns
if no error, CPL_ERROR_NONE

Definition at line 504 of file xsh_utils_ifu.c.

Referenced by xsh_ifu_trace_object_calibrate().