Skip to content
GitLab
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
6090bd65
Commit
6090bd65
authored
Apr 11, 2017
by
Gregory Ashton
Browse files
General improvements to the documentation and imports
parent
e22e9b59
Changes
5
Expand all
Hide whitespace changes
Inline
Side-by-side
pyfstat/__init__.py
View file @
6090bd65
from
__future__
import
division
from
__future__
import
division
as
_division
from
.core
import
BaseSearchClass
,
ComputeFstat
,
Writer
from
.mcmc_based_searches
import
*
from
.grid_based_searches
import
*
from
.helper_functions
import
texify_float
from
.core
import
BaseSearchClass
,
ComputeFstat
,
Writer
,
SemiCoherentSearch
,
SemiCoherentGlitchSearch
from
.mcmc_based_searches
import
MCMCSearch
,
MCMCGlitchSearch
,
MCMCSemiCoherentSearch
,
MCMCFollowUpSearch
,
MCMCTransientSearch
from
.grid_based_searches
import
GridSearch
,
GridUniformPriorSearch
,
GridGlitchSearch
pyfstat/core.py
View file @
6090bd65
...
...
@@ -37,7 +37,7 @@ class BaseSearchClass(object):
earth_ephem_default
=
earth_ephem
sun_ephem_default
=
sun_ephem
def
add_log_file
(
self
):
def
_
add_log_file
(
self
):
""" Log output to a file, requires class to have outdir and label """
logfilename
=
'{}/{}.log'
.
format
(
self
.
outdir
,
self
.
label
)
fh
=
logging
.
FileHandler
(
logfilename
)
...
...
@@ -47,7 +47,7 @@ class BaseSearchClass(object):
datefmt
=
'%y-%m-%d %H:%M'
))
logging
.
getLogger
().
addHandler
(
fh
)
def
shift_matrix
(
self
,
n
,
dT
):
def
_
shift_matrix
(
self
,
n
,
dT
):
""" Generate the shift matrix
Parameters
...
...
@@ -78,7 +78,7 @@ class BaseSearchClass(object):
m
[
i
,
j
]
=
float
(
dT
)
**
(
j
-
i
)
/
factorial
(
j
-
i
)
return
m
def
shift_coefficients
(
self
,
theta
,
dT
):
def
_
shift_coefficients
(
self
,
theta
,
dT
):
""" Shift a set of coefficients by dT
Parameters
...
...
@@ -96,30 +96,30 @@ class BaseSearchClass(object):
"""
n
=
len
(
theta
)
m
=
self
.
shift_matrix
(
n
,
dT
)
m
=
self
.
_
shift_matrix
(
n
,
dT
)
return
np
.
dot
(
m
,
theta
)
def
calculate_thetas
(
self
,
theta
,
delta_thetas
,
tbounds
,
theta0_idx
=
0
):
def
_
calculate_thetas
(
self
,
theta
,
delta_thetas
,
tbounds
,
theta0_idx
=
0
):
""" Calculates the set of coefficients for the post-glitch signal """
thetas
=
[
theta
]
for
i
,
dt
in
enumerate
(
delta_thetas
):
if
i
<
theta0_idx
:
pre_theta_at_ith_glitch
=
self
.
shift_coefficients
(
pre_theta_at_ith_glitch
=
self
.
_
shift_coefficients
(
thetas
[
0
],
tbounds
[
i
+
1
]
-
self
.
tref
)
post_theta_at_ith_glitch
=
pre_theta_at_ith_glitch
-
dt
thetas
.
insert
(
0
,
self
.
shift_coefficients
(
thetas
.
insert
(
0
,
self
.
_
shift_coefficients
(
post_theta_at_ith_glitch
,
self
.
tref
-
tbounds
[
i
+
1
]))
elif
i
>=
theta0_idx
:
pre_theta_at_ith_glitch
=
self
.
shift_coefficients
(
pre_theta_at_ith_glitch
=
self
.
_
shift_coefficients
(
thetas
[
i
],
tbounds
[
i
+
1
]
-
self
.
tref
)
post_theta_at_ith_glitch
=
pre_theta_at_ith_glitch
+
dt
thetas
.
append
(
self
.
shift_coefficients
(
thetas
.
append
(
self
.
_
shift_coefficients
(
post_theta_at_ith_glitch
,
self
.
tref
-
tbounds
[
i
+
1
]))
self
.
thetas_at_tref
=
thetas
return
thetas
def
generate_loudest
(
self
):
def
_
generate_loudest
(
self
):
params
=
read_par
(
self
.
label
,
self
.
outdir
)
for
key
in
[
'Alpha'
,
'Delta'
,
'F0'
,
'F1'
]:
if
key
not
in
params
:
...
...
@@ -133,7 +133,7 @@ class BaseSearchClass(object):
self
.
maxStartTime
)
subprocess
.
call
([
cmd
],
shell
=
True
)
def
get_list_of_matching_sfts
(
self
):
def
_
get_list_of_matching_sfts
(
self
):
matches
=
[
glob
.
glob
(
p
)
for
p
in
self
.
sftfilepath
]
matches
=
[
item
for
sublist
in
matches
for
item
in
sublist
]
if
len
(
matches
)
>
0
:
...
...
@@ -685,7 +685,7 @@ class SemiCoherentGlitchSearch(BaseSearchClass, ComputeFstat):
delta_thetas
=
np
.
atleast_2d
(
np
.
array
([
delta_phi
,
delta_F0s
,
delta_F1s
,
delta_F2
]).
T
)
thetas
=
self
.
calculate_thetas
(
theta
,
delta_thetas
,
tboundaries
,
thetas
=
self
.
_
calculate_thetas
(
theta
,
delta_thetas
,
tboundaries
,
theta0_idx
=
self
.
theta0_idx
)
twoFSum
=
0
...
...
@@ -713,9 +713,9 @@ class SemiCoherentGlitchSearch(BaseSearchClass, ComputeFstat):
delta_theta
=
[
delta_F0
,
delta_F1
,
0
]
tref
=
self
.
tref
theta_at_glitch
=
self
.
shift_coefficients
(
theta
,
tglitch
-
tref
)
theta_at_glitch
=
self
.
_
shift_coefficients
(
theta
,
tglitch
-
tref
)
theta_post_glitch_at_glitch
=
theta_at_glitch
+
delta_theta
theta_post_glitch
=
self
.
shift_coefficients
(
theta_post_glitch
=
self
.
_
shift_coefficients
(
theta_post_glitch_at_glitch
,
tref
-
tglitch
)
twoFsegA
=
self
.
run_computefstatistic_single_point
(
...
...
@@ -849,7 +849,7 @@ transientTauDays={:1.3f}\n""")
"""
thetas
=
self
.
calculate_thetas
(
self
.
theta
,
self
.
delta_thetas
,
thetas
=
self
.
_
calculate_thetas
(
self
.
theta
,
self
.
delta_thetas
,
self
.
tbounds
)
content
=
''
...
...
pyfstat/helper_functions.py
View file @
6090bd65
...
...
@@ -65,6 +65,7 @@ def set_up_command_line_arguments():
def
set_up_ephemeris_configuration
():
""" Returns the earth_ephem and sun_ephem """
config_file
=
os
.
path
.
expanduser
(
'~'
)
+
'/.pyfstat.conf'
if
os
.
path
.
isfile
(
config_file
):
d
=
{}
...
...
pyfstat/mcmc_based_searches.py
View file @
6090bd65
This diff is collapsed.
Click to expand it.
tests.py
View file @
6090bd65
...
...
@@ -49,7 +49,7 @@ class TestBaseSearchClass(Test):
def
test_shift_matrix
(
self
):
BSC
=
pyfstat
.
BaseSearchClass
()
dT
=
10
a
=
BSC
.
shift_matrix
(
4
,
dT
)
a
=
BSC
.
_
shift_matrix
(
4
,
dT
)
b
=
np
.
array
([[
1
,
2
*
np
.
pi
*
dT
,
2
*
np
.
pi
*
dT
**
2
/
2.0
,
2
*
np
.
pi
*
dT
**
3
/
6.0
],
[
0
,
1
,
dT
,
dT
**
2
/
2.0
],
[
0
,
0
,
1
,
dT
],
...
...
@@ -71,16 +71,16 @@ class TestBaseSearchClass(Test):
self
.
assertTrue
(
np
.
array_equal
(
thetaB
,
BSC
.
shift_coefficients
(
thetaA
,
dT
)))
thetaB
,
BSC
.
_
shift_coefficients
(
thetaA
,
dT
)))
def
test_shift_coefficients_loop
(
self
):
BSC
=
pyfstat
.
BaseSearchClass
()
thetaA
=
np
.
array
([
10.
,
1e2
,
10.
,
1e2
])
dT
=
1e1
thetaB
=
BSC
.
shift_coefficients
(
thetaA
,
dT
)
thetaB
=
BSC
.
_
shift_coefficients
(
thetaA
,
dT
)
self
.
assertTrue
(
np
.
allclose
(
thetaA
,
BSC
.
shift_coefficients
(
thetaB
,
-
dT
),
thetaA
,
BSC
.
_
shift_coefficients
(
thetaB
,
-
dT
),
rtol
=
1e-9
,
atol
=
1e-9
))
...
...
@@ -257,8 +257,7 @@ class TestAuxillaryFunctions(Test):
DeltaFs
=
[
1e-4
,
1e-14
]
fiducial_freq
=
100
detector_names
=
[
'H1'
,
'L1'
]
earth_ephem
=
pyfstat
.
earth_ephem
sun_ephem
=
pyfstat
.
sun_ephem
earth_ephem
,
sun_ephem
=
pyfstat
.
helper_functions
.
set_up_ephemeris_configuration
()
def
test_get_V_estimate_sky_F0_F1
(
self
):
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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