Loading [MathJax]/extensions/TeX/AMSsymbols.js
LALPulsar 7.1.1.1-5e288d3
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
DopplerFullScan.c
Go to the documentation of this file.
1/*
2 * Copyright (C) 2007, 2008, 2012 Karl Wette
3 * Copyright (C) 2006, 2007 Reinhard Prix
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with with program; see the file COPYING. If not, write to the
17 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
18 * MA 02110-1301 USA
19 */
20
21/**
22 * \author Reinhard Prix, Karl Wette
23 * \date 2006, 2007, 2008
24 * \file
25 * \brief Functions for handling "full" multi-dimensional search-grids for CFS.
26 * as opposed to the "factored" grids implemented in DopplerScan.[ch]
27 */
28
29/*---------- INCLUDES ----------*/
30#include <math.h>
31
32#include <lal/LALStdlib.h>
33#include <lal/FileIO.h>
34#include <lal/DetectorSite.h>
35#include <lal/LALError.h>
36#include <lal/ConfigFile.h>
37#include <lal/LogPrintf.h>
38
39#include <lal/DopplerFullScan.h>
40
41/*---------- DEFINES ----------*/
42#define MIN(x,y) (x < y ? x : y)
43#define MAX(x,y) (x > y ? x : y)
44
45#define TRUE (1==1)
46#define FALSE (1==0)
47
48#ifdef __GNUC__
49#define UNUSED __attribute__ ((unused))
50#else
51#define UNUSED
52#endif
53
54/*---------- internal types ----------*/
55typedef struct {
56 PulsarDopplerParams thisPoint; /**< current doppler-position of the scan */
57 DopplerSkyScanState skyScan; /**< keep track of sky-grid stepping */
59
60/** doubly linked list of REAL8-vectors (physical vectors) */
61typedef struct tagREAL8VectorList {
63 struct tagREAL8VectorList *next;
64 struct tagREAL8VectorList *prev;
66
67/** ----- internal [opaque] type to store the state of a FULL multidimensional grid-scan ----- */
69 INT2 state; /**< idle, ready or finished */
70 DopplerGridType gridType; /**< what type of grid are we dealing with */
71 REAL8 numTemplates; /**< total number of templates in the grid */
72 PulsarSpinRange spinRange; /**< spin-range covered by template bank */
73 SkyRegion skyRegion; /**< sky-range covered by template bank */
74
75 /* ----- full multi-dim parameter-space grid stuff ----- */
76 REAL8VectorList *covering; /**< multi-dimensional covering */
77 REAL8VectorList *thisGridPoint; /**< pointer to current grid-point */
78
79 /* ----- spindown lattice tiling ----- */
80 LatticeTiling *spindownTiling; /**< spindown lattice tiling */
81 LatticeTilingIterator *spindownTilingItr; /**< iterator over spindown lattice tiling */
82 gsl_vector *spindownTilingPoint; /**< current point in spindown lattice tiling */
83
84 /* ----- emulate old-style factored grids */
85 factoredGridScan_t *factoredScan; /**< only used to emulate FACTORED grids sky x Freq x f1dot */
86
87} /* struct DopplerFullScanState */;
88
89/*---------- internal prototypes ----------*/
90int XLALInitFactoredGrid( DopplerFullScanState *scan, const DopplerFullScanInit *init );
91int nextPointInFactoredGrid( PulsarDopplerParams *pos, DopplerFullScanState *scan );
92int XLALLoadFullGridFile( DopplerFullScanState *scan, const DopplerFullScanInit *init );
93
94/*==================== FUNCTION DEFINITIONS ====================*/
95
96/**
97 * Set up a full multi-dimensional grid-scan.
98 * Currently this only emulates a 'factored' grid-scan with 'sky x Freq x f1dot ...' , but
99 * keeps all details within the DopplerScan module for future extension to real multidimensional
100 * grids.
101 *
102 * NOTE: Use 'XLALNextDopplerPos()' to step through this template grid.
103 *
104 */
105DopplerFullScanState *
106XLALInitDopplerFullScan( const DopplerFullScanInit *init /**< [in] initialization parameters */
107 )
108{
109 XLAL_CHECK_NULL( init != NULL, XLAL_EINVAL );
110
111 DopplerFullScanState *thisScan;
112 XLAL_CHECK_NULL( ( thisScan = LALCalloc( 1, sizeof( *thisScan ) ) ) != NULL, XLAL_ENOMEM );
113
114 thisScan->gridType = init->gridType;
115
116 /* store the user-input spinRange (includes refTime) in DopplerFullScanState */
117 thisScan->spinRange.refTime = init->searchRegion.refTime;
118 memcpy( thisScan->spinRange.fkdot, init->searchRegion.fkdot, sizeof( PulsarSpins ) );
119 memcpy( thisScan->spinRange.fkdotBand, init->searchRegion.fkdotBand, sizeof( PulsarSpins ) );
120
121 // check that some old metric-codes aren't used with refTime!=startTime, which they don't handle correctly
122 switch ( thisScan->gridType ) {
123 case GRID_METRIC:
125 case GRID_SPINDOWN_SQUARE: /* square parameter space */
126 case GRID_SPINDOWN_AGEBRK: /* age-braking index parameter space */
127
129 "NOTE: gridType={metric,4,spin-square,spin-age-brk} only work for refTime (%f) == startTime (%f)!\n",
130 XLALGPSGetREAL8( &( init->searchRegion.refTime ) ), XLALGPSGetREAL8( &( init->startTime ) ) );;
131
132 break;
133 default:
134 break;
135 }
136
137 /* which "class" of template grid to generate?: factored, or full-multidim ? */
138 switch ( thisScan->gridType ) {
139 /* emulate old 'factored' grids 'sky x f0dot x f1dot x f2dot x f3dot': */
140 case GRID_FLAT:
141 case GRID_ISOTROPIC:
142 case GRID_METRIC:
145 /* backwards-compatibility mode */
147 break;
148
149 /* ----- multi-dimensional covering of full parameter space ----- */
152 break;
153
154 case GRID_SPINDOWN_SQUARE: /* square parameter space */
155 case GRID_SPINDOWN_AGEBRK: { /* age-braking index parameter space */
156 const size_t n = 2 + PULSAR_MAX_SPINS;
157
158 /* Check that the reference time is the same as the start time */
159 XLAL_CHECK_NULL( XLALGPSCmp( &thisScan->spinRange.refTime, &init->startTime ) == 0, XLAL_EINVAL,
160 "\nGRID_SPINDOWN_{SQUARE,AGEBRK}: This option currently restricts the reference time to be the same as the start time.\n" );
161
162 /* Create a vector to hold lattice tiling parameter-space points */
163 XLAL_CHECK_NULL( ( thisScan->spindownTilingPoint = gsl_vector_alloc( n ) ) != NULL, XLAL_ENOMEM,
164 "\nGRID_SPINDOWN_{SQUARE,AGEBRK}: gsl_vector_alloc failed\n" );
165
166 /* Create a lattice tiling */
167 XLAL_CHECK_NULL( ( thisScan->spindownTiling = XLALCreateLatticeTiling( n ) ) != NULL, XLAL_EFUNC );
168
169 /* Parse the sky region string and check that it consists of only one point, and set bounds on it */
172 XLAL_CHECK_NULL( sky.numVertices == 1, XLAL_EINVAL, "\nGRID_SPINDOWN_{SQUARE,AGEBRK}: This option can only handle a single sky position.\n" );
173 XLAL_CHECK_NULL( sky.vertices[0].system == COORDINATESYSTEM_EQUATORIAL, XLAL_EINVAL, "\nGRID_SPINDOWN_{SQUARE,AGEBRK}: This option only understands COORDINATESYSTEM_EQUATORIAL\n" );
174
175 XLAL_CHECK_NULL( XLALSetLatticeTilingConstantBound( thisScan->spindownTiling, 0, sky.vertices[0].longitude, sky.vertices[0].longitude ) == XLAL_SUCCESS, XLAL_EFUNC );
176
177 XLAL_CHECK_NULL( XLALSetLatticeTilingConstantBound( thisScan->spindownTiling, 1, sky.vertices[0].latitude, sky.vertices[0].latitude ) == XLAL_SUCCESS, XLAL_EFUNC );
178 if ( sky.vertices ) {
179 XLALFree( sky.vertices );
180 }
181
182 /* Set up parameter space */
183 if ( thisScan->gridType == GRID_SPINDOWN_SQUARE ) { /* square parameter space */
184
185 /* Set square bounds on the frequency and spindowns */
186 for ( size_t i = 0; i < PULSAR_MAX_SPINS; ++i ) {
188 }
189 /* if requested by user, suppress padding in the fkdot (k>0) dimensions;
190 * if not, default padding is kept the same as in XLALCreateLatticeTiling()
191 */
192 if ( !init->extraArgs[0] ) {
193 for ( size_t i = 1; i < PULSAR_MAX_SPINS; ++i ) {
194 XLAL_CHECK_NULL( XLALSetLatticeTilingPadding( thisScan->spindownTiling, 2 + i, 0, 0, 0, 0, -1 ) == XLAL_SUCCESS, XLAL_EFUNC );
195 }
196 }
197
198 } else if ( thisScan->gridType == GRID_SPINDOWN_AGEBRK ) { /* age-braking index parameter space */
199
200 /* Get age and braking index from extra arguments */
201 const REAL8 spindownAge = init->extraArgs[0];
202 const REAL8 minBraking = init->extraArgs[1];
203 const REAL8 maxBraking = init->extraArgs[2];
204
205 /* Set age-braking index parameter space */
206 XLAL_CHECK_NULL( XLAL_SUCCESS == XLALSetLatticeTilingConstantBound( thisScan->spindownTiling, 2, init->searchRegion.fkdot[0], init->searchRegion.fkdot[0] + init->searchRegion.fkdotBand[0] ), XLAL_EFUNC );
207 XLAL_CHECK_NULL( XLAL_SUCCESS == XLALSetLatticeTilingF1DotAgeBrakingBound( thisScan->spindownTiling, 2, 3, spindownAge, minBraking, maxBraking ), XLAL_EFUNC );
208 XLAL_CHECK_NULL( XLAL_SUCCESS == XLALSetLatticeTilingF2DotBrakingBound( thisScan->spindownTiling, 2, 3, 4, minBraking, maxBraking ), XLAL_EFUNC );
209
210 /* This current only goes up to second spindown, so bound higher dimensions */
211 for ( size_t i = 3; i < PULSAR_MAX_SPINS; ++i ) {
213 }
214
215 }
216
217 /* Create a lattice tiling with Anstar lattice and spindown metric */
218 gsl_matrix *metric;
219 XLAL_CHECK_NULL( ( metric = gsl_matrix_alloc( n, n ) ) != NULL, XLAL_ENOMEM );
220 gsl_matrix_set_identity( metric );
221 gsl_matrix_view spin_metric = gsl_matrix_submatrix( metric, 2, 2, PULSAR_MAX_SPINS, PULSAR_MAX_SPINS );
222 XLAL_CHECK_NULL( XLALSpindownMetric( &spin_metric.matrix, init->Tspan ) == XLAL_SUCCESS, XLAL_EFUNC );
224
225 /* Create iterator over flat lattice tiling */
226 XLAL_CHECK_NULL( ( thisScan->spindownTilingItr = XLALCreateLatticeTilingIterator( thisScan->spindownTiling, n ) ) != NULL, XLAL_EFUNC );
227
228 /* Cleanup */
229 gsl_matrix_free( metric );
230
231 }
232
233 break;
234
235 default:
236 XLAL_ERROR_NULL( XLAL_EINVAL, "\nInvalid grid type '%d'\n\n", init->gridType );
237 break;
238 } /* switch gridType */
239
240 /* we're ready */
241 thisScan->state = STATE_READY;
242
243 /* return result */
244 return thisScan;
245
246} // XLALInitDopplerFullScan()
247
248
249/** \deprecated Use XLALInitDopplerFullScan() instead.
250 */
251void
252InitDopplerFullScan( LALStatus *status, /**< pointer to LALStatus structure */
253 DopplerFullScanState **scan, /**< [out] initialized Doppler scan state */
254 const DopplerFullScanInit *init /**< [in] initialization parameters */
255 )
256{
258
259 XLAL_PRINT_DEPRECATION_WARNING( "XLALInitDopplerFullScan" );
260
264
265 if ( ( ( *scan ) = XLALInitDopplerFullScan( init ) ) == NULL ) {
267 }
268
269 RETURN( status );
270
271} /* InitDopplerFullScan() */
272
273/**
274 * Return the spin-range spanned by the given template bank stored in the
275 * *opaque* DopplerFullScanState.
276 *
277 * \note The user cannot directly access any internal fields of that opaque type,
278 * which is why we need this API.
279 */
280int
281XLALGetDopplerSpinRange( PulsarSpinRange *spinRange, const DopplerFullScanState *scan )
282{
283 if ( spinRange == NULL ) {
284 XLAL_ERROR( XLAL_EINVAL, "\nPulsarSpinRange pointer 'spinRange' is NULL\n" );
285 }
286
287 if ( scan == NULL ) {
288 XLAL_ERROR( XLAL_EINVAL, "\nDopplerFullScanState pointer 'scan' is NULL\n" );
289 }
290
291 ( *spinRange ) = scan->spinRange; // simple struct-copy is all that's needed
292
293 return XLAL_SUCCESS;
294
295} /* XLALGetDopplerSpinRange() */
296
297/**
298 * Initialize Doppler-scanner to emulate an old-style factored template grid: 'sky x f0dot x f1dot x f2dot x f3dot'.
299 * This is a compatiblity-mode with the previous implementation currently also used in ComputeFstatistic.c.
300 */
301int
302XLALInitFactoredGrid( DopplerFullScanState *scan, /**< [bout] initialized Doppler scan state */
303 const DopplerFullScanInit *init /**< [in] initialization parameters */
304 )
305{
306 XLAL_CHECK( scan, XLAL_EINVAL );
307 XLAL_CHECK( scan->state == STATE_IDLE, XLAL_EINVAL );
308 XLAL_CHECK( init, XLAL_EINVAL );
309
310 DopplerSkyScanInit XLAL_INIT_DECL( skyScanInit );
311 SkyPosition skypos;
312 factoredGridScan_t *fscan = NULL;
313
314 /* prepare initialization of DopplerSkyScanner to step through paramter space */
315 skyScanInit.dAlpha = init->stepSizes.Alpha;
316 skyScanInit.dDelta = init->stepSizes.Delta;
317 skyScanInit.gridType = init->gridType;
318 skyScanInit.metricType = init->metricType;
319 skyScanInit.metricMismatch = init->metricMismatch;
320 skyScanInit.projectMetric = init->projectMetric;
321 skyScanInit.obsBegin = init->startTime;
322 skyScanInit.obsDuration = init->Tspan;
323
324 skyScanInit.Detector = init->Detector;
325 skyScanInit.ephemeris = init->ephemeris; /* used only by Ephemeris-based metric */
326 skyScanInit.skyGridFile = init->gridFile;
327 skyScanInit.skyRegionString = init->searchRegion.skyRegionString;
328 skyScanInit.Freq = init->searchRegion.fkdot[0] + init->searchRegion.fkdotBand[0];
329
330 XLAL_CHECK( ( fscan = LALCalloc( 1, sizeof( *fscan ) ) ) != NULL, XLAL_ENOMEM );
331 scan->factoredScan = fscan;
332 XLAL_CHECK( XLALInitDopplerSkyScan( &( fscan->skyScan ), &skyScanInit ) == XLAL_SUCCESS, XLAL_EFUNC );
333
334 /* overload spin step-sizes with user-settings if given */
335 for ( UINT4 i = 0; i < PULSAR_MAX_SPINS; i ++ ) {
336 if ( init->stepSizes.fkdot[i] ) {
337 fscan->skyScan.dfkdot[i] = init->stepSizes.fkdot[i];
338 }
339 }
340
341 /* ----- set Doppler-scanner to start-point ----- */
342 fscan->thisPoint.refTime = init->searchRegion.refTime; /* set proper reference time for spins */
343
344 /* normalize skyposition: correctly map into [0,2pi]x[-pi/2,pi/2] */
345 skypos.longitude = fscan->skyScan.skyNode->Alpha;
346 skypos.latitude = fscan->skyScan.skyNode->Delta;
348 XLALNormalizeSkyPosition( &skypos.longitude, &skypos.latitude );
349 fscan->thisPoint.Alpha = skypos.longitude;
350 fscan->thisPoint.Delta = skypos.latitude;
351 /* set spins to start */
352 for ( UINT4 i = 0; i < PULSAR_MAX_SPINS; i ++ ) {
353 fscan->thisPoint.fkdot[i] = scan->spinRange.fkdot[i];
354 }
355
356 { /* count total number of templates */
357 REAL8 nSky, nTot;
358 REAL8 nSpins[PULSAR_MAX_SPINS];
359 nSky = fscan->skyScan.numSkyGridPoints;
360 for ( UINT4 i = 0; i < PULSAR_MAX_SPINS; i ++ ) {
361 nSpins[i] = floor( scan->spinRange.fkdotBand[i] / fscan->skyScan.dfkdot[i] ) + 1.0;
362 }
363 nTot = nSky;
364 for ( UINT4 i = 0; i < PULSAR_MAX_SPINS; i ++ ) {
365 nTot *= nSpins[i];
366 }
367 scan->numTemplates = nTot;
368 XLALPrintInfo( "Template grid: nSky x nFreq x nf1dot = %.0f x %.0f x %.0f = %.0f \n", nSky, nSpins[0], nSpins[1], nTot );
369 }
370
371 return XLAL_SUCCESS;
372
373} // XLALInitFactoredGrid()
374
375
376/**
377 * Return (and compute if not done so yet) the total number of Doppler templates
378 * of the DopplerScan \a scan
379 */
380REAL8
381XLALNumDopplerTemplates( DopplerFullScanState *scan )
382{
383 if ( ! scan->numTemplates ) { /* not pre-computed already ? */
384 switch ( scan->gridType ) {
385 /* case GRID_METRIC_LATTICE: */
386 /* LogPrintf ( LOG_DEBUG, "Now counting number of templates in lattice ... "); */
387 /* scan->numTemplates = XLALCountLatticeTemplates ( scan->latticeScan ); */
388 /* LogPrintfVerbatim( LOG_DEBUG, " done. (%.0f)\n", scan->numTemplates ); */
389 /* break; */
390
391 case GRID_SPINDOWN_SQUARE: /* square parameter space */
392 case GRID_SPINDOWN_AGEBRK: /* age-braking index parameter space */
393 LogPrintf( LOG_DEBUG, "Counting spindown lattice templates ... " );
394 scan->numTemplates = ( REAL8 )XLALTotalLatticeTilingPoints( scan->spindownTilingItr );
395 LogPrintfVerbatim( LOG_DEBUG, "%0.0f\n", scan->numTemplates );
396 break;
397
398 default:
399 /* FIXME: not implemented yet */
400 LogPrintf( LOG_NORMAL, "template counting not implemented yet for gridType=%d!\n", scan->gridType );
401 return -1;
402 break;
403 } /* switch() */
404 } /* ! numTemplates */
405
406 return scan->numTemplates;
407
408} /* XLALNumDopplerTemplates() */
409
410
411/**
412 * Compute and return the total number of frequency and spindown points
413 * up to and along a certain dimension \a dim of the DopplerScan \a scan
414 */
415UINT8
416XLALNumDopplerPointsAtDimension( DopplerFullScanState *scan, const size_t dim )
417{
418 UINT8 numTemplates;
419 switch ( scan->gridType ) {
420 case GRID_SPINDOWN_SQUARE: /* square parameter space */
421 case GRID_SPINDOWN_AGEBRK: /* age-braking index parameter space */
422 LogPrintf( LOG_DEBUG, "Counting templates of spindown lattice at dimension %ld... ", dim );
423 numTemplates = XLALLatticeTilingPointsAtDimension( scan->spindownTilingItr, dim );
424 LogPrintfVerbatim( LOG_DEBUG, "%" LAL_INT8_FORMAT "\n", numTemplates );
425 break;
426
427 default:
428 /* FIXME: not implemented yet */
429 LogPrintf( LOG_NORMAL, "template counting not implemented yet for gridType=%d!\n", scan->gridType );
430 return -1;
431 break;
432 } /* switch() */
433
434 return numTemplates;
435
436} /* XLALNumDopplerPointsAtDimension() */
437
438
439/**
440 * Function to step through the full template grid point by point.
441 * Normal return = 0,
442 * errors return -1,
443 * end of scan is signalled by return = 1
444 */
445int
446XLALNextDopplerPos( PulsarDopplerParams *pos, DopplerFullScanState *scan )
447{
448
449 /* This traps coding errors in the calling routine. */
450 if ( pos == NULL || scan == NULL ) {
452 }
453 if ( scan->state == STATE_IDLE ) {
454 XLALPrintError( "\nCalled XLALNextDopplerPos() on un-initialized DopplerFullScanState !\n\n" );
456 }
457
458 /* is this search finished? then return '1' */
459 if ( scan->state == STATE_FINISHED ) {
460 return 1;
461 }
462
463 // set refTime in returned template to the refTime of the grid
464 pos->refTime = scan->spinRange.refTime;
465
466 /* ----- step foward one template in full grid ----- */
467 /* Which "class" of template grid are we dealing with: factored, or full-multidim ? */
468 switch ( scan->gridType ) {
469 /* emulate old 'factored' grids 'sky x f0dot x f1dot x f2dot x f3dot': */
470 case GRID_FLAT:
471 case GRID_ISOTROPIC:
472 case GRID_METRIC:
475 /* backwards-compatibility mode */
477 break;
478
480 XLAL_INIT_MEM( pos->fkdot );
481 pos->fkdot[0] = scan->thisGridPoint->entry.data[0];
482 pos->Alpha = scan->thisGridPoint->entry.data[1];
483 pos->Delta = scan->thisGridPoint->entry.data[2];
484 pos->fkdot[1] = scan->thisGridPoint->entry.data[3];
485 pos->fkdot[2] = scan->thisGridPoint->entry.data[4];
486 pos->fkdot[3] = scan->thisGridPoint->entry.data[5];
487 pos->asini = 0; // isolated pulsar
488 /* advance to next grid point */
489 if ( ( scan->thisGridPoint = scan->thisGridPoint->next ) == NULL ) {
490 scan->state = STATE_FINISHED;
491 }
492
493 break;
494
495 /* case GRID_METRIC_LATTICE: */
496 /* if ( XLALgetCurrentDopplerPos ( pos, scan->latticeScan, COORDINATESYSTEM_EQUATORIAL ) ) { */
497 /* XLAL_ERROR ( XLAL_EFUNC ); */
498 /* } */
499 /* /\* advance to next point *\/ */
500 /* ret = XLALadvanceLatticeIndex ( scan->latticeScan ); */
501 /* if ( ret < 0 ) { */
502 /* XLAL_ERROR ( XLAL_EFUNC ); */
503 /* } */
504 /* else if ( ret == 1 ) */
505 /* { */
506 /* XLALPrintError ( "\n\nXLALadvanceLatticeIndex(): this was the last lattice points!\n\n"); */
507 /* scan->state = STATE_FINISHED; */
508 /* } */
509 /* #if 0 */
510 /* { /\* debugging *\/ */
511 /* gsl_vector_int *lal_index = NULL; */
512 /* XLALgetCurrentLatticeIndex ( &lal)index, scan->latticeScan ); */
513 /* XLALfprintfGSLvector_int ( stderr, "%d", lal_index ); */
514 /* gsl_vector_int_free ( lal_index ); */
515 /* } */
516 /* #endif */
517
518 break;
519
520 case GRID_SPINDOWN_SQUARE: /* square parameter space */
521 case GRID_SPINDOWN_AGEBRK: { /* age-braking index parameter space */
522
523 /* Advance to next tile */
524 int retn = XLALNextLatticeTilingPoint( scan->spindownTilingItr, scan->spindownTilingPoint );
525 if ( retn < 0 ) {
526 XLALPrintError( "\nGRID_SPINDOWN_{SQUARE,AGEBRK}: XLALNextLatticeTilingPoint() failed\n" );
527 return -1;
528 }
529
530 if ( retn > 0 ) {
531
532 /* Found a point */
533 pos->Alpha = gsl_vector_get( scan->spindownTilingPoint, 0 );
534 pos->Delta = gsl_vector_get( scan->spindownTilingPoint, 1 );
535 pos->fkdot[0] = gsl_vector_get( scan->spindownTilingPoint, 2 );
536 for ( size_t i = 1; i < PULSAR_MAX_SPINS; ++i ) {
537 pos->fkdot[i] = gsl_vector_get( scan->spindownTilingPoint, i + 2 );
538 }
539
540 return 0;
541
542 } else {
543
544 /* No more points */
545 scan->state = STATE_FINISHED;
546 return 1;
547
548 }
549
550 }
551
552 break;
553
554 default:
555 XLALPrintError( "\nInvalid grid type '%d'\n\n", scan->gridType );
557 return -1;
558 break;
559 } /* switch gridType */
560
561 return 0;
562
563} /* XLALNextDopplerPos() */
564
565/**
566 * return current grid-point and step forward one template in 'factored' grids (sky x f0dot x f1dot ... )
567 * return 0 = OK, -1 = ERROR
568 */
569int
570nextPointInFactoredGrid( PulsarDopplerParams *pos, DopplerFullScanState *scan )
571{
573 factoredGridScan_t *fscan;
575 PulsarSpins fkdotMax;
576 SkyPosition skypos;
577
578 if ( pos == NULL || scan == NULL ) {
579 return -1;
580 }
581
582 if ( ( fscan = scan->factoredScan ) == NULL ) {
583 return -1;
584 }
585
586 range = &( scan->spinRange ); /* shortcut */
587
588 ( *pos ) = fscan->thisPoint; /* RETURN current Doppler-point (struct-copy) */
589
590 nextPos = fscan->thisPoint; /* struct-copy: start from current point to get next one */
591
592 /* shortcuts: spin boundaries */
593 fkdotMax[3] = range->fkdot[3] + range->fkdotBand[3];
594 fkdotMax[2] = range->fkdot[2] + range->fkdotBand[2];
595 fkdotMax[1] = range->fkdot[1] + range->fkdotBand[1];
596 fkdotMax[0] = range->fkdot[0] + range->fkdotBand[0];
597
598 /* try to advance to next template */
599 nextPos.fkdot[0] += fscan->skyScan.dfkdot[0]; /* f0dot one forward */
600 if ( nextPos.fkdot[0] > fkdotMax[0] ) { /* too far? */
601 nextPos.fkdot[0] = range->fkdot[0]; /* f0dot return to start */
602 nextPos.fkdot[1] += fscan->skyScan.dfkdot[1]; /* f1dot one step forward */
603 if ( nextPos.fkdot[1] > fkdotMax[1] ) {
604 nextPos.fkdot[1] = range->fkdot[1]; /* f1dot return to start */
605 nextPos.fkdot[2] += fscan->skyScan.dfkdot[2]; /* f2dot one forward */
606 if ( nextPos.fkdot[2] > fkdotMax[2] ) {
607 nextPos.fkdot[2] = range->fkdot[2]; /* f2dot return to start */
608 nextPos.fkdot[3] += fscan->skyScan.dfkdot[3]; /* f3dot one forward */
609 if ( nextPos.fkdot[3] > fkdotMax[3] ) {
610 nextPos.fkdot[3] = range->fkdot[3]; /* f3dot return to start */
611 /* skygrid one forward */
612 if ( ( fscan->skyScan.skyNode = fscan->skyScan.skyNode->next ) == NULL ) { /* no more sky-points ?*/
613 fscan->skyScan.state = STATE_FINISHED; /* avoid warning when freeing */
614 scan->state = STATE_FINISHED; /* we're done */
615 } else {
616 /* normalize next skyposition: correctly map into [0,2pi]x[-pi/2,pi/2] */
617 skypos.longitude = fscan->skyScan.skyNode->Alpha;
618 skypos.latitude = fscan->skyScan.skyNode->Delta;
620 XLALNormalizeSkyPosition( &skypos.longitude, &skypos.latitude );
621 nextPos.Alpha = skypos.longitude;
622 nextPos.Delta = skypos.latitude;
623 }
624 } /* f3dot */
625 } /* f2dot */
626 } /* f1dot */
627 } /* f0dot */
628
629 /* prepare next step */
630 fscan->thisPoint = nextPos;
631
632 return 0;
633
634} /* nextPointInFactoredGrid() */
635
636static void
638{
639 REAL8VectorList *ptr, *next;
640
641 if ( !head ) {
642 return;
643 }
644
645 next = head;
646
647 do {
648 /* step to next element */
649 ptr = next;
650 /* remember pointer to next element */
651 next = ptr->next;
652 /* free current element */
653 LALFree( ptr->entry.data );
654 LALFree( ptr );
655
656 } while ( ( ptr = next ) != NULL );
657
658 return;
659} /* XLALREAL8VectorListDestroy() */
660
661/**
662 * Destroy the a full DopplerFullScanState structure
663 */
664void
665XLALDestroyDopplerFullScan( DopplerFullScanState *scan )
666{
667 if ( scan == NULL ) {
668 return;
669 }
670
671 if ( scan->factoredScan ) {
672 XLALDestroyDopplerSkyScan( &( scan->factoredScan->skyScan ) );
673 XLALFree( scan->factoredScan );
674 }
675
676 if ( scan->covering ) {
677 XLALREAL8VectorListDestroy( scan->covering );
678 }
679
680 if ( scan->spindownTiling ) {
681 XLALDestroyLatticeTiling( scan->spindownTiling );
682 }
683 if ( scan->spindownTilingItr ) {
684 XLALDestroyLatticeTilingIterator( scan->spindownTilingItr );
685 }
686 if ( scan->spindownTilingPoint ) {
687 gsl_vector_free( scan->spindownTilingPoint );
688 }
689
690 if ( scan->skyRegion.vertices ) {
691 XLALFree( scan->skyRegion.vertices );
692 }
693
694 XLALFree( scan );
695
696 return;
697
698} // XLALDestroyDopplerFullScan()
699
700
701static REAL8VectorList *
703{
704 UINT4 dim;
705 REAL8VectorList *ptr = NULL; /* running list-pointer */
706 REAL8VectorList *newElement = NULL; /* new list-element */
707 /* check illegal input */
708 if ( ( head == NULL ) || ( entry == NULL ) ) {
709 return NULL;
710 }
711
712 /* find tail of list */
713 ptr = head;
714 while ( ptr->next ) {
715 ptr = ptr->next;
716 }
717
718 /* construct new list-element */
719 dim = entry->length;
720 if ( ( newElement = LALCalloc( 1, sizeof( *newElement ) ) ) == NULL ) {
721 return NULL;
722 }
723 if ( ( newElement->entry.data = LALCalloc( dim, sizeof( entry->data[0] ) ) ) == NULL ) {
724 LALFree( newElement );
725 return NULL;
726 }
727 newElement->entry.length = dim;
728 memcpy( newElement->entry.data, entry->data, dim * sizeof( entry->data[0] ) );
729
730 /* link this to the tail of list */
731 ptr->next = newElement;
732 newElement->prev = ptr;
733
734 return newElement;
735
736} /* XLALREAL8VectorListAddEntry() */
737
738/**
739 * load a full multi-dim template grid from the file init->gridFile,
740 * the file-format is: lines of 6 columns, which are:
741 *
742 * Freq Alpha Delta f1dot f2dot f3dot
743 *
744 * \note
745 * *) this function returns the effective spinRange covered by the read-in template bank
746 * by storing it in scan->spinRange, potentially overwriting any previous user-input values in there.
747 *
748 * *) a possible future extension should probably *clip* the template-bank to the user-specified ranges,
749 * then return the effective ranges spanned by the resultant template bank.
750 *
751 * *) in order to avoid surprises until such a feature is implemented, we currently return an error if
752 * any of the input spinRanges are non-zero
753 *
754 */
755int
756XLALLoadFullGridFile( DopplerFullScanState *scan,
757 const DopplerFullScanInit *init
758 )
759{
760 XLAL_CHECK( ( scan != NULL ) && ( init != NULL ), XLAL_EINVAL );
761 XLAL_CHECK( init->gridFile != NULL, XLAL_EINVAL );
762 XLAL_CHECK( scan->state == STATE_IDLE, XLAL_EINVAL );
763
765 REAL8VectorList *tail = NULL;
766 REAL8Vector *entry = NULL;
767 UINT4 numTemplates;
768 FILE *fp;
769
770
771 /* Check that all user-input spin- and sky-ranges are zero, otherwise fail!
772 *
773 * NOTE: In the future we should allow combining the user-input ranges with
774 * those found in the grid-file by forming the intersection, ie *clipping*
775 * of the read-in grids to the user-input ranges.
776 * Right now we require empty ranges input, and report back the ranges from the grid-file
777 *
778 */
779 if ( init->searchRegion.skyRegionString != NULL ) {
780 XLAL_ERROR( XLAL_EINVAL, "\nnon-NULL skyRegion input currently not supported! skyRegion = '%s'\n\n", init->searchRegion.skyRegionString );
781 }
782 for ( UINT4 s = 0; s < PULSAR_MAX_SPINS; s ++ ) {
783 if ( ( init->searchRegion.fkdot[s] != 0 ) || ( init->searchRegion.fkdotBand[s] != 0 ) ) {
784 XLAL_ERROR( XLAL_EINVAL, "\nnon-zero input spinRanges currently not supported! fkdot[%d] = %g, fkdotBand[%d] = %g\n\n",
785 s, init->searchRegion.fkdot[s], s, init->searchRegion.fkdotBand[s] );
786 }
787 } /* for s < max_spins */
788
789 /* open input data file */
790 XLAL_CHECK( ( fp = fopen( init->gridFile, "r" ) ) != NULL, XLAL_ESYS, "Could not open data-file: `%s`\n\n", init->gridFile );
791
792 /* prepare grid-entry buffer */
793 XLAL_CHECK( ( entry = XLALCreateREAL8Vector( 6 ) ) != NULL, XLAL_EFUNC );
794
795 /* keep track of the sky- and spinRanges spanned by the template bank */
796 REAL8 FreqMax = - LAL_REAL4_MAX, FreqMin = LAL_REAL4_MAX; // only using REAL4 ranges to avoid over/under flows, and should be enough
797 REAL8 f1dotMax = - LAL_REAL4_MAX, f1dotMin = LAL_REAL4_MAX;
798 REAL8 f2dotMax = - LAL_REAL4_MAX, f2dotMin = LAL_REAL4_MAX;
799 REAL8 f3dotMax = - LAL_REAL4_MAX, f3dotMin = LAL_REAL4_MAX;
800
801 REAL8 alphaMax = - LAL_REAL4_MAX, alphaMin = LAL_REAL4_MAX;
802 REAL8 deltaMax = - LAL_REAL4_MAX, deltaMin = LAL_REAL4_MAX;
803
804 /* parse this list of lines into a full grid */
805 numTemplates = 0;
806 tail = &head; /* head will remain empty! */
807 CHAR line[2048];
808 while ( ! feof( fp ) && ! ferror( fp ) && fgets( line, sizeof( line ), fp ) != NULL ) {
809
810 // Skip over any comment lines
811 if ( line[0] == '#' || line[0] == '%' ) {
812 continue;
813 }
814
815 // File format expects lines containing 6 columns: Freq Alpha Delta f1dot f2dot f3dot
816 REAL8 Freq, Alpha, Delta, f1dot, f2dot, f3dot;
818 &Freq, &Alpha, &Delta, &f1dot, &f2dot, &f3dot ) ) {
819 XLALPrintError( "ERROR: Failed to parse 6 REAL8's from line %d in grid-file '%s'\n\n", numTemplates + 1, init->gridFile );
820 if ( head.next ) {
822 }
824 }
825
826 /* keep track of maximal spans */
827 alphaMin = fmin( Alpha, alphaMin );
828 deltaMin = fmin( Delta, deltaMin );
829 FreqMin = fmin( Freq, FreqMin );
830 f1dotMin = fmin( f1dot, f1dotMin );
831 f2dotMin = fmin( f2dot, f2dotMin );
832 f3dotMin = fmin( f3dot, f3dotMin );
833
834 alphaMax = fmax( Alpha, alphaMax );
835 deltaMax = fmax( Delta, deltaMax );
836 FreqMax = fmax( Freq, FreqMax );
837 f1dotMax = fmax( f1dot, f1dotMax );
838 f2dotMax = fmax( f2dot, f2dotMax );
839 f3dotMax = fmax( f3dot, f3dotMax );
840
841 /* add this entry to template-bank list */
842 entry->data[0] = Freq;
843 entry->data[1] = Alpha;
844 entry->data[2] = Delta;
845 entry->data[3] = f1dot;
846 entry->data[4] = f2dot;
847 entry->data[5] = f3dot;
848
849 if ( ( tail = XLALREAL8VectorListAddEntry( tail, entry ) ) == NULL ) {
850 if ( head.next ) {
852 }
854 }
855
856 numTemplates ++ ;
857
858 } /* while !feof(fp) && ... */
859 if ( ferror( fp ) ) {
861 }
862
863 XLALDestroyREAL8Vector( entry );
864
865 XLAL_CHECK( numTemplates > 0, XLAL_EIO, "Got empty grid from file %s", init->gridFile );
866
867 /* ---------- update scan-state ---------- */
868
869 // ----- report back ranges actually spanned by grid-file
870
871 CHAR *skyRegionString = NULL;
873 XLAL_CHECK( ( skyRegionString = XLALSkySquare2String( alphaMin, deltaMin, ( alphaMax - alphaMin ) + eps, ( deltaMax - deltaMin ) + eps ) ) != NULL, XLAL_EFUNC );
874
875 // note: we slight expanded the enclosing sky-square by eps to avoid complaints when a grid-file contains
876 // only points in a line, which is perfectly valid here.
877 XLAL_CHECK( XLALParseSkyRegionString( &scan->skyRegion, skyRegionString ) == XLAL_SUCCESS, XLAL_EFUNC );
878 XLALFree( skyRegionString );
879
880 scan->spinRange.fkdot[0] = FreqMin;
881 scan->spinRange.fkdotBand[0] = FreqMax - FreqMin;
882
883 scan->spinRange.fkdot[1] = f1dotMin;
884 scan->spinRange.fkdotBand[1] = f1dotMax - f1dotMin;
885
886 scan->spinRange.fkdot[2] = f2dotMin;
887 scan->spinRange.fkdotBand[2] = f2dotMax - f2dotMin;
888
889 scan->spinRange.fkdot[3] = f3dotMin;
890 scan->spinRange.fkdotBand[3] = f3dotMax - f3dotMin;
891
892 scan->numTemplates = numTemplates;
893 scan->covering = head.next; /* pass result (without head!) */
894 scan->thisGridPoint = scan->covering; /* init to start */
895
896 XLALPrintInfo( "Template grid: nTot = %.0f\n", 1.0 * numTemplates );
897 XLALPrintInfo( "Spanned ranges: Freq in [%g, %g], f1dot in [%g, %g], f2dot in [%g, %g], f3dot in [%g, %g]\n",
898 FreqMin, FreqMax, f1dotMin, f1dotMax, f2dotMin, f2dotMax, f3dotMin, f3dotMax );
899
900 return XLAL_SUCCESS;
901
902} /* XLALLoadFullGridFile() */
903
904typedef struct {
905 size_t freq_dim;
906 double scale;
908
910 const void *data,
911 const size_t dim UNUSED,
912 const gsl_matrix *cache UNUSED,
913 const gsl_vector *point
914)
915{
916
917 // Get bounds info
919
920 // Get current value of frequency
921 const double freq = gsl_vector_get( point, info->freq_dim );
922
923 // Return first spindown bounds
924 return info->scale * freq;
925
926}
927
929 LatticeTiling *tiling,
930 const size_t freq_dimension,
931 const size_t f1dot_dimension,
932 const double age,
933 const double min_braking,
934 const double max_braking
935)
936{
937
938 // Check input
939 XLAL_CHECK( tiling != NULL, XLAL_EFAULT );
940 XLAL_CHECK( freq_dimension < f1dot_dimension, XLAL_EINVAL );
941 XLAL_CHECK( age > 0.0, XLAL_EINVAL );
942 XLAL_CHECK( min_braking > 1.0, XLAL_EINVAL );
943 XLAL_CHECK( max_braking > 1.0, XLAL_EINVAL );
944 XLAL_CHECK( min_braking <= max_braking, XLAL_EINVAL );
945
946 // Set the parameter-space bound
949 info_lower.freq_dim = info_upper.freq_dim = freq_dimension;
950 info_lower.scale = -1.0 / ( ( min_braking - 1.0 ) * age );
951 info_upper.scale = -1.0 / ( ( max_braking - 1.0 ) * age );
952 XLAL_CHECK( XLALSetLatticeTilingBound( tiling, f1dot_dimension, F1DotAgeBrakingBound, sizeof( info_lower ), &info_lower, &info_upper ) == XLAL_SUCCESS, XLAL_EFAILED );
953
954 return XLAL_SUCCESS;
955
956}
957
958typedef struct {
959 size_t freq_dim;
960 size_t f1dot_dim;
961 double scale;
963
964static double F2DotBrakingBound(
965 const void *data,
966 const size_t dim UNUSED,
967 const gsl_matrix *cache UNUSED,
968 const gsl_vector *point
969)
970{
971
972 // Get bounds info
974
975 // Get current values of frequency and first spindown
976 const double freq = gsl_vector_get( point, info->freq_dim );
977 const double f1dot = gsl_vector_get( point, info->f1dot_dim );
978
979 // Return second spindown bounds
980 return info->scale * f1dot * f1dot / freq;
981
982}
983
985 LatticeTiling *tiling,
986 const size_t freq_dimension,
987 const size_t f1dot_dimension,
988 const size_t f2dot_dimension,
989 const double min_braking,
990 const double max_braking
991)
992{
993
994 // Check input
995 XLAL_CHECK( tiling != NULL, XLAL_EFAULT );
996 XLAL_CHECK( freq_dimension < f1dot_dimension, XLAL_EINVAL );
997 XLAL_CHECK( f1dot_dimension < f2dot_dimension, XLAL_EINVAL );
998 XLAL_CHECK( min_braking > 0.0, XLAL_EINVAL );
999 XLAL_CHECK( max_braking > 0.0, XLAL_EINVAL );
1000 XLAL_CHECK( min_braking <= max_braking, XLAL_EINVAL );
1001
1002 // Set the parameter-space bound
1005 info_lower.freq_dim = info_upper.freq_dim = freq_dimension;
1006 info_lower.f1dot_dim = info_upper.f1dot_dim = f1dot_dimension;
1007 info_lower.scale = min_braking;
1008 info_upper.scale = max_braking;
1009 XLAL_CHECK( XLALSetLatticeTilingBound( tiling, f2dot_dimension, F2DotBrakingBound, sizeof( info_lower ), &info_lower, &info_upper ) == XLAL_SUCCESS, XLAL_EFAILED );
1010
1011 return XLAL_SUCCESS;
1012
1013}
1014
1016 DopplerFullScanState *scan,
1017 const size_t dim
1018)
1019{
1020
1021 return XLALLatticeTilingStepSize( scan->spindownTiling, dim );
1022
1023}
const REAL8 eps
static double F2DotBrakingBound(const void *data, const size_t dim UNUSED, const gsl_matrix *cache UNUSED, const gsl_vector *point)
int nextPointInFactoredGrid(PulsarDopplerParams *pos, DopplerFullScanState *scan)
return current grid-point and step forward one template in 'factored' grids (sky x f0dot x f1dot ....
int XLALInitFactoredGrid(DopplerFullScanState *scan, const DopplerFullScanInit *init)
Initialize Doppler-scanner to emulate an old-style factored template grid: 'sky x f0dot x f1dot x f2d...
void XLALDestroyDopplerFullScan(DopplerFullScanState *scan)
Destroy the a full DopplerFullScanState structure.
REAL8 XLALNumDopplerTemplates(DopplerFullScanState *scan)
Return (and compute if not done so yet) the total number of Doppler templates of the DopplerScan scan...
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.
UINT8 XLALNumDopplerPointsAtDimension(DopplerFullScanState *scan, const size_t dim)
Compute and return the total number of frequency and spindown points up to and along a certain dimens...
static REAL8VectorList * XLALREAL8VectorListAddEntry(REAL8VectorList *head, const REAL8Vector *entry)
DopplerFullScanState * XLALInitDopplerFullScan(const DopplerFullScanInit *init)
Set up a full multi-dimensional grid-scan.
static void XLALREAL8VectorListDestroy(REAL8VectorList *head)
void InitDopplerFullScan(LALStatus *status, DopplerFullScanState **scan, const DopplerFullScanInit *init)
int XLALGetDopplerSpinRange(PulsarSpinRange *spinRange, const DopplerFullScanState *scan)
Return the spin-range spanned by the given template bank stored in the opaque DopplerFullScanState.
int XLALLoadFullGridFile(DopplerFullScanState *scan, const DopplerFullScanInit *init)
load a full multi-dim template grid from the file init->gridFile, the file-format is: lines of 6 colu...
REAL8 XLALGetDopplerLatticeTilingStepSize(DopplerFullScanState *scan, const size_t dim)
Return the step size of the spindown lattice tiling in a given dimension, or 0 for non-tiled dimensio...
int XLALNextDopplerPos(PulsarDopplerParams *pos, DopplerFullScanState *scan)
Function to step through the full template grid point by point.
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.
static double F1DotAgeBrakingBound(const void *data, const size_t dim UNUSED, const gsl_matrix *cache UNUSED, const gsl_vector *point)
int XLALParseSkyRegionString(SkyRegion *region, const CHAR *input)
parse a skyRegion-string into a SkyRegion structure: the expected string-format is " (longitude1,...
Definition: DopplerScan.c:1203
CHAR * XLALSkySquare2String(REAL8 Alpha, REAL8 Delta, REAL8 AlphaBand, REAL8 DeltaBand)
parse a 'classical' sky-square (Alpha, Delta, AlphaBand, DeltaBand) into a "SkyRegion"-string of the ...
Definition: DopplerScan.c:1295
int XLALInitDopplerSkyScan(DopplerSkyScanState *skyScan, const DopplerSkyScanInit *init)
Initialize the Doppler sky-scanner.
Definition: DopplerScan.c:170
void XLALDestroyDopplerSkyScan(DopplerSkyScanState *skyScan)
Destroy the DopplerSkyScanState structure.
Definition: DopplerScan.c:294
#define DOPPLERSCANH_MSGENONULL
Definition: DopplerScan.h:71
#define DOPPLERSCANH_ENONULL
Definition: DopplerScan.h:55
#define DOPPLERSCANH_MSGEXLAL
Definition: DopplerScan.h:76
#define DOPPLERSCANH_EINPUT
Definition: DopplerScan.h:58
#define DOPPLERSCANH_MSGEINPUT
Definition: DopplerScan.h:74
#define DOPPLERSCANH_EXLAL
Definition: DopplerScan.h:60
@ STATE_READY
initialized and ready
Definition: DopplerScan.h:83
@ STATE_FINISHED
all templates have been read
Definition: DopplerScan.h:84
@ STATE_IDLE
not initialized yet
Definition: DopplerScan.h:82
DopplerGridType
different types of grids:
Definition: DopplerScan.h:89
@ GRID_METRIC
generate grid using a 2D sky-metric
Definition: DopplerScan.h:93
@ GRID_SPINDOWN_SQUARE
spindown tiling for a single sky position and square parameter space
Definition: DopplerScan.h:100
@ GRID_FLAT
"flat" sky-grid: fixed step-size (dAlpha,dDelta)
Definition: DopplerScan.h:91
@ GRID_FILE_SKYGRID
read skygrid from a file
Definition: DopplerScan.h:94
@ GRID_FILE_FULLGRID
load the full D-dim grid from a file
Definition: DopplerScan.h:98
@ GRID_METRIC_SKYFILE
'hybrid' grid-construction: use skygrid from file, metric for others
Definition: DopplerScan.h:95
@ GRID_ISOTROPIC
approximately isotropic sky-grid
Definition: DopplerScan.h:92
@ GRID_SPINDOWN_AGEBRK
spindown tiling for a single sky position and non-square parameter space defined by spindown age and ...
Definition: DopplerScan.h:101
ProcessParamsTable * ptr
#define LALCalloc(m, n)
#define LALFree(p)
#define ABORT(statusptr, code, mesg)
#define ASSERT(assertion, statusptr, code, mesg)
#define INITSTATUS(statusptr)
#define RETURN(statusptr)
#define LAL_REAL4_MAX
#define LAL_REAL8_EPS
#define XLAL_INIT_MEM(x)
uint64_t UINT8
double REAL8
#define XLAL_INIT_DECL(var,...)
int16_t INT2
char CHAR
uint32_t UINT4
void XLALFree(void *p)
#define LAL_REAL8_FORMAT
#define LAL_INT8_FORMAT
int XLALSetLatticeTilingBound(LatticeTiling *tiling, const size_t dim, const LatticeTilingBound func, const size_t data_len, const void *data_lower, const void *data_upper)
Set a parameter-space bound on a dimension of the lattice tiling.
UINT8 XLALTotalLatticeTilingPoints(const LatticeTilingIterator *itr)
Return the total number of points covered by the lattice tiling iterator.
UINT8 XLALLatticeTilingPointsAtDimension(const LatticeTilingIterator *itr, const size_t dim)
Return the total number of points along a certain dimension 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...
REAL8 XLALLatticeTilingStepSize(const LatticeTiling *tiling, const size_t dim)
Return the step size of the lattice tiling in a given dimension, or 0 for non-tiled dimensions.
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.
int XLALNextLatticeTilingPoint(LatticeTilingIterator *itr, gsl_vector *point)
Advance lattice tiling iterator, and optionally return the next point in point.
LatticeTiling * XLALCreateLatticeTiling(const size_t ndim)
Create a new lattice tiling.
int XLALSetLatticeTilingPadding(LatticeTiling *tiling, const size_t dim, const double lower_bbox_pad, const double upper_bbox_pad, const int lower_intp_pad, const int upper_intp_pad, const int find_bound_extrema)
Control the padding of lattice tiling parameter-space bounds in the given dimension.
@ TILING_LATTICE_ANSTAR
An-star ( ) lattice.
Definition: LatticeTiling.h:65
void void LogPrintfVerbatim(LogLevel_t, const char *format,...) _LAL_GCC_PRINTF_FORMAT_(2
void LogPrintf(LogLevel_t, const char *format,...) _LAL_GCC_PRINTF_FORMAT_(2
LOG_DEBUG
LOG_NORMAL
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
REAL8 PulsarSpins[PULSAR_MAX_SPINS]
Typedef for fixed-size array holding GW frequency and derivatives fk = d^k Freq/dt^k|(tau_ref)
#define PULSAR_MAX_SPINS
maximal number of spin-parameters (Freq + spindowns) we can handle
void XLALNormalizeSkyPosition(double *restrict longitude, double *restrict latitude)
COORDINATESYSTEM_EQUATORIAL
REAL8Vector * XLALCreateREAL8Vector(UINT4 length)
void XLALDestroyREAL8Vector(REAL8Vector *vector)
#define XLAL_ERROR_NULL(...)
#define xlalErrno
int int int XLALPrintInfo(const char *fmt,...) _LAL_GCC_PRINTF_FORMAT_(1
#define XLAL_ERROR(...)
#define XLAL_CHECK(assertion,...)
int XLALPrintError(const char *fmt,...) _LAL_GCC_PRINTF_FORMAT_(1
#define XLAL_CHECK_NULL(assertion,...)
#define XLAL_PRINT_DEPRECATION_WARNING(replacement)
XLAL_ENOMEM
XLAL_SUCCESS
XLAL_EFAULT
XLAL_EFUNC
XLAL_EIO
XLAL_ESYS
XLAL_EINVAL
XLAL_EFAILED
int XLALGPSCmp(const LIGOTimeGPS *t0, const LIGOTimeGPS *t1)
REAL8 XLALGPSGetREAL8(const LIGOTimeGPS *epoch)
REAL8 XLALGPSDiff(const LIGOTimeGPS *t1, const LIGOTimeGPS *t0)
float data[BLOCKSIZE]
Definition: hwinject.c:360
head
pos
n
Structure describing a region in paramter-space (a,d,f,f1dot,..).
LALPulsarMetricType metricType
which metric to use if GRID_METRIC
const CHAR * gridFile
filename for sky-grid or full-grid if GRID_FILE_SKYGRID or GRID_FILE_FULLGRID
REAL8 metricMismatch
for GRID_METRIC and GRID_ISOTROPIC
REAL8 extraArgs[3]
extra grid-specific setup arguments
const LALDetector * Detector
Current detector.
LIGOTimeGPS startTime
start-time of the observation
REAL8 Tspan
total time spanned by observation
DopplerRegion searchRegion
Doppler-space region to be covered + scanned.
BOOLEAN projectMetric
project metric on f=const subspace
PulsarDopplerParams stepSizes
user-settings for stepsizes if GRID_FLAT
const EphemerisData * ephemeris
ephemeris-data for numerical metrics
DopplerGridType gridType
which type of grid to generate
PulsarSpins fkdotBand
spin-intervals
Definition: DopplerScan.h:119
CHAR * skyRegionString
sky-region string '(a1,d1), (a2,d2), ..'
Definition: DopplerScan.h:116
LIGOTimeGPS refTime
Definition: DopplerScan.h:117
PulsarSpins fkdot
reference time of definition of Doppler parameters
Definition: DopplerScan.h:118
struct tagDopplerSkyGrid * next
Definition: DopplerScan.h:127
initialization-structure passed to InitDopplerSkyScan()
Definition: DopplerScan.h:134
this structure reflects the current state of a DopplerSkyScan
Definition: DopplerScan.h:152
UINT4 numSkyGridPoints
how many skygrid-points
Definition: DopplerScan.h:155
PulsarSpins dfkdot
fixed-size steps in spins
Definition: DopplerScan.h:156
DopplerSkyGrid * skyNode
pointer to current grid-node in skygrid
Definition: DopplerScan.h:158
scan_state_t state
idle, ready or finished
Definition: DopplerScan.h:153
Type containing the 'Doppler-parameters' affecting the time-evolution of the phase.
PulsarSpins fkdot
Intrinsic spins: [Freq, f1dot, f2dot, ... ] where fkdot = d^kFreq/dt^k.
REAL8 Delta
Sky position: DEC (latitude) in equatorial coords and radians.
LIGOTimeGPS refTime
Reference time of pulsar parameters (in SSB!)
REAL8 Alpha
Sky position: RA (longitude) in equatorial coords and radians.
Contains a "spin-range", ie spins and corresponding bands at a given (SSB) reference GPS-time .
REAL8 * data
doubly linked list of REAL8-vectors (physical vectors)
REAL8Vector entry
struct tagREAL8VectorList * next
struct tagREAL8VectorList * prev
REAL8 longitude
REAL8 latitude
CoordinateSystem system
structure describing a polygon-region in the sky
Definition: DopplerScan.h:108
PulsarDopplerParams thisPoint
current doppler-position of the scan
DopplerSkyScanState skyScan
keep track of sky-grid stepping
--— internal [opaque] type to store the state of a FULL multidimensional grid-scan --—
REAL8VectorList * covering
multi-dimensional covering
SkyRegion skyRegion
sky-range covered by template bank
factoredGridScan_t * factoredScan
only used to emulate FACTORED grids sky x Freq x f1dot
REAL8VectorList * thisGridPoint
pointer to current grid-point
INT2 state
idle, ready or finished
LatticeTiling * spindownTiling
spindown lattice tiling
DopplerGridType gridType
what type of grid are we dealing with
PulsarSpinRange spinRange
spin-range covered by template bank
REAL8 numTemplates
total number of templates in the grid
LatticeTilingIterator * spindownTilingItr
iterator over spindown lattice tiling
gsl_vector * spindownTilingPoint
current point in spindown lattice tiling