XLALmergeMultiFstatAtomsBinned: fix subtle i<->j index swap in timestamps assignment
Description
@karl-wette here's something in the transient-Fstat code I noticed last year and corrected in my branch used for the O2 paper, but apparently never merged to master. Since it's a fairly obscure function that probably nobody besides Reinhard and me has ever used, here's a doxygen link to what it does.
The issue and changes:
- merged atoms had the right data assigned from the input SFTs, but potentially the wrong timestamps
- output timestamp must be the one picked from the equally spaced ones, using the correct "target bin-index" as it's called in the code comments, not the index from the initial SFT list
- timestamps are so far only used for XLALGetExponentialTransientWindowValue()
- thus bug was only noticeable in F-stat output for exp window functions
- also some minor comment fixes, (c) update
Luckily the timestamps themselves of the merged atoms (as opposed to the contents of those atoms) are never used in the standard "recangular window" case, so this does not affect e.g. the various uses of the transient functions for non-transient tricks in PyFstat, which always rely on that simpler window.
API Changes and Justification
Backwards Compatible Changes
-
This change introduces no API changes -
This change adds new API calls
Backwards Incompatible Changes
-
This change modifies an existing API -
This change removes an existing API
If any of the Backwards Incompatible check boxes are ticked please provide a justification why this change is necessary and why it needs to be done in a backwards incompatible way.
Review Status
Simple example to illustrate the point - the F-stats themselves are not very conspicious here since it's just a small signal-free data set, but from the "Merging atoms:" debug output it should be sufficiently clear what's going on:
- make fake data
../Injections/lalapps_Makefakedata_v4 --IFO=H1 --Tsft=1800 --startTime=1000000000 --duration=3600 --fmin=49.9 --Band=1 --outSFTbname=testXLALmergeMultiFstatAtomsBinned/ --noiseSqrtSh=1 --randSeed=1
../Injections/lalapps_Makefakedata_v4 --IFO=H1 --Tsft=1800 --startTime=1000006000 --duration=1800 --fmin=49.9 --Band=1 --outSFTbname=testXLALmergeMultiFstatAtomsBinned/ --noiseSqrtSh=1 --randSeed=2
- run original version
./lalapps_ComputeFstatistic_v2 --DataFiles='testXLALmergeMultiFstatAtomsBinned/H*.sft' --Freq=50 --FreqBand=0 --Alpha=0 --Delta=0 --outputTransientStatsAll=testXLALmergeMultiFstatAtomsBinned/Fmn.txt --transient-WindowType=exp --transient-t0Epoch=1000000000 --transient-t0Band=0 --transient-dt0=1800 --transient-tau=3600 --transient-tauBand=0 --transient-dtau=1800
Merging atoms: tMin=1000000000, tMax=1000006000, deltaT=1800 => NBinnedAtoms=4
X=0/1, adding SFT i=0/3 with ts=1000000000 to merged bin 0 with ts=1000000000
X=0/1, adding SFT i=1/3 with ts=1000001800 to merged bin 1 with ts=1000001800
X=0/1, adding SFT i=2/3 with ts=1000006000 to merged bin 3 with ts=1000003600
IFO 0/1: 3 atoms in [1000000000,1000006000]
merged: 4 atoms in [1000000000,1000003600]
X=-1: m=0, n=0, win_mn.t0=1000000000, win_mn.tau=3600, t0=1000000000, t1=1000010800, i_t0=0, i_t1=3
i=0, t_i=1000000000, win_i=1.0000, a2=0.0074, b2=0.0568, ab=-0.0204, Fa=(0.1173+i0.0166), Fb=(-0.3261+i-0.0461)
i=1, t_i=1000001800, win_i=0.6065, a2=0.0000, b2=0.0187, ab=0.0008, Fa=(0.0030+i-0.0035), Fb=(0.0717+i-0.0833)
i=2, t_i=0, win_i=0.0000, a2=0.0000, b2=0.0000, ab=0.0000, Fa=(0.0000+i0.0000), Fb=(0.0000+i0.0000)
i=3, t_i=1000003600, win_i=0.3679, a2=0.0480, b2=0.0039, ab=-0.0136, Fa=(-0.1104+i-0.1418), Fb=(0.0314+i0.0403)
==> Ad=0.0139, Bd=0.0642, Cd=-0.0220, Dd=0.0004, Fa=(0.0785+i-0.0377), Fb=(-0.2710+i-0.0818), 2F=3.9263
%% Freq[Hz] Alpha[rad] Delta[rad] fkdot[1] fkdot[2] fkdot[3] t0[s] tau[s] twoF
50.0000000000000000 0.0000000000000000 0.0000000000000000 0 0 0 1000000000 3600 3.9263146
- rerun with i->j fix:
Merging atoms: tMin=1000000000, tMax=1000006000, deltaT=1800 => NBinnedAtoms=4
X=0/1, adding SFT i=0/3 with ts=1000000000 to merged bin 0 with ts=1000000000
X=0/1, adding SFT i=1/3 with ts=1000001800 to merged bin 1 with ts=1000001800
X=0/1, adding SFT i=2/3 with ts=1000006000 to merged bin 3 with ts=1000005400
IFO 0/1: 3 atoms in [1000000000,1000006000]
merged: 4 atoms in [1000000000,1000005400]
m=0, n=0, win_mn.t0=1000000000, win_mn.tau=3600, t0=1000000000, t1=1000010800, i_t0=0, i_t1=3
i=0, t_i=1000000000, win_i=1.0000, a2=0.0074, b2=0.0568, ab=-0.0204, Fa=(0.1173+i0.0166), Fb=(-0.3261+i-0.0461)
i=1, t_i=1000001800, win_i=0.6065, a2=0.0000, b2=0.0187, ab=0.0008, Fa=(0.0030+i-0.0035), Fb=(0.0717+i-0.0833)
i=2, t_i=0, win_i=0.0000, a2=0.0000, b2=0.0000, ab=0.0000, Fa=(0.0000+i0.0000), Fb=(0.0000+i0.0000)
i=3, t_i=1000005400, win_i=0.2231, a2=0.0480, b2=0.0039, ab=-0.0136, Fa=(-0.1104+i-0.1418), Fb=(0.0314+i0.0403)
==> Ad=0.0098, Bd=0.0639, Cd=-0.0208, Dd=0.0002, Fa=(0.0945+i-0.0172), Fb=(-0.2756+i-0.0876), 2F=4.0443
%% Freq[Hz] Alpha[rad] Delta[rad] fkdot[1] fkdot[2] fkdot[3] t0[s] tau[s] twoF
50.0000000000000000 0.0000000000000000 0.0000000000000000 0 0 0 1000000000 3600 4.0443497