ERIS Pipeline Reference Manual 1.8.15
Enumerations | Functions
IFU Vector with Bad Pixel Masking

Enumerations

enum  medianType
 The type of median behavior: For an odd number of samples the behaviour is the same for both methods. For an even number of samples: More...
 

Functions

eris_ifu_vector * eris_ifu_vector_new (int n)
 Create a new eris_ifu_vector.
 
eris_ifu_vector * eris_ifu_vector_new_wrap (int n, const double *data)
 Create a new eris_ifu_vector from a C array (duplicated).
 
eris_ifu_vector * eris_ifu_vector_create (const cpl_vector *data)
 Create a new eris_ifu_vector out of a data cpl_vector.
 
eris_ifu_vector * eris_ifu_vector_create2 (const cpl_vector *data, const cpl_vector *mask)
 Create a new eris_ifu_vector out of a data and mask cpl_vector.
 
void eris_ifu_vector_delete (eris_ifu_vector *ev)
 Delete a eris_ifu_vector.
 
eris_ifu_vector * eris_ifu_vector_duplicate (const eris_ifu_vector *ev)
 This function duplicates an existing eris_ifu_vector and allocates memory.
 
cpl_error_code eris_ifu_vector_set (eris_ifu_vector *ev, int pos, double val)
 Set an element of the eris_ifu_vector.
 
double eris_ifu_vector_get_rej (const eris_ifu_vector *ev, int pos, int *rej)
 Get an element of the eris_ifu_vector.
 
double eris_ifu_vector_get (const eris_ifu_vector *ev, int pos)
 Get an element of the eris_ifu_vector.
 
cpl_vector * eris_ifu_vector_get_mask (const eris_ifu_vector *ev)
 Get a copy of the mask of eris_ifu_vector.
 
cpl_vector * eris_ifu_vector_get_data (const eris_ifu_vector *ev)
 Get a copy of the data, rejected values are set to NaN.
 
cpl_vector * eris_ifu_vector_get_bpm (eris_ifu_vector *ev)
 Get the pointer to the mask of the eris_ifu_vector.
 
cpl_error_code eris_ifu_vector_reject_from_mask (eris_ifu_vector *ev, const cpl_vector *mask, int keep)
 Set the rejected elements in an eris_ifu_vector as defined in a mask.
 
int eris_ifu_vector_count_rejected (const eris_ifu_vector *ev)
 Count the number of rejected elements in a eris_ifu_vector.
 
int eris_ifu_vector_count_non_rejected (const eris_ifu_vector *ev)
 Count the number of non-rejected elements in a eris_ifu_vector.
 
int eris_ifu_vector_is_rejected (const eris_ifu_vector *ev, int n)
 Test if a value is good or bad.
 
cpl_error_code eris_ifu_vector_reject (eris_ifu_vector *ev, int n)
 Set a value as rejected in a eris_ifu_vector.
 
eris_ifu_vector * eris_ifu_vector_extract (const eris_ifu_vector *ev, int istart, int istop)
 Extract a sub-vector from a eris_ifu_vector.
 
cpl_vector * eris_ifu_vector_create_non_rejected (const eris_ifu_vector *ev)
 Creates a cpl_vector out of a eris_ifu_vector with non-rejected values.
 
cpl_error_code eris_ifu_vector_adapt_rejected (eris_ifu_vector *kv1, eris_ifu_vector *kv2)
 Assert that rejected values on both vectors are the same.
 
cpl_error_code eris_ifu_vector_add (eris_ifu_vector *kv1, const eris_ifu_vector *kv2)
 Add a eris_ifu_vector to another.
 
cpl_error_code eris_ifu_vector_subtract (eris_ifu_vector *kv1, const eris_ifu_vector *kv2)
 Subtract two eris_ifu_vectors.
 
cpl_error_code eris_ifu_vector_multiply (eris_ifu_vector *kv1, const eris_ifu_vector *kv2)
 Multiply two eris_ifu_vectors.
 
cpl_error_code eris_ifu_vector_divide (eris_ifu_vector *kv1, const eris_ifu_vector *kv2)
 Divide two eris_ifu_vectors element-wise.
 
cpl_error_code eris_ifu_vector_add_scalar (eris_ifu_vector *ev, double addend)
 Elementwise addition of a scalar to a eris_ifu_vector.
 
cpl_error_code eris_ifu_vector_subtract_scalar (eris_ifu_vector *ev, double subtrahend)
 Elementwise subtraction of a scalar from a eris_ifu_vector.
 
cpl_error_code eris_ifu_vector_multiply_scalar (eris_ifu_vector *ev, double factor)
 Elementwise multiplication of a scalar to a eris_ifu_vector.
 
cpl_error_code eris_ifu_vector_divide_scalar (eris_ifu_vector *ev, double dividend)
 Elementwise division of a eris_ifu_vector by a scalar.
 
cpl_error_code eris_ifu_vector_abs (eris_ifu_vector *ev)
 Calculates the absolute value of a vector in-place.
 
int eris_ifu_vector_get_size (const eris_ifu_vector *ev)
 Get the size of the eris_ifu_vector.
 
double eris_ifu_vector_get_mean (const eris_ifu_vector *ev)
 Compute the mean value of non-rejected eris_ifu_vector elements.
 
double eris_ifu_vector_get_median (const eris_ifu_vector *ev, const enum medianType type)
 Compute the median of the elements of a vector.
 
eris_ifu_vector * eris_ifu_vector_cut_percentian (const eris_ifu_vector *ev, double percentage)
 Remove a certain percentage of brightest pixels.
 
double eris_ifu_vector_get_sum (const eris_ifu_vector *ev)
 Compute the sum of non-rejected eris_ifu_vector elements.
 
double eris_ifu_vector_get_stdev (const eris_ifu_vector *ev)
 Compute the bias-corrected standard deviation of a vector's elements.
 
double eris_ifu_vector_get_stdev_median (const eris_ifu_vector *ev)
 Compute the bias-corrected standard deviation using median instead of mean.
 
double eris_ifu_vector_get_max (const eris_ifu_vector *ev, int *pos)
 Get the maximum of the eris_ifu_vector and its position.
 
double eris_ifu_vector_get_min (const eris_ifu_vector *ev, int *pos)
 Get the minimum of the eris_ifu_vector and its position.
 
cpl_error_code eris_ifu_vector_power (eris_ifu_vector *ev, double exponent)
 Compute the elementwise power of the vector.
 
cpl_error_code eris_ifu_vector_fill (eris_ifu_vector *ev, double val)
 Fill a eris_ifu_vector.
 
cpl_error_code eris_ifu_vector_flip (eris_ifu_vector *ev)
 Flip the values of a vector.
 
eris_ifu_vector * eris_ifu_vector_histogram (const eris_ifu_vector *ev, int nbins)
 Calculates the histogram of a vector.
 
eris_ifu_vector * eris_ifu_vector_load (const char *filename, int position)
 Override for cpl_vector_load().
 
cpl_error_code eris_ifu_vector_save (const eris_ifu_vector *ev, const char *filename, cpl_type_bpp bpp, const cpl_propertylist *pl, unsigned mode, double rej_val)
 Override for cpl_vector_save().
 
cpl_error_code eris_ifu_vector_dump (const eris_ifu_vector *ev)
 All values contained in vec are printed for debugging purposes.
 
int eris_ifu_is_nan_or_inf (double A)
 Checks if a value is nan, inf or -inf.
 
cpl_error_code eris_ifu_vector_sqrt (eris_ifu_vector *ev)
 eris_ifu_vector_sqrt
 

Detailed Description

This module provides the eris_ifu_vector data type, which extends the standard cpl_vector with integrated bad pixel masking capabilities.

What is eris_ifu_vector?

An eris_ifu_vector is a data structure that contains:

Mask Convention:

This is similar to how HDRL images work but for 1D vectors.

Automatic NaN/Inf Rejection:

All creation and arithmetic functions automatically detect and reject:

These values are marked as rejected in the mask but the data values themselves are preserved (not overwritten).

Key Features:

Creation:

Element Access:

Arithmetic Operations:

Statistics:

Masking:

Extraction:

I/O:

Usage Examples:

Example 1: Basic creation and statistics

// Create vector with 100 elements eris_ifu_vector *ev = eris_ifu_vector_new(100);

// Fill with data for (int i = 0; i < 100; i++) { eris_ifu_vector_set(ev, i, some_data[i]); }

// Reject outliers manually eris_ifu_vector_reject(ev, 42);

// Compute statistics (ignores rejected elements) double mean = eris_ifu_vector_get_mean(ev); double stdev = eris_ifu_vector_get_stdev(ev);

// Cleanup eris_ifu_vector_delete(ev);

Example 2: Arithmetic with automatic rejection propagation

eris_ifu_vector *v1 = eris_ifu_vector_create(data1); eris_ifu_vector *v2 = eris_ifu_vector_create(data2);

// Divide v1 by v2 (division by zero → automatic rejection) eris_ifu_vector_divide(v1, v2); // v1 modified in-place

// If v2[i] was rejected or v2[i]==0, then v1[i] is now rejected

Example 3: Extract only valid data

eris_ifu_vector *ev = eris_ifu_vector_load("data.fits", 0);

// Get CPL vector with only non-rejected values cpl_vector *valid = eris_ifu_vector_create_non_rejected(ev);

// valid is shorter than ev if some elements were rejected int n_valid = cpl_vector_get_size(valid);

Compatibility Notes:

Note
All functions that modify vectors check for NaN/Inf and reject automatically
Rejected elements are never removed, just marked in the mask
Statistics functions return 0 if all elements are rejected (check error code)

eris_ifu_vector provides the functionality of rejected values like cpl_image does. It is a struct containing to vectors. The data vector can contain any value. If there are any infinite values in the data, these values will be masked already in eris_ifu_vector_create() and eris_ifu_vector_create2().

The mask vector can just contain the values 0 and 1. (this is asserted in eris_ifu_new() and eris_ifu_create() and eris_ifu_create2()))

Synopsis:
#include <eris_ifu_vector.h>

Enumeration Type Documentation

◆ medianType

enum medianType

The type of median behavior: For an odd number of samples the behaviour is the same for both methods. For an even number of samples:

  • ERIS_IFU_STATISTICAL:
    The returned value is the lower of the two center elements of the sorted input vector.
  • ERIS_IFU_ARITHMETIC
    The arithmetic mean of the two center elements of the sorted input vector is calculated

Definition at line 58 of file eris_ifu_vector.h.

Function Documentation

◆ eris_ifu_is_nan_or_inf()

int eris_ifu_is_nan_or_inf ( double  A)

◆ eris_ifu_vector_abs()

cpl_error_code eris_ifu_vector_abs ( eris_ifu_vector *  ev)

Calculates the absolute value of a vector in-place.

Parameters
evThe vector (modified in-place).
Returns
The function returns CPL_ERROR_NONE on success or a CPL error code otherwise.

The vector is checked elementwise: if the data is negative, its sign is changed. Only non-rejected elements are processed.

Possible cpl_error_code set in this function:

  • CPL_ERROR_NULL_INPUT if ev is NULL.
Note
Only non-rejected elements are modified
Result is always >= 0 for non-rejected elements

Definition at line 1730 of file eris_ifu_vector.c.

References BRK_IF_NULL, CATCH, and TRY.

◆ eris_ifu_vector_adapt_rejected()

cpl_error_code eris_ifu_vector_adapt_rejected ( eris_ifu_vector *  kv1,
eris_ifu_vector *  kv2 
)

Assert that rejected values on both vectors are the same.

Parameters
kv11st input eris_ifu_vector (modified in-place)
kv22nd input eris_ifu_vector (modified in-place)
Returns
CPL_ERROR_NONE or error code.

It is asserted that all rejected elements in kv1 are also rejected in kv2 and vice versa. Both masks are modified to ensure synchronization: if either vector has element i rejected, both will have it rejected.

Possible cpl_error_code set in this function:

  • CPL_ERROR_NULL_INPUT if any of the inputs is NULL
  • CPL_ERROR_ILLEGAL_INPUT if the inputs don't have the same length
Note
Both vectors are modified (logical OR of rejections)
Use before operations that require aligned masks

Definition at line 1129 of file eris_ifu_vector.c.

References BRK_IF_NULL, CATCH, and TRY.

◆ eris_ifu_vector_add()

cpl_error_code eris_ifu_vector_add ( eris_ifu_vector *  kv1,
const eris_ifu_vector *  kv2 
)

Add a eris_ifu_vector to another.

Parameters
kv1First eris_ifu_vector (modified in-place)
kv2Second eris_ifu_vector (not modified)
Returns
CPL_ERROR_NONE or the relevant error code

The second vector is added to the first one: kv1 = kv1 + kv2. The input first vector is modified in-place.

Rejection Propagation:

  • If kv2[i] is rejected → kv1[i] becomes rejected
  • Result checked for NaN/Inf → rejected if invalid
  • If both non-rejected → kv1[i] = kv1[i] + kv2[i]

The input vectors must have the same size.

Possible cpl_error_code set in this function:

  • CPL_ERROR_NULL_INPUT if any input pointer is NULL
  • CPL_ERROR_INCOMPATIBLE_INPUT if kv1 and kv2 have different sizes
Note
kv1 is modified in-place
Rejection in either operand causes rejection in result

Definition at line 1195 of file eris_ifu_vector.c.

References BRK_IF_NULL, CATCH, eris_ifu_is_nan_or_inf(), and TRY.

Referenced by eris_ifu_dist_calc_distortion().

◆ eris_ifu_vector_add_scalar()

cpl_error_code eris_ifu_vector_add_scalar ( eris_ifu_vector *  ev,
double  addend 
)

Elementwise addition of a scalar to a eris_ifu_vector.

Parameters
everis_ifu_vector to modify (modified in-place)
addendNumber to add
Returns
CPL_ERROR_NONE or the relevant error code

Add a number to each non-rejected element: ev[i] = ev[i] + addend. Rejected elements remain unchanged and rejected.

Possible cpl_error_code set in this function:

  • CPL_ERROR_NULL_INPUT if ev is NULL
Note
Only non-rejected elements are modified
Result checked for NaN/Inf

Definition at line 1508 of file eris_ifu_vector.c.

References BRK_IF_NULL, CATCH, CHECK_ERROR_STATE, eris_ifu_is_nan_or_inf(), and TRY.

Referenced by eris_ifu_vector_power().

◆ eris_ifu_vector_count_non_rejected()

int eris_ifu_vector_count_non_rejected ( const eris_ifu_vector *  ev)

Count the number of non-rejected elements in a eris_ifu_vector.

Parameters
evThe input eris_ifu_vector
Returns
The number of non-rejected values or -1 if the input vector is NULL

Possible cpl_error_code set in this function:

  • CPL_ERROR_NULL_INPUT if ev is NULL
Note
Returns -1 on error (check cpl_error_get_code())
count_non_rejected + count_rejected = size

Definition at line 878 of file eris_ifu_vector.c.

References BRK_IF_NULL, CATCH, and TRY.

Referenced by eris_ifu_combine_calc_error(), eris_ifu_dist_calc_centers_fit(), and eris_ifu_vector_get_stdev_median().

◆ eris_ifu_vector_count_rejected()

int eris_ifu_vector_count_rejected ( const eris_ifu_vector *  ev)

Count the number of rejected elements in a eris_ifu_vector.

Parameters
evThe input eris_ifu_vector
Returns
The number of rejected values or -1 if the input vector is NULL

Possible cpl_error_code set in this function:

  • CPL_ERROR_NULL_INPUT if ev is NULL
Note
Returns -1 on error (check cpl_error_get_code())

Definition at line 838 of file eris_ifu_vector.c.

References BRK_IF_NULL, CATCH, and TRY.

Referenced by eris_ifu_vector_create_non_rejected(), eris_ifu_vector_get_max(), and eris_ifu_vector_get_min().

◆ eris_ifu_vector_create()

eris_ifu_vector * eris_ifu_vector_create ( const cpl_vector *  data)

Create a new eris_ifu_vector out of a data cpl_vector.

Parameters
dataThe cpl_vector to wrap (will be duplicated).
Returns
1 newly allocated eris_ifu_vector or NULL in case of an error

The returned object must be deallocated using

All NaNs and Infs in data will be marked as rejected. The rejected data value will remain unchanged (not overwritten to NaN).

Possible cpl_error_code set in this function:

  • CPL_ERROR_NULL_INPUT if data is NULL
Note
This is the standard way to create eris_ifu_vector from cpl_vector
Input cpl_vector is duplicated and can be safely deleted

Definition at line 310 of file eris_ifu_vector.c.

References BRK_IF_ERROR, BRK_IF_NULL, CATCH, eris_ifu_is_nan_or_inf(), and TRY.

Referenced by eris_ifu_dist_calc_centers_fit(), eris_ifu_dist_calc_centers_profile(), eris_ifu_vector_cut_percentian(), and eris_ifu_vector_load().

◆ eris_ifu_vector_create2()

eris_ifu_vector * eris_ifu_vector_create2 ( const cpl_vector *  data,
const cpl_vector *  mask 
)

Create a new eris_ifu_vector out of a data and mask cpl_vector.

Parameters
dataThe data cpl_vector to wrap (will be duplicated).
maskThe mask cpl_vector to wrap (will be duplicated).
Returns
1 newly allocated eris_ifu_vector or NULL in case of an error

The returned object must be deallocated using

All NaNs and Infs in data will be marked as rejected. The rejected data value will remain unchanged. All NaNs and Infs in mask are set rejected.

Mask Input Convention:

  • mask[i] >= 0.5: element i is treated as GOOD
  • mask[i] < 0.5: element i is treated as BAD
  • NaN/Inf in mask: element i is treated as BAD

Output mask is normalized to 1.0 (good) or 0.0 (bad).

Possible cpl_error_code set in this function:

  • CPL_ERROR_NULL_INPUT if data or mask is NULL
  • CPL_ERROR_ILLEGAL_INPUT if the size of data and mask isn't the same.
Note
Use this when you already have a mask from another source
Mask values are thresholded at 0.5

Definition at line 390 of file eris_ifu_vector.c.

References BRK_IF_NULL, CATCH, eris_ifu_is_nan_or_inf(), and TRY.

◆ eris_ifu_vector_create_non_rejected()

cpl_vector * eris_ifu_vector_create_non_rejected ( const eris_ifu_vector *  ev)

Creates a cpl_vector out of a eris_ifu_vector with non-rejected values.

Parameters
evThe input eris_ifu_vector
Returns
The extracted cpl_vector or NULL.

The length of the returned cpl_vector may be, depending on the number of rejected values, shorter than the input eris_ifu_vector! If all values are rejected NULL is returned but no error is set.

Possible cpl_error_code set in this function:

  • CPL_ERROR_NULL_INPUT if ev is NULL
Note
Returned vector is shorter than input (only valid elements)
Returned vector must be deleted with cpl_vector_delete()
Returns NULL if all elements are rejected (no error set)
This removes the rejected elements entirely (vs get_data which sets NaN)

Definition at line 1066 of file eris_ifu_vector.c.

References BRK_IF_NULL, CATCH, CHECK_ERROR_STATE, eris_ifu_vector_count_rejected(), and TRY.

Referenced by eris_ifu_vector_cut_percentian(), eris_ifu_vector_get_mean(), eris_ifu_vector_get_median(), and eris_ifu_vector_get_stdev().

◆ eris_ifu_vector_cut_percentian()

eris_ifu_vector * eris_ifu_vector_cut_percentian ( const eris_ifu_vector *  ev,
double  percentage 
)

Remove a certain percentage of brightest pixels.

Parameters
evInput Vector.
percentageThe percentage of brightest pixels to remove (between 0 and 1).
Returns
The cut vector (shorter than input).

Creates a new vector containing only the (1-percentage)*100% dimmest pixels. For example, percentage=0.1 removes the brightest 10% of pixels.

Only non-rejected elements are considered. Rejected elements are excluded.

Possible cpl_error_code set in this function:

  • CPL_ERROR_NULL_INPUT if ev is NULL.
  • CPL_ERROR_ILLEGAL_INPUT if percentage is not in [0, 1)
Note
Returned vector must be deleted with eris_ifu_vector_delete()
Returned vector is shorter than input
Useful for removing outliers before statistics

Definition at line 1921 of file eris_ifu_vector.c.

References BRK_IF_NULL, CATCH, CHECK_ERROR_STATE, eris_ifu_vector_create(), eris_ifu_vector_create_non_rejected(), eris_ifu_vector_delete(), and TRY.

◆ eris_ifu_vector_delete()

void eris_ifu_vector_delete ( eris_ifu_vector *  ev)

Delete a eris_ifu_vector.

Parameters
everis_ifu_vector to delete.
Returns
void

Deallocates both data and mask vectors, then frees the structure. If the eris_ifu_vector ev is NULL, nothing is done and no error is set.

Note
Safe to call with NULL pointer

Definition at line 457 of file eris_ifu_vector.c.

References CATCH, and TRY.

Referenced by eris_ifu_combine_coadd(), eris_ifu_combine_coadd_ks_clip(), eris_ifu_free_ifu_vector(), eris_ifu_vector_cut_percentian(), eris_ifu_vector_histogram(), eris_ifu_vector_load(), and eris_ifu_vector_save().

◆ eris_ifu_vector_divide()

cpl_error_code eris_ifu_vector_divide ( eris_ifu_vector *  kv1,
const eris_ifu_vector *  kv2 
)

Divide two eris_ifu_vectors element-wise.

Parameters
kv1First eris_ifu_vector (modified in-place)
kv2Second eris_ifu_vector (not modified)
Returns
CPL_ERROR_NONE or the relevant error code

Elementwise division: kv1 = kv1 / kv2. In opposite to cpl_vector_divide(), a division by zero doesn't throw an error but results in a rejected element of the vector (NaN/Inf detection).

Rejection Propagation:

  • If kv2[i] is rejected → kv1[i] becomes rejected
  • If kv2[i] == 0 → result is Inf → kv1[i] becomes rejected
  • Result checked for NaN/Inf → rejected if invalid
  • If both non-rejected and kv2[i] != 0 → kv1[i] = kv1[i] / kv2[i]

The input vectors must have the same size.

Possible cpl_error_code set in this function:

  • CPL_ERROR_NULL_INPUT if any input pointer is NULL
  • CPL_ERROR_INCOMPATIBLE_INPUT if kv1 and kv2 have different sizes
Note
kv1 is modified in-place
Division by zero results in rejection (no error thrown)
Rejection in either operand causes rejection in result

Definition at line 1437 of file eris_ifu_vector.c.

References BRK_IF_NULL, CATCH, eris_ifu_is_nan_or_inf(), and TRY.

◆ eris_ifu_vector_divide_scalar()

cpl_error_code eris_ifu_vector_divide_scalar ( eris_ifu_vector *  ev,
double  dividend 
)

Elementwise division of a eris_ifu_vector by a scalar.

Parameters
everis_ifu_vector to modify (modified in-place)
dividendNumber to divide by
Returns
CPL_ERROR_NONE or the relevant error code

Divide each non-rejected element by a number: ev[i] = ev[i] / dividend. Rejected elements remain unchanged and rejected.

Possible cpl_error_code set in this function:

  • CPL_ERROR_NULL_INPUT if ev is NULL
Note
Only non-rejected elements are modified
Result checked for NaN/Inf (division by zero → rejection)

Definition at line 1674 of file eris_ifu_vector.c.

References BRK_IF_NULL, CATCH, CHECK_ERROR_STATE, eris_ifu_is_nan_or_inf(), and TRY.

◆ eris_ifu_vector_dump()

cpl_error_code eris_ifu_vector_dump ( const eris_ifu_vector *  ev)

All values contained in vec are printed for debugging purposes.

Parameters
evThe vector to print.
Returns
The function returns CPL_ERROR_NONE on success or a CPL error code otherwise.

Definition at line 2619 of file eris_ifu_vector.c.

References BRK_IF_NULL, BRK_WITH_ERROR_MSG, CATCH, CHECK_ERROR_STATE, and TRY.

◆ eris_ifu_vector_duplicate()

eris_ifu_vector * eris_ifu_vector_duplicate ( const eris_ifu_vector *  ev)

This function duplicates an existing eris_ifu_vector and allocates memory.

Parameters
evInput eris_ifu_vector
Returns
A newly allocated eris_ifu_vector or NULL in case of an error

The returned object must be deallocated using eris_ifu_vector_delete(). Both data and mask are duplicated (deep copy).

Possible cpl_error_code set in this function:

  • CPL_ERROR_NULL_INPUT if ev is NULL
Note
Creates independent copy (modifications won't affect original)

Definition at line 489 of file eris_ifu_vector.c.

References BRK_IF_NULL, CATCH, CHECK_ERROR_STATE, and TRY.

Referenced by eris_ifu_dist_calc_distortion(), and eris_ifu_vector_save().

◆ eris_ifu_vector_extract()

eris_ifu_vector * eris_ifu_vector_extract ( const eris_ifu_vector *  ev,
int  istart,
int  istop 
)

Extract a sub-vector from a eris_ifu_vector.

Parameters
evThe input eris_ifu_vector
istartStart index (from 0 to number of elements - 1)
istopStop index (from 0 to number of elements - 1)
Returns
A newly allocated eris_ifu_vector or NULL in case of an error

Rejected elements are also extracted (mask is preserved).

Possible cpl_error_code set in this function:

  • CPL_ERROR_NULL_INPUT if ev is NULL
  • CPL_ERROR_ILLEGAL_INPUT if istop <= istart
Note
Returned vector must be deleted with eris_ifu_vector_delete()
Both data and mask are extracted
Range is [istart, istop] (inclusive on both ends)

Definition at line 1013 of file eris_ifu_vector.c.

References BRK_IF_NULL, CATCH, and TRY.

Referenced by eris_ifu_dist_calc_centers_fit().

◆ eris_ifu_vector_fill()

cpl_error_code eris_ifu_vector_fill ( eris_ifu_vector *  ev,
double  val 
)

Fill a eris_ifu_vector.

Parameters
evThe vector to be filled with the value val (modified in-place).
valValue used to fill the eris_ifu_vector.
Returns
The function returns CPL_ERROR_NONE on success or a CPL error code otherwise.

All elements (rejected and non-rejected) are set to val. If val is NaN or Inf, all elements will be rejected. If val is finite, all elements will be non-rejected.

Possible cpl_error_code set in this function:

  • CPL_ERROR_NULL_INPUT if ev is NULL.
Note
All elements are affected (not just non-rejected)
Automatically rejects if val is NaN/Inf

Definition at line 2346 of file eris_ifu_vector.c.

References CATCH, eris_ifu_vector_get_size(), eris_ifu_vector_set(), and TRY.

◆ eris_ifu_vector_flip()

cpl_error_code eris_ifu_vector_flip ( eris_ifu_vector *  ev)

Flip the values of a vector.

Parameters
evThe vector (modified in-place).
Returns
The function returns CPL_ERROR_NONE on success or a CPL error code otherwise.

The vector is flipped elementwise from both sides: first element swaps with last, second with second-to-last, etc. Both data and mask are flipped.

Possible cpl_error_code set in this function:

  • CPL_ERROR_NULL_INPUT if ev is NULL.
Note
Both data and mask are flipped
Rejection status is preserved but moves with data

Definition at line 2386 of file eris_ifu_vector.c.

References BRK_IF_NULL, CATCH, and TRY.

◆ eris_ifu_vector_get()

double eris_ifu_vector_get ( const eris_ifu_vector *  ev,
int  pos 
)

Get an element of the eris_ifu_vector.

Parameters
evInput eris_ifu_vector
posThe index of the element (0 to nelem-1)
Returns
The element value (returned regardless of rejection status)

Convenience wrapper for eris_ifu_vector_get_rej() when rejection status is not needed. The value is returned regardless if it is rejected or not!

Possible cpl_error_code set in this function:

  • CPL_ERROR_NULL_INPUT if ev is NULL
  • CPL_ERROR_ACCESS_OUT_OF_RANGE if the specified position is out of the vector
Note
Returns data value even if rejected
Use eris_ifu_vector_is_rejected() to check rejection status separately

Definition at line 639 of file eris_ifu_vector.c.

References eris_ifu_vector_get_rej().

Referenced by eris_ifu_combine_calc_error(), and eris_ifu_dist_calc_centers_fit().

◆ eris_ifu_vector_get_bpm()

cpl_vector * eris_ifu_vector_get_bpm ( eris_ifu_vector *  ev)

Get the pointer to the mask of the eris_ifu_vector.

Parameters
evInput eris_ifu_vector
Returns
Pointer to the internal mask vector (not a copy!)

The output vector contains 1.0 for non-rejected elements and 0.0 for rejected elements.

Possible cpl_error_code set in this function:

  • CPL_ERROR_NULL_INPUT if ev is NULL
Note
Returns pointer to internal mask (NOT a copy!)
Modifications will affect the eris_ifu_vector
Do NOT delete the returned pointer

Definition at line 742 of file eris_ifu_vector.c.

References BRK_IF_NULL, CATCH, and TRY.

◆ eris_ifu_vector_get_data()

cpl_vector * eris_ifu_vector_get_data ( const eris_ifu_vector *  ev)

Get a copy of the data, rejected values are set to NaN.

Parameters
evInput eris_ifu_vector
Returns
A cpl_vector with NaN for rejected elements

The output vector contains NaN for rejected elements, allowing standard CPL operations to naturally ignore them.

Possible cpl_error_code set in this function:

  • CPL_ERROR_NULL_INPUT if ev is NULL
Note
Returned vector must be deleted with cpl_vector_delete()
Rejected elements are replaced with NaN (data is modified)
Use eris_ifu_vector_create_non_rejected() to get only valid elements

Definition at line 700 of file eris_ifu_vector.c.

References BRK_IF_ERROR, BRK_IF_NULL, CATCH, eris_ifu_vector_get_size(), eris_ifu_vector_is_rejected(), and TRY.

◆ eris_ifu_vector_get_mask()

cpl_vector * eris_ifu_vector_get_mask ( const eris_ifu_vector *  ev)

Get a copy of the mask of eris_ifu_vector.

Parameters
evInput eris_ifu_vector
Returns
A duplicated mask vector or NULL on error

The output vector contains 1.0 for non-rejected elements and 0.0 for rejected elements.

Possible cpl_error_code set in this function:

  • CPL_ERROR_NULL_INPUT if ev is NULL
Note
Returned vector must be deleted with cpl_vector_delete()
Returns a copy (modifications won't affect original)

Definition at line 663 of file eris_ifu_vector.c.

References BRK_IF_NULL, CATCH, and TRY.

◆ eris_ifu_vector_get_max()

double eris_ifu_vector_get_max ( const eris_ifu_vector *  ev,
int *  pos 
)

Get the maximum of the eris_ifu_vector and its position.

Parameters
evInput eris_ifu_vector
pos(Output) The index of the max element (first value is 0), is set to -1 if all elements are rejected. If set to NULL it won't be returned.
Returns
The maximum element value or 0 if all rejected

Only non-rejected elements are considered.

Possible cpl_error_code set in this function:

  • CPL_ERROR_NULL_INPUT if ev is NULL
Note
Returns 0 if all elements are rejected (pos is set to -1)
Only non-rejected elements are considered

Definition at line 2145 of file eris_ifu_vector.c.

References BRK_IF_NULL, CATCH, CHECK_ERROR_STATE, eris_ifu_vector_count_rejected(), and TRY.

Referenced by eris_ifu_vector_histogram().

◆ eris_ifu_vector_get_mean()

double eris_ifu_vector_get_mean ( const eris_ifu_vector *  ev)

Compute the mean value of non-rejected eris_ifu_vector elements.

Parameters
evInput eris_ifu_vector
Returns
Mean value of vector elements or 0 on error or when all values are rejected.

Only non-rejected elements are included in the calculation.

Possible cpl_error_code set in this function:

  • CPL_ERROR_NULL_INPUT if ev is NULL
Note
Returns 0 if all elements are rejected (check error code!)
Only non-rejected elements are used

Definition at line 1813 of file eris_ifu_vector.c.

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

Referenced by eris_ifu_dist_calc_centers_profile(), and eris_ifu_dist_calc_distortion().

◆ eris_ifu_vector_get_median()

double eris_ifu_vector_get_median ( const eris_ifu_vector *  ev,
const enum medianType  type 
)

Compute the median of the elements of a vector.

Parameters
evInput Vector.
typeThe method to calculate the median with: ERIS_IFU_STATISTICAL: The returned value is the lower of the two center elements of the sorted input vector. ERIS_IFU_ARITHMETIC: The arithmetic mean of the two center elements of the sorted input vector is calculated.
Returns
Median value of the vector elements or 0 on error or when all values are rejected.

Unlike

  • cpl_vector_get_median this function doesn't modify the order of the elements of the input vector (uses a copy internally)!

Only non-rejected elements are included in the calculation.

Possible cpl_error_code set in this function:

  • CPL_ERROR_NULL_INPUT if ev is NULL.
Note
Returns 0 if all elements are rejected (check error code!)
Input vector is not modified
Only non-rejected elements are used

Definition at line 1864 of file eris_ifu_vector.c.

References CATCH, eris_ifu_vector_create_non_rejected(), and TRY.

Referenced by eris_ifu_dist_calc_centers_fit(), and eris_ifu_vector_get_stdev_median().

◆ eris_ifu_vector_get_min()

double eris_ifu_vector_get_min ( const eris_ifu_vector *  ev,
int *  pos 
)

Get the minimum of the eris_ifu_vector and its position.

Parameters
evInput eris_ifu_vector
pos(Output) The index of the min element (first value is 0), is set to -1 if all elements are rejected. If set to NULL it won't be returned.
Returns
The minimum element value or 0 if all rejected

Only non-rejected elements are considered.

Possible cpl_error_code set in this function:

  • CPL_ERROR_NULL_INPUT if ev is NULL
Note
Returns 0 if all elements are rejected (pos is set to -1)
Only non-rejected elements are considered

Definition at line 2209 of file eris_ifu_vector.c.

References BRK_IF_NULL, CATCH, CHECK_ERROR_STATE, eris_ifu_vector_count_rejected(), and TRY.

Referenced by eris_ifu_vector_histogram().

◆ eris_ifu_vector_get_rej()

double eris_ifu_vector_get_rej ( const eris_ifu_vector *  ev,
int  pos,
int *  rej 
)

Get an element of the eris_ifu_vector.

Parameters
evInput eris_ifu_vector
posThe index of the element (0 to nelem-1)
rej(Output) 1 if the pixel is bad, 0 if good, negative on error. Can be NULL if rejection status not needed.
Returns
The element value (returned regardless of rejection status)

The value is returned regardless if it is rejected or not! By examining rej the status of the element can be examined.

Possible cpl_error_code set in this function:

  • CPL_ERROR_NULL_INPUT if ev is NULL
  • CPL_ERROR_ACCESS_OUT_OF_RANGE if the specified position is out of the vector
Note
Returns data value even if rejected (check rej parameter!)
If rej is NULL, only the value is returned

Definition at line 587 of file eris_ifu_vector.c.

References CATCH, and TRY.

Referenced by eris_ifu_vector_get().

◆ eris_ifu_vector_get_size()

int eris_ifu_vector_get_size ( const eris_ifu_vector *  ev)

Get the size of the eris_ifu_vector.

Parameters
evInput eris_ifu_vector
Returns
The size or -1 in case of an error

Returns the total number of elements (rejected + non-rejected).

Possible cpl_error_code set in this function:

  • CPL_ERROR_NULL_INPUT if ev is NULL
Note
Returns total size (not just non-rejected count)
Use eris_ifu_vector_count_non_rejected() to get valid element count

Definition at line 1776 of file eris_ifu_vector.c.

References CATCH, CHECK_ERROR_STATE, and TRY.

Referenced by eris_ifu_vector_fill(), and eris_ifu_vector_get_data().

◆ eris_ifu_vector_get_stdev()

double eris_ifu_vector_get_stdev ( const eris_ifu_vector *  ev)

Compute the bias-corrected standard deviation of a vector's elements.

Parameters
evInput eris_ifu_vector
Returns
standard deviation of the elements or -1 on error.

Formula: S(n-1) = sqrt[sum((xi-mean)^2) / (n-1)] (i=1 -> n)

The length of ev must be at least 2. Only non-rejected elements are included in the calculation.

Possible cpl_error_code set in this function:

  • CPL_ERROR_NULL_INPUT if ev is NULL
  • CPL_ERROR_ILLEGAL_INPUT if the number of non-rejected values in ev is less than 2
Note
Returns -1 on error or if < 2 non-rejected elements
Uses (n-1) denominator (bias-corrected)
Only non-rejected elements are used

Definition at line 2034 of file eris_ifu_vector.c.

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

Referenced by eris_ifu_combine_calc_error().

◆ eris_ifu_vector_get_stdev_median()

double eris_ifu_vector_get_stdev_median ( const eris_ifu_vector *  ev)

Compute the bias-corrected standard deviation using median instead of mean.

Parameters
evInput eris_ifu_vector
Returns
standard deviation using median of the elements or -1 on error.

Formula: S(n-1) = sqrt[sum((xi-median)^2) / (n-1)] (i=1 -> n)

The length of ev must be at least 2. Only non-rejected elements are included in the calculation.

This is more robust to outliers than standard stdev.

Possible cpl_error_code set in this function:

  • CPL_ERROR_NULL_INPUT if ev is NULL
  • CPL_ERROR_ILLEGAL_INPUT if the number of non-rejected values in ev is less than 2
Note
Returns -1 on error or if < 2 non-rejected elements
More robust to outliers than eris_ifu_vector_get_stdev()
Uses (n-1) denominator (bias-corrected)

Definition at line 2083 of file eris_ifu_vector.c.

References BRK_IF_NULL, BRK_WITH_ERROR, CATCH, CHECK_ERROR_STATE, eris_ifu_vector_count_non_rejected(), eris_ifu_vector_get_median(), and TRY.

Referenced by eris_ifu_combine_calc_error(), and eris_ifu_dist_calc_centers_fit().

◆ eris_ifu_vector_get_sum()

double eris_ifu_vector_get_sum ( const eris_ifu_vector *  ev)

Compute the sum of non-rejected eris_ifu_vector elements.

Parameters
evInput eris_ifu_vector
Returns
Sum of vector elements or 0 on error or when all values are rejected.

Only non-rejected elements are included in the sum.

Possible cpl_error_code set in this function:

  • CPL_ERROR_NULL_INPUT if ev is NULL
Note
Returns 0 if all elements are rejected
Only non-rejected elements are summed

Definition at line 1979 of file eris_ifu_vector.c.

References BRK_IF_NULL, CATCH, CHECK_ERROR_STATE, and TRY.

◆ eris_ifu_vector_histogram()

eris_ifu_vector * eris_ifu_vector_histogram ( const eris_ifu_vector *  ev,
int  nbins 
)

Calculates the histogram of a vector.

Parameters
evInput vector.
nbinsThe number of bins to produce.
Returns
A vector of size nbins containing the histogram of input data, or NULL on error.

This implementation follows the one used in IDL. This means that in the highest bin can only be found values corresponding to the maximum value in the input vector.

Only non-rejected elements are included in the histogram.

Possible cpl_error_code set in this function:

  • CPL_ERROR_NULL_INPUT if ev is NULL.
  • CPL_ERROR_ILLEGAL_INPUT if nbins is <= 0.
Note
Returned vector must be deleted with eris_ifu_vector_delete()
Only non-rejected elements are histogrammed
Returned histogram is itself an eris_ifu_vector (all non-rejected)

Definition at line 2450 of file eris_ifu_vector.c.

References BRK_IF_NULL, CATCH, CHECK_ERROR_STATE, eris_ifu_vector_delete(), eris_ifu_vector_get_max(), eris_ifu_vector_get_min(), eris_ifu_vector_new(), and TRY.

◆ eris_ifu_vector_is_rejected()

int eris_ifu_vector_is_rejected ( const eris_ifu_vector *  ev,
int  n 
)

Test if a value is good or bad.

Parameters
evThe input eris_ifu_vector
nThe position of the value in the vector (first value is 0)
Returns
1 if the value is rejected, 0 if it is good, -1 on error

Possible cpl_error_code set in this function:

  • CPL_ERROR_NULL_INPUT if ev is NULL
  • CPL_ERROR_ACCESS_OUT_OF_RANGE if the specified position is out of the vector
Note
Return values: 0=good, 1=rejected, -1=error

Definition at line 925 of file eris_ifu_vector.c.

References CATCH, and TRY.

Referenced by eris_ifu_combine_calc_error(), eris_ifu_dist_calc_centers_fit(), and eris_ifu_vector_get_data().

◆ eris_ifu_vector_load()

eris_ifu_vector * eris_ifu_vector_load ( const char *  filename,
int  position 
)

Override for cpl_vector_load().

Parameters
filenameName of the input file
positionExtension number in the file.
Returns
The function returns the newly created eris_ifu_vector or NULL if an error occurred.

This is an override for cpl_vector_load(), just giving a proper error message if the input file isn't found. The errors returned are the same as with cpl_vector_load

Definition at line 2511 of file eris_ifu_vector.c.

References BRK_IF_NULL, CATCH, CHECK_ERROR_STATE, eris_ifu_vector_create(), eris_ifu_vector_delete(), and TRY.

◆ eris_ifu_vector_multiply()

cpl_error_code eris_ifu_vector_multiply ( eris_ifu_vector *  kv1,
const eris_ifu_vector *  kv2 
)

Multiply two eris_ifu_vectors.

Parameters
kv1First eris_ifu_vector (modified in-place)
kv2Second eris_ifu_vector (not modified)
Returns
CPL_ERROR_NONE or the relevant error code

Elementwise multiplication: kv1 = kv1 * kv2. The input first vector is modified in-place.

Rejection Propagation:

  • If kv2[i] is rejected → kv1[i] becomes rejected
  • Result checked for NaN/Inf → rejected if invalid
  • If both non-rejected → kv1[i] = kv1[i] * kv2[i]

The input vectors must have the same size.

Possible cpl_error_code set in this function:

  • CPL_ERROR_NULL_INPUT if any input pointer is NULL
  • CPL_ERROR_INCOMPATIBLE_INPUT if kv1 and kv2 have different sizes
Note
kv1 is modified in-place
Rejection in either operand causes rejection in result

Definition at line 1354 of file eris_ifu_vector.c.

References BRK_IF_NULL, CATCH, eris_ifu_is_nan_or_inf(), and TRY.

◆ eris_ifu_vector_multiply_scalar()

cpl_error_code eris_ifu_vector_multiply_scalar ( eris_ifu_vector *  ev,
double  factor 
)

Elementwise multiplication of a scalar to a eris_ifu_vector.

Parameters
everis_ifu_vector to modify (modified in-place)
factorNumber to multiply with
Returns
CPL_ERROR_NONE or the relevant error code

Multiply each non-rejected element with a number: ev[i] = ev[i] * factor. Rejected elements remain unchanged and rejected.

Possible cpl_error_code set in this function:

  • CPL_ERROR_NULL_INPUT if ev is NULL
Note
Only non-rejected elements are modified
Result checked for NaN/Inf

Definition at line 1619 of file eris_ifu_vector.c.

References BRK_IF_NULL, CATCH, CHECK_ERROR_STATE, eris_ifu_is_nan_or_inf(), and TRY.

Referenced by eris_ifu_vector_power().

◆ eris_ifu_vector_new()

eris_ifu_vector * eris_ifu_vector_new ( int  n)

Create a new eris_ifu_vector.

Parameters
nNumber of elements of the eris_ifu_vector
Returns
1 newly allocated eris_ifu_vector or NULL in case of an error

The returned object must be deallocated using

  • eris_ifu_vector_delete(). In opposite to cpl_vector_new, the data values are initialised to zero, and all values are marked as non-rejected (mask = 1.0).

Possible cpl_error_code set in this function:

  • CPL_ERROR_ILLEGAL_INPUT if n is negative or zero
Note
All elements initialized to 0.0 with mask = 1.0 (good)

Definition at line 184 of file eris_ifu_vector.c.

References BRK_IF_ERROR, BRK_IF_NULL, CATCH, and TRY.

Referenced by eris_ifu_combine_coadd(), eris_ifu_combine_coadd_ks_clip(), and eris_ifu_vector_histogram().

◆ eris_ifu_vector_new_wrap()

eris_ifu_vector * eris_ifu_vector_new_wrap ( int  n,
const double *  data 
)

Create a new eris_ifu_vector from a C array (duplicated).

Parameters
nNumber of elements of the eris_ifu_vector
dataData array (will be duplicated)
Returns
1 newly allocated eris_ifu_vector or NULL in case of an error

The returned object must be deallocated using

  • eris_ifu_vector_delete(). The input data array is duplicated (safe to free after calling this function). All NaN and Inf values are automatically marked as rejected.

Possible cpl_error_code set in this function:

  • CPL_ERROR_ILLEGAL_INPUT if n is negative or zero
  • CPL_ERROR_NULL_INPUT if data is NULL
Note
NaN and Inf values in data are automatically rejected
Input array is not modified

Definition at line 240 of file eris_ifu_vector.c.

References BRK_IF_ERROR, BRK_IF_NULL, CATCH, eris_ifu_is_nan_or_inf(), and TRY.

Referenced by eris_ifu_dist_calc_distortion().

◆ eris_ifu_vector_power()

cpl_error_code eris_ifu_vector_power ( eris_ifu_vector *  ev,
double  exponent 
)

Compute the elementwise power of the vector.

Parameters
evThe vector to be modified in place.
exponentThe Exponent.
Returns
The function returns CPL_ERROR_NONE on success or a CPL error code otherwise.

Computes ev[i] = pow(ev[i], exponent) for non-rejected elements. Special case: exponent == 0 → ev[i] = 1.0 for all non-rejected elements.

With a vector-element being zero and negative exponent, this function produces Inf which is then rejected.

Possible cpl_error_code set in this function:

  • CPL_ERROR_NULL_INPUT if ev is NULL.
Note
Only non-rejected elements are modified
exponent=0 always produces 1.0 (even for 0^0)
Result checked for NaN/Inf

Definition at line 2279 of file eris_ifu_vector.c.

References BRK_IF_NULL, CATCH, CHECK_ERROR_STATE, eris_ifu_is_nan_or_inf(), eris_ifu_vector_add_scalar(), eris_ifu_vector_multiply_scalar(), and TRY.

◆ eris_ifu_vector_reject()

cpl_error_code eris_ifu_vector_reject ( eris_ifu_vector *  ev,
int  n 
)

Set a value as rejected in a eris_ifu_vector.

Parameters
evThe input eris_ifu_vector (modified in-place)
nThe position of the value in the vector (first value is 0)
Returns
CPL_ERROR_NONE or the relevant error code

Marks the element at position n as rejected (mask[n] = 0.0). The data value itself is not modified.

Possible cpl_error_code set in this function:

  • CPL_ERROR_NULL_INPUT if ev is NULL
  • CPL_ERROR_ACCESS_OUT_OF_RANGE if the specified position is out of the vector
Note
Data value is not modified, only the mask
Once rejected, use eris_ifu_vector_set() to un-reject

Definition at line 970 of file eris_ifu_vector.c.

References CATCH, CHECK_ERROR_STATE, and TRY.

Referenced by eris_ifu_combine_coadd(), eris_ifu_combine_coadd_ks_clip(), and eris_ifu_dist_calc_centers_fit().

◆ eris_ifu_vector_reject_from_mask()

cpl_error_code eris_ifu_vector_reject_from_mask ( eris_ifu_vector *  ev,
const cpl_vector *  mask,
int  keep 
)

Set the rejected elements in an eris_ifu_vector as defined in a mask.

Parameters
evInput eris_ifu_vector (modified in-place)
maskThe mask defining the bad elements (1.0=good, 0.0=bad).
keepTRUE: keep already rejected values and just update the non-rejected ones. FALSE: apply the supplied mask completely.
Returns
CPL_ERROR_NONE or the relevant error code

Applies a mask to the eris_ifu_vector. If keep=TRUE, only currently non-rejected elements can be updated; already rejected elements remain rejected.

Possible cpl_error_code set in this function:

  • CPL_ERROR_NULL_INPUT if ev or mask is NULL
  • CPL_ERROR_ILLEGAL_INPUT if ev and mask don't have same length
Note
mask convention: 1.0=good, 0.0=bad (threshold at 0.5)
keep=TRUE: logical AND with existing mask (can only add rejections)
keep=FALSE: replaces mask entirely

Definition at line 783 of file eris_ifu_vector.c.

References BRK_IF_NULL, CATCH, CHECK_ERROR_STATE, and TRY.

◆ eris_ifu_vector_save()

cpl_error_code eris_ifu_vector_save ( const eris_ifu_vector *  ev,
const char *  filename,
cpl_type_bpp  bpp,
const cpl_propertylist *  pl,
unsigned  mode,
double  rej_val 
)

Override for cpl_vector_save().

Parameters
everis_ifu_vector to write to disk or NULL
filenameName of the file to write
bppBits per pixel
plProperty list for the output header or NULL
modeThe desired output options
rej_valThe rejected values are filled with this value. If -1 is provided, the rejected values in the internal cpl-bad pixel mask are ignored.
Returns
CPL_ERROR_NONE or the relevant cpl_error_code on error

This is an override for cpl_vector_save(), just giving a proper error message if the input file isn't found and rejecting all infinite values (NaN, +/-Inf). The errors returned are the same as with cpl_vector_save

Definition at line 2561 of file eris_ifu_vector.c.

References BRK_IF_NULL, CATCH, CHECK_ERROR_STATE, eris_ifu_is_nan_or_inf(), eris_ifu_vector_delete(), eris_ifu_vector_duplicate(), and TRY.

Referenced by eris_ifu_save_ifu_vector_dbg().

◆ eris_ifu_vector_set()

cpl_error_code eris_ifu_vector_set ( eris_ifu_vector *  ev,
int  pos,
double  val 
)

Set an element of the eris_ifu_vector.

Parameters
evInput eris_ifu_vector (modified in-place)
posThe index of the element (0 to nelem-1)
valThe value to set in the vector
Returns
CPL_ERROR_NONE or the relevant error code

If the value is NaN or Inf the element is automatically marked as rejected. If the value is finite, the element is marked as non-rejected.

Possible cpl_error_code set in this function:

  • CPL_ERROR_NULL_INPUT if ev is NULL
  • CPL_ERROR_ACCESS_OUT_OF_RANGE if the specified position is out of the vector
Note
Automatically rejects NaN/Inf values
Automatically un-rejects finite values

Definition at line 540 of file eris_ifu_vector.c.

References CATCH, eris_ifu_is_nan_or_inf(), and TRY.

Referenced by eris_ifu_combine_coadd(), eris_ifu_combine_coadd_ks_clip(), and eris_ifu_vector_fill().

◆ eris_ifu_vector_sqrt()

cpl_error_code eris_ifu_vector_sqrt ( eris_ifu_vector *  ev)

eris_ifu_vector_sqrt

Parameters
v
Returns

Fixes a bug in cpl_vector_sqrt(): When a value is -nan, the function returns an ILLEGAL_INPUT error... sqrt() does return just the same nan value, so let's do so...

Definition at line 2684 of file eris_ifu_vector.c.

References BRK_IF_NULL, CATCH, CHECK_ERROR_STATE, eris_ifu_is_nan_or_inf(), and TRY.

◆ eris_ifu_vector_subtract()

cpl_error_code eris_ifu_vector_subtract ( eris_ifu_vector *  kv1,
const eris_ifu_vector *  kv2 
)

Subtract two eris_ifu_vectors.

Parameters
kv1First eris_ifu_vector (modified in-place)
kv2Second eris_ifu_vector (not modified)
Returns
CPL_ERROR_NONE or the relevant error code

The second vector is subtracted from the first one: kv1 = kv1 - kv2. The input first vector is modified in-place.

Rejection Propagation:

  • If kv2[i] is rejected → kv1[i] becomes rejected
  • Result checked for NaN/Inf → rejected if invalid
  • If both non-rejected → kv1[i] = kv1[i] - kv2[i]

The input vectors must have the same size.

Possible cpl_error_code set in this function:

  • CPL_ERROR_NULL_INPUT if any input pointer is NULL
  • CPL_ERROR_INCOMPATIBLE_INPUT if kv1 and kv2 have different sizes
Note
kv1 is modified in-place
Rejection in either operand causes rejection in result

Definition at line 1274 of file eris_ifu_vector.c.

References BRK_IF_NULL, CATCH, eris_ifu_is_nan_or_inf(), and TRY.

Referenced by eris_ifu_dist_calc_distortion().

◆ eris_ifu_vector_subtract_scalar()

cpl_error_code eris_ifu_vector_subtract_scalar ( eris_ifu_vector *  ev,
double  subtrahend 
)

Elementwise subtraction of a scalar from a eris_ifu_vector.

Parameters
everis_ifu_vector to modify (modified in-place)
subtrahendNumber to subtract
Returns
CPL_ERROR_NONE or the relevant error code

Subtract a number from each non-rejected element: ev[i] = ev[i] - subtrahend. Rejected elements remain unchanged and rejected.

Possible cpl_error_code set in this function:

  • CPL_ERROR_NULL_INPUT if ev is NULL
Note
Only non-rejected elements are modified
Result checked for NaN/Inf

Definition at line 1563 of file eris_ifu_vector.c.

References BRK_IF_NULL, CATCH, CHECK_ERROR_STATE, eris_ifu_is_nan_or_inf(), and TRY.