|
|
# Transient search
|
|
|
|
|
|
This is an example of running a *transient* search: a search which allows
|
|
|
the signal to only last for some short duration (parameterised by the start
|
|
|
time and duration).
|
|
|
|
|
|
## Generating the data
|
|
|
|
|
|
In order to demonstrate the method working, we will simulate a data set
|
|
|
containing a transient signal. This can be done be running the example script
|
|
|
`transient_search_using_MCMC_make_simulated_data.py`. This script contains
|
|
|
some setup of times and signal properties, then uses the `Writer` to generate
|
|
|
the simulated data:
|
|
|
|
|
|
```python
|
|
|
#!/usr/bin/env python
|
|
|
|
|
|
import pyfstat
|
|
|
|
|
|
F0 = 30.0
|
|
|
F1 = -1e-10
|
|
|
F2 = 0
|
|
|
Alpha = 0.5
|
|
|
Delta = 1
|
|
|
|
|
|
tstart = 1000000000
|
|
|
duration = 100*86400
|
|
|
data_tstart = tstart - duration
|
|
|
data_tend = data_tstart + 3*duration
|
|
|
tref = .5*(data_tstart+data_tend)
|
|
|
|
|
|
h0 = 1e-23
|
|
|
sqrtSX = 1e-22
|
|
|
|
|
|
transient = pyfstat.Writer(
|
|
|
label='simulated_transient_signal', outdir='data', tref=tref,
|
|
|
tstart=tstart, F0=F0, F1=F1, F2=F2, duration=duration, Alpha=Alpha,
|
|
|
Delta=Delta, h0=h0, sqrtSX=sqrtSX, minStartTime=data_tstart,
|
|
|
maxStartTime=data_tend)
|
|
|
transient.make_data()
|
|
|
```
|
|
|
|
|
|
Running this script, e.g.
|
|
|
|
|
|
```
|
|
|
$ python transient_search_using_MCMC_make_simulated_data.py
|
|
|
```
|
|
|
|
|
|
will produce `data/simulated_transient_signal.cff` (the config file passed to
|
|
|
`lalapps_Makefakedata_v5`) and an `sft` file (also in the `data` directory).
|
|
|
|
|
|
## Running the search
|
|
|
|
|
|
The script `examples/transient_search_using_MCMC.py` contains the basic setup and
|
|
|
commands to run the transient search:
|
|
|
|
|
|
```python
|
|
|
#!/usr/bin/env python
|
|
|
|
|
|
import pyfstat
|
|
|
|
|
|
F0 = 30.0
|
|
|
F1 = -1e-10
|
|
|
F2 = 0
|
|
|
Alpha = 0.5
|
|
|
Delta = 1
|
|
|
|
|
|
minStartTime = 1000000000
|
|
|
maxStartTime = minStartTime + 200*86400
|
|
|
Tspan = maxStartTime - minStartTime
|
|
|
tref = minStartTime
|
|
|
|
|
|
DeltaF0 = 6e-7
|
|
|
DeltaF1 = 1e-13
|
|
|
|
|
|
theta_prior = {'F0': {'type': 'unif',
|
|
|
'lower': F0-DeltaF0/2.,
|
|
|
'upper': F0+DeltaF0/2.},
|
|
|
'F1': {'type': 'unif',
|
|
|
'lower': F1-DeltaF1/2.,
|
|
|
'upper': F1+DeltaF1/2.},
|
|
|
'F2': F2,
|
|
|
'Alpha': Alpha,
|
|
|
'Delta': Delta,
|
|
|
'transient_tstart': {'type': 'unif',
|
|
|
'lower': minStartTime,
|
|
|
'upper': maxStartTime},
|
|
|
'transient_duration': {'type': 'halfnorm',
|
|
|
'loc': 0.001*Tspan,
|
|
|
'scale': 0.5*Tspan}
|
|
|
}
|
|
|
|
|
|
ntemps = 3
|
|
|
log10temperature_min = -1
|
|
|
nwalkers = 100
|
|
|
nsteps = [100, 100]
|
|
|
|
|
|
mcmc = pyfstat.MCMCTransientSearch(
|
|
|
label='transient_search', outdir='data',
|
|
|
sftfilepath='data/*simulated_transient_signal*sft',
|
|
|
theta_prior=theta_prior, tref=tref, minStartTime=minStartTime,
|
|
|
maxStartTime=maxStartTime, nsteps=nsteps, nwalkers=nwalkers, ntemps=ntemps,
|
|
|
log10temperature_min=log10temperature_min)
|
|
|
mcmc.run()
|
|
|
mcmc.plot_corner(label_offset=0.7)
|
|
|
mcmc.print_summary()
|
|
|
```
|
|
|
|
|
|
In this example, we of course know the properties of the simulated signal. In a
|
|
|
real search, the prior will be based on the candidate one is following up.
|
|
|
Here for example, we are performing a directed follow up, one could search over
|
|
|
`Alpha` and `Delta` by specifying a prior distribution (rather than a fixed
|
|
|
value).
|
|
|
|
|
|
The `search.run()` command runs the sampler (which may take a few minutes)
|
|
|
and will save an image `data/glitch_robust_search_walkers.png`:
|
|
|
![](img/transient_search_walkers.png)
|
|
|
|
|
|
The output walker plots gives the values in terms of the default units (i.e.
|
|
|
units for the transient start times and duration). However this behaviour
|
|
|
is not so intuitive as an output. Therefore, a `rescale_dictionary` attribute
|
|
|
(of the `pyfstat.MCMCTransientSearch` instance) controls how to rescale this.
|
|
|
For example, in the corner plot the default `rescale_dictionary' puts the
|
|
|
output in terms of days:
|
|
|
![](img/transient_search_corner.png) |