LAL  7.5.0.1-bede9b2
TimeSeriesInterp.c File Reference

Prototypes

static void default_kernel (double *cached_kernel, int kernel_length, double residual, void *data)
 
LALREAL8SequenceInterp * XLALREAL8SequenceInterpCreate (const REAL8Sequence *s, int kernel_length, void(*kernel)(double *, int, double, void *), void *kernel_data)
 Create a new REAL8Sequence interpolator associated with the given REAL8Sequence object. More...
 
void XLALREAL8SequenceInterpDestroy (LALREAL8SequenceInterp *interp)
 Free a LALREAL8SequenceInterp object. More...
 
REAL8 XLALREAL8SequenceInterpEval (LALREAL8SequenceInterp *interp, double x, int bounds_check)
 Evaluate a LALREAL8SequenceInterp at the real-valued index x. More...
 
LALREAL8TimeSeriesInterp * XLALREAL8TimeSeriesInterpCreate (const REAL8TimeSeries *series, int kernel_length, void(*kernel)(double *, int, double, void *), void *kernel_data)
 Create a new REAL8TimeSeries interpolator associated with the given REAL8TimeSeries object. More...
 
void XLALREAL8TimeSeriesInterpDestroy (LALREAL8TimeSeriesInterp *interp)
 Free a LALREAL8TimeSeriesInterp object. More...
 
REAL8 XLALREAL8TimeSeriesInterpEval (LALREAL8TimeSeriesInterp *interp, const LIGOTimeGPS *t, int bounds_check)
 Evaluate a LALREAL8TimeSeriesInterp at the LIGOTimeGPS t. More...
 

Go to the source code of this file.

Data Structures

struct  default_kernel_data
 Default kernel function. More...
 
struct  LALREAL8SequenceInterp
 Opaque LALREAL8SequenceInterp instance structure. More...
 
struct  LALREAL8TimeSeriesInterp
 Opaque LALREAL8TimeSeriesInterp structure. More...
 

Function Documentation

◆ default_kernel()

static void default_kernel ( double *  cached_kernel,
int  kernel_length,
double  residual,
void *  data 
)
static

Definition at line 54 of file TimeSeriesInterp.c.

◆ XLALREAL8SequenceInterpCreate()

LALREAL8SequenceInterp* XLALREAL8SequenceInterpCreate ( const REAL8Sequence s,
int  kernel_length,
void(*)(double *, int, double, void *)  kernel,
void *  kernel_data 
)

Create a new REAL8Sequence interpolator associated with the given REAL8Sequence object.

The kernel_length parameter sets the length of the interpolating kernel in samples. Use XLALREAL8SequenceInterpDestroy() to free.

The optional kernel() function has the signature

void (*kernel)(double *kern, int length, double residual, void *data);

The optional kernel_data parameter will be passed to kernel() as the final argument. It is an error to provide a non-NULL kernel_data pointer without supplying a kernel() function. If both are NULL, an internal default Welch-windowed sinc kernel function will be used. If supplied, the kernel() function is responsible for computing the time-domain interpolation kernel. The kernel must be exactly length samples long and be placed in the kernel array, which is guaranteed to be non-NULL and large enough to contain length samples. length is guaranteed to be odd, and not less than 3.

residual is the interval from the nearest available sample of source data to the co-ordinate at which the user has requested the interpolated function be evaluated. The middle sample of the kernel will be the weight applied to that sample of source data. A purely sinc() kernel function would be of the form

static voic kernel(double *kern, int length, double res, void *ignored) { int i;

for(i = 0; i < length; i++) { double x = i - (length - 1) / 2.; kern[i] = x ? sin(PI * x + res) / (PI * x + res) : 1.; } }

Notes:

The LALREAL8SequenceInterp object is opaque. Calling code should not attempt to inspect nor manipulate its contents directly.

The REAL8Sequence object with which the LALREAL8SequenceInterp is associated must remain valid as long as the interpolator exists. Do not free the REAL8Sequence before freeing the LALREAL8SequenceInterp.

Definition at line 169 of file TimeSeriesInterp.c.

◆ XLALREAL8SequenceInterpDestroy()

void XLALREAL8SequenceInterpDestroy ( LALREAL8SequenceInterp *  interp)

Free a LALREAL8SequenceInterp object.

NULL is no-op.

Definition at line 233 of file TimeSeriesInterp.c.

◆ XLALREAL8SequenceInterpEval()

REAL8 XLALREAL8SequenceInterpEval ( LALREAL8SequenceInterp *  interp,
double  x,
int  bounds_check 
)

Evaluate a LALREAL8SequenceInterp at the real-valued index x.

The data beyond the domain of the input sequence are assumed to be 0 when computing results near (or beyond) the boundaries. An XLAL_EDOM domain error is raised if x is not finite. If bounds_check is non-zero then an XLAL_EDOM domain error is also raised if x is not in [0, length) where length is the sample count of the sequence to which the interpolator is attached.

Be aware that for performance reasons the interpolating kernel is cached and only recomputed if the error estimated to arise from failing to recompute it exceeds the error estimated to arise from using a finite interpolating kernel. Therefore, if a function is interpolated at very high resolution with a short kernel the result will consist of intervals of constant values in a stair-step pattern. The stair steps should be a small contribution to the interpolation error but numerical differentiation of the result is likely to be unsatisfactory. In that case, consider interpolating the derivative or use a longer kernel to force more frequent kernel updates.

Definition at line 274 of file TimeSeriesInterp.c.

◆ XLALREAL8TimeSeriesInterpCreate()

LALREAL8TimeSeriesInterp* XLALREAL8TimeSeriesInterpCreate ( const REAL8TimeSeries series,
int  kernel_length,
void(*)(double *, int, double, void *)  kernel,
void *  kernel_data 
)

Create a new REAL8TimeSeries interpolator associated with the given REAL8TimeSeries object.

The kernel_length parameter sets the length of the interpolating kernel in samples. Use XLALREAL8TimeSeriesInterpDestroy() to free.

See XLALREAL8SequenceInterpCreate() for the definition of the kernel and kernel_data parameters. These are optional; set both to NULL to use the internal default interpolation kernel.

Notes:

The LALREAL8TimeSeriesInterp object is opaque. Calling code should not attempt to inspect nor manipulate its contents directly.

The REAL8TimeSeries object with which the LALREAL8TimeSeriesInterp is associated must remain valid as long as the interpolator exists. Do not free the REAL8TimeSeries before freeing the LALREAL8TimeSeriesInterp.

Definition at line 346 of file TimeSeriesInterp.c.

◆ XLALREAL8TimeSeriesInterpDestroy()

void XLALREAL8TimeSeriesInterpDestroy ( LALREAL8TimeSeriesInterp *  interp)

Free a LALREAL8TimeSeriesInterp object.

NULL is no-op.

Definition at line 371 of file TimeSeriesInterp.c.

◆ XLALREAL8TimeSeriesInterpEval()

REAL8 XLALREAL8TimeSeriesInterpEval ( LALREAL8TimeSeriesInterp *  interp,
const LIGOTimeGPS t,
int  bounds_check 
)

Evaluate a LALREAL8TimeSeriesInterp at the LIGOTimeGPS t.

Raises a XLAL_EDOM domain error if t is not in [epoch, epoch + length * deltaT) where epoch, length, and deltaT are the start time, sample count, and sample period, respectively, of the time series to which the interpolator is attached.

See XLALREAL8SequenceInterpEval() for information about the interpolation kernel that is used and performance enhancements that can give rise to numerical artifacts.

Definition at line 396 of file TimeSeriesInterp.c.