Loading [MathJax]/extensions/TeX/AMSsymbols.js
LALPulsar 7.1.1.1-ea7c608
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
ppe_init.c File Reference

Prototypes

static void strtoupper (CHAR *s)
 Convert string to uppercase. More...
 
void nested_sampling_algorithm_wrapper (LALInferenceRunState *runState)
 A wrapper around LALInferenceNestedSamplingAlgorithm. More...
 
void setup_live_points_array_wrapper (LALInferenceRunState *runState)
 A wrapper around LALInferenceSetupLivePointsArray. More...
 
void initialise_algorithm (LALInferenceRunState *runState)
 Initialises the nested sampling algorithm control. More...
 
void setup_lookup_tables (LALInferenceRunState *runState, LALSource *source)
 Sets the time angle antenna response lookup table. More...
 
void add_initial_variables (LALInferenceVariables *ini, PulsarParameters *pars)
 Set up all the allowed variables for a known pulsar search This functions sets up all possible variables that are possible in a known pulsar search. More...
 
void initialise_prior (LALInferenceRunState *runState)
 Sets up the parameters to be searched over and their prior ranges. More...
 
void initialise_proposal (LALInferenceRunState *runState)
 Initialise the MCMC proposal distribution for sampling new points. More...
 
void add_correlation_matrix (LALInferenceVariables *ini, LALInferenceVariables *priors, REAL8Array *corMat, LALStringVector *parMat)
 Adds a correlation matrix for a multi-variate Gaussian prior. More...
 
void sum_data (LALInferenceRunState *runState)
 Calculates the sum of the square of the data and model terms. More...
 
REAL8Vector ** parse_gmm_means (CHAR *meanstr, UINT4 npars, UINT4 nmodes)
 Parse data from a prior file containing Gaussian Mixture Model mean values. More...
 
gsl_matrix ** parse_gmm_covs (CHAR *covstr, UINT4 npars, UINT4 nmodes)
 Parse data from a prior file containing Gaussian Mixture Model covariance matrix values. More...
 
CHARget_bracketed_string (CHAR *dest, const CHAR *bstr, int openbracket, int closebracket)
 
void initialise_threads (LALInferenceRunState *state, INT4 nthreads)
 

Go to the source code of this file.

Variables

static const CHAR a2A [256]
 Array for conversion from lowercase to uppercase. More...
 

Function Documentation

◆ strtoupper()

static void strtoupper ( CHAR s)
static

Convert string to uppercase.

Definition at line 37 of file ppe_init.c.

◆ nested_sampling_algorithm_wrapper()

void nested_sampling_algorithm_wrapper ( LALInferenceRunState runState)

A wrapper around LALInferenceNestedSamplingAlgorithm.

This function just calls LALInferenceNestedSamplingAlgorithm, but will time the algorithm if required.

Parameters
runState[] A pointer to the LALInferenceRunState

Definition at line 57 of file ppe_init.c.

◆ setup_live_points_array_wrapper()

void setup_live_points_array_wrapper ( LALInferenceRunState runState)

A wrapper around LALInferenceSetupLivePointsArray.

This function just calls LALInferenceSetupLivePointsArray, but will time the algorithm if required.

Parameters
runState[] A pointer to the LALInferenceRunState

Definition at line 100 of file ppe_init.c.

◆ initialise_algorithm()

void initialise_algorithm ( LALInferenceRunState runState)

Initialises the nested sampling algorithm control.

Memory is allocated for the parameters, priors and proposals. The nested sampling control parameters are set: the number of live points Nlive, the number of points for each MCMC Nmcmc, the number of independent runs within the algorithm Nruns, and the stopping criterion tolerance.

The random number generator is initialise (the GSL Mersenne Twister algorithm gsl_rng_mt19937) using either a user defined seed randomseed, the system defined /dev/urandom file, or the system clock time.

Parameters
runState[in] A pointer to the LALInferenceRunState

Definition at line 138 of file ppe_init.c.

◆ setup_lookup_tables()

void setup_lookup_tables ( LALInferenceRunState runState,
LALSource source 
)

Sets the time angle antenna response lookup table.

This function sets up an antenna response lookup table in time for each detector from which data exists (either real or fake). The time ranges over one sidereal day. The number of bins for the grid over time can be specified on the command line via time-bins, but if this are not given then default values are used. The data times as a fraction of a sidereal day from the start time will also be calculated.

Parameters
runState[in] A pointer to the LALInferenceRunState
source[in] A pointer to a LALSource variable containing the source location

Definition at line 296 of file ppe_init.c.

◆ add_initial_variables()

void add_initial_variables ( LALInferenceVariables ini,
PulsarParameters pars 
)

Set up all the allowed variables for a known pulsar search This functions sets up all possible variables that are possible in a known pulsar search.

Parameter values read in from a .par file and passed in via the pars variable will be set.

Parameters
ini[in] A pointer to a LALInferenceVariables type that will be filled in with pulsar parameters
pars[in] A PulsarParameters type containing pulsar parameters read in from a TEMPO-style .par file

Definition at line 386 of file ppe_init.c.

◆ initialise_prior()

void initialise_prior ( LALInferenceRunState runState)

Sets up the parameters to be searched over and their prior ranges.

This function sets up any parameters that you require the code to search over and specifies the prior range and type for each. This information is contained in a prior file specified by the command line argument prior-file. There are currently five different allowed prior distributions:

  • "uniform": A flat distribution between a minimum and maximum range (with zero probabiility outside that range);
  • "gaussian": A Gaussian/Normal distribution defined by a mean and standard devaition;
  • "fermidirac": A Fermi-Dirac-like distribution defined by a knee and attenuation width;
  • "gmm": A one- or more-dimensional Gaussian Mixture model defined by the means, standard deviations and weights of each mode.
  • "loguniform": A flat distribution in log-space (proportional to the inverse of the value in non-log-space) For all priors the first two columns of the prior definition should be:
  1. the name of a parameter to be searched over, and
  2. the prior type (e.g. "uniform", "gaussian", "fermidirac", "gmm" or "loguniform". For the "uniform, "loguniform", "gaussian", "fermidirac" priors the prior file should contain the a further two columns containing: -# the lower limit ("uniform" and "loguniform"), mean ("gaussian"), or sigma ("fermidirac") of the distribution; -# the upper limit ("uniform" and "loguniform"), standard deviation ("gaussian"), or r ("fermidirac") of the distribution. For the "gmm" prior the file should contain at least a further four columns. The third column gives the number of modes for the mixture. The fourth columns is a list of means for each mode (with sub-lists of means for each parameter). The fifth column is a list of covariance matrices for each mode. The sixth column is a list of weights for each mode (weights can be relative weights as they will be normalised when parsed by the code). Finally, there can be additional lists containing pairs of values for each parameter giving lower and upper limits of the distribution (note that the weights given are weights assuming that there are no bounds on the distributions).

Some examples of files are:

H0 uniform 0 1e-21
PHI0 uniform 0 3.14159265359
COSIOTA uniform -1 1
PSI uniform -0.785398163397448 0.785398163397448
#define H0
#define PHI0
#define COSIOTA
#define PSI
double e

or

H0 fermidirac 3.3e-26 9.16
PHI0 uniform 0 3.14159265359
IOTA uniform 0 3.14159265359
PSI uniform -0.785398163397448 0.785398163397448

or

H0 gmm 3 [[1e-25],[2e-25],[1e-26]] [[[2e-24]],[[3e-24]],[[1e-25]]] [1.5,2.5,0.2] [0.0,1e-20]
PHI0 uniform 0 3.14159265359
COSIOTA uniform -1 1
PSI uniform -0.785398163397448 0.785398163397448

Any parameter specified in the file will have its vary type set to LALINFERENCE_PARAM_LINEAR.

If a parameter correlation matrix is given by the cor-file command then this is used to construct a multi-variate Gaussian prior for the given parameters (it is assumed that this file is created using TEMPO and the parameters it contains are the same as those for which a standard deviation is defined in the par file). This overrules the Gaussian priors that will have been set for these parameters.

Parameters
runState[in] A pointer to the LALInferenceRunState

Definition at line 620 of file ppe_init.c.

◆ initialise_proposal()

void initialise_proposal ( LALInferenceRunState runState)

Initialise the MCMC proposal distribution for sampling new points.

There are various proposal distributions that can be used to sample new live points via an MCMC. A combination of different ones can be used to help efficiency for awkward posterior distributions. Here the proposals that can be used are: diffev Drawing a new point by differential evolution of two randomly chosen live points. All parameters are evolved during a single draw. freqBinJump Jumps that are the size of the Fourier frequency bins (can be used if searching over frequency). ensembleStretch Ensemble stretch moves (WARNING: These can lead to long autocorrelation lengths). ensembleWalk Ensemble walk moves. These are used as the default proposal. uniformprop Points for any parameters with uniform priors are drawn from those priors

This function sets up the relative weights with which each of above distributions is used.

Parameters
runState[in] A pointer to the run state

Definition at line 918 of file ppe_init.c.

◆ add_correlation_matrix()

void add_correlation_matrix ( LALInferenceVariables ini,
LALInferenceVariables priors,
REAL8Array corMat,
LALStringVector parMat 
)

Adds a correlation matrix for a multi-variate Gaussian prior.

If a TEMPO-style parameter correlation coefficient file has been given, then this function will use it to set the prior distribution for the given parameters. It is assumed that the equivalent par file contained standard deviations for all parameters given in the correlation matrix file, but if the correlation matrix contains more parameters they will be ignored.

Definition at line 1012 of file ppe_init.c.

◆ sum_data()

void sum_data ( LALInferenceRunState runState)

Calculates the sum of the square of the data and model terms.

This function calculates the sum of the square of the data and model terms:

\[ \sum_i^N \Re{d_i}^2 + \Im{d_i}^2, \sum_i^N \Re{h_i}^2, \sum_i^N \Im{h_i}^2, \sum_i^N \Re{d_i}\Re{h_i}, \sum_i^N Im{d_i}\Im{h_i} \]

for each stationary segment given in the chunkLength vector. These value are used in the likelihood calculation in pulsar_log_likelihood and are precomputed here to speed that calculation up.

Parameters
runState[in] The analysis information structure

Definition at line 1110 of file ppe_init.c.

◆ parse_gmm_means()

REAL8Vector ** parse_gmm_means ( CHAR meanstr,
UINT4  npars,
UINT4  nmodes 
)

Parse data from a prior file containing Gaussian Mixture Model mean values.

If a Gaussian Mixture Model prior has been specified then this function will parse the means for each parameter for each mode given. E.g. if the GMM provides multivariate Gaussian modes for two parameters, x and y, then the means would be specified in a string of the form "[[mux1,muy1],[mux2,muy2],....]". The string should have no whitespace between values, and mean values for a given mode must be separated by a comma.

These values are returned in an vector of REAL8Vectors. If an error occurred then NULL will be returned.

Parameters
meanstr[in] A string containing the mean values
npars[in] The number of parameters
nmodes[in] The number of modes

Definition at line 1537 of file ppe_init.c.

◆ parse_gmm_covs()

gsl_matrix ** parse_gmm_covs ( CHAR covstr,
UINT4  npars,
UINT4  nmodes 
)

Parse data from a prior file containing Gaussian Mixture Model covariance matrix values.

If a Gaussian Mixture Model prior has been specified then this function will parse the covariance matrices for each mode given. E.g. if the GMM provides multivariate Gaussian modes for two parameters, x and y, then the covariances for each mode would be specified in a string of the form "[[[covxx1,covxy1][covyx1,covyy1]],[[covxx2,covxy2][covyx2,covyy2]],...]". The string should have no whitespace between values, and covariance values for a given mode must be separated by a comma.

These values are returned in an array of GSL matrices. If an error occurred then NULL will be returned.

Parameters
covstr[in] A string containing the covariance matrix values
npars[in] The number of parameters
nmodes[in] The number of modes

Definition at line 1608 of file ppe_init.c.

◆ get_bracketed_string()

CHAR * get_bracketed_string ( CHAR dest,
const CHAR bstr,
int  openbracket,
int  closebracket 
)

Definition at line 1700 of file ppe_init.c.

◆ initialise_threads()

void initialise_threads ( LALInferenceRunState state,
INT4  nthreads 
)

Definition at line 1719 of file ppe_init.c.

Variable Documentation

◆ a2A

const CHAR a2A[256]
static
Initial value:
= {
['a'] = 'A', ['b'] = 'B', ['c'] = 'C', ['d'] = 'D', ['e'] = 'E', ['f'] = 'F', ['g'] = 'G', ['h'] = 'H',
['i'] = 'I', ['j'] = 'J', ['k'] = 'K', ['l'] = 'L', ['m'] = 'M', ['n'] = 'N', ['o'] = 'O', ['p'] = 'P',
['q'] = 'Q', ['r'] = 'R', ['s'] = 'S', ['t'] = 'T', ['u'] = 'U', ['v'] = 'V', ['w'] = 'W', ['x'] = 'X',
['y'] = 'Y', ['z'] = 'Z'
}

Array for conversion from lowercase to uppercase.

Definition at line 28 of file ppe_init.c.