LALPulsar 7.1.1.1-eeff03c
HierarchicalSearch.c
Go to the documentation of this file.
1/*
2 * Copyright (C) 2013 Karl Wette
3 * Copyright (C) 2005 Badri Krishnan, Alicia Sintes, Reinhard Prix, Bernd Machenschalk
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; withoulistt 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 * \defgroup lalpulsar_bin_HoughFstat Hough-on-Fstatistic Search Application
23 * \ingroup lalpulsar_bin_Apps
24 */
25
26/**
27 * \author Badri Krishnan, Alicia Sintes, Reinhard Prix, Bernd Machenschalk
28 * \file
29 * \ingroup lalpulsar_bin_HoughFstat
30 * \brief Program for calculating F-stat values for different time segments
31 * and combining them semi-coherently using the Hough transform, and following
32 * up candidates using a longer coherent integration.
33 *
34 * \par Description
35 *
36 * This code implements a hierarchical strategy to look for unknown gravitational
37 * wave pulsars. It scans through the parameter space using a less sensitive but
38 * computationally inexpensive search and follows up the candidates using
39 * more sensitive methods.
40 *
41 * \par Algorithm
42 *
43 * Currently the code does a single stage hierarchical search using the Hough
44 * algorithm and follows up the candidates using a full coherent integration.
45 *
46 * - The user specifies a directory containing SFTs, and the number of
47 * \e stacks that this must be broken up into. Stacks are chosen by
48 * breaking up the total time spanned by the sfts into equal
49 * portions, and then choosing the sfts which lie in each stack
50 * portion. The SFTs can be from multiple IFOs.
51 *
52 * - The user specifies a region in parameter space to search over.
53 * The code sets up a grid (the "coarse" grid) in this region and
54 * calculates the F-statistic for each stack at each point of the
55 * coarse grid, for the entire frequency band. Alternatively, the
56 * user can specify a sky-grid file.
57 *
58 * - The different Fstat vactors for each stack are combined using a
59 * semi-coherent method such as the Hough transform or stack slide
60 * algorithms.
61 *
62 * - For Hough, a threshold is set on the F-statistic to convert the
63 * F-statistic vector into a vector of 0s and 1s known as a \e
64 * peakgram -- there is one peakgram for each stack and for each
65 * grid point. These peakgrams are combined using the Hough algorithm.
66 *
67 * - For stack-slide, we add the different Fstatistic values to get
68 * the summed Fstatistic power.
69 *
70 * - The semi-coherent part of the search constructs a grid (the
71 * "fine" grid) in a small patch around every coarse grid point, and
72 * combines the different stacks following the \e master equation
73 * \f[ f(t) - F_0(t) = \xi(t).(\hat{n} - \hat{n}_0) \f]
74 * where
75 * \f[ F_0 = f_0 + \sum \Delta f_k \frac{(\Delta t)^k}{k!} \f]
76 * Here \f$ \hat{n}_0 \f$ is the sky-point at which the F-statistic is
77 * calculated and \f$ \Delta f_k \f$ is the \e residual spindown
78 * parameter. For details see Phys.Rev.D 70, 082001 (2004). The
79 * size of the patch depends on the validity of the above master
80 * equation.
81 *
82 * - The output of the Hough search is a \e number \e count at each point
83 * of the grid. A threshold is set on the number count, leading to
84 * candidates in parameter space. For stack slide, instead of the
85 * number count, we get the summed Fstatistic power. Alternatively,
86 * the user can specify exactly how many candidates should be
87 * followed up for each coarse grid point.
88 *
89 * - These candidates are followed up using a second set of SFTs (also
90 * specified by the user). The follow up consists of a full
91 * coherent integration, i.e. the F-statistic is calculated for the
92 * whole set of SFTs without breaking them up into stacks. The user
93 * can choose to output the N highest significance candidates.
94 *
95 * \par Questions/To-do
96 *
97 * - Should we over-resolve the Fstat calculation to reduce loss in signal power? We would
98 * still calculate the peakgrams at the 1/T resolution, but the peak selection would
99 * take into account Fstat values over several over-resolved bins.
100 *
101 * - What is the best grid for calculating the F-statistic? At first glance, the
102 * Hough patch and the metric F-statistic patch do not seem to be compatible. If we
103 * use the Hough patches to break up the sky, it could be far from optimal. What is
104 * the exact connection between the two grids?
105 *
106 * - Implement multiple semi-coherent stages
107 *
108 * - Get timings and optimize the pipeline parameters
109 *
110 * - Checkpointing for running on Einstein\@Home
111 *
112 * - Incorporate stack slide as an alternative to Hough in the semi-coherent stages
113 *
114 * - ....
115 *
116 */
117
118#include <lal/LALString.h>
119#include "HierarchicalSearch.h"
120
121/* This need to go here after HierarchicalSearch.h is included;
122 StackSlideFstat.h needs SemiCohCandidateList defined. */
123#include "StackSlideFstat.h"
124
125#define TRUE (1==1)
126#define FALSE (1==0)
127
128/* checkpointing (non-functional placeholders for non-BOINC case) */
129#define HS_CHECKPOINTING 0 /* no checkpointing in the non-BOINC case (yet) */
130#define GET_CHECKPOINT(toplist,total,count,outputname,cptname) *total=0;
131#define INSERT_INTO_HOUGHFSTAT_TOPLIST insert_into_houghFstat_toplist
132#define SHOW_PROGRESS(rac,dec,tpl_count,tpl_total,freq,fband)
133#define SET_CHECKPOINT
134#define MAIN main
135
136/* These might have been set differently in ComputeFstatREAL4.h */
137#ifndef COMPUTEFSTATHOUGHMAP
138#define COMPUTEFSTATHOUGHMAP ComputeFstatHoughMap
139#endif
140#ifndef GPUREADY_DEFAULT
141#define GPUREADY_DEFAULT 0
142#endif
143#ifndef REARRANGE_SFT_DATA
144#define REARRANGE_SFT_DATA
145#endif
146#ifndef INITIALIZE_COPROCESSOR_DEVICE
147#define INITIALIZE_COPROCESSOR_DEVICE
148#endif
149#ifndef UNINITIALIZE_COPROCESSOR_DEVICE
150#define UNINITIALIZE_COPROCESSOR_DEVICE
151#endif
152
153#if USE_OPENCL_KERNEL || defined(USE_CUDA)
154extern int gpu_device_id;
155#else
157#endif
158
159
160BOOLEAN uvar_printMaps = FALSE; /**< global variable for printing Hough maps */
161BOOLEAN uvar_printGrid = FALSE; /**< global variable for printing Hough grid */
162BOOLEAN uvar_printStats = FALSE;/**< global variable for calculating Hough map stats */
163BOOLEAN uvar_dumpLUT = FALSE; /**< global variable for printing Hough look-up-tables for debugging */
165
166#define HSMAX(x,y) ( (x) > (y) ? (x) : (y) )
167#define HSMIN(x,y) ( (x) < (y) ? (x) : (y) )
168
169#define BLOCKSIZE_REALLOC 50
170
171/** Useful stuff for a single stage of the Hierarchical search */
172typedef struct {
173 CHAR *sftbasename; /**< filename pattern for sfts */
174 REAL8 tStack; /**< duration of stacks */
175 UINT4 nStacks; /**< number of stacks */
176 LIGOTimeGPS tStartGPS; /**< start and end time of stack */
177 REAL8 tObs; /**< tEndGPS - tStartGPS */
178 REAL8 refTime; /**< reference time for pulsar params */
179 PulsarSpinRange spinRange_startTime; /**< freq and fdot range at start-time of observation */
180 PulsarSpinRange spinRange_endTime; /**< freq and fdot range at end-time of observation */
181 PulsarSpinRange spinRange_refTime; /**< freq and fdot range at the reference time */
182 PulsarSpinRange spinRange_midTime; /**< freq and fdot range at mid-time of observation */
183 EphemerisData *edat; /**< ephemeris data for XLALBarycenter */
184 LIGOTimeGPSVector *midTstack; /**< timestamps vector for mid time of each stack */
185 LIGOTimeGPSVector *startTstack; /**< timestamps vector for start time of each stack */
186 LIGOTimeGPS minStartTimeGPS; /**< Only use SFTs with timestamps starting from (including) this GPS time */
187 LIGOTimeGPS maxStartTimeGPS; /**< Only use SFTs with timestamps up to (excluding) this GPS time */
188 UINT4 blocksRngMed; /**< blocksize for running median noise floor estimation */
189 UINT4 Dterms; /**< size of Dirichlet kernel for Fstat calculation */
190 REAL8 dopplerMax; /**< extra sft wings for doppler motion */
191 int SSBprec; /**< SSB transform precision */
192 REAL8 dFreqStack; /**< frequency resolution of Fstat calculation */
194
195
196static int smallerHough(const void *a,const void *b) {
198 a1 = *((const SemiCohCandidate *)a);
199 b1 = *((const SemiCohCandidate *)b);
200
201 if( a1.significance < b1.significance )
202 return(1);
203 else if( a1.significance > b1.significance)
204 return(-1);
205 else
206 return(0);
207}
208
209/* functions for printing various stuff */
211
213
215 FstatInputVector* Fstat_in_vec );
216
217
218void SetUpSFTs( LALStatus *status, FstatInputVector** p_Fstat_in_vec, UsefulStageVariables *in );
219
221 LIGOTimeGPS refTime, INT4 stackIndex);
222
223void PrintHoughGrid(LALStatus *status, HOUGHPatchGrid *patch, HOUGHDemodPar *parDem, CHAR *fnameOut, INT4 iHmap);
224
226
227void PrintHoughHistogram(LALStatus *status, UINT8Vector *hist, CHAR *fnameOut);
228
229void PrintCatalogInfo( LALStatus *status, const SFTCatalog *catalog, FILE *fp);
230
231void PrintStackInfo( LALStatus *status, const SFTCatalogSequence *catalogSeq, FILE *fp);
232
234
236
237void DumpLUT2file(LALStatus *status, HOUGHptfLUT *lut, HOUGHPatchGrid *patch, CHAR *basename, INT4 ind);
238
239void ValidateHoughLUT(LALStatus *status, HOUGHptfLUT *lut, HOUGHPatchGrid *patch, CHAR *basename, INT4 ind, REAL4 alpha, REAL4 delta, REAL4 weight);
240
242 HOUGHSizePar *size,
244
245/* default values for input variables */
246#define FSTART 310.0 /**< Default Start search frequency */
247
248#define FBAND 0.01 /**< Default search band */
249#define FDOT 0.0 /**< Default value of first spindown */
250#define DFDOT 0.0 /**< Default range of first spindown parameter */
251#define SKYREGION "allsky" /**< default sky region to search over -- just a single point*/
252#define NFDOT 10 /**< Default size of hough cylinder of look up tables */
253#define MISMATCH 0.2 /**< Default for metric grid maximal mismatch value */
254#define DALPHA 0.001 /**< Default resolution for isotropic or flat grids */
255#define DDELTA 0.001 /**< Default resolution for isotropic or flat grids */
256#define FSTATTHRESHOLD 2.6 /**< Default threshold on Fstatistic for peak selection */
257#define NCAND1 5 /**< Default number of candidates to be followed up from first stage */
258#define FNAMEOUT "./out/HS.dat" /**< Default output file basename */
259#define PIXELFACTOR 2.0
260#ifndef LAL_INT4_MAX
261#define LAL_INT4_MAX 2147483647
262#endif
263
264/* a global pointer to MAIN()s head of the LALStatus structure,
265 made global so a signal handler can read it */
267
269
270#ifdef OUTPUT_TIMING
271time_t clock0;
272UINT4 nSFTs;
273UINT4 nStacks;
274UINT4 nSkyRefine;
275#endif
276
277
278int MAIN( int argc, char *argv[]) {
279
281
282 /* temp loop variables: generally k loops over stacks */
283 UINT4 k;
284 UINT4 skyGridCounter;
285
286 /* in general any variable ending with 1 is for the
287 first stage, 2 for the second and so on */
288
289 /* timestamp vectors */
290 LIGOTimeGPSVector *midTstack=NULL;
291 LIGOTimeGPSVector *startTstack=NULL;
292
293
294 LIGOTimeGPS XLAL_INIT_DECL(refTimeGPS);
296 REAL8 tObs;
297
298 /* velocities and positions at midTstack */
299 REAL8VectorSequence *velStack=NULL;
300 REAL8VectorSequence *posStack=NULL;
301
302 /* weights for each stack*/
303 REAL8Vector *weightsV=NULL;
304 REAL8Vector *weightsNoise=NULL;
305
306 /* duration of each stack */
307 REAL8 tStack;
308
309 /* sft related stuff */
310 static LIGOTimeGPS minStartTimeGPS, maxStartTimeGPS;
311
312
313 /* some useful variables for each stage */
314 UsefulStageVariables usefulParams;
315
316 /* number of stacks -- not necessarily same as uvar_nStacks! */
317 UINT4 nStacks;
318 REAL8 df1dot, df1dotRes; /* coarse grid resolution in spindown */
319 UINT4 nf1dot, nf1dotRes; /* coarse and fine grid number of spindown values */
320
321 /* F-statistic computation related stuff */
322 static REAL4FrequencySeriesVector fstatVector; /* Fstatistic vectors for each stack */
323 FstatInputVector* Fstat_in_vec = NULL; // Vector of Fstat input data structures for XLALComputeFstat(), one per stack
324 FstatResults* Fstat_res = NULL; // Pointer to Fstat results structure, will be allocated by XLALComputeFstat()
325 FstatQuantities Fstat_what = FSTATQ_2F; // Quantities to be computed by XLALComputeFstat()
326 UINT4 binsFstat1, binsFstatSearch;
327
328 /* hough variables */
329 static HOUGHPeakGramVector pgV;
330 static SemiCoherentParams semiCohPar;
331 static SemiCohCandidateList semiCohCandList;
332 REAL8 alphaPeak, sumWeightSquare, meanN=0, sigmaN=0;
333
334 /* fstat candidate structure */
335 toplist_t *semiCohToplist=NULL;
336
337 /* template and grid variables */
338 static DopplerSkyScanInit scanInit; /* init-structure for DopperScanner */
340 static PulsarDopplerParams dopplerpos; /* current search-parameters */
341 static PulsarDopplerParams thisPoint;
342
343 /* temporary storage for spinrange vector */
344 static PulsarSpinRange spinRange_Temp;
345
346 /* variables for logging */
347 CHAR *fnamelog=NULL;
348 FILE *fpLog=NULL;
349 CHAR *logstr=NULL;
350
351 /* output candidate files and file pointers */
352 CHAR *fnameSemiCohCand=NULL;
353 CHAR *fnameFstatVec1=NULL;
354 FILE *fpSemiCoh=NULL;
355 FILE *fpFstat1=NULL;
356
357 /* checkpoint filename and index of loop over skypoints */
358 /* const CHAR *fnameChkPoint="checkpoint.cpt"; */
359 /* FILE *fpChkPoint=NULL; */
360 /* UINT4 loopindex, loopcounter; */
361
362 /* user variables */
363 BOOLEAN uvar_log = FALSE; /* logging done if true */
364
365 BOOLEAN uvar_printCand1 = FALSE; /* if 1st stage candidates are to be printed */
366 BOOLEAN uvar_printFstat1 = FALSE;
367 BOOLEAN uvar_useToplist1 = FALSE;
368 BOOLEAN uvar_useWeights = FALSE;
369 BOOLEAN uvar_semiCohToplist = FALSE; /* if overall first stage candidates are to be output */
370
371 REAL8 uvar_dAlpha = DALPHA; /* resolution for flat or isotropic grids -- coarse grid*/
373 REAL8 uvar_f1dot = FDOT; /* first spindown value */
374 REAL8 uvar_f1dotBand = DFDOT; /* range of first spindown parameter */
375 REAL8 uvar_Freq = FSTART;
376 REAL8 uvar_FreqBand = FBAND;
377
378 REAL8 uvar_dFreq = 0;
379 REAL8 uvar_df1dot = 0; /* coarse grid frequency and spindown resolution */
380
381 REAL8 uvar_peakThrF = FSTATTHRESHOLD; /* threshold of Fstat to select peaks */
382 REAL8 uvar_mismatch1 = MISMATCH; /* metric mismatch for first stage coarse grid */
383
384 REAL8 uvar_pixelFactor = PIXELFACTOR;
385 REAL8 uvar_df1dotRes = 0;
386 REAL8 uvar_threshold1 = 0;
387 REAL8 uvar_minStartTime1 = 0;
388 REAL8 uvar_maxStartTime1 = LAL_INT4_MAX;
389 REAL8 uvar_dopplerMax = 1.05e-4;
390
392 REAL8 uvar_semiCohPatchX = 0;
393 REAL8 uvar_semiCohPatchY = 0;
394 REAL8 uvar_tStack = 0;
395
396 INT4 uvar_method = -1; /* hough = 0, stackslide = 1, -1 = pure fstat*/
397 INT4 uvar_nCand1 = NCAND1; /* number of candidates to be followed up from first stage */
398
400 INT4 uvar_nStacksMax = 1;
402 INT4 uvar_SSBprecision = FstatOptionalArgsDefaults.SSBprec;
403 INT4 uvar_nf1dotRes = 1;
404 INT4 uvar_metricType1 = LAL_PMETRIC_COH_PTOLE_ANALYTIC;
405 INT4 uvar_gridType1 = GRID_METRIC;
406 INT4 uvar_skyPointIndex = -1;
407
408 CHAR *uvar_ephemEarth = NULL;
409 CHAR *uvar_ephemSun = NULL;
410
411 CHAR *uvar_skyRegion = NULL;
412 CHAR *uvar_fnameout = NULL;
413 CHAR *uvar_DataFiles1 = NULL;
414 CHAR *uvar_skyGridFile=NULL;
415 INT4 uvar_numSkyPartitions = 0;
416 INT4 uvar_partitionIndex = 0;
417
418 BOOLEAN uvar_correctFreqs = TRUE;
419
420 INT4 uvar_gpu_device = -1;
422
423#ifdef EAH_LALDEBUGLEVEL
424#endif
425 uvar_ephemEarth = XLALStringDuplicate("earth00-40-DE405.dat.gz");
426 uvar_ephemSun = XLALStringDuplicate("sun00-40-DE405.dat.gz");
427
428 uvar_skyRegion = LALCalloc( alloc_len = strlen(SKYREGION) + 1, sizeof(CHAR) );
429 XLAL_CHECK ( uvar_skyRegion != NULL, XLAL_ENOMEM, "Failed to allocated memory LALCalloc(1, %d)\n", alloc_len );
430 strcpy(uvar_skyRegion, SKYREGION);
431
432 uvar_fnameout = LALCalloc( alloc_len = strlen(FNAMEOUT) + 1, sizeof(CHAR) );
433 XLAL_CHECK ( uvar_fnameout != NULL, XLAL_ENOMEM, "Failed to allocated memory LALCalloc(1, %d)\n", alloc_len );
434 strcpy(uvar_fnameout, FNAMEOUT);
435
436 /* set LAL error-handler */
438
439 /* register user input variables */
440 XLAL_CHECK_MAIN( XLALRegisterNamedUvar( &uvar_log, "log", BOOLEAN, 0, OPTIONAL, "Write log file") == XLAL_SUCCESS, XLAL_EFUNC);
441 XLAL_CHECK_MAIN( XLALRegisterNamedUvar( &uvar_method, "method", INT4, 0, OPTIONAL, "0=Hough, 1=stackslide, -1=fstat" ) == XLAL_SUCCESS, XLAL_EFUNC);
442 XLAL_CHECK_MAIN( XLALRegisterNamedUvar( &uvar_semiCohToplist, "semiCohToplist", BOOLEAN, 0, OPTIONAL, "Print semicoh toplist?" ) == XLAL_SUCCESS, XLAL_EFUNC);
443 XLAL_CHECK_MAIN( XLALRegisterNamedUvar( &uvar_useWeights, "useWeights", BOOLEAN, 0, OPTIONAL, "Weight each stack using noise and AM?" ) == XLAL_SUCCESS, XLAL_EFUNC);
444 XLAL_CHECK_MAIN( XLALRegisterNamedUvar( &uvar_DataFiles1, "DataFiles1", STRING, 0, REQUIRED, "1st SFT file pattern. Possibilities are:\n"
445 " - '<SFT file>;<SFT file>;...', where <SFT file> may contain wildcards\n - 'list:<file containing list of SFT files>'") == XLAL_SUCCESS, XLAL_EFUNC);
446 XLAL_CHECK_MAIN( XLALRegisterNamedUvar( &uvar_skyRegion, "skyRegion", STRING, 0, OPTIONAL, "Sky-region by polygon of form '(ra1,dec1),(ra2,dec2),(ra3,dec3),...' or 'allsky'") == XLAL_SUCCESS, XLAL_EFUNC);
447 XLAL_CHECK_MAIN( XLALRegisterNamedUvar( &uvar_numSkyPartitions, "numSkyPartitions",INT4, 0, OPTIONAL, "Number of (equi-)partitions to split skygrid into") == XLAL_SUCCESS, XLAL_EFUNC);
448 XLAL_CHECK_MAIN( XLALRegisterNamedUvar( &uvar_partitionIndex, "partitionIndex", INT4, 0, OPTIONAL, "Index [0,numSkyPartitions-1] of sky-partition to generate") == XLAL_SUCCESS, XLAL_EFUNC);
449
450 XLAL_CHECK_MAIN( XLALRegisterNamedUvar( &uvar_Freq, "Freq", REAL8, 'f', OPTIONAL, "Start search frequency") == XLAL_SUCCESS, XLAL_EFUNC);
451 XLAL_CHECK_MAIN( XLALRegisterNamedUvar( &uvar_dFreq, "dFreq", REAL8, 0, OPTIONAL, "Frequency resolution (default=1/Tstack)") == XLAL_SUCCESS, XLAL_EFUNC);
452 XLAL_CHECK_MAIN( XLALRegisterNamedUvar( &uvar_FreqBand, "FreqBand", REAL8, 'b', OPTIONAL, "Search frequency band") == XLAL_SUCCESS, XLAL_EFUNC);
453 XLAL_CHECK_MAIN( XLALRegisterNamedUvar( &uvar_f1dot, "f1dot", REAL8, 0, OPTIONAL, "Spindown parameter") == XLAL_SUCCESS, XLAL_EFUNC);
454 XLAL_CHECK_MAIN( XLALRegisterNamedUvar( &uvar_df1dot, "df1dot", REAL8, 0, OPTIONAL, "Spindown resolution (default=1/Tstack^2)") == XLAL_SUCCESS, XLAL_EFUNC);
455 XLAL_CHECK_MAIN( XLALRegisterNamedUvar( &uvar_f1dotBand, "f1dotBand", REAL8, 0, OPTIONAL, "Spindown Range") == XLAL_SUCCESS, XLAL_EFUNC);
456 XLAL_CHECK_MAIN( XLALRegisterNamedUvar( &uvar_nf1dotRes, "nf1dotRes", INT4, 0, OPTIONAL, "No.of residual fdot values (default=nStacks)") == XLAL_SUCCESS, XLAL_EFUNC);
457 XLAL_CHECK_MAIN( XLALRegisterNamedUvar( &uvar_nStacksMax, "nStacksMax", INT4, 0, OPTIONAL, "Maximum No. of 1st stage stacks" ) == XLAL_SUCCESS, XLAL_EFUNC);
458 XLAL_CHECK_MAIN( XLALRegisterNamedUvar( &uvar_tStack, "tStack", REAL8, 0, REQUIRED, "Duration of 1st stage stacks (sec)" ) == XLAL_SUCCESS, XLAL_EFUNC);
459 XLAL_CHECK_MAIN( XLALRegisterNamedUvar( &uvar_mismatch1, "mismatch1", REAL8, 0, OPTIONAL, "1st stage mismatch") == XLAL_SUCCESS, XLAL_EFUNC);
460 XLAL_CHECK_MAIN( XLALRegisterNamedUvar( &uvar_gridType1, "gridType1", INT4, 0, OPTIONAL, "0=flat, 1=isotropic, 2=metric, 3=file") == XLAL_SUCCESS, XLAL_EFUNC);
461 XLAL_CHECK_MAIN( XLALRegisterNamedUvar( &uvar_metricType1, "metricType1", INT4, 0, OPTIONAL, "0=none, 1=Ptole-analytic, 2=Ptole-numeric, 3=exact") == XLAL_SUCCESS, XLAL_EFUNC);
462 XLAL_CHECK_MAIN( XLALRegisterNamedUvar( &uvar_skyGridFile, "skyGridFile", STRING, 0, OPTIONAL, "sky-grid file") == XLAL_SUCCESS, XLAL_EFUNC);
463 XLAL_CHECK_MAIN( XLALRegisterNamedUvar( &uvar_dAlpha, "dAlpha", REAL8, 0, OPTIONAL, "Resolution for flat or isotropic coarse grid") == XLAL_SUCCESS, XLAL_EFUNC);
464 XLAL_CHECK_MAIN( XLALRegisterNamedUvar( &uvar_dDelta, "dDelta", REAL8, 0, OPTIONAL, "Resolution for flat or isotropic coarse grid") == XLAL_SUCCESS, XLAL_EFUNC);
465 XLAL_CHECK_MAIN( XLALRegisterNamedUvar( &uvar_pixelFactor, "pixelFactor", REAL8, 0, OPTIONAL, "Semi coh. sky resolution = 1/v*pixelFactor*f*Tcoh") == XLAL_SUCCESS, XLAL_EFUNC);
466 XLAL_CHECK_MAIN( XLALRegisterNamedUvar( &uvar_semiCohPatchX, "semiCohPatchX", REAL8, 0, OPTIONAL, "Semi coh. sky grid size (default = 1/f*Tcoh*Vepi)") == XLAL_SUCCESS, XLAL_EFUNC);
467 XLAL_CHECK_MAIN( XLALRegisterNamedUvar( &uvar_semiCohPatchY, "semiCohPatchY", REAL8, 0, OPTIONAL, "Semi coh. sky grid size (default = 1/f*Tcoh*Vepi)") == XLAL_SUCCESS, XLAL_EFUNC);
468 XLAL_CHECK_MAIN( XLALRegisterNamedUvar( &uvar_fnameout, "fnameout", STRING, 'o', OPTIONAL, "Output fileneme") == XLAL_SUCCESS, XLAL_EFUNC);
469 XLAL_CHECK_MAIN( XLALRegisterNamedUvar( &uvar_peakThrF, "peakThrF", REAL8, 0, OPTIONAL, "Fstat Threshold") == XLAL_SUCCESS, XLAL_EFUNC);
470 XLAL_CHECK_MAIN( XLALRegisterNamedUvar( &uvar_nCand1, "nCand1", INT4, 0, OPTIONAL, "No.of 1st stage candidates to be followed up") == XLAL_SUCCESS, XLAL_EFUNC);
471 XLAL_CHECK_MAIN( XLALRegisterNamedUvar( &uvar_threshold1, "threshold1", REAL8, 0, OPTIONAL, "Threshold on significance for 1st stage (if no toplist)") == XLAL_SUCCESS, XLAL_EFUNC);
472 XLAL_CHECK_MAIN( XLALRegisterNamedUvar( &uvar_printCand1, "printCand1", BOOLEAN, 0, OPTIONAL, "Print 1st stage candidates") == XLAL_SUCCESS, XLAL_EFUNC);
473 XLAL_CHECK_MAIN( XLALRegisterNamedUvar( &uvar_refTime, "refTime", REAL8, 0, OPTIONAL, "Ref. time for pulsar pars [Default: mid-time]") == XLAL_SUCCESS, XLAL_EFUNC);
474 XLAL_CHECK_MAIN( XLALRegisterNamedUvar( &uvar_ephemEarth, "ephemEarth", STRING, 0, OPTIONAL, "Location of Earth ephemeris file") == XLAL_SUCCESS, XLAL_EFUNC);
475 XLAL_CHECK_MAIN( XLALRegisterNamedUvar( &uvar_ephemSun, "ephemSun", STRING, 0, OPTIONAL, "Location of Sun ephemeris file") == XLAL_SUCCESS, XLAL_EFUNC);
476 XLAL_CHECK_MAIN( XLALRegisterNamedUvar( &uvar_minStartTime1, "minStartTime1", REAL8, 0, OPTIONAL, "1st stage: Only use SFTs with timestamps starting from (including) this GPS time") == XLAL_SUCCESS, XLAL_EFUNC);
477 XLAL_CHECK_MAIN( XLALRegisterNamedUvar( &uvar_maxStartTime1, "maxStartTime1", REAL8, 0, OPTIONAL, "1st stage: Only use SFTs with timestamps up to (excluding) this GPS time") == XLAL_SUCCESS, XLAL_EFUNC);
478 XLAL_CHECK_MAIN( XLALRegisterNamedUvar( &uvar_printFstat1, "printFstat1", BOOLEAN, 0, OPTIONAL, "Print 1st stage Fstat vectors") == XLAL_SUCCESS, XLAL_EFUNC);
479
480 /* developer user variables */
481 XLAL_CHECK_MAIN( XLALRegisterNamedUvar( &uvar_blocksRngMed, "blocksRngMed", INT4, 0, DEVELOPER, "RngMed block size") == XLAL_SUCCESS, XLAL_EFUNC);
482 XLAL_CHECK_MAIN( XLALRegisterNamedUvarAuxData( &uvar_SSBprecision, "SSBprecision", UserEnum, &SSBprecisionChoices, 0, DEVELOPER, "Precision for SSB transform") == XLAL_SUCCESS, XLAL_EFUNC);
483 XLAL_CHECK_MAIN( XLALRegisterNamedUvar( &uvar_printMaps, "printMaps", BOOLEAN, 0, DEVELOPER, "Print Hough maps -- for debugging") == XLAL_SUCCESS, XLAL_EFUNC);
484 XLAL_CHECK_MAIN( XLALRegisterNamedUvar( &uvar_printGrid, "printGrid", BOOLEAN, 0, DEVELOPER, "Print Hough fine grid -- for debugging") == XLAL_SUCCESS, XLAL_EFUNC);
485 XLAL_CHECK_MAIN( XLALRegisterNamedUvar( &uvar_dumpLUT, "dumpLUT", BOOLEAN, 0, DEVELOPER, "Print Hough look-up-tables -- for debugging") == XLAL_SUCCESS, XLAL_EFUNC);
486 XLAL_CHECK_MAIN( XLALRegisterNamedUvar( &uvar_validateLUT, "validateLUT", BOOLEAN, 0, DEVELOPER, "Validate Hough look-up-tables -- for debugging") == XLAL_SUCCESS, XLAL_EFUNC);
487 XLAL_CHECK_MAIN( XLALRegisterNamedUvar( &uvar_printStats, "printStats", BOOLEAN, 0, DEVELOPER, "Print Hough map statistics") == XLAL_SUCCESS, XLAL_EFUNC);
488 XLAL_CHECK_MAIN( XLALRegisterNamedUvar( &uvar_Dterms, "Dterms", INT4, 0, DEVELOPER, "No.of terms to keep in Dirichlet Kernel" ) == XLAL_SUCCESS, XLAL_EFUNC);
489 XLAL_CHECK_MAIN( XLALRegisterNamedUvar( &uvar_skyPointIndex, "skyPointIndex", INT4, 0, DEVELOPER, "Only analyze this skypoint in grid" ) == XLAL_SUCCESS, XLAL_EFUNC);
490 XLAL_CHECK_MAIN( XLALRegisterNamedUvar( &uvar_dopplerMax, "dopplerMax", REAL8, 0, DEVELOPER, "Max Doppler shift") == XLAL_SUCCESS, XLAL_EFUNC);
491 XLAL_CHECK_MAIN( XLALRegisterNamedUvar( &uvar_useToplist1, "useToplist1", BOOLEAN, 0, DEVELOPER, "Use toplist for 1st stage candidates?" ) == XLAL_SUCCESS, XLAL_EFUNC);
492 XLAL_CHECK_MAIN( XLALRegisterNamedUvar( &uvar_df1dotRes, "df1dotRes", REAL8, 0, DEVELOPER, "Resolution in residual fdot values (default=df1dot/nf1dotRes)") == XLAL_SUCCESS, XLAL_EFUNC);
493 XLAL_CHECK_MAIN( XLALRegisterNamedUvar( &uvar_correctFreqs, "correctFreqs", BOOLEAN, 0, DEVELOPER, "Correct candidate output frequencies (ie fix bug #147). Allows reproducing 'historical results'") == XLAL_SUCCESS, XLAL_EFUNC);
494 XLAL_CHECK_MAIN( XLALRegisterNamedUvar( &uvar_gpu_device, "device", INT4, 0, DEVELOPER, "GPU device id" ) == XLAL_SUCCESS, XLAL_EFUNC);
495
496 /* read all command line variables */
497 BOOLEAN should_exit = 0;
499 if (should_exit)
500 return(1);
501
502
503 /* assemble version string */
504 CHAR *VCSInfoString;
505 if ( (VCSInfoString = XLALVCSInfoString(lalPulsarVCSInfoList, 0, "%% ")) == NULL ) {
506 XLALPrintError("XLALVCSInfoString failed.\n");
507 return( HIERARCHICALSEARCH_EBAD );
508 }
509 LogPrintfVerbatim( LOG_DEBUG, "Code-version: %s", VCSInfoString );
510
511 if(uvar_gpu_device >= 0)
512 gpu_device_id = uvar_gpu_device;
513
514 /* some basic sanity checks on user vars */
515 if ( (uvar_method != 0) && (uvar_method != 1) && (uvar_method != -1)) {
516 fprintf(stderr, "Invalid method....must be 0, 1 or -1\n");
517 return( HIERARCHICALSEARCH_EBAD );
518 }
519
520 if ( uvar_nStacksMax < 1) {
521 fprintf(stderr, "Invalid number of stacks\n");
522 return( HIERARCHICALSEARCH_EBAD );
523 }
524
525
526 if ( uvar_blocksRngMed < 1 ) {
527 fprintf(stderr, "Invalid Running Median block size\n");
528 return( HIERARCHICALSEARCH_EBAD );
529 }
530
531 if ( uvar_peakThrF < 0 ) {
532 fprintf(stderr, "Invalid value of Fstatistic threshold\n");
533 return( HIERARCHICALSEARCH_EBAD );
534 }
535
536 /* probability of peak selection */
537 alphaPeak = (1+uvar_peakThrF)*exp(-uvar_peakThrF);
538
539 /* create toplist -- semiCohToplist has the same structure
540 as a fstat candidate, so treat it as a fstat candidate */
541 create_houghFstat_toplist(&semiCohToplist, uvar_nCand1);
542
543 /* write the log file */
544 if ( uvar_log )
545 {
546 fnamelog = LALCalloc( alloc_len = strlen(uvar_fnameout) + 1 + 4, sizeof(CHAR) );
547 XLAL_CHECK ( fnamelog != NULL, XLAL_ENOMEM, "Failed to allocated memory LALCalloc(1, %d)\n", alloc_len );
548 strcpy(fnamelog, uvar_fnameout);
549 strcat(fnamelog, ".log");
550 /* open the log file for writing */
551 if ((fpLog = fopen(fnamelog, "wb")) == NULL) {
552 fprintf(stderr, "Unable to open file %s for writing\n", fnamelog);
553 LALFree(fnamelog);
554 /*exit*/ return(HIERARCHICALSEARCH_EFILE);
555 }
556
557 /* get the log string */
559
560 fprintf( fpLog, "## Log file for HierarchicalSearch.c\n\n");
561 fprintf( fpLog, "# User Input:\n");
562 fprintf( fpLog, "#-------------------------------------------\n");
563 fprintf( fpLog, "%s", logstr);
564 LALFree(logstr);
565
566 /* add code version ID */
567 fprintf ( fpLog, "%s", VCSInfoString );
568
569 fclose (fpLog);
570
571 LALFree(fnamelog);
572
573 } /* end of logging */
574
575
576 /*--------- Some initializations ----------*/
577
578 /* initialize ephemeris info */
581
582 XLALGPSSetREAL8(&minStartTimeGPS, uvar_minStartTime1);
583 XLALGPSSetREAL8(&maxStartTimeGPS, uvar_maxStartTime1);
584
585 /* create output Hough file for writing if requested by user */
586 if ( uvar_printCand1 )
587 {
588 fnameSemiCohCand = LALCalloc( alloc_len = strlen(uvar_fnameout) + 1, sizeof(CHAR) );
589 XLAL_CHECK ( fnameSemiCohCand != NULL, XLAL_ENOMEM, "Failed to allocate memory LALCalloc ( 1, %d )\n", alloc_len );
590
591 strcpy(fnameSemiCohCand, uvar_fnameout);
592 }
593
594
595 if ( uvar_printFstat1 )
596 {
597 const CHAR *append = "_fstatVec1.dat";
598 fnameFstatVec1 = LALCalloc( alloc_len = strlen(uvar_fnameout) + strlen(append) + 1, sizeof(CHAR) );
599 XLAL_CHECK ( fnameFstatVec1 != NULL, XLAL_ENOMEM, "Failed to allocate memory LALCalloc ( 1, %d )\n", alloc_len );
600 strcpy(fnameFstatVec1, uvar_fnameout);
601 strcat(fnameFstatVec1, append);
602 if ( !(fpFstat1 = fopen( fnameFstatVec1, "wb")))
603 {
604 fprintf ( stderr, "Unable to open Fstat file fstatvec1.out for writing.\n");
606 }
607 }
608
609 /*------------ Set up stacks, noise weights, detector states etc. */
610 /* initialize spin range vectors */
611 XLAL_INIT_MEM(spinRange_Temp);
612
613 /* some useful first stage params */
614 usefulParams.sftbasename = uvar_DataFiles1;
615 usefulParams.nStacks = uvar_nStacksMax;
616 usefulParams.tStack = uvar_tStack;
617 usefulParams.SSBprec = uvar_SSBprecision;
618
619 XLAL_INIT_MEM ( usefulParams.spinRange_startTime );
620 XLAL_INIT_MEM ( usefulParams.spinRange_endTime );
621 XLAL_INIT_MEM ( usefulParams.spinRange_refTime );
622 XLAL_INIT_MEM ( usefulParams.spinRange_midTime );
623
624 /* copy user specified spin variables at reftime */
625 /* the reference time value in spinRange_refTime will be set in SetUpSFTs() */
626 usefulParams.spinRange_refTime.fkdot[0] = uvar_Freq; /* frequency */
627 usefulParams.spinRange_refTime.fkdot[1] = uvar_f1dot; /* 1st spindown */
628 usefulParams.spinRange_refTime.fkdotBand[0] = uvar_FreqBand; /* frequency range */
629 usefulParams.spinRange_refTime.fkdotBand[1] = uvar_f1dotBand; /* spindown range */
630
631 usefulParams.edat = edat;
632 usefulParams.minStartTimeGPS = minStartTimeGPS;
633 usefulParams.maxStartTimeGPS = maxStartTimeGPS;
634 usefulParams.blocksRngMed = uvar_blocksRngMed;
635 usefulParams.Dterms = uvar_Dterms;
636 usefulParams.dopplerMax = uvar_dopplerMax;
637
638 /* set Fstat calculation frequency resolution
639 -- default is 1/tstack */
640 if ( XLALUserVarWasSet(&uvar_dFreq) ) {
641 usefulParams.dFreqStack = uvar_dFreq;
642 }
643 else {
644 usefulParams.dFreqStack = 1.0/usefulParams.tStack;
645 }
646
647 /* set reference time for pular parameters */
649 usefulParams.refTime = uvar_refTime;
650 else {
651 LogPrintf(LOG_DETAIL, "Reference time will be set to mid-time of observation time\n");
652 usefulParams.refTime = -1;
653 }
654
655 /* for 1st stage: read sfts, calculate multi-noise weights and detector states */
656 LogPrintf (LOG_DEBUG, "Reading SFTs and setting up stacks ... ");
657 LAL_CALL( SetUpSFTs( &status, &Fstat_in_vec, &usefulParams ), &status);
658 LogPrintfVerbatim (LOG_DEBUG, "done\n");
659
660 /* some useful params computed by SetUpSFTs */
661 tStack = usefulParams.tStack;
662 tObs = usefulParams.tObs;
663 nStacks = usefulParams.nStacks;
664 /* currently unused: LIGOTimeGPS tStartGPS = usefulParams.tStartGPS; */
665 midTstack = usefulParams.midTstack;
666 startTstack = usefulParams.startTstack;
667 tMidGPS = usefulParams.spinRange_midTime.refTime;
668 refTimeGPS = usefulParams.spinRange_refTime.refTime;
669 LogPrintf(LOG_DETAIL, "GPS Reference Time = %d\n", refTimeGPS.gpsSeconds);
670
671
672 /*------- set frequency and spindown resolutions and ranges for Fstat and semicoherent steps -----*/
673
674 /* set Fstat spindown resolution
675 -- default is 1/Tstack^2 */
676 if ( XLALUserVarWasSet(&uvar_df1dot) ) {
677 df1dot = uvar_df1dot;
678 }
679 else {
680 df1dot = 1.0/(tStack*tStack);
681 }
682
683 /* number of coarse grid spindown values */
684 nf1dot = (UINT4)( usefulParams.spinRange_midTime.fkdotBand[1]/ df1dot + 1e-6) + 1;
685
686 /* set number of residual spindowns for semi-coherent step
687 --default = nStacks */
688 if ( XLALUserVarWasSet(&uvar_nf1dotRes) ) {
689 nf1dotRes = uvar_nf1dotRes;
690 }
691 else {
692 nf1dotRes = nStacks;
693 }
694
695 /* resolution of residual spindowns
696 -- default = df1dot/nf1dotRes */
697 if ( XLALUserVarWasSet(&uvar_df1dotRes) ) {
698 df1dotRes = uvar_df1dotRes;
699 }
700 else {
701 df1dotRes = df1dot/nf1dotRes;
702 }
703
704
705 /*---------- compute noise weight for each stack and initialize total weights vector
706 -- for debugging purposes only -- we will calculate noise and AM weights later ----------*/
707 if (lalDebugLevel) {
708 LAL_CALL( ComputeStackNoiseWeights( &status, &weightsNoise, Fstat_in_vec), &status);
709 }
710
711 /* weightsV is the actual weights vector used */
712 LAL_CALL( LALDCreateVector( &status, &weightsV, nStacks), &status);
713
714
715 /**** debugging information ******/
716 /* print some debug info about spinrange */
717 LogPrintf(LOG_DETAIL, "Frequency and spindown range at refTime (%d): [%f-%f], [%e-%e]\n",
719 usefulParams.spinRange_refTime.fkdot[0],
720 usefulParams.spinRange_refTime.fkdot[0] + usefulParams.spinRange_refTime.fkdotBand[0],
721 usefulParams.spinRange_refTime.fkdot[1],
722 usefulParams.spinRange_refTime.fkdot[1] + usefulParams.spinRange_refTime.fkdotBand[1]);
723
724 LogPrintf(LOG_DETAIL, "Frequency and spindown range at startTime (%d): [%f-%f], [%e-%e]\n",
726 usefulParams.spinRange_startTime.fkdot[0],
727 usefulParams.spinRange_startTime.fkdot[0] + usefulParams.spinRange_startTime.fkdotBand[0],
728 usefulParams.spinRange_startTime.fkdot[1],
729 usefulParams.spinRange_startTime.fkdot[1] + usefulParams.spinRange_startTime.fkdotBand[1]);
730
731 LogPrintf(LOG_DETAIL, "Frequency and spindown range at midTime (%d): [%f-%f], [%e-%e]\n",
733 usefulParams.spinRange_midTime.fkdot[0],
734 usefulParams.spinRange_midTime.fkdot[0] + usefulParams.spinRange_midTime.fkdotBand[0],
735 usefulParams.spinRange_midTime.fkdot[1],
736 usefulParams.spinRange_midTime.fkdot[1] + usefulParams.spinRange_midTime.fkdotBand[1]);
737
738 LogPrintf(LOG_DETAIL, "Frequency and spindown range at endTime (%d): [%f-%f], [%e-%e]\n",
740 usefulParams.spinRange_endTime.fkdot[0],
741 usefulParams.spinRange_endTime.fkdot[0] + usefulParams.spinRange_endTime.fkdotBand[0],
742 usefulParams.spinRange_endTime.fkdot[1],
743 usefulParams.spinRange_endTime.fkdot[1] + usefulParams.spinRange_endTime.fkdotBand[1]);
744
745 /* print debug info about stacks */
746 LogPrintf(LOG_DETAIL, "1st stage params: Nstacks = %d, Tstack = %.0fsec, dFreq = %eHz, Tobs = %.0fsec\n",
747 nStacks, tStack, usefulParams.dFreqStack, tObs);
748 if ( weightsNoise ) {
749 for (k = 0; k < nStacks; k++) {
750 LogPrintf(LOG_DETAIL, "Stack %d (GPS start time = %d, Noise weight = %f )\n ",
751 k, startTstack->data[k].gpsSeconds, weightsNoise->data[k]);
752 } /* loop over stacks */
753 }
754
755 /** fix frequency-quantization offset bug #147, by applying a fixed frequency-correction to all candidates */
756 REAL8 FreqBugCorrection = 0;
757 if ( uvar_correctFreqs )
758 {
759 FreqBugCorrection = uvar_Freq - uvar_dFreq * floor ( uvar_Freq / uvar_dFreq + 0.5 );
760 printf ("Applying frequency-correction shift of %.9g Hz \n", FreqBugCorrection );
761 }
762 else
763 {
764 printf ("WARNING: turned off frequency-shift bug correction! I hope you know what you're doing!\n");
765 }
766
767 /*---------- set up F-statistic calculation stuff ---------*/
768
769 /* set reference time for calculating Fstatistic */
770 /* thisPoint.refTime = tStartGPS; */
771 thisPoint.refTime = tMidGPS;
772 /* binary orbit and higher spindowns not considered */
773 thisPoint.asini = 0 /* isolated pulsar */;
774 XLAL_INIT_MEM ( thisPoint.fkdot );
775
776
777 /* set up some semiCoherent parameters */
778 semiCohPar.useToplist = uvar_useToplist1;
779 semiCohPar.tsMid = midTstack;
780 /* semiCohPar.refTime = tStartGPS; */
781 semiCohPar.refTime = tMidGPS;
782 /* calculate detector velocity and positions */
783 LAL_CALL( GetStackVelPos( &status, &velStack, &posStack, Fstat_in_vec), &status);
784 semiCohPar.vel = velStack;
785 semiCohPar.pos = posStack;
786
787 semiCohPar.outBaseName = uvar_fnameout;
788 semiCohPar.pixelFactor = uvar_pixelFactor;
789 semiCohPar.nfdot = nf1dotRes;
790 semiCohPar.dfdot = df1dotRes;
791
792 /* allocate memory for Hough candidates */
793 semiCohCandList.length = uvar_nCand1;
794 /* reference time for candidates */
795 /* semiCohCandList.refTime = tStartGPS; */
796 semiCohCandList.refTime = tMidGPS;
797 semiCohCandList.nCandidates = 0; /* initialization */
798 semiCohCandList.list = LALCalloc( 1, alloc_len = semiCohCandList.length * sizeof(SemiCohCandidate));
799 XLAL_CHECK ( semiCohCandList.list != NULL, XLAL_ENOMEM, "Error allocating memory LALCalloc ( 1, %d )\n", alloc_len );
800
801 /* set semicoherent patch size */
802 if ( XLALUserVarWasSet(&uvar_semiCohPatchX)) {
803 semiCohPar.patchSizeX = uvar_semiCohPatchX;
804 }
805 else {
806 semiCohPar.patchSizeX = 1.0 / ( tStack * usefulParams.spinRange_midTime.fkdot[0] * VEPI );
807 }
808
809 if ( XLALUserVarWasSet(&uvar_semiCohPatchY)) {
810 semiCohPar.patchSizeY = uvar_semiCohPatchY;
811 }
812 else {
813 semiCohPar.patchSizeY = 1.0 / ( tStack * usefulParams.spinRange_midTime.fkdot[0] * VEPI );
814 }
815
816 LogPrintf(LOG_DETAIL,"Hough/Stackslide patchsize is %frad x %frad\n",
817 semiCohPar.patchSizeX, semiCohPar.patchSizeY);
818
819 /* allocate some fstat memory */
820 fstatVector.length = nStacks;
821 fstatVector.data = NULL;
822 fstatVector.data = LALCalloc( 1, alloc_len = nStacks * sizeof(REAL4FrequencySeries));
823 XLAL_CHECK ( fstatVector.data != NULL, XLAL_ENOMEM, "Error allocating memory LALCalloc ( 1, %d )\n", alloc_len );
824
825 /*-----------Create template grid for first stage ---------------*/
826 /* prepare initialization of DopplerSkyScanner to step through paramter space */
827 scanInit.dAlpha = uvar_dAlpha;
828 scanInit.dDelta = uvar_dDelta;
829 scanInit.gridType = uvar_gridType1;
830 scanInit.metricType = uvar_metricType1;
831 scanInit.metricMismatch = uvar_mismatch1;
832 scanInit.projectMetric = TRUE;
833 scanInit.obsDuration = tStack;
834 scanInit.obsBegin = tMidGPS;
835 scanInit.Detector = &XLALGetFstatInputDetectorStates(Fstat_in_vec->data[0])->data[0]->detector;
836 scanInit.ephemeris = edat;
837 scanInit.skyGridFile = uvar_skyGridFile;
838 scanInit.skyRegionString = LALCalloc(1, alloc_len = strlen(uvar_skyRegion)+1);
839 XLAL_CHECK ( scanInit.skyRegionString != NULL, XLAL_ENOMEM, "Failed to allocate memory LALCalloc ( 1, %d )\n", alloc_len );
840 strcpy (scanInit.skyRegionString, uvar_skyRegion);
841
842 scanInit.numSkyPartitions = uvar_numSkyPartitions;
843 scanInit.partitionIndex = uvar_partitionIndex;
844
845 scanInit.Freq = usefulParams.spinRange_midTime.fkdot[0] + usefulParams.spinRange_midTime.fkdotBand[0];
846
847 /* initialize skygrid */
848 LogPrintf(LOG_DETAIL, "Setting up coarse sky grid...");
849 LAL_CALL ( InitDopplerSkyScan ( &status, &thisScan, &scanInit), &status);
850 LogPrintfVerbatim(LOG_DETAIL, "done\n");
851
852 /*----- start main calculations by going over coarse grid points and
853 selecting candidates and following up --------*/
854
855 /* loop over skygrid points */
856 skyGridCounter = 0;
857
858 XLALNextDopplerSkyPos(&dopplerpos, &thisScan);
859
860 /* "spool forward" if we found a checkpoint */
861 {
862 UINT4 count = 0;
863 GET_CHECKPOINT(semiCohToplist, &count, thisScan.numSkyGridPoints, fnameSemiCohCand, NULL);
864 for(skyGridCounter = 0; skyGridCounter < count; skyGridCounter++)
865 XLALNextDopplerSkyPos(&dopplerpos, &thisScan);
866 }
867
868 /* spool forward if uvar_skyPointIndex is set
869 ---This probably doesn't make sense when checkpointing is turned on */
870 if ( XLALUserVarWasSet(&uvar_skyPointIndex)) {
871 UINT4 count = uvar_skyPointIndex;
872 for(skyGridCounter = 0; (skyGridCounter < count)&&(thisScan.state != STATE_FINISHED) ; skyGridCounter++)
873 XLALNextDopplerSkyPos(&dopplerpos, &thisScan);
874 }
875
876
877#ifdef SKYPOS_PRECISION
878 LogPrintf(LOG_DEBUG, "SKYPOS_PRECISION: %15f (0x%x)\n", (REAL4)SKYPOS_PRECISION,(INT8)SKYPOS_PRECISION);
879#endif
880
881 LogPrintf(LOG_DEBUG, "Total skypoints = %d. Progress: ", thisScan.numSkyGridPoints);
882
884
885#ifdef OUTPUT_TIMING
886 clock0 = time(NULL);
887#endif
888
889
890 while(thisScan.state != STATE_FINISHED)
891 {
892 UINT4 ifdot; /* counter for spindown values */
893 SkyPosition skypos;
894
895 /* if (skyGridCounter == 25965) { */
896
897
898#ifdef SKYPOS_PRECISION
899 /* reduce precision of sky position */
900 dopplerpos.Alpha = (INT4)(dopplerpos.Alpha * SKYPOS_PRECISION) / (REAL4)SKYPOS_PRECISION;
901 dopplerpos.Delta = (INT4)(dopplerpos.Delta * SKYPOS_PRECISION) / (REAL4)SKYPOS_PRECISION;
902#endif
903
904 SHOW_PROGRESS(dopplerpos.Alpha,dopplerpos.Delta,
905 skyGridCounter,thisScan.numSkyGridPoints,
906 uvar_Freq, uvar_FreqBand);
907
908 LogPrintfVerbatim(LOG_DEBUG, "%d, ", skyGridCounter );
909
910 /*------------- calculate F statistic for each stack --------------*/
911
912 /* normalize skyposition: correctly map into [0,2pi]x[-pi/2,pi/2] */
913 thisPoint.Alpha = dopplerpos.Alpha;
914 thisPoint.Delta = dopplerpos.Delta;
915
916 /* get amplitude modulation weights */
917 skypos.longitude = thisPoint.Alpha;
918 skypos.latitude = thisPoint.Delta;
920
921 semiCohPar.alpha = thisPoint.Alpha;
922 semiCohPar.delta = thisPoint.Delta;
923
924 /* initialize weights to unity */
926
927 if (uvar_useWeights) {
928 LAL_CALL( ComputeStackNoiseAndAMWeights( &status, weightsV, Fstat_in_vec, skypos), &status);
929 }
930 semiCohPar.weightsV = weightsV;
931
932 LogPrintf(LOG_DETAIL, "Stack weights for alpha = %f, delta = %f are:\n", skypos.longitude, skypos.latitude);
933 for (k = 0; k < nStacks; k++) {
934 LogPrintf(LOG_DETAIL, "%f\n", weightsV->data[k]);
935 }
936
937
938 { /********Allocate fstat vector memory *****************/
939
940 /* extra bins for fstat due to skypatch and spindowns */
941 UINT4 extraBinsfdot;
942 REAL8 freqHighest;
943
944 /* calculate number of bins for fstat overhead */
945 freqHighest = usefulParams.spinRange_midTime.fkdot[0] + usefulParams.spinRange_midTime.fkdotBand[0];
946 ComputeNumExtraBins(&status, &semiCohPar, 0, freqHighest, usefulParams.dFreqStack);
947
948 /* conservative estimate */
949 /* extraBinsSky = (UINT4)(0.5 * LAL_SQRT2 * VTOT */
950 /* * (usefulParams.spinRange_midTime.fkdot[0] + usefulParams.spinRange_midTime.fkdotBand[0]) */
951 /* * HSMAX(semiCohPar.patchSizeX, semiCohPar.patchSizeY) / dFreqStack) + 10; */
952
953 /* extra bins due to fdot is maximum number of frequency bins drift that can be
954 caused by the residual spindown. The reference time for the spindown is the midtime,
955 so relevant interval is Tobs/2 and largest possible value of residual spindown is
956 (number of residual spindowns -1)*resolution in residual spindowns */
957 extraBinsfdot = (UINT4)(tObs * (nf1dotRes - 1) * df1dotRes / usefulParams.dFreqStack + 0.5);
958
959 semiCohPar.extraBinsFstat += extraBinsfdot;
960
961 /* allocate fstat memory */
962 binsFstatSearch = (UINT4)(usefulParams.spinRange_midTime.fkdotBand[0]/usefulParams.dFreqStack + 1e-6) + 1;
963 binsFstat1 = binsFstatSearch + 2*semiCohPar.extraBinsFstat;
964
965 for (k = 0; k < nStacks; k++) {
966 /* careful--the epoch here is not the reference time for f0! */
967 fstatVector.data[k].epoch = startTstack->data[k];
968 fstatVector.data[k].deltaF = usefulParams.dFreqStack;
969 fstatVector.data[k].f0 = usefulParams.spinRange_midTime.fkdot[0] - semiCohPar.extraBinsFstat * usefulParams.dFreqStack;
970 if (fstatVector.data[k].data == NULL) {
971 fstatVector.data[k].data = LALCalloc( 1, alloc_len = sizeof(REAL4Sequence));
972 XLAL_CHECK( fstatVector.data[k].data != NULL, XLAL_ENOMEM, "Failed to allocate memory LALCalloc ( 1, %d )\n", alloc_len );
973
974 fstatVector.data[k].data->length = binsFstat1;
975 fstatVector.data[k].data->data = LALCalloc( 1, alloc_len = binsFstat1 * sizeof(REAL4));
976 XLAL_CHECK( fstatVector.data[k].data->data != NULL, XLAL_ENOMEM, "Failed to allocate memory LALCalloc ( 1, %d )\n", alloc_len );
977 }
978 else {
979 fstatVector.data[k].data = LALRealloc( fstatVector.data[k].data, sizeof(REAL4Sequence));
980 XLAL_CHECK( fstatVector.data[k].data != NULL, XLAL_ENOMEM, "Failed to re-allocate memory LALRealloc ( %zu )\n", sizeof(REAL4Sequence) );
981
982 fstatVector.data[k].data->length = binsFstat1;
983 fstatVector.data[k].data->data = LALRealloc( fstatVector.data[k].data->data, alloc_len = binsFstat1 * sizeof(REAL4));
984 XLAL_CHECK( fstatVector.data[k].data->data != NULL, XLAL_ENOMEM, "Failed to re-allocate memory LALRealloc ( %d )\n", alloc_len );
985 }
986 } /* loop over stacks */
987
989
990 } /* fstat memory allocation block */
991
992
993 /* loop over fdot values
994 -- spindown range and resolutionhas been set earlier */
995 for ( ifdot = 0; ifdot < nf1dot; ifdot++)
996 {
997
998 LogPrintf(LOG_DETAIL, "Analyzing %d/%d Coarse sky grid points and %d/%d spindown values\n",
999 skyGridCounter, thisScan.numSkyGridPoints, ifdot+1, nf1dot);
1000
1001 SHOW_PROGRESS(dopplerpos.Alpha,dopplerpos.Delta, skyGridCounter + (REAL4)ifdot / (REAL4)nf1dot,
1002 thisScan.numSkyGridPoints, uvar_Freq, uvar_FreqBand);
1003
1004
1005 /* calculate the Fstatistic for each stack*/
1006 LogPrintf(LOG_DETAIL, "Starting Fstat calculation for each stack...");
1007 for ( k = 0; k < nStacks; k++)
1008 {
1009 /* set spindown value for Fstat calculation */
1010 thisPoint.fkdot[1] = usefulParams.spinRange_midTime.fkdot[1] + ifdot * df1dot;
1011 thisPoint.fkdot[0] = fstatVector.data[k].f0;
1012 /* thisPoint.fkdot[0] = usefulParams.spinRange_midTime.fkdot[0]; */
1013
1014 const int retn = XLALComputeFstat(&Fstat_res, Fstat_in_vec->data[k], &thisPoint, binsFstat1, Fstat_what);
1015 if ( retn != XLAL_SUCCESS ) {
1016 XLALPrintError ("%s: XLALComputeFstat() failed with errno=%d\n", __func__, xlalErrno );
1017 return xlalErrno;
1018 }
1019 for (UINT4 iFreq = 0; iFreq < binsFstat1; ++iFreq) {
1020 fstatVector.data[k].data->data[iFreq] = 0.5 * Fstat_res->twoF[iFreq]; // *** copy value of *1*F ***
1021 }
1022 } /* for k < nStacks */
1023
1024 LogPrintfVerbatim(LOG_DETAIL, "done\n");
1025
1026 /* print fstat vector if required -- mostly for debugging */
1027 if ( uvar_printFstat1 )
1028 {
1029 for (k = 0; k < nStacks; k++)
1030 LAL_CALL( PrintFstatVec ( &status, fstatVector.data + k, fpFstat1, &thisPoint, refTimeGPS, k+1), &status);
1031 }
1032
1033
1034 /*--------------- get candidates from a semicoherent search ---------------*/
1035
1036 /* the input to this section is the set of fstat vectors fstatVector and the
1037 parameters semiCohPar. The output is the list of candidates in semiCohCandList */
1038
1039
1040 /* set spindown for Hough grid -- same as for Fstat calculation */
1041 semiCohPar.fdot = thisPoint.fkdot[1];
1042
1043 /* the hough option */
1044 /* select peaks */
1045 if (uvar_method == 0) {
1046
1047 LogPrintf(LOG_DETAIL, "Starting Hough calculation...\n");
1048 sumWeightSquare = 0.0;
1049 for ( k = 0; k < nStacks; k++)
1050 sumWeightSquare += weightsV->data[k] * weightsV->data[k];
1051
1052 /* set number count threshold based on significance threshold */
1053 meanN = nStacks * alphaPeak;
1054 sigmaN = sqrt(sumWeightSquare * alphaPeak * (1.0 - alphaPeak));
1055 semiCohPar.threshold = uvar_threshold1*sigmaN + meanN;
1056 LogPrintf(LOG_DETAIL, "Expected mean number count=%f, std=%f, threshold=%f\n",
1057 meanN, sigmaN, semiCohPar.threshold);
1058
1059 /* convert fstat vector to peakgrams using the Fstat threshold */
1060 LAL_CALL( FstatVectToPeakGram( &status, &pgV, &fstatVector, (REAL4)uvar_peakThrF), &status);
1061
1062 /* get candidates */
1063 /* this is the second most costly function. We here allow for using architecture-specific
1064 optimized functions from a local file instead of the standard ComputeFstatHoughMap()
1065 below that refers to the LALHOUGH functions in LAL */
1066 LAL_CALL ( COMPUTEFSTATHOUGHMAP ( &status, &semiCohCandList, &pgV, &semiCohPar), &status);
1067
1068 /* ----- now apply frequency-shift correction to fix bug #147 to all candidates returned */
1069 INT4 iCand;
1070 for ( iCand = 0; iCand < semiCohCandList.nCandidates; iCand ++ )
1071 semiCohCandList.list[iCand].freq += FreqBugCorrection;
1072 /* ------------------------------------------------------------ */
1073
1074 /* free peakgrams -- we don't need them now because we have the Hough maps */
1075 for (k=0; k<nStacks; k++)
1076 LALFree(pgV.pg[k].peak);
1077 LALFree(pgV.pg);
1078 LogPrintf(LOG_DETAIL, "...finished Hough calculation\n");
1079
1080 /* end hough */
1081 } else if ( uvar_method == 1 ) {
1082 /* --- stackslide option --------*/
1083 LogPrintf(LOG_DETAIL, "Starting StackSlide calculation...\n");
1084 /* 12/18/06 gm; use threshold from command line as threshold on stackslide sum of F-stat values */
1085 semiCohPar.threshold = uvar_threshold1;
1086 LAL_CALL( StackSlideVecF( &status, &semiCohCandList, &fstatVector, &semiCohPar), &status);
1087 LogPrintf(LOG_DETAIL, "...finished StackSlide calculation\n");
1088 }
1089
1090 /* print candidates if desired */
1091 /* if ( uvar_printCand1 ) { */
1092 /* LAL_CALL ( PrintSemiCohCandidates ( &status, &semiCohCandList, fpSemiCoh, refTimeGPS), &status); */
1093 /* } */
1094
1095
1096 if( uvar_semiCohToplist) {
1097 /* this is necessary here, because GetSemiCohToplist() might set
1098 a checkpoint that needs some information from here */
1099 SHOW_PROGRESS(dopplerpos.Alpha,dopplerpos.Delta,
1100 skyGridCounter,thisScan.numSkyGridPoints,
1101 uvar_Freq, uvar_FreqBand);
1102
1103 LogPrintf(LOG_DETAIL, "Selecting toplist from semicoherent candidates\n");
1104 LAL_CALL( GetSemiCohToplist(&status, semiCohToplist, &semiCohCandList, meanN, sigmaN), &status);
1105 }
1106
1107 } /* end loop over coarse grid fdot values */
1108
1109
1110 /* continue forward till the end if uvar_skyPointIndex is set
1111 ---This probably doesn't make sense when checkpointing is turned on */
1112 if ( XLALUserVarWasSet(&uvar_skyPointIndex) )
1113 {
1114 while(thisScan.state != STATE_FINISHED) {
1115 skyGridCounter++;
1116 XLALNextDopplerSkyPos(&dopplerpos, &thisScan);
1117 }
1118 }
1119 else
1120 {
1121 skyGridCounter++;
1122
1123 /* this is necessary here, because the checkpoint needs some information from here */
1124 SHOW_PROGRESS(dopplerpos.Alpha,dopplerpos.Delta,
1125 skyGridCounter,thisScan.numSkyGridPoints,
1126 uvar_Freq, uvar_FreqBand);
1127
1129
1130 XLALNextDopplerSkyPos( &dopplerpos, &thisScan );
1131 }
1132
1133 } /* end while loop over 1st stage coarse skygrid */
1134
1135#ifdef OUTPUT_TIMING
1136 {
1137 time_t tau = time(NULL) - clock0;
1138 UINT4 Nrefine = nSkyRefine * nf1dotRes;
1139 FILE *timing_fp = fopen ( "HS_timing.dat", "ab" );
1140 fprintf ( timing_fp, "%d %d %d %d %d %d %d %d\n",
1141 thisScan.numSkyGridPoints, nf1dot, binsFstatSearch, 2 * semiCohPar.extraBinsFstat, nSFTs, nStacks, Nrefine, tau );
1142 fclose ( timing_fp );
1143 }
1144#endif
1145
1147
1148 LogPrintfVerbatim ( LOG_DEBUG, " done.\n");
1149
1150 LogPrintf(LOG_DETAIL, "Finished analysis and now printing results and cleaning up...");
1151
1152 LogPrintfVerbatim ( LOG_DEBUG, "Writing output ...\n");
1153
1154#if (!HS_CHECKPOINTING)
1155 /* print 1st stage candidates */
1156 {
1157 if (!(fpSemiCoh = fopen(fnameSemiCohCand, "wb")))
1158 {
1159 LogPrintf ( LOG_CRITICAL, "Unable to open output-file '%s' for writing.\n", fnameSemiCohCand);
1161 }
1162 if ( uvar_printCand1 && uvar_semiCohToplist ) {
1163 fprintf ( fpSemiCoh, "%%%% Freq Alpha Delta f1dot HoughFstat AlphaBest DeltaBest MeanSig VarSig\n");
1164 sort_houghFstat_toplist(semiCohToplist);
1165 if ( write_houghFstat_toplist_to_fp( semiCohToplist, fpSemiCoh, NULL) < 0)
1166 fprintf( stderr, "Error in writing toplist to file\n");
1167 /* LAL_CALL( AppendFstatCandidates( &status, &fStatCand, fpFstat), &status); */
1168 if (fprintf(fpSemiCoh,"%%DONE\n") < 0)
1169 fprintf(stderr, "Error writing end marker\n");
1170 fclose(fpSemiCoh);
1171 }
1172 }
1173#else
1174 write_and_close_checkpointed_file();
1175#endif
1176
1177 LogPrintfVerbatim ( LOG_DEBUG, " done.\n");
1178
1179 /*------------ free all remaining memory -----------*/
1180
1181 /* free memory */
1182
1183 if ( uvar_printCand1 )
1184 {
1185 LALFree(fnameSemiCohCand);
1186 }
1187
1188 if ( VCSInfoString ) XLALFree ( VCSInfoString );
1189
1190 if ( uvar_printFstat1 )
1191 {
1192 fclose(fpFstat1);
1193 LALFree( fnameFstatVec1 );
1194 }
1195
1196 /* free first stage memory */
1197 XLALDestroyFstatInputVector( Fstat_in_vec );
1198 XLALDestroyFstatResults( Fstat_res );
1199
1200 XLALDestroyTimestampVector(midTstack);
1201 XLALDestroyTimestampVector(startTstack);
1202
1203 /* free Fstat vectors */
1204 for(k = 0; k < nStacks; k++)
1205 if (fstatVector.data[k].data) {
1206 if (fstatVector.data[k].data->data)
1207 LALFree(fstatVector.data[k].data->data);
1208 LALFree(fstatVector.data[k].data);
1209 }
1210 LALFree(fstatVector.data);
1211
1212
1213 /* free Vel/Pos vectors and ephemeris */
1217
1218 if (weightsNoise) {
1219 LAL_CALL( LALDDestroyVector ( &status, &weightsNoise ), &status);
1220 }
1221 LAL_CALL( LALDDestroyVector ( &status, &weightsV ), &status);
1222
1223 /* free dopplerscan stuff */
1224 LAL_CALL ( FreeDopplerSkyScan(&status, &thisScan), &status);
1225 if ( scanInit.skyRegionString )
1226 LALFree ( scanInit.skyRegionString );
1227
1228
1229 /* free candidates */
1230 LALFree(semiCohCandList.list);
1231 free_houghFstat_toplist(&semiCohToplist);
1232
1234
1236
1237 LogPrintfVerbatim(LOG_DETAIL, "done\n");
1238
1240} /* main */
1241
1242
1243
1244
1245/**
1246 * Set up stacks, read SFTs, calculate SFT noise weights and calculate
1247 * detector-state
1248 */
1249void SetUpSFTs( LALStatus *status, /**< pointer to LALStatus structure */
1250 FstatInputVector** p_Fstat_in_vec, /**< pointer to vector of Fstat input data structures for XLALComputeFstat(), one per stack */
1251 UsefulStageVariables *in /**< input params */)
1252{
1253
1254 SFTCatalog *catalog = NULL;
1255 static SFTConstraints constraints;
1256 REAL8 timebase, tObs, deltaFsft;
1257 UINT4 k,numSFTby2;
1258 LIGOTimeGPS tStartGPS, tEndGPS, refTimeGPS, tMidGPS;
1259 SFTCatalogSequence catalogSeq;
1260
1261 REAL8 doppWings, fMin, fMax;
1262 REAL8 startTime_freqLo, startTime_freqHi;
1263 REAL8 endTime_freqLo, endTime_freqHi;
1264 REAL8 freqLo, freqHi;
1265
1266 BOOLEAN crc_check;
1267
1270
1271 /* get sft catalog */
1272 constraints.minStartTime = &(in->minStartTimeGPS);
1273 constraints.maxStartTime = &(in->maxStartTimeGPS);
1274 XLAL_CHECK_LAL( status, ( catalog = XLALSFTdataFind( in->sftbasename, &constraints) ) != NULL, XLAL_EFUNC);
1275
1276 /* check CRC sums of SFTs */
1277 XLAL_CHECK_LAL ( status, XLALCheckCRCSFTCatalog ( &crc_check, catalog ) == XLAL_SUCCESS, XLAL_EFUNC );
1278 if (!crc_check) {
1279 LogPrintf(LOG_CRITICAL,"SFT validity check failed\n");
1281 }
1282
1283 /* set some sft parameters */
1284 deltaFsft = catalog->data[0].header.deltaF;
1285 timebase = 1.0/deltaFsft;
1286
1287 /* get sft catalogs for each stack */
1288 TRY( SetUpStacks( status->statusPtr, &catalogSeq, in->tStack, catalog, in->nStacks), status);
1289
1290 /* reset number of stacks */
1291 UINT4 numSegments = catalogSeq.length;
1292 in->nStacks = numSegments;
1293
1294 /* calculate start and end times and tobs from segmented catalog*/
1295 tStartGPS = catalogSeq.data[0].data[0].header.epoch;
1296 in->tStartGPS = tStartGPS;
1297 SFTCatalog *LastSegmentCat = &(catalogSeq.data[numSegments - 1]);
1298 UINT4 numSFTsInLastSeg = LastSegmentCat->length;
1299 tEndGPS = LastSegmentCat->data[numSFTsInLastSeg-1].header.epoch;
1300 XLALGPSAdd(&tEndGPS, timebase);
1301 tObs = XLALGPSDiff(&tEndGPS, &tStartGPS);
1302 in->tObs = tObs;
1303
1304 /* get timestamps of start and mid of each stack */
1305 /* set up vector containing mid times of stacks */
1307
1308 /* set up vector containing start times of stacks */
1310
1311 /* now loop over stacks and get time stamps */
1312 for (k = 0; k < in->nStacks; k++) {
1313
1314 if ( catalogSeq.data[k].length == 0 ) {
1315 /* something is wrong */
1317 }
1318
1319 /* start time of stack = time of first sft in stack */
1320 in->startTstack->data[k] = catalogSeq.data[k].data[0].header.epoch;
1321
1322 /* mid time of stack */
1323 numSFTby2 = catalogSeq.data[k].length/2;
1324 in->midTstack->data[k] = catalogSeq.data[k].data[numSFTby2].header.epoch;
1325
1326 } /* loop over k */
1327
1328
1329 /* set reference time for pular parameters */
1330 /* first calculate the mid time of observation time span*/
1331 {
1332 REAL8 tStart8, tEnd8, tMid8;
1333
1334 tStart8 = XLALGPSGetREAL8( &tStartGPS );
1335 tEnd8 = XLALGPSGetREAL8( &tEndGPS );
1336 tMid8 = 0.5 * (tStart8 + tEnd8);
1337 XLALGPSSetREAL8( &tMidGPS, tMid8 );
1338 }
1339
1340 if ( in->refTime > 0) {
1341 REAL8 refTime = in->refTime;
1342 XLALGPSSetREAL8(&refTimeGPS, refTime);
1343 }
1344 else { /* set refTime to exact midtime of the total observation-time spanned */
1345 refTimeGPS = tMidGPS;
1346 }
1347
1348 /* get frequency and fdot bands at start time of sfts by extrapolating from reftime */
1349 in->spinRange_refTime.refTime = refTimeGPS;
1350
1351
1355
1356
1357 /* set wings of sfts to be read */
1358 /* the wings must be enough for the Doppler shift and extra bins
1359 for the running median block size and Dterms for Fstat calculation.
1360 In addition, it must also include wings for the spindown correcting
1361 for the reference time */
1362 /* calculate Doppler wings at the highest frequency */
1363 startTime_freqLo = in->spinRange_startTime.fkdot[0]; /* lowest search freq at start time */
1364 startTime_freqHi = startTime_freqLo + in->spinRange_startTime.fkdotBand[0]; /* highest search freq. at start time*/
1365 endTime_freqLo = in->spinRange_endTime.fkdot[0];
1366 endTime_freqHi = endTime_freqLo + in->spinRange_endTime.fkdotBand[0];
1367
1368 freqLo = HSMIN ( startTime_freqLo, endTime_freqLo );
1369 freqHi = HSMAX ( startTime_freqHi, endTime_freqHi );
1370 doppWings = freqHi * in->dopplerMax; /* maximum Doppler wing -- probably larger than it has to be */
1371
1372 fMin = freqLo - doppWings;
1373 fMax = freqHi + doppWings;
1374
1375 // ---------- wild hack: FIXME if you can
1376 // this code only worked previously because the running-median sideband
1377 // actually covered for *physically needed* extraBinsFstat sidebands.
1378 // Those are unfortunately unknown at this point in the code, and it turned to
1379 // too tricky to get their calculation moved here before SetupSFTs()
1380 // Now that CreateFstatInput will actually remove the running-median sidebands
1381 // before proceeding with the Fstat-calculation, this fails...
1382 // We fix this simply by tagging on an extra 50 SFT bins on either side, which
1383 // have previously made this work. I don't think this code cares ...
1384 // To whom it may concern: feel free to clean this up if it matters to you.
1385 fMin -= 50 * deltaFsft;
1386 fMax += 50 * deltaFsft;
1387 // ---------- end: wild hack
1388
1389 /* set up vector of Fstat input data structs */
1390 (*p_Fstat_in_vec) = XLALCreateFstatInputVector( in->nStacks );
1391 if ( (*p_Fstat_in_vec) == NULL ) {
1393 }
1394
1395#ifdef OUTPUT_TIMING
1396 /* need to count the total number of SFTs */
1397 nStacks = in->nStacks;
1398 nSFTs = 0;
1399#endif
1400
1402 optionalArgs.SSBprec = in->SSBprec;
1403 optionalArgs.Dterms = in->Dterms;
1404 optionalArgs.runningMedianWindow = in->blocksRngMed;
1405 optionalArgs.FstatMethod = FMETHOD_DEMOD_BEST;
1406
1407 /* loop over stacks and read sfts */
1408 for (k = 0; k < in->nStacks; k++) {
1409
1410 /* create Fstat input data struct for Fstat-computation */
1411 (*p_Fstat_in_vec)->data[k] = XLALCreateFstatInput( &catalogSeq.data[k], fMin, fMax, in->dFreqStack, in->edat, &optionalArgs );
1412 if ( (*p_Fstat_in_vec)->data[k] == NULL ) {
1413 XLALPrintError("%s: XLALCreateFstatInput() failed with errno=%d", __func__, xlalErrno);
1415 }
1416
1417 /* get SFT detectors and timestamps */
1418 const MultiLALDetector *multiIFO = XLALGetFstatInputDetectors( (*p_Fstat_in_vec)->data[k] );
1419 if ( multiIFO == NULL ) {
1420 XLALPrintError("%s: XLALGetFstatInputDetectors() failed with errno=%d", __func__, xlalErrno);
1422 }
1423 const MultiLIGOTimeGPSVector *multiTS = XLALGetFstatInputTimestamps( (*p_Fstat_in_vec)->data[k] );
1424 if ( multiTS == NULL ) {
1425 XLALPrintError("%s: XLALGetFstatInputTimestamps() failed with errno=%d", __func__, xlalErrno);
1427 }
1428
1429 /* print debug info about this stack */
1430 LogPrintf(LOG_DETAIL, "Stack %d ", k);
1431 for ( UINT4 j = 0; j < multiTS->length; j++) {
1432 LogPrintfVerbatim(LOG_DETAIL, "%s: %d ", multiIFO->sites[j].frDetector.prefix, multiTS->data[j]->length);
1433 } /* loop over ifos */
1435
1436#ifdef OUTPUT_TIMING
1437 /* need to count the total number of SFTs */
1438 for ( UINT4 X = 0; X < multiTS->length; X++ ) {
1439 nSFTs += multiTS->data[X]->length;
1440 }
1441#endif
1442
1443 } /* loop over k */
1444
1445
1446 /* realloc if nStacks != in->nStacks */
1447 /* if ( in->nStacks > nStacks ) { */
1448
1449 /* in->midTstack->length = nStacks; */
1450 /* in->midTstack->data = (LIGOTimeGPS *)LALRealloc( in->midTstack->data, nStacks * sizeof(LIGOTimeGPS)); */
1451
1452 /* in->startTstack->length = nStacks; */
1453 /* in->startTstack->data = (LIGOTimeGPS *)LALRealloc( in->startTstack->data, nStacks * sizeof(LIGOTimeGPS)); */
1454
1455 /* stackMultiSFT->length = nStacks; */
1456 /* stackMultiSFT->data = (MultiSFTVector **)LALRealloc( stackMultiSFT->data, nStacks * sizeof(MultiSFTVector *)); */
1457
1458 /* } */
1459
1460 /* we don't need the original catalog anymore*/
1461 XLALDestroySFTCatalog(catalog );
1462
1463 /* free catalog sequence */
1464 for (k = 0; k < in->nStacks; k++)
1465 {
1466 if ( catalogSeq.data[k].length > 0 ) {
1467 LALFree(catalogSeq.data[k].data);
1468 } /* end if */
1469 } /* loop over stacks */
1470 LALFree( catalogSeq.data);
1471
1472
1474 RETURN(status);
1475
1476} /* SetUpSFTs */
1477
1478
1479
1480/**
1481 * Function for calculating Hough Maps and candidates.
1482 * This function takes a peakgram as input. This peakgram was constructed
1483 * by setting a threshold on a sequence of Fstatistic vectors. The function
1484 * produces a Hough map in the sky for each value of the frequency and spindown.
1485 * The Hough nummber counts are then used to select candidates in
1486 * parameter space to be followed up in a more refined search.
1487 * This uses DriveHough_v3.c as a prototype suitably modified to work
1488 * on demodulated data instead of SFTs.
1489 */
1490void ComputeFstatHoughMap(LALStatus *status, /**< pointer to LALStatus structure */
1491 SemiCohCandidateList *out, /**< Candidates from thresholding Hough number counts */
1492 HOUGHPeakGramVector *pgV, /**< HOUGHPeakGramVector obtained after thresholding Fstatistic vectors */
1493 SemiCoherentParams *params /**< pointer to HoughParams -- parameters for calculating Hough maps */
1494 )
1495{
1496
1497 /* hough structures */
1498 HOUGHMapTotal ht;
1499 HOUGHptfLUTVector lutV; /* the Look Up Table vector*/
1500 PHMDVectorSequence phmdVS; /* the partial Hough map derivatives */
1501 UINT8FrequencyIndexVector freqInd; /* for trajectory in time-freq plane */
1502 HOUGHResolutionPar parRes; /* patch grid information */
1503 HOUGHPatchGrid patch; /* Patch description */
1504 HOUGHParamPLUT parLut; /* parameters needed to build lut */
1505 HOUGHDemodPar parDem; /* demodulation parameters */
1506 HOUGHSizePar parSize;
1507
1508 UINT2 xSide, ySide, maxNBins, maxNBorders;
1509 INT8 fBinIni, fBinFin, fBin;
1510 INT4 iHmap, nfdot;
1511 UINT4 k, nStacks ;
1512 REAL8 deltaF, dfdot, alpha, delta;
1513 REAL8 patchSizeX, patchSizeY;
1514 REAL8VectorSequence *vel, *pos;
1515 REAL8 fdot, refTime;
1516 LIGOTimeGPS refTimeGPS;
1517 LIGOTimeGPSVector *tsMid;
1518 REAL8Vector *timeDiffV=NULL;
1519 UINT8Vector hist; /* histogram vector */
1520 UINT8Vector histTotal; /* total histogram vector */
1521 HoughStats stats; /* statistics struct */
1522 CHAR *fileStats = NULL;
1523 FILE *fpStats = NULL;
1524
1525 toplist_t *houghToplist;
1526
1529
1530 /* check input is not null */
1531 if ( out == NULL ) {
1533 }
1534 if ( out->length == 0 ) {
1536 }
1537 if ( out->list == NULL ) {
1539 }
1540 if ( pgV == NULL ) {
1542 }
1543 if ( pgV->length == 0 ) {
1545 }
1546 if ( pgV->pg == NULL ) {
1548 }
1549 if ( params == NULL ) {
1551 }
1552
1553
1554
1555 /* copy some parameters from peakgram vector */
1556 deltaF = pgV->pg->deltaF;
1557 nStacks = pgV->length;
1558 fBinIni = pgV->pg[0].fBinIni;
1559 fBinFin = pgV->pg[0].fBinFin;
1560
1561 /* copy some params to local variables */
1562 nfdot = params->nfdot;
1563 dfdot = params->dfdot;
1564 alpha = params->alpha;
1565 delta = params->delta;
1566 vel = params->vel;
1567 pos = params->pos;
1568 fdot = params->fdot;
1569 tsMid = params->tsMid;
1570 refTimeGPS = params->refTime;
1571 refTime = XLALGPSGetREAL8(&refTimeGPS);
1572
1573 /* set patch size */
1574 /* this is supposed to be the "educated guess"
1575 delta theta = 1.0 / (Tcoh * f0 * Vepi )
1576 where Tcoh is coherent time baseline,
1577 f0 is frequency and Vepi is rotational velocity
1578 of detector */
1579 patchSizeX = params->patchSizeX;
1580 patchSizeY = params->patchSizeY;
1581
1582 /* calculate time differences from start of observation time for each stack*/
1583 TRY( LALDCreateVector( status->statusPtr, &timeDiffV, nStacks), status);
1584
1585 for (k=0; k<nStacks; k++) {
1586 REAL8 tMidStack;
1587 tMidStack = XLALGPSGetREAL8(tsMid->data + k);
1588 timeDiffV->data[k] = tMidStack - refTime;
1589 }
1590
1591
1592
1593 /*--------------- first memory allocation --------------*/
1594 /* look up table vector */
1595 lutV.length = nStacks;
1596 lutV.lut = LALCalloc(1, alloc_len = nStacks*sizeof(HOUGHptfLUT));
1597 if ( lutV.lut == NULL ) {
1598 XLALPrintError ("Failed to LALCalloc(1,%d)\n", alloc_len );
1600 }
1601
1602
1603 /* partial hough map derivative vector */
1604 phmdVS.length = nStacks;
1605
1606 {
1607 REAL8 maxTimeDiff, startTimeDiff, endTimeDiff;
1608
1609 startTimeDiff = fabs(timeDiffV->data[0]);
1610 endTimeDiff = fabs(timeDiffV->data[timeDiffV->length - 1]);
1611 maxTimeDiff = HSMAX( startTimeDiff, endTimeDiff);
1612
1613 /* set number of freq. bins for which LUTs will be calculated */
1614 /* this sets the range of residual spindowns values */
1615 /* phmdVS.nfSize = 2*nfdotBy2 + 1; */
1616 phmdVS.nfSize = 2 * floor((nfdot-1) * (REAL4)(dfdot * maxTimeDiff / deltaF) + 0.5f) + 1;
1617 }
1618
1619 phmdVS.deltaF = deltaF;
1620 phmdVS.phmd = LALCalloc( 1, alloc_len = phmdVS.length * phmdVS.nfSize *sizeof(HOUGHphmd));
1621 if ( phmdVS.phmd == NULL ) {
1622 XLALPrintError ("Failed to LALCalloc(1,%d)\n", alloc_len );
1624 }
1625
1626 /* residual spindown trajectory */
1627 freqInd.deltaF = deltaF;
1628 freqInd.length = nStacks;
1629 freqInd.data = LALCalloc(1, alloc_len = nStacks*sizeof(UINT8));
1630 if ( freqInd.data == NULL ) {
1631 XLALPrintError ("Failed to LALCalloc(1,%d)\n", alloc_len );
1633 }
1634
1635 /* resolution in space of residual spindowns */
1636 ht.dFdot.length = 1;
1637 ht.dFdot.data = LALCalloc( 1, alloc_len = ht.dFdot.length * sizeof(REAL8));
1638 if ( ht.dFdot.data == NULL ) {
1639 XLALPrintError ("Failed to LALCalloc(1,%d)\n", alloc_len );
1641 }
1642
1643 /* the residual spindowns */
1644 ht.spinRes.length = 1;
1645 ht.spinRes.data = LALCalloc( 1, alloc_len = ht.spinRes.length*sizeof(REAL8));
1646 if ( ht.spinRes.data == NULL ) {
1647 XLALPrintError ("Failed to LALCalloc(1,%d)\n", alloc_len );
1649 }
1650
1651 /* the residual spindowns */
1652 ht.spinDem.length = 1;
1653 ht.spinDem.data = LALCalloc( 1, alloc_len = ht.spinRes.length*sizeof(REAL8));
1654 if ( ht.spinDem.data == NULL ) {
1655 XLALPrintError ("Failed to LALCalloc(1,%d)\n", alloc_len );
1657 }
1658
1659 /* the demodulation params */
1660 parDem.deltaF = deltaF;
1661 parDem.skyPatch.alpha = alpha;
1662 parDem.skyPatch.delta = delta;
1663 parDem.spin.length = 1;
1664 parDem.spin.data = LALCalloc(1, alloc_len = sizeof(REAL8));
1665 if ( parDem.spin.data == NULL ) {
1666 XLALPrintError ("Failed to LALCalloc(1,%d)\n", alloc_len );
1668 }
1669 parDem.spin.data[0] = fdot;
1670
1671 /* the skygrid resolution params */
1672 parRes.deltaF = deltaF;
1673 parRes.patchSkySizeX = patchSizeX;
1674 parRes.patchSkySizeY = patchSizeY;
1675 parRes.pixelFactor = params->pixelFactor;
1676 parRes.pixErr = PIXERR;
1677 parRes.linErr = LINERR;
1678 parRes.vTotC = VTOT;
1679
1680 /* memory allocation for histogram and opening stats file*/
1681 if ( uvar_printStats ) {
1682 hist.length = nStacks+1;
1683 histTotal.length = nStacks+1;
1684 hist.data = NULL;
1685 hist.data = LALCalloc(1, alloc_len = (nStacks+1)*sizeof(UINT8));
1686 if ( hist.data == NULL ) {
1687 XLALPrintError ("Failed to LALCalloc(1,%d)\n", alloc_len );
1689 }
1690
1691 histTotal.data = LALCalloc(1, alloc_len = (nStacks+1)*sizeof(UINT8));
1692 if ( histTotal.data == NULL ) {
1693 XLALPrintError ("Failed to LALCalloc(1,%d)\n", alloc_len );
1695 }
1696
1697 {
1698 UINT4 j;
1699 for(j=0; j< histTotal.length; ++j)
1700 histTotal.data[j]=0;
1701 }
1702 {
1703 const CHAR *append = "stats";
1704 fileStats = LALCalloc( alloc_len = strlen(params->outBaseName) + strlen(append) + 1, sizeof(CHAR) );
1705 if ( fileStats == NULL ) {
1706 XLALPrintError ("Failed to LALCalloc(1,%d)\n", alloc_len );
1708 }
1709
1710 strcpy( fileStats, params->outBaseName);
1711 strcat( fileStats, append);
1712 }
1713 if ( !(fpStats = fopen(fileStats, "wb")))
1714 {
1715 fprintf(stderr, "Unable to open file '%s' for writing...continuing\n", fileStats);
1716 }
1717 }
1718
1719
1720
1721 /* adjust fBinIni and fBinFin to take maxNBins into account */
1722 /* and make sure that we have fstat values for sufficient number of bins */
1723 parRes.f0Bin = fBinIni;
1724
1725 fBinIni += params->extraBinsFstat;
1726 fBinFin -= params->extraBinsFstat;
1727 /* this is not very clean -- the Fstat calculation has to know how many extra bins are needed */
1728
1729 LogPrintf(LOG_DETAIL, "Freq. range analyzed by Hough = [%fHz - %fHz] (%"LAL_INT8_FORMAT" bins)\n",
1730 fBinIni*deltaF, fBinFin*deltaF, fBinFin - fBinIni + 1);
1732
1733 /* initialise number of candidates -- this means that any previous candidates
1734 stored in the list will be lost for all practical purposes*/
1735 out->nCandidates = 0;
1736
1737 /* create toplist of candidates */
1738 if (params->useToplist) {
1739 create_toplist(&houghToplist, out->length, sizeof(SemiCohCandidate), smallerHough);
1740 }
1741 else {
1742 /* if no toplist then use number of hough maps */
1743 INT4 numHmaps = (fBinFin - fBinIni + 1)*phmdVS.nfSize;
1744 if (out->length != numHmaps) {
1745 out->length = numHmaps;
1746 out->list = LALRealloc( out->list, alloc_len = out->length * sizeof(SemiCohCandidate));
1747 if ( out->list == NULL ) {
1748 XLALPrintError ("Failed to LALRealloc( *, %d)\n", alloc_len );
1750 }
1751 }
1752 }
1753
1754 /*------------------ start main Hough calculation ---------------------*/
1755
1756 /* initialization */
1757 fBin= fBinIni; /* initial search bin */
1758 iHmap = 0; /* hough map index */
1759
1760 while( fBin <= fBinFin ){
1761 INT8 fBinSearch, fBinSearchMax;
1762 UINT4 i,j;
1763 REAL8UnitPolarCoor sourceLocation;
1764
1765 parRes.f0Bin = fBin;
1766 TRY( LALHOUGHComputeSizePar( status->statusPtr, &parSize, &parRes ), status );
1767 xSide = parSize.xSide;
1768 ySide = parSize.ySide;
1769
1770 maxNBins = parSize.maxNBins;
1771 maxNBorders = parSize.maxNBorders;
1772
1773 /*------------------ create patch grid at fBin ----------------------*/
1774 patch.xSide = xSide;
1775 patch.ySide = ySide;
1776 patch.xCoor = NULL;
1777 patch.yCoor = NULL;
1778 patch.xCoor = LALCalloc(1, alloc_len = xSide*sizeof(REAL8));
1779 if ( patch.xCoor == NULL ) {
1780 XLALPrintError ("Failed to LALCalloc( 1, %d)\n", alloc_len );
1782 }
1783
1784 patch.yCoor = LALCalloc(1, alloc_len = ySide*sizeof(REAL8));
1785 if ( patch.yCoor == NULL ) {
1786 XLALPrintError ("Failed to LALCalloc( 1, %d)\n", alloc_len );
1788 }
1789 TRY( LALHOUGHFillPatchGrid( status->statusPtr, &patch, &parSize ), status );
1790
1791 /*------------- other memory allocation and settings----------------- */
1792 for(j=0; j<lutV.length; ++j){
1793 lutV.lut[j].maxNBins = maxNBins;
1794 lutV.lut[j].maxNBorders = maxNBorders;
1795 lutV.lut[j].border = LALCalloc(1, alloc_len = maxNBorders*sizeof(HOUGHBorder));
1796 if ( lutV.lut[j].border == NULL ) {
1797 XLALPrintError ("Failed to LALCalloc( 1, %d)\n", alloc_len );
1799 }
1800
1801 lutV.lut[j].bin = LALCalloc(1, alloc_len = maxNBins*sizeof(HOUGHBin2Border));
1802 if ( lutV.lut[j].bin == NULL ) {
1803 XLALPrintError ("Failed to LALCalloc( 1, %d)\n", alloc_len );
1805 }
1806
1807 for (i=0; i<maxNBorders; ++i){
1808 lutV.lut[j].border[i].ySide = ySide;
1809 lutV.lut[j].border[i].xPixel = LALCalloc(1, alloc_len = ySide*sizeof(COORType));
1810 if ( lutV.lut[j].border[i].xPixel == NULL ) {
1811 XLALPrintError ("Failed to LALCalloc( 1, %d)\n", alloc_len );
1813 }
1814 }
1815 }
1816
1817 for(j = 0; j < phmdVS.length * phmdVS.nfSize; ++j){
1818 phmdVS.phmd[j].maxNBorders = maxNBorders;
1819 phmdVS.phmd[j].leftBorderP = LALCalloc(1, alloc_len = maxNBorders*sizeof(HOUGHBorder *));
1820 if ( phmdVS.phmd[j].leftBorderP == NULL ) {
1821 XLALPrintError ("Failed to LALCalloc( 1, %d)\n", alloc_len );
1823 }
1824
1825 phmdVS.phmd[j].rightBorderP = LALCalloc(1, alloc_len = maxNBorders*sizeof(HOUGHBorder *));
1826 if ( phmdVS.phmd[j].rightBorderP == NULL ) {
1827 XLALPrintError ("Failed to LALCalloc( 1, %d)\n", alloc_len );
1829 }
1830
1831 phmdVS.phmd[j].ySide = ySide;
1832 phmdVS.phmd[j].firstColumn = NULL;
1833 phmdVS.phmd[j].firstColumn = LALCalloc(1, alloc_len = ySide*sizeof(UCHAR));
1834 if ( phmdVS.phmd[j].firstColumn == NULL ) {
1835 XLALPrintError ("Failed to LALCalloc( 1, %d)\n", alloc_len );
1837 }
1838 }
1839
1840 /*------------------- create all the LUTs at fBin ---------------------*/
1841 for (j=0; j < (UINT4)nStacks; j++){ /* create all the LUTs */
1842 parDem.veloC.x = vel->data[3*j];
1843 parDem.veloC.y = vel->data[3*j + 1];
1844 parDem.veloC.z = vel->data[3*j + 2];
1845 parDem.positC.x = pos->data[3*j];
1846 parDem.positC.y = pos->data[3*j + 1];
1847 parDem.positC.z = pos->data[3*j + 2];
1848 parDem.timeDiff = timeDiffV->data[j];
1849
1850 /* calculate parameters needed for buiding the LUT */
1851 TRY( LALHOUGHCalcParamPLUT( status->statusPtr, &parLut, &parSize, &parDem), status);
1852
1853 /* build the LUT */
1854 TRY( LALHOUGHConstructPLUT( status->statusPtr, &(lutV.lut[j]), &patch, &parLut ), status);
1855
1856
1857 /* for debugging
1858 fprintf(stdout,"%d\n", lutV.lut[j].nBin);
1859 */
1860
1861 /* for debugging */
1862 if ( uvar_validateLUT) {
1863 TRY( ValidateHoughLUT( status->statusPtr, &(lutV.lut[j]), &patch, params->outBaseName, j, alpha, delta, params->weightsV->data[j]), status);
1864 }
1865
1866 /* for debugging */
1867 if ( uvar_dumpLUT) {
1868 TRY( DumpLUT2file( status->statusPtr, &(lutV.lut[j]), &patch, params->outBaseName, j), status);
1869 }
1870 }
1871
1872 /*--------- build the set of PHMD centered around fBin -------------*/
1873 phmdVS.fBinMin = fBin - phmdVS.nfSize/2;
1874 TRY( LALHOUGHConstructSpacePHMD(status->statusPtr, &phmdVS, pgV, &lutV), status );
1875 TRY( LALHOUGHWeighSpacePHMD(status->statusPtr, &phmdVS, params->weightsV), status);
1876
1877 /*-------------- initializing the Total Hough map space ------------*/
1878 ht.xSide = xSide;
1879 ht.ySide = ySide;
1880 ht.skyPatch.alpha = alpha;
1881 ht.skyPatch.delta = delta;
1882 ht.mObsCoh = nStacks;
1883 ht.deltaF = deltaF;
1884 ht.spinDem.data[0] = fdot;
1885 ht.patchSizeX = patchSizeX;
1886 ht.patchSizeY = patchSizeY;
1887 ht.dFdot.data[0] = dfdot;
1888 ht.map = LALCalloc(1, alloc_len = xSide*ySide*sizeof(HoughTT));
1889 if ( ht.map == NULL ) {
1890 XLALPrintError ("Failed to LALCalloc( 1, %d)\n", alloc_len );
1892 }
1893
1894 TRY( LALHOUGHInitializeHT( status->statusPtr, &ht, &patch), status); /*not needed */
1895
1896 /* Search frequency interval possible using the same LUTs */
1897 fBinSearch = fBin;
1898 fBinSearchMax = fBin + parSize.nFreqValid - 1;
1899
1900 /* Study all possible frequencies with one set of LUT */
1901 while ( (fBinSearch <= fBinFin) && (fBinSearch < fBinSearchMax) ) {
1902
1903 /* finally we can construct the hough maps and select candidates */
1904 {
1905 INT4 n, nfdotBy2;
1906
1907 nfdotBy2 = nfdot/2;
1908 ht.f0Bin = fBinSearch;
1909
1910 /*loop over all values of residual spindown */
1911 /* check limits of loop */
1912 for( n = -nfdotBy2; n <= nfdotBy2 ; n++ ){
1913
1914 ht.spinRes.data[0] = n*dfdot;
1915
1916 for (j=0; j < (UINT4)nStacks; j++) {
1917 freqInd.data[j] = fBinSearch + floor( (REAL4)(timeDiffV->data[j]*n*dfdot/deltaF) + 0.5f);
1918 }
1919
1920 TRY( LALHOUGHConstructHMT_W(status->statusPtr, &ht, &freqInd, &phmdVS),status );
1921
1922 /* get candidates */
1923 if ( params->useToplist ) {
1924 TRY(GetHoughCandidates_toplist( status->statusPtr, houghToplist, &ht, &patch, &parDem), status);
1925 }
1926 else {
1927 TRY(GetHoughCandidates_threshold( status->statusPtr, out, &ht, &patch, &parDem, params->threshold), status);
1928 }
1929
1930 /* calculate statistics and histogram */
1931 if ( uvar_printStats && (fpStats != NULL) ) {
1932 TRY( LALHoughStatistics ( status->statusPtr, &stats, &ht), status );
1933 TRY( LALStereo2SkyLocation ( status->statusPtr, &sourceLocation,
1934 stats.maxIndex[0], stats.maxIndex[1],
1935 &patch, &parDem), status);
1936
1937 fprintf(fpStats, "%d %f %f %f %f %f %f %f %g \n", iHmap, sourceLocation.alpha, sourceLocation.delta,
1938 (REAL4)stats.maxCount, (REAL4)stats.minCount, (REAL4)stats.avgCount, (REAL4)stats.stdDev,
1939 fBinSearch*deltaF, ht.spinRes.data[0] );
1940
1941 TRY( LALHoughHistogram ( status->statusPtr, &hist, &ht), status);
1942 for(j=0; j< histTotal.length; ++j)
1943 histTotal.data[j]+=hist.data[j];
1944 }
1945
1946 /* print hough map */
1947 if ( uvar_printMaps ) {
1948 TRY( PrintHmap2file( status->statusPtr, &ht, params->outBaseName, iHmap), status);
1949 }
1950
1951 if ( uvar_printGrid ) {
1952 /* just print one grid */
1953 if ( iHmap == 0 ) {
1954 TRY( PrintHoughGrid( status->statusPtr, &patch, &parDem, params->outBaseName, iHmap), status);
1955 }
1956 }
1957
1958 /* increment hough map index */
1959 ++iHmap;
1960
1961 } /* end loop over spindown trajectories */
1962
1963 } /* end of block for calculating total hough maps */
1964
1965
1966 /*------ shift the search freq. & PHMD structure 1 freq.bin -------*/
1967 ++fBinSearch;
1968 TRY( LALHOUGHupdateSpacePHMDup(status->statusPtr, &phmdVS, pgV, &lutV), status );
1969 TRY( LALHOUGHWeighSpacePHMD(status->statusPtr, &phmdVS, params->weightsV), status);
1970
1971 } /* closing while loop over fBinSearch */
1972
1973#ifdef OUTPUT_TIMING
1974 /* printf ("xside x yside = %d x %d = %d\n", parSize.xSide, parSize.ySide, parSize.xSide * parSize.ySide ); */
1975 nSkyRefine = parSize.xSide * parSize.ySide;
1976#endif
1977
1978 fBin = fBinSearch;
1979
1980 /*-------------- Free partial memory -----------------*/
1981 LALFree(patch.xCoor);
1982 LALFree(patch.yCoor);
1983 LALFree(ht.map);
1984
1985 for (j=0; j<lutV.length ; ++j){
1986 for (i=0; i<maxNBorders; ++i){
1987 LALFree( lutV.lut[j].border[i].xPixel);
1988 }
1989 LALFree( lutV.lut[j].border);
1990 LALFree( lutV.lut[j].bin);
1991 }
1992 for(j=0; j<phmdVS.length * phmdVS.nfSize; ++j){
1993 LALFree( phmdVS.phmd[j].leftBorderP);
1994 LALFree( phmdVS.phmd[j].rightBorderP);
1995 LALFree( phmdVS.phmd[j].firstColumn);
1996 }
1997
1998 } /* closing first while */
1999
2000
2001 /* free remaining memory */
2002 LALFree(ht.spinRes.data);
2003 LALFree(ht.spinDem.data);
2004 LALFree(ht.dFdot.data);
2005 LALFree(lutV.lut);
2006 LALFree(phmdVS.phmd);
2007 LALFree(freqInd.data);
2008 LALFree(parDem.spin.data);
2009
2010 TRY( LALDDestroyVector( status->statusPtr, &timeDiffV), status);
2011
2012 /* copy toplist candidates to output structure if necessary */
2013 if ( params->useToplist ) {
2014 for ( k=0; k<houghToplist->elems; k++) {
2015 out->list[k] = *((SemiCohCandidate *)(toplist_elem(houghToplist, k)));
2016 }
2017 out->nCandidates = houghToplist->elems;
2018 free_toplist(&houghToplist);
2019 }
2020
2021 if (uvar_printStats ) {
2022
2023 /* print the histogram */
2024 TRY( PrintHoughHistogram(status->statusPtr, &histTotal, params->outBaseName), status);
2025
2026 /* close stats file */
2027 LALFree(fileStats);
2028 fclose(fpStats);
2029
2030 /* free histograms */
2031 LALFree(hist.data);
2032 LALFree(histTotal.data);
2033 }
2034
2036 RETURN(status);
2037
2038}
2039
2040/**
2041 * Function for selecting frequency bins from a set of Fstatistic vectors.
2042 *
2043 * Input is a vector of Fstatistic vectors. It allocates memory
2044 * for the peakgrams based on the frequency span of the Fstatistic vectors
2045 * and fills tyem up by setting a threshold on the Fstatistic. Peakgram must be
2046 * deallocated outside the function.
2047 */
2048void FstatVectToPeakGram (LALStatus *status, /**< pointer to LALStatus structure */
2049 HOUGHPeakGramVector *pgV, /**< a vector of peakgrams */
2050 REAL4FrequencySeriesVector *FstatVect,/**< sequence of Fstatistic vectors */
2051 REAL4 thr /**< REAL8 threshold for selecting frequency bins */
2052 )
2053{
2054 INT4 j, k;
2055 INT4 nStacks, nSearchBins, nPeaks;
2056 UCHAR *upg;
2057
2060
2061 if ( FstatVect == NULL ) {
2063 }
2064 if ( FstatVect->length == 0 ) {
2066 }
2067 if ( FstatVect->data == NULL ) {
2069 }
2070 if ( pgV == NULL ) {
2072 }
2073
2074 nStacks = FstatVect->length;
2075 nSearchBins = FstatVect->data->data->length;
2076
2077
2078 /* first memory allocation */
2079 pgV->length = nStacks;
2080 pgV->pg = LALCalloc( 1, alloc_len = nStacks * sizeof(HOUGHPeakGram));
2081 if ( pgV->pg == NULL ) {
2082 XLALPrintError ("Failed to LALCalloc( 1, %d)\n", alloc_len );
2084 }
2085
2086 upg = LALCalloc( 1, alloc_len = nSearchBins * sizeof(UCHAR));
2087 if ( upg == NULL ) {
2088 XLALPrintError ("Failed to LALCalloc( 1, %d)\n", alloc_len );
2090 }
2091
2092 /* loop over each stack and set peakgram */
2093 for (k=0; k<nStacks; k++) {
2094 INT4 *pInt; /* temporary pointer */
2095 REAL4 *pV; /* temporary pointer */
2096 REAL8 f0, deltaF;
2097 pV = FstatVect->data[k].data->data;
2098
2099 /* loop over Fstat vector, count peaks, and set upg values */
2100 nPeaks = 0;
2101 for(j=0; j<nSearchBins; j++) {
2102 if (pV[j] > thr ) {
2103 nPeaks++;
2104 upg[j] = 1;
2105 }
2106 else
2107 upg[j] = 0;
2108 }
2109
2110 /* fix length of peakgram and allocate memory appropriately */
2111 pgV->pg[k].length = nPeaks;
2112 pgV->pg[k].peak = LALCalloc( 1, alloc_len = nPeaks * sizeof(INT4));
2113 if ( pgV->pg[k].peak == NULL ) {
2114 XLALPrintError ("Failed to LALCalloc( 1, %d)\n", alloc_len );
2116 }
2117
2118
2119 /* fill up other peakgram parameters */
2120 pgV->pg[k].deltaF = FstatVect->data[k].deltaF;
2121 f0 = FstatVect->data[k].f0;
2122 deltaF = FstatVect->data[k].deltaF;
2123 pgV->pg[k].fBinIni = (UINT4)( f0/deltaF + 0.5);
2124 pgV->pg[k].fBinFin = pgV->pg[k].fBinIni + nSearchBins - 1;
2125
2126 /* do loop again and fill peakgram vector */
2127 pInt = pgV->pg[k].peak;
2128 for (j=0; j<nSearchBins; j++) {
2129 if ( upg[j] == 1) {
2130 *pInt = j;
2131 pInt++;
2132 }
2133 }
2134 }
2135
2136 /* free the UCHAR peakgram */
2137 LALFree(upg);
2138
2140 RETURN(status);
2141}
2142
2143
2144/**
2145 * \brief Breaks up input sft catalog into specified number of stacks
2146 *
2147 * Loops over elements of the catalog, assigns a bin index and
2148 * allocates memory to the output catalog sequence appropriately. If
2149 * there are long gaps in the data, then some of the catalogs in the
2150 * output catalog sequence may be of zero length.
2151 */
2152void SetUpStacks(LALStatus *status, /**< pointer to LALStatus structure */
2153 SFTCatalogSequence *out, /**< Output catalog of sfts -- one for each stack */
2154 REAL8 tStack, /**< Output duration of each stack */
2155 SFTCatalog *in, /**< Input sft catalog to be broken up into stacks (ordered in increasing time)*/
2156 UINT4 nStacksMax ) /**< User specified number of stacks */
2157{
2158 UINT4 j, stackCounter, length;
2159 REAL8 tStart, thisTime;
2160 REAL8 Tsft;
2161
2164
2165 /* check input parameters */
2172
2173 /* set memory of output catalog sequence to maximum possible length */
2174 out->length = nStacksMax;
2175 out->data = LALCalloc( 1, alloc_len = nStacksMax * sizeof(SFTCatalog));
2176 if ( out->data == NULL ) {
2177 XLALPrintError ("Failed to LALCalloc( 1, %d)\n", alloc_len );
2179 }
2180
2181
2182 Tsft = 1.0 / in->data[0].header.deltaF;
2183
2184 /* get first sft timestamp */
2185 /* tStart will be start time of a given stack.
2186 This initializes tStart to the first sft time stamp as this will
2187 be the start time of the first stack */
2188 tStart = XLALGPSGetREAL8(&(in->data[0].header.epoch));
2189
2190 /* loop over the sfts */
2191 stackCounter = 0;
2192 for( j = 0; j < in->length; j++)
2193 {
2194 /* thisTime is current sft timestamp */
2195 thisTime = XLALGPSGetREAL8(&(in->data[j].header.epoch));
2196
2197 /* if sft lies in stack duration then add
2198 this sft to the stack. Otherwise move
2199 on to the next stack */
2200 if ( (thisTime - tStart + Tsft <= tStack) )
2201 {
2202 out->data[stackCounter].length += 1;
2203
2204 length = out->data[stackCounter].length;
2205
2206 /* realloc to increase length of catalog */
2207 out->data[stackCounter].data = LALRealloc( out->data[stackCounter].data, alloc_len = length * sizeof(SFTDescriptor));
2208 if ( out->data[stackCounter].data == NULL ) {
2209 XLALPrintError ("Failed to LALRealloc( *, %d)\n", alloc_len );
2211 }
2212
2213 out->data[stackCounter].data[length - 1] = in->data[j];
2214 }
2215 else /* move onto the next stack */
2216 {
2217 if ( stackCounter + 1 == nStacksMax )
2218 break;
2219
2220 stackCounter++;
2221
2222 /* reset start time of stack */
2223 tStart = XLALGPSGetREAL8(&(in->data[j].header.epoch));
2224
2225 /* realloc to increase length of catalog and copy data */
2226 out->data[stackCounter].length = 1; /* first entry in new stack */
2227 out->data[stackCounter].data = LALRealloc( out->data[stackCounter].data, alloc_len = sizeof(SFTDescriptor));
2228 if ( out->data[stackCounter].data == NULL ) {
2229 XLALPrintError ("Failed to LALRealloc( *, %d)\n", alloc_len );
2231 }
2232
2233 out->data[stackCounter].data[0] = in->data[j];
2234 } /* if new stack */
2235
2236 } /* loop over sfts */
2237
2238 /* realloc catalog sequence length to actual number of stacks */
2239 out->length = stackCounter + 1;
2240 out->data = LALRealloc( out->data, alloc_len = (stackCounter+1) * sizeof(SFTCatalog) );
2241 if ( out->data == NULL ) {
2242 XLALPrintError ("Failed to LALRealloc( *, %d)\n", alloc_len );
2244 }
2245
2247 RETURN(status);
2248
2249} /* SetUpStacks() */
2250
2251
2252/** Print single Hough map to a specified output file */
2254 HOUGHMapTotal *ht,
2255 CHAR *fnameOut,
2256 INT4 iHmap)
2257{
2258 FILE *fp=NULL; /* Output file */
2259 CHAR filename[256], filenumber[16];
2260 INT4 k, i ;
2261 UINT2 xSide, ySide;
2262
2265
2266 strcpy( filename, fnameOut);
2267 sprintf( filenumber, ".%06d",iHmap);
2268 strcat( filename, filenumber);
2269
2270 fp=fopen(filename,"wb");
2272
2273 ySide= ht->ySide;
2274 xSide= ht->xSide;
2275
2276 for(k=ySide-1; k>=0; --k){
2277 for(i=0;i<xSide;++i){
2278 fprintf( fp ," %f", ht->map[k*xSide +i]);
2279 fflush( fp );
2280 }
2281 fprintf( fp ," \n");
2282 fflush( fp );
2283 }
2284
2285 fclose( fp );
2286
2288 RETURN(status);
2289}
2290
2291
2293 HOUGHPatchGrid *patch,
2294 HOUGHDemodPar *parDem,
2295 CHAR *fnameOut,
2296 INT4 iHmap)
2297{
2298
2299 UINT2 xSide, ySide;
2300 FILE *fp1=NULL; /* Output file */
2301 FILE *fp2=NULL; /* Output file */
2302 CHAR filename1[256], filename2[256], filenumber[16];
2303 INT4 k, i ;
2304 REAL8UnitPolarCoor sourceLocation;
2305
2308
2309 sprintf( filenumber, ".%06d",iHmap);
2310
2311 strcpy( filename1, fnameOut);
2312 strcat( filename1, "_GridAlpha");
2313 strcat( filename1, filenumber);
2314
2315 strcpy( filename2, fnameOut);
2316 strcat( filename2, "_GridDelta");
2317 strcat( filename2, filenumber);
2318
2319 fp1=fopen(filename1,"wb");
2321
2322 fp2=fopen(filename2,"wb");
2324
2325 xSide = patch->xSide;
2326 ySide = patch->ySide;
2327
2328 for(k=ySide-1; k>=0; --k){
2329 for(i=0;i<xSide;++i){
2330
2331 TRY( LALStereo2SkyLocation ( status->statusPtr, &sourceLocation,
2332 k, i, patch, parDem), status);
2333
2334 fprintf( fp1 ," %f", sourceLocation.alpha);
2335 fflush( fp1 );
2336
2337 fprintf( fp2 ," %f", sourceLocation.delta);
2338 fflush( fp2 );
2339 }
2340
2341 fprintf( fp1 ," \n");
2342 fflush( fp1 );
2343
2344 fprintf( fp2 ," \n");
2345 fflush( fp2 );
2346 }
2347
2348 fclose( fp1 );
2349 fclose( fp2 );
2350
2352 RETURN(status);
2353
2354}
2355
2357 HOUGHptfLUT *lut,
2358 HOUGHPatchGrid *patch,
2359 CHAR *basename,
2360 INT4 ind,
2361 REAL4 alpha,
2362 REAL4 delta,
2363 REAL4 weight)
2364{
2365 FILE *fp=NULL;
2366 CHAR filename[256];
2367 INT4 j, i;
2368 UINT4 k;
2369 INT8 f0Bin;
2370 UINT2 xSide, ySide, maxNBins, maxNBorders;
2371
2372 HOUGHPeakGram pg;
2373 HOUGHphmd phmd;
2374 HOUGHMapDeriv hd;
2375 HOUGHMapTotal ht;
2376
2377 BOOLEAN validateFlag = FALSE;
2378
2381
2382 strcpy( filename, basename);
2383 strcat( filename, ".validate");
2384
2385 maxNBins = lut->maxNBins;
2386 maxNBorders = lut->maxNBorders;
2387 f0Bin = lut->f0Bin;
2388
2389 xSide = patch->xSide;
2390 ySide = patch->ySide;
2391
2392 pg.deltaF = lut->deltaF;
2393 pg.fBinIni = f0Bin - maxNBins;
2394 pg.fBinFin = f0Bin + 5*maxNBins;
2395 pg.length = maxNBins;
2396 pg.peak = LALCalloc(1, alloc_len = pg.length*sizeof(INT4) );
2397 if ( pg.peak == NULL ) {
2398 XLALPrintError ("Failed to LALCalloc ( 1, %d )\n", alloc_len );
2400 }
2401
2402 phmd.fBin = f0Bin;
2403 phmd.maxNBorders = maxNBorders;
2404 phmd.leftBorderP = LALMalloc( alloc_len = maxNBorders*sizeof(HOUGHBorder *));
2405 if ( phmd.leftBorderP == NULL ) {
2406 XLALPrintError ("Failed to LALCalloc ( 1, %d )\n", alloc_len );
2408 }
2409
2410 phmd.rightBorderP = LALMalloc( alloc_len = maxNBorders*sizeof(HOUGHBorder *));
2411 if ( phmd.rightBorderP == NULL ) {
2412 XLALPrintError ("Failed to LALCalloc ( 1, %d )\n", alloc_len );
2414 }
2415
2416 phmd.ySide = ySide;
2417 phmd.firstColumn = LALMalloc( alloc_len = ySide*sizeof(UCHAR));
2418 if ( phmd.firstColumn == NULL ) {
2419 XLALPrintError ("Failed to LALCalloc ( 1, %d )\n", alloc_len );
2421 }
2422
2423 ht.xSide = xSide;
2424 ht.ySide = ySide;
2425 ht.map = LALMalloc( alloc_len = xSide*ySide*sizeof(HoughTT));
2426 if ( ht.map == NULL ) {
2427 XLALPrintError ("Failed to LALCalloc ( 1, %d )\n", alloc_len );
2429 }
2430
2431 hd.xSide = xSide;
2432 hd.ySide = ySide;
2433 hd.map = LALMalloc( alloc_len = (xSide+1)*ySide*sizeof(HoughDT));
2434 if ( hd.map == NULL ) {
2435 XLALPrintError ("Failed to LALCalloc ( 1, %d )\n", alloc_len );
2437 }
2438
2439 /* construct a fake peakgram to print all borders
2440 -- peakgram should be 1,0,1,0,1,0.... */
2441 for (k = 0; k < pg.length; ++k){
2442 pg.peak[k] = 2*k;
2443 }
2444
2445 TRY( LALHOUGHPeak2PHMD(status->statusPtr, &phmd, lut, &pg ), status );
2446
2447 TRY( LALHOUGHInitializeHT(status->statusPtr, &ht, patch ), status );
2448
2449 TRY( LALHOUGHInitializeHD(status->statusPtr, &hd), status );
2450
2451 TRY( LALHOUGHAddPHMD2HD(status->statusPtr, &hd, &phmd ), status );
2452
2453 TRY( LALHOUGHIntegrHD2HT(status->statusPtr, &ht, &hd ), status );
2454
2455 for(j = ySide-1; j >= 0; --j){
2456 for(i = 0; i < xSide; ++i){
2457
2458 if (( ht.map[j*xSide+i] > 1.0) || (ht.map[j*xSide+i] < 0.0 ))
2459 validateFlag = TRUE;
2460 }
2461 }
2462
2463 LALFree(pg.peak);
2464
2465 LALFree(phmd.leftBorderP);
2466 LALFree(phmd.rightBorderP);
2467 LALFree(phmd.firstColumn);
2468
2469 LALFree(ht.map);
2470 LALFree(hd.map);
2471
2472 if (validateFlag) {
2473 fp=fopen(filename,"a");
2475 fprintf(fp ," %d %f %f %f\n", ind, alpha, delta, weight);
2476 fflush(fp);
2477 fclose(fp);
2478 }
2479
2481 RETURN(status);
2482
2483}
2484
2485
2486/** Print single Hough map to a specified output file */
2488 HOUGHptfLUT *lut,
2489 HOUGHPatchGrid *patch,
2490 CHAR *basename,
2491 INT4 ind)
2492{
2493
2494 FILE *fp=NULL;
2495 CHAR filename[256], filenumber[16];
2496 INT4 j, i;
2497 UINT4 k;
2498 INT8 f0Bin;
2499 UINT2 xSide, ySide, maxNBins, maxNBorders;
2500
2501 HOUGHPeakGram pg;
2502 HOUGHphmd phmd;
2503 HOUGHMapDeriv hd;
2504 HOUGHMapTotal ht;
2505
2508
2509 strcpy( filename, basename);
2510 strcat( filename, ".lut");
2511 sprintf( filenumber, ".%06d",ind);
2512 strcat( filename, filenumber);
2513
2514 fp=fopen(filename,"w");
2516
2517 maxNBins = lut->maxNBins;
2518 maxNBorders = lut->maxNBorders;
2519 f0Bin = lut->f0Bin;
2520
2521 xSide = patch->xSide;
2522 ySide = patch->ySide;
2523
2524 pg.deltaF = lut->deltaF;
2525 pg.fBinIni = f0Bin - maxNBins;
2526 pg.fBinFin = f0Bin + 5*maxNBins;
2527 pg.length = maxNBins;
2528 pg.peak = LALCalloc(1, alloc_len = pg.length*sizeof(INT4));
2529 if ( pg.peak == NULL ) {
2530 XLALPrintError ("Failed to LALCalloc ( 1, %d )\n", alloc_len );
2532 }
2533
2534 phmd.fBin = f0Bin;
2535 phmd.maxNBorders = maxNBorders;
2536 phmd.leftBorderP = LALMalloc( alloc_len = maxNBorders*sizeof(HOUGHBorder *));
2537 if ( phmd.leftBorderP == NULL ) {
2538 XLALPrintError ("Failed to LALCalloc ( 1, %d )\n", alloc_len );
2540 }
2541
2542 phmd.rightBorderP = LALMalloc( alloc_len = maxNBorders*sizeof(HOUGHBorder *));
2543 if ( phmd.rightBorderP == NULL ) {
2544 XLALPrintError ("Failed to LALCalloc ( 1, %d )\n", alloc_len );
2546 }
2547
2548 phmd.ySide = ySide;
2549 phmd.firstColumn = LALMalloc( alloc_len = ySide*sizeof(UCHAR));
2550 if ( phmd.firstColumn == NULL ) {
2551 XLALPrintError ("Failed to LALCalloc ( 1, %d )\n", alloc_len );
2553 }
2554
2555 ht.xSide = xSide;
2556 ht.ySide = ySide;
2557 ht.map = LALMalloc( alloc_len = xSide*ySide*sizeof(HoughTT));
2558 if ( ht.map == NULL ) {
2559 XLALPrintError ("Failed to LALCalloc ( 1, %d )\n", alloc_len );
2561 }
2562
2563 hd.xSide = xSide;
2564 hd.ySide = ySide;
2565 hd.map = LALMalloc( alloc_len = (xSide+1)*ySide*sizeof(HoughDT));
2566 if ( hd.map == NULL ) {
2567 XLALPrintError ("Failed to LALCalloc ( 1, %d )\n", alloc_len );
2569 }
2570
2571 /* construct a fake peakgram to print all borders
2572 -- peakgram should be 1,0,1,0,1,0.... */
2573 for (k = 0; k < pg.length; ++k){
2574 /* pg.peak[k] = 4*k+3; */
2575 pg.peak[k] = 2*k;
2576 }
2577
2578 TRY( LALHOUGHPeak2PHMD(status->statusPtr, &phmd, lut, &pg ), status );
2579
2580 TRY( LALHOUGHInitializeHT(status->statusPtr, &ht, patch ), status );
2581
2582 TRY( LALHOUGHInitializeHD(status->statusPtr, &hd), status );
2583
2584 TRY( LALHOUGHAddPHMD2HD(status->statusPtr, &hd, &phmd ), status );
2585
2586 TRY( LALHOUGHIntegrHD2HT(status->statusPtr, &ht, &hd ), status );
2587
2588 for(j = ySide-1; j >= 0; --j){
2589 for(i = 0; i < xSide; ++i){
2590 fprintf(fp ," %f", ht.map[j*xSide +i]);
2591 fflush(fp);
2592 }
2593 fprintf(fp," \n");
2594 fflush(fp);
2595 }
2596
2597 LALFree(pg.peak);
2598
2599 LALFree(phmd.leftBorderP);
2600 LALFree(phmd.rightBorderP);
2601 LALFree(phmd.firstColumn);
2602
2603 LALFree(ht.map);
2604 LALFree(hd.map);
2605
2606 fclose(fp);
2607
2609 RETURN(status);
2610}
2611
2612
2613/** Get Hough candidates as a toplist */
2615 toplist_t *list,
2616 HOUGHMapTotal *ht,
2617 HOUGHPatchGrid *patch,
2618 HOUGHDemodPar *parDem)
2619{
2620 REAL8UnitPolarCoor sourceLocation;
2621 REAL8 deltaF, f0, fdot, dFdot, patchSizeX, patchSizeY;
2622 INT8 f0Bin;
2623 INT4 i,j, xSide, ySide;
2624 SemiCohCandidate thisCandidate;
2625
2628
2629 deltaF = ht->deltaF;
2630 f0Bin = ht->f0Bin;
2631 f0 = f0Bin * deltaF;
2632
2633 fdot = ht->spinDem.data[0] + ht->spinRes.data[0];
2634 dFdot = ht->dFdot.data[0];
2635
2636 xSide = ht->xSide;
2637 ySide = ht->ySide;
2638 patchSizeX = ht->patchSizeX;
2639 patchSizeY = ht->patchSizeY;
2640
2641 thisCandidate.freq = f0;
2642 thisCandidate.dFreq = deltaF;
2643 thisCandidate.fdot = fdot;
2644 thisCandidate.dFdot = dFdot;
2645 thisCandidate.dAlpha = patchSizeX / ((REAL8)xSide);
2646 thisCandidate.dDelta = patchSizeY / ((REAL8)ySide);
2647
2648 for (i = 0; i < ySide; i++)
2649 {
2650 for (j = 0; j < xSide; j++)
2651 {
2652
2653 /* get sky location of pixel */
2654 TRY( LALStereo2SkyLocation (status->statusPtr, &sourceLocation,
2655 j, i, patch, parDem), status);
2656
2657 thisCandidate.alpha = sourceLocation.alpha;
2658 thisCandidate.delta = sourceLocation.delta;
2659 thisCandidate.significance = ht->map[i*xSide + j];
2660
2661 insert_into_toplist(list, &thisCandidate);
2662
2663 } /* end loop over xSide */
2664
2665 } /* end loop over ySide */
2666
2668 RETURN(status);
2669
2670} /* end hough toplist selection */
2671
2672
2673
2674/** Get Hough candidates as a toplist using a fixed threshold*/
2677 HOUGHMapTotal *ht,
2678 HOUGHPatchGrid *patch,
2679 HOUGHDemodPar *parDem,
2680 REAL8 threshold)
2681{
2682 REAL8UnitPolarCoor sourceLocation, sourceLocationBest;
2683 REAL8 deltaF, f0, fdot, dFdot, patchSizeX, patchSizeY;
2684 INT8 f0Bin;
2685 INT4 i,j, xSide, ySide, numCandidates;
2686 SemiCohCandidate thisCandidate;
2687 UINT2 criteria=1;
2688
2691
2692
2696
2701
2702 deltaF = ht->deltaF;
2703 f0Bin = ht->f0Bin;
2704 f0 = f0Bin * deltaF;
2705
2706 fdot = ht->spinDem.data[0] + ht->spinRes.data[0];
2707 dFdot = ht->dFdot.data[0];
2708
2709 xSide = ht->xSide;
2710 ySide = ht->ySide;
2711 patchSizeX = ht->patchSizeX;
2712 patchSizeY = ht->patchSizeY;
2713
2714 numCandidates = out->nCandidates;
2715
2716
2717 /* choose local max and threshold crossing */
2718 if (criteria == 0) {
2719
2720 thisCandidate.freq = f0;
2721 thisCandidate.dFreq = deltaF;
2722 thisCandidate.fdot = fdot;
2723 thisCandidate.dFdot = dFdot;
2724 thisCandidate.dAlpha = 3.0 * patchSizeX / ((REAL8)xSide);
2725 thisCandidate.dDelta = 3.0 * patchSizeY / ((REAL8)ySide);
2726
2727
2728 for (i = 1; i < ySide-1; i++)
2729 {
2730 for (j = 1; j < xSide-1; j++)
2731 {
2732
2733 BOOLEAN isLocalMax = TRUE;
2734
2735 thisCandidate.significance = ht->map[i*xSide + j];
2736
2737 /* check if this is a local maximum */
2738 isLocalMax = (thisCandidate.significance > ht->map[i*xSide + j - 1])
2739 && (thisCandidate.significance > ht->map[i*xSide + j + 1])
2740 && (thisCandidate.significance > ht->map[(i+1)*xSide + j])
2741 && (thisCandidate.significance > ht->map[(i-1)*xSide + j])
2742 && (thisCandidate.significance > ht->map[(i-1)*xSide + j - 1])
2743 && (thisCandidate.significance > ht->map[(i-1)*xSide + j + 1])
2744 && (thisCandidate.significance > ht->map[(i+1)*xSide + j - 1])
2745 && (thisCandidate.significance > ht->map[(i+1)*xSide + j + 1]);
2746
2747 /* realloc list if necessary */
2748 if (numCandidates >= out->length) {
2749 out->length += BLOCKSIZE_REALLOC;
2750 out->list = LALRealloc( out->list, alloc_len = out->length * sizeof(SemiCohCandidate));
2751 if ( out->list == NULL ) {
2752 XLALPrintError ("Failed to LALRealloc ( 1, %d )\n", alloc_len );
2754 }
2755 LogPrintf(LOG_DETAIL, "Need to realloc Hough candidate list to %d entries\n", out->length);
2756 } /* need a safeguard to ensure that the reallocs don't happen too often */
2757
2758 /* add to list if candidate exceeds threshold and there is enough space in list */
2759 if( ((REAL8)thisCandidate.significance > threshold) && (numCandidates < out->length) && isLocalMax) {
2760 /* get sky location of pixel */
2761
2762 TRY( LALStereo2SkyLocation (status->statusPtr, &sourceLocation,
2763 j, i, patch, parDem), status);
2764
2765 /* the above function uses atan2() which returns alpha in
2766 the range [-pi,pi] => add pi to it */
2767 thisCandidate.alpha = sourceLocation.alpha;
2768 thisCandidate.delta = sourceLocation.delta;
2769
2770 out->list[numCandidates] = thisCandidate;
2771 numCandidates++;
2772 out->nCandidates = numCandidates;
2773 }
2774
2775
2776 } /* end loop over xSide */
2777
2778 } /* end loop over ySide */
2779
2780 } /* local maximum criteria for candidate selection */
2781
2782
2783 /* choose global maximum */
2784 if ( criteria == 1) {
2785
2786 REAL8 currentMax;
2787 INT4 jMax, iMax;
2788 REAL8 meanSig, varianceSig;
2789
2790 currentMax = 0.0;
2791 jMax = iMax = 0;
2792
2793 /* loop over hough map to get location of max */
2794 for (i = 0; i < ySide; i++)
2795 {
2796 for (j = 0; j < xSide; j++)
2797 {
2798
2799 if ( ht->map[i*xSide + j] > currentMax ) {
2800 currentMax = ht->map[i*xSide + j];
2801 jMax = j;
2802 iMax = i;
2803 }
2804
2805 } /* end loop over xSide */
2806
2807 } /* end loop over ySide */
2808
2809
2810 thisCandidate.significance = ht->map[iMax*xSide + jMax];
2811
2812 thisCandidate.freq = f0;
2813 thisCandidate.dFreq = deltaF;
2814 thisCandidate.fdot = fdot;
2815 thisCandidate.dFdot = dFdot;
2816 thisCandidate.dAlpha = 3.0 * patchSizeX / ((REAL8)xSide);
2817 thisCandidate.dDelta = 3.0 * patchSizeY / ((REAL8)ySide);
2818
2819 TRY( LALStereo2SkyLocation (status->statusPtr, &sourceLocationBest,
2820 jMax, iMax, patch, parDem), status);
2821
2822 thisCandidate.alphaBest = sourceLocationBest.alpha;
2823 thisCandidate.deltaBest = sourceLocationBest.delta;
2824
2825 TRY( LALHoughmapMeanVariance( status->statusPtr, &meanSig, &varianceSig, ht), status);
2826 thisCandidate.meanSig = meanSig;
2827 thisCandidate.varianceSig = varianceSig;
2828
2829 /* realloc list if necessary */
2830 if (numCandidates >= out->length) {
2831 out->length += BLOCKSIZE_REALLOC;
2832 out->list = LALRealloc( out->list, alloc_len = out->length * sizeof(SemiCohCandidate));
2833 if ( out->list == NULL ) {
2834 XLALPrintError ("Failed to LALRealloc ( 1, %d )\n", alloc_len );
2836 }
2837 LogPrintf(LOG_DETAIL, "Need to realloc Hough candidate list to %d entries\n", out->length);
2838 } /* need a safeguard to ensure that the reallocs don't happen too often */
2839
2840
2841 /* get sky location of pixel */
2842
2843 /* TRY( LALStereo2SkyLocation (status->statusPtr, &sourceLocation, */
2844 /* jMax, iMax, patch, parDem), status); */
2845
2846 /* the above function uses atan2() which returns alpha in
2847 the range [-pi,pi] => add pi to it */
2848 /* thisCandidate.alpha = sourceLocation.alpha + LAL_PI; */
2849 /* thisCandidate.delta = sourceLocation.delta; */
2850
2851 /* return coordinates of hough map center only */
2852 thisCandidate.alpha = parDem->skyPatch.alpha;
2853 thisCandidate.delta = parDem->skyPatch.delta;
2854
2855 out->list[numCandidates] = thisCandidate;
2856 numCandidates++;
2857 out->nCandidates = numCandidates;
2858 }
2859
2861 RETURN(status);
2862
2863} /* end hough threshold selection */
2864
2865
2866
2867
2868
2869/** Print Hough candidates */
2872 FILE *fp,
2873 LIGOTimeGPS refTime)
2874{
2875 INT4 k;
2876 PulsarSpins fkdotIn, fkdotOut;
2877
2880
2881 XLAL_INIT_MEM ( fkdotIn );
2882 XLAL_INIT_MEM ( fkdotOut );
2883
2884 for (k=0; k < in->nCandidates; k++) {
2885 /* fprintf(fp, "%e %e %e %g %g %g %g %e %e\n", in->list[k].significance, in->list[k].freq, */
2886 /* in->list[k].dFreq, in->list[k].alpha, in->list[k].dAlpha, in->list[k].delta, in->list[k].dDelta, */
2887 /* in->list[k].fdot, in->list[k].dFdot); */
2888
2889 fkdotIn[0] = in->list[k].freq;
2890 fkdotIn[1] = in->list[k].fdot;
2891
2892 XLAL_CHECK_LAL( status, XLALExtrapolatePulsarSpins( fkdotOut, fkdotIn, XLALGPSDiff( &refTime, &in->refTime ) ) == XLAL_SUCCESS, XLAL_EFUNC);
2893
2894 fprintf(fp, "%f %f %f %e %f\n", fkdotOut[0], in->list[k].alpha, in->list[k].delta,
2895 fkdotOut[1], in->list[k].significance);
2896 }
2897
2898
2900 RETURN(status);
2901}
2902
2903
2904/** Print Fstat vectors */
2907 FILE *fp,
2908 PulsarDopplerParams *thisPoint,
2909 LIGOTimeGPS refTime,
2910 INT4 stackIndex)
2911{
2912 INT4 length, k;
2914 PulsarSpins fkdot;
2915
2918
2919 XLAL_INIT_MEM(fkdot);
2920
2921 fprintf(fp, "## Fstat values from stack %d (reftime -- %d %d)\n", stackIndex, refTime.gpsSeconds, refTime.gpsNanoSeconds);
2922
2923 alpha = thisPoint->Alpha;
2924 delta = thisPoint->Delta;
2925 fkdot[1] = thisPoint->fkdot[1];
2926 f0 = thisPoint->fkdot[0];
2927
2928 length = in->data->length;
2929 deltaF = in->deltaF;
2930
2931 for (k=0; k<length; k++)
2932 {
2933 fkdot[0] = f0 + k*deltaF;
2934
2935 /* propagate fkdot back to reference-time */
2936 XLAL_CHECK_LAL ( status, XLALExtrapolatePulsarSpins( fkdot, fkdot, XLALGPSDiff( &refTime, &thisPoint->refTime ) ) == XLAL_SUCCESS, XLAL_EFUNC );
2937
2938 fprintf(fp, "%.13g %.7g %.7g %.5g %.6g\n", fkdot[0], alpha, delta, fkdot[1], 2*in->data->data[k]);
2939 }
2940
2941 fprintf(fp, "\n");
2942
2944 RETURN(status);
2945
2946}
2947
2948
2949
2951 toplist_t *list,
2953 REAL8 alpha,
2954 REAL8 delta,
2955 REAL8 fdot)
2956{
2957 INT4 k, length;
2958 REAL8 deltaF, f0;
2960
2963
2964 /* fill up alpha, delta and fdot in fstatline */
2965 line.f1dot = fdot;
2966 line.Alpha = alpha;
2967 line.Delta = delta;
2968
2969 length = in->data->length;
2970 deltaF = in->deltaF;
2971 f0 = in->f0;
2972
2973 /* loop over Fstat vector and fill up toplist */
2974 for ( k=0; k<length; k++)
2975 {
2976
2977 line.HoughFstat = in->data->data[k];
2978 line.Freq = f0 + k*deltaF;
2979
2981
2982 }
2983
2985 RETURN(status);
2986}
2987
2988
2989/** Print hough histogram to a file */
2991 UINT8Vector *hist,
2992 CHAR *fnameOut)
2993{
2994
2995 FILE *fp=NULL; /* Output file */
2996 char filename[256];
2997 UINT4 i ;
2998
3001
3002 strcpy( filename, fnameOut);
3003 strcat( filename, "histo");
3004 if ( !(fp=fopen(filename,"w")))
3005 {
3006 fprintf(stderr, "Unable to open file '%s' for writing\n", filename);
3007 exit(1);
3008 }
3009
3010 for (i=0; i < hist->length; i++)
3011 fprintf(fp,"%d %" LAL_UINT8_FORMAT "\n", i, hist->data[i]);
3012
3013 fclose( fp );
3014
3016 RETURN(status);
3017
3018}
3019
3020
3021/** Print some sft catalog info */
3023 const SFTCatalog *catalog,
3024 FILE *fp)
3025{
3026
3027 INT4 nSFT;
3029
3032
3035
3036 nSFT = catalog->length;
3037 start = catalog->data[0].header.epoch;
3038 end = catalog->data[nSFT-1].header.epoch;
3039
3040 fprintf(fp, "## Number of SFTs: %d\n", nSFT);
3041 fprintf(fp, "## First SFT timestamp: %d %d\n", start.gpsSeconds, start.gpsNanoSeconds);
3042 fprintf(fp, "## Last SFT timestamp: %d %d\n", end.gpsSeconds, end.gpsNanoSeconds);
3043
3045 RETURN(status);
3046
3047}
3048
3049
3050
3051/** Print some stack info from sft catalog sequence*/
3053 const SFTCatalogSequence *catalogSeq,
3054 FILE *fp)
3055{
3056
3057 INT4 nStacks, k;
3058
3061
3066
3067 nStacks = catalogSeq->length;
3068 fprintf(fp, "## Number of stacks: %d\n", nStacks);
3069
3070 for ( k = 0; k < nStacks; k++) {
3071 fprintf(fp, "## Stack No. %d : \n", k+1);
3072 TRY ( PrintCatalogInfo( status->statusPtr, catalogSeq->data + k, fp), status);
3073 }
3074
3075 fprintf(fp, "\n\n");
3076
3078 RETURN(status);
3079
3080}
3081
3082
3083/**
3084 * Read checkpointing file
3085 * This does not (yet) check any consistency of
3086 * the existing results file
3087 */
3089 INT4 *loopindex,
3090 const CHAR *fnameChkPoint)
3091{
3092
3093 FILE *fp=NULL;
3094 UINT4 tmpIndex;
3095 CHAR lastnewline='\0';
3096
3099
3100 /* if something goes wrong later then lopindex will be 0 */
3101 *loopindex = 0;
3102
3103 /* try to open checkpoint file */
3104 if (!(fp = fopen(fnameChkPoint, "rb")))
3105 {
3106 if ( lalDebugLevel )
3107 fprintf (stdout, "Checkpoint-file '%s' not found.\n", fnameChkPoint);
3108
3110 RETURN(status);
3111 }
3112
3113 /* if we are here then checkpoint file has been found */
3114 if ( lalDebugLevel )
3115 fprintf ( stdout, "Found checkpoint-file '%s' \n", fnameChkPoint);
3116
3117 /* check the checkpointfile -- it should just have one integer
3118 and a DONE on the next line */
3119 if ( ( 2 != fscanf (fp, "%" LAL_UINT4_FORMAT "\nDONE%c", &tmpIndex, &lastnewline) ) || ( lastnewline!='\n' ) )
3120 {
3121 fprintf ( stdout, "Failed to read checkpoint index from '%s'!\n", fnameChkPoint);
3122 fclose(fp);
3123
3125 RETURN(status);
3126 }
3127
3128 /* everything seems ok -- set loop index */
3129 *loopindex = tmpIndex;
3130
3131 fclose( fp );
3132
3134 RETURN(status);
3135
3136}
3137
3138/**
3139 * Calculate average velocity and position of detector network during each
3140 * stack
3141 */
3143 REAL8VectorSequence **velStack,
3144 REAL8VectorSequence **posStack,
3145 FstatInputVector* Fstat_in_vec)
3146{
3147 UINT4 k, j, m, nStacks;
3148 INT4 counter, numifo;
3149 CreateVectorSequenceIn createPar;
3150
3153
3154
3160
3161 nStacks = Fstat_in_vec->length;
3162
3163 /* create velocity and position vectors */
3164 createPar.length = nStacks; /* number of vectors */
3165 createPar.vectorLength = 3; /* length of each vector */
3166 TRY( LALDCreateVectorSequence ( status->statusPtr, velStack, &createPar), status);
3167 TRY( LALDCreateVectorSequence ( status->statusPtr, posStack, &createPar), status);
3168
3169
3170 /* calculate detector velocity and position for each stack*/
3171 /* which detector? -- think carefully about this! */
3172 /* Since only the sfts are associated with a detector, the cleanest
3173 solution (unless something better comes up) seems to be to
3174 average the velocities and positions of the ifo within the sft
3175 time intervals in each stack. Thus, for the purposes of the
3176 velocity and position calculation, we can view the sfts as coming
3177 from the a single hypothetical ifo which is moving in a strange
3178 way */
3179
3180 for (k = 0; k < nStacks; k++)
3181 {
3182 const MultiDetectorStateSeries *multiDetStates = XLALGetFstatInputDetectorStates(Fstat_in_vec->data[k]);
3183 counter=0;
3184 numifo = multiDetStates->length;
3185
3186 /* initialize velocities and positions */
3187 velStack[0]->data[3*k] = 0;
3188 velStack[0]->data[3*k+1] = 0;
3189 velStack[0]->data[3*k+2] = 0;
3190
3191 posStack[0]->data[3*k] = 0;
3192 posStack[0]->data[3*k+1] = 0;
3193 posStack[0]->data[3*k+2] = 0;
3194
3195 for ( j = 0; (INT4)j < numifo; j++)
3196 {
3197 INT4 numsft = multiDetStates->data[j]->length;
3198 for ( m = 0; (INT4)m < numsft; m++)
3199 {
3200 /* sum velocity components */
3201 velStack[0]->data[3*k] += multiDetStates->data[j]->data[m].vDetector[0];
3202 velStack[0]->data[3*k+1] += multiDetStates->data[j]->data[m].vDetector[1];
3203 velStack[0]->data[3*k+2] += multiDetStates->data[j]->data[m].vDetector[2];
3204 /* sum position components */
3205 posStack[0]->data[3*k] += multiDetStates->data[j]->data[m].rDetector[0];
3206 posStack[0]->data[3*k+1] += multiDetStates->data[j]->data[m].rDetector[1];
3207 posStack[0]->data[3*k+2] += multiDetStates->data[j]->data[m].rDetector[2];
3208
3209 counter++;
3210
3211 } /* loop over sfts for this ifo */
3212
3213 } /* loop over ifos in stack */
3214
3215 /* divide by 'counter' to get average */
3216 velStack[0]->data[3*k] /= counter;
3217 velStack[0]->data[3*k+1] /= counter;
3218 velStack[0]->data[3*k+2] /= counter;
3219
3220 posStack[0]->data[3*k] /= counter;
3221 posStack[0]->data[3*k+1] /= counter;
3222 posStack[0]->data[3*k+2] /= counter;
3223
3224 } /* loop over stacks -- end velocity and position calculation */
3225
3227 RETURN(status);
3228
3229}
3230
3231
3232/** Calculate noise weight for each stack*/
3234 REAL8Vector **out,
3235 FstatInputVector* Fstat_in_vec )
3236{
3237
3238 INT4 nStacks, k, j, i, numifo, numsft;
3239 REAL8Vector *weightsVec=NULL;
3240
3241
3244
3248
3251
3252 nStacks = Fstat_in_vec->length;
3253
3254 TRY( LALDCreateVector( status->statusPtr, &weightsVec, nStacks), status);
3255
3256
3257 for (k=0; k<nStacks; k++) {
3258
3259 MultiNoiseWeights *multNoiseWts = XLALGetFstatInputNoiseWeights(Fstat_in_vec->data[k]);
3261
3262 numifo = multNoiseWts->length;
3264
3265 /* initialize */
3266 weightsVec->data[k] = 0;
3267
3268 for ( j = 0; j < numifo; j++) {
3269
3270 numsft = multNoiseWts->data[j]->length;
3271
3272 for ( i = 0; i < numsft; i++) {
3273
3274 weightsVec->data[k] += multNoiseWts->data[j]->data[i];
3275
3276 } /* loop over sfts */
3277
3278 }/* loop over ifos in stack */
3279
3280 XLALDestroyMultiNoiseWeights ( multNoiseWts );
3281 } /* loop over stacks*/
3282
3283
3284 LAL_CALL( LALHOUGHNormalizeWeights( status->statusPtr, weightsVec), status);
3285
3286 *out = weightsVec;
3287
3289 RETURN(status);
3290
3291}
3292
3293
3294
3295
3296/** Calculate noise and AM weight for each stack for a given sky position*/
3298 REAL8Vector *out,
3299 FstatInputVector* Fstat_in_vec,
3300 SkyPosition skypos)
3301{
3302
3303 UINT4 nStacks, iStack, iIFO, iSFT, numifo, numsft;
3304 REAL8 a, b, n;
3305 MultiAMCoeffs *multiAMcoef = NULL;
3306
3309
3313
3314 nStacks = Fstat_in_vec->length;
3315
3319
3320
3321 for (iStack=0; iStack<nStacks; iStack++) {
3322
3323 MultiNoiseWeights *multNoiseWts = XLALGetFstatInputNoiseWeights(Fstat_in_vec->data[iStack]);
3325
3326 const MultiDetectorStateSeries *multDetStates = XLALGetFstatInputDetectorStates(Fstat_in_vec->data[iStack]);
3328
3329 numifo = multNoiseWts->length;
3332
3333 /* initialize */
3334 out->data[iStack] = 0;
3335
3336 multiAMcoef = NULL;
3337 XLAL_CHECK_LAL ( status, ( multiAMcoef = XLALComputeMultiAMCoeffs ( multDetStates, NULL, skypos) ) != NULL, XLAL_EFUNC);
3338
3339
3340 for ( iIFO = 0; iIFO < numifo; iIFO++) {
3341
3342 numsft = multNoiseWts->data[iIFO]->length;
3343 ASSERT ( multDetStates->data[iIFO]->length == numsft, status, HIERARCHICALSEARCH_EVAL, HIERARCHICALSEARCH_MSGEVAL );
3344
3345 for ( iSFT = 0; iSFT < numsft; iSFT++) {
3346
3347 a = multiAMcoef->data[iIFO]->a->data[iSFT];
3348 b = multiAMcoef->data[iIFO]->b->data[iSFT];
3349 n = multNoiseWts->data[iIFO]->data[iSFT];
3350
3351 out->data[iStack] += (a*a + b*b)*n;
3352
3353 } /* loop over sfts */
3354
3355 }/* loop over ifos in stack */
3356
3357 XLALDestroyMultiAMCoeffs ( multiAMcoef );
3358 XLALDestroyMultiNoiseWeights ( multNoiseWts );
3359
3360 } /* loop over stacks*/
3361
3362
3363 TRY( LALHOUGHNormalizeWeights( status->statusPtr, out), status);
3364
3366 RETURN(status);
3367
3368}
3369
3370
3371/** Get SemiCoh candidates toplist */
3373 toplist_t *list,
3375 REAL8 meanN,
3376 REAL8 sigmaN)
3377{
3378
3379 INT4 k;
3381
3384
3388
3389 XLAL_INIT_MEM ( line );
3390
3391 /* go through candidates and insert into toplist if necessary */
3392 for ( k = 0; k < in->nCandidates; k++) {
3393
3394 line.Freq = in->list[k].freq;
3395 line.Alpha = in->list[k].alpha;
3396 line.Delta = in->list[k].delta;
3397 line.f1dot = in->list[k].fdot;
3398 line.HoughFstat = (in->list[k].significance - meanN)/sigmaN;
3399 /* for debugging */
3400 /* line.HoughFstat = in->list[k].significance; */
3401 /* if (line.HoughFstat > 121) */
3402 /* fprintf(stdout, "number count exceeded"); */
3403
3404 line.AlphaBest = in->list[k].alphaBest;
3405
3406 if ( line.AlphaBest < 0 ) {
3407 line.AlphaBest += LAL_TWOPI;
3408 }
3409 if ( line.AlphaBest > LAL_TWOPI ) {
3410 line.AlphaBest -= LAL_TWOPI;
3411 }
3412
3413 line.DeltaBest = in->list[k].deltaBest;
3414 line.MeanSig = (in->list[k].meanSig - meanN) / sigmaN;
3415 line.VarianceSig = in->list[k].varianceSig / (sigmaN * sigmaN);
3416
3418 }
3419
3421 RETURN(status);
3422
3423} /* GetSemiCohToplist() */
3424
3425
3426
3427/** Optimized calculation of Fstat overhead */
3430 REAL8 fdot,
3431 REAL8 f0,
3432 REAL8 deltaF)
3433{
3434
3435 UINT4 i, j, nStacks, extraBins2, tmpExtraBins2;
3436 HOUGHptfLUT lut;
3437 HOUGHDemodPar parDem;
3438 HOUGHParamPLUT parLut;
3439 HOUGHSizePar parSize;
3440 HOUGHResolutionPar parRes;
3441 REAL8 tMidStack, tStart, tEnd;
3442 REAL8Vector *timeDiffV=NULL;
3443 HOUGHPatchGrid patch;
3444 REAL8 pixelFactor, alpha, delta, patchSizeX, patchSizeY, refTime;
3445 LIGOTimeGPS refTimeGPS;
3446
3449 LIGOTimeGPSVector *tsMid;
3450
3453
3454 vel = par->vel;
3455 pos = par->pos;
3456 pixelFactor = par->pixelFactor;
3457 fdot = par->fdot;
3458 alpha = par->alpha;
3459 delta = par->delta;
3460 patchSizeX = par->patchSizeX;
3461 patchSizeY = par->patchSizeY;
3462 tsMid = par->tsMid;
3463
3464 refTimeGPS = par->refTime;
3465 refTime = XLALGPSGetREAL8(&refTimeGPS);
3466
3467 nStacks = tsMid->length;;
3468
3469 tStart = XLALGPSGetREAL8(tsMid->data);
3470 tEnd = XLALGPSGetREAL8(tsMid->data + nStacks - 1);
3471 refTime = 0.5 * (tStart + tEnd);
3472
3473 /* the skygrid resolution params */
3474 parRes.deltaF = deltaF;
3475 parRes.patchSkySizeX = patchSizeX;
3476 parRes.patchSkySizeY = patchSizeY;
3477 parRes.pixelFactor = pixelFactor;
3478 parRes.pixErr = PIXERR;
3479 parRes.linErr = LINERR;
3480 parRes.vTotC = VTOT;
3481 parRes.f0Bin = (INT8)(f0/deltaF + 0.5);
3482
3483 TRY( LALHOUGHComputeSizePar( status->statusPtr, &parSize, &parRes ), status );
3484
3485 patch.xSide = parSize.xSide;
3486 patch.ySide = parSize.ySide;
3487 patch.xCoor = NULL;
3488 patch.yCoor = NULL;
3489 patch.xCoor = LALCalloc(1, alloc_len = patch.xSide*sizeof(REAL8));
3490 if ( patch.xCoor == NULL ) {
3491 XLALPrintError ("Failed to LALCalloc ( 1, %d )\n", alloc_len );
3493 }
3494
3495 patch.yCoor = LALCalloc(1, alloc_len = patch.ySide*sizeof(REAL8));
3496 if ( patch.yCoor == NULL ) {
3497 XLALPrintError ("Failed to LALCalloc ( 1, %d )\n", alloc_len );
3499 }
3500
3501 TRY( LALHOUGHFillPatchGrid( status->statusPtr, &patch, &parSize ), status );
3502
3503 /* the demodulation params */
3504 parDem.deltaF = deltaF;
3505 parDem.skyPatch.alpha = alpha;
3506 parDem.skyPatch.delta = delta;
3507 parDem.spin.length = 1;
3508 parDem.spin.data = LALCalloc(1, alloc_len = sizeof(REAL8));
3509 if ( parDem.spin.data == NULL ) {
3510 XLALPrintError ("Failed to LALCalloc ( 1, %d )\n", alloc_len );
3512 }
3513
3514 parDem.spin.data[0] = fdot;
3515
3516 TRY( LALDCreateVector( status->statusPtr, &timeDiffV, nStacks), status);
3517
3518 for (j=0; j<nStacks; j++) {
3519 tMidStack = XLALGPSGetREAL8(tsMid->data + j);
3520 timeDiffV->data[j] = tMidStack - refTime;
3521 }
3522
3523
3524 lut.maxNBins = parSize.maxNBins;
3525 lut.maxNBorders = parSize.maxNBorders;
3526 lut.border = LALCalloc(1, alloc_len = parSize.maxNBorders*sizeof(HOUGHBorder));
3527 if ( lut.border == NULL ) {
3528 XLALPrintError ("Failed to LALCalloc ( 1, %d )\n", alloc_len );
3530 }
3531
3532 lut.bin = LALCalloc(1, alloc_len = parSize.maxNBins*sizeof(HOUGHBin2Border));
3533 if ( lut.bin == NULL ) {
3534 XLALPrintError ("Failed to LALCalloc ( 1, %d )\n", alloc_len );
3536 }
3537
3538 for (i = 0; i < parSize.maxNBorders; i++){
3539 lut.border[i].ySide = parSize.ySide;
3540 lut.border[i].xPixel = LALCalloc(1, alloc_len = parSize.ySide*sizeof(COORType));
3541 if ( lut.border[i].xPixel == NULL ) {
3542 XLALPrintError ("Failed to LALCalloc ( 1, %d )\n", alloc_len );
3544 }
3545 }
3546
3547 /* loop over stacks and create LUTs */
3548 extraBins2 = 0;
3549 for (j=0; j < (UINT4)nStacks; j++){
3550 parDem.veloC.x = vel->data[3*j];
3551 parDem.veloC.y = vel->data[3*j + 1];
3552 parDem.veloC.z = vel->data[3*j + 2];
3553 parDem.positC.x = pos->data[3*j];
3554 parDem.positC.y = pos->data[3*j + 1];
3555 parDem.positC.z = pos->data[3*j + 2];
3556 parDem.timeDiff = timeDiffV->data[j];
3557
3558 /* calculate parameters needed for buiding the LUT */
3559 TRY( LALHOUGHCalcParamPLUT( status->statusPtr, &parLut, &parSize, &parDem),status );
3560 /* build the LUT */
3561 TRY( LALHOUGHConstructPLUT( status->statusPtr, &lut, &patch, &parLut ),
3562 status );
3563
3564 tmpExtraBins2 = HSMAX( abs(lut.iniBin), abs(lut.nBin + lut.iniBin) );
3565
3566 if ( tmpExtraBins2 > extraBins2)
3567 extraBins2 = tmpExtraBins2;
3568 } /* LUTs are created */
3569
3570
3571 par->extraBinsFstat = extraBins2 + 2;
3572
3573 /* now free memory and exit */
3574 TRY( LALDDestroyVector( status->statusPtr, &timeDiffV), status);
3575
3576 LALFree(patch.xCoor);
3577 LALFree(patch.yCoor);
3578
3579 LALFree(parDem.spin.data);
3580
3581 for (i = 0; i < lut.maxNBorders; i++){
3582 LALFree( lut.border[i].xPixel);
3583 }
3584 LALFree( lut.border);
3585 LALFree( lut.bin);
3586
3587
3589 RETURN(status);
3590
3591
3592 /* REAL8 skypos[3], xi[3], xiProj[3], xhat[3], yhat[3]; */
3593 /* REAL8 xiDotn, xiProjX, xiProjY, patchSizeNorm, xiProjNorm; */
3594
3595
3596 /* nStacks = vel->vectorLength; */
3597 /* extraBins = 0; */
3598
3599 /* skypos[0] = cos(delta) * cos(alpha); */
3600 /* skypos[1] = cos(delta) * sin(alpha); */
3601 /* skypos[2] = sin(delta); */
3602
3603 /* xhat[0] = -sin(alpha); */
3604 /* xhat[1] = cos(alpha); */
3605 /* xhat[3] = 0; */
3606
3607 /* yhat[0] = sin(delta)*cos(alpha); */
3608 /* yhat[1] = sin(delta)*sin(alpha); */
3609 /* yhat[2] = -cos(delta); */
3610
3611 /* /\* loop over stacks *\/ */
3612 /* for ( k = 0; k < nStacks; k++) { */
3613
3614 /* UINT4 minBinsPar, minBinsPerp; */
3615
3616
3617 /* xi[0] = vel->data[3*k]; */
3618 /* xi[1] = vel->data[3*k+1]; */
3619 /* xi[2] = vel->data[3*k+2]; */
3620
3621 /* xiDotn = xi[0]*skypos[0] + xi[1]*skypos[1] + xi[2]*skypos[2]; */
3622
3623 /* xiProj[0] = xi[0] - xiDotn * skypos[0]; */
3624 /* xiProj[1] = xi[1] - xiDotn * skypos[1]; */
3625 /* xiProj[2] = xi[2] - xiDotn * skypos[2]; */
3626
3627 /* xiProjX = xiProj[0]*xhat[0] + xiProj[1]*xhat[1] + xiProj[2]*xhat[2]; */
3628 /* xiProjY = xiProj[0]*yhat[0] + xiProj[1]*yhat[1] + xiProj[2]*yhat[2]; */
3629
3630 /* xiProjNorm = sqrt(xiProj[0]*xiProj[0] + xiProj[0]*xiProj[0] + xiProj[0]*xiProj[0]); */
3631 /* patchSizeNorm = patchSizeX*patchSizeX + patchSizeY*patchSizeY; */
3632
3633 /* minBinsPar = (UINT4)(f0 * fabs(xiDotn) * patchSizeNorm /deltaF + 0.5); */
3634
3635 /* minBinsPerp = (UINT4)(f0 * xiProjNorm * patchSizeNorm/ deltaF + 0.5); */
3636
3637 /* extraBinsInThisStack = minBinsPar + minBinsPerp; */
3638
3639 /* if (extraBins < extraBinsInThisStack) */
3640 /* extraBins = extraBinsInThisStack; */
3641
3642 /* } /\* loop over stacks *\/ */
3643
3644
3645
3646} /*ComputeNumExtraBins()*/
3647
3648
3650 HOUGHSizePar *size,
3651 HOUGHDemodPar *par) /* demodulation parameters */
3652{
3653
3654 /* --------------------------------------------- */
3655
3656 REAL8 f0; /* frequency corresponding to f0Bin */
3657 INT8 f0Bin;
3658 REAL8 deltaF; /* df=1/TCOH */
3659 REAL8 vFactor, xFactor;
3660 REAL8 xiX, xiY, xiZ;
3661 REAL8 modXi,invModXi;
3662 REAL8UnitPolarCoor xiInit, xiFinal;
3663 UINT4 spinOrder, i;
3664 REAL8 *spinF;
3665 REAL8 timeDiff; /* T(t)-T(t0) */
3666 REAL8 timeDiffProd;
3667 /* --------------------------------------------- */
3668
3671
3672 /* Make sure the arguments are not NULL: */
3675
3676 /* Make sure f0Bin is not zero: */
3677 f0Bin = size->f0Bin;
3679
3680
3681 deltaF = size->deltaF;
3682
3683 f0 = f0Bin * deltaF;
3684
3685
3686 /* *********** xi calculation ***************** */
3687
3688 vFactor = f0;
3689 xFactor = 0.0;
3690
3691 spinOrder = par->spin.length;
3692
3693 if(spinOrder){
3695 timeDiff = par->timeDiff;
3696 timeDiffProd = 1.0;
3697 spinF = par->spin.data;
3698
3699 for (i=0; i<spinOrder; ++i ){
3700 xFactor += spinF[i] * timeDiffProd * (i+1.0);
3701 timeDiffProd *= timeDiff;
3702 vFactor += spinF[i] * timeDiffProd;
3703 }
3704 }
3705
3706 xiX = vFactor * (par->veloC.x) + xFactor * (par->positC.x);
3707 xiY = vFactor * (par->veloC.y) + xFactor * (par->positC.y);
3708 xiZ = vFactor * (par->veloC.z) + xFactor * (par->positC.z);
3709
3710 /* ------------------------------------------- */
3711 /* ***** convert xi into Polar coordinates ***** */
3712
3713 modXi = sqrt(xiX*xiX + xiY*xiY + xiZ*xiZ);
3714 /* for testing we used: modXi = F0* 1.06e-4; */
3715 invModXi = 1./modXi;
3716
3717 xiInit.delta = asin( xiZ*invModXi);
3718 /* the arc sine is in the interval [-pi/2,pi/2] */
3719
3720 if( xiX || xiY ){
3721 xiInit.alpha = atan2(xiY, xiX);
3722 }else{
3723 xiInit.alpha = 0.0;
3724 }
3725
3726 /* if( (xiX == 0.0 ) && (xiY == 0.0 ) ){ */
3727 /* xiInit.alpha = 0.0; */
3728 /* }else{ xiInit.alpha = atan2(xiY, xiX); } */
3729
3730 /* ------------------------------------------- */
3731 /* **** Rotate Patch, so that its center becomes */
3732 /* **** the south pole {x,y,z} = {0,0,-1} ***** */
3733 /* Calculate xi in the new coordinate system. */
3734
3735 TRY(LALRotatePolarU(status->statusPtr,
3736 &xiFinal ,&xiInit, &(*par).skyPatch), status);
3737
3738
3740
3741 /* normal exit */
3742 RETURN (status);
3743}
#define __func__
log an I/O error, i.e.
void InitDopplerSkyScan(LALStatus *status, DopplerSkyScanState *skyScan, const DopplerSkyScanInit *init)
Definition: DopplerScan.c:273
void FreeDopplerSkyScan(LALStatus *status, DopplerSkyScanState *skyScan)
Definition: DopplerScan.c:324
int XLALNextDopplerSkyPos(PulsarDopplerParams *pos, DopplerSkyScanState *skyScan)
NextDopplerSkyPos(): step through sky-grid return 0 = OK, -1 = ERROR.
Definition: DopplerScan.c:127
@ STATE_FINISHED
all templates have been read
Definition: DopplerScan.h:84
@ GRID_METRIC
generate grid using a 2D sky-metric
Definition: DopplerScan.h:93
int create_toplist(toplist_t **list, size_t length, size_t size, int(*smaller)(const void *, const void *))
Definition: HeapToplist.c:101
void free_toplist(toplist_t **list)
Definition: HeapToplist.c:139
void * toplist_elem(toplist_t *list, size_t ind)
Definition: HeapToplist.c:185
int insert_into_toplist(toplist_t *list, void *element)
Definition: HeapToplist.c:151
#define HIERARCHICALSEARCH_EMEM
#define HIERARCHICALSEARCH_ENONULL
#define HIERARCHICALSEARCH_MSGEXLAL
#define HIERARCHICALSEARCH_MSGENULL
#define HIERARCHICALSEARCH_MSGEFILE
#define HIERARCHICALSEARCH_ENULL
#define HIERARCHICALSEARCH_MSGESFT
#define HIERARCHICALSEARCH_MSGEBAD
#define HIERARCHICALSEARCH_EFILE
#define HIERARCHICALSEARCH_EBAD
#define HIERARCHICALSEARCH_EVAL
#define HIERARCHICALSEARCH_MSGEVAL
#define HIERARCHICALSEARCH_ENORM
#define HIERARCHICALSEARCH_EXLAL
#define HIERARCHICALSEARCH_MSGEMEM
#define HIERARCHICALSEARCH_ESFT
#define HIERARCHICALSEARCH_MSGENONULL
void FstatVectToPeakGram(LALStatus *status, HOUGHPeakGramVector *pgV, REAL4FrequencySeriesVector *FstatVect, REAL4 thr)
Function for selecting frequency bins from a set of Fstatistic vectors.
void SetUpSFTs(LALStatus *status, FstatInputVector **p_Fstat_in_vec, UsefulStageVariables *in)
Set up stacks, read SFTs, calculate SFT noise weights and calculate detector-state.
#define SET_CHECKPOINT
void GetSemiCohToplist(LALStatus *status, toplist_t *list, SemiCohCandidateList *in, REAL8 meanN, REAL8 sigmaN)
Get SemiCoh candidates toplist.
#define FSTART
Default Start search frequency.
void GetChkPointIndex(LALStatus *status, INT4 *loopindex, const CHAR *fnameChkPoint)
Read checkpointing file This does not (yet) check any consistency of the existing results file.
void ComputeStackNoiseWeights(LALStatus *status, REAL8Vector **out, FstatInputVector *Fstat_in_vec)
Calculate noise weight for each stack.
#define MAIN
#define MISMATCH
Default for metric grid maximal mismatch value.
#define INSERT_INTO_HOUGHFSTAT_TOPLIST
#define DDELTA
Default resolution for isotropic or flat grids.
void GetStackVelPos(LALStatus *status, REAL8VectorSequence **velStack, REAL8VectorSequence **posStack, FstatInputVector *Fstat_in_vec)
Calculate average velocity and position of detector network during each stack.
#define BLOCKSIZE_REALLOC
void PrintSemiCohCandidates(LALStatus *status, SemiCohCandidateList *in, FILE *fp, LIGOTimeGPS refTime)
Print Hough candidates.
void SetUpStacks(LALStatus *status, SFTCatalogSequence *out, REAL8 tStack, SFTCatalog *in, UINT4 nStacksMax)
Breaks up input sft catalog into specified number of stacks.
void PrintHmap2file(LALStatus *status, HOUGHMapTotal *ht, CHAR *fnameOut, INT4 iHmap)
Print single Hough map to a specified output file.
#define UNINITIALIZE_COPROCESSOR_DEVICE
BOOLEAN uvar_printGrid
global variable for printing Hough grid
void GetHoughCandidates_toplist(LALStatus *status, toplist_t *list, HOUGHMapTotal *ht, HOUGHPatchGrid *patch, HOUGHDemodPar *parDem)
Get Hough candidates as a toplist.
#define DALPHA
Default resolution for isotropic or flat grids.
void GetFstatCandidates_toplist(LALStatus *status, toplist_t *list, REAL8FrequencySeries *in, REAL8 alpha, REAL8 delta, REAL8 fdot)
void GetXiInSingleStack(LALStatus *status, HOUGHSizePar *size, HOUGHDemodPar *par)
#define COMPUTEFSTATHOUGHMAP
#define LAL_INT4_MAX
LALStatus * global_status
#define REARRANGE_SFT_DATA
BOOLEAN uvar_validateLUT
BOOLEAN uvar_dumpLUT
global variable for printing Hough look-up-tables for debugging
#define INITIALIZE_COPROCESSOR_DEVICE
void DumpLUT2file(LALStatus *status, HOUGHptfLUT *lut, HOUGHPatchGrid *patch, CHAR *basename, INT4 ind)
Print single Hough map to a specified output file.
#define SKYREGION
default sky region to search over – just a single point
void PrintHoughGrid(LALStatus *status, HOUGHPatchGrid *patch, HOUGHDemodPar *parDem, CHAR *fnameOut, INT4 iHmap)
void ComputeFstatHoughMap(LALStatus *status, SemiCohCandidateList *out, HOUGHPeakGramVector *pgV, SemiCoherentParams *params)
Function for calculating Hough Maps and candidates.
#define TRUE
#define FALSE
BOOLEAN uvar_printStats
global variable for calculating Hough map stats
BOOLEAN uvar_printMaps
global variable for printing Hough maps
void ValidateHoughLUT(LALStatus *status, HOUGHptfLUT *lut, HOUGHPatchGrid *patch, CHAR *basename, INT4 ind, REAL4 alpha, REAL4 delta, REAL4 weight)
static int smallerHough(const void *a, const void *b)
#define FDOT
Default value of first spindown.
#define NCAND1
Default number of candidates to be followed up from first stage.
#define HSMAX(x, y)
int alloc_len
void PrintStackInfo(LALStatus *status, const SFTCatalogSequence *catalogSeq, FILE *fp)
Print some stack info from sft catalog sequence.
int gpu_device_id
#define PIXELFACTOR
#define DFDOT
Default range of first spindown parameter.
#define FBAND
Default search band.
void ComputeStackNoiseAndAMWeights(LALStatus *status, REAL8Vector *out, FstatInputVector *Fstat_in_vec, SkyPosition skypos)
Calculate noise and AM weight for each stack for a given sky position.
#define FNAMEOUT
Default output file basename.
#define FSTATTHRESHOLD
Default threshold on Fstatistic for peak selection.
#define HSMIN(x, y)
void PrintFstatVec(LALStatus *status, REAL4FrequencySeries *in, FILE *fp, PulsarDopplerParams *thisPoint, LIGOTimeGPS refTime, INT4 stackIndex)
Print Fstat vectors.
void PrintCatalogInfo(LALStatus *status, const SFTCatalog *catalog, FILE *fp)
Print some sft catalog info.
#define GET_CHECKPOINT(toplist, total, count, outputname, cptname)
void PrintHoughHistogram(LALStatus *status, UINT8Vector *hist, CHAR *fnameOut)
Print hough histogram to a file.
#define SHOW_PROGRESS(rac, dec, tpl_count, tpl_total, freq, fband)
void GetHoughCandidates_threshold(LALStatus *status, SemiCohCandidateList *out, HOUGHMapTotal *ht, HOUGHPatchGrid *patch, HOUGHDemodPar *parDem, REAL8 threshold)
Get Hough candidates as a toplist using a fixed threshold.
void ComputeNumExtraBins(LALStatus *status, SemiCoherentParams *par, REAL8 fdot, REAL8 f0, REAL8 deltaF)
Optimized calculation of Fstat overhead.
Header file for DriveHoughFstat.c.
int create_houghFstat_toplist(toplist_t **tl, UINT8 length)
creates a toplist with length elements, returns -1 on error (usually out of memory),...
void sort_houghFstat_toplist(toplist_t *l)
sorts the toplist with an internal sorting function, used before finally writing it
void free_houghFstat_toplist(toplist_t **l)
frees the space occupied by the toplist
int write_houghFstat_toplist_to_fp(toplist_t *tl, FILE *fp, UINT4 *checksum)
Writes the toplist to an (already open) filepointer Returns the number of written charactes sets the ...
int insert_into_houghFstat_toplist(toplist_t *tl, HoughFstatOutputEntry elem)
Inserts an element in to the toplist either if there is space left or the element is larger than the ...
lal_errhandler_t lal_errhandler
int LAL_ERR_EXIT(LALStatus *stat, const char *func, const char *file, const int line, volatile const char *id)
#define LAL_CALL(function, statusptr)
int j
int k
void LALCheckMemoryLeaks(void)
#define LALRealloc(p, n)
#define LALCalloc(m, n)
#define LALMalloc(n)
#define LALFree(p)
const LALVCSInfoList lalPulsarVCSInfoList
NULL-terminated list of VCS and build information for LALPulsar and its dependencies
const double b1
static double double delta
#define tEnd
#define ABORT(statusptr, code, mesg)
#define XLAL_CHECK_LAL(sp, assertion,...)
#define TRY(func, statusptr)
#define ATTATCHSTATUSPTR(statusptr)
#define ASSERT(assertion, statusptr, code, mesg)
#define DETATCHSTATUSPTR(statusptr)
#define INITSTATUS(statusptr)
#define RETURN(statusptr)
#define STRING(a)
void StackSlideVecF(LALStatus *status, SemiCohCandidateList *out, REAL4FrequencySeriesVector *vecF, SemiCoherentParams *params)
Function StackSlides a vector of Fstat frequency series or any REAL8FrequencySeriesVector.
Header file for StackSlideFstat.c.
#define fscanf
#define fprintf
double e
void LALDDestroyVectorSequence(LALStatus *status, REAL8VectorSequence **vectorSequence)
void LALDCreateVectorSequence(LALStatus *status, REAL8VectorSequence **vectorSequence, CreateVectorSequenceIn *vSeqParams)
const MultiLIGOTimeGPSVector * XLALGetFstatInputTimestamps(const FstatInput *input)
Returns the SFT timestamps stored in a FstatInput structure.
Definition: ComputeFstat.c:701
const MultiLALDetector * XLALGetFstatInputDetectors(const FstatInput *input)
Returns the detector information stored in a FstatInput structure.
Definition: ComputeFstat.c:687
const MultiDetectorStateSeries * XLALGetFstatInputDetectorStates(const FstatInput *input)
Returns the multi-detector state series stored in a FstatInput structure.
Definition: ComputeFstat.c:746
const FstatOptionalArgs FstatOptionalArgsDefaults
Global initializer for setting FstatOptionalArgs to default values.
Definition: ComputeFstat.c:90
void XLALDestroyFstatInputVector(FstatInputVector *inputs)
Free all memory associated with a FstatInputVector structure.
Definition: ComputeFstat.c:252
MultiNoiseWeights * XLALGetFstatInputNoiseWeights(const FstatInput *input)
Returns the multi-detector noise weights stored in a FstatInput structure.
Definition: ComputeFstat.c:716
FstatInputVector * XLALCreateFstatInputVector(const UINT4 length)
Create a FstatInputVector of the given length, for example for setting up F-stat searches over severa...
Definition: ComputeFstat.c:231
FstatQuantities
Bit-field of -statistic quantities which can be computed by XLALComputeFstat().
Definition: ComputeFstat.h:94
FstatInput * XLALCreateFstatInput(const SFTCatalog *SFTcatalog, const REAL8 minCoverFreq, const REAL8 maxCoverFreq, const REAL8 dFreq, const EphemerisData *ephemerides, const FstatOptionalArgs *optionalArgs)
Create a fully-setup FstatInput structure for computing the -statistic using XLALComputeFstat().
Definition: ComputeFstat.c:359
int XLALComputeFstat(FstatResults **Fstats, FstatInput *input, const PulsarDopplerParams *doppler, const UINT4 numFreqBins, const FstatQuantities whatToCompute)
Compute the -statistic over a band of frequencies.
Definition: ComputeFstat.c:760
void XLALDestroyFstatResults(FstatResults *Fstats)
Free all memory associated with a FstatResults structure.
Definition: ComputeFstat.c:934
@ FMETHOD_DEMOD_BEST
Demod: best guess of the fastest available hotloop
Definition: ComputeFstat.h:121
@ FSTATQ_2F
Compute multi-detector .
Definition: ComputeFstat.h:96
int XLALExtrapolatePulsarSpinRange(PulsarSpinRange *range1, const PulsarSpinRange *range0, const REAL8 dtau)
General pulsar-spin extrapolation function: given a "spin-range" (ie spins + spin-bands) range0 at ti...
int XLALExtrapolatePulsarSpins(PulsarSpins fkdot1, const PulsarSpins fkdot0, REAL8 dtau)
Extrapolate the Pulsar spin-parameters (fkdot0) from the initial reference-epoch to the new referen...
void LALStereo2SkyLocation(LALStatus *status, REAL8UnitPolarCoor *sourceLocation, UINT2 xPos, UINT2 yPos, HOUGHPatchGrid *patch, HOUGHDemodPar *parDem)
Find source sky location given stereographic coordinates indexes.
Definition: HoughMap.c:405
void LALHOUGHInitializeHD(LALStatus *status, HOUGHMapDeriv *hd)
This function initializes the Hough map derivative space HOUGHMapDeriv *hd to zero.
Definition: HoughMap.c:31
REAL8 HoughTT
Total Hough Map pixel type.
Definition: HoughMap.h:113
void LALHOUGHAddPHMD2HD(LALStatus *status, HOUGHMapDeriv *hd, HOUGHphmd *phmd)
Given an initial Hough map derivative HOUGHMapDeriv *hd and a representation of a phmd HOUGHphmd *phm...
Definition: HoughMap.c:123
void LALHOUGHIntegrHD2HT(LALStatus *status, HOUGHMapTotal *ht, HOUGHMapDeriv *hd)
This function constructs a total Hough map HOUGHMapTotal *ht from its derivative HOUGHMapDeriv *hd by...
Definition: HoughMap.c:353
void LALHOUGHInitializeHT(LALStatus *status, HOUGHMapTotal *ht, HOUGHPatchGrid *patch)
This function initializes the total Hough map HOUGHMapTotal *ht to zero and checks consistency betwee...
Definition: HoughMap.c:74
EphemerisData * XLALInitBarycenter(const CHAR *earthEphemerisFile, const CHAR *sunEphemerisFile)
XLAL interface to reading ephemeris files 'earth' and 'sun', and return ephemeris-data in old backwar...
void XLALDestroyEphemerisData(EphemerisData *edat)
Destructor for EphemerisData struct, NULL robust.
void XLALDestroyMultiAMCoeffs(MultiAMCoeffs *multiAMcoef)
Destroy a MultiAMCoeffs structure.
Definition: LALComputeAM.c:469
MultiAMCoeffs * XLALComputeMultiAMCoeffs(const MultiDetectorStateSeries *multiDetStates, const MultiNoiseWeights *multiWeights, SkyPosition skypos)
Multi-IFO version of XLALComputeAMCoeffs().
Definition: LALComputeAM.c:379
#define LAL_TWOPI
unsigned char BOOLEAN
#define XLAL_INIT_MEM(x)
unsigned char UCHAR
uint64_t UINT8
double REAL8
#define XLAL_INIT_DECL(var,...)
int64_t INT8
uint16_t UINT2
char CHAR
uint32_t UINT4
int32_t INT4
float REAL4
#define lalDebugLevel
void LALHOUGHConstructHMT_W(LALStatus *status, HOUGHMapTotal *ht, UINT8FrequencyIndexVector *freqInd, PHMDVectorSequence *phmdVS)
Calculates the total hough map for a given trajectory in the time-frequency plane and a set of partia...
Definition: DriveHough.c:474
void LALHOUGHConstructSpacePHMD(LALStatus *status, PHMDVectorSequence *phmdVS, HOUGHPeakGramVector *pgV, HOUGHptfLUTVector *lutV)
constructs the space of phmd PHMDVectorSequence *phmdVS, given a HOUGHPeakGramVector *pgV and HOUGHpt...
Definition: DriveHough.c:54
void LALHOUGHNormalizeWeights(LALStatus *status, REAL8Vector *weightV)
Normalizes weight factors so that their sum is N.
Definition: DriveHough.c:668
void LALHOUGHWeighSpacePHMD(LALStatus *status, PHMDVectorSequence *phmdVS, REAL8Vector *weightV)
Adds weight factors for set of partial hough map derivatives – the weights must be calculated outside...
Definition: DriveHough.c:580
void LALHOUGHInitializeWeights(LALStatus *status, REAL8Vector *weightV)
Initializes weight factors to unity.
Definition: DriveHough.c:633
void LALHOUGHupdateSpacePHMDup(LALStatus *status, PHMDVectorSequence *phmdVS, HOUGHPeakGramVector *pgV, HOUGHptfLUTVector *lutV)
This function updates the space of phmd increasing the frequency phmdVS->fBinMin by one.
Definition: DriveHough.c:130
void XLALFree(void *p)
#define LAL_INT8_FORMAT
#define LAL_UINT8_FORMAT
#define LAL_UINT4_FORMAT
char char * XLALStringDuplicate(const char *s)
char * XLALVCSInfoString(const LALVCSInfoList vcs_list, const int verbose, const char *prefix)
void LALRotatePolarU(LALStatus *status, REAL8UnitPolarCoor *out, REAL8UnitPolarCoor *in, REAL8UnitPolarCoor *par)
Definition: Stereographic.c:97
#define VTOT
Total detector velocity/c TO BE CHANGED DEPENDING ON DETECTOR.
Definition: LUT.h:207
#define PIXERR
Maximum `‘error’' (as a fraction of the width of the thinnest annulus) which allows to consider two b...
Definition: LUT.h:195
#define LINERR
Maximum `‘error’' (as a fraction of the width of the thinnest annulus) which allows to represent a ci...
Definition: LUT.h:188
void LALHOUGHFillPatchGrid(LALStatus *status, HOUGHPatchGrid *out, HOUGHSizePar *par)
Definition: PatchGrid.c:331
#define VEPI
Earth v_epicycle/c TO BE CHANGED DEPENDING ON DETECTOR.
Definition: LUT.h:202
void LALHOUGHConstructPLUT(LALStatus *status, HOUGHptfLUT *lut, HOUGHPatchGrid *patch, HOUGHParamPLUT *par)
void LALHOUGHCalcParamPLUT(LALStatus *status, HOUGHParamPLUT *out, HOUGHSizePar *sizePar, HOUGHDemodPar *par)
Definition: ParamPLUT.c:71
void LALHOUGHComputeSizePar(LALStatus *status, HOUGHSizePar *out, HOUGHResolutionPar *in)
Definition: PatchGrid.c:92
INT2 COORType
To be changed to {INT2 COORType} if the number of pixels in the x-direction exceeds 255.
Definition: LUT.h:218
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_CRITICAL
LOG_DEBUG
LOG_DETAIL
REAL8 HoughDT
Hough Map derivative pixel type.
Definition: PHMD.h:121
void LALHOUGHPeak2PHMD(LALStatus *status, HOUGHphmd *phmd, HOUGHptfLUT *lut, HOUGHPeakGram *pg)
Construction of Partial-Hough-Map-Derivatives (phmd) given a peak-gram and the look-up-table.
Definition: Peak2PHMD.c:61
void XLALDestroyMultiNoiseWeights(MultiNoiseWeights *weights)
Destroy a MultiNoiseWeights object.
Definition: PSDutils.c:172
@ LAL_PMETRIC_COH_PTOLE_ANALYTIC
Definition: PtoleMetric.h:97
REAL8 PulsarSpins[PULSAR_MAX_SPINS]
Typedef for fixed-size array holding GW frequency and derivatives fk = d^k Freq/dt^k|(tau_ref)
static const INT4 m
static const INT4 a
void XLALDestroySFTCatalog(SFTCatalog *catalog)
Free an 'SFT-catalogue'.
Definition: SFTcatalog.c:329
int XLALCheckCRCSFTCatalog(BOOLEAN *crc_check, SFTCatalog *catalog)
This function reads in the SFTs in the catalog and validates their CRC64 checksums.
Definition: SFTcatalog.c:524
LIGOTimeGPSVector * XLALCreateTimestampVector(UINT4 len)
Allocate a LIGOTimeGPSVector.
Definition: SFTtimestamps.c:47
SFTCatalog * XLALSFTdataFind(const CHAR *file_pattern, const SFTConstraints *constraints)
Find the list of SFTs matching the file_pattern and satisfying the given constraints,...
Definition: SFTcatalog.c:71
void XLALDestroyTimestampVector(LIGOTimeGPSVector *vect)
De-allocate a LIGOTimeGPSVector.
Definition: SFTtimestamps.c:69
const UserChoices SSBprecisionChoices
Static array of all SSBprecision choices, for use by the UserInput module parsing routines.
Definition: SSBtimes.c:41
COORDINATESYSTEM_EQUATORIAL
void LALHoughStatistics(LALStatus *status, HoughStats *out, HOUGHMapTotal *in)
This function calculates the maximum number count, minimum number count, average and standard deviati...
void LALHoughHistogram(LALStatus *status, UINT8Vector *out, HOUGHMapTotal *in)
Produces a histogram of the number counts in a total Hough map.
void LALHoughmapMeanVariance(LALStatus *status, REAL8 *mean, REAL8 *variance, HOUGHMapTotal *in)
int XLALUserVarReadAllInput(BOOLEAN *should_exit, int argc, char *argv[], const LALVCSInfoList vcs_list)
void XLALDestroyUserVars(void)
void CHAR * XLALUserVarGetLog(UserVarLogFormat format)
#define XLALRegisterNamedUvar(cvar, name, type, option, category,...)
int XLALUserVarWasSet(const void *cvar)
#define XLALRegisterNamedUvarAuxData(cvar, name, type, cdata, option, category,...)
UVAR_LOGFMT_CFGFILE
void LALDCreateVector(LALStatus *, REAL8Vector **, UINT4)
void LALDDestroyVector(LALStatus *, REAL8Vector **)
#define xlalErrno
#define XLAL_CHECK(assertion,...)
#define XLAL_CHECK_MAIN(assertion,...)
int XLALPrintError(const char *fmt,...) _LAL_GCC_PRINTF_FORMAT_(1
XLAL_ENOMEM
XLAL_SUCCESS
XLAL_EFUNC
LIGOTimeGPS * XLALGPSSetREAL8(LIGOTimeGPS *epoch, REAL8 t)
LIGOTimeGPS * XLALGPSAdd(LIGOTimeGPS *epoch, REAL8 dt)
REAL8 XLALGPSGetREAL8(const LIGOTimeGPS *epoch)
REAL8 XLALGPSDiff(const LIGOTimeGPS *t1, const LIGOTimeGPS *t0)
long long count
Definition: hwinject.c:371
pos
size
end
n
out
int deltaF
CHAR * uvar_skyRegion
REAL8 uvar_dAlpha
REAL8 uvar_refTime
REAL8 uvar_dDelta
CHAR * uvar_ephemEarth
Earth ephemeris file to use.
INT4 uvar_blocksRngMed
CHAR * uvar_ephemSun
Sun ephemeris file to use.
double alpha
REAL4Vector * b
(weighted) per-SFT antenna-pattern function
Definition: LALComputeAM.h:65
REAL4Vector * a
(weighted) per-SFT antenna-pattern function
Definition: LALComputeAM.h:64
REAL8 vDetector[3]
Cart.
REAL8 rDetector[3]
Cartesian coords of detector position in ICRS J2000.
DetectorState * data
array of DetectorState entries
UINT4 length
total number of entries
LALDetector detector
detector-info corresponding to this timeseries
initialization-structure passed to InitDopplerSkyScan()
Definition: DopplerScan.h:134
const EphemerisData * ephemeris
ephemeris-data for "exact" metric
Definition: DopplerScan.h:145
BOOLEAN projectMetric
project the metric orthogonal to Freq?
Definition: DopplerScan.h:143
UINT4 numSkyPartitions
number of (roughly) equal partitions to split sky-grid into
Definition: DopplerScan.h:147
UINT4 partitionIndex
index of requested sky-grid partition: in [0, numPartitions - 1]
Definition: DopplerScan.h:148
const CHAR * skyGridFile
file containing a sky-grid (list of points) if GRID_FILE
Definition: DopplerScan.h:146
LIGOTimeGPS obsBegin
GPS start-time of time-series.
Definition: DopplerScan.h:141
REAL8 dDelta
sky step-sizes for GRID_FLAT and GRID_ISOTROPIC
Definition: DopplerScan.h:139
REAL8 Freq
Frequency for which to build the skyGrid.
Definition: DopplerScan.h:136
DopplerGridType gridType
which type of skygrid to generate
Definition: DopplerScan.h:137
REAL8 obsDuration
length of time-series in seconds
Definition: DopplerScan.h:142
REAL8 metricMismatch
for GRID_METRIC
Definition: DopplerScan.h:140
LALPulsarMetricType metricType
which metric to use if GRID_METRIC
Definition: DopplerScan.h:138
CHAR * skyRegionString
sky-region to search: format polygon '(a1,d1), (a2,d2), ..'
Definition: DopplerScan.h:135
const LALDetector * Detector
Current detector.
Definition: DopplerScan.h:144
this structure reflects the current state of a DopplerSkyScan
Definition: DopplerScan.h:152
This structure contains all information about the center-of-mass positions of the Earth and Sun,...
A vector of XLALComputeFstat() input data structures, for e.g.
Definition: ComputeFstat.h:82
FstatInput ** data
Pointer to the data array.
Definition: ComputeFstat.h:87
UINT4 length
Number of elements in array.
Definition: ComputeFstat.h:86
Struct of optional 'advanced level' and (potentially method-specific) arguments to be passed to the ...
Definition: ComputeFstat.h:137
UINT4 runningMedianWindow
If SFT noise weights are calculated from the SFTs, the running median window length to use.
Definition: ComputeFstat.h:141
UINT4 Dterms
Number of Dirichlet kernel terms, used by some Demod methods; see FstatMethodType.
Definition: ComputeFstat.h:140
FstatMethodType FstatMethod
Method to use for computing the -statistic.
Definition: ComputeFstat.h:142
SSBprecision SSBprec
Barycentric transformation precision.
Definition: ComputeFstat.h:139
XLALComputeFstat() computed results structure.
Definition: ComputeFstat.h:202
REAL4 * twoF
If whatWasComputed & FSTATQ_2F is true, the multi-detector values computed at numFreqBins frequencie...
Definition: ComputeFstat.h:242
This structure stores the border indexes corresponding to one frequency bin plus the corrections to b...
Definition: LUT.h:234
This structure stores the border of a circle clipped on the projected plane.
Definition: LUT.h:221
COORType * xPixel
x pixel index to be marked
Definition: LUT.h:226
UINT2 ySide
length of xPixel
Definition: LUT.h:225
Demodulation parameters needed for the Hough transform; all coordinates are assumed to be with respec...
Definition: LUT.h:353
REAL8Cart3Coor positC
(x,y,z): Position of the detector
Definition: LUT.h:357
REAL8 deltaF
Frequency resolution: df=1/TCOH
Definition: LUT.h:354
REAL8 timeDiff
: time difference
Definition: LUT.h:358
REAL8Cart3Coor veloC
(x,y,z): Relative detector velocity
Definition: LUT.h:356
REAL8Vector spin
Spin down information.
Definition: LUT.h:359
REAL8UnitPolarCoor skyPatch
(alpha, delta): position of the center of the patch
Definition: LUT.h:355
This structure stores the Hough map derivative.
Definition: HoughMap.h:121
UINT2 ySide
number of physical pixels in the y direction
Definition: HoughMap.h:123
UINT2 xSide
number of physical pixels in the x direction
Definition: HoughMap.h:122
HoughDT * map
the pixel count derivatives; the number of elements to allocate is ySide*(xSide+1)*
Definition: HoughMap.h:124
This structure stores the Hough map.
Definition: HoughMap.h:130
UINT2 ySide
number of physical pixels in the y direction
Definition: HoughMap.h:142
UINT2 xSide
number of physical pixels in the x direction
Definition: HoughMap.h:141
HoughTT * map
the pixel counts; the number of elements to allocate is ySide*xSide
Definition: HoughMap.h:143
REAL8Vector dFdot
resolution in spindown parameters
Definition: HoughMap.h:140
REAL8Vector spinRes
Refined spin parameters used in the Hough transform.
Definition: HoughMap.h:139
REAL8UnitPolarCoor skyPatch
Coordinates of the versor (alpha, delta) pointing to the center of the sky patch.
Definition: HoughMap.h:137
INT8 f0Bin
frequency bin for which it has been constructed
Definition: HoughMap.h:131
UINT4 mObsCoh
ratio of observation time and coherent timescale
Definition: HoughMap.h:133
REAL8 patchSizeX
x size of patch
Definition: HoughMap.h:135
REAL8 deltaF
frequency resolution
Definition: HoughMap.h:132
REAL8 patchSizeY
y size of patch
Definition: HoughMap.h:136
REAL8Vector spinDem
Spin parameters used in the demodulation stage.
Definition: HoughMap.h:138
Parameters needed to construct the partial look up table.
Definition: LUT.h:333
This structure stores patch-frequency grid information.
Definition: LUT.h:264
UINT2 ySide
Real number of pixels in the y-direction (in the projected plane).
Definition: LUT.h:275
REAL8 * xCoor
Coordinates of the pixel centers.
Definition: LUT.h:271
UINT2 xSide
Real number of pixels in the x direction (in the projected plane); it should be less than or equal to...
Definition: LUT.h:270
REAL8 * yCoor
Coordinates of the pixel centers.
Definition: LUT.h:278
This structure stores the `‘peak-gram’'.
Definition: PHMD.h:129
REAL8 deltaF
Frequency resolution: df=1/TCOH
Definition: PHMD.h:131
UINT4 length
Number of peaks present in the peak-gram.
Definition: PHMD.h:134
UINT8 fBinFin
Frequency index of the last element of the spectrum covered by this peak-gram.
Definition: PHMD.h:133
UINT8 fBinIni
Frequency index of the first element of the spectrum covered by this peak-gram; it can be seen as an ...
Definition: PHMD.h:132
INT4 * peak
The peak indices relative to fBinIni, i.e., the zero peak corresponds to fBinIni.
Definition: PHMD.h:135
This structure contains a vector of peak-grams (for the different time stamps)
Definition: LALHough.h:167
UINT4 length
number of elements
Definition: LALHough.h:168
HOUGHPeakGram * pg
the Peakgrams
Definition: LALHough.h:169
parameters needed for gridding the patch
Definition: LUT.h:282
REAL8 deltaF
Frequency resolution: df=1/TCOH
Definition: LUT.h:284
REAL8 pixErr
for validity of LUT as PIXERR
Definition: LUT.h:288
INT8 f0Bin
Frequency bin at which construct the grid.
Definition: LUT.h:283
REAL8 patchSkySizeY
Patch size in radians along y-axis.
Definition: LUT.h:286
REAL8 patchSkySizeX
Patch size in radians along x-axis.
Definition: LUT.h:285
REAL8 pixelFactor
number of pixel that fit in the thinnest annulus
Definition: LUT.h:287
REAL8 vTotC
estimate value of v-total/C as VTOT
Definition: LUT.h:290
REAL8 linErr
as LINERR circle ->line
Definition: LUT.h:289
required for constructing patch
Definition: LUT.h:294
UINT2 maxNBorders
maximum number of borders affecting the patch; for memory allocation
Definition: LUT.h:302
UINT2 maxNBins
maximum number of bins affecting the patch; for memory allocation
Definition: LUT.h:301
UINT2 ySide
number of pixels in the y direction
Definition: LUT.h:300
INT8 nFreqValid
number of frequencies where the LUT is valid
Definition: LUT.h:303
UINT2 xSide
number of pixels in the x direction (projected plane)
Definition: LUT.h:299
This structure stores a partial Hough map derivative.
Definition: PHMD.h:141
UINT8 fBin
Frequency bin of this partial map derivative.
Definition: PHMD.h:142
UCHAR * firstColumn
Number of elements of firstColumn.
Definition: PHMD.h:151
UINT2 ySide
number of elements of firstColumn
Definition: PHMD.h:150
HOUGHBorder ** rightBorderP
Pointers to borders.
Definition: PHMD.h:149
UINT2 maxNBorders
Maximun number of borders of each type (for memory allocation purposes), i.e. length of *leftBorderP ...
Definition: PHMD.h:145
HOUGHBorder ** leftBorderP
Pointers to borders.
Definition: PHMD.h:148
This structure stores the patch-time-frequency look up table.
Definition: LUT.h:246
REAL8 deltaF
Frequency resolution df=1/TCOH, where 1/TCOH is the coherent integration time used in teh demodulatio...
Definition: LUT.h:249
UINT2 maxNBins
Maximum number of bins affecting the patch (for memory allocation purposes)
Definition: LUT.h:256
INT4 nBin
Exact number of bins affecting the patch.
Definition: LUT.h:254
HOUGHBorder * border
The annulus borders.
Definition: LUT.h:258
INT4 iniBin
First bin affecting the patch with respect to f0.
Definition: LUT.h:253
HOUGHBin2Border * bin
Bin to border correspondence.
Definition: LUT.h:259
UINT2 maxNBorders
Maximum number of borders affecting the patch (for memory allocation purposes)
Definition: LUT.h:257
INT8 f0Bin
Frequency bin for which it has been constructed.
Definition: LUT.h:248
This structure contains a vector of partial look up tables (for the different time stamps)
Definition: LALHough.h:173
HOUGHptfLUT * lut
the partial Look Up Tables
Definition: LALHough.h:175
UINT4 length
number of elements
Definition: LALHough.h:174
Type to hold the fields that will be kept in a "toplist"
Structure for storing statistical information about a Hough map.
LALFrDetector frDetector
CHAR prefix[3]
INT4 gpsNanoSeconds
A vector of 'timestamps' of type LIGOTimeGPS.
Definition: SFTfileIO.h:188
LIGOTimeGPS * data
array of timestamps
Definition: SFTfileIO.h:193
UINT4 length
number of timestamps
Definition: SFTfileIO.h:192
Multi-IFO container for antenna-pattern coefficients and atenna-pattern matrix .
Definition: LALComputeAM.h:137
AMCoeffs ** data
noise-weighted AM-coeffs , and
Definition: LALComputeAM.h:142
Multi-IFO time-series of DetectorStates.
UINT4 length
number of detectors
DetectorStateSeries ** data
vector of pointers to DetectorStateSeries
array of detectors definitions 'LALDetector'
LALDetector sites[PULSAR_MAX_DETECTORS]
array of site information
A collection of (multi-IFO) LIGOTimeGPSVector time-stamps vectors.
Definition: SFTfileIO.h:198
One noise-weight (number) per SFT (therefore indexed over IFOs and SFTs.
Definition: PSDutils.h:71
UINT4 length
number of detectors
Definition: PSDutils.h:75
REAL8Vector ** data
weights-vector for each detector
Definition: PSDutils.h:76
This structure contains a vector sequence of partial-Hough maps derivatives (for different time stamp...
Definition: LALHough.h:189
UINT8 fBinMin
frequency index of smallest intrinsic frequency in circular buffer
Definition: LALHough.h:192
UINT4 nfSize
number of different frequencies
Definition: LALHough.h:190
REAL8 deltaF
frequency resolution
Definition: LALHough.h:193
HOUGHphmd * phmd
the partial Hough map derivatives
Definition: LALHough.h:195
UINT4 length
number of elements for each frequency
Definition: LALHough.h:191
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.
REAL8 asini
Binary: projected, normalized orbital semi-major axis (s).
Contains a "spin-range", ie spins and corresponding bands at a given (SSB) reference GPS-time .
PulsarSpins fkdot
Vector of spin-values .
LIGOTimeGPS refTime
SSB reference GPS-time at which spin-range is defined.
PulsarSpins fkdotBand
Vector of spin-bands , MUST be same length as fkdot.
REAL4Sequence * data
A vector of REAL4FrequencySeries.
REAL4FrequencySeries * data
Pointer to the data array.
UINT4 length
Number of elements in array.
REAL4 * data
REAL8 y
Definition: LUT.h:310
REAL8 x
Definition: LUT.h:309
REAL8 z
Definition: LUT.h:311
REAL8Sequence * data
Polar coordinates of a unitary vector on the sphere.
Definition: LUT.h:327
REAL8 alpha
any value
Definition: LUT.h:328
REAL8 delta
In the interval [ ].
Definition: LUT.h:329
REAL8 * data
An "SFT-catalogue": a vector of SFTdescriptors, as returned by XLALSFTdataFind()
Definition: SFTfileIO.h:238
SFTDescriptor * data
array of data-entries describing matched SFTs
Definition: SFTfileIO.h:243
UINT4 length
number of SFTs in catalog
Definition: SFTfileIO.h:242
sequence of SFT catalogs – for each segment
SFTCatalog * data
the catalogs
UINT4 length
the number of stacks
'Constraints' for SFT-matching: which detector, within which time-stretch and which timestamps exactl...
Definition: SFTfileIO.h:212
LIGOTimeGPS * maxStartTime
only include SFTs whose epoch is < maxStartTime
Definition: SFTfileIO.h:215
LIGOTimeGPS * minStartTime
only include SFTs whose epoch is >= minStartTime
Definition: SFTfileIO.h:214
A 'descriptor' of an SFT: basically containing the header-info plus an opaque description of where ex...
Definition: SFTfileIO.h:226
SFTtype header
SFT-header info.
Definition: SFTfileIO.h:228
one hough or stackslide candidate
REAL8 varianceSig
variance of significance values in Hough map
REAL8 dDelta
delta error
REAL8 deltaBest
delta for best candidate in hough map
REAL8 dFdot
fdot error
REAL8 dAlpha
alpha error
REAL8 meanSig
mean of significance values in hough map
REAL8 alpha
right ascension
REAL8 freq
frequency
REAL8 dFreq
frequency error
REAL8 alphaBest
alpha for best candidate in hough map
REAL8 significance
significance
REAL8 delta
declination
structure for storing candidates produced by Hough search
SemiCohCandidate * list
LIGOTimeGPS refTime
reference time for candidates
INT4 length
maximum allowed length of vectors
INT4 nCandidates
number of candidates – must be less than length
parameters for the semicoherent stage
REAL8 patchSizeX
Size of semicoherent sky-patch.
REAL8 patchSizeY
Size of semicoherent sky-patch.
REAL8 alpha
right ascension of demodulation point
REAL8 dfdot
resolution in residual spindowns
REAL8VectorSequence * pos
Earth orbital position for each segment.
LIGOTimeGPSVector * tsMid
timestamps of mid points of segments
REAL8 fdot
spindown value of demodulation point
BOOLEAN useToplist
Use a toplist for producing candidates?
REAL8 pixelFactor
Resolution of semicoherent sky-grid.
CHAR * outBaseName
file for writing output – if chosen
REAL8 delta
declination of demodulation point
LIGOTimeGPS refTime
reference time for f, fdot definition
REAL8VectorSequence * vel
Earth orbital velocity for each segment.
REAL8Vector * weightsV
Vector of weights for each stack.
REAL8 threshold
Threshold for candidate selection.
UINT4 nfdot
number of fdot values to search over
UINT4 extraBinsFstat
Extra bins required for Fstat calculation.
REAL8 longitude
REAL8 latitude
CoordinateSystem system
This structure stores the frequency indexes of the partial-Hough map derivatives at different time st...
Definition: LALHough.h:149
UINT8 * data
the frequency indexes
Definition: LALHough.h:152
REAL8 deltaF
frequency resolution
Definition: LALHough.h:151
UINT4 length
number of elements
Definition: LALHough.h:150
UINT8 * data
useful variables for each hierarchical stage
LIGOTimeGPSVector * startTstack
timestamps vector for start time of each stack
PulsarSpinRange spinRange_refTime
freq and fdot range at the reference time
REAL8 tObs
tEndGPS - tStartGPS
LIGOTimeGPS tStartGPS
start and end time of stack
UINT4 nStacks
number of stacks
PulsarSpinRange spinRange_startTime
freq and fdot range at start-time of observation
PulsarSpinRange spinRange_midTime
freq and fdot range at mid-time of observation
REAL8 tStack
duration of stacks
REAL8 dFreqStack
frequency resolution of Fstat calculation
PulsarSpinRange spinRange_endTime
freq and fdot range at end-time of observation
REAL8 refTime
reference time for pulsar params
LIGOTimeGPS maxStartTimeGPS
all sft timestamps must be before this GPS time
UINT4 Dterms
size of Dirichlet kernel for Fstat calculation
EphemerisData * edat
ephemeris data for XLALBarycenter
LIGOTimeGPS minStartTimeGPS
all sft data must be after this time
REAL8 dopplerMax
extra sft wings for doppler motion
CHAR * sftbasename
filename pattern for sfts
LIGOTimeGPSVector * midTstack
timestamps vector for mid time of each stack
int SSBprec
SSB transform precision.
UINT4 blocksRngMed
blocksize for running median noise floor estimation
size_t elems
Definition: HeapToplist.h:37