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
42739af1
Commit
42739af1
authored
Aug 01, 2017
by
Gregory Ashton
Browse files
Adds log_level option to run_commandline and minor PEP8 change
parent
48d1f278
Changes
1
Hide whitespace changes
Inline
Side-by-side
pyfstat/helper_functions.py
View file @
42739af1
...
@@ -12,6 +12,7 @@ import peakutils
...
@@ -12,6 +12,7 @@ import peakutils
from
functools
import
wraps
from
functools
import
wraps
from
scipy.stats.distributions
import
ncx2
from
scipy.stats.distributions
import
ncx2
import
lal
import
lal
import
lalpulsar
import
matplotlib.pyplot
as
plt
import
matplotlib.pyplot
as
plt
import
numpy
as
np
import
numpy
as
np
...
@@ -187,10 +188,20 @@ def compute_pstar(twoFcheck_obs, twoFstarcheck_obs, m0, plot=False):
...
@@ -187,10 +188,20 @@ def compute_pstar(twoFcheck_obs, twoFstarcheck_obs, m0, plot=False):
return
2
*
np
.
min
([
pstar_l
,
1
-
pstar_l
])
return
2
*
np
.
min
([
pstar_l
,
1
-
pstar_l
])
def
run_commandline
(
cl
):
def
run_commandline
(
cl
,
log_level
=
20
):
"""Run a string c
ommandline
as a subprocess, check for errors and return output.
"""
"""Run a string c
md
as a subprocess, check for errors and return output.
logging
.
info
(
'Now executing: '
+
cl
)
Parameters
----------
cl: str
Command to run
log_level: int
See https://docs.python.org/2/library/logging.html#logging-levels,
default is '20' (INFO)
"""
logging
.
log
(
log_level
,
'Now executing: '
+
cl
)
try
:
try
:
out
=
subprocess
.
check_output
(
cl
,
# what to run
out
=
subprocess
.
check_output
(
cl
,
# what to run
stderr
=
subprocess
.
STDOUT
,
# catch errors
stderr
=
subprocess
.
STDOUT
,
# catch errors
...
@@ -205,8 +216,9 @@ def run_commandline (cl):
...
@@ -205,8 +216,9 @@ def run_commandline (cl):
return
(
out
)
return
(
out
)
def
convert_array_to_gsl_matrix
(
array
):
def
convert_array_to_gsl_matrix
(
array
):
gsl_matrix
=
lal
.
gsl_matrix
(
*
array
.
shape
)
gsl_matrix
=
lal
.
gsl_matrix
(
*
array
.
shape
)
gsl_matrix
.
data
=
array
gsl_matrix
.
data
=
array
return
gsl_matrix
return
gsl_matrix
...
...
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