Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
PyFstat
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
Operations
Operations
Incidents
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Gregory Ashton
PyFstat
Commits
a2acfcff
Commit
a2acfcff
authored
Jul 01, 2019
by
Reinhard Prix
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
apply 'black' coding style (stricter subset of PEP8)
- supply consistent flake8 settings in setup.cfg
parent
96e1046c
Changes
30
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
30 changed files
with
4577 additions
and
2682 deletions
+4577
-2682
examples/MCMC_examples/fully_coherent_search_using_MCMC.py
examples/MCMC_examples/fully_coherent_search_using_MCMC.py
+43
-27
examples/MCMC_examples/semi_coherent_search_using_MCMC.py
examples/MCMC_examples/semi_coherent_search_using_MCMC.py
+44
-28
examples/followup_examples/semi_coherent_directed_follow_up.py
...les/followup_examples/semi_coherent_directed_follow_up.py
+50
-30
examples/glitch_examples/make_simulated_data.py
examples/glitch_examples/make_simulated_data.py
+53
-15
examples/glitch_examples/semicoherent_glitch_robust_directed_MCMC_search_on_1_glitch.py
...oherent_glitch_robust_directed_MCMC_search_on_1_glitch.py
+67
-43
examples/glitch_examples/semicoherent_glitch_robust_directed_grid_search_on_1_glitch.py
...oherent_glitch_robust_directed_grid_search_on_1_glitch.py
+61
-29
examples/glitch_examples/standard_directed_MCMC_search_on_1_glitch.py
...tch_examples/standard_directed_MCMC_search_on_1_glitch.py
+26
-23
examples/grid_examples/grid_F0F1F2.py
examples/grid_examples/grid_F0F1F2.py
+49
-23
examples/grid_examples/grided_frequency_search.py
examples/grid_examples/grided_frequency_search.py
+44
-24
examples/other_examples/sliding_window.py
examples/other_examples/sliding_window.py
+30
-10
examples/other_examples/twoF_cumulative.py
examples/other_examples/twoF_cumulative.py
+40
-24
examples/other_examples/using_initialisation.py
examples/other_examples/using_initialisation.py
+40
-26
examples/transient_examples/long_transient_search_MCMC.py
examples/transient_examples/long_transient_search_MCMC.py
+26
-20
examples/transient_examples/long_transient_search_make_simulated_data.py
...ent_examples/long_transient_search_make_simulated_data.py
+19
-7
examples/transient_examples/short_transient_search_MCMC.py
examples/transient_examples/short_transient_search_MCMC.py
+30
-22
examples/transient_examples/short_transient_search_gridded.py
...ples/transient_examples/short_transient_search_gridded.py
+38
-22
examples/transient_examples/short_transient_search_make_simulated_data.py
...nt_examples/short_transient_search_make_simulated_data.py
+22
-10
pyfstat/__init__.py
pyfstat/__init__.py
+28
-6
pyfstat/core.py
pyfstat/core.py
+533
-317
pyfstat/grid_based_searches.py
pyfstat/grid_based_searches.py
+746
-368
pyfstat/helper_functions.py
pyfstat/helper_functions.py
+129
-86
pyfstat/injection_helper_functions.py
pyfstat/injection_helper_functions.py
+16
-18
pyfstat/make_sfts.py
pyfstat/make_sfts.py
+379
-173
pyfstat/mcmc_based_searches.py
pyfstat/mcmc_based_searches.py
+1329
-878
pyfstat/optimal_setup_functions.py
pyfstat/optimal_setup_functions.py
+67
-50
pyfstat/tcw_fstat_map_funcs.py
pyfstat/tcw_fstat_map_funcs.py
+309
-241
requirements.txt
requirements.txt
+1
-0
setup.cfg
setup.cfg
+8
-0
setup.py
setup.py
+26
-21
tests.py
tests.py
+324
-141
No files found.
examples/MCMC_examples/fully_coherent_search_using_MCMC.py
View file @
a2acfcff
...
...
@@ -4,7 +4,7 @@ import numpy as np
# Properties of the GW data
sqrtSX
=
1e-23
tstart
=
1000000000
duration
=
100
*
86400
duration
=
100
*
86400
tend
=
tstart
+
duration
# Properties of the signal
...
...
@@ -13,39 +13,46 @@ F1 = -1e-10
F2
=
0
Alpha
=
np
.
radians
(
83.6292
)
Delta
=
np
.
radians
(
22.0144
)
tref
=
.
5
*
(
tstart
+
tend
)
tref
=
0.5
*
(
tstart
+
tend
)
depth
=
10
h0
=
sqrtSX
/
depth
label
=
'fully_coherent_search_using_MCMC'
outdir
=
'data'
label
=
"fully_coherent_search_using_MCMC"
outdir
=
"data"
data
=
pyfstat
.
Writer
(
label
=
label
,
outdir
=
outdir
,
tref
=
tref
,
tstart
=
tstart
,
F0
=
F0
,
F1
=
F1
,
F2
=
F2
,
duration
=
duration
,
Alpha
=
Alpha
,
Delta
=
Delta
,
h0
=
h0
,
sqrtSX
=
sqrtSX
)
label
=
label
,
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
()
# The predicted twoF, given by lalapps_predictFstat can be accessed by
twoF
=
data
.
predict_fstat
()
print
(
'Predicted twoF value: {}
\n
'
.
format
(
twoF
))
print
(
"Predicted twoF value: {}
\n
"
.
format
(
twoF
))
DeltaF0
=
1e-7
DeltaF1
=
1e-13
VF0
=
(
np
.
pi
*
duration
*
DeltaF0
)
**
2
/
3.0
VF1
=
(
np
.
pi
*
duration
**
2
*
DeltaF1
)
**
2
*
4
/
45.
print
(
'
\n
V={:1.2e}, VF0={:1.2e}, VF1={:1.2e}
\n
'
.
format
(
VF0
*
VF1
,
VF0
,
VF1
))
VF0
=
(
np
.
pi
*
duration
*
DeltaF0
)
**
2
/
3.0
VF1
=
(
np
.
pi
*
duration
**
2
*
DeltaF1
)
**
2
*
4
/
45.0
print
(
"
\n
V={:1.2e}, VF0={:1.2e}, VF1={:1.2e}
\n
"
.
format
(
VF0
*
VF1
,
VF0
,
VF1
))
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
}
theta_prior
=
{
"F0"
:
{
"type"
:
"unif"
,
"lower"
:
F0
-
DeltaF0
/
2.0
,
"upper"
:
F0
+
DeltaF0
/
2.0
},
"F1"
:
{
"type"
:
"unif"
,
"lower"
:
F1
-
DeltaF1
/
2.0
,
"upper"
:
F1
+
DeltaF1
/
2.0
},
"F2"
:
F2
,
"Alpha"
:
Alpha
,
"Delta"
:
Delta
,
}
ntemps
=
2
log10beta_min
=
-
0.5
...
...
@@ -53,13 +60,22 @@ nwalkers = 100
nsteps
=
[
300
,
300
]
mcmc
=
pyfstat
.
MCMCSearch
(
label
=
label
,
outdir
=
outdir
,
sftfilepattern
=
'{}/*{}*sft'
.
format
(
outdir
,
label
),
theta_prior
=
theta_prior
,
tref
=
tref
,
minStartTime
=
tstart
,
maxStartTime
=
tend
,
nsteps
=
nsteps
,
nwalkers
=
nwalkers
,
ntemps
=
ntemps
,
log10beta_min
=
log10beta_min
)
label
=
label
,
outdir
=
outdir
,
sftfilepattern
=
"{}/*{}*sft"
.
format
(
outdir
,
label
),
theta_prior
=
theta_prior
,
tref
=
tref
,
minStartTime
=
tstart
,
maxStartTime
=
tend
,
nsteps
=
nsteps
,
nwalkers
=
nwalkers
,
ntemps
=
ntemps
,
log10beta_min
=
log10beta_min
,
)
mcmc
.
transform_dictionary
=
dict
(
F0
=
dict
(
subtractor
=
F0
,
symbol
=
'$f-f^\mathrm{s}$'
),
F1
=
dict
(
subtractor
=
F1
,
symbol
=
'$\dot{f}-\dot{f}^\mathrm{s}$'
))
F0
=
dict
(
subtractor
=
F0
,
symbol
=
"$f-f^\mathrm{s}$"
),
F1
=
dict
(
subtractor
=
F1
,
symbol
=
"$\dot{f}-\dot{f}^\mathrm{s}$"
),
)
mcmc
.
run
()
mcmc
.
plot_corner
(
add_prior
=
True
)
mcmc
.
print_summary
()
examples/MCMC_examples/semi_coherent_search_using_MCMC.py
View file @
a2acfcff
...
...
@@ -4,7 +4,7 @@ import numpy as np
# Properties of the GW data
sqrtSX
=
1e-23
tstart
=
1000000000
duration
=
100
*
86400
duration
=
100
*
86400
tend
=
tstart
+
duration
# Properties of the signal
...
...
@@ -13,39 +13,46 @@ F1 = -1e-10
F2
=
0
Alpha
=
np
.
radians
(
83.6292
)
Delta
=
np
.
radians
(
22.0144
)
tref
=
.
5
*
(
tstart
+
tend
)
tref
=
0.5
*
(
tstart
+
tend
)
depth
=
10
h0
=
sqrtSX
/
depth
label
=
'semicoherent_search_using_MCMC'
outdir
=
'data'
label
=
"semicoherent_search_using_MCMC"
outdir
=
"data"
data
=
pyfstat
.
Writer
(
label
=
label
,
outdir
=
outdir
,
tref
=
tref
,
tstart
=
tstart
,
F0
=
F0
,
F1
=
F1
,
F2
=
F2
,
duration
=
duration
,
Alpha
=
Alpha
,
Delta
=
Delta
,
h0
=
h0
,
sqrtSX
=
sqrtSX
)
label
=
label
,
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
()
# The predicted twoF, given by lalapps_predictFstat can be accessed by
twoF
=
data
.
predict_fstat
()
print
(
'Predicted twoF value: {}
\n
'
.
format
(
twoF
))
print
(
"Predicted twoF value: {}
\n
"
.
format
(
twoF
))
DeltaF0
=
1e-7
DeltaF1
=
1e-13
VF0
=
(
np
.
pi
*
duration
*
DeltaF0
)
**
2
/
3.0
VF1
=
(
np
.
pi
*
duration
**
2
*
DeltaF1
)
**
2
*
4
/
45.
print
(
'
\n
V={:1.2e}, VF0={:1.2e}, VF1={:1.2e}
\n
'
.
format
(
VF0
*
VF1
,
VF0
,
VF1
))
VF0
=
(
np
.
pi
*
duration
*
DeltaF0
)
**
2
/
3.0
VF1
=
(
np
.
pi
*
duration
**
2
*
DeltaF1
)
**
2
*
4
/
45.0
print
(
"
\n
V={:1.2e}, VF0={:1.2e}, VF1={:1.2e}
\n
"
.
format
(
VF0
*
VF1
,
VF0
,
VF1
))
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
}
theta_prior
=
{
"F0"
:
{
"type"
:
"unif"
,
"lower"
:
F0
-
DeltaF0
/
2.0
,
"upper"
:
F0
+
DeltaF0
/
2.0
},
"F1"
:
{
"type"
:
"unif"
,
"lower"
:
F1
-
DeltaF1
/
2.0
,
"upper"
:
F1
+
DeltaF1
/
2.0
},
"F2"
:
F2
,
"Alpha"
:
Alpha
,
"Delta"
:
Delta
,
}
ntemps
=
1
log10beta_min
=
-
1
...
...
@@ -53,14 +60,23 @@ nwalkers = 100
nsteps
=
[
300
,
300
]
mcmc
=
pyfstat
.
MCMCSemiCoherentSearch
(
label
=
label
,
outdir
=
outdir
,
nsegs
=
10
,
sftfilepattern
=
'{}/*{}*sft'
.
format
(
outdir
,
label
),
theta_prior
=
theta_prior
,
tref
=
tref
,
minStartTime
=
tstart
,
maxStartTime
=
tend
,
nsteps
=
nsteps
,
nwalkers
=
nwalkers
,
ntemps
=
ntemps
,
log10beta_min
=
log10beta_min
)
label
=
label
,
outdir
=
outdir
,
nsegs
=
10
,
sftfilepattern
=
"{}/*{}*sft"
.
format
(
outdir
,
label
),
theta_prior
=
theta_prior
,
tref
=
tref
,
minStartTime
=
tstart
,
maxStartTime
=
tend
,
nsteps
=
nsteps
,
nwalkers
=
nwalkers
,
ntemps
=
ntemps
,
log10beta_min
=
log10beta_min
,
)
mcmc
.
transform_dictionary
=
dict
(
F0
=
dict
(
subtractor
=
F0
,
symbol
=
'$f-f^\mathrm{s}$'
),
F1
=
dict
(
subtractor
=
F1
,
symbol
=
'$\dot{f}-\dot{f}^\mathrm{s}$'
))
F0
=
dict
(
subtractor
=
F0
,
symbol
=
"$f-f^\mathrm{s}$"
),
F1
=
dict
(
subtractor
=
F1
,
symbol
=
"$\dot{f}-\dot{f}^\mathrm{s}$"
),
)
mcmc
.
run
()
mcmc
.
plot_corner
(
add_prior
=
True
)
mcmc
.
print_summary
()
examples/followup_examples/semi_coherent_directed_follow_up.py
View file @
a2acfcff
...
...
@@ -11,39 +11,47 @@ Delta = np.radians(22.0144)
# Properties of the GW data
sqrtSX
=
1e-23
tstart
=
1000000000
duration
=
100
*
86400
tend
=
tstart
+
duration
tref
=
.
5
*
(
tstart
+
tend
)
duration
=
100
*
86400
tend
=
tstart
+
duration
tref
=
0.5
*
(
tstart
+
tend
)
depth
=
40
label
=
'semicoherent_directed_follow_up'
outdir
=
'data'
label
=
"semicoherent_directed_follow_up"
outdir
=
"data"
h0
=
sqrtSX
/
depth
data
=
pyfstat
.
Writer
(
label
=
label
,
outdir
=
outdir
,
tref
=
tref
,
tstart
=
tstart
,
F0
=
F0
,
F1
=
F1
,
F2
=
F2
,
duration
=
duration
,
Alpha
=
Alpha
,
Delta
=
Delta
,
h0
=
h0
,
sqrtSX
=
sqrtSX
)
label
=
label
,
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
()
# The predicted twoF, given by lalapps_predictFstat can be accessed by
twoF
=
data
.
predict_fstat
()
print
(
'Predicted twoF value: {}
\n
'
.
format
(
twoF
))
print
(
"Predicted twoF value: {}
\n
"
.
format
(
twoF
))
# Search
VF0
=
VF1
=
1e5
DeltaF0
=
np
.
sqrt
(
VF0
)
*
np
.
sqrt
(
3
)
/
(
np
.
pi
*
duration
)
DeltaF1
=
np
.
sqrt
(
VF1
)
*
np
.
sqrt
(
180
)
/
(
np
.
pi
*
duration
**
2
)
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
}
DeltaF0
=
np
.
sqrt
(
VF0
)
*
np
.
sqrt
(
3
)
/
(
np
.
pi
*
duration
)
DeltaF1
=
np
.
sqrt
(
VF1
)
*
np
.
sqrt
(
180
)
/
(
np
.
pi
*
duration
**
2
)
theta_prior
=
{
"F0"
:
{
"type"
:
"unif"
,
"lower"
:
F0
-
DeltaF0
/
2.0
,
"upper"
:
F0
+
DeltaF0
/
2
},
"F1"
:
{
"type"
:
"unif"
,
"lower"
:
F1
-
DeltaF1
/
2.0
,
"upper"
:
F1
+
DeltaF1
/
2
},
"F2"
:
F2
,
"Alpha"
:
Alpha
,
"Delta"
:
Delta
,
}
ntemps
=
3
log10beta_min
=
-
0.5
...
...
@@ -51,23 +59,35 @@ nwalkers = 100
nsteps
=
[
100
,
100
]
mcmc
=
pyfstat
.
MCMCFollowUpSearch
(
label
=
label
,
outdir
=
outdir
,
sftfilepattern
=
'{}/*{}*sft'
.
format
(
outdir
,
label
),
theta_prior
=
theta_prior
,
tref
=
tref
,
minStartTime
=
tstart
,
maxStartTime
=
tend
,
nwalkers
=
nwalkers
,
nsteps
=
nsteps
,
ntemps
=
ntemps
,
log10beta_min
=
log10beta_min
)
label
=
label
,
outdir
=
outdir
,
sftfilepattern
=
"{}/*{}*sft"
.
format
(
outdir
,
label
),
theta_prior
=
theta_prior
,
tref
=
tref
,
minStartTime
=
tstart
,
maxStartTime
=
tend
,
nwalkers
=
nwalkers
,
nsteps
=
nsteps
,
ntemps
=
ntemps
,
log10beta_min
=
log10beta_min
,
)
NstarMax
=
1000
Nsegs0
=
100
fig
,
axes
=
plt
.
subplots
(
nrows
=
2
,
figsize
=
(
3.4
,
3.5
))
fig
,
axes
=
mcmc
.
run
(
NstarMax
=
NstarMax
,
Nsegs0
=
Nsegs0
,
labelpad
=
0.01
,
plot_det_stat
=
False
,
return_fig
=
True
,
fig
=
fig
,
axes
=
axes
)
NstarMax
=
NstarMax
,
Nsegs0
=
Nsegs0
,
labelpad
=
0.01
,
plot_det_stat
=
False
,
return_fig
=
True
,
fig
=
fig
,
axes
=
axes
,
)
for
ax
in
axes
:
ax
.
grid
()
ax
.
set_xticks
(
np
.
arange
(
0
,
600
,
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
.
savefig
(
'{}/{}_walkers.png'
.
format
(
mcmc
.
outdir
,
mcmc
.
label
),
dpi
=
400
)
fig
.
savefig
(
"{}/{}_walkers.png"
.
format
(
mcmc
.
outdir
,
mcmc
.
label
),
dpi
=
400
)
examples/glitch_examples/make_simulated_data.py
View file @
a2acfcff
from
pyfstat
import
Writer
,
GlitchWriter
import
numpy
as
np
outdir
=
'data'
outdir
=
"data"
# First, we generate data with a reasonably strong smooth signal
# Define parameters of the Crab pulsar as an example
...
...
@@ -17,37 +17,75 @@ h0 = 5e-24
# Properties of the GW data
sqrtSX
=
1e-22
tstart
=
1000000000
duration
=
50
*
86400
tend
=
tstart
+
duration
tref
=
tstart
+
0.5
*
duration
duration
=
50
*
86400
tend
=
tstart
+
duration
tref
=
tstart
+
0.5
*
duration
data
=
Writer
(
label
=
'0_glitch'
,
outdir
=
outdir
,
tref
=
tref
,
tstart
=
tstart
,
F0
=
F0
,
F1
=
F1
,
F2
=
F2
,
duration
=
duration
,
Alpha
=
Alpha
,
Delta
=
Delta
,
h0
=
h0
,
sqrtSX
=
sqrtSX
)
label
=
"0_glitch"
,
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
()
# Next, taking the same signal parameters, we include a glitch half way through
dtglitch
=
duration
/
2.0
dtglitch
=
duration
/
2.0
delta_F0
=
5e-6
delta_F1
=
0
glitch_data
=
GlitchWriter
(
label
=
'1_glitch'
,
outdir
=
outdir
,
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
)
label
=
"1_glitch"
,
outdir
=
outdir
,
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
()
# Making data with two glitches
dtglitch_2
=
[
duration
/
4.0
,
4
*
duration
/
5.0
]
dtglitch_2
=
[
duration
/
4.0
,
4
*
duration
/
5.0
]
delta_phi_2
=
[
0
,
0
]
delta_F0_2
=
[
4e-6
,
3e-7
]
delta_F1_2
=
[
0
,
0
]
delta_F2_2
=
[
0
,
0
]
two_glitch_data
=
GlitchWriter
(
label
=
'2_glitch'
,
outdir
=
outdir
,
tref
=
tref
,
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
)
label
=
"2_glitch"
,
outdir
=
outdir
,
tref
=
tref
,
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
()
examples/glitch_examples/semicoherent_glitch_robust_directed_MCMC_search_on_1_glitch.py
View file @
a2acfcff
...
...
@@ -3,34 +3,42 @@ import matplotlib.pyplot as plt
import
pyfstat
import
gridcorner
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
F0_width
=
np
.
sqrt
(
Nstar
)
*
np
.
sqrt
(
12
)
/
(
np
.
pi
*
duration
)
F1_width
=
np
.
sqrt
(
Nstar
)
*
np
.
sqrt
(
180
)
/
(
np
.
pi
*
duration
**
2
)
F0_width
=
np
.
sqrt
(
Nstar
)
*
np
.
sqrt
(
12
)
/
(
np
.
pi
*
duration
)
F1_width
=
np
.
sqrt
(
Nstar
)
*
np
.
sqrt
(
180
)
/
(
np
.
pi
*
duration
**
2
)
theta_prior
=
{
'F0'
:
{
'type'
:
'unif'
,
'lower'
:
F0
-
F0_width
/
2.
,
'upper'
:
F0
+
F0_width
/
2.
},
'F1'
:
{
'type'
:
'unif'
,
'lower'
:
F1
-
F1_width
/
2.
,
'upper'
:
F1
+
F1_width
/
2.
},
'F2'
:
F2
,
'delta_F0'
:
{
'type'
:
'unif'
,
'lower'
:
0
,
'upper'
:
1e-5
},
'delta_F1'
:
0
,
'tglitch'
:
{
'type'
:
'unif'
,
'lower'
:
tstart
+
0.1
*
duration
,
'upper'
:
tstart
+
0.9
*
duration
},
'Alpha'
:
Alpha
,
'Delta'
:
Delta
,
}
"F0"
:
{
"type"
:
"unif"
,
"lower"
:
F0
-
F0_width
/
2.0
,
"upper"
:
F0
+
F0_width
/
2.0
},
"F1"
:
{
"type"
:
"unif"
,
"lower"
:
F1
-
F1_width
/
2.0
,
"upper"
:
F1
+
F1_width
/
2.0
},
"F2"
:
F2
,
"delta_F0"
:
{
"type"
:
"unif"
,
"lower"
:
0
,
"upper"
:
1e-5
},
"delta_F1"
:
0
,
"tglitch"
:
{
"type"
:
"unif"
,
"lower"
:
tstart
+
0.1
*
duration
,
"upper"
:
tstart
+
0.9
*
duration
,
},
"Alpha"
:
Alpha
,
"Delta"
:
Delta
,
}
ntemps
=
3
log10beta_min
=
-
0.5
...
...
@@ -38,33 +46,49 @@ nwalkers = 100
nsteps
=
[
250
,
250
]
mcmc
=
pyfstat
.
MCMCGlitchSearch
(
label
=
label
,
sftfilepattern
=
'data/*1_glitch*sft'
,
theta_prior
=
theta_prior
,
tref
=
tref
,
minStartTime
=
tstart
,
maxStartTime
=
tstart
+
duration
,
nsteps
=
nsteps
,
nwalkers
=
nwalkers
,
ntemps
=
ntemps
,
log10beta_min
=
log10beta_min
,
nglitch
=
1
)
mcmc
.
transform_dictionary
[
'F0'
]
=
dict
(
subtractor
=
F0
,
multiplier
=
1e6
,
symbol
=
'$f-f_\mathrm{s}$'
)
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]'
label
=
label
,
sftfilepattern
=
"data/*1_glitch*sft"
,
theta_prior
=
theta_prior
,
tref
=
tref
,
minStartTime
=
tstart
,
maxStartTime
=
tstart
+
duration
,
nsteps
=
nsteps
,
nwalkers
=
nwalkers
,
ntemps
=
ntemps
,
log10beta_min
=
log10beta_min
,
nglitch
=
1
,
)
mcmc
.
transform_dictionary
[
"F0"
]
=
dict
(
subtractor
=
F0
,
multiplier
=
1e6
,
symbol
=
"$f-f_\mathrm{s}$"
)
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
()
mcmc
.
run
()
dT
=
time
.
time
()
-
t1
fig_and_axes
=
gridcorner
.
_get_fig_and_axes
(
4
,
2
,
0.05
)
mcmc
.
plot_corner
(
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
),
truth_color
=
'C3'
)
mcmc
.
plot_corner
(
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
),
truth_color
=
"C3"
,
)
mcmc
.
print_summary
()
print
((
'Prior widths ='
,
F0_width
,
F1_width
))
print
((
"Prior widths ="
,
F0_width
,
F1_width
))
print
((
"Actual run time = {}"
.
format
(
dT
)))
examples/glitch_examples/semicoherent_glitch_robust_directed_grid_search_on_1_glitch.py
View file @
a2acfcff
import
pyfstat
import
numpy
as
np
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
try
:
...
...
@@ -9,34 +21,46 @@ try:
except
ImportError
:
raise
ImportError
(
"Python module 'gridcorner' not found, please install from "
"https://gitlab.aei.uni-hannover.de/GregAshton/gridcorner"
)