Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Gregory Ashton
PyFstat
Commits
1b1caf04
Commit
1b1caf04
authored
Jul 18, 2017
by
David Keitel
Browse files
Merge branch 'renaming_sftfilepath_to_pattern' into 'master'
Renames sftfilepath -> sftfilepattern See merge request
!6
parents
54b82bdb
89f200ed
Changes
15
Hide whitespace changes
Inline
Side-by-side
examples/computing_the_Bayes_factor.py
View file @
1b1caf04
...
...
@@ -24,7 +24,7 @@ nwalkers = 100
nsteps
=
[
500
,
500
]
mcmc
=
MCMCSearch
(
label
=
'computing_the_Bayes_factor'
,
outdir
=
'data'
,
sftfilepat
h
=
'data/*basic*sft'
,
theta_prior
=
theta_prior
,
sftfilepat
tern
=
'data/*basic*sft'
,
theta_prior
=
theta_prior
,
tref
=
tref
,
tstart
=
tstart
,
tend
=
tend
,
nsteps
=
nsteps
,
nwalkers
=
nwalkers
,
ntemps
=
ntemps
,
log10temperature_min
=
log10temperature_min
)
...
...
examples/follow_up.py
View file @
1b1caf04
...
...
@@ -26,7 +26,7 @@ run_setup = [(1000, 50), (1000, 25), (1000, 1, False),
mcmc
=
pyfstat
.
MCMCFollowUpSearch
(
label
=
'follow_up'
,
outdir
=
'data'
,
sftfilepat
h
=
'data/*basic*sft'
,
theta_prior
=
theta_prior
,
tref
=
tref
,
sftfilepat
tern
=
'data/*basic*sft'
,
theta_prior
=
theta_prior
,
tref
=
tref
,
minStartTime
=
tstart
,
maxStartTime
=
tend
,
nwalkers
=
nwalkers
,
ntemps
=
ntemps
,
log10temperature_min
=
log10temperature_min
)
mcmc
.
run
(
run_setup
)
...
...
examples/fully_coherent_search_using_MCMC.py
View file @
1b1caf04
...
...
@@ -53,7 +53,7 @@ nsteps = [50, 50]
mcmc
=
pyfstat
.
MCMCSearch
(
label
=
'fully_coherent_search_using_MCMC'
,
outdir
=
'data'
,
sftfilepat
h
=
'data/*'
+
data_label
+
'*sft'
,
theta_prior
=
theta_prior
,
tref
=
tref
,
sftfilepat
tern
=
'data/*'
+
data_label
+
'*sft'
,
theta_prior
=
theta_prior
,
tref
=
tref
,
minStartTime
=
tstart
,
maxStartTime
=
tend
,
nsteps
=
nsteps
,
nwalkers
=
nwalkers
,
ntemps
=
ntemps
,
log10temperature_min
=
log10temperature_min
)
mcmc
.
run
(
context
=
'paper'
,
subtractions
=
[
30
,
-
1e-10
])
...
...
examples/fully_coherent_search_using_MCMC_on_glitching_data.py
View file @
1b1caf04
...
...
@@ -26,7 +26,7 @@ nwalkers = 100
nsteps
=
[
500
,
500
]
mcmc
=
MCMCSearch
(
'fully_coherent_search_using_MCMC_on_glitching_data'
,
'data'
,
sftfilepat
h
=
'data/*_glitch*.sft'
,
sftfilepat
tern
=
'data/*_glitch*.sft'
,
theta_prior
=
theta_prior
,
tref
=
tref
,
minStartTime
=
tstart
,
maxStartTime
=
tend
,
nsteps
=
nsteps
,
nwalkers
=
nwalkers
,
ntemps
=
ntemps
,
log10temperature_min
=
log10temperature_min
)
...
...
examples/glitch_robust_search.py
View file @
1b1caf04
...
...
@@ -17,7 +17,7 @@ Delta = np.radians(22.0144)
tref
=
tstart
+
.
5
*
Tspan
sftfilepat
h
=
'data/*glitching_signal*sft'
sftfilepat
tern
=
'data/*glitching_signal*sft'
F0_width
=
np
.
sqrt
(
3
)
/
(
np
.
pi
*
Tspan
)
F1_width
=
np
.
sqrt
(
45
/
4.
)
/
(
np
.
pi
*
Tspan
**
2
)
...
...
@@ -45,7 +45,7 @@ theta_prior = {'F0': {'type': 'unif',
}
search
=
pyfstat
.
MCMCGlitchSearch
(
label
=
label
,
outdir
=
outdir
,
sftfilepat
h
=
sftfilepat
h
,
label
=
label
,
outdir
=
outdir
,
sftfilepat
tern
=
sftfilepat
tern
,
theta_prior
=
theta_prior
,
nglitch
=
1
,
tref
=
tref
,
nsteps
=
[
500
,
500
],
ntemps
=
3
,
log10temperature_min
=-
0.5
,
minStartTime
=
tstart
,
maxStartTime
=
tstart
+
Tspan
)
...
...
examples/semi_coherent_glitch_search_using_MCMC.py
View file @
1b1caf04
...
...
@@ -31,7 +31,7 @@ nsteps = [5000, 1000, 1000]
mcmc
=
pyfstat
.
MCMCGlitchSearch
(
'semi_coherent_glitch_search_using_MCMC'
,
'data'
,
sftfilepat
h
=
'data/*_glitch*sft'
,
theta_prior
=
theta_prior
,
tref
=
tref
,
sftfilepat
tern
=
'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
)
...
...
examples/semi_coherent_search_using_MCMC.py
View file @
1b1caf04
...
...
@@ -25,7 +25,7 @@ nsteps = [500, 500, 500]
mcmc
=
pyfstat
.
MCMCSemiCoherentSearch
(
label
=
'semi_coherent_search_using_MCMC'
,
outdir
=
'data'
,
nsegs
=
20
,
sftfilepat
h
=
'data/*basic*sft'
,
theta_prior
=
theta_prior
,
tref
=
tref
,
sftfilepat
tern
=
'data/*basic*sft'
,
theta_prior
=
theta_prior
,
tref
=
tref
,
minStartTime
=
tstart
,
maxStartTime
=
tend
,
nsteps
=
nsteps
,
nwalkers
=
nwalkers
,
ntemps
=
ntemps
,
log10temperature_min
=
log10temperature_min
)
mcmc
.
run
()
...
...
examples/semi_coherent_twoglitch_search_using_MCMC.py
View file @
1b1caf04
...
...
@@ -34,7 +34,7 @@ nwalkers = 100
nsteps
=
[
1000
,
1000
,
5000
]
mcmc
=
pyfstat
.
MCMCGlitchSearch
(
'semi_coherent_twoglitch_search'
,
'data'
,
sftfilepat
h
=
'data/*twoglitch*sft'
,
'semi_coherent_twoglitch_search'
,
'data'
,
sftfilepat
tern
=
'data/*twoglitch*sft'
,
theta_prior
=
theta_prior
,
tref
=
tref
,
tstart
=
tstart
,
tend
=
tend
,
nsteps
=
nsteps
,
nwalkers
=
nwalkers
,
scatter_val
=
1e-10
,
nglitch
=
2
)
...
...
examples/sliding_window.py
View file @
1b1caf04
...
...
@@ -27,7 +27,7 @@ data.make_data()
DeltaF0
=
1e-5
search
=
pyfstat
.
FrequencySlidingWindow
(
label
=
'sliding_window'
,
outdir
=
'data'
,
sftfilepat
h
=
'data/*sliding_window*sft'
,
label
=
'sliding_window'
,
outdir
=
'data'
,
sftfilepat
tern
=
'data/*sliding_window*sft'
,
F0s
=
[
F0
-
DeltaF0
,
F0
+
DeltaF0
,
DeltaF0
/
100.
],
F1
=
F1
,
F2
=
0
,
Alpha
=
Alpha
,
Delta
=
Delta
,
tref
=
tref
,
minStartTime
=
tstart
,
maxStartTime
=
tend
,
window_size
=
25
*
86400
,
window_delta
=
1
*
86400
)
...
...
examples/transient_search_using_MCMC.py
View file @
1b1caf04
...
...
@@ -40,7 +40,7 @@ nsteps = [100, 100]
mcmc
=
pyfstat
.
MCMCTransientSearch
(
label
=
'transient_search'
,
outdir
=
'data'
,
sftfilepat
h
=
'data/*simulated_transient_signal*sft'
,
sftfilepat
tern
=
'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
)
...
...
examples/weak_signal_follow_up.py
View file @
1b1caf04
...
...
@@ -55,7 +55,7 @@ nsteps = [100, 100]
mcmc
=
pyfstat
.
MCMCFollowUpSearch
(
label
=
'weak_signal_follow_up'
,
outdir
=
'data'
,
sftfilepat
h
=
'data/*'
+
data_label
+
'*sft'
,
theta_prior
=
theta_prior
,
tref
=
tref
,
sftfilepat
tern
=
'data/*'
+
data_label
+
'*sft'
,
theta_prior
=
theta_prior
,
tref
=
tref
,
minStartTime
=
tstart
,
maxStartTime
=
tend
,
nwalkers
=
nwalkers
,
nsteps
=
nsteps
,
ntemps
=
ntemps
,
log10temperature_min
=
log10temperature_min
,
scatter_val
=
scatter_val
)
...
...
pyfstat/core.py
View file @
1b1caf04
...
...
@@ -174,16 +174,15 @@ class BaseSearchClass(object):
return
thetas
def
_get_list_of_matching_sfts
(
self
):
# first make sure we have a list of paths, to avoid
# list comprehension trying to glob each single character
sftfilepathlist
=
np
.
atleast_1d
(
self
.
sftfilepath
)
matches
=
[
glob
.
glob
(
p
)
for
p
in
sftfilepathlist
]
""" Returns a list of sfts matching the sftfilepattern """
sftfilepatternlist
=
np
.
atleast_1d
(
self
.
sftfilepattern
.
split
(
';'
))
matches
=
[
glob
.
glob
(
p
)
for
p
in
sftfilepatternlist
]
matches
=
[
item
for
sublist
in
matches
for
item
in
sublist
]
if
len
(
matches
)
>
0
:
return
matches
else
:
raise
IOError
(
'No sfts found matching {}'
.
format
(
self
.
sftfilepat
h
))
self
.
sftfilepat
tern
))
class
ComputeFstat
(
object
):
...
...
@@ -193,7 +192,7 @@ class ComputeFstat(object):
sun_ephem_default
=
sun_ephem
@
helper_functions
.
initializer
def
__init__
(
self
,
tref
,
sftfilepat
h
=
None
,
minStartTime
=
None
,
def
__init__
(
self
,
tref
,
sftfilepat
tern
=
None
,
minStartTime
=
None
,
maxStartTime
=
None
,
binary
=
False
,
transient
=
True
,
BSGL
=
False
,
detectors
=
None
,
minCoverFreq
=
None
,
maxCoverFreq
=
None
,
earth_ephem
=
None
,
sun_ephem
=
None
,
injectSources
=
None
,
...
...
@@ -203,8 +202,9 @@ class ComputeFstat(object):
----------
tref: int
GPS seconds of the reference time.
sftfilepath: str
File patern to match SFTs
sftfilepattern: str
Pattern to match SFTs using wildcards (*?) and ranges [0-9];
mutiple patterns can be given separated by colons.
minStartTime, maxStartTime: float GPStime
Only use SFTs with timestemps starting from (including, excluding)
this epoch
...
...
@@ -250,7 +250,7 @@ class ComputeFstat(object):
def
get_SFTCatalog
(
self
):
if
hasattr
(
self
,
'SFTCatalog'
):
return
if
self
.
sftfilepat
h
is
None
:
if
self
.
sftfilepat
tern
is
None
:
for
k
in
[
'minStartTime'
,
'maxStartTime'
,
'detectors'
]:
if
getattr
(
self
,
k
)
is
None
:
raise
ValueError
(
'You must provide "{}" to injectSources'
...
...
@@ -285,8 +285,8 @@ class ComputeFstat(object):
constraints
.
maxStartTime
=
lal
.
LIGOTimeGPS
(
self
.
maxStartTime
)
logging
.
info
(
'Loading data matching pattern {}'
.
format
(
self
.
sftfilepat
h
))
SFTCatalog
=
lalpulsar
.
SFTdataFind
(
self
.
sftfilepat
h
,
constraints
)
self
.
sftfilepat
tern
))
SFTCatalog
=
lalpulsar
.
SFTdataFind
(
self
.
sftfilepat
tern
,
constraints
)
detector_names
=
list
(
set
([
d
.
header
.
name
for
d
in
SFTCatalog
.
data
]))
self
.
detector_names
=
detector_names
SFT_timestamps
=
[
d
.
header
.
epoch
for
d
in
SFTCatalog
.
data
]
...
...
@@ -572,7 +572,7 @@ class ComputeFstat(object):
times
=
np
.
linspace
(
self
.
minStartTime
,
self
.
maxStartTime
,
N
+
1
)[
1
:]
times
=
np
.
insert
(
times
,
0
,
self
.
minStartTime
+
86400
/
2.
)
out
=
[
predict_fstat
(
minStartTime
=
self
.
minStartTime
,
maxStartTime
=
t
,
sftfilepattern
=
self
.
sftfilepat
h
,
IFO
=
IFO
,
sftfilepattern
=
self
.
sftfilepat
tern
,
IFO
=
IFO
,
**
pfs_input
)
for
t
in
times
]
pfs
,
pfs_sigma
=
np
.
array
(
out
).
T
return
times
,
pfs
,
pfs_sigma
...
...
@@ -647,7 +647,7 @@ class SemiCoherentSearch(BaseSearchClass, ComputeFstat):
""" A semi-coherent search """
@
helper_functions
.
initializer
def
__init__
(
self
,
label
,
outdir
,
tref
,
nsegs
=
None
,
sftfilepat
h
=
None
,
def
__init__
(
self
,
label
,
outdir
,
tref
,
nsegs
=
None
,
sftfilepat
tern
=
None
,
binary
=
False
,
BSGL
=
False
,
minStartTime
=
None
,
maxStartTime
=
None
,
minCoverFreq
=
None
,
maxCoverFreq
=
None
,
detectors
=
None
,
earth_ephem
=
None
,
sun_ephem
=
None
,
...
...
@@ -661,8 +661,9 @@ class SemiCoherentSearch(BaseSearchClass, ComputeFstat):
GPS seconds of the reference time, and start and end of the data.
nsegs: int
The (fixed) number of segments
sftfilepath: str
File patern to match SFTs
sftfilepattern: str
Pattern to match SFTs using wildcards (*?) and ranges [0-9];
mutiple patterns can be given separated by colons.
For all other parameters, see pyfstat.ComputeFStat.
"""
...
...
@@ -776,7 +777,7 @@ class SemiCoherentGlitchSearch(BaseSearchClass, ComputeFstat):
@
helper_functions
.
initializer
def
__init__
(
self
,
label
,
outdir
,
tref
,
minStartTime
,
maxStartTime
,
nglitch
=
0
,
sftfilepat
h
=
None
,
theta0_idx
=
0
,
BSGL
=
False
,
nglitch
=
0
,
sftfilepat
tern
=
None
,
theta0_idx
=
0
,
BSGL
=
False
,
minCoverFreq
=
None
,
maxCoverFreq
=
None
,
assumeSqrtSX
=
None
,
detectors
=
None
,
earth_ephem
=
None
,
sun_ephem
=
None
,
SSBprec
=
None
,
injectSources
=
None
):
...
...
@@ -790,8 +791,9 @@ class SemiCoherentGlitchSearch(BaseSearchClass, ComputeFstat):
nglitch: int
The (fixed) number of glitches; this can zero, but occasionally
this causes issue (in which case just use ComputeFstat).
sftfilepath: str
File patern to match SFTs
sftfilepattern: str
Pattern to match SFTs using wildcards (*?) and ranges [0-9];
mutiple patterns can be given separated by colons.
theta0_idx, int
Index (zero-based) of which segment the theta refers to - uyseful
if providing a tight prior on theta to allow the signal to jump
...
...
pyfstat/grid_based_searches.py
View file @
1b1caf04
...
...
@@ -17,7 +17,7 @@ from core import tqdm, args, earth_ephem, sun_ephem, read_par
class
GridSearch
(
BaseSearchClass
):
""" Gridded search using ComputeFstat """
@
helper_functions
.
initializer
def
__init__
(
self
,
label
,
outdir
,
sftfilepat
h
,
F0s
=
[
0
],
F1s
=
[
0
],
F2s
=
[
0
],
def
__init__
(
self
,
label
,
outdir
,
sftfilepat
tern
,
F0s
=
[
0
],
F1s
=
[
0
],
F2s
=
[
0
],
Alphas
=
[
0
],
Deltas
=
[
0
],
tref
=
None
,
minStartTime
=
None
,
maxStartTime
=
None
,
nsegs
=
1
,
BSGL
=
False
,
minCoverFreq
=
None
,
maxCoverFreq
=
None
,
earth_ephem
=
None
,
sun_ephem
=
None
,
...
...
@@ -28,8 +28,9 @@ class GridSearch(BaseSearchClass):
----------
label, outdir: str
A label and directory to read/write data from/to
sftfilepath: str
File patern to match SFTs
sftfilepattern: str
Pattern to match SFTs using wildcards (*?) and ranges [0-9];
mutiple patterns can be given separated by colons.
F0s, F1s, F2s, delta_F0s, delta_F1s, tglitchs, Alphas, Deltas: tuple
Length 3 tuple describing the grid for each parameter, e.g
[F0min, F0max, dF0], for a fixed value simply give [F0]. Unless
...
...
@@ -56,7 +57,7 @@ class GridSearch(BaseSearchClass):
logging
.
info
(
'Setting up search object'
)
if
self
.
nsegs
==
1
:
self
.
search
=
ComputeFstat
(
tref
=
self
.
tref
,
sftfilepat
h
=
self
.
sftfilepat
h
,
tref
=
self
.
tref
,
sftfilepat
tern
=
self
.
sftfilepat
tern
,
minCoverFreq
=
self
.
minCoverFreq
,
maxCoverFreq
=
self
.
maxCoverFreq
,
earth_ephem
=
self
.
earth_ephem
,
sun_ephem
=
self
.
sun_ephem
,
detectors
=
self
.
detectors
,
transient
=
False
,
...
...
@@ -68,7 +69,7 @@ class GridSearch(BaseSearchClass):
else
:
self
.
search
=
SemiCoherentSearch
(
label
=
self
.
label
,
outdir
=
self
.
outdir
,
tref
=
self
.
tref
,
nsegs
=
self
.
nsegs
,
sftfilepat
h
=
self
.
sftfilepat
h
,
nsegs
=
self
.
nsegs
,
sftfilepat
tern
=
self
.
sftfilepat
tern
,
BSGL
=
self
.
BSGL
,
minStartTime
=
self
.
minStartTime
,
maxStartTime
=
self
.
maxStartTime
,
minCoverFreq
=
self
.
minCoverFreq
,
maxCoverFreq
=
self
.
maxCoverFreq
,
detectors
=
self
.
detectors
,
...
...
@@ -106,7 +107,7 @@ class GridSearch(BaseSearchClass):
if
os
.
path
.
isfile
(
self
.
out_file
)
is
False
:
logging
.
info
(
'No old data found, continuing with grid search'
)
return
False
if
self
.
sftfilepat
h
is
not
None
:
if
self
.
sftfilepat
tern
is
not
None
:
oldest_sft
=
min
([
os
.
path
.
getmtime
(
f
)
for
f
in
self
.
_get_list_of_matching_sfts
()])
if
os
.
path
.
getmtime
(
self
.
out_file
)
<
oldest_sft
:
...
...
@@ -275,7 +276,7 @@ class GridSearch(BaseSearchClass):
class
GridUniformPriorSearch
():
def
__init__
(
self
,
theta_prior
,
NF0
,
NF1
,
label
,
outdir
,
sftfilepat
h
,
def
__init__
(
self
,
theta_prior
,
NF0
,
NF1
,
label
,
outdir
,
sftfilepat
tern
,
tref
,
minStartTime
,
maxStartTime
,
minCoverFreq
=
None
,
maxCoverFreq
=
None
,
BSGL
=
False
,
detectors
=
None
,
nsegs
=
1
):
dF0
=
(
theta_prior
[
'F0'
][
'upper'
]
-
theta_prior
[
'F0'
][
'lower'
])
/
NF0
...
...
@@ -283,7 +284,7 @@ class GridUniformPriorSearch():
F0s
=
[
theta_prior
[
'F0'
][
'lower'
],
theta_prior
[
'F0'
][
'upper'
],
dF0
]
F1s
=
[
theta_prior
[
'F1'
][
'lower'
],
theta_prior
[
'F1'
][
'upper'
],
dF1
]
self
.
search
=
GridSearch
(
label
,
outdir
,
sftfilepat
h
,
F0s
=
F0s
,
F1s
=
F1s
,
tref
=
tref
,
label
,
outdir
,
sftfilepat
tern
,
F0s
=
F0s
,
F1s
=
F1s
,
tref
=
tref
,
Alphas
=
[
theta_prior
[
'Alpha'
]],
Deltas
=
[
theta_prior
[
'Delta'
]],
minStartTime
=
minStartTime
,
maxStartTime
=
maxStartTime
,
BSGL
=
BSGL
,
detectors
=
detectors
,
minCoverFreq
=
minCoverFreq
,
...
...
@@ -299,7 +300,7 @@ class GridUniformPriorSearch():
class
GridGlitchSearch
(
GridSearch
):
""" Grid search using the SemiCoherentGlitchSearch """
@
helper_functions
.
initializer
def
__init__
(
self
,
label
,
outdir
,
sftfilepat
h
=
None
,
F0s
=
[
0
],
def
__init__
(
self
,
label
,
outdir
,
sftfilepat
tern
=
None
,
F0s
=
[
0
],
F1s
=
[
0
],
F2s
=
[
0
],
delta_F0s
=
[
0
],
delta_F1s
=
[
0
],
tglitchs
=
None
,
Alphas
=
[
0
],
Deltas
=
[
0
],
tref
=
None
,
minStartTime
=
None
,
maxStartTime
=
None
,
minCoverFreq
=
None
,
maxCoverFreq
=
None
,
...
...
@@ -310,8 +311,9 @@ class GridGlitchSearch(GridSearch):
----------
label, outdir: str
A label and directory to read/write data from/to
sftfilepath: str
File patern to match SFTs
sftfilepattern: str
Pattern to match SFTs using wildcards (*?) and ranges [0-9];
mutiple patterns can be given separated by colons.
F0s, F1s, F2s, delta_F0s, delta_F1s, tglitchs, Alphas, Deltas: tuple
Length 3 tuple describing the grid for each parameter, e.g
[F0min, F0max, dF0], for a fixed value simply give [F0].
...
...
@@ -328,7 +330,7 @@ class GridGlitchSearch(GridSearch):
self
.
sun_ephem
=
self
.
sun_ephem_default
self
.
search
=
SemiCoherentGlitchSearch
(
label
=
label
,
outdir
=
outdir
,
sftfilepat
h
=
self
.
sftfilepat
h
,
label
=
label
,
outdir
=
outdir
,
sftfilepat
tern
=
self
.
sftfilepat
tern
,
tref
=
tref
,
minStartTime
=
minStartTime
,
maxStartTime
=
maxStartTime
,
minCoverFreq
=
minCoverFreq
,
maxCoverFreq
=
maxCoverFreq
,
earth_ephem
=
self
.
earth_ephem
,
sun_ephem
=
self
.
sun_ephem
,
...
...
@@ -357,7 +359,7 @@ class GridGlitchSearch(GridSearch):
class
FrequencySlidingWindow
(
GridSearch
):
""" A sliding-window search over the Frequency """
@
helper_functions
.
initializer
def
__init__
(
self
,
label
,
outdir
,
sftfilepat
h
,
F0s
,
F1
,
F2
,
def
__init__
(
self
,
label
,
outdir
,
sftfilepat
tern
,
F0s
,
F1
,
F2
,
Alpha
,
Delta
,
tref
,
minStartTime
=
None
,
maxStartTime
=
None
,
window_size
=
10
*
86400
,
window_delta
=
86400
,
BSGL
=
False
,
minCoverFreq
=
None
,
maxCoverFreq
=
None
,
...
...
@@ -368,8 +370,9 @@ class FrequencySlidingWindow(GridSearch):
----------
label, outdir: str
A label and directory to read/write data from/to
sftfilepath: str
File patern to match SFTs
sftfilepattern: str
Pattern to match SFTs using wildcards (*?) and ranges [0-9];
mutiple patterns can be given separated by colons.
F0s: array
Frequency range
F1, F2, Alpha, Delta: float
...
...
@@ -397,7 +400,7 @@ class FrequencySlidingWindow(GridSearch):
def
inititate_search_object
(
self
):
logging
.
info
(
'Setting up search object'
)
self
.
search
=
ComputeFstat
(
tref
=
self
.
tref
,
sftfilepat
h
=
self
.
sftfilepat
h
,
tref
=
self
.
tref
,
sftfilepat
tern
=
self
.
sftfilepat
tern
,
minCoverFreq
=
self
.
minCoverFreq
,
maxCoverFreq
=
self
.
maxCoverFreq
,
earth_ephem
=
self
.
earth_ephem
,
sun_ephem
=
self
.
sun_ephem
,
detectors
=
self
.
detectors
,
transient
=
True
,
...
...
@@ -473,7 +476,7 @@ class FrequencySlidingWindow(GridSearch):
class
DMoff_NO_SPIN
(
GridSearch
):
""" DMoff test using SSBPREC_NO_SPIN """
@
helper_functions
.
initializer
def
__init__
(
self
,
par
,
label
,
outdir
,
sftfilepat
h
,
minStartTime
=
None
,
def
__init__
(
self
,
par
,
label
,
outdir
,
sftfilepat
tern
,
minStartTime
=
None
,
maxStartTime
=
None
,
minCoverFreq
=
None
,
maxCoverFreq
=
None
,
earth_ephem
=
None
,
sun_ephem
=
None
,
detectors
=
None
,
injectSources
=
None
,
assumeSqrtSX
=
None
):
...
...
@@ -485,8 +488,9 @@ class DMoff_NO_SPIN(GridSearch):
and 'tref') or a path to a .par file to read in the F0, F1 etc
label, outdir: str
A label and directory to read/write data from/to
sftfilepath: str
File patern to match SFTs
sftfilepattern: str
Pattern to match SFTs using wildcards (*?) and ranges [0-9];
mutiple patterns can be given separated by colons.
minStartTime, maxStartTime: int
GPS seconds of the start time and end time
...
...
pyfstat/mcmc_based_searches.py
View file @
1b1caf04
...
...
@@ -36,7 +36,7 @@ class MCMCSearch(core.BaseSearchClass):
@
helper_functions
.
initializer
def
__init__
(
self
,
label
,
outdir
,
theta_prior
,
tref
,
minStartTime
,
maxStartTime
,
sftfilepat
h
=
None
,
nsteps
=
[
100
,
100
],
maxStartTime
,
sftfilepat
tern
=
None
,
nsteps
=
[
100
,
100
],
nwalkers
=
100
,
ntemps
=
1
,
log10temperature_min
=-
5
,
theta_initial
=
None
,
scatter_val
=
1e-10
,
rhohatmax
=
1000
,
binary
=
False
,
BSGL
=
False
,
minCoverFreq
=
None
,
SSBprec
=
None
,
...
...
@@ -46,7 +46,7 @@ class MCMCSearch(core.BaseSearchClass):
Parameters
label, outdir: str
A label and directory to read/write data from/to
sftfilepat
h
: str
sftfilepat
tern
: str
Pattern to match SFTs using wildcards (*?) and ranges [0-9];
mutiple patterns can be given separated by colons.
theta_prior: dict
...
...
@@ -94,10 +94,10 @@ class MCMCSearch(core.BaseSearchClass):
os
.
mkdir
(
outdir
)
self
.
_add_log_file
()
logging
.
info
(
'Set-up MCMC search for model {}'
.
format
(
self
.
label
))
if
sftfilepat
h
:
logging
.
info
(
'Using data {}'
.
format
(
self
.
sftfilepat
h
))
if
sftfilepat
tern
:
logging
.
info
(
'Using data {}'
.
format
(
self
.
sftfilepat
tern
))
else
:
logging
.
info
(
'No sftfilepat
h
given'
)
logging
.
info
(
'No sftfilepat
tern
given'
)
if
injectSources
:
logging
.
info
(
'Inject sources: {}'
.
format
(
injectSources
))
self
.
pickle_path
=
'{}/{}_saved_data.p'
.
format
(
self
.
outdir
,
self
.
label
)
...
...
@@ -132,7 +132,7 @@ class MCMCSearch(core.BaseSearchClass):
def
_initiate_search_object
(
self
):
logging
.
info
(
'Setting up search object'
)
self
.
search
=
core
.
ComputeFstat
(
tref
=
self
.
tref
,
sftfilepat
h
=
self
.
sftfilepat
h
,
tref
=
self
.
tref
,
sftfilepat
tern
=
self
.
sftfilepat
tern
,
minCoverFreq
=
self
.
minCoverFreq
,
maxCoverFreq
=
self
.
maxCoverFreq
,
earth_ephem
=
self
.
earth_ephem
,
sun_ephem
=
self
.
sun_ephem
,
detectors
=
self
.
detectors
,
BSGL
=
self
.
BSGL
,
transient
=
False
,
...
...
@@ -1112,7 +1112,7 @@ class MCMCSearch(core.BaseSearchClass):
logging
.
info
(
'No pickled data found'
)
return
False
if
self
.
sftfilepat
h
is
not
None
:
if
self
.
sftfilepat
tern
is
not
None
:
oldest_sft
=
min
([
os
.
path
.
getmtime
(
f
)
for
f
in
self
.
_get_list_of_matching_sfts
()])
if
os
.
path
.
getmtime
(
self
.
pickle_path
)
<
oldest_sft
:
...
...
@@ -1275,7 +1275,7 @@ class MCMCSearch(core.BaseSearchClass):
' --refTime={} --outputLoudest="{}/{}.loudest" '
'--minStartTime={} --maxStartTime={}'
).
format
(
params
[
'Alpha'
],
params
[
'Delta'
],
params
[
'F0'
],
params
[
'F1'
],
self
.
sftfilepat
h
,
params
[
'tref'
],
params
[
'F1'
],
self
.
sftfilepat
tern
,
params
[
'tref'
],
self
.
outdir
,
self
.
label
,
self
.
minStartTime
,
self
.
maxStartTime
)
subprocess
.
call
([
cmd
],
shell
=
True
)
...
...
@@ -1459,7 +1459,7 @@ class MCMCGlitchSearch(MCMCSearch):
)
@
helper_functions
.
initializer
def
__init__
(
self
,
label
,
outdir
,
sftfilepat
h
,
theta_prior
,
tref
,
def
__init__
(
self
,
label
,
outdir
,
sftfilepat
tern
,
theta_prior
,
tref
,
minStartTime
,
maxStartTime
,
nglitch
=
1
,
nsteps
=
[
100
,
100
],
nwalkers
=
100
,
ntemps
=
1
,
log10temperature_min
=-
5
,
theta_initial
=
None
,
scatter_val
=
1e-10
,
rhohatmax
=
1000
,
...
...
@@ -1471,8 +1471,9 @@ class MCMCGlitchSearch(MCMCSearch):
----------
label, outdir: str
A label and directory to read/write data from/to
sftfilepath: str
File patern to match SFTs
sftfilepattern: str
Pattern to match SFTs using wildcards (*?) and ranges [0-9];
mutiple patterns can be given separated by colons.
theta_prior: dict
Dictionary of priors and fixed values for the search parameters.
For each parameters (key of the dict), if it is to be held fixed
...
...
@@ -1530,7 +1531,7 @@ class MCMCGlitchSearch(MCMCSearch):
self
.
_add_log_file
()
logging
.
info
((
'Set-up MCMC glitch search with {} glitches for model {}'
' on data {}'
).
format
(
self
.
nglitch
,
self
.
label
,
self
.
sftfilepat
h
))
self
.
sftfilepat
tern
))
self
.
pickle_path
=
'{}/{}_saved_data.p'
.
format
(
self
.
outdir
,
self
.
label
)
self
.
_unpack_input_theta
()
self
.
ndim
=
len
(
self
.
theta_keys
)
...
...
@@ -1554,7 +1555,7 @@ class MCMCGlitchSearch(MCMCSearch):
def
_initiate_search_object
(
self
):
logging
.
info
(
'Setting up search object'
)
self
.
search
=
core
.
SemiCoherentGlitchSearch
(
label
=
self
.
label
,
outdir
=
self
.
outdir
,
sftfilepat
h
=
self
.
sftfilepat
h
,
label
=
self
.
label
,
outdir
=
self
.
outdir
,
sftfilepat
tern
=
self
.
sftfilepat
tern
,
tref
=
self
.
tref
,
minStartTime
=
self
.
minStartTime
,
maxStartTime
=
self
.
maxStartTime
,
minCoverFreq
=
self
.
minCoverFreq
,
maxCoverFreq
=
self
.
maxCoverFreq
,
earth_ephem
=
self
.
earth_ephem
,
...
...
@@ -1718,7 +1719,7 @@ class MCMCGlitchSearch(MCMCSearch):
class
MCMCSemiCoherentSearch
(
MCMCSearch
):
""" MCMC search for a signal using the semi-coherent ComputeFstat """
@
helper_functions
.
initializer
def
__init__
(
self
,
label
,
outdir
,
theta_prior
,
tref
,
sftfilepat
h
=
None
,
def
__init__
(
self
,
label
,
outdir
,
theta_prior
,
tref
,
sftfilepat
tern
=
None
,
nsegs
=
None
,
nsteps
=
[
100
,
100
,
100
],
nwalkers
=
100
,
binary
=
False
,
ntemps
=
1
,
log10temperature_min
=-
5
,
theta_initial
=
None
,
scatter_val
=
1e-10
,
rhohatmax
=
1000
,
...
...
@@ -1735,7 +1736,7 @@ class MCMCSemiCoherentSearch(MCMCSearch):
self
.
_add_log_file
()
logging
.
info
((
'Set-up MCMC semi-coherent search for model {} on data'
'{}'
).
format
(
self
.
label
,
self
.
sftfilepat
h
))
self
.
label
,
self
.
sftfilepat
tern
))
self
.
pickle_path
=
'{}/{}_saved_data.p'
.
format
(
self
.
outdir
,
self
.
label
)
self
.
_unpack_input_theta
()
self
.
ndim
=
len
(
self
.
theta_keys
)
...
...
@@ -1767,7 +1768,7 @@ class MCMCSemiCoherentSearch(MCMCSearch):
logging
.
info
(
'Setting up search object'
)
self
.
search
=
core
.
SemiCoherentSearch
(
label
=
self
.
label
,
outdir
=
self
.
outdir
,
tref
=
self
.
tref
,
nsegs
=
self
.
nsegs
,
sftfilepat
h
=
self
.
sftfilepat
h
,
binary
=
self
.
binary
,
nsegs
=
self
.
nsegs
,
sftfilepat
tern
=
self
.
sftfilepat
tern
,
binary
=
self
.
binary
,
BSGL
=
self
.
BSGL
,
minStartTime
=
self
.
minStartTime
,
maxStartTime
=
self
.
maxStartTime
,
minCoverFreq
=
self
.
minCoverFreq
,
maxCoverFreq
=
self
.
maxCoverFreq
,
detectors
=
self
.
detectors
,
...
...
@@ -2124,7 +2125,7 @@ class MCMCTransientSearch(MCMCSearch):
def
_initiate_search_object
(
self
):
logging
.
info
(
'Setting up search object'
)
self
.
search
=
core
.
ComputeFstat
(
tref
=
self
.
tref
,
sftfilepat
h
=
self
.
sftfilepat
h
,
tref
=
self
.
tref
,
sftfilepat
tern
=
self
.
sftfilepat
tern
,
minCoverFreq
=
self
.
minCoverFreq
,
maxCoverFreq
=
self
.
maxCoverFreq
,
earth_ephem
=
self
.
earth_ephem
,
sun_ephem
=
self
.
sun_ephem
,
detectors
=
self
.
detectors
,
transient
=
True
,
...
...
tests.py
View file @
1b1caf04
...
...
@@ -95,7 +95,7 @@ class TestComputeFstat(Test):
search
=
pyfstat
.
ComputeFstat
(
tref
=
Writer
.
tref
,
sftfilepat
h
=
'{}/*{}*sft'
.
format
(
Writer
.
outdir
,
Writer
.
label
))
sftfilepat
tern
=
'{}/*{}*sft'
.
format
(
Writer
.
outdir
,
Writer
.
label
))
FS
=
search
.
run_computefstatistic_single_point
(
Writer
.
tstart
,
Writer
.
tend
,
Writer
.
F0
,
...
...
@@ -113,7 +113,7 @@ class TestComputeFstat(Test):
search
=
pyfstat
.
ComputeFstat
(
tref
=
Writer
.
tref
,
assumeSqrtSX
=
1
,
sftfilepat
h
=
'{}/*{}*sft'
.
format
(
Writer
.
outdir
,
Writer
.
label
))
sftfilepat
tern
=
'{}/*{}*sft'
.
format
(
Writer
.
outdir
,
Writer
.
label
))
FS
=
search
.
run_computefstatistic_single_point
(
Writer
.
tstart
,
Writer
.
tend
,
Writer
.
F0
,
...
...
@@ -162,7 +162,7 @@ class TestSemiCoherentGlitchSearch(Test):
search
=
pyfstat
.
SemiCoherentGlitchSearch
(
label
=
self
.
label
,
outdir
=
outdir
,
sftfilepat
h
=
'{}/*{}*sft'
.
format
(
Writer
.
outdir
,
Writer
.
label
),
sftfilepat
tern
=
'{}/*{}*sft'
.
format
(
Writer
.
outdir
,
Writer
.
label
),
tref
=
Writer
.
tref
,
minStartTime
=
Writer
.
tstart
,
maxStartTime
=
Writer
.
tend
,
nglitch
=
1
)
...
...
@@ -221,7 +221,7 @@ class TestMCMCSearch(Test):
search
=
pyfstat
.
MCMCSearch
(
label
=
self
.
label
,
outdir
=
outdir
,
theta_prior
=
theta
,
tref
=
tref
,
sftfilepat
h
=
'{}/*{}*sft'
.
format
(
Writer
.
outdir
,
Writer
.
label
),
sftfilepat
tern
=
'{}/*{}*sft'
.
format
(
Writer
.
outdir
,
Writer
.
label
),
minStartTime
=
minStartTime
,
maxStartTime
=
maxStartTime
,
nsteps
=
[
100
,
100
],
nwalkers
=
100
,
ntemps
=
2
,
log10temperature_min
=-
1
)
search
.
setup_convergence_testing
()
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment