diff --git a/docs/fully_coherent_search_using_MCMC_on_glitching_data.md b/docs/fully_coherent_search_using_MCMC_on_glitching_data.md index 7f2ea890e07a9e2cb37dcaef45bd5f2a9193800f..80073253fe6f50dd3f948ae327c43e30f10d137b 100644 --- a/docs/fully_coherent_search_using_MCMC_on_glitching_data.md +++ b/docs/fully_coherent_search_using_MCMC_on_glitching_data.md @@ -54,8 +54,8 @@ Running this example, we obtain traces of the walkers like this:  Although it is not obvious at first, the large widths of these traces in fact -show that the walkers are jumping between two bimodal peaks (for both `F0` and -`F1): this is possible due to the tuning of the parallel tempering. To see this +show that the walkers are jumping between multiple peaks (for both `F0` and +`F1): this is possible, due to the tuning of the parallel tempering. To see this clearly, we also plot the corner plot:  @@ -71,7 +71,7 @@ see bimodality in `F1`, which did does not change during the glitch. ``` >>> mcmc.print_summary() -Max twoF: 1354.7 +Max twoF: 422.97 ``` That is, compared to the basic search (on a smooth signal) which had a twoF of `~1764` (in agreement with the predicted twoF), we have lost a large diff --git a/docs/img/fully_coherent_search_using_MCMC_on_glitching_data_corner.png b/docs/img/fully_coherent_search_using_MCMC_on_glitching_data_corner.png index c6002bd29400430f3bc46dbe13d66a095e36f059..a3812bfd1aa21d5add813c9405d37cc1b3ea5639 100644 Binary files a/docs/img/fully_coherent_search_using_MCMC_on_glitching_data_corner.png and b/docs/img/fully_coherent_search_using_MCMC_on_glitching_data_corner.png differ diff --git a/docs/img/fully_coherent_search_using_MCMC_on_glitching_data_walkers.png b/docs/img/fully_coherent_search_using_MCMC_on_glitching_data_walkers.png index e54b4a441f494db7ead5ade1793846d664a9e056..6ad24a11b4e4488a071cae1f861e44bef4f15fd1 100644 Binary files a/docs/img/fully_coherent_search_using_MCMC_on_glitching_data_walkers.png and b/docs/img/fully_coherent_search_using_MCMC_on_glitching_data_walkers.png differ diff --git a/docs/img/semi_coherent_glitch_search_using_MCMC_corner.png b/docs/img/semi_coherent_glitch_search_using_MCMC_corner.png new file mode 100644 index 0000000000000000000000000000000000000000..51628bf3ccf38323c2126f735f086c3571e96075 Binary files /dev/null and b/docs/img/semi_coherent_glitch_search_using_MCMC_corner.png differ diff --git a/docs/img/semi_coherent_glitch_search_using_MCMC_init_0_walkers.png b/docs/img/semi_coherent_glitch_search_using_MCMC_init_0_walkers.png new file mode 100644 index 0000000000000000000000000000000000000000..13e8abb0f1e4ca7a56228d0bbf3d11fa87c9b00a Binary files /dev/null and b/docs/img/semi_coherent_glitch_search_using_MCMC_init_0_walkers.png differ diff --git a/docs/img/semi_coherent_glitch_search_using_MCMC_walkers.png b/docs/img/semi_coherent_glitch_search_using_MCMC_walkers.png new file mode 100644 index 0000000000000000000000000000000000000000..d9e791f51306ce5b5a74f8c533dbae46e57a779a Binary files /dev/null and b/docs/img/semi_coherent_glitch_search_using_MCMC_walkers.png differ diff --git a/docs/img/semi_coherent_twoglitch_search_corner.png b/docs/img/semi_coherent_twoglitch_search_corner.png new file mode 100644 index 0000000000000000000000000000000000000000..b744791f4ce5986fbbf29d67eee8d8ab27642f60 Binary files /dev/null and b/docs/img/semi_coherent_twoglitch_search_corner.png differ diff --git a/docs/img/semi_coherent_twoglitch_search_init_0_walkers.png b/docs/img/semi_coherent_twoglitch_search_init_0_walkers.png new file mode 100644 index 0000000000000000000000000000000000000000..f66bc3e869bdaecc265b7545d056324009b5c633 Binary files /dev/null and b/docs/img/semi_coherent_twoglitch_search_init_0_walkers.png differ diff --git a/docs/img/semi_coherent_twoglitch_search_walkers.png b/docs/img/semi_coherent_twoglitch_search_walkers.png new file mode 100644 index 0000000000000000000000000000000000000000..219bd3f2cd0b5cbf18c022f6f24369b18db83922 Binary files /dev/null and b/docs/img/semi_coherent_twoglitch_search_walkers.png differ diff --git a/docs/semi_coherent_glitch_search_using_MCMC_on_glitching_data.md b/docs/semi_coherent_glitch_search_using_MCMC_on_glitching_data.md new file mode 100644 index 0000000000000000000000000000000000000000..cb376e898206d0be77b1751ebda292d93bea1389 --- /dev/null +++ b/docs/semi_coherent_glitch_search_using_MCMC_on_glitching_data.md @@ -0,0 +1,59 @@ +# Semi-coherent glitch search on data with a single glitch using MCMC + +In this example, based on [this +script](../examples/semi_coherent_glitch_search_using_MCMC.py), we show the +basic setup for a single-glitch search. We begin, in the usual way, with +defining some the prior + +```python +import pyfstat + +F0 = 30.0 +F1 = -1e-10 +F2 = 0 +Alpha = 5e-3 +Delta = 6e-2 +tref = 362750407.0 + +tstart = 1000000000 +duration = 100*86400 +tend = tstart + duration + +theta_prior = {'F0': {'type': 'norm', 'loc': F0, 'scale': abs(1e-6*F0)}, + 'F1': {'type': 'norm', 'loc': F1, 'scale': abs(1e-6*F1)}, + 'F2': F2, + 'Alpha': Alpha, + 'Delta': Delta, + 'delta_F0': {'type': 'halfnorm', 'loc': 0, + 'scale': 1e-5*F0}, + 'delta_F1': 0, + 'tglitch': {'type': 'unif', + 'lower': tstart+0.1*duration, + 'upper': tstart+0.9*duration}, + } +``` + +For simplicity, we have chosen a prior based on the known inputs. The important +steps here are the definition of `delta_F0`, `delta_F1` and `tglitch`, the +prior densities for the glitch-parameters. We then use a parallel-tempered +set-up, in addition to an initialisation step and run the search: +```python +ntemps = 4 +log10temperature_min = -1 +nwalkers = 100 +nsteps = [5000, 1000, 1000] + +mcmc = pyfstat.MCMCGlitchSearch( + 'semi_coherent_glitch_search_using_MCMC', 'data', + sftfilepath='data/*_glitch*sft', theta_prior=theta_prior, tref=tref, + tstart=tstart, tend=tend, nsteps=nsteps, nwalkers=nwalkers, + scatter_val=1e-10, nglitch=1, ntemps=ntemps, + log10temperature_min=log10temperature_min) + +mcmc.run() +mcmc.plot_corner(add_prior=True) +mcmc.print_summary() +``` + +The posterior for this search demonstrates that we recover the input parameters: + diff --git a/docs/semi_coherent_glitch_search_with_two_glitches_using_MCMC_on_glitching_data.md b/docs/semi_coherent_glitch_search_with_two_glitches_using_MCMC_on_glitching_data.md new file mode 100644 index 0000000000000000000000000000000000000000..10eca7ae9c38e330e02a62a69cb6c7f20e302419 --- /dev/null +++ b/docs/semi_coherent_glitch_search_with_two_glitches_using_MCMC_on_glitching_data.md @@ -0,0 +1,4 @@ +# Semi-coherent glitch search on data with two-glitches using MCMC + + + diff --git a/examples/make_fake_data.py b/examples/make_fake_data.py index 47072ce87a0ef622774436db581c0b676a065b47..49f450f604e19a8244ae6a83e77128523ce400cf 100644 --- a/examples/make_fake_data.py +++ b/examples/make_fake_data.py @@ -36,7 +36,7 @@ delta_F1 = 0 glitch_data = Writer( label='glitch', outdir='data', tref=tref, tstart=tstart, F0=F0, F1=F1, F2=F2, duration=duration, Alpha=Alpha, Delta=Delta, h0=h0, sqrtSX=sqrtSX, - dtglitch=dtglitch, delta_F0=delta_F0, delta_F1=delta_F1, detector='L1') + dtglitch=dtglitch, delta_F0=delta_F0, delta_F1=delta_F1) glitch_data.make_data() # Making data with two glitches diff --git a/examples/semi_coherent_glitch_search.py b/examples/semi_coherent_glitch_search_using_MCMC.py similarity index 68% rename from examples/semi_coherent_glitch_search.py rename to examples/semi_coherent_glitch_search_using_MCMC.py index 435ea6b4f7edfa77ba9f13981ba920784f8bf69d..789481de83b5fcd0670f44e1a39d09d39070af3d 100644 --- a/examples/semi_coherent_glitch_search.py +++ b/examples/semi_coherent_glitch_search_using_MCMC.py @@ -24,13 +24,17 @@ theta_prior = {'F0': {'type': 'norm', 'loc': F0, 'scale': abs(1e-6*F0)}, 'upper': tstart+0.9*duration}, } -nwalkers = 500 -nsteps = [1000, 1000, 1000] +ntemps = 4 +log10temperature_min = -1 +nwalkers = 100 +nsteps = [5000, 1000, 1000] mcmc = pyfstat.MCMCGlitchSearch( - 'semi_coherent_glitch_search', 'data', sftfilepath='data/*_glitch*sft', - theta_prior=theta_prior, tref=tref, tstart=tstart, tend=tend, - nsteps=nsteps, nwalkers=nwalkers, scatter_val=1e-10, nglitch=1) + 'semi_coherent_glitch_search_using_MCMC', 'data', + sftfilepath='data/*_glitch*sft', theta_prior=theta_prior, tref=tref, + tstart=tstart, tend=tend, nsteps=nsteps, nwalkers=nwalkers, + scatter_val=1e-10, nglitch=1, ntemps=ntemps, + log10temperature_min=log10temperature_min) mcmc.run() mcmc.plot_corner(add_prior=True) diff --git a/examples/semi_coherent_twoglitch_search.py b/examples/semi_coherent_twoglitch_search.py index 8514cbf57da235d5445f14fc999dcc7614ff87fd..3e3a7d3bbe307b923372edb9952a4e1d3c0ba2b1 100644 --- a/examples/semi_coherent_twoglitch_search.py +++ b/examples/semi_coherent_twoglitch_search.py @@ -16,9 +16,12 @@ theta_prior = {'F0': {'type': 'norm', 'loc': F0, 'scale': abs(1e-6*F0)}, 'F2': F2, 'Alpha': Alpha, 'Delta': Delta, - 'delta_F0': {'type': 'halfnorm', 'loc': 0, - 'scale': 1e-7*F0}, - 'delta_F1': 0, + 'delta_F0_0': {'type': 'halfnorm', 'loc': 0, + 'scale': 1e-7*F0}, + 'delta_F0_1': {'type': 'halfnorm', 'loc': 0, + 'scale': 1e-7*F0}, + 'delta_F1_0': 0, + 'delta_F1_1': 0, 'tglitch_0': {'type': 'unif', 'lower': tstart+0.01*duration, 'upper': tstart+0.5*duration}, @@ -27,8 +30,8 @@ theta_prior = {'F0': {'type': 'norm', 'loc': F0, 'scale': abs(1e-6*F0)}, 'upper': tstart+0.99*duration}, } -nwalkers = 50 -nsteps = [500, 500, 500] +nwalkers = 100 +nsteps = [1000, 1000, 5000] mcmc = pyfstat.MCMCGlitchSearch( 'semi_coherent_twoglitch_search', 'data', sftfilepath='data/*twoglitch*sft',