ERIS Pipeline Reference Manual 1.8.14
Functions
IFU Miscellaneous Functions

Functions

ifsInstrument eris_ifu_get_instrument_frame (cpl_frame *frame)
 Return value of INSTRUME from a given input frame.
 
hdrl_image * eris_ifu_raw_hdrl_image (const cpl_image *cplImage)
 Return an HDRL image containing a noise image as well.
 
cpl_image * eris_ifu_calc_noise_map (const cpl_image *data, double gain, double readnoise)
 Return an HDRL image containing a noise image.
 
hdrl_imagelist * eris_ifu_load_exposure_frameset (const cpl_frameset *frameset, int exposureCorrectionMode)
 Read a raw detector exposure, perform some correction, add noise data.
 
hdrl_image * eris_ifu_load_exposure_frame (const cpl_frame *frame, int exposureCorrectionMode, cpl_image *dqi)
 Read a raw detector exposure, perform some correction, add noise data.
 
cpl_error_code eris_ifu_add_badpix_border (cpl_image *data, cpl_boolean add_ones, cpl_image *dqi)
 Add image border frame to bad pixel map.
 
hdrl_image * eris_ifu_load_exposure_file (const char *filename, int exposureCorrectionMode, cpl_image *dqi)
 Read a raw detector exposure, perform some correction, add noise data.
 
cpl_mask * eris_ifu_detect_crh (hdrl_image *image, int exposureCorrectionMode, hdrl_parameter *laCosmicParams, bool maskImage)
 Detect Cosmic Ray Hits.
 
cpl_error_code eris_ifu_saturation_detection (cpl_image *image, cpl_image *dqi)
 Detect saturated pixel and mask them as bad pixels.
 
cpl_error_code eris_ifu_exposure_line_correction (cpl_image *image)
 Perform line correction on a raw detector image.
 
cpl_error_code eris_ifu_exposure_column_correction (cpl_image *image)
 Perform column correction on a raw detector image.
 
cpl_error_code eris_ifu_calc_bpm (const cpl_parameterlist *pl, const char *recipe_name, hdrl_image *master_img, const hdrl_imagelist *imglist_on, cpl_mask **bpm2dMask, cpl_mask **bpm3dMask)
 Create and apply 2D and/or 3D Badpixel-Mask based on parameter.
 
hdrl_image * eris_ifu_warp_polynomial_image (const hdrl_image *hdrlInImg, const cpl_polynomial *poly_u, const cpl_polynomial *poly_v)
 eris_ifu_warp_polynomial_image
 
cpl_vector * eris_ifu_polyfit_1d (const cpl_vector *x, const cpl_vector *y, const int degree)
 An easy-to-handle wrapper to cpl_polynomial_fit() to fit a vector.
 
cpl_error_code eris_ifu_1d_interpolation (double *xIn, double *yIn, int nIn, double *xOut, double *yOut, int nOut, const int interType)
 Perform 1D interpolation using GSL routines.
 
double eris_ifu_image_get_mean (const cpl_image *image)
 ‍**
 
cpl_vector * eris_ifu_calc_centers_collapse_chunk (const cpl_image *img, int chunk_center, int height)
 
cpl_vector * eris_ifu_image_collapse (const cpl_image *img)
 
cpl_error_code eris_ifu_slitpos_gauss (const cpl_image *profile_x, double *left_edge_pos, double *right_edge_pos, int llx, int productDepth)
 eris_ifu_dist_slitpos_gauss
 
cpl_error_code eris_ifu_bpm_correction (hdrl_image *himg, hdrl_image *badPixelMaskImg)
 eris_ifu_bpm_correction
 

Detailed Description

Function Documentation

◆ eris_ifu_1d_interpolation()

cpl_error_code eris_ifu_1d_interpolation ( double *  xIn,
double *  yIn,
int  nIn,
double *  xOut,
double *  yOut,
int  nOut,
const int  interType 
)

Perform 1D interpolation using GSL routines.

Parameters
xIn(intput) x values of input data set points
yIn(intput) y values of input data set points
nIn(intput) number of input data set points
xOut(input) x values of points to be interpolated
yOut(output) dependent y values for xOut points
nOut(input) number of output data points
interType(intput) type of interpolation

The intertype parameter can have following values:

interType > 2: polynomial interpolation, polynomial degree is interType-1 For the interpolation a box car with a number of "interTpye" samples is used. interType 2: linear interpolation intertype -1: Cubic spline with natural boundary conditions. The resulting curve is piecewise cubic on each interval, with matching first and second derivatives at the supplied data points. The second derivative is chosen to be zero at the first point and last point.

intertype -2: cubic spline with periodic boundary conditions. The resulting curve is piecewise cubic on each interval, with matching first and second derivatives at the supplied data points. The derivatives at the first and last points are also matched. Note that the last point in the data must have the same y-value as the first point, otherwise the resulting periodic interpolation will have a discontinuity at the boundary.

intertype -3: Non-rounded Akima spline with natural boundary conditions. This method uses the non-rounded corner algorithm of Wodicka.

intertype -4: Non-rounded Akima spline with periodic boundary conditions. This method uses the non-rounded corner algorithm of Wodicka.

intertype -5: Steffen's method guarantees the monotonicity of the interpolating function between the given data points. Therefore, minima and maxima can only occur exactly at the data points, and there can never be spurious oscillations between data points. The interpolated function is piecewise cubic in each interval. The resulting curve and its first derivative are guaranteed to be continuous, but the second derivative may be discontinuous.

Returns
CPL_ERROR_NONE on success, otherwise the relevant CPL error code

Definition at line 1636 of file eris_ifu_functions.c.

References ASSURE, BRK_WITH_ERROR_MSG, CATCH, eris_check_error_code(), eris_ifu_free_double_array(), and TRY.

◆ eris_ifu_add_badpix_border()

cpl_error_code eris_ifu_add_badpix_border ( cpl_image *  data,
cpl_boolean  add_ones,
cpl_image *  dqi 
)

Add image border frame to bad pixel map.

Parameters
datainput image
add_onesswitch to set flagged pixels to 1 or not
dqiinput bad pixel (data quality) map
Returns
CPL_ERROR_NONE if OK

Definition at line 246 of file eris_ifu_functions.c.

References CATCH, CHECK_ERROR_STATE, eris_check_error_code(), and TRY.

Referenced by eris_ifu_load_exposure_file().

◆ eris_ifu_bpm_correction()

cpl_error_code eris_ifu_bpm_correction ( hdrl_image *  himg,
hdrl_image *  badPixelMaskImg 
)

eris_ifu_bpm_correction

Parameters
image2D hdrl image to be corrected
badPixelMaskImgMaster bad pixel image
Returns
Error in case of error

Correct the bad pixels of the image by taking the average of the 4 neighboring pixels

Definition at line 2347 of file eris_ifu_functions.c.

References eris_check_error_code(), hdrl_image_get_error(), hdrl_image_get_error_const(), hdrl_image_get_image(), hdrl_image_get_image_const(), hdrl_image_get_mask(), hdrl_image_get_mask_const(), hdrl_image_get_size_x(), hdrl_image_get_size_y(), hdrl_image_insert(), and hdrl_image_new().

◆ eris_ifu_calc_bpm()

cpl_error_code eris_ifu_calc_bpm ( const cpl_parameterlist *  pl,
const char *  recipe_name,
hdrl_image *  master_img,
const hdrl_imagelist *  imglist_on,
cpl_mask **  bpm2dMask,
cpl_mask **  bpm3dMask 
)

Create and apply 2D and/or 3D Badpixel-Mask based on parameter.

Parameters
plinput parameter list
recipe_nameinput recipe name
master_imginput (HDRL) image
imglist_oninput HDRL list of on images
bpm2dMaskoutput bad pixel mask with flagged pixels with method 2D
bpm3dMaskoutput bad pixel mask with flagged pixels with method 3D
Returns
CPL_ERROR_NONE on success, otherwise the relevant CPL error code

Definition at line 727 of file eris_ifu_functions.c.

References CATCH, CHECK_ERROR_STATE, eris_check_error_code(), eris_ifu_free_hdrl_parameter(), eris_ifu_free_image(), eris_ifu_free_imagelist(), eris_ifu_free_mask(), eris_ifu_free_string(), hdrl_bpm_2d_compute(), hdrl_bpm_2d_parameter_parse_parlist(), hdrl_bpm_3d_compute(), hdrl_bpm_3d_parameter_parse_parlist(), hdrl_image_get_mask(), hdrl_image_get_size_x(), hdrl_image_get_size_y(), hdrl_image_reject_from_mask(), and TRY.

◆ eris_ifu_calc_centers_collapse_chunk()

cpl_vector * eris_ifu_calc_centers_collapse_chunk ( const cpl_image *  img,
int  chunk_center,
int  height 
)

takes horizontal chuck of an image, collapses it in y

Definition at line 2012 of file eris_ifu_functions.c.

References CATCH, CATCH_MSGS, eris_check_error_code(), eris_ifu_free_image(), eris_ifu_free_vector(), and TRY.

◆ eris_ifu_calc_noise_map()

cpl_image * eris_ifu_calc_noise_map ( const cpl_image *  data,
double  gain,
double  readnoise 
)

Return an HDRL image containing a noise image.

Parameters
datainput image data
gaininput gain
readnoiseinout read-out-noise
Returns
HDRL image with data and noise

Possible cpl_error_code set in this function:

  • CPL_ERROR_NULL_INPUT The CPL image is a NULL pointer

Definition at line 130 of file eris_ifu_functions.c.

References BRK_IF_NULL, CATCH, CATCH_MSG, eris_check_error_code(), eris_ifu_free_image(), and TRY.

Referenced by eris_ifu_load_exposure_file(), and eris_ifu_raw_hdrl_image().

◆ eris_ifu_detect_crh()

cpl_mask * eris_ifu_detect_crh ( hdrl_image *  image,
int  exposureCorrectionMode,
hdrl_parameter *  laCosmicParams,
bool  maskImage 
)

Detect Cosmic Ray Hits.

Parameters
imageinput (HDRL) image
exposureCorrectionModedata correction to be applied
laCosmicParamsHDRL parameters controlling LA-cosmic detection
maskImagemask or not flagged pixels from the input (HDRL) image
Returns
HDRL mask flagged pixels

The exposureCorrectionMode parameter is a bit coded value to specify the required corrections. When more than one correction is requested the mode values can be concatenated using the OR operator.

Definition at line 446 of file eris_ifu_functions.c.

References BRK_IF_ERROR, CATCH, CATCH_MSGS, eris_check_error_code(), eris_ifu_free_mask(), hdrl_image_reject_from_mask(), hdrl_lacosmic_edgedetect(), and TRY.

◆ eris_ifu_exposure_column_correction()

cpl_error_code eris_ifu_exposure_column_correction ( cpl_image *  image)

Perform column correction on a raw detector image.

Parameters
image
Returns
CPL error code

The detector is read out in vertical direction. Hence, artefacts in the vertical direction can be due to a read out problem. Sometimes a pattern of columns can be seen of which every second is too bright and every other is too dark.

The correction is done by subtracting the median of 4 reference pixels located at the top and bottom of the detector.

Possible cpl_error_code set in this function:

  • CPL_ERROR_NULL_INPUT The CPL image is a NULL pointer
  • CPL_TYPE_INVALID The image has less two times the border size rows

Definition at line 644 of file eris_ifu_functions.c.

References BRK_IF_NULL, BRK_WITH_ERROR_MSG, CATCH, CHECK_ERROR_STATE, eris_check_error_code(), eris_ifu_free_vector(), and TRY.

Referenced by eris_ifu_load_exposure_file().

◆ eris_ifu_exposure_line_correction()

cpl_error_code eris_ifu_exposure_line_correction ( cpl_image *  image)

Perform line correction on a raw detector image.

Parameters
image
Returns
CPL error code

The read-out electronics subtracts the mean of the 4 reference pixel located at the left and right border of the detector image. This is done on purpose to remove the row-number dependent bias. However a bad (hot) pixel has a strong impact on the mean value. Therefore this function replaces the mean by the median value which is less affected by out-lyers.

Possible cpl_error_code set in this function:

  • CPL_ERROR_NULL_INPUT The CPL image is a NULL pointer
  • CPL_TYPE_INVALID The image has less two times the border size columns

Definition at line 548 of file eris_ifu_functions.c.

References BRK_IF_NULL, BRK_WITH_ERROR_MSG, CATCH, CHECK_ERROR_STATE, eris_check_error_code(), eris_ifu_free_vector(), and TRY.

Referenced by eris_ifu_load_exposure_file().

◆ eris_ifu_get_instrument_frame()

ifsInstrument eris_ifu_get_instrument_frame ( cpl_frame *  frame)

Return value of INSTRUME from a given input frame.

Parameters
frameinput frame
Returns
value of INSTRUME FITS keyword

Definition at line 58 of file eris_ifu_functions.c.

References BRK_WITH_ERROR, CATCH, CHECK_ERROR_STATE, eris_check_error_code(), eris_ifu_free_propertylist(), eris_ifu_get_instrument(), and TRY.

Referenced by eris_ifu_dfs_set_groups().

◆ eris_ifu_image_collapse()

cpl_vector * eris_ifu_image_collapse ( const cpl_image *  img)

collapses image in y and converts to vector

Definition at line 2063 of file eris_ifu_functions.c.

References CATCH, CATCH_MSGS, eris_check_error_code(), eris_ifu_free_image(), eris_ifu_free_vector(), and TRY.

◆ eris_ifu_image_get_mean()

double eris_ifu_image_get_mean ( const cpl_image *  image)

‍**

Calculate the mean of an image ignoring NaN values.

Parameters
imageImage to be averaged.
Returns
The mean.

Possible cpl_error_code set in this function:

  • CPL_ERROR_NULL_INPUT if data is NULL.

Definition at line 1827 of file eris_ifu_functions.c.

References BRK_IF_NULL, CATCH, CATCH_MSGS, eris_check_error_code(), and TRY.

◆ eris_ifu_load_exposure_file()

hdrl_image * eris_ifu_load_exposure_file ( const char *  filename,
int  exposureCorrectionMode,
cpl_image *  dqi 
)

Read a raw detector exposure, perform some correction, add noise data.

Parameters
filenameof the detector exposure FITS file
exposureCorrectionModedata correction to be applied
dqiinput bad pixel (data quality) map if not NULL will be filled with a data quality image
Returns
HDRL image containing data and noise images

The exposureCorrectionMode parameter is a bit coded value to specify the required corrections. When more than one correction is requested the mode values can be concatenated using the OR operator.

The list of corrections are:

  • LINE_EXPOSURE_CORRECTION Correct for bad lines
    See also
    eris_ifu_exposure_line_correction()
  • COLUMN_EXPOSURE_CORRECTION Correct for bad columns
    See also
    eris_ifu_exposure_column_correction()
  • COSMIC_RAY_EXPOSURE_CORRECTION Correct for cosmic rays (not yet implemented)
  • COSMIC_RAY_EXPOSURE_DETECTION Detect cosmic rays and mark the pixels as bad (not yet implemented)

The bad pixel mask of returned HDRL image is set with the border pixels and the detected saturated pixels. The DQI (data quality image) holds a more detailed about which why a pixel is rejected. bit number bit value description 4 8 saturated pixel 5 16 border pixel (the first/last 4 rows/columns)

Detected cosmic ray hits may be added in future.

Possible cpl_error_code set in this function:

  • CPL_ERROR_NULL_INPUT The CPL image is a NULL pointer
  • CPL_TYPE_INVALID The image has less two times the border size columns
  • CPL_TYPE_INVALID The image has less two times the border size rows

Definition at line 362 of file eris_ifu_functions.c.

References CATCH, CATCH_MSGS, CHECK_ERROR_STATE, eris_check_error_code(), eris_ifu_add_badpix_border(), eris_ifu_calc_noise_map(), eris_ifu_exposure_column_correction(), eris_ifu_exposure_line_correction(), eris_ifu_free_hdrl_image(), eris_ifu_free_image(), eris_ifu_free_propertylist(), eris_ifu_get_instrument(), eris_ifu_saturation_detection(), hdrl_image_create(), and TRY.

Referenced by eris_ifu_get_hdrlimagelist_by_tag(), and eris_ifu_load_exposure_frame().

◆ eris_ifu_load_exposure_frame()

hdrl_image * eris_ifu_load_exposure_frame ( const cpl_frame *  frame,
int  exposureCorrectionMode,
cpl_image *  dqi 
)

Read a raw detector exposure, perform some correction, add noise data.

Parameters
frameCPL frame holding the file info of the detector FITS file
exposureCorrectionModedata correction to be applied
Returns
HDRL image containing data and noise images
Parameters
dqiinput bad pixel (data quality) map
See also
eris_ifu_load_exposure_file

Definition at line 213 of file eris_ifu_functions.c.

References CATCH, eris_check_error_code(), eris_ifu_load_exposure_file(), and TRY.

Referenced by eris_ifu_load_exposure_frameset().

◆ eris_ifu_load_exposure_frameset()

hdrl_imagelist * eris_ifu_load_exposure_frameset ( const cpl_frameset *  frameset,
int  exposureCorrectionMode 
)

Read a raw detector exposure, perform some correction, add noise data.

Parameters
framesetCPL frameset holding the file info of the detector FITS files
exposureCorrectionModedata correction to be applied
Returns
HDRL imagelist containing data and noise images
See also
eris_ifu_load_exposure_file

Definition at line 173 of file eris_ifu_functions.c.

References CATCH, eris_check_error_code(), eris_ifu_load_exposure_frame(), hdrl_imagelist_get_size(), hdrl_imagelist_new(), hdrl_imagelist_set(), and TRY.

◆ eris_ifu_polyfit_1d()

cpl_vector * eris_ifu_polyfit_1d ( const cpl_vector *  x,
const cpl_vector *  y,
const int  degree 
)

An easy-to-handle wrapper to cpl_polynomial_fit() to fit a vector.

Parameters
xPositions to fit.
yValues to fit.
degreeDegree of the polynomial to fit.
Returns
The function returns a vector with the fit parameters. Its length is degree + 1 The first value is the constant term: y(x) = fit_par[0] + fit_par[1]*x + fit_par[2]*x^2 + fit_par[3]*x^3 + ...

Possible cpl_error_code set in this function:

  • CPL_ERROR_NULL_INPUT any of the inputs is NULL.

Definition at line 1474 of file eris_ifu_functions.c.

References CATCH, CHECK_ERROR_STATE, eris_check_error_code(), eris_ifu_free_vector(), and TRY.

◆ eris_ifu_raw_hdrl_image()

hdrl_image * eris_ifu_raw_hdrl_image ( const cpl_image *  cplImage)

Return an HDRL image containing a noise image as well.

Parameters
cplImageas data
Returns
HDRL image with data and noise

Possible cpl_error_code set in this function:

  • CPL_ERROR_NULL_INPUT The CPL image is a NULL pointer

Definition at line 96 of file eris_ifu_functions.c.

References CATCH, eris_check_error_code(), eris_ifu_calc_noise_map(), hdrl_image_create(), and TRY.

◆ eris_ifu_saturation_detection()

cpl_error_code eris_ifu_saturation_detection ( cpl_image *  image,
cpl_image *  dqi 
)

Detect saturated pixel and mask them as bad pixels.

Parameters
image
dqiinput bad pixel (data quality) map

Definition at line 494 of file eris_ifu_functions.c.

References eris_check_error_code().

Referenced by eris_ifu_load_exposure_file().

◆ eris_ifu_slitpos_gauss()

cpl_error_code eris_ifu_slitpos_gauss ( const cpl_image *  profile_x,
double *  left_edge_pos,
double *  right_edge_pos,
int  llx,
int  productDepth 
)

eris_ifu_dist_slitpos_gauss

Parameters
profile_xIn y collapsed profile across detector
left_edge_pos(return) position of left edge ()
right_edge_pos(return) position of right edge
llxoffset in x for specific slitlet
productDepthlevel of verbosity
Returns
Error in case of error

The function extracts a small area around the left ascending edge and another around the descending right edge. The y-values are subtracted in order th get a peak at the edge. The peak will be fitted using a gauss-funtion.

Definition at line 2108 of file eris_ifu_functions.c.

References BRK_WITH_ERROR, CATCH, CATCH_MSGS, CHECK_ERROR_STATE, eris_check_error_code(), eris_ifu_free_vector(), eris_ifu_save_vector_dbg(), and TRY.

◆ eris_ifu_warp_polynomial_image()

hdrl_image * eris_ifu_warp_polynomial_image ( const hdrl_image *  hdrlInImg,
const cpl_polynomial *  poly_u,
const cpl_polynomial *  poly_v 
)