GRAVI Pipeline Reference Manual  1.2.3
Functions
Gravity CPL interface

Functions

cpl_array ** gravi_array_new_list (int n, cpl_type type, int size)
 Allocate a list of arrays, pre-filled with 0.0.
 
cpl_error_code gravi_table_set_string_fixlen (cpl_table *table, const char *name, int row, const char *value, int len)
 Set string in table, ensuring fixed length (right space padding). see cpl_table_set_string. More...
 
cpl_array * gravi_array_cexp (double complex factor, const cpl_array *input)
 Compute the complex exponention of an array: cexp (factor * input)
 
cpl_error_code gravi_array_multiply_phasor (cpl_array *input, double complex factor, cpl_array *phase)
 Multiply a REAL phase to a COMPLEX array, in-place: input = input * cexp (factor * phase)
 
cpl_error_code gravi_array_add_phasor (cpl_array *input, double complex factor, cpl_array *phase)
 Add a REAL phase to a COMPLEX array, in-place: input = input + cexp (factor * phase)
 
cpl_error_code gravi_array_add_phasors (cpl_array *input, cpl_array *add, cpl_array *sub)
 Add a pair of COMPLEX arrays to a COMPLEX array, in-place: input = input + add*conj(sub)
 
cpl_error_code gravi_array_add_phase (cpl_array *input, double factor, cpl_array *phase)
 Add a REAL phase to a REAL phase array, in-place: input = input + factor * phase.
 
cpl_error_code gravi_array_get_group_delay_loop (cpl_array **input, cpl_array *sigma, double *gd, cpl_size nrow, double max_width, int verbose)
 Optimized computation of GDELAY for a list of arrays. More...
 
int gravi_table_are_equal (cpl_table *first, cpl_table *second)
 Check if two tables have the same content. More...
 
cpl_error_code gravi_imagelist_unwrap_images (cpl_imagelist *imglist)
 Unwrap an imagelist an all its images. More...
 
cpl_imagelist * gravi_imagelist_wrap_column (cpl_table *table_data, const char *data_x)
 Wrap a column array of a table into an imagelist. More...
 
double gravi_image_get_noise_window (cpl_image *img, cpl_size llx, cpl_size lly, cpl_size urx, cpl_size ury)
 Estimate the median noise in a window. This noise is estimated as the median{img**2}**0.5, so that it is a robust estimate.
 
cpl_image * gravi_image_from_column (cpl_table *table_data, const char *data_x, cpl_size row)
 Create an image from a column array in table. More...
 
cpl_imagelist * gravi_imagelist_from_column (cpl_table *table_data, const char *data_x)
 Create an imagelist from a column array in table. More...
 
cpl_array * gravi_table_get_column_dimension (const cpl_table *table, const char *name)
 Return an array ready for cpl_table_set_column_dimension. More...
 
cpl_array * gravi_array_wrap_image (cpl_image *img)
 Wrap the data of na image into an array. More...
 
cpl_matrix * get_matrix_from_vector (cpl_vector *vector1, cpl_vector *vector2)
 Copy the content of two vector into a newly allocated 2D matrix. More...
 
cpl_vector * gravi_table_get_vector (cpl_table *spectrum_data, cpl_size index, const char *regname)
 Create a vector from the row index of the column regname. More...
 
cpl_vector * gravi_table_get_vector_diff (cpl_table *spectrum_data, int index, const char *regname1, const char *regname2)
 Create a vector from the row index of the column regname. More...
 
cpl_error_code gravi_image_fill (cpl_image *img, double value)
 Fill entire image with value.
 
cpl_image * gravi_image_wrap_matrix (cpl_matrix *matrix)
 Wrap matrix into an image (data not duplicated)
 
cpl_image * gravi_image_wrap_vector (cpl_vector *vector)
 Wrap vector into an image (data not duplicated)
 
double gravi_image_get_quantile (const cpl_image *img, double thr)
 Compute the quantile of an image. More...
 
double gravi_array_get_quantile (cpl_array *arr, double thr)
 Compute the value of the vector corresponding to the quantile 'thr' (0 < thr < 1) More...
 
cpl_size gravi_vector_get_maxpos (cpl_vector *vector)
 Return the index of maximum in a vector. If several indexes exists with the maximum value, the smallest index is returned. More...
 
double gravi_vector_get_mean_clip (cpl_vector *vector_in, double percent, double nsigma)
 Return the mean of a vector after extrema and RMS clipping. More...
 
cpl_vector * gravi_vector_extract (const cpl_vector *vector, int start, int step)
 Extract part of a vector. More...
 
cpl_error_code gravi_vector_unwrap_with_guess (cpl_vector *vector, cpl_vector *ref, double ref_to_phase)
 Unwrap a phase vector following a guess vector. The difference is actually unwrap and shall thus be slowly evolving. The operration if performed in-place. More...
 
cpl_error_code gravi_table_multiply_scalar (cpl_table *table, const char *name, int base, int nbase, double value)
 Multiply scalar or array column by scalar. More...
 
cpl_error_code gravi_table_add_scalar (cpl_table *table, const char *name, int base, int nbase, double value)
 Multply scalar or array column by scalar. More...
 
cpl_matrix * gravi_matrix_interpolate_col (cpl_matrix *matrix, cpl_vector *xref, cpl_vector *xout)
 Linear interpolation of matrix column. More...
 
cpl_matrix * gravi_matrix_invertSV_create (cpl_matrix *a_in)
 Invers a matrix with singular value decomposition. More...
 
cpl_table * gravi_table_extract_time_interval (cpl_table *table, double start, double end)
 Extract rows from table based on the TIME column. More...
 

Detailed Description

This module implements some interactions with cpl objects to address specific gravity needs. The manipulated cpl object are cpl_matrix, cpl_array, cpl_table and cpl_image

Function Documentation

cpl_matrix* get_matrix_from_vector ( cpl_vector *  vector1,
cpl_vector *  vector2 
)

Copy the content of two vector into a newly allocated 2D matrix.

Parameters
vector1
vector2
Returns
The newly allocated matrix
Note
The returned matrix must be deallocated using the function
See also
cpl_matrix_delete()

Definition at line 1820 of file gravi_cpl.c.

Referenced by gravi_ellipse_phase_create().

cpl_error_code gravi_array_get_group_delay_loop ( cpl_array **  input,
cpl_array *  sigma,
double *  gd,
cpl_size  nrow,
double  max_width,
int  verbose 
)

Optimized computation of GDELAY for a list of arrays.

Parameters
inputPointer to arrays (complex coherent flux)
sigmaArray with the wavenumbers [m]
gdPointer to output GDELAYs [m]
nrowSize of input and gd
max_widthMaximum opd to explore [m]
verboseFlag to dump the computation time in log

For each input array, the group-delay in [m] as the maximum of |Env(x)| where Env(x) = < visdata(lbd) * exp(2i.pi * x / lbd) > with <> sum over lbd

This is optimized to run on a column of arrays:

  • guess the delay with the interspectra
  • crude search over the max_width, resolution 2lbd
  • fine search resolution lbd/10
  • fine search resolution lbd/100

Definition at line 1187 of file gravi_cpl.c.

References gravi_array_get_group_delay_loop().

Referenced by gravi_array_get_group_delay_loop(), gravi_average_self_visphi(), gravi_compute_vis(), and gravi_p2vm_phase_correction().

double gravi_array_get_quantile ( cpl_array *  arr,
double  thr 
)

Compute the value of the vector corresponding to the quantile 'thr' (0 < thr < 1)

Returns
quantile value

Definition at line 2146 of file gravi_cpl.c.

Referenced by gravi_p2vm_normalisation().

cpl_array* gravi_array_wrap_image ( cpl_image *  img)

Wrap the data of na image into an array.

Parameters
imgThe image to wrap
Returns
An array with the same type as the image img.
Note
the returned array must unwrap using the function cpl_array_unwrap().
See also
cpl_array_unwrap().

Definition at line 1776 of file gravi_cpl.c.

Referenced by gravi_compute_dark(), and gravi_compute_profile().

cpl_image* gravi_image_from_column ( cpl_table *  table_data,
const char *  data_x,
cpl_size  row 
)

Create an image from a column array in table.

Parameters
table_dataThe input table
data_xThe column name
rowThe row to extract

The array is copied into image of same type. The returned pointer shall be deleted with cpl_image_delete

FIXME: to be optimized

Definition at line 1687 of file gravi_cpl.c.

References gravi_imagelist_unwrap_images(), and gravi_imagelist_wrap_column().

Referenced by gravi_compute_gain(), and gravi_compute_profile().

double gravi_image_get_quantile ( const cpl_image *  img,
double  thr 
)

Compute the quantile of an image.

Parameters
imginput image
thrquantile fraction (0 < thr < 1)

Compute the value of the image corresponding to the quantile fraction 'thr', that is such that their is nx*ny*thr pixels with values lower the returned value.

Definition at line 2112 of file gravi_cpl.c.

Referenced by gravi_compute_badpix(), and gravi_compute_biasmask().

cpl_imagelist* gravi_imagelist_from_column ( cpl_table *  table_data,
const char *  data_x 
)

Create an imagelist from a column array in table.

Parameters
table_dataThe input table
data_xThe column name

The array of each row are copied into image of their type, and append into the returned imagelist. The returned pointer shall be deleted with cpl_imagelist_delete

FIXME: to be optimized

Definition at line 1719 of file gravi_cpl.c.

References gravi_imagelist_unwrap_images(), and gravi_imagelist_wrap_column().

Referenced by gravi_compute_gain().

cpl_error_code gravi_imagelist_unwrap_images ( cpl_imagelist *  imglist)

Unwrap an imagelist an all its images.

Parameters
imglistThe imagelist to unwrap

All the images of imaglist are unwrapped, that is the data remain allocated but the image structure is deleted (see cpl_image_unwrap). Then the imagelist structure itself is deleted with cpl_imagelist_delete.

Definition at line 1496 of file gravi_cpl.c.

Referenced by gravi_compute_dark(), gravi_compute_p2vm(), gravi_compute_profile(), gravi_image_from_column(), gravi_imagelist_from_column(), gravi_imglist_sc_collapse(), and gravi_wave_test_image().

cpl_imagelist* gravi_imagelist_wrap_column ( cpl_table *  table_data,
const char *  data_x 
)

Wrap a column array of a table into an imagelist.

Parameters
table_dataThe input table
data_xThe column name

The array of each row are wrapped into image of their type, and append into the returned imagelist. The returned pointer shall be deleted with gravi_imagelist_unwrap_images

Definition at line 1526 of file gravi_cpl.c.

Referenced by gravi_compute_dark(), gravi_compute_p2vm(), gravi_compute_profile(), gravi_image_from_column(), gravi_imagelist_from_column(), gravi_imglist_sc_collapse(), and gravi_wave_test_image().

cpl_matrix* gravi_matrix_interpolate_col ( cpl_matrix *  matrix,
cpl_vector *  xref,
cpl_vector *  xout 
)

Linear interpolation of matrix column.

Parameters
matrixThe input matrix to interpolate (size n,m)
xrefThe vector of current x axis (size m)
xoutThe vector of target x axis (size k)
Returns
A newly allocated matrix of size (n,k)

The routine interpolate each column of the matrix using cpl_bivector_interpolate_linear

Definition at line 2432 of file gravi_cpl.c.

cpl_matrix* gravi_matrix_invertSV_create ( cpl_matrix *  a_in)

Invers a matrix with singular value decomposition.

Parameters
a_inThe input matrix to invert
Returns
Inverse matrix. In case of error a NULL is returned.

Definition at line 2486 of file gravi_cpl.c.

Referenced by gravi_compute_p2vm(), and gravi_compute_p2vmred().

cpl_error_code gravi_table_add_scalar ( cpl_table *  table,
const char *  name,
int  base,
int  nbase,
double  value 
)

Multply scalar or array column by scalar.

Parameters
tableThe table to modify in-place
nameThe name of the column to modify
baseThe starting row
nbaseThe row increment
valueValue to add

Each row in base::nbase (pythonic notation) of the column name is being added by value.

Definition at line 2381 of file gravi_cpl.c.

Referenced by gravi_opds_compute_guess().

int gravi_table_are_equal ( cpl_table *  first,
cpl_table *  second 
)

Check if two tables have the same content.

Parameters
firsttable to compare
secondtable to compare
Returns
1 / 0

Definition at line 1358 of file gravi_cpl.c.

Referenced by gravi_data_append().

cpl_table* gravi_table_extract_time_interval ( cpl_table *  table,
double  start,
double  end 
)

Extract rows from table based on the TIME column.

Parameters
tableinput table
start,endmax and min accepted time.
Returns
A new table, with rows matching TIME>=start && TIME<end

Definition at line 2826 of file gravi_cpl.c.

Referenced by gravi_compute_vis().

cpl_array* gravi_table_get_column_dimension ( const cpl_table *  table,
const char *  name 
)

Return an array ready for cpl_table_set_column_dimension.

Parameters
tableThe input table
nameThe column name

The return array (CPL_TYPE_INT) is of size the number returned by cpl_table_get_column_dimensions, and each values corresponds to the dimension returned by cpl_table_get_column_dimension

Definition at line 1749 of file gravi_cpl.c.

cpl_vector* gravi_table_get_vector ( cpl_table *  spectrum_data,
cpl_size  index,
const char *  regname 
)

Create a vector from the row index of the column regname.

Parameters
spectrum_tableThe table loaded from the SPECTRUM_DATA field
regnameThe column's name on the table
indexThe index on the row (0 for a scalar column)
Returns
An allocated vector with values extracted from the table

Create a vector from the row index of the column regname The returned vector must be deallocated.

Definition at line 1870 of file gravi_cpl.c.

Referenced by gravi_compute_disp(), gravi_compute_p2vm(), gravi_ellipse_meanopd_create(), gravi_p2vm_normalisation(), and gravi_wave_fibre().

cpl_vector* gravi_table_get_vector_diff ( cpl_table *  spectrum_data,
int  index,
const char *  regname1,
const char *  regname2 
)

Create a vector from the row index of the column regname.

Parameters
spectrum_tableThe table loaded from the SPECTRUM_DATA field
indexThe index on the row
regname1The column's name on the table
regname2The column's name on the table
Returns
An allocated vector with values extracted from the table regname1[index] - regname2[index]

Create a vector from the row index of the column regname The returned vector must be deallocated.

Definition at line 1991 of file gravi_cpl.c.

cpl_error_code gravi_table_multiply_scalar ( cpl_table *  table,
const char *  name,
int  base,
int  nbase,
double  value 
)

Multiply scalar or array column by scalar.

Parameters
tableThe table to modify in-place
nameThe name of the column to modify
baseThe starting row
nbaseThe row increment
valueValue to multiply

Each row in base::nbase (pythonic notation) of the column name is being multiplied by value.

Definition at line 2331 of file gravi_cpl.c.

Referenced by gravi_compute_disp().

cpl_error_code gravi_table_set_string_fixlen ( cpl_table *  table,
const char *  name,
int  row,
const char *  value,
int  len 
)

Set string in table, ensuring fixed length (right space padding). see cpl_table_set_string.

Parameters
len,thespecified maximum length of the string.
Returns
CPL_ERRROR_NONE

Definition at line 605 of file gravi_cpl.c.

Referenced by gravi_create_oiarray_table(), and gravi_create_oitarget_table().

cpl_vector* gravi_vector_extract ( const cpl_vector *  vector,
int  start,
int  step 
)

Extract part of a vector.

Parameters
vectorInput vector (size)
startStarting index (0...size-1)
stepStep index, so the returned values are every step
Returns
A new vector with size size/step

Definition at line 2261 of file gravi_cpl.c.

Referenced by gravi_compute_disp().

cpl_size gravi_vector_get_maxpos ( cpl_vector *  vector)

Return the index of maximum in a vector. If several indexes exists with the maximum value, the smallest index is returned.

Parameters
vectorInput vector (size)
Returns
The index of maximum or NULL on error

Definition at line 2179 of file gravi_cpl.c.

Referenced by gravi_compute_disp().

double gravi_vector_get_mean_clip ( cpl_vector *  vector_in,
double  percent,
double  nsigma 
)

Return the mean of a vector after extrema and RMS clipping.

Parameters
vector_ininput vector
percent0-1, fraction of extremes values rejected
nsigmasigma clipping
Returns
The mean of accepted values after

Definition at line 2207 of file gravi_cpl.c.

Referenced by gravi_data_detector_cleanup().

cpl_error_code gravi_vector_unwrap_with_guess ( cpl_vector *  vector,
cpl_vector *  ref,
double  ref_to_phase 
)

Unwrap a phase vector following a guess vector. The difference is actually unwrap and shall thus be slowly evolving. The operration if performed in-place.

Parameters
vectorto unwrap [rad]
refis the guess
ref_to_phaseis the coefficient to convert ref into [rad]

Definition at line 2284 of file gravi_cpl.c.

Referenced by gravi_ellipse_meanopd_create(), and gravi_wave_fibre().