X-shooter Pipeline Reference Manual 3.8.15
Macros | Functions
test-xsh_fit.c File Reference
#include <xsh_fit.h>
#include <tests.h>
#include <cpl_test.h>
#include <math.h>
#include <float.h>

Go to the source code of this file.

Macros

#define MODULE_ID   "XSH_FIT"
 
#define XSH_TEST_MARGIN   2.0
 
#define xsh_test(expr)
 
#define xsh_test_tol(first, second, tolerance)
 
#define IMAGESZ   10
 
#define NFRAMES   10
 
#define IMAGESZFIT   256
 
#define xsh_fit_imagelist_is_zero(A, B)    xsh_fit_imagelist_is_zero_macro(A, B)
 
#define xsh_fit_image_is_zero(A, B)    xsh_fit_image_is_zero_macro(A, B)
 

Functions

static void xsh_fit_imagelist_polynomial_tests (void)
 
static void xsh_fit_imagelist_is_zero_macro (const cpl_imagelist *self, double tol)
 Verify that all elements in an imagelist are zero (within a tolerance)
 
static void xsh_fit_image_is_zero_macro (const cpl_image *self, double tol)
 Verify that all elements in an image are zero (within a tolerance)
 
static cpl_error_code xsh_image_fill_noise_uniform (cpl_image *self, double min_pix, double max_pix)
 Fill an image with uniform random noise distribution.
 
int main (void)
 Unit tests of fit module.
 

Macro Definition Documentation

◆ IMAGESZ

#define IMAGESZ   10

Definition at line 63 of file test-xsh_fit.c.

◆ IMAGESZFIT

#define IMAGESZFIT   256

Definition at line 65 of file test-xsh_fit.c.

◆ MODULE_ID

#define MODULE_ID   "XSH_FIT"

Definition at line 38 of file test-xsh_fit.c.

◆ NFRAMES

#define NFRAMES   10

Definition at line 64 of file test-xsh_fit.c.

◆ xsh_fit_image_is_zero

#define xsh_fit_image_is_zero (   A,
 
)     xsh_fit_image_is_zero_macro(A, B)

Definition at line 69 of file test-xsh_fit.c.

◆ xsh_fit_imagelist_is_zero

#define xsh_fit_imagelist_is_zero (   A,
 
)     xsh_fit_imagelist_is_zero_macro(A, B)

Definition at line 67 of file test-xsh_fit.c.

◆ xsh_test

#define xsh_test (   expr)
Value:
do { \
if (!(expr)) assure(0, CPL_ERROR_ILLEGAL_OUTPUT, "Test failed"); \
} while(0) \
#define assure(CONDITION, ERROR_CODE,...)
Definition: xsh_error.h:54

Definition at line 43 of file test-xsh_fit.c.

◆ XSH_TEST_MARGIN

#define XSH_TEST_MARGIN   2.0

Definition at line 41 of file test-xsh_fit.c.

◆ xsh_test_tol

#define xsh_test_tol (   first,
  second,
  tolerance 
)
Value:
do { \
const double xsh_test_first = (double)(first); \
const double xsh_test_second = (double)(second); \
const double xsh_test_tolerance = (double)(tolerance); \
/* The error margin on the tolerance */ \
const double xsh_test_margin = (double)(XSH_TEST_MARGIN); \
\
if (!(fabs(xsh_test_first - xsh_test_second) <= \
xsh_test_tolerance * xsh_test_margin)) \
{ \
xsh_test(0); \
} \
} while (0)
unsigned int first
Definition: irplib_error.c:88
#define XSH_TEST_MARGIN
Definition: test-xsh_fit.c:41
double tolerance

Definition at line 48 of file test-xsh_fit.c.

Function Documentation

◆ main()

int main ( void  )

Unit tests of fit module.

Definition at line 99 of file test-xsh_fit.c.

References check, MODULE_ID, TEST_END, TESTS_INIT, xsh_error_dump, and xsh_fit_imagelist_polynomial_tests().

◆ xsh_fit_image_is_zero_macro()

static void xsh_fit_image_is_zero_macro ( const cpl_image *  self,
double  tol 
)
static

Verify that all elements in an image are zero (within a tolerance)

Parameters
selfThe image to check
tolThe non-negative tolerance param line The line number of the caller
Returns
void

Definition at line 447 of file test-xsh_fit.c.

References xsh_test_tol.

Referenced by xsh_fit_imagelist_is_zero_macro().

◆ xsh_fit_imagelist_is_zero_macro()

static void xsh_fit_imagelist_is_zero_macro ( const cpl_imagelist *  self,
double  tol 
)
static

Verify that all elements in an imagelist are zero (within a tolerance)

Parameters
selfThe list of images to check
tolThe non-negative tolerance
Returns
void

Definition at line 418 of file test-xsh_fit.c.

References check, n, and xsh_fit_image_is_zero_macro().

◆ xsh_fit_imagelist_polynomial_tests()

static void xsh_fit_imagelist_polynomial_tests ( void  )
static

◆ xsh_image_fill_noise_uniform()

static cpl_error_code xsh_image_fill_noise_uniform ( cpl_image *  self,
double  min_pix,
double  max_pix 
)
static

Fill an image with uniform random noise distribution.

Parameters
selfImage to fill
min_pixMinimum output pixel value.
max_pixMaximum output pixel value.
Returns
CPL_ERROR_NONE or the relevant CPL error code on error.
See also
cpl_image_fill_noise_uniform()
Note
Images with pixel type int are also supported

FIXME: Add Integer support to cpl_image_fill_noise_uniform()

Definition at line 481 of file test-xsh_fit.c.

References nx, and ny.

Referenced by xsh_fit_imagelist_polynomial_tests().