Loading [MathJax]/extensions/TeX/AMSsymbols.js
LALPulsar 7.1.1.1-b246709
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
ComputeFstatLatticeCount.c
Go to the documentation of this file.
1//
2// Copyright (C) 2007, 2008, 2016 Karl Wette
3//
4// This program is free software; you can redistribute it and/or modify
5// it under the terms of the GNU General Public License as published by
6// the Free Software Foundation; either version 2 of the License, or
7// (at your option) any later version.
8//
9// This program is distributed in the hope that it will be useful,
10// but WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12// GNU General Public License for more details.
13//
14// You should have received a copy of the GNU General Public License
15// along with with program; see the file COPYING. If not, write to the
16// Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
17// MA 02110-1301 USA
18//
19
20///
21/// \file
22/// \ingroup lalpulsar_bin_Fstatistic
23/// \author Karl Wette
24/// \brief Count number of templates in a given lattice tiling
25///
26
27#include "config.h"
28
29#include <stdlib.h>
30#include <stdio.h>
31
32#include <gsl/gsl_math.h>
33
34#include <lal/LALStdlib.h>
35#include <lal/LALString.h>
36#include <lal/XLALError.h>
37#include <lal/UserInput.h>
38#include <lal/LatticeTiling.h>
39#include <lal/DopplerFullScan.h>
40#include <lal/PtoleMetric.h>
41#include <lal/GSLHelpers.h>
42#include <lal/LALPulsarVCSInfo.h>
43
44typedef struct {
50 int metric;
52
54const UserChoices MetricTypeChoices = { { SPINDOWN, "spindown" }, { EYE, "eye" } };
55
56int main( int argc, char *argv[] )
57{
58
59 // Initialise user variables
61 .lattice = TILING_LATTICE_ANSTAR,
62 .metric = SPINDOWN,
63 };
64 UserVariables *const uvar = &uvar_struct;
65
66 // Register user variables
67 XLAL_CHECK_MAIN( XLALRegisterUvarMember( time_span, REAL8, 'T', REQUIRED, "Time-span of the data set (in seconds)" ) == XLAL_SUCCESS, XLAL_EFUNC );
68 XLAL_CHECK_MAIN( XLALRegisterUvarMember( square, REAL8Vector, 0, OPTIONAL, "Square parameter space: start,width,..." ) == XLAL_SUCCESS, XLAL_EFUNC );
69 XLAL_CHECK_MAIN( XLALRegisterUvarMember( age_braking, REAL8Vector, 0, OPTIONAL, "Age/braking index parameter space: alpha,delta,freq,freqband,age,minbrake,maxbrake" ) == XLAL_SUCCESS, XLAL_EFUNC );
70 XLAL_CHECK_MAIN( XLALRegisterUvarMember( max_mismatch, REAL8, 'X', REQUIRED, "Maximum allowed mismatch between the templates" ) == XLAL_SUCCESS, XLAL_EFUNC );
71 XLAL_CHECK_MAIN( XLALRegisterUvarAuxDataMember( lattice, UserEnum, &TilingLatticeChoices, 'L', REQUIRED, "Type of lattice to use" ) == XLAL_SUCCESS, XLAL_EFUNC );
72 XLAL_CHECK_MAIN( XLALRegisterUvarAuxDataMember( metric, UserEnum, &MetricTypeChoices, 'M', OPTIONAL, "Type of metric to use" ) == XLAL_SUCCESS, XLAL_EFUNC );
73
74 // Parse user input
75 BOOLEAN should_exit = 0;
77
78 // Check user input
79 XLALUserVarCheck( &should_exit, UVAR_SET2( square, age_braking ) == 1, "Exactly one of " UVAR_STR2AND( square, age_braking ) " must be specified" );
80
81 // Exit if required
82 if ( should_exit ) {
83 return EXIT_FAILURE;
84 }
85
86 LatticeTiling *tiling = NULL;
87 if ( UVAR_SET( square ) ) {
88
89 // Create square parameter space
90 XLAL_CHECK_MAIN( GSL_IS_EVEN( uvar->square->length ), XLAL_EINVAL, "'square' must have an even number of arguments" );
91 const size_t n = uvar->square->length / 2;
94 for ( size_t i = 0; i < n; ++i ) {
95 XLAL_CHECK_MAIN( XLALSetLatticeTilingConstantBound( tiling, i, uvar->square->data[2 * i], uvar->square->data[2 * i] + uvar->square->data[2 * i + 1] ) == XLAL_SUCCESS, XLAL_EFUNC );
96 }
97
98 } else {
99
100 // Create age--braking index parameter space
101 XLAL_CHECK_MAIN( uvar->age_braking->length == 7, XLAL_EINVAL, "'age-braking' must have exactly 7 arguments" );
102 const double alpha = uvar->age_braking->data[0];
103 const double delta = uvar->age_braking->data[1];
104 const double freq = uvar->age_braking->data[2];
105 const double freq_band = uvar->age_braking->data[3];
106 const double age = uvar->age_braking->data[4];
107 const double min_braking = uvar->age_braking->data[5];
108 const double max_braking = uvar->age_braking->data[6];
114 XLAL_CHECK_MAIN( XLALSetLatticeTilingF1DotAgeBrakingBound( tiling, 2, 3, age, min_braking, max_braking ) == XLAL_SUCCESS, XLAL_EFUNC );
115 XLAL_CHECK_MAIN( XLALSetLatticeTilingF2DotBrakingBound( tiling, 2, 3, 4, min_braking, max_braking ) == XLAL_SUCCESS, XLAL_EFUNC );
116
117 }
118 const size_t n = XLALTotalLatticeTilingDimensions( tiling );
119
120 // Set lattice and metric
121 gsl_matrix *metric = NULL;
122 if ( uvar->metric == SPINDOWN ) {
123 GAMAT( metric, n, n );
124 gsl_matrix_set_identity( metric );
125 gsl_matrix_view spin_metric = gsl_matrix_submatrix( metric, 2, 2, n - 2, n - 2 );
126 XLAL_CHECK_MAIN( XLALSpindownMetric( &spin_metric.matrix, uvar->time_span ) == XLAL_SUCCESS, XLAL_EFUNC );
127 } else {
128 GAMAT( metric, n, n );
129 gsl_matrix_set_identity( metric );
130 }
132 gsl_matrix_free( metric );
133
134 // Create a lattice iterator
135 LatticeTilingIterator *itr = XLALCreateLatticeTilingIterator( tiling, n );
136 XLAL_CHECK_MAIN( itr != NULL, XLAL_EFUNC );
137
138 // Print number of templates
139 UINT8 ntemplates = XLALTotalLatticeTilingPoints( itr );
140 XLAL_CHECK_MAIN( ntemplates > 0, XLAL_EFUNC );
141 printf( "%" LAL_UINT8_FORMAT "\n", ntemplates );
142
143 // Cleanup
147
149
150 return EXIT_SUCCESS;
151
152}
int main(int argc, char *argv[])
const UserChoices MetricTypeChoices
enum @0 MetricType
int XLALSetLatticeTilingF2DotBrakingBound(LatticeTiling *tiling, const size_t freq_dimension, const size_t f1dot_dimension, const size_t f2dot_dimension, const double min_braking, const double max_braking)
Set a second spindown bound derived from braking indices.
int XLALSetLatticeTilingF1DotAgeBrakingBound(LatticeTiling *tiling, const size_t freq_dimension, const size_t f1dot_dimension, const double age, const double min_braking, const double max_braking)
Set a first spindown bound derived from spindown age and braking indices.
void LALCheckMemoryLeaks(void)
const LALVCSInfoList lalPulsarVCSInfoList
NULL-terminated list of VCS and build information for LALPulsar and its dependencies
static double double delta
unsigned char BOOLEAN
uint64_t UINT8
double REAL8
#define LAL_UINT8_FORMAT
size_t XLALTotalLatticeTilingDimensions(const LatticeTiling *tiling)
Return the total number of dimensions of the lattice tiling.
UINT8 XLALTotalLatticeTilingPoints(const LatticeTilingIterator *itr)
Return the total number of points covered by the lattice tiling iterator.
int XLALSetLatticeTilingConstantBound(LatticeTiling *tiling, const size_t dim, const double bound1, const double bound2)
Set a constant lattice tiling parameter-space bound, given by the minimum and maximum of the two supp...
int XLALSetTilingLatticeAndMetric(LatticeTiling *tiling, const TilingLattice lattice, const gsl_matrix *metric, const double max_mismatch)
Set the tiling lattice, parameter-space metric, and maximum prescribed mismatch.
LatticeTilingIterator * XLALCreateLatticeTilingIterator(const LatticeTiling *tiling, const size_t itr_ndim)
Create a new lattice tiling iterator.
void XLALDestroyLatticeTilingIterator(LatticeTilingIterator *itr)
Destroy a lattice tiling iterator.
void XLALDestroyLatticeTiling(LatticeTiling *tiling)
Destroy a lattice tiling.
LatticeTiling * XLALCreateLatticeTiling(const size_t ndim)
Create a new lattice tiling.
const UserChoices TilingLatticeChoices
Static array of all :tagTilingLattice choices, for use by the UserInput module parsing routines.
@ TILING_LATTICE_ANSTAR
An-star ( ) lattice.
Definition: LatticeTiling.h:65
int XLALSpindownMetric(gsl_matrix *metric, double Tspan)
Frequency and frequency derivative components of the metric, suitable for a directed search with only...
Definition: PtoleMetric.c:828
#define UVAR_STR2AND(n1, n2)
int XLALUserVarReadAllInput(BOOLEAN *should_exit, int argc, char *argv[], const LALVCSInfoList vcs_list)
void XLALDestroyUserVars(void)
#define XLALRegisterUvarMember(name, type, option, category,...)
void XLALUserVarCheck(BOOLEAN *should_exit, const int assertion, const CHAR *fmt,...) _LAL_GCC_PRINTF_FORMAT_(3
#define UVAR_SET(n)
#define XLALRegisterUvarAuxDataMember(name, type, cdata, option, category,...)
#define UVAR_SET2(n1, n2)
#define XLAL_CHECK(assertion,...)
#define XLAL_CHECK_MAIN(assertion,...)
XLAL_SUCCESS
XLAL_EFUNC
XLAL_EINVAL
n
double alpha
REAL8 * data
REAL8Vector * age_braking
UserInput_t uvar_struct
Definition: sw_inj_frames.c:93