Waveform handling routines


Detailed Description

This module contains the basic waveform handling routines and structures for libbpm

The bpmwf sublibrary implements 3 waveform types doublewf_t, intwf_t and complexwf_t, all of which are simple structure typedefs which hold the number of samples, the sampling frequency and a pointer "wf" to the waveform. So the data array is accessible via doublewf_t::wf as a normal array of integers, doubles and complex_t 's.

Memory management

All have memory management routines (allocation/deletion) and routines to cast to other times ( eg doublewf_t -> intwf_t or the other way around ). This can be done either by filling existing waveforms ( convenient when you e.g. have already allocated memory and referenced it into a root branch ) or by having the casting routine allocate memory itself and return a pointer to it. e.g:

   intwf_t *w = intwf_cast_new( doublewf_t *dw );

this allocates memory for intwf_t and returns a pointer it, or

   intwf_cast( intwf_t *w, doublewf_t *dw );  

this casts dw into existing intwf w.

The sublibrary employs the sampling convention, where the sample is taken at the time index corresponding to

   t = (double) i / sampling_freq

Waveform handling

The sublibrary implements basic waveform hanlding like addition, subtraction, multiplication, division, biasing and scaling.

Some advanced routines like differentiation, integration of the waveforms are also present. Also interpolation is impemented using various schemes which are more applicable depending on the type of waveform : linear, parabolic : for non repeatative signals, sinc and lanczos for repeatative signals (cfr. Shannon-Whittaker interpolation). (thinking of cubic-spline as well... but not implemented yet). Using these interpolation schemes, the sublibrary also implements resampling routines.

The complex waveforms have a set of routines to extract real/imag parts as well as phase and amplitude. Similar comments apply as for the casting routines, where the "_new" versions allocate memory in the routine and return a pointer to it.

Filling the waveforms

The values of the waveforms can be set by either filling them from a given array of values using e.g.

   doublewf_setvalues( doublewf_t *w, double *a)

or by calculating them from a function which returns the basic type of the waveform.

E.g. define a complex valued function in your code:

   complex_t csin( double t, int npars, double a ) {
     complex_t z
     // calculate a complex number z from the time t and parameters...
     return z;
   }

which returns a complex value from the time t and having npar paramaters a[0] ... a[n-1]

You can fill a waveform ( and so bascially sample the function at sampling frequency fs ) by executing

   complexwf_setfunction( complexwf_t *z, &csin, npars, a )

Also some routines are added to fill the waveforms with CW tones and decaying waves, along with some noise adding routines etc...

Note on the interpolation options.

Here are some examples of the different interpolation options that one can give to the doublewf/complexwf_getvalue() or _resample() routines.

linear_interpolation.gif

The WF_LINEAR interpolation option

quadratic_interpolation.gif

The WF_QUADRATIC interpolation ption

sinc_interpolation.gif

The WF_SINC interpolation option

lanczos_interpolation.gif

The WF_LANCZOS interpolation option

For examples...

For examples on library use, please see the examples/wf directory in the libbpm main tree...

Todo list


Files

file  bpm_wf.h
 Simple waveform handling routines for libbpm.
file  complexwf.c
file  doublewf.c
file  intwf.c
file  wfstats.c

Data Structures

struct  doublewf_t
struct  intwf_t
struct  complexwf_t
struct  wfstat_t

Defines

#define WF_EPS
#define MAX_ALLOWED_NS
#define WF_NEAREST
#define WF_LINEAR
#define WF_QUADRATIC
#define WF_SINC
#define WF_LANCZOS

Functions

EXTERN int wfstat_reset (wfstat_t *s)
EXTERN void wfstat_print (FILE *of, wfstat_t *s)
EXTERN doublewf_tdoublewf (int ns, double fs)
EXTERN doublewf_tdoublewf_time_series (int ns, double fs)
EXTERN doublewf_tdoublewf_sample_series (int ns, double fs)
EXTERN doublewf_tdoublewf_frequency_series (int ns, double fs)
EXTERN int doublewf_setvalues (doublewf_t *w, double *x)
EXTERN int doublewf_setfunction (doublewf_t *w, double(*wffun)(double t, int, double *), int npars, double *par)
EXTERN int doublewf_copy (doublewf_t *copy, doublewf_t *src)
EXTERN doublewf_tdoublewf_copy_new (doublewf_t *w)
EXTERN int doublewf_subset (doublewf_t *sub, doublewf_t *w, int i1, int i2)
EXTERN int doublewf_reset (doublewf_t *w)
EXTERN void doublewf_delete (doublewf_t *w)
EXTERN intwf_tintwf_cast_new (doublewf_t *w)
EXTERN int intwf_cast (intwf_t *iw, doublewf_t *w)
EXTERN int doublewf_compat (doublewf_t *w1, doublewf_t *w2)
EXTERN int doublewf_add (doublewf_t *w1, doublewf_t *w2)
EXTERN int doublewf_subtract (doublewf_t *w1, doublewf_t *w2)
EXTERN int doublewf_multiply (doublewf_t *w1, doublewf_t *w2)
EXTERN int doublewf_divide (doublewf_t *w1, doublewf_t *w2)
EXTERN int doublewf_scale (double f, doublewf_t *w)
EXTERN int doublewf_bias (double c, doublewf_t *w)
EXTERN int doublewf_add_cwtone (doublewf_t *w, double amp, double phase, double freq, double phasenoise)
EXTERN int doublewf_add_dcywave (doublewf_t *w, double amp, double phase, double freq, double ttrig, double tdcy, double phasenoise)
EXTERN int doublewf_add_ampnoise (doublewf_t *w, double sigma)
EXTERN int doublewf_basic_stats (doublewf_t *w, int s0, int s1, wfstat_t *stats)
EXTERN int doublewf_derive (doublewf_t *w)
EXTERN int doublewf_integrate (doublewf_t *w)
EXTERN void doublewf_print (FILE *of, doublewf_t *w)
EXTERN double doublewf_getvalue (doublewf_t *w, double t, unsigned int mode)
EXTERN int doublewf_resample (doublewf_t *w2, double fs, doublewf_t *w1, unsigned int mode)
EXTERN intwf_tintwf (int ns, double fs)
EXTERN intwf_tintwf_sample_series (int ns, double fs)
EXTERN int intwf_setvalues (intwf_t *w, int *x)
EXTERN int intwf_setfunction (intwf_t *w, int(*wffun)(double t, int, double *), int npars, double *par)
EXTERN int intwf_copy (intwf_t *copy, intwf_t *src)
EXTERN intwf_tintwf_copy_new (intwf_t *w)
EXTERN int intwf_subset (intwf_t *sub, intwf_t *w, int i1, int i2)
EXTERN int intwf_reset (intwf_t *w)
EXTERN void intwf_delete (intwf_t *w)
EXTERN doublewf_tdoublewf_cast_new (intwf_t *w)
EXTERN int doublewf_cast (doublewf_t *w, intwf_t *iw)
EXTERN int intwf_compat (intwf_t *w1, intwf_t *w2)
EXTERN int intwf_add (intwf_t *w1, intwf_t *w2)
EXTERN int intwf_subtract (intwf_t *w1, intwf_t *w2)
EXTERN int intwf_multiply (intwf_t *w1, intwf_t *w2)
EXTERN int intwf_divide (intwf_t *w1, intwf_t *w2)
EXTERN int intwf_scale (int f, intwf_t *w)
EXTERN int intwf_bias (int c, intwf_t *w)
EXTERN int intwf_add_cwtone (intwf_t *w, double amp, double phase, double freq, double phasenoise)
EXTERN int intwf_add_dcywave (intwf_t *w, double amp, double phase, double freq, double ttrig, double tdcy, double phasenoise)
EXTERN int intwf_add_ampnoise (intwf_t *w, double sigma)
EXTERN int intwf_basic_stats (intwf_t *w, int s0, int s1, wfstat_t *stats)
EXTERN int intwf_derive (intwf_t *w)
EXTERN int intwf_integrate (intwf_t *w)
EXTERN void intwf_print (FILE *of, intwf_t *w)
EXTERN int intwf_getvalue (intwf_t *w, double t, unsigned int mode)
EXTERN int intwf_resample (intwf_t *w2, double fs, intwf_t *w1, unsigned int mode)
EXTERN complexwf_tcomplexwf (int ns, double fs)
EXTERN complexwf_tcomplexwf_copy_new (complexwf_t *w)
EXTERN int complexwf_copy (complexwf_t *copy, complexwf_t *src)
EXTERN int complexwf_subset (complexwf_t *sub, complexwf_t *w, int i1, int i2)
EXTERN int complexwf_setvalues (complexwf_t *w, complex_t *x)
EXTERN int complexwf_setfunction (complexwf_t *w, complex_t(*wffun)(double, int, double *), int npars, double *par)
EXTERN int complexwf_reset (complexwf_t *w)
EXTERN void complexwf_delete (complexwf_t *w)
EXTERN int complexwf_compat (complexwf_t *w1, complexwf_t *w2)
EXTERN int complexwf_add (complexwf_t *w1, complexwf_t *w2)
EXTERN int complexwf_subtract (complexwf_t *w1, complexwf_t *w2)
EXTERN int complexwf_multiply (complexwf_t *w1, complexwf_t *w2)
EXTERN int complexwf_divide (complexwf_t *w1, complexwf_t *w2)
EXTERN int complexwf_scale (complex_t f, complexwf_t *w)
EXTERN int complexwf_bias (complex_t c, complexwf_t *w)
EXTERN int complexwf_add_cwtone (complexwf_t *w, double amp, double phase, double freq, double phasenoise)
EXTERN int complexwf_add_dcywave (complexwf_t *w, double amp, double phase, double freq, double ttrig, double tdcy, double phasenoise)
EXTERN int complexwf_add_noise (complexwf_t *w, double sigma)
EXTERN int complexwf_add_ampnoise (complexwf_t *w, double sigma)
EXTERN int complexwf_add_phasenoise (complexwf_t *w, double sigma)
EXTERN void complexwf_print (FILE *of, complexwf_t *w)
EXTERN int complexwf_getreal (doublewf_t *re, complexwf_t *z)
EXTERN int complexwf_getimag (doublewf_t *im, complexwf_t *z)
EXTERN int complexwf_getamp (doublewf_t *r, complexwf_t *z)
EXTERN int complexwf_getphase (doublewf_t *theta, complexwf_t *z)
EXTERN doublewf_tcomplexwf_getreal_new (complexwf_t *z)
EXTERN doublewf_tcomplexwf_getimag_new (complexwf_t *z)
EXTERN doublewf_tcomplexwf_getamp_new (complexwf_t *z)
EXTERN doublewf_tcomplexwf_getphase_new (complexwf_t *z)
EXTERN int complexwf_setreal (complexwf_t *z, doublewf_t *re)
EXTERN int complexwf_setimag (complexwf_t *z, doublewf_t *im)
EXTERN int time_to_sample (double fs, int ns, double t, int *iS)
EXTERN int freq_to_sample (double fs, int ns, double f, int *iS)
EXTERN int sample_to_time (double fs, int ns, int iS, double *t)
EXTERN int sample_to_freq (double fs, int ns, int iS, double *f)


Define Documentation

#define WF_EPS

A small number

Definition at line 157 of file bpm_wf.h.

Referenced by complexwf_compat(), doublewf_compat(), and intwf_compat().

#define MAX_ALLOWED_NS

Maximum allowed number of samples (2^18)

Definition at line 158 of file bpm_wf.h.

Referenced by complexwf(), doublewf(), doublewf_resample(), intwf(), and intwf_resample().

#define WF_NEAREST

No interpolation, return nearest sample

Definition at line 160 of file bpm_wf.h.

#define WF_LINEAR

Perform linear interpolation in XXXwf_getsample()

Definition at line 161 of file bpm_wf.h.

Referenced by doublewf_getvalue().

#define WF_QUADRATIC

Perform quadratic (parabolic) interpolation

Definition at line 162 of file bpm_wf.h.

Referenced by doublewf_getvalue(), and generate_bpmsignal().

#define WF_SINC

signal reconstruction using sinc kernel (0..ns)

Definition at line 163 of file bpm_wf.h.

Referenced by doublewf_getvalue().

#define WF_LANCZOS

signal reconstruction using lanczos kernel (a=3)

Definition at line 164 of file bpm_wf.h.

Referenced by doublewf_getvalue().


Function Documentation

EXTERN int wfstat_reset ( wfstat_t s  ) 

Reset the waveform statistics structure.

Parameters:
s A pointer to a wfstat_t structure
Returns:
BPM_SUCCESS upon success, BPM_FAILURE upon failure

Definition at line 8 of file wfstats.c.

References bpm_error(), wfstat_t::imax, wfstat_t::imin, wfstat_t::max, wfstat_t::mean, wfstat_t::min, and wfstat_t::rms.

Referenced by doublewf_basic_stats().

EXTERN void wfstat_print ( FILE *  of,
wfstat_t s 
)

Prints the waveform statistics to the screen,

Parameters:
of A filepointer
s A pointer to the waveform statistics structure
Returns:
void

Definition at line 29 of file wfstats.c.

References bpm_error(), wfstat_t::imax, wfstat_t::imin, wfstat_t::max, wfstat_t::mean, wfstat_t::min, and wfstat_t::rms.

EXTERN doublewf_t* doublewf ( int  ns,
double  fs 
)

Allocates memory for a new waveform of doubles

Parameters:
ns The number of samples in the waveform
fs The sampling frequency of the waveform
Returns:
A pointer to the allocated waveform structure

Definition at line 8 of file doublewf.c.

References bpm_error(), doublewf_t::fs, MAX_ALLOWED_NS, doublewf_t::ns, and doublewf_t::wf.

Referenced by complexwf_getamp_new(), complexwf_getimag_new(), complexwf_getphase_new(), complexwf_getreal_new(), ddc_initialise(), doublewf_cast_new(), doublewf_copy_new(), doublewf_frequency_series(), doublewf_sample_series(), doublewf_time_series(), fit_waveform(), generate_bpmsignal(), generate_diodesignal(), and get_mode_response().

EXTERN doublewf_t* doublewf_time_series ( int  ns,
double  fs 
)

Allocates memory for a new waveform of doubles and fills it with the sample time values

Parameters:
ns The number of samples in the waveform
fs The sampling frequency of the waveform
Returns:
A pointer to the allocated waveform structure

Definition at line 63 of file doublewf.c.

References doublewf(), doublewf_t::fs, doublewf_t::ns, and doublewf_t::wf.

EXTERN doublewf_t* doublewf_sample_series ( int  ns,
double  fs 
)

Allocates memory for a new waveform of doubles and fills it with sample numbers.

Parameters:
ns The number of samples in the waveform
fs The sampling frequency of the waveform
Returns:
A pointer to the allocated waveform structure

Definition at line 50 of file doublewf.c.

References doublewf(), doublewf_t::ns, and doublewf_t::wf.

EXTERN doublewf_t* doublewf_frequency_series ( int  ns,
double  fs 
)

Allocates memory for a new waveform of doubles and fills it with the frequency values

Parameters:
ns The number of samples in the waveform
fs The sampling frequency of the waveform
Returns:
A pointer to the allocated waveform structure

Definition at line 76 of file doublewf.c.

References doublewf(), doublewf_t::fs, doublewf_t::ns, and doublewf_t::wf.

EXTERN int doublewf_setvalues ( doublewf_t w,
double *  x 
)

Fills the waveform of doubles with the values from the array x. No check is performed whether x contains enough samples, the user needs to be sure this is the case !

Parameters:
w A pointer to the waveform of doubles
x A pointer to the x values
Returns:
BPM_SUCCESS upon succes, BPM_FAILURE upon failure.

Definition at line 151 of file doublewf.c.

References bpm_error(), doublewf_t::ns, and doublewf_t::wf.

EXTERN int doublewf_setfunction ( doublewf_t w,
double(*)(double t, int, double *)  wffun,
int  npars,
double *  par 
)

Fills the waveform with values from the function wffun(), this function has to return a double from argument t ( time ) and has npars parameters given by the array *par. The function will be evaluated at the time t of each sample...

Parameters:
w A pointer to the waveform of doubles
wffun A pointer to the function to fill the waveform with
t The time parameter in the function
npars Number of parameters for the function
par Array of parameters for the function
Returns:
BPM_SUCCESS upon succes, BPM_FAILURE upon failure.

EXTERN int doublewf_copy ( doublewf_t copy,
doublewf_t src 
)

Copies the values from existing waveform src into copy checks first whether the waveforms are compatible... This routine doesn't allocate memory internally and the waveforms should already have been created by the user...

Parameters:
copy A pointer to the copy waveform
src A pointer to the original waveform
Returns:
BPM_SUCCESS upon succes, BPM_FAILURE upon failure.

Definition at line 106 of file doublewf.c.

References bpm_error(), doublewf_compat(), doublewf_t::ns, and doublewf_t::wf.

Referenced by rf_mixer().

EXTERN doublewf_t* doublewf_copy_new ( doublewf_t w  ) 

Allocates memory and produces a copy of the waveform w;

Parameters:
w A pointer to the original waveform
Returns:
A pointer to the copy of w

Definition at line 89 of file doublewf.c.

References bpm_error(), doublewf(), doublewf_t::fs, doublewf_t::ns, and doublewf_t::wf.

EXTERN int doublewf_subset ( doublewf_t sub,
doublewf_t w,
int  i1,
int  i2 
)

Copies a subset from sample i1 to sample i2 ( inclusive ) to the sub waveform from waveform w. The routine expects the sub waveform to already exist with enough samples. ( this is not checked ! ) The sub->fs and sub->ns will be overwritten.

Parameters:
sub Pointer to the waveform which will hold the subset
w Pointer to the original waveform
i1 First sample of w to copy
i2 Last sample of w to copy
Returns:
BPM_SUCCESS upon succes, BPM_FAILURE upon failure.

Definition at line 127 of file doublewf.c.

References bpm_error(), doublewf_t::fs, doublewf_t::ns, and doublewf_t::wf.

EXTERN int doublewf_reset ( doublewf_t w  ) 

Resets the waveform of doubles to 0.

Parameters:
w A pointer to the waveform of doubles
Returns:
BPM_SUCCESS upon succes, BPM_FAILURE upon failure.

Definition at line 185 of file doublewf.c.

References bpm_error(), doublewf_t::ns, and doublewf_t::wf.

Referenced by generate_bpmsignal().

EXTERN void doublewf_delete ( doublewf_t w  ) 

Frees up the memory used by the waveform

Parameters:
w A pointer to the waveform of doubles
Returns:
void

Definition at line 202 of file doublewf.c.

References bpm_warning(), and doublewf_t::wf.

Referenced by ddc_cleanup(), fit_waveform(), get_mode_response(), intwf_basic_stats(), intwf_getvalue(), and intwf_resample().

EXTERN intwf_t* intwf_cast_new ( doublewf_t w  ) 

Cast the waveform of doubles to a new waveform of integers. Memory is allocated inside this routine so the user just needs to have a inwf_t pointer ready.

Parameters:
w A pointer to the waveform of doubles
Returns:
A newly created intwf_t representation of the waveform of doubles

Definition at line 219 of file doublewf.c.

References bpm_error(), dround(), doublewf_t::fs, intwf(), intwf_t::ns, doublewf_t::ns, doublewf_t::wf, and intwf_t::wf.

EXTERN int intwf_cast ( intwf_t iw,
doublewf_t w 
)

Cast the waveform of doubles to an already existing waveform of integers.

Parameters:
iw A pointer to an existing waveform of integers
w A pointer to the waveform of doubles
Returns:
BPM_SUCCESS upon succes, BPM_FAILURE upon failure.

Definition at line 245 of file doublewf.c.

References bpm_error(), dround(), intwf_t::ns, doublewf_t::wf, and intwf_t::wf.

EXTERN int doublewf_compat ( doublewf_t w1,
doublewf_t w2 
)

Checks compatiblity of the two waveforms, returns true if the number of samples and the sampling frequencies match. For the sampling frequency, it is simply checked whether they match to WF_EPS.

Parameters:
w1 A pointer to the first waveform of doubles
w2 A pointer to the second waveform of doubles
Returns:
1 if the waveforms match, 0 if not.

Definition at line 263 of file doublewf.c.

References bpm_error(), doublewf_t::fs, doublewf_t::ns, and WF_EPS.

Referenced by doublewf_add(), doublewf_copy(), doublewf_divide(), doublewf_multiply(), and doublewf_subtract().

EXTERN int doublewf_add ( doublewf_t w1,
doublewf_t w2 
)

Adds two waveforms of doubles w1+w2 sample per sample. The result is stored in w1.

Parameters:
w1 A pointer to the first waveform of doubles
w2 A pointer to the second waveform of doubles
Returns:
BPM_SUCCESS upon succes, BPM_FAILURE upon failure.

Definition at line 276 of file doublewf.c.

References bpm_error(), bpm_warning(), doublewf_compat(), doublewf_t::ns, and doublewf_t::wf.

EXTERN int doublewf_subtract ( doublewf_t w1,
doublewf_t w2 
)

Subtracts two waveforms of doubles w1-w2 sample per sample. The result is stored in w1.

Parameters:
w1 A pointer to the first waveform of doubles
w2 A pointer to the second waveform of doubles
Returns:
BPM_SUCCESS upon succes, BPM_FAILURE upon failure.

Definition at line 297 of file doublewf.c.

References bpm_error(), bpm_warning(), doublewf_compat(), doublewf_t::ns, and doublewf_t::wf.

EXTERN int doublewf_multiply ( doublewf_t w1,
doublewf_t w2 
)

Multiplies two waveforms of doubles w1*w2 sample per sample. The result is stored in w1.

Parameters:
w1 A pointer to the first waveform of doubles
w2 A pointer to the second waveform of doubles
Returns:
BPM_SUCCESS upon succes, BPM_FAILURE upon failure.

Definition at line 317 of file doublewf.c.

References bpm_error(), bpm_warning(), doublewf_compat(), doublewf_t::ns, and doublewf_t::wf.

Referenced by rf_mixer().

EXTERN int doublewf_divide ( doublewf_t w1,
doublewf_t w2 
)

Divides two waveforms of doubles w1/w2 sample per sample. The result is stored in w1. When w2[i] is 0, w1[i] will be set to 0. and a warning message is printed.

Parameters:
w1 A pointer to the first waveform of doubles
w2 A pointer to the second waveform of doubles
Returns:
BPM_SUCCESS upon succes, BPM_FAILURE upon failure.

Definition at line 338 of file doublewf.c.

References bpm_error(), bpm_warning(), doublewf_compat(), doublewf_t::ns, and doublewf_t::wf.

EXTERN int doublewf_scale ( double  f,
doublewf_t w 
)

Scales the waveform of doubles w by factor f. The result is stored in w.

Parameters:
f The scalefactor
w A pointer to the waveform of doubles
Returns:
BPM_SUCCESS upon succes, BPM_FAILURE upon failure.

Definition at line 368 of file doublewf.c.

References bpm_error(), doublewf_t::ns, and doublewf_t::wf.

Referenced by get_mode_response(), and rf_amplify().

EXTERN int doublewf_bias ( double  c,
doublewf_t w 
)

Biases the waveform of doubles w by a constant c. The result is stored in w.

Parameters:
c The constant bias.
w A pointer to the waveform of doubles
Returns:
BPM_SUCCESS upon succes, BPM_FAILURE upon failure.

Definition at line 385 of file doublewf.c.

References bpm_error(), doublewf_t::ns, and doublewf_t::wf.

Referenced by process_caltone(), and process_waveform().

EXTERN int doublewf_add_cwtone ( doublewf_t w,
double  amp,
double  phase,
double  freq,
double  phasenoise 
)

Adds a cosine-like CW tone to the entire waveform. The sampling time is taken on the array index, so t=(double)i/w->fs.

Parameters:
w A pointer to the waveform structure
amp Amplitude of the CW tone
phase Phase of the CW tone
freq Frequency of the CW tone
phasenoise Sigma of the gaussian phasenoise
Returns:
BPM_SUCCESS upon succes, BPM_FAILURE upon failure.

Definition at line 402 of file doublewf.c.

References bpm_error(), doublewf_t::fs, nr_rangauss(), doublewf_t::ns, and doublewf_t::wf.

Referenced by rf_addLO().

EXTERN int doublewf_add_dcywave ( doublewf_t w,
double  amp,
double  phase,
double  freq,
double  ttrig,
double  tdcy,
double  phasenoise 
)

Adds a decaying wave pulse to the waveform. The sampling time is taken on the array index, so t=(double)i/w->fs. The added signal is of the form :

\[ amp e^{- ( t - ttrig ) / tdcy } cos( 2 \pi freq ( t- ttrig ) + phase ) \]

If desired, phasenoise is added to the phase of the waveform.

Parameters:
w A pointer to the waveform structure
amp Amplitude of the CW tone
phase Phase of the CW tone
freq Frequency of the CW tone
ttrig Trigger time of the pulse
tdcy Decay time of the pulse
phasenoise Sigma of the gaussian phasenoise
Returns:
BPM_SUCCESS upon succes, BPM_FAILURE upon failure.

Definition at line 422 of file doublewf.c.

References bpm_error(), doublewf_t::fs, nr_rangauss(), doublewf_t::ns, and doublewf_t::wf.

EXTERN int doublewf_add_ampnoise ( doublewf_t w,
double  sigma 
)

Adds gaussian amplitude noise to the waveform.

Parameters:
w A pointer to the waveform structure
sigma The gaussian sigma of the amplitude noise
Returns:
BPM_SUCCESS upon succes, BPM_FAILURE upon failure.

Definition at line 447 of file doublewf.c.

References bpm_error(), nr_rangauss(), doublewf_t::ns, and doublewf_t::wf.

EXTERN int doublewf_basic_stats ( doublewf_t w,
int  s0,
int  s1,
wfstat_t stats 
)

Retrieves some basic statistics about the waveform of doubles in w, only considers samples between s0 and s1.

Parameters:
w A pointer to the waveform structure
s0 First sample to consider
s1 Last sample to consider
stats A filled wfstat_t structure is returned.
Returns:
BPM_SUCCESS upon succes, BPM_FAILURE upon failure.

Definition at line 467 of file doublewf.c.

References bpm_error(), bpm_warning(), wfstat_t::imax, wfstat_t::imin, wfstat_t::max, wfstat_t::mean, wfstat_t::min, doublewf_t::ns, wfstat_t::rms, doublewf_t::wf, and wfstat_reset().

Referenced by get_pedestal(), intwf_basic_stats(), and process_diode().

EXTERN int doublewf_derive ( doublewf_t w  ) 

Produce the derivative waveform for w : dw/dt.

Parameters:
w A pointer to the waveform structure.
Returns:
BPM_SUCCESS upon succes, BPM_FAILURE upon failure

Definition at line 507 of file doublewf.c.

References bpm_error(), doublewf_t::fs, doublewf_t::ns, and doublewf_t::wf.

EXTERN int doublewf_integrate ( doublewf_t w  ) 

Produce the integrated waveform for w : ^t w(s)ds.

Parameters:
w A pointer to the waveform structure.
Returns:
BPM_SUCCESS upon succes, BPM_FAILURE upon failure

Definition at line 532 of file doublewf.c.

References bpm_error(), doublewf_t::fs, doublewf_t::ns, and doublewf_t::wf.

Referenced by get_mode_response().

EXTERN void doublewf_print ( FILE *  of,
doublewf_t w 
)

Print the waveform to the filepointer

Parameters:
of A filepointer, use stdout for the terminal
w A pointer to the waveform
Returns:
void

Definition at line 556 of file doublewf.c.

References bpm_error(), doublewf_t::fs, doublewf_t::ns, and doublewf_t::wf.

EXTERN double doublewf_getvalue ( doublewf_t w,
double  t,
unsigned int  mode 
)

Return the value for the waveform at sample time t, according to the interpolation mode.

Parameters:
w A pointer to the waveform structure
t A time at which to sample the waveform
mode Interpolation mode
Returns:
the value of the waveform at time t

Definition at line 575 of file doublewf.c.

References bpm_error(), doublewf_t::fs, lanczos(), nr_quadinterpol(), doublewf_t::ns, sinc(), doublewf_t::wf, WF_LANCZOS, WF_LINEAR, WF_QUADRATIC, and WF_SINC.

Referenced by digitise(), doublewf_resample(), generate_bpmsignal(), intwf_getvalue(), and intwf_resample().

EXTERN int doublewf_resample ( doublewf_t w2,
double  fs,
doublewf_t w1,
unsigned int  mode 
)

Resamples the waveform w1 into w2 with new fs sampling frequency This routine recalculates the correct number of samples required. However the user needs to make sure that there are enough samples in w2 available as this is not checked. The w2->ns value will be overwritten with the correct amount. The routine checkes whether the maximum allowed number of samples is not exceeded to avoid memory problems.

Parameters:
w A pointer to the waveform structure
t A time at which to sample the waveform
mode Interpolation mode
Returns:
the value of the waveform at time t

Definition at line 664 of file doublewf.c.

References bpm_error(), doublewf_getvalue(), doublewf_t::fs, MAX_ALLOWED_NS, doublewf_t::ns, and doublewf_t::wf.

EXTERN intwf_t* intwf ( int  ns,
double  fs 
)

Allocates memory for a new waveform of integers

Parameters:
ns The number of samples in the waveform
fs The sampling frequency of the waveform
Returns:
A pointer to the allocated waveform structure

Definition at line 8 of file intwf.c.

References bpm_error(), intwf_t::fs, MAX_ALLOWED_NS, intwf_t::ns, and intwf_t::wf.

Referenced by intwf_cast_new(), intwf_copy_new(), and intwf_sample_series().

EXTERN intwf_t* intwf_sample_series ( int  ns,
double  fs 
)

Allocates memory for a new waveform of integers and fills it with sample numbers.

Parameters:
ns The number of samples in the waveform
fs The sampling frequency of the waveform
Returns:
A pointer to the allocated waveform structure

Definition at line 50 of file intwf.c.

References intwf(), intwf_t::ns, and intwf_t::wf.

EXTERN int intwf_setvalues ( intwf_t w,
int *  x 
)

Fills the waveform of integers with the values from the array x. No check is performed whether x contains enough samples, the user needs to be sure this is the case !

Parameters:
w A pointer to the waveform of integers
x A pointer to the x values
Returns:
BPM_SUCCESS upon succes, BPM_FAILURE upon failure.

Definition at line 126 of file intwf.c.

References bpm_error(), intwf_t::ns, and intwf_t::wf.

EXTERN int intwf_setfunction ( intwf_t w,
int(*)(double t, int, double *)  wffun,
int  npars,
double *  par 
)

Fills the waveform with values from the function wffun(), this function has to return a double from argument t ( time ) and has npars parameters given by the array *par. The function will be evaluated at the time t of each sample...

Parameters:
w A pointer to the waveform of integers
wffun A pointer to the function to fill the waveform with
t The time parameter in the function
npars Number of parameters for the function
par Array of parameters for the function
Returns:
BPM_SUCCESS upon succes, BPM_FAILURE upon failure.

EXTERN int intwf_copy ( intwf_t copy,
intwf_t src 
)

Copies the values from existing waveform src into copy checks first whether the waveforms are compatible... This routine doesn't allocate memory internally and the waveforms should already have been created by the user...

Parameters:
copy A pointer to the copy waveform
src A pointer to the original waveform
Returns:
BPM_SUCCESS upon succes, BPM_FAILURE upon failure.

Definition at line 81 of file intwf.c.

References bpm_error(), intwf_compat(), intwf_t::ns, and intwf_t::wf.

EXTERN intwf_t* intwf_copy_new ( intwf_t w  ) 

Allocates memory and produces a copy of the waveform w;

Parameters:
w A pointer to the original waveform
Returns:
A pointer to the copy of w

Definition at line 63 of file intwf.c.

References bpm_error(), intwf_t::fs, intwf(), intwf_t::ns, and intwf_t::wf.

EXTERN int intwf_subset ( intwf_t sub,
intwf_t w,
int  i1,
int  i2 
)

Copies a subset from sample i1 to sample i2 ( inclusive ) to the sub waveform from waveform w. The routine expects the sub waveform to already exist with enough samples. ( this is not checked ! ) The sub->fs and sub->ns will be overwritten.

Parameters:
sub Pointer to the waveform which will hold the subset
w Pointer to the original waveform
i1 First sample of w to copy
i2 Last sample of w to copy
Returns:
BPM_SUCCESS upon succes, BPM_FAILURE upon failure.

Definition at line 102 of file intwf.c.

References bpm_error(), intwf_t::fs, intwf_t::ns, and intwf_t::wf.

EXTERN int intwf_reset ( intwf_t w  ) 

Resets the waveform of integers to 0.

Parameters:
w A pointer to the waveform of integers
Returns:
BPM_SUCCESS upon succes, BPM_FAILURE upon failure.

Definition at line 160 of file intwf.c.

References bpm_error(), intwf_t::ns, and intwf_t::wf.

EXTERN void intwf_delete ( intwf_t w  ) 

Frees up the memory used by the waveform

Parameters:
w A pointer to the waveform of integers
Returns:
void

Definition at line 177 of file intwf.c.

References bpm_warning(), and intwf_t::wf.

EXTERN doublewf_t* doublewf_cast_new ( intwf_t w  ) 

Cast the waveform of integers to a new waveform of doubles. Memory is allocated inside this routine so the user just needs to have a inwf_t pointer ready.

Parameters:
w A pointer to the waveform of integers
Returns:
A newly created doublewf_t representation of the waveform of integers

Definition at line 194 of file intwf.c.

References bpm_error(), doublewf(), intwf_t::fs, intwf_t::ns, intwf_t::wf, and doublewf_t::wf.

Referenced by intwf_basic_stats(), intwf_getvalue(), and intwf_resample().

EXTERN int doublewf_cast ( doublewf_t w,
intwf_t iw 
)

Cast the waveform of integers to an already existing waveform of doubles.

Parameters:
iw A pointer to an existing waveform of integers
w A pointer to the waveform of integers
Returns:
BPM_SUCCESS upon succes, BPM_FAILURE upon failure.

Definition at line 220 of file intwf.c.

References bpm_error(), intwf_t::ns, intwf_t::wf, and doublewf_t::wf.

EXTERN int intwf_compat ( intwf_t w1,
intwf_t w2 
)

Checks compatiblity of the two waveforms, returns true if the number of samples and the sampling frequencies match. For the sampling frequency, it is simply checked whether they match to WF_EPS.

Parameters:
w1 A pointer to the first waveform of integers
w2 A pointer to the second waveform of integers
Returns:
1 if the waveforms match, 0 if not.

Definition at line 238 of file intwf.c.

References bpm_error(), intwf_t::fs, intwf_t::ns, and WF_EPS.

Referenced by intwf_add(), intwf_copy(), intwf_divide(), intwf_multiply(), and intwf_subtract().

EXTERN int intwf_add ( intwf_t w1,
intwf_t w2 
)

Adds two waveforms of integers w1+w2 sample per sample. The result is stored in w1.

Parameters:
w1 A pointer to the first waveform of integers
w2 A pointer to the second waveform of integers
Returns:
BPM_SUCCESS upon succes, BPM_FAILURE upon failure.

Definition at line 251 of file intwf.c.

References bpm_error(), bpm_warning(), intwf_compat(), intwf_t::ns, and intwf_t::wf.

EXTERN int intwf_subtract ( intwf_t w1,
intwf_t w2 
)

Subtracts two waveforms of integers w1-w2 sample per sample. The result is stored in w1.

Parameters:
w1 A pointer to the first waveform of integers
w2 A pointer to the second waveform of integers
Returns:
BPM_SUCCESS upon succes, BPM_FAILURE upon failure.

Definition at line 271 of file intwf.c.

References bpm_error(), bpm_warning(), intwf_compat(), intwf_t::ns, and intwf_t::wf.

EXTERN int intwf_multiply ( intwf_t w1,
intwf_t w2 
)

Multiplies two waveforms of integers w1*w2 sample per sample. The result is stored in w1.

Parameters:
w1 A pointer to the first waveform of integers
w2 A pointer to the second waveform of integers
Returns:
BPM_SUCCESS upon succes, BPM_FAILURE upon failure.

Definition at line 291 of file intwf.c.

References bpm_error(), bpm_warning(), intwf_compat(), intwf_t::ns, and intwf_t::wf.

EXTERN int intwf_divide ( intwf_t w1,
intwf_t w2 
)

Divides two waveforms of integers w1/w2 sample per sample. The result is stored in w1. When w2[i] is 0, w1[i] will be set to 0. and a warning message is printed.

Parameters:
w1 A pointer to the first waveform of integers
w2 A pointer to the second waveform of integers
Returns:
BPM_SUCCESS upon succes, BPM_FAILURE upon failure.

Definition at line 313 of file intwf.c.

References bpm_error(), bpm_warning(), intwf_compat(), intwf_t::ns, and intwf_t::wf.

EXTERN int intwf_scale ( int  f,
intwf_t w 
)

Scales the waveform of integers w by factor f. The result is stored in w.

Parameters:
f The scalefactor
w A pointer to the waveform of integers
Returns:
BPM_SUCCESS upon succes, BPM_FAILURE upon failure.

Definition at line 343 of file intwf.c.

References bpm_error(), intwf_t::ns, and intwf_t::wf.

EXTERN int intwf_bias ( int  c,
intwf_t w 
)

Biases the waveform of integers w by a constant c. The result is stored in w.

Parameters:
c The constant bias.
w A pointer to the waveform of integers
Returns:
BPM_SUCCESS upon succes, BPM_FAILURE upon failure.

Definition at line 360 of file intwf.c.

References bpm_error(), intwf_t::ns, and intwf_t::wf.

EXTERN int intwf_add_cwtone ( intwf_t w,
double  amp,
double  phase,
double  freq,
double  phasenoise 
)

Adds a cosine-like CW tone to the entire waveform. The sampling time is taken on the array index, so t=(double)i/w->fs.

Parameters:
w A pointer to the waveform structure
amp Amplitude of the CW tone
phase Phase of the CW tone
freq Frequency of the CW tone
phasenoise Sigma of the gaussian phasenoise
Returns:
BPM_SUCCESS upon succes, BPM_FAILURE upon failure.

Definition at line 377 of file intwf.c.

References bpm_error(), dround(), intwf_t::fs, nr_rangauss(), intwf_t::ns, and intwf_t::wf.

EXTERN int intwf_add_dcywave ( intwf_t w,
double  amp,
double  phase,
double  freq,
double  ttrig,
double  tdcy,
double  phasenoise 
)

Adds a decaying wave pulse to the waveform. The sampling time is taken on the array index, so t=(double)i/w->fs. The added signal is of the form :

\[ amp e^{- ( t - ttrig ) / tdcy } cos( 2 \pi freq ( t- ttrig ) + phase ) \]

If desired, phasenoise is added to the phase of the waveform.

Parameters:
w A pointer to the waveform structure
amp Amplitude of the CW tone
phase Phase of the CW tone
freq Frequency of the CW tone
ttrig Trigger time of the pulse
tdcy Decay time of the pulse
phasenoise Sigma of the gaussian phasenoise
Returns:
BPM_SUCCESS upon succes, BPM_FAILURE upon failure.

Definition at line 397 of file intwf.c.

References bpm_error(), dround(), intwf_t::fs, nr_rangauss(), intwf_t::ns, and intwf_t::wf.

EXTERN int intwf_add_ampnoise ( intwf_t w,
double  sigma 
)

Adds gaussian amplitude noise to the waveform.

Parameters:
w A pointer to the waveform structure
sigma The gaussian sigma of the amplitude noise
Returns:
BPM_SUCCESS upon succes, BPM_FAILURE upon failure.

Definition at line 423 of file intwf.c.

References bpm_error(), dround(), nr_rangauss(), intwf_t::ns, and intwf_t::wf.

Referenced by digitise().

EXTERN int intwf_basic_stats ( intwf_t w,
int  s0,
int  s1,
wfstat_t stats 
)

Retrieves some basic statistics about the waveform of integers in w, only considers samples between s0 and s1.

Parameters:
w A pointer to the waveform structure
s0 First sample to consider
s1 Last sample to consider
stats A filled wfstat_t structure is returned.
Returns:
BPM_SUCCESS upon succes, BPM_FAILURE upon failure.

Definition at line 443 of file intwf.c.

References bpm_error(), doublewf_basic_stats(), doublewf_cast_new(), and doublewf_delete().

EXTERN int intwf_derive ( intwf_t w  ) 

Produce the derivative waveform for w : dw/dt.

Parameters:
w A pointer to the waveform structure.
Returns:
BPM_SUCCESS upon succes, BPM_FAILURE upon failure

Definition at line 469 of file intwf.c.

References bpm_error(), dround(), intwf_t::fs, intwf_t::ns, and intwf_t::wf.

EXTERN int intwf_integrate ( intwf_t w  ) 

Produce the integrated waveform for w : ^t w(s)ds.

Parameters:
w A pointer to the waveform structure.
Returns:
BPM_SUCCESS upon succes, BPM_FAILURE upon failure

Definition at line 494 of file intwf.c.

References bpm_error(), dround(), intwf_t::fs, intwf_t::ns, and intwf_t::wf.

EXTERN void intwf_print ( FILE *  of,
intwf_t w 
)

Print the waveform to the filepointer

Parameters:
of A filepointer, use stdout for the terminal
w A pointer to the waveform
Returns:
void

Definition at line 525 of file intwf.c.

References bpm_error(), intwf_t::fs, intwf_t::ns, and intwf_t::wf.

EXTERN int intwf_getvalue ( intwf_t w,
double  t,
unsigned int  mode 
)

Return the value for the waveform at sample time t, according to the interpolation mode.

Parameters:
w A pointer to the waveform structure
t A time at which to sample the waveform
mode Interpolation mode
Returns:
the value of the waveform at time t

Definition at line 544 of file intwf.c.

References bpm_error(), doublewf_cast_new(), doublewf_delete(), doublewf_getvalue(), and dround().

EXTERN int intwf_resample ( intwf_t w2,
double  fs,
intwf_t w1,
unsigned int  mode 
)

Resamples the waveform w1 into w2 with new fs sampling frequency This routine recalculates the correct number of samples required. However the user needs to make sure that there are enough samples in w2 available as this is not checked. The w2->ns value will be overwritten with the correct amount. The routine checkes whether the maximum allowed number of samples is not exceeded to avoid memory problems.

Parameters:
w A pointer to the waveform structure
t A time at which to sample the waveform
mode Interpolation mode
Returns:
the value of the waveform at time t

Definition at line 571 of file intwf.c.

References bpm_error(), doublewf_cast_new(), doublewf_delete(), doublewf_getvalue(), dround(), intwf_t::fs, MAX_ALLOWED_NS, intwf_t::ns, and intwf_t::wf.

EXTERN complexwf_t* complexwf ( int  ns,
double  fs 
)

Allocates memory for a new waveform of complex numbers

Parameters:
ns The number of samples in the waveform
fs The sampling frequency of the waveform
Returns:
A pointer to the allocated waveform structure

Definition at line 9 of file complexwf.c.

References bpm_error(), complexwf_t::fs, MAX_ALLOWED_NS, complexwf_t::ns, and complexwf_t::wf.

Referenced by complexwf_copy_new().

EXTERN complexwf_t* complexwf_copy_new ( complexwf_t w  ) 

Allocates memory and produces a copy of the complex waveform w;

Parameters:
w A pointer to the original waveform
Returns:
A pointer to the copy of w

Definition at line 51 of file complexwf.c.

References bpm_error(), complexwf(), complexwf_t::fs, complexwf_t::ns, and complexwf_t::wf.

EXTERN int complexwf_copy ( complexwf_t copy,
complexwf_t src 
)

Copies the values from existing complex waveform src into copy checks first whether the waveforms are compatible... This routine doesn't allocate memory internally and the waveforms should already have been created by the user...

Parameters:
copy A pointer to the copy waveform
src A pointer to the original waveform
Returns:
BPM_SUCCESS upon succes, BPM_FAILURE upon failure.

Definition at line 68 of file complexwf.c.

References bpm_error(), complexwf_compat(), complexwf_t::ns, and complexwf_t::wf.

EXTERN int complexwf_subset ( complexwf_t sub,
complexwf_t w,
int  i1,
int  i2 
)

Copies a subset from sample i1 to sample i2 ( inclusive ) to the sub waveform from complex waveform w. The routine expects the sub waveform to already exist with enough samples. ( this is not checked ! ) The sub->fs and sub->ns will be overwritten.

Parameters:
sub Pointer to the waveform which will hold the subset
w Pointer to the original waveform
i1 First sample of w to copy
i2 Last sample of w to copy
Returns:
BPM_SUCCESS upon succes, BPM_FAILURE upon failure.

Definition at line 89 of file complexwf.c.

References bpm_error(), complexwf_t::fs, complexwf_t::ns, and complexwf_t::wf.

EXTERN int complexwf_setvalues ( complexwf_t w,
complex_t x 
)

Fills the complex waveform with the values from the array x. No check is performed whether x contains enough samples, the user needs to be sure this is the case !

Parameters:
w A pointer to the waveform of complex numbers
x A pointer to the complex x values
Returns:
BPM_SUCCESS upon succes, BPM_FAILURE upon failure.

Definition at line 113 of file complexwf.c.

References bpm_error(), complexwf_t::ns, and complexwf_t::wf.

EXTERN int complexwf_setfunction ( complexwf_t w,
complex_t(*)(double, int, double *)  wffun,
int  npars,
double *  par 
)

Fills the waveform with values from the function wffun(), this function has to return a complex_t from argument t ( time ) and has npars parameters given by the array *par. The function will be evaluated at the time t of each sample...

Parameters:
w A pointer to the waveform of complex numbers
wffun A pointer to the function to fill the waveform with
t The time parameter in the function
npars Number of parameters for the function
par Array of parameters for the function
Returns:
BPM_SUCCESS upon succes, BPM_FAILURE upon failure.

Definition at line 128 of file complexwf.c.

References bpm_error(), complexwf_t::fs, complexwf_t::ns, and complexwf_t::wf.

EXTERN int complexwf_reset ( complexwf_t w  ) 

Resets the waveform of complex numbers to 0+0i

Parameters:
w A pointer to the complex waveform
Returns:
BPM_SUCCESS upon succes, BPM_FAILURE upon failure.

Definition at line 146 of file complexwf.c.

References bpm_error(), complexwf_t::ns, and complexwf_t::wf.

Referenced by get_mode_response().

EXTERN void complexwf_delete ( complexwf_t w  ) 

Frees up the memory used by the waveform

Parameters:
w A pointer to the waveform of complex numbers
Returns:
void

Definition at line 163 of file complexwf.c.

References bpm_warning(), and complexwf_t::wf.

EXTERN int complexwf_compat ( complexwf_t w1,
complexwf_t w2 
)

Checks compatiblity of the two waveforms, returns true if the number of samples and the sampling frequencies match. For the sampling frequency, it is simply checked whether they match to WF_EPS.

Parameters:
w1 A pointer to the first waveform of complex numbers
w2 A pointer to the second waveform of complex numbers
Returns:
1 if the waveforms match, 0 if not.

Definition at line 180 of file complexwf.c.

References bpm_error(), complexwf_t::fs, complexwf_t::ns, and WF_EPS.

Referenced by complexwf_add(), complexwf_copy(), complexwf_divide(), complexwf_multiply(), and complexwf_subtract().

EXTERN int complexwf_add ( complexwf_t w1,
complexwf_t w2 
)

Adds two waveforms of complex numbers w1+w2 sample per sample. The result is stored in w1.

Parameters:
w1 A pointer to the first waveform of complex numbers
w2 A pointer to the second waveform of comlex numbers
Returns:
BPM_SUCCESS upon succes, BPM_FAILURE upon failure.

Definition at line 193 of file complexwf.c.

References bpm_error(), bpm_warning(), complexwf_compat(), complexwf_t::ns, and complexwf_t::wf.

EXTERN int complexwf_subtract ( complexwf_t w1,
complexwf_t w2 
)

Subtracts two waveforms of complex numbers w1-w2 sample per sample. The result is stored in w1.

Parameters:
w1 A pointer to the first waveform of complex numbers
w2 A pointer to the second waveform of comlex numbers
Returns:
BPM_SUCCESS upon succes, BPM_FAILURE upon failure.

Definition at line 213 of file complexwf.c.

References bpm_error(), bpm_warning(), complexwf_compat(), complexwf_t::ns, and complexwf_t::wf.

EXTERN int complexwf_multiply ( complexwf_t w1,
complexwf_t w2 
)

Multiplies two waveforms of complex numbers w1*w2 sample per sample. The result is stored in w1.

Parameters:
w1 A pointer to the first waveform of complex numbers
w2 A pointer to the second waveform of comlex numbers
Returns:
BPM_SUCCESS upon succes, BPM_FAILURE upon failure.

Definition at line 234 of file complexwf.c.

References bpm_error(), bpm_warning(), complexwf_compat(), complexwf_t::ns, and complexwf_t::wf.

EXTERN int complexwf_divide ( complexwf_t w1,
complexwf_t w2 
)

Divides two waveforms of complex numbers w1/w2 sample per sample. The result is stored in w1.

Parameters:
w1 A pointer to the first waveform of complex numbers
w2 A pointer to the second waveform of comlex numbers
Returns:
BPM_SUCCESS upon succes, BPM_FAILURE upon failure.

Definition at line 256 of file complexwf.c.

References bpm_error(), bpm_warning(), complexwf_compat(), complexwf_t::ns, and complexwf_t::wf.

EXTERN int complexwf_scale ( complex_t  f,
complexwf_t w 
)

Scales the waveform of complex numbers w with complex factor f The result is stored in w.

Parameters:
f The complex scaling factor
w A pointer to the waveform of comlex numbers
Returns:
BPM_SUCCESS upon succes, BPM_FAILURE upon failure.

Definition at line 288 of file complexwf.c.

References bpm_error(), complexwf_t::ns, and complexwf_t::wf.

Referenced by rf_amplify_complex(), and rf_phase_shifter().

EXTERN int complexwf_bias ( complex_t  c,
complexwf_t w 
)

Biases the waveform of complex numbers w with complex constant c The result is stored in w.

Parameters:
c The complex constant
w A pointer to the waveform of comlex numbers
Returns:
BPM_SUCCESS upon succes, BPM_FAILURE upon failure.

Definition at line 305 of file complexwf.c.

References bpm_error(), complexwf_t::ns, and complexwf_t::wf.

EXTERN int complexwf_add_cwtone ( complexwf_t w,
double  amp,
double  phase,
double  freq,
double  phasenoise 
)

Adds a CW tone to the entire waveform. The sampling time is taken on the array index, so t=(double)i/w->fs. The real part will have the cos-like waveform, the imaginary part the sin-like waveform.

Parameters:
w A pointer to the complex waveform structure
amp Amplitude of the CW tone
phase Phase of the CW tone
freq Frequency of the CW tone
phasenoise Sigma of the gaussian phasenoise
Returns:
BPM_SUCCESS upon succes, BPM_FAILURE upon failure.

Definition at line 322 of file complexwf.c.

References bpm_error(), complexwf_t::fs, complex_t::im, nr_rangauss(), complexwf_t::ns, complex_t::re, and complexwf_t::wf.

EXTERN int complexwf_add_dcywave ( complexwf_t w,
double  amp,
double  phase,
double  freq,
double  ttrig,
double  tdcy,
double  phasenoise 
)

Adds a decaying wave pulse to the waveform. The sampling time is taken on the array index, so t=(double)i/w->fs. The added signal is of the form :

\[ amp e^{- ( t - ttrig ) / tdcy } sin( 2 \pi freq ( t- ttrig ) + phase ) \]

The real part will have the cos-like component, the imaginary part the sin-like component. If desired, phasenoise is added to the phase of the waveform.

Parameters:
w A pointer to the waveform structure
amp Amplitude of the CW tone
phase Phase of the CW tone
freq Frequency of the CW tone
ttrig Trigger time of the pulse
tdcy Decay time of the pulse
phasenoise Sigma of the gaussian phasenoise
Returns:
BPM_SUCCESS upon succes, BPM_FAILURE upon failure.

Definition at line 346 of file complexwf.c.

References bpm_error(), complexwf_t::fs, complex_t::im, nr_rangauss(), complexwf_t::ns, complex_t::re, and complexwf_t::wf.

EXTERN int complexwf_add_noise ( complexwf_t w,
double  sigma 
)

Adds uncorrelated gaussian amplitude noise with uniformly distributed random phase to the complex the waveform.

Parameters:
w A pointer to the complex waveform structure
sigma The gaussian sigma of the amplitude noise, phase is uniform over 2pi
Returns:
BPM_SUCCESS upon succes, BPM_FAILURE upon failure.

Definition at line 373 of file complexwf.c.

References bpm_error(), nr_rangauss(), nr_ranuniform(), complexwf_t::ns, and complexwf_t::wf.

EXTERN int complexwf_add_ampnoise ( complexwf_t w,
double  sigma 
)

Adds pure gaussian amplitude noise to the complex waveform and leaves the phase untouched

Parameters:
w A pointer to the complex waveform structure
sigma The gaussian sigma of the amplitude noise
Returns:
BPM_SUCCESS upon succes, BPM_FAILURE upon failure.

Definition at line 397 of file complexwf.c.

References bpm_error(), nr_rangauss(), complexwf_t::ns, and complexwf_t::wf.

EXTERN int complexwf_add_phasenoise ( complexwf_t w,
double  sigma 
)

Adds pure gaussian phase noise to the complex waveform and leaves the amplitude untouched

Parameters:
w A pointer to the complex waveform structure
sigma The gaussian sigma of the phase noise
Returns:
BPM_SUCCESS upon succes, BPM_FAILURE upon failure.

Definition at line 421 of file complexwf.c.

References bpm_error(), nr_rangauss(), complexwf_t::ns, and complexwf_t::wf.

EXTERN void complexwf_print ( FILE *  of,
complexwf_t w 
)

Print the waveform to the filepointer

Parameters:
of A filepointer, use stdout for the terminal
w A pointer to the waveform
Returns:
void

Definition at line 446 of file complexwf.c.

References bpm_error(), complexwf_t::fs, complex_t::im, complexwf_t::ns, complex_t::re, and complexwf_t::wf.

EXTERN int complexwf_getreal ( doublewf_t re,
complexwf_t z 
)

Gets the real part of the comlex waveform into the waveform of doubles. The doublewf needs to be allocated by the user beforehand and have the same number of samples as the complex waveform.

Parameters:
re A pointer to the waveform of doubles which will store the real part
z A pointer to the complex waveform
Returns:
BPM_SUCCESS upon success, BPM_FAILURE upon failure

Definition at line 466 of file complexwf.c.

References bpm_error(), bpm_warning(), complexwf_t::ns, doublewf_t::ns, complex_t::re, complexwf_t::wf, and doublewf_t::wf.

Referenced by rf_rectify().

EXTERN int complexwf_getimag ( doublewf_t im,
complexwf_t z 
)

Gets the imaginary part of the comlex waveform into the waveform of doubles. The doublewf needs to be allocated by the user beforehand and have the same number of samples as the complex waveform.

Parameters:
im A pointer to the waveform of doubles which will store the imaginary part
z A pointer to the complex waveform
Returns:
BPM_SUCCESS upon success, BPM_FAILURE upon failure

Definition at line 488 of file complexwf.c.

References bpm_error(), bpm_warning(), complex_t::im, complexwf_t::ns, doublewf_t::ns, complexwf_t::wf, and doublewf_t::wf.

EXTERN int complexwf_getamp ( doublewf_t r,
complexwf_t z 
)

Gets the amplitude of the comlex waveform into the waveform of doubles. The doublewf needs to be allocated by the user beforehand and have the same number of samples as the complex waveform.

Parameters:
im A pointer to the waveform of doubles which will store the amplitude
z A pointer to the complex waveform
Returns:
BPM_SUCCESS upon success, BPM_FAILURE upon failure

Definition at line 510 of file complexwf.c.

References bpm_error(), bpm_warning(), complexwf_t::ns, doublewf_t::ns, complexwf_t::wf, and doublewf_t::wf.

EXTERN int complexwf_getphase ( doublewf_t theta,
complexwf_t z 
)

Gets the phase of the comlex waveform into the waveform of doubles. The doublewf needs to be allocated by the user beforehand and have the same number of samples as the complex waveform. The phase is normalised between [0,2pi[.

Parameters:
im A pointer to the waveform of doubles which will store the phase
z A pointer to the complex waveform
Returns:
BPM_SUCCESS upon success, BPM_FAILURE upon failure

Definition at line 532 of file complexwf.c.

References bpm_error(), bpm_warning(), norm_phase(), complexwf_t::ns, doublewf_t::ns, complexwf_t::wf, and doublewf_t::wf.

EXTERN doublewf_t* complexwf_getreal_new ( complexwf_t z  ) 

Retrieves the real part of the complex waveform in a newly allocated waveform of doubles. Memory on the heap is allocated inside this routine, the user has to deal with deal with freeing it him/her self.

Parameters:
z A pointer to the complex waveform
Returns:
A pointer to the allocated waveform of doubles containing the real part of z.

Definition at line 601 of file complexwf.c.

References bpm_error(), doublewf(), complexwf_t::fs, complexwf_t::ns, complex_t::re, complexwf_t::wf, and doublewf_t::wf.

EXTERN doublewf_t* complexwf_getimag_new ( complexwf_t z  ) 

Retrieves the imaginary part of the complex waveform in a newly allocated waveform of doubles. Memory on the heap is allocated inside this routine, the user has to deal with deal with freeing it him/her self.

Parameters:
z A pointer to the complex waveform
Returns:
A pointer to the allocated waveform of doubles containing the imaginary part of z.

Definition at line 626 of file complexwf.c.

References bpm_error(), doublewf(), complexwf_t::fs, complex_t::im, complexwf_t::ns, complexwf_t::wf, and doublewf_t::wf.

EXTERN doublewf_t* complexwf_getamp_new ( complexwf_t z  ) 

Retrieves the amplitude of the complex waveform in a newly allocated waveform of doubles. Memory on the heap is allocated inside this routine, the user has to deal with deal with freeing it him/her self.

Parameters:
z A pointer to the complex waveform
Returns:
A pointer to the allocated waveform of doubles containing the amplitude of z.

Definition at line 651 of file complexwf.c.

References bpm_error(), doublewf(), complexwf_t::fs, complexwf_t::ns, complexwf_t::wf, and doublewf_t::wf.

EXTERN doublewf_t* complexwf_getphase_new ( complexwf_t z  ) 

Retrieves the phase of the complex waveform in a newly allocated waveform of doubles. Memory on the heap is allocated inside this routine, the user has to deal with deal with freeing it him/her self. The phase is normalised between [0,2pi[.

Parameters:
z A pointer to the complex waveform
Returns:
A pointer to the allocated waveform of doubles containing the phase of z.

Definition at line 676 of file complexwf.c.

References bpm_error(), doublewf(), complexwf_t::fs, norm_phase(), complexwf_t::ns, complexwf_t::wf, and doublewf_t::wf.

EXTERN int complexwf_setreal ( complexwf_t z,
doublewf_t re 
)

Set the real part of the complex waveform z to re. The complexwf needs to be allocated by the user beforehand and have the same number of samples as the double waveform.

Parameters:
z A pointer to the complex waveform
re A pointer to a waveform of double containing the real part
Returns:
BPM_SUCCESS upon success, BPM_FAILURE upon failure

Definition at line 557 of file complexwf.c.

References bpm_error(), bpm_warning(), complexwf_t::ns, doublewf_t::ns, complex_t::re, doublewf_t::wf, and complexwf_t::wf.

Referenced by ddc(), and get_mode_response().

EXTERN int complexwf_setimag ( complexwf_t z,
doublewf_t im 
)

Set the imaginary part of the complex waveform z to im. The complexwf needs to be allocated by the user beforehand and have the same number of samples as the double waveform.

Parameters:
z A pointer to the complex waveform
re A pointer to a waveform of double containing the imaginary part
Returns:
BPM_SUCCESS upon success, BPM_FAILURE upon failure

Definition at line 579 of file complexwf.c.

References bpm_error(), bpm_warning(), complex_t::im, complexwf_t::ns, doublewf_t::ns, doublewf_t::wf, and complexwf_t::wf.

Referenced by ddc(), and get_mode_response().


Generated on Wed Jun 25 17:32:50 2008 for libbpm by  doxygen 1.5.6