28#ifndef _PULSAR_PARAMETER_ESTIMATION_NESTED_H
29#define _PULSAR_PARAMETER_ESTIMATION_NESTED_H
41#include <lal/LALStdlib.h>
42#include <lal/LALgetopt.h>
43#include <lal/LALAtomicDatatypes.h>
44#include <lal/LALDatatypes.h>
45#include <lal/AVFactories.h>
46#include <lal/SkyCoordinates.h>
47#include <lal/DetectorSite.h>
48#include <lal/DetResponse.h>
49#include <lal/BinaryPulsarTiming.h>
50#include <lal/Random.h>
51#include <lal/LALString.h>
52#include <lal/SFTfileIO.h>
53#include <lal/LALBarycenter.h>
54#include <lal/LALInitBarycenter.h>
55#include <lal/MatrixUtils.h>
56#include <lal/LALConstants.h>
57#include <lal/XLALError.h>
58#include <lal/ComputeFstat.h>
59#include <lal/TimeSeries.h>
60#include <lal/LALNoiseModels.h>
63#include <lal/StringVector.h>
64#include <lal/XLALGSL.h>
65#include <lal/FileIO.h>
66#include <lal/LALPulsarVCSInfo.h>
68#include <lal/LALInference.h>
69#include <lal/LALInferenceNestedSampler.h>
70#include <lal/LALInferencePrior.h>
71#include <lal/LALInferenceProposal.h>
72#include <lal/LALInferenceGenerateROQ.h>
74#include <lal/LALSimNoise.h>
76#include <gsl/gsl_sort_double.h>
77#include <gsl/gsl_statistics_double.h>
78#include <gsl/gsl_blas.h>
79#include <gsl/gsl_sf_gamma.h>
80#include <gsl/gsl_randist.h>
87#define UNUSED __attribute__ ((unused))
93#define ROUND(x) (floor(x+0.5))
96#define LOGPLUS(x,y) ( x>y ? x+log(1.+exp(y-x)) : y+log(1.+exp(x-y)) )
99#define FACTOR(x,y) ((INT4)floor(x/y))
102#define SQUARE(x) ( (x) * (x) )
108#define MAXLENGTH 1000000
113#define PPEN_MAXLINELENGTH 1024
154#define NUMGLITCHPARS 7
161"Usage: %s [options]\n\n"\
162" --help display this message\n"\
163" --verbose display all error messages\n"\
164" --detectors all IFOs with data to be analysed e.g. H1,H2\n\
165 (delimited by commas) (if generating fake data these\n\
166 should not be set)\n"\
167" --par-file pulsar parameter (.par) file (full path)\n"\
168" --cor-file pulsar TEMPO-fit parameter correlation matrix\n"\
169" --input-files full paths and file names for the data for each\n\
170 detector and model harmonic in the list (must be in the\n\
171 same order) delimited by commas. These files can be gzipped.\n\
172 If not set you can generate fake data (see --fake-data below)\n"\
173" --outfile name of output data file (a HDF5 formated file with the\n\
174 extension '.hdf' or '.h5' [required])\n"\
175" --output-chunks Output lists of stationary chunks into which the data has been split\n"\
176" --chunk-min (INT4) minimum stationary length of data to be used in\n\
177 the likelihood e.g. 5 mins\n"\
178" --chunk-max (INT4) maximum stationary length of data to be used in\n\
179 the likelihood e.g. 30 mins\n"\
180" --time-bins (INT4) no. of time bins in the time-psi lookup table\n"\
181" --prior-file file containing the parameters to search over and\n\
182 their upper and lower ranges\n"\
183" --ephem-earth Earth ephemeris file\n"\
184" --ephem-sun Sun ephemeris file\n"\
185" --ephem-timecorr Einstein delay time correction ephemeris file\n"\
186" --harmonics (CHAR) the signal model frequency harmonics that you want\n\
187 to use (delimited by commas). Currently this can be either\n\
188 the 'triaxial' model for which you use 2 (the default\n\
189 value) or 1,2 for a model with emission at both the rotation\n\
190 frequency and twice the rotation frequency.\n"\
191" --biaxial Set this if the waveform model parameters spcify a biaxial star\n"\
192" --gaussian-like Set this if a Gaussian likelihood is to be used. If the input\n\
193 file contains a column specifying the noise standard deviation of\n\
194 the data then that will be used in the Gaussian likelihood function,\n\
195 otherwise the noise variance will be calculated from the data.\n"\
196" --nonGR Set to allow non-GR polarisation modes and/or a variable\n\
197 speed of gravitational waves\n"\
198" --randomise Set this, with an INT seed, to randomise the data (through permutations\n\
199 of the time stamps) for use in Monte-Carlo studies. NOTE: this will not\n\
200 work if using the code to create injections\n"\
201" --start-time (REAL8) only use data after the given GPS start time\n"\
202" --end-time (REAL8) discard data after the given GPS end time\n"\
203" --truncate-time maximum GPS time to be analyzed (discards data with larger\n\
205" --truncate-samples maximum sample number to be analyzed (analyzes only first\n\
206 datapoints and discards rest)\n"\
207" --truncate-fraction fraction of data samples to be analyzed (0<f<=1)\n"\
208" --veto-threshold veto any data samples with an absolute value greater than the input\n\
209 threshold (defaults to 1e-18)\n"\
211" Nested sampling parameters:\n"\
212" --Nlive (INT4) no. of live points for nested sampling\n"\
213" --Nmcmc (INT4) no. of for MCMC used to find new live points\n\
214 (if not specified an adaptive number of points is used)\n"\
215" --Nmcmcinitial (INT4) no. of MCMC points to use in the initial resampling of\n\
216 the prior (default is to use MAXMCMC)\n"\
217" --tolerance (REAL8) tolerance of nested sampling integrator\n"\
218" --randomseed seed for random number generator\n"\
220" MCMC proposal parameters:\n"\
221" --diffev (UINT4) relative weight of using differential evolution\n\
222 of the live points as the proposal (DEFAULT = 0, e.g.\n\
224" --freqBinJump (UINT4) relative weight of using jumps to adjacent\n\
225 frequency bins as a proposal (DEFAULT = 0, e.g. this is\n\
226 not required unless searching over frequency)\n"\
227" --ensembleStretch (UINT4) relative weight of the ensemble stretch\n\
228 proposal (DEFAULT = 0, e.g. 0%%) [NOTE: this proposal\n\
229 greatly increases the autocorrelation lengths, so in\n\
230 general should be avoided]\n"\
231" --ensembleWalk (UINT4) relative weight of the ensemble walk\n\
232 proposal (DEFAULT = 3, e.g. 75%%)\n"\
233" --uniformprop (UINT4) relative weights of uniform proposal\n\
234 (DEFAULT = 1, e.g. 25%%)\n"\
236" Reduced order quadrature (ROQ) parameters:\n"\
237" --roq Set this to use reduced order quadrature to compute the\n\
239" --ntraining (UINT4) The number of training models used to generate an\n\
240 orthonormal basis of waveform models\n"\
241" --roq-tolerance (REAL8) The tolerance used during the basis generation\n\
242 (DEFAULT = 1e-11)\n"\
243" --enrich-max (UINT4) The number of times to try and \"enrich\" the\n\
244 basis set using new training data. The enrichment process\n\
245 stop before this value is reached if three consecutive\n\
246 enrichment steps produce no new bases (DEFAULT = 100)\n"\
247" --roq-uniform Set this flag to cause training model parameters for\n\
248 parameters with Gaussian prior distributions to be drawn\n\
249 from a uniform distribution spanning mu +/- 5 sigma.\n\
250 Otherwise, by default parameters are drawn from their given\n\
251 prior distributions\n"\
252" --output-weights (CHAR) If this is set then the weights will be output to\n\
253 the (binary) file that is named and the programme will\n\
254 exit. These could be read in later instead of being\n\
255 regenerated. This allows the ROQ to be generated on a\n\
256 machine with a large amount of RAM, whilst the full\n\
257 parameter estimation can run on a machine with less RAM.\n"\
258" --input-weights (CHAR) A binary file containing all the weights in a\n\
259 defined format. If this is present then the RQO will\n\
260 not be recalculated\n"\
262" Signal injection parameters:\n"\
263" --inject-file a pulsar parameter (par) file containing the parameters\n\
264 of a signal to be injected. If this is given a signal\n\
266" --inject-output a filename to which the injected signal will be\n\
267 output if specified\n"\
268" --inject-only do not perform nested sampling on a created injection\n\
269 provided that injection has been output (i.e. exit the code\n\
270 after creation of and writing out of the injection).\n"\
271" --inject-coarse create an injected signal as if it has only been \"coarse\n\
272 heterodyned\", i.e., the orbital modulation effects have not\n\
273 been removed from the signal. This will only work when using\n\
274 the code to just create and output an injection with the\n\
275 \"--inject-only\" flag set.\n"\
276" --fake-data a list of IFO's for which fake data will be generated\n\
277 e.g. H1,L1 (delimited by commas). Unless the --fake-psd\n\
278 flag is set the power spectral density for the data will\n\
279 be generated from the noise models in LALNoiseModels.\n\
280 For Advanced detectors (e.g Advanced LIGO) prefix the\n\
281 name with an A (e.g. AH1 for an Advanced LIGO detector\n\
282 at Hanford). The noise will be white across the data\n\
284" --fake-psd if you want to generate fake data with specific power\n\
285 spectral densities for each detector giving in\n\
286 --fake-data then they should be specified here delimited\n\
287 by commas (e.g. for --fake-data H1,L1 then you could use\n\
288 --fake-psd 1e-48,1.5e-48) where values are single-sided\n\
290" --fake-starts the start times (in GPS seconds) of the fake data for\n\
291 each detector separated by commas (e.g.\n\
292 910000000,910021000). If not specified these will all\n\
293 default to 900000000\n"\
294" --fake-lengths the length of each fake data set (in seconds) for each\n\
295 detector separated by commas. If not specified these\n\
296 will all default to 86400 (i.e. 1 day)\n"\
297" --fake-dt the data sample rate (in seconds) for the fake data for\n\
298 each detector. If not specified this will default to\n\
300" --scale-snr give a (multi-detector) SNR value to which you want to\n\
301 scale the injection. This is 1 by default\n"\
303" Flags for using a Nested sampling file as a prior (DO NOT USE!):\n"\
304" --sample-files a list of (comma separated) file containing the nested\n\
305 samples from a previous run of the code (these should\n\
306 contain samples in ascending likelihood order and be\n\
307 accompanied by a file containg a list of the parameter\n\
308 names for each column with the suffix _params.txt). If\n\
309 this is set this WILL be used as the only prior, but the\n\
310 prior ranges set in the --prior-file and --par-file are\n\
311 still needed (and should be consistent with the variable\n\
312 parameters in the nested sample file)\n"\
313" --sample-nlives a list (comma separated) of the number of live point\n\
314 that where used when creating each nested sample file.\n"\
315" --prior-cell The number of samples to use in a k-d tree cell for the\n\
316 prior (the default will be 8)\n"\
317" --Npost The (approximate) number of posterior samples to be\n\
318 generated from each nested sample file (default = 1000)\n"\
320" Legacy code flags:\n"\
321" --oldChunks Set if using fixed chunk sizes for dividing the data as\n\
322 in the old code, rather than the calculating chunks\n\
323 using the change point method\n"\
324" --source-model Set if using both 1 and 2 multiples of the frequency and\n\
325 requiring the use of the original source model parameters\n\
326 from Jones, MNRAS, 402 (2010)\n"\
329" --time-it Set if wanting to time the various parts of the code.\n\
330 A output file with the \"outfile\" filename appended with\n\
331 \"_timings\" will contain the timings\n"\
332" --sampleprior (UINT4) Set this to be a number of samples generated from\n\
333 the prior. The nested sampling will not be performed\n"\
341 "COSIOTA",
"C22",
"C21",
"PHI22",
"PHI21",
"HPLUS",
"HCROSS",
"HSCALARB",
342 "HSCALARL",
"HVECTORX",
"HVECTORY",
"PSIVECTOR",
"PHI0VECTOR",
"PSISCALAR",
343 "PHI0SCALAR",
"PSITENSOR",
"PHI0TENSOR",
"I21",
"I31",
"LAMBDA",
"COSTHETA",
344 "IOTA",
"THETA",
"Q22",
"DIST",
"H0_F"
352 "PMDEC",
"POSEPOCH",
"PX"
360 "EPS2",
"T0",
"TASC",
"A1",
"OM",
"PB_2",
"ECC_2",
"T0_2",
"A1_2",
"OM_2",
"PB_3",
"ECC_3",
361 "T0_3",
"A1_3",
"OM_3",
"XPBDOT",
"EPS1DOT",
"EPS2DOT",
"OMDOT",
"GAMMA",
"PBDOT",
362 "XDOT",
"EDOT",
"SINI",
"DR",
"DTHETA",
"A0",
"B0",
"MTOT",
"M2",
"FB"
#define NUMGLITCHPARS
The total number of glitch parameters that can define a signal.
#define NUMSKYPARS
The total number of sky position parameters that can define a signal e.g.
LALStringVector * corlist
static const CHAR binpars[NUMBINPARS][VARNAME_MAX]
A list of the binary system parameters.
#define NUMAMPPARS
The total number of 'amplitude' parameters that can define a signal e.g.
static const CHAR amppars[NUMAMPPARS][VARNAME_MAX]
A list of the amplitude parameters.
static const CHAR glitchpars[NUMGLITCHPARS][VARNAME_MAX]
A list of the glitch parameters.
#define NUMBINPARS
The total number of binary system parameters that can define a signal e.g.
static const CHAR skypars[NUMSKYPARS][VARNAME_MAX]
A list of the sky position parameters.