Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found
Select Git revision

Target

Select target project
  • GregAshton/PyFstat
  • Yuanhao.Zhang/PyFstat
  • dkeitel/PyFstat
3 results
Select Git revision
Show changes
Commits on Source (48)
Showing
with 780 additions and 518 deletions
test_app: stages:
- Test
- Static Analysis
variables:
VENV_DIR: $CI_PROJECT_DIR/../venv-pyFstat
INSTALLER_DIR: $CI_PROJECT_DIR/install-cw-software
pytest:
stage: Test
tags: [ pyFstat ]
before_script:
- python3 -m venv $VENV_DIR
- source ${VENV_DIR}/bin/activate
- pip install --upgrade pip
- pip install -r requirements.txt
- pip install lalsuite
- pip install pytest
- export LAL_DATA_PATH=$HOME/ephemeris
- export LALPULSAR_DATADIR=$LAL_DATA_PATH
script: script:
- . /home/user1/lalsuite-install/etc/lalapps-user-env.sh - pip install -e $CI_PROJECT_DIR
- /home/user1/anaconda2/bin/python tests.py Writer # make sure to test *installed* version of pyFstat
- /home/user1/anaconda2/bin/python tests.py par - (cd .. && pytest $CI_PROJECT_DIR/tests.py --log-file=$CI_PROJECT_DIR/tests.log)
- /home/user1/anaconda2/bin/python tests.py BaseSearchClass
- /home/user1/anaconda2/bin/python tests.py ComputeFstat artifacts:
- /home/user1/anaconda2/bin/python tests.py SemiCoherentSearch paths:
- /home/user1/anaconda2/bin/python tests.py SemiCoherentGlitchSearch - ./*.log
- /home/user1/anaconda2/bin/python tests.py MCMCSearch name: testlogs
- /home/user1/anaconda2/bin/python tests.py GridSearch when: always
expire_in: 24h
static:
stage: Static Analysis
tags: [ pyFstat ]
script:
- source ${VENV_DIR}/bin/activate
- black --check --diff .
# - flake8 . ## not ready
...@@ -3,110 +3,13 @@ ...@@ -3,110 +3,13 @@
This is a python package providing an interface to perform F-statistic based This is a python package providing an interface to perform F-statistic based
continuous gravitational wave (CW) searches. continuous gravitational wave (CW) searches.
For documentation, please use the [wiki](https://gitlab.aei.uni-hannover.de/GregAshton/PyFstat/wikis/home). This repository is now for archival purposes only,
active development has been moved to:
In the **===> https://github.com/PyFstat/PyFstat <===**
[examples](https://gitlab.aei.uni-hannover.de/GregAshton/PyFstat/tree/master/examples),
we have a number of scripts demonstrating different use cases.
Please also refer to the github repository for installation and usage instructions
## Installation and to report issues.
### `python` installation
The scripts are written in `python 2.7+` and therefore require a working
`python` installation. While many systems come with a system wide python
installation, it can often be easier to manage a user-specific python
installation. This way one does not require root access to install or remove
modules. One method to do this, is to use the `conda` system, either through
the stripped down [miniconda](http://conda.pydata.org/miniconda.html)
installation, or the full-featured
[anaconda](https://www.continuum.io/downloads) (these are essentially the
same, but the `anaconda` version installs a variety of useful packages such as
`numpy` and `scipy` by default).
The fastest/easiest method is to follow your OS instructions
[here](https://conda.io/docs/install/quick.html) which will install Miniconda.
For the rest of this tutorial, we will make use of `pip` to install modules (
not all packages can be installed with `conda` and for those using alternatives
to `conda`, `pip` is more universal).
This can be installed with
```
$ conda install pip
```
### Clone the repository
In a terminal, clone the directory:
```
$ git clone https://gitlab.aei.uni-hannover.de/GregAshton/PyFstat.git
```
### Dependencies
`pyfstat` makes uses the following external python modules:
* [numpy](http://www.numpy.org/)
* [matplotlib](http://matplotlib.org/) >= 1.4
* [scipy](https://www.scipy.org/)
* [ptemcee](https://github.com/willvousden/ptemcee)
* [corner](https://pypi.python.org/pypi/corner/)
* [dill](https://pypi.python.org/pypi/dill)
* [peakutils](https://pypi.python.org/pypi/PeakUtils)
*Optional*
* [tqdm](https://pypi.python.org/pypi/tqdm)(optional), if installed, this
provides a useful progress bar and estimate of the remaining run-time.
* [bashplotlib](https://github.com/glamp/bashplotlib), if installed, presents
a histogram of the loaded SFT data
* [pathos](https://pypi.python.org/pypi/pathos), if installed, this provides
support for multiprocessing some functions.
For an introduction to installing modules see
[here](https://docs.python.org/3.5/installing/index.html). If you are using
`pip`, to install all of these modules, run
```
$ pip install -r /PATH/TO/THIS/DIRECTORY/requirements.txt
```
In addition to these modules, you also need a working **swig-enabled**
[`lalapps`](http://software.ligo.org/docs/lalsuite/lalsuite/) with
at least `lalpulsar`. A minimal confuration line to use when installing
`lalapps` is
```
$ ./configure --prefix=${HOME}/lalsuite-install --disable-all-lal --enable-lalpulsar --enable-lalapps --enable-swig
```
### `pyfstat` installation
The script can be installed system wide, assuming you are in the source directory, via
```
$ python setup.py install
```
or simply add this directory to your python path. To check that the installation
was successful, run
```
$ python -c 'import pyfstat'
```
if no error message is output, then you have installed `pyfstat`. Note that
the module will be installed to whichever python executable you call it from.
### Ephemeris installation
The scripts require a path to ephemeris files in order to use the
`lalpulsar.ComputeFstat` module. This can either be specified when initialising
each search (as one of the arguments), or simply by placing a file
`~/.pyfstat.conf` into your home directory which looks like
```
earth_ephem = '/home/<USER>/lalsuite-install/share/lalpulsar/earth00-19-DE421.dat.gz'
sun_ephem = '/home/<USER>/lalsuite-install/share/lalpulsar/sun00-19-DE421.dat.gz'
```
here, we use the default ephemeris files provided with `lalsuite`.
### Contributors ### Contributors
...@@ -116,25 +19,29 @@ here, we use the default ephemeris files provided with `lalsuite`. ...@@ -116,25 +19,29 @@ here, we use the default ephemeris files provided with `lalsuite`.
* Karl Wette * Karl Wette
* Sylvia Zhu * Sylvia Zhu
This project is open to development, please feel free to contact us
for advice or just jump in and submit a pull request.
## Citing this work ## Citing this work
If you use `PyFstat` in a publication we would appreciate if you cite the If you use `PyFstat` in a publication we would appreciate if you cite both the
original paper introducing the code, the [ADS page can be found original paper introducing the code
here](http://adsabs.harvard.edu/abs/2018arXiv180205450A) and the version (the [ADS page can be found here](http://adsabs.harvard.edu/abs/2018arXiv180205450A))
release: and the DOI for the software itself.
The latest version released on Zenodo from this repository here was v1.3,
see the following Bibtex entry.
Or see the [new github repository](https://github.com/PyFstat/PyFstat)
for the latest information.
``` ```
@misc{pyfstat, @misc{pyfstat,
author = {{Ashton}, G. and {Keitel}, D.}, author = {Ashton, Gregory and
title = {{PyFstat-v1.2}}, Keitel, David and
month = may, Prix, Reinhard},
year = 2018, title = {PyFstat-v1.3},
doi = {10.5281/zenodo.1243931}, month = jan,
url = {https://doi.org/10.5281/zenodo.1243931}, year = 2020,
note= {\url{https://doi.org/10.5281/zenodo.1243931}} publisher = {Zenodo},
version = {1.3},
doi = {10.5281/zenodo.3620861},
url = {https://doi.org/10.5281/zenodo.3620861}
note = {\url{https://doi.org/10.5281/zenodo.3620861}}
} }
``` ```
......
...@@ -13,38 +13,45 @@ F1 = -1e-10 ...@@ -13,38 +13,45 @@ F1 = -1e-10
F2 = 0 F2 = 0
Alpha = np.radians(83.6292) Alpha = np.radians(83.6292)
Delta = np.radians(22.0144) Delta = np.radians(22.0144)
tref = .5*(tstart+tend) tref = 0.5 * (tstart + tend)
depth = 10 depth = 10
h0 = sqrtSX / depth h0 = sqrtSX / depth
label = 'fully_coherent_search_using_MCMC' label = "fully_coherent_search_using_MCMC"
outdir = 'data' outdir = "data"
data = pyfstat.Writer( data = pyfstat.Writer(
label=label, outdir=outdir, tref=tref, label=label,
tstart=tstart, F0=F0, F1=F1, F2=F2, duration=duration, Alpha=Alpha, outdir=outdir,
Delta=Delta, h0=h0, sqrtSX=sqrtSX) tref=tref,
tstart=tstart,
F0=F0,
F1=F1,
F2=F2,
duration=duration,
Alpha=Alpha,
Delta=Delta,
h0=h0,
sqrtSX=sqrtSX,
)
data.make_data() data.make_data()
# The predicted twoF, given by lalapps_predictFstat can be accessed by # The predicted twoF, given by lalapps_predictFstat can be accessed by
twoF = data.predict_fstat() twoF = data.predict_fstat()
print 'Predicted twoF value: {}\n'.format(twoF) print("Predicted twoF value: {}\n".format(twoF))
DeltaF0 = 1e-7 DeltaF0 = 1e-7
DeltaF1 = 1e-13 DeltaF1 = 1e-13
VF0 = (np.pi * duration * DeltaF0) ** 2 / 3.0 VF0 = (np.pi * duration * DeltaF0) ** 2 / 3.0
VF1 = (np.pi * duration**2 * DeltaF1)**2 * 4/45. VF1 = (np.pi * duration ** 2 * DeltaF1) ** 2 * 4 / 45.0
print '\nV={:1.2e}, VF0={:1.2e}, VF1={:1.2e}\n'.format(VF0*VF1, VF0, VF1) print("\nV={:1.2e}, VF0={:1.2e}, VF1={:1.2e}\n".format(VF0 * VF1, VF0, VF1))
theta_prior = {'F0': {'type': 'unif', theta_prior = {
'lower': F0-DeltaF0/2., "F0": {"type": "unif", "lower": F0 - DeltaF0 / 2.0, "upper": F0 + DeltaF0 / 2.0},
'upper': F0+DeltaF0/2.}, "F1": {"type": "unif", "lower": F1 - DeltaF1 / 2.0, "upper": F1 + DeltaF1 / 2.0},
'F1': {'type': 'unif', "F2": F2,
'lower': F1-DeltaF1/2., "Alpha": Alpha,
'upper': F1+DeltaF1/2.}, "Delta": Delta,
'F2': F2,
'Alpha': Alpha,
'Delta': Delta
} }
ntemps = 2 ntemps = 2
...@@ -53,13 +60,22 @@ nwalkers = 100 ...@@ -53,13 +60,22 @@ nwalkers = 100
nsteps = [300, 300] nsteps = [300, 300]
mcmc = pyfstat.MCMCSearch( mcmc = pyfstat.MCMCSearch(
label=label, outdir=outdir, label=label,
sftfilepattern='{}/*{}*sft'.format(outdir, label), theta_prior=theta_prior, outdir=outdir,
tref=tref, minStartTime=tstart, maxStartTime=tend, nsteps=nsteps, sftfilepattern="{}/*{}*sft".format(outdir, label),
nwalkers=nwalkers, ntemps=ntemps, log10beta_min=log10beta_min) theta_prior=theta_prior,
tref=tref,
minStartTime=tstart,
maxStartTime=tend,
nsteps=nsteps,
nwalkers=nwalkers,
ntemps=ntemps,
log10beta_min=log10beta_min,
)
mcmc.transform_dictionary = dict( mcmc.transform_dictionary = dict(
F0=dict(subtractor=F0, symbol='$f-f^\mathrm{s}$'), F0=dict(subtractor=F0, symbol="$f-f^\mathrm{s}$"),
F1=dict(subtractor=F1, symbol='$\dot{f}-\dot{f}^\mathrm{s}$')) F1=dict(subtractor=F1, symbol="$\dot{f}-\dot{f}^\mathrm{s}$"),
)
mcmc.run() mcmc.run()
mcmc.plot_corner(add_prior=True) mcmc.plot_corner(add_prior=True)
mcmc.print_summary() mcmc.print_summary()
...@@ -13,38 +13,45 @@ F1 = -1e-10 ...@@ -13,38 +13,45 @@ F1 = -1e-10
F2 = 0 F2 = 0
Alpha = np.radians(83.6292) Alpha = np.radians(83.6292)
Delta = np.radians(22.0144) Delta = np.radians(22.0144)
tref = .5*(tstart+tend) tref = 0.5 * (tstart + tend)
depth = 10 depth = 10
h0 = sqrtSX / depth h0 = sqrtSX / depth
label = 'semicoherent_search_using_MCMC' label = "semicoherent_search_using_MCMC"
outdir = 'data' outdir = "data"
data = pyfstat.Writer( data = pyfstat.Writer(
label=label, outdir=outdir, tref=tref, label=label,
tstart=tstart, F0=F0, F1=F1, F2=F2, duration=duration, Alpha=Alpha, outdir=outdir,
Delta=Delta, h0=h0, sqrtSX=sqrtSX) tref=tref,
tstart=tstart,
F0=F0,
F1=F1,
F2=F2,
duration=duration,
Alpha=Alpha,
Delta=Delta,
h0=h0,
sqrtSX=sqrtSX,
)
data.make_data() data.make_data()
# The predicted twoF, given by lalapps_predictFstat can be accessed by # The predicted twoF, given by lalapps_predictFstat can be accessed by
twoF = data.predict_fstat() twoF = data.predict_fstat()
print 'Predicted twoF value: {}\n'.format(twoF) print("Predicted twoF value: {}\n".format(twoF))
DeltaF0 = 1e-7 DeltaF0 = 1e-7
DeltaF1 = 1e-13 DeltaF1 = 1e-13
VF0 = (np.pi * duration * DeltaF0) ** 2 / 3.0 VF0 = (np.pi * duration * DeltaF0) ** 2 / 3.0
VF1 = (np.pi * duration**2 * DeltaF1)**2 * 4/45. VF1 = (np.pi * duration ** 2 * DeltaF1) ** 2 * 4 / 45.0
print '\nV={:1.2e}, VF0={:1.2e}, VF1={:1.2e}\n'.format(VF0*VF1, VF0, VF1) print("\nV={:1.2e}, VF0={:1.2e}, VF1={:1.2e}\n".format(VF0 * VF1, VF0, VF1))
theta_prior = {'F0': {'type': 'unif', theta_prior = {
'lower': F0-DeltaF0/2., "F0": {"type": "unif", "lower": F0 - DeltaF0 / 2.0, "upper": F0 + DeltaF0 / 2.0},
'upper': F0+DeltaF0/2.}, "F1": {"type": "unif", "lower": F1 - DeltaF1 / 2.0, "upper": F1 + DeltaF1 / 2.0},
'F1': {'type': 'unif', "F2": F2,
'lower': F1-DeltaF1/2., "Alpha": Alpha,
'upper': F1+DeltaF1/2.}, "Delta": Delta,
'F2': F2,
'Alpha': Alpha,
'Delta': Delta
} }
ntemps = 1 ntemps = 1
...@@ -53,14 +60,23 @@ nwalkers = 100 ...@@ -53,14 +60,23 @@ nwalkers = 100
nsteps = [300, 300] nsteps = [300, 300]
mcmc = pyfstat.MCMCSemiCoherentSearch( mcmc = pyfstat.MCMCSemiCoherentSearch(
label=label, outdir=outdir, nsegs=10, label=label,
sftfilepattern='{}/*{}*sft'.format(outdir, label), outdir=outdir,
theta_prior=theta_prior, tref=tref, minStartTime=tstart, maxStartTime=tend, nsegs=10,
nsteps=nsteps, nwalkers=nwalkers, ntemps=ntemps, sftfilepattern="{}/*{}*sft".format(outdir, label),
log10beta_min=log10beta_min) theta_prior=theta_prior,
tref=tref,
minStartTime=tstart,
maxStartTime=tend,
nsteps=nsteps,
nwalkers=nwalkers,
ntemps=ntemps,
log10beta_min=log10beta_min,
)
mcmc.transform_dictionary = dict( mcmc.transform_dictionary = dict(
F0=dict(subtractor=F0, symbol='$f-f^\mathrm{s}$'), F0=dict(subtractor=F0, symbol="$f-f^\mathrm{s}$"),
F1=dict(subtractor=F1, symbol='$\dot{f}-\dot{f}^\mathrm{s}$')) F1=dict(subtractor=F1, symbol="$\dot{f}-\dot{f}^\mathrm{s}$"),
)
mcmc.run() mcmc.run()
mcmc.plot_corner(add_prior=True) mcmc.plot_corner(add_prior=True)
mcmc.print_summary() mcmc.print_summary()
...@@ -13,36 +13,44 @@ sqrtSX = 1e-23 ...@@ -13,36 +13,44 @@ sqrtSX = 1e-23
tstart = 1000000000 tstart = 1000000000
duration = 100 * 86400 duration = 100 * 86400
tend = tstart + duration tend = tstart + duration
tref = .5*(tstart+tend) tref = 0.5 * (tstart + tend)
depth = 40 depth = 40
label = 'semicoherent_directed_follow_up' label = "semicoherent_directed_follow_up"
outdir = 'data' outdir = "data"
h0 = sqrtSX / depth h0 = sqrtSX / depth
data = pyfstat.Writer( data = pyfstat.Writer(
label=label, outdir=outdir, tref=tref, tstart=tstart, F0=F0, F1=F1, label=label,
F2=F2, duration=duration, Alpha=Alpha, Delta=Delta, h0=h0, sqrtSX=sqrtSX) outdir=outdir,
tref=tref,
tstart=tstart,
F0=F0,
F1=F1,
F2=F2,
duration=duration,
Alpha=Alpha,
Delta=Delta,
h0=h0,
sqrtSX=sqrtSX,
)
data.make_data() data.make_data()
# The predicted twoF, given by lalapps_predictFstat can be accessed by # The predicted twoF, given by lalapps_predictFstat can be accessed by
twoF = data.predict_fstat() twoF = data.predict_fstat()
print 'Predicted twoF value: {}\n'.format(twoF) print("Predicted twoF value: {}\n".format(twoF))
# Search # Search
VF0 = VF1 = 1e5 VF0 = VF1 = 1e5
DeltaF0 = np.sqrt(VF0) * np.sqrt(3) / (np.pi * duration) DeltaF0 = np.sqrt(VF0) * np.sqrt(3) / (np.pi * duration)
DeltaF1 = np.sqrt(VF1) * np.sqrt(180) / (np.pi * duration ** 2) DeltaF1 = np.sqrt(VF1) * np.sqrt(180) / (np.pi * duration ** 2)
theta_prior = {'F0': {'type': 'unif', theta_prior = {
'lower': F0-DeltaF0/2., "F0": {"type": "unif", "lower": F0 - DeltaF0 / 2.0, "upper": F0 + DeltaF0 / 2},
'upper': F0+DeltaF0/2}, "F1": {"type": "unif", "lower": F1 - DeltaF1 / 2.0, "upper": F1 + DeltaF1 / 2},
'F1': {'type': 'unif', "F2": F2,
'lower': F1-DeltaF1/2., "Alpha": Alpha,
'upper': F1+DeltaF1/2}, "Delta": Delta,
'F2': F2,
'Alpha': Alpha,
'Delta': Delta
} }
ntemps = 3 ntemps = 3
...@@ -51,23 +59,35 @@ nwalkers = 100 ...@@ -51,23 +59,35 @@ nwalkers = 100
nsteps = [100, 100] nsteps = [100, 100]
mcmc = pyfstat.MCMCFollowUpSearch( mcmc = pyfstat.MCMCFollowUpSearch(
label=label, outdir=outdir, label=label,
sftfilepattern='{}/*{}*sft'.format(outdir, label), outdir=outdir,
theta_prior=theta_prior, tref=tref, minStartTime=tstart, maxStartTime=tend, sftfilepattern="{}/*{}*sft".format(outdir, label),
nwalkers=nwalkers, nsteps=nsteps, ntemps=ntemps, theta_prior=theta_prior,
log10beta_min=log10beta_min) tref=tref,
minStartTime=tstart,
maxStartTime=tend,
nwalkers=nwalkers,
nsteps=nsteps,
ntemps=ntemps,
log10beta_min=log10beta_min,
)
NstarMax = 1000 NstarMax = 1000
Nsegs0 = 100 Nsegs0 = 100
fig, axes = plt.subplots(nrows=2, figsize=(3.4, 3.5)) fig, axes = plt.subplots(nrows=2, figsize=(3.4, 3.5))
fig, axes = mcmc.run( fig, axes = mcmc.run(
NstarMax=NstarMax, Nsegs0=Nsegs0, labelpad=0.01, NstarMax=NstarMax,
plot_det_stat=False, return_fig=True, fig=fig, Nsegs0=Nsegs0,
axes=axes) labelpad=0.01,
plot_det_stat=False,
return_fig=True,
fig=fig,
axes=axes,
)
for ax in axes: for ax in axes:
ax.grid() ax.grid()
ax.set_xticks(np.arange(0, 600, 100)) ax.set_xticks(np.arange(0, 600, 100))
ax.set_xticklabels([str(s) for s in np.arange(0, 700, 100)]) ax.set_xticklabels([str(s) for s in np.arange(0, 700, 100)])
axes[-1].set_xlabel(r'$\textrm{Number of steps}$', labelpad=0.1) axes[-1].set_xlabel(r"$\textrm{Number of steps}$", labelpad=0.1)
fig.tight_layout() fig.tight_layout()
fig.savefig('{}/{}_walkers.png'.format(mcmc.outdir, mcmc.label), dpi=400) fig.savefig("{}/{}_walkers.png".format(mcmc.outdir, mcmc.label), dpi=400)
from pyfstat import Writer, GlitchWriter from pyfstat import Writer, GlitchWriter
import numpy as np import numpy as np
outdir = 'data' outdir = "data"
# First, we generate data with a reasonably strong smooth signal # First, we generate data with a reasonably strong smooth signal
# Define parameters of the Crab pulsar as an example # Define parameters of the Crab pulsar as an example
...@@ -22,8 +22,19 @@ tend = tstart+duration ...@@ -22,8 +22,19 @@ tend = tstart+duration
tref = tstart + 0.5 * duration tref = tstart + 0.5 * duration
data = Writer( data = Writer(
label='0_glitch', outdir=outdir, tref=tref, tstart=tstart, F0=F0, F1=F1, label="0_glitch",
F2=F2, duration=duration, Alpha=Alpha, Delta=Delta, h0=h0, sqrtSX=sqrtSX) outdir=outdir,
tref=tref,
tstart=tstart,
F0=F0,
F1=F1,
F2=F2,
duration=duration,
Alpha=Alpha,
Delta=Delta,
h0=h0,
sqrtSX=sqrtSX,
)
data.make_data() data.make_data()
# Next, taking the same signal parameters, we include a glitch half way through # Next, taking the same signal parameters, we include a glitch half way through
...@@ -32,9 +43,22 @@ delta_F0 = 5e-6 ...@@ -32,9 +43,22 @@ delta_F0 = 5e-6
delta_F1 = 0 delta_F1 = 0
glitch_data = GlitchWriter( glitch_data = GlitchWriter(
label='1_glitch', outdir=outdir, tref=tref, tstart=tstart, F0=F0, F1=F1, label="1_glitch",
F2=F2, duration=duration, Alpha=Alpha, Delta=Delta, h0=h0, sqrtSX=sqrtSX, outdir=outdir,
dtglitch=dtglitch, delta_F0=delta_F0, delta_F1=delta_F1) 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,
)
glitch_data.make_data() glitch_data.make_data()
# Making data with two glitches # Making data with two glitches
...@@ -46,8 +70,22 @@ delta_F1_2 = [0, 0] ...@@ -46,8 +70,22 @@ delta_F1_2 = [0, 0]
delta_F2_2 = [0, 0] delta_F2_2 = [0, 0]
two_glitch_data = GlitchWriter( two_glitch_data = GlitchWriter(
label='2_glitch', outdir=outdir, tref=tref, tstart=tstart, F0=F0, F1=F1, label="2_glitch",
F2=F2, duration=duration, Alpha=Alpha, Delta=Delta, h0=h0, sqrtSX=sqrtSX, outdir=outdir,
dtglitch=dtglitch_2, delta_phi=delta_phi_2, delta_F0=delta_F0_2, tref=tref,
delta_F1=delta_F1_2, delta_F2=delta_F2_2) tstart=tstart,
F0=F0,
F1=F1,
F2=F2,
duration=duration,
Alpha=Alpha,
Delta=Delta,
h0=h0,
sqrtSX=sqrtSX,
dtglitch=dtglitch_2,
delta_phi=delta_phi_2,
delta_F0=delta_F0_2,
delta_F1=delta_F1_2,
delta_F2=delta_F2_2,
)
two_glitch_data.make_data() two_glitch_data.make_data()
...@@ -3,33 +3,41 @@ import matplotlib.pyplot as plt ...@@ -3,33 +3,41 @@ import matplotlib.pyplot as plt
import pyfstat import pyfstat
import gridcorner import gridcorner
import time import time
from make_simulated_data import tstart, duration, tref, F0, F1, F2, Alpha, Delta, delta_F0, dtglitch, outdir from make_simulated_data import (
tstart,
duration,
tref,
F0,
F1,
F2,
Alpha,
Delta,
delta_F0,
dtglitch,
outdir,
)
plt.style.use('./paper.mplstyle') plt.style.use("./paper.mplstyle")
label = 'semicoherent_glitch_robust_directed_MCMC_search_on_1_glitch' label = "semicoherent_glitch_robust_directed_MCMC_search_on_1_glitch"
Nstar = 1000 Nstar = 1000
F0_width = np.sqrt(Nstar) * np.sqrt(12) / (np.pi * duration) F0_width = np.sqrt(Nstar) * np.sqrt(12) / (np.pi * duration)
F1_width = np.sqrt(Nstar) * np.sqrt(180) / (np.pi * duration ** 2) F1_width = np.sqrt(Nstar) * np.sqrt(180) / (np.pi * duration ** 2)
theta_prior = { theta_prior = {
'F0': {'type': 'unif', "F0": {"type": "unif", "lower": F0 - F0_width / 2.0, "upper": F0 + F0_width / 2.0},
'lower': F0-F0_width/2., "F1": {"type": "unif", "lower": F1 - F1_width / 2.0, "upper": F1 + F1_width / 2.0},
'upper': F0+F0_width/2.}, "F2": F2,
'F1': {'type': 'unif', "delta_F0": {"type": "unif", "lower": 0, "upper": 1e-5},
'lower': F1-F1_width/2., "delta_F1": 0,
'upper': F1+F1_width/2.}, "tglitch": {
'F2': F2, "type": "unif",
'delta_F0': {'type': 'unif', "lower": tstart + 0.1 * duration,
'lower': 0, "upper": tstart + 0.9 * duration,
'upper': 1e-5}, },
'delta_F1': 0, "Alpha": Alpha,
'tglitch': {'type': 'unif', "Delta": Delta,
'lower': tstart+0.1*duration,
'upper': tstart+0.9*duration},
'Alpha': Alpha,
'Delta': Delta,
} }
ntemps = 3 ntemps = 3
...@@ -38,33 +46,49 @@ nwalkers = 100 ...@@ -38,33 +46,49 @@ nwalkers = 100
nsteps = [250, 250] nsteps = [250, 250]
mcmc = pyfstat.MCMCGlitchSearch( mcmc = pyfstat.MCMCGlitchSearch(
label=label, sftfilepattern='data/*1_glitch*sft', theta_prior=theta_prior, label=label,
tref=tref, minStartTime=tstart, maxStartTime=tstart+duration, sftfilepattern="data/*1_glitch*sft",
nsteps=nsteps, nwalkers=nwalkers, ntemps=ntemps, theta_prior=theta_prior,
log10beta_min=log10beta_min, nglitch=1) tref=tref,
mcmc.transform_dictionary['F0'] = dict( minStartTime=tstart,
subtractor=F0, multiplier=1e6, symbol='$f-f_\mathrm{s}$') maxStartTime=tstart + duration,
mcmc.unit_dictionary['F0'] = '$\mu$Hz' nsteps=nsteps,
mcmc.transform_dictionary['F1'] = dict( nwalkers=nwalkers,
subtractor=F1, multiplier=1e12, symbol='$\dot{f}-\dot{f}_\mathrm{s}$') ntemps=ntemps,
mcmc.unit_dictionary['F1'] = '$p$Hz/s' log10beta_min=log10beta_min,
mcmc.transform_dictionary['delta_F0'] = dict( nglitch=1,
multiplier=1e6, subtractor=delta_F0, )
symbol='$\delta f-\delta f_\mathrm{s}$') mcmc.transform_dictionary["F0"] = dict(
mcmc.unit_dictionary['delta_F0'] = '$\mu$Hz/s' subtractor=F0, multiplier=1e6, symbol="$f-f_\mathrm{s}$"
mcmc.transform_dictionary['tglitch']['subtractor'] = tstart + dtglitch )
mcmc.transform_dictionary['tglitch']['label'] ='$t^\mathrm{g}-t^\mathrm{g}_\mathrm{s}$\n[d]' mcmc.unit_dictionary["F0"] = "$\mu$Hz"
mcmc.transform_dictionary["F1"] = dict(
subtractor=F1, multiplier=1e12, symbol="$\dot{f}-\dot{f}_\mathrm{s}$"
)
mcmc.unit_dictionary["F1"] = "$p$Hz/s"
mcmc.transform_dictionary["delta_F0"] = dict(
multiplier=1e6, subtractor=delta_F0, symbol="$\delta f-\delta f_\mathrm{s}$"
)
mcmc.unit_dictionary["delta_F0"] = "$\mu$Hz/s"
mcmc.transform_dictionary["tglitch"]["subtractor"] = tstart + dtglitch
mcmc.transform_dictionary["tglitch"][
"label"
] = "$t^\mathrm{g}-t^\mathrm{g}_\mathrm{s}$\n[d]"
t1 = time.time() t1 = time.time()
mcmc.run() mcmc.run()
dT = time.time() - t1 dT = time.time() - t1
fig_and_axes = gridcorner._get_fig_and_axes(4, 2, 0.05) fig_and_axes = gridcorner._get_fig_and_axes(4, 2, 0.05)
mcmc.plot_corner(label_offset=0.25, truths=[0, 0, 0, 0], mcmc.plot_corner(
fig_and_axes=fig_and_axes, quantiles=(0.16, 0.84), label_offset=0.25,
truths=[0, 0, 0, 0],
fig_and_axes=fig_and_axes,
quantiles=(0.16, 0.84),
hist_kwargs=dict(lw=1.5, zorder=-1), hist_kwargs=dict(lw=1.5, zorder=-1),
truth_color='C3') truth_color="C3",
)
mcmc.print_summary() mcmc.print_summary()
print('Prior widths =', F0_width, F1_width) print(("Prior widths =", F0_width, F1_width))
print("Actual run time = {}".format(dT)) print(("Actual run time = {}".format(dT)))
import pyfstat import pyfstat
import numpy as np import numpy as np
import matplotlib.pyplot as plt import matplotlib.pyplot as plt
from make_simulated_data import tstart, duration, tref, F0, F1, F2, Alpha, Delta, delta_F0, outdir, dtglitch from make_simulated_data import (
tstart,
duration,
tref,
F0,
F1,
F2,
Alpha,
Delta,
delta_F0,
outdir,
dtglitch,
)
import time import time
try: try:
...@@ -9,18 +21,19 @@ try: ...@@ -9,18 +21,19 @@ try:
except ImportError: except ImportError:
raise ImportError( raise ImportError(
"Python module 'gridcorner' not found, please install from " "Python module 'gridcorner' not found, please install from "
"https://gitlab.aei.uni-hannover.de/GregAshton/gridcorner") "https://gitlab.aei.uni-hannover.de/GregAshton/gridcorner"
)
label = 'semicoherent_glitch_robust_directed_grid_search_on_1_glitch' label = "semicoherent_glitch_robust_directed_grid_search_on_1_glitch"
plt.style.use('./paper.mplstyle') plt.style.use("./paper.mplstyle")
Nstar = 1000 Nstar = 1000
F0_width = np.sqrt(Nstar) * np.sqrt(12) / (np.pi * duration) F0_width = np.sqrt(Nstar) * np.sqrt(12) / (np.pi * duration)
F1_width = np.sqrt(Nstar) * np.sqrt(180) / (np.pi * duration ** 2) F1_width = np.sqrt(Nstar) * np.sqrt(180) / (np.pi * duration ** 2)
N = 20 N = 20
F0s = [F0-F0_width/2., F0+F0_width/2., F0_width/N] F0s = [F0 - F0_width / 2.0, F0 + F0_width / 2.0, F0_width / N]
F1s = [F1-F1_width/2., F1+F1_width/2., F1_width/N] F1s = [F1 - F1_width / 2.0, F1 + F1_width / 2.0, F1_width / N]
F2s = [F2] F2s = [F2]
Alphas = [Alpha] Alphas = [Alpha]
Deltas = [Delta] Deltas = [Delta]
...@@ -33,10 +46,21 @@ delta_F1s = [0] ...@@ -33,10 +46,21 @@ delta_F1s = [0]
t1 = time.time() t1 = time.time()
search = pyfstat.GridGlitchSearch( search = pyfstat.GridGlitchSearch(
label, outdir, 'data/*1_glitch*sft', F0s=F0s, F1s=F1s, F2s=F2s, label,
Alphas=Alphas, Deltas=Deltas, tref=tref, minStartTime=tstart, outdir,
maxStartTime=tstart+duration, tglitchs=tglitchs, delta_F0s=delta_F0s, "data/*1_glitch*sft",
delta_F1s=delta_F1s) F0s=F0s,
F1s=F1s,
F2s=F2s,
Alphas=Alphas,
Deltas=Deltas,
tref=tref,
minStartTime=tstart,
maxStartTime=tstart + duration,
tglitchs=tglitchs,
delta_F0s=delta_F0s,
delta_F1s=delta_F1s,
)
search.run() search.run()
dT = time.time() - t1 dT = time.time() - t1
...@@ -44,24 +68,32 @@ F0_vals = np.unique(search.data[:, 0]) - F0 ...@@ -44,24 +68,32 @@ F0_vals = np.unique(search.data[:, 0]) - F0
F1_vals = np.unique(search.data[:, 1]) - F1 F1_vals = np.unique(search.data[:, 1]) - F1
delta_F0s_vals = np.unique(search.data[:, 5]) - delta_F0 delta_F0s_vals = np.unique(search.data[:, 5]) - delta_F0
tglitch_vals = np.unique(search.data[:, 7]) tglitch_vals = np.unique(search.data[:, 7])
tglitch_vals_days = (tglitch_vals-tstart) / 86400. - dtglitch/86400. tglitch_vals_days = (tglitch_vals - tstart) / 86400.0 - dtglitch / 86400.0
twoF = search.data[:, -1].reshape((len(F0_vals), len(F1_vals), twoF = search.data[:, -1].reshape(
len(delta_F0s_vals), len(tglitch_vals))) (len(F0_vals), len(F1_vals), len(delta_F0s_vals), len(tglitch_vals))
)
xyz = [F0_vals * 1e6, F1_vals * 1e12, delta_F0s_vals * 1e6, tglitch_vals_days] xyz = [F0_vals * 1e6, F1_vals * 1e12, delta_F0s_vals * 1e6, tglitch_vals_days]
labels = ['$f - f_\mathrm{s}$\n[$\mu$Hz]', labels = [
'$\dot{f} - \dot{f}_\mathrm{s}$\n[$p$Hz/s]', "$f - f_\mathrm{s}$\n[$\mu$Hz]",
'$\delta f-\delta f_\mathrm{s}$\n[$\mu$Hz]', "$\dot{f} - \dot{f}_\mathrm{s}$\n[$p$Hz/s]",
'$t^\mathrm{g} - t^\mathrm{g}_\mathrm{s}$\n[d]', "$\delta f-\delta f_\mathrm{s}$\n[$\mu$Hz]",
'$\widehat{2\mathcal{F}}$'] "$t^\mathrm{g} - t^\mathrm{g}_\mathrm{s}$\n[d]",
"$\widehat{2\mathcal{F}}$",
]
fig, axes = gridcorner( fig, axes = gridcorner(
twoF, xyz, projection='log_mean', labels=labels, twoF,
showDvals=False, lines=[0, 0, 0, 0], label_offset=0.25, xyz,
max_n_ticks=4) projection="log_mean",
fig.savefig('{}/{}_projection_matrix.png'.format(outdir, label), labels=labels,
bbox_inches='tight') showDvals=False,
lines=[0, 0, 0, 0],
label_offset=0.25,
max_n_ticks=4,
)
fig.savefig("{}/{}_projection_matrix.png".format(outdir, label), bbox_inches="tight")
print('Prior widths =', F0_width, F1_width) print(("Prior widths =", F0_width, F1_width))
print("Actual run time = {}".format(dT)) print(("Actual run time = {}".format(dT)))
print("Actual number of grid points = {}".format(search.data.shape[0])) print(("Actual number of grid points = {}".format(search.data.shape[0])))
...@@ -3,24 +3,20 @@ import matplotlib.pyplot as plt ...@@ -3,24 +3,20 @@ import matplotlib.pyplot as plt
import pyfstat import pyfstat
from make_simulated_data import tstart, duration, tref, F0, F1, F2, Alpha, Delta, outdir from make_simulated_data import tstart, duration, tref, F0, F1, F2, Alpha, Delta, outdir
plt.style.use('paper') plt.style.use("paper")
label = 'standard_directed_MCMC_search_on_1_glitch' label = "standard_directed_MCMC_search_on_1_glitch"
Nstar = 10000 Nstar = 10000
F0_width = np.sqrt(Nstar) * np.sqrt(12) / (np.pi * duration) F0_width = np.sqrt(Nstar) * np.sqrt(12) / (np.pi * duration)
F1_width = np.sqrt(Nstar) * np.sqrt(180) / (np.pi * duration ** 2) F1_width = np.sqrt(Nstar) * np.sqrt(180) / (np.pi * duration ** 2)
theta_prior = { theta_prior = {
'F0': {'type': 'unif', "F0": {"type": "unif", "lower": F0 - F0_width / 2.0, "upper": F0 + F0_width / 2.0},
'lower': F0-F0_width/2., "F1": {"type": "unif", "lower": F1 - F1_width / 2.0, "upper": F1 + F1_width / 2.0},
'upper': F0+F0_width/2.}, "F2": F2,
'F1': {'type': 'unif', "Alpha": Alpha,
'lower': F1-F1_width/2., "Delta": Delta,
'upper': F1+F1_width/2.},
'F2': F2,
'Alpha': Alpha,
'Delta': Delta,
} }
ntemps = 2 ntemps = 2
...@@ -29,15 +25,22 @@ nwalkers = 100 ...@@ -29,15 +25,22 @@ nwalkers = 100
nsteps = [500, 2000] nsteps = [500, 2000]
mcmc = pyfstat.MCMCSearch( mcmc = pyfstat.MCMCSearch(
label=label, sftfilepattern='data/*1_glitch*sft', theta_prior=theta_prior, label=label,
tref=tref, minStartTime=tstart, maxStartTime=tstart+duration, sftfilepattern="data/*1_glitch*sft",
nsteps=nsteps, nwalkers=nwalkers, ntemps=ntemps, theta_prior=theta_prior,
log10beta_min=log10beta_min) tref=tref,
minStartTime=tstart,
mcmc.transform_dictionary['F0'] = dict( maxStartTime=tstart + duration,
subtractor=F0, symbol='$f-f^\mathrm{s}$') nsteps=nsteps,
mcmc.transform_dictionary['F1'] = dict( nwalkers=nwalkers,
subtractor=F1, symbol='$\dot{f}-\dot{f}^\mathrm{s}$') ntemps=ntemps,
log10beta_min=log10beta_min,
)
mcmc.transform_dictionary["F0"] = dict(subtractor=F0, symbol="$f-f^\mathrm{s}$")
mcmc.transform_dictionary["F1"] = dict(
subtractor=F1, symbol="$\dot{f}-\dot{f}^\mathrm{s}$"
)
mcmc.run() mcmc.run()
mcmc.plot_corner() mcmc.plot_corner()
......
...@@ -7,7 +7,8 @@ try: ...@@ -7,7 +7,8 @@ try:
except ImportError: except ImportError:
raise ImportError( raise ImportError(
"Python module 'gridcorner' not found, please install from " "Python module 'gridcorner' not found, please install from "
"https://gitlab.aei.uni-hannover.de/GregAshton/gridcorner") "https://gitlab.aei.uni-hannover.de/GregAshton/gridcorner"
)
F0 = 30.0 F0 = 30.0
F1 = 1e-10 F1 = 1e-10
...@@ -20,18 +21,28 @@ sqrtSX = 1e-23 ...@@ -20,18 +21,28 @@ sqrtSX = 1e-23
tstart = 1000000000 tstart = 1000000000
duration = 10 * 86400 duration = 10 * 86400
tend = tstart + duration tend = tstart + duration
tref = .5*(tstart+tend) tref = 0.5 * (tstart + tend)
depth = 20 depth = 20
label = 'grid_F0F1F2' label = "grid_F0F1F2"
outdir = 'data' outdir = "data"
h0 = sqrtSX / depth h0 = sqrtSX / depth
data = pyfstat.Writer( data = pyfstat.Writer(
label=label, outdir=outdir, tref=tref, label=label,
tstart=tstart, F0=F0, F1=F1, F2=F2, duration=duration, Alpha=Alpha, outdir=outdir,
Delta=Delta, h0=h0, sqrtSX=sqrtSX) tref=tref,
tstart=tstart,
F0=F0,
F1=F1,
F2=F2,
duration=duration,
Alpha=Alpha,
Delta=Delta,
h0=h0,
sqrtSX=sqrtSX,
)
data.make_data() data.make_data()
m = 0.01 m = 0.01
...@@ -42,14 +53,24 @@ N = 100 ...@@ -42,14 +53,24 @@ N = 100
DeltaF0 = N * dF0 DeltaF0 = N * dF0
DeltaF1 = N * dF1 DeltaF1 = N * dF1
DeltaF2 = N * dF2 DeltaF2 = N * dF2
F0s = [F0-DeltaF0/2., F0+DeltaF0/2., dF0] F0s = [F0 - DeltaF0 / 2.0, F0 + DeltaF0 / 2.0, dF0]
F1s = [F1-DeltaF1/2., F1+DeltaF1/2., dF1] F1s = [F1 - DeltaF1 / 2.0, F1 + DeltaF1 / 2.0, dF1]
F2s = [F2-DeltaF2/2., F2+DeltaF2/2., dF2] F2s = [F2 - DeltaF2 / 2.0, F2 + DeltaF2 / 2.0, dF2]
Alphas = [Alpha] Alphas = [Alpha]
Deltas = [Delta] Deltas = [Delta]
search = pyfstat.GridSearch( search = pyfstat.GridSearch(
'grid_F0F1F2', 'data', data.sftfilepath, F0s, F1s, "grid_F0F1F2",
F2s, Alphas, Deltas, tref, tstart, tend) "data",
data.sftfilepath,
F0s,
F1s,
F2s,
Alphas,
Deltas,
tref,
tstart,
tend,
)
search.run() search.run()
F0_vals = np.unique(search.data[:, 2]) - F0 F0_vals = np.unique(search.data[:, 2]) - F0
...@@ -57,8 +78,13 @@ F1_vals = np.unique(search.data[:, 3]) - F1 ...@@ -57,8 +78,13 @@ F1_vals = np.unique(search.data[:, 3]) - F1
F2_vals = np.unique(search.data[:, 4]) - F2 F2_vals = np.unique(search.data[:, 4]) - F2
twoF = search.data[:, -1].reshape((len(F0_vals), len(F1_vals), len(F2_vals))) twoF = search.data[:, -1].reshape((len(F0_vals), len(F1_vals), len(F2_vals)))
xyz = [F0_vals, F1_vals, F2_vals] xyz = [F0_vals, F1_vals, F2_vals]
labels = ['$f - f_0$', '$\dot{f} - \dot{f}_0$', '$\ddot{f} - \ddot{f}_0$', labels = [
'$\widetilde{2\mathcal{F}}$'] "$f - f_0$",
"$\dot{f} - \dot{f}_0$",
"$\ddot{f} - \ddot{f}_0$",
"$\widetilde{2\mathcal{F}}$",
]
fig, axes = gridcorner( fig, axes = gridcorner(
twoF, xyz, projection='log_mean', labels=labels, whspace=0.1, factor=1.8) twoF, xyz, projection="log_mean", labels=labels, whspace=0.1, factor=1.8
fig.savefig('{}/{}_projection_matrix.png'.format(outdir, label)) )
fig.savefig("{}/{}_projection_matrix.png".format(outdir, label))
...@@ -13,50 +13,70 @@ sqrtSX = 1e-23 ...@@ -13,50 +13,70 @@ sqrtSX = 1e-23
tstart = 1000000000 tstart = 1000000000
duration = 100 * 86400 duration = 100 * 86400
tend = tstart + duration tend = tstart + duration
tref = .5*(tstart+tend) tref = 0.5 * (tstart + tend)
depth = 70 depth = 70
data_label = 'grided_frequency_depth_{:1.0f}'.format(depth) data_label = "grided_frequency_depth_{:1.0f}".format(depth)
h0 = sqrtSX / depth h0 = sqrtSX / depth
data = pyfstat.Writer( data = pyfstat.Writer(
label=data_label, outdir='data', tref=tref, label=data_label,
tstart=tstart, F0=F0, F1=F1, F2=F2, duration=duration, Alpha=Alpha, outdir="data",
Delta=Delta, h0=h0, sqrtSX=sqrtSX) tref=tref,
tstart=tstart,
F0=F0,
F1=F1,
F2=F2,
duration=duration,
Alpha=Alpha,
Delta=Delta,
h0=h0,
sqrtSX=sqrtSX,
)
data.make_data() data.make_data()
m = 0.001 m = 0.001
dF0 = np.sqrt(12 * m) / (np.pi * duration) dF0 = np.sqrt(12 * m) / (np.pi * duration)
DeltaF0 = 800 * dF0 DeltaF0 = 800 * dF0
F0s = [F0-DeltaF0/2., F0+DeltaF0/2., dF0] F0s = [F0 - DeltaF0 / 2.0, F0 + DeltaF0 / 2.0, dF0]
F1s = [F1] F1s = [F1]
F2s = [F2] F2s = [F2]
Alphas = [Alpha] Alphas = [Alpha]
Deltas = [Delta] Deltas = [Delta]
search = pyfstat.GridSearch( search = pyfstat.GridSearch(
'grided_frequency_search', 'data', 'data/*'+data_label+'*sft', F0s, F1s, "grided_frequency_search",
F2s, Alphas, Deltas, tref, tstart, tend) "data",
"data/*" + data_label + "*sft",
F0s,
F1s,
F2s,
Alphas,
Deltas,
tref,
tstart,
tend,
)
search.run() search.run()
fig, ax = plt.subplots() fig, ax = plt.subplots()
xidx = search.keys.index('F0') xidx = search.keys.index("F0")
frequencies = np.unique(search.data[:, xidx]) frequencies = np.unique(search.data[:, xidx])
twoF = search.data[:, -1] twoF = search.data[:, -1]
# mismatch = np.sign(x-F0)*(duration * np.pi * (x - F0))**2 / 12.0 # mismatch = np.sign(x-F0)*(duration * np.pi * (x - F0))**2 / 12.0
ax.plot(frequencies, twoF, 'k', lw=1) ax.plot(frequencies, twoF, "k", lw=1)
DeltaF = frequencies - F0 DeltaF = frequencies - F0
sinc = np.sin(np.pi * DeltaF * duration) / (np.pi * DeltaF * duration) sinc = np.sin(np.pi * DeltaF * duration) / (np.pi * DeltaF * duration)
A = np.abs((np.max(twoF) - 4) * sinc ** 2 + 4) A = np.abs((np.max(twoF) - 4) * sinc ** 2 + 4)
ax.plot(frequencies, A, '-r', lw=1) ax.plot(frequencies, A, "-r", lw=1)
ax.set_ylabel('$\widetilde{2\mathcal{F}}$') ax.set_ylabel("$\widetilde{2\mathcal{F}}$")
ax.set_xlabel('Frequency') ax.set_xlabel("Frequency")
ax.set_xlim(F0s[0], F0s[1]) ax.set_xlim(F0s[0], F0s[1])
dF0 = np.sqrt(12 * 1) / (np.pi * duration) dF0 = np.sqrt(12 * 1) / (np.pi * duration)
xticks = [F0 - 10 * dF0, F0, F0 + 10 * dF0] xticks = [F0 - 10 * dF0, F0, F0 + 10 * dF0]
ax.set_xticks(xticks) ax.set_xticks(xticks)
xticklabels = ['$f_0 {-} 10\Delta f$', '$f_0$', '$f_0 {+} 10\Delta f$'] xticklabels = ["$f_0 {-} 10\Delta f$", "$f_0$", "$f_0 {+} 10\Delta f$"]
ax.set_xticklabels(xticklabels) ax.set_xticklabels(xticklabels)
plt.tight_layout() plt.tight_layout()
fig.savefig('{}/{}_1D.png'.format(search.outdir, search.label), dpi=300) fig.savefig("{}/{}_1D.png".format(search.outdir, search.label), dpi=300)
...@@ -13,23 +13,43 @@ F1 = -1e-10 ...@@ -13,23 +13,43 @@ F1 = -1e-10
F2 = 0 F2 = 0
Alpha = np.radians(83.6292) Alpha = np.radians(83.6292)
Delta = np.radians(22.0144) Delta = np.radians(22.0144)
tref = .5*(tstart+tend) tref = 0.5 * (tstart + tend)
depth = 60 depth = 60
h0 = sqrtSX / depth h0 = sqrtSX / depth
data_label = 'sliding_window' data_label = "sliding_window"
data = pyfstat.Writer( data = pyfstat.Writer(
label=data_label, outdir='data', tref=tref, label=data_label,
tstart=tstart, F0=F0, F1=F1, F2=F2, duration=duration, Alpha=Alpha, outdir="data",
Delta=Delta, h0=h0, sqrtSX=sqrtSX) tref=tref,
tstart=tstart,
F0=F0,
F1=F1,
F2=F2,
duration=duration,
Alpha=Alpha,
Delta=Delta,
h0=h0,
sqrtSX=sqrtSX,
)
data.make_data() data.make_data()
DeltaF0 = 1e-5 DeltaF0 = 1e-5
search = pyfstat.FrequencySlidingWindow( search = pyfstat.FrequencySlidingWindow(
label='sliding_window', outdir='data', sftfilepattern='data/*sliding_window*sft', label="sliding_window",
F0s=[F0-DeltaF0, F0+DeltaF0, DeltaF0/100.], F1=F1, F2=0, outdir="data",
Alpha=Alpha, Delta=Delta, tref=tref, minStartTime=tstart, sftfilepattern="data/*sliding_window*sft",
maxStartTime=tend, window_size=25*86400, window_delta=1*86400) F0s=[F0 - DeltaF0, F0 + DeltaF0, DeltaF0 / 100.0],
F1=F1,
F2=0,
Alpha=Alpha,
Delta=Delta,
tref=tref,
minStartTime=tstart,
maxStartTime=tend,
window_size=25 * 86400,
window_delta=1 * 86400,
)
search.run() search.run()
search.plot_sliding_window() search.plot_sliding_window()
...@@ -13,37 +13,45 @@ F1 = -1e-10 ...@@ -13,37 +13,45 @@ F1 = -1e-10
F2 = 0 F2 = 0
Alpha = np.radians(83.6292) Alpha = np.radians(83.6292)
Delta = np.radians(22.0144) Delta = np.radians(22.0144)
tref = .5*(tstart+tend) tref = 0.5 * (tstart + tend)
depth = 100 depth = 100
h0 = sqrtSX / depth h0 = sqrtSX / depth
data_label = 'twoF_cumulative' data_label = "twoF_cumulative"
data = pyfstat.Writer( data = pyfstat.Writer(
label=data_label, outdir='data', tref=tref, label=data_label,
tstart=tstart, F0=F0, F1=F1, F2=F2, duration=duration, Alpha=Alpha, outdir="data",
Delta=Delta, h0=h0, sqrtSX=sqrtSX, detectors='H1,L1') tref=tref,
tstart=tstart,
F0=F0,
F1=F1,
F2=F2,
duration=duration,
Alpha=Alpha,
Delta=Delta,
h0=h0,
sqrtSX=sqrtSX,
detectors="H1,L1",
)
data.make_data() data.make_data()
# The predicted twoF, given by lalapps_predictFstat can be accessed by # The predicted twoF, given by lalapps_predictFstat can be accessed by
twoF = data.predict_fstat() twoF = data.predict_fstat()
print 'Predicted twoF value: {}\n'.format(twoF) print("Predicted twoF value: {}\n".format(twoF))
DeltaF0 = 1e-7 DeltaF0 = 1e-7
DeltaF1 = 1e-13 DeltaF1 = 1e-13
VF0 = (np.pi * duration * DeltaF0) ** 2 / 3.0 VF0 = (np.pi * duration * DeltaF0) ** 2 / 3.0
VF1 = (np.pi * duration**2 * DeltaF1)**2 * 4/45. VF1 = (np.pi * duration ** 2 * DeltaF1) ** 2 * 4 / 45.0
print '\nV={:1.2e}, VF0={:1.2e}, VF1={:1.2e}\n'.format(VF0*VF1, VF0, VF1) print("\nV={:1.2e}, VF0={:1.2e}, VF1={:1.2e}\n".format(VF0 * VF1, VF0, VF1))
theta_prior = {'F0': {'type': 'unif', theta_prior = {
'lower': F0-DeltaF0/2., "F0": {"type": "unif", "lower": F0 - DeltaF0 / 2.0, "upper": F0 + DeltaF0 / 2.0},
'upper': F0+DeltaF0/2.}, "F1": {"type": "unif", "lower": F1 - DeltaF1 / 2.0, "upper": F1 + DeltaF1 / 2.0},
'F1': {'type': 'unif', "F2": F2,
'lower': F1-DeltaF1/2., "Alpha": Alpha,
'upper': F1+DeltaF1/2.}, "Delta": Delta,
'F2': F2,
'Alpha': Alpha,
'Delta': Delta
} }
ntemps = 1 ntemps = 1
...@@ -52,10 +60,18 @@ nwalkers = 100 ...@@ -52,10 +60,18 @@ nwalkers = 100
nsteps = [50, 50] nsteps = [50, 50]
mcmc = pyfstat.MCMCSearch( mcmc = pyfstat.MCMCSearch(
label='twoF_cumulative', outdir='data', label="twoF_cumulative",
sftfilepattern='data/*'+data_label+'*sft', theta_prior=theta_prior, tref=tref, outdir="data",
minStartTime=tstart, maxStartTime=tend, nsteps=nsteps, nwalkers=nwalkers, sftfilepattern="data/*" + data_label + "*sft",
ntemps=ntemps, log10beta_min=log10beta_min) theta_prior=theta_prior,
tref=tref,
minStartTime=tstart,
maxStartTime=tend,
nsteps=nsteps,
nwalkers=nwalkers,
ntemps=ntemps,
log10beta_min=log10beta_min,
)
mcmc.run() mcmc.run()
mcmc.plot_corner(add_prior=True) mcmc.plot_corner(add_prior=True)
mcmc.print_summary() mcmc.print_summary()
......
...@@ -13,38 +13,45 @@ F1 = -1e-10 ...@@ -13,38 +13,45 @@ F1 = -1e-10
F2 = 0 F2 = 0
Alpha = np.radians(83.6292) Alpha = np.radians(83.6292)
Delta = np.radians(22.0144) Delta = np.radians(22.0144)
tref = .5*(tstart+tend) tref = 0.5 * (tstart + tend)
depth = 10 depth = 10
h0 = sqrtSX / depth h0 = sqrtSX / depth
label = 'using_initialisation' label = "using_initialisation"
outdir = 'data' outdir = "data"
data = pyfstat.Writer( data = pyfstat.Writer(
label=label, outdir=outdir, tref=tref, label=label,
tstart=tstart, F0=F0, F1=F1, F2=F2, duration=duration, Alpha=Alpha, outdir=outdir,
Delta=Delta, h0=h0, sqrtSX=sqrtSX) tref=tref,
tstart=tstart,
F0=F0,
F1=F1,
F2=F2,
duration=duration,
Alpha=Alpha,
Delta=Delta,
h0=h0,
sqrtSX=sqrtSX,
)
data.make_data() data.make_data()
# The predicted twoF, given by lalapps_predictFstat can be accessed by # The predicted twoF, given by lalapps_predictFstat can be accessed by
twoF = data.predict_fstat() twoF = data.predict_fstat()
print 'Predicted twoF value: {}\n'.format(twoF) print("Predicted twoF value: {}\n".format(twoF))
DeltaF0 = 1e-7 DeltaF0 = 1e-7
DeltaF1 = 1e-13 DeltaF1 = 1e-13
VF0 = (np.pi * duration * DeltaF0) ** 2 / 3.0 VF0 = (np.pi * duration * DeltaF0) ** 2 / 3.0
VF1 = (np.pi * duration**2 * DeltaF1)**2 * 4/45. VF1 = (np.pi * duration ** 2 * DeltaF1) ** 2 * 4 / 45.0
print '\nV={:1.2e}, VF0={:1.2e}, VF1={:1.2e}\n'.format(VF0*VF1, VF0, VF1) print("\nV={:1.2e}, VF0={:1.2e}, VF1={:1.2e}\n".format(VF0 * VF1, VF0, VF1))
theta_prior = {'F0': {'type': 'unif', theta_prior = {
'lower': F0-DeltaF0/2., "F0": {"type": "unif", "lower": F0 - DeltaF0 / 2.0, "upper": F0 + DeltaF0 / 2.0},
'upper': F0+DeltaF0/2.}, "F1": {"type": "unif", "lower": F1 - DeltaF1 / 2.0, "upper": F1 + DeltaF1 / 2.0},
'F1': {'type': 'unif', "F2": F2,
'lower': F1-DeltaF1/2., "Alpha": Alpha,
'upper': F1+DeltaF1/2.}, "Delta": Delta,
'F2': F2,
'Alpha': Alpha,
'Delta': Delta
} }
ntemps = 1 ntemps = 1
...@@ -53,11 +60,18 @@ nwalkers = 100 ...@@ -53,11 +60,18 @@ nwalkers = 100
nsteps = [100, 100] nsteps = [100, 100]
mcmc = pyfstat.MCMCSearch( mcmc = pyfstat.MCMCSearch(
label=label, outdir=outdir, label=label,
sftfilepattern='{}/*{}*sft'.format(outdir, label), outdir=outdir,
theta_prior=theta_prior, tref=tref, minStartTime=tstart, maxStartTime=tend, sftfilepattern="{}/*{}*sft".format(outdir, label),
nsteps=nsteps, nwalkers=nwalkers, ntemps=ntemps, theta_prior=theta_prior,
log10beta_min=log10beta_min) tref=tref,
minStartTime=tstart,
maxStartTime=tend,
nsteps=nsteps,
nwalkers=nwalkers,
ntemps=ntemps,
log10beta_min=log10beta_min,
)
mcmc.setup_initialisation(100, scatter_val=1e-10) mcmc.setup_initialisation(100, scatter_val=1e-10)
mcmc.run() mcmc.run()
mcmc.plot_corner(add_prior=True) mcmc.plot_corner(add_prior=True)
......
...@@ -16,19 +16,18 @@ tref = minStartTime ...@@ -16,19 +16,18 @@ tref = minStartTime
DeltaF0 = 6e-7 DeltaF0 = 6e-7
DeltaF1 = 1e-13 DeltaF1 = 1e-13
theta_prior = {'F0': {'type': 'unif', theta_prior = {
'lower': F0-DeltaF0/2., "F0": {"type": "unif", "lower": F0 - DeltaF0 / 2.0, "upper": F0 + DeltaF0 / 2.0},
'upper': F0+DeltaF0/2.}, "F1": {"type": "unif", "lower": F1 - DeltaF1 / 2.0, "upper": F1 + DeltaF1 / 2.0},
'F1': {'type': 'unif', "F2": F2,
'lower': F1-DeltaF1/2., "Alpha": Alpha,
'upper': F1+DeltaF1/2.}, "Delta": Delta,
'F2': F2, "transient_tstart": minStartTime,
'Alpha': Alpha, "transient_duration": {
'Delta': Delta, "type": "halfnorm",
'transient_tstart': minStartTime, "loc": 0.001 * Tspan,
'transient_duration': {'type': 'halfnorm', "scale": 0.5 * Tspan,
'loc': 0.001*Tspan, },
'scale': 0.5*Tspan}
} }
ntemps = 2 ntemps = 2
...@@ -37,12 +36,19 @@ nwalkers = 100 ...@@ -37,12 +36,19 @@ nwalkers = 100
nsteps = [100, 100] nsteps = [100, 100]
mcmc = pyfstat.MCMCTransientSearch( mcmc = pyfstat.MCMCTransientSearch(
label='transient_search', outdir='data_l', label="transient_search",
sftfilepattern='data_l/*simulated_transient_signal*sft', outdir="data_l",
theta_prior=theta_prior, tref=tref, minStartTime=minStartTime, sftfilepattern="data_l/*simulated_transient_signal*sft",
maxStartTime=maxStartTime, nsteps=nsteps, nwalkers=nwalkers, ntemps=ntemps, theta_prior=theta_prior,
tref=tref,
minStartTime=minStartTime,
maxStartTime=maxStartTime,
nsteps=nsteps,
nwalkers=nwalkers,
ntemps=ntemps,
log10beta_min=log10beta_min, log10beta_min=log10beta_min,
transientWindowType='rect') transientWindowType="rect",
)
mcmc.run() mcmc.run()
mcmc.plot_corner(label_offset=0.7) mcmc.plot_corner(label_offset=0.7)
mcmc.print_summary() mcmc.print_summary()
...@@ -19,8 +19,20 @@ h0 = 1e-23 ...@@ -19,8 +19,20 @@ h0 = 1e-23
sqrtSX = 1e-22 sqrtSX = 1e-22
transient = pyfstat.Writer( transient = pyfstat.Writer(
label='simulated_transient_signal', outdir='data_l', tref=tref, label="simulated_transient_signal",
tstart=transient_tstart, F0=F0, F1=F1, F2=F2, duration=transient_duration, outdir="data_l",
Alpha=Alpha, Delta=Delta, h0=h0, sqrtSX=sqrtSX, minStartTime=minStartTime, tref=tref,
maxStartTime=maxStartTime, transientWindowType='rect') tstart=transient_tstart,
F0=F0,
F1=F1,
F2=F2,
duration=transient_duration,
Alpha=Alpha,
Delta=Delta,
h0=h0,
sqrtSX=sqrtSX,
minStartTime=minStartTime,
maxStartTime=maxStartTime,
transientWindowType="rect",
)
transient.make_data() transient.make_data()
...@@ -18,21 +18,22 @@ Tsft = 1800 ...@@ -18,21 +18,22 @@ Tsft = 1800
DeltaF0 = 1e-2 DeltaF0 = 1e-2
DeltaF1 = 1e-9 DeltaF1 = 1e-9
theta_prior = {'F0': {'type': 'unif', theta_prior = {
'lower': F0-DeltaF0/2., "F0": {"type": "unif", "lower": F0 - DeltaF0 / 2.0, "upper": F0 + DeltaF0 / 2.0},
'upper': F0+DeltaF0/2.}, "F1": {"type": "unif", "lower": F1 - DeltaF1 / 2.0, "upper": F1 + DeltaF1 / 2.0},
'F1': {'type': 'unif', "F2": F2,
'lower': F1-DeltaF1/2., "Alpha": Alpha,
'upper': F1+DeltaF1/2.}, "Delta": Delta,
'F2': F2, "transient_tstart": {
'Alpha': Alpha, "type": "unif",
'Delta': Delta, "lower": minStartTime,
'transient_tstart': {'type': 'unif', "upper": maxStartTime - 2 * Tsft,
'lower': minStartTime, },
'upper': maxStartTime-2*Tsft}, "transient_duration": {
'transient_duration': {'type': 'unif', "type": "unif",
'lower': 2*Tsft, "lower": 2 * Tsft,
'upper': Tspan-2*Tsft} "upper": Tspan - 2 * Tsft,
},
} }
ntemps = 2 ntemps = 2
...@@ -41,12 +42,19 @@ nwalkers = 100 ...@@ -41,12 +42,19 @@ nwalkers = 100
nsteps = [100, 100] nsteps = [100, 100]
mcmc = pyfstat.MCMCTransientSearch( mcmc = pyfstat.MCMCTransientSearch(
label='transient_search', outdir='data_s', label="transient_search",
sftfilepattern='data_s/*simulated_transient_signal*sft', outdir="data_s",
theta_prior=theta_prior, tref=tref, minStartTime=minStartTime, sftfilepattern="data_s/*simulated_transient_signal*sft",
maxStartTime=maxStartTime, nsteps=nsteps, nwalkers=nwalkers, ntemps=ntemps, theta_prior=theta_prior,
tref=tref,
minStartTime=minStartTime,
maxStartTime=maxStartTime,
nsteps=nsteps,
nwalkers=nwalkers,
ntemps=ntemps,
log10beta_min=log10beta_min, log10beta_min=log10beta_min,
transientWindowType='rect') transientWindowType="rect",
)
mcmc.run() mcmc.run()
mcmc.plot_corner(label_offset=0.7) mcmc.plot_corner(label_offset=0.7)
mcmc.print_summary() mcmc.print_summary()
...@@ -5,7 +5,7 @@ import os ...@@ -5,7 +5,7 @@ import os
import numpy as np import numpy as np
import matplotlib.pyplot as plt import matplotlib.pyplot as plt
datadir = 'data_s' datadir = "data_s"
F0 = 30.0 F0 = 30.0
F1 = -1e-10 F1 = -1e-10
...@@ -23,37 +23,53 @@ Tsft = 1800 ...@@ -23,37 +23,53 @@ Tsft = 1800
m = 0.001 m = 0.001
dF0 = np.sqrt(12 * m) / (np.pi * Tspan) dF0 = np.sqrt(12 * m) / (np.pi * Tspan)
DeltaF0 = 100 * dF0 DeltaF0 = 100 * dF0
F0s = [F0-DeltaF0/2., F0+DeltaF0/2., dF0] F0s = [F0 - DeltaF0 / 2.0, F0 + DeltaF0 / 2.0, dF0]
F1s = [F1] F1s = [F1]
F2s = [F2] F2s = [F2]
Alphas = [Alpha] Alphas = [Alpha]
Deltas = [Delta] Deltas = [Delta]
print('Standard CW search:') print("Standard CW search:")
search1 = pyfstat.GridSearch( search1 = pyfstat.GridSearch(
label='CW', outdir=datadir, label="CW",
sftfilepattern=os.path.join(datadir,'*simulated_transient_signal*sft'), outdir=datadir,
F0s=F0s, F1s=F1s, F2s=F2s, Alphas=Alphas, Deltas=Deltas, tref=tref, sftfilepattern=os.path.join(datadir, "*simulated_transient_signal*sft"),
minStartTime=minStartTime, maxStartTime=maxStartTime, F0s=F0s,
BSGL=False) F1s=F1s,
F2s=F2s,
Alphas=Alphas,
Deltas=Deltas,
tref=tref,
minStartTime=minStartTime,
maxStartTime=maxStartTime,
BSGL=False,
)
search1.run() search1.run()
search1.print_max_twoF() search1.print_max_twoF()
search1.plot_1D(xkey='F0', search1.plot_1D(xkey="F0", xlabel="freq [Hz]", ylabel="$2\mathcal{F}$")
xlabel='freq [Hz]', ylabel='$2\mathcal{F}$')
print('with t0,tau bands:') print("with t0,tau bands:")
search2 = pyfstat.TransientGridSearch( search2 = pyfstat.TransientGridSearch(
label='tCW', outdir=datadir, label="tCW",
sftfilepattern=os.path.join(datadir,'*simulated_transient_signal*sft'), outdir=datadir,
F0s=F0s, F1s=F1s, F2s=F2s, Alphas=Alphas, Deltas=Deltas, tref=tref, sftfilepattern=os.path.join(datadir, "*simulated_transient_signal*sft"),
minStartTime=minStartTime, maxStartTime=maxStartTime, F0s=F0s,
transientWindowType='rect', t0Band=Tspan-2*Tsft, tauBand=Tspan, F1s=F1s,
F2s=F2s,
Alphas=Alphas,
Deltas=Deltas,
tref=tref,
minStartTime=minStartTime,
maxStartTime=maxStartTime,
transientWindowType="rect",
t0Band=Tspan - 2 * Tsft,
tauBand=Tspan,
BSGL=False, BSGL=False,
outputTransientFstatMap=True, outputTransientFstatMap=True,
tCWFstatMapVersion='lal') tCWFstatMapVersion="lal",
)
search2.run() search2.run()
search2.print_max_twoF() search2.print_max_twoF()
search2.plot_1D(xkey='F0', search2.plot_1D(xkey="F0", xlabel="freq [Hz]", ylabel="$2\mathcal{F}$")
xlabel='freq [Hz]', ylabel='$2\mathcal{F}$')
...@@ -17,15 +17,27 @@ tref = minStartTime ...@@ -17,15 +17,27 @@ tref = minStartTime
h0 = 1e-23 h0 = 1e-23
sqrtSX = 1e-22 sqrtSX = 1e-22
detectors = 'H1,L1' detectors = "H1,L1"
Tsft = 1800 Tsft = 1800
transient = pyfstat.Writer( transient = pyfstat.Writer(
label='simulated_transient_signal', outdir='data_s', label="simulated_transient_signal",
tref=tref, tstart=transient_tstart, duration=transient_duration, outdir="data_s",
F0=F0, F1=F1, F2=F2, Alpha=Alpha, Delta=Delta, h0=h0, tref=tref,
detectors=detectors,sqrtSX=sqrtSX, tstart=transient_tstart,
minStartTime=minStartTime, maxStartTime=maxStartTime, duration=transient_duration,
transientWindowType='rect', Tsft=Tsft) F0=F0,
F1=F1,
F2=F2,
Alpha=Alpha,
Delta=Delta,
h0=h0,
detectors=detectors,
sqrtSX=sqrtSX,
minStartTime=minStartTime,
maxStartTime=maxStartTime,
transientWindowType="rect",
Tsft=Tsft,
)
transient.make_data() transient.make_data()
from __future__ import division as _division from .core import (
BaseSearchClass,
ComputeFstat,
SemiCoherentSearch,
SemiCoherentGlitchSearch,
)
from .make_sfts import (
Writer,
GlitchWriter,
FrequencyModulatedArtifactWriter,
FrequencyAmplitudeModulatedArtifactWriter,
)
from .mcmc_based_searches import (
MCMCSearch,
MCMCGlitchSearch,
MCMCSemiCoherentSearch,
MCMCFollowUpSearch,
MCMCTransientSearch,
)
from .grid_based_searches import (
GridSearch,
GridUniformPriorSearch,
GridGlitchSearch,
FrequencySlidingWindow,
DMoff_NO_SPIN,
SliceGridSearch,
TransientGridSearch,
)
from .core import BaseSearchClass, ComputeFstat, SemiCoherentSearch, SemiCoherentGlitchSearch
from .make_sfts import Writer, GlitchWriter, FrequencyModulatedArtifactWriter, FrequencyAmplitudeModulatedArtifactWriter from .helper_functions import get_version_information
from .mcmc_based_searches import MCMCSearch, MCMCGlitchSearch, MCMCSemiCoherentSearch, MCMCFollowUpSearch, MCMCTransientSearch
from .grid_based_searches import GridSearch, GridUniformPriorSearch, GridGlitchSearch, FrequencySlidingWindow, DMoff_NO_SPIN, SliceGridSearch, TransientGridSearch __version__ = get_version_information()