Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
PyFstat
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Gregory Ashton
PyFstat
Commits
975f1f5c
Commit
975f1f5c
authored
7 years ago
by
Gregory Ashton
Browse files
Options
Downloads
Patches
Plain Diff
Adds compute pstar functionality
parent
f5634a0a
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
pyfstat/grid_based_searches.py
+3
-2
3 additions, 2 deletions
pyfstat/grid_based_searches.py
pyfstat/helper_functions.py
+32
-0
32 additions, 0 deletions
pyfstat/helper_functions.py
with
35 additions
and
2 deletions
pyfstat/grid_based_searches.py
+
3
−
2
View file @
975f1f5c
...
...
@@ -501,7 +501,7 @@ class DMoff_NO_SPIN(GridSearch):
self
.
c
=
2.998e8
self
.
SIDEREAL_DAY
=
23
*
60
*
60
+
56
*
60
+
4.0916
self
.
TERRESTRIAL_DAY
=
86400.
a0
=
self
.
Re
/
self
.
c
*
np
.
cos
(
self
.
par
[
'
Delta
'
])
a0
=
self
.
Re
/
self
.
c
#
*np.cos(self.par['Delta'])
self
.
m0
=
np
.
max
([
4
,
int
(
np
.
ceil
(
2
*
np
.
pi
*
self
.
par
[
'
F0
'
]
*
a0
))])
logging
.
info
(
'
m0 = {}
'
.
format
(
self
.
m0
))
...
...
@@ -516,7 +516,8 @@ class DMoff_NO_SPIN(GridSearch):
self
.
SSBprec
=
2
self
.
out_file
=
'
{}/{}_gridFS_SSBPREC2.txt
'
.
format
(
self
.
outdir
,
self
.
label
)
self
.
F0s
=
[
self
.
par
[
'
F0
'
]
+
j
/
self
.
SIDEREAL_DAY
for
j
in
range
(
-
4
,
5
)]
self
.
F0s
=
[
self
.
par
[
'
F0
'
]
+
j
/
self
.
SIDEREAL_DAY
for
j
in
range
(
-
self
.
m0
,
self
.
m0
+
1
)]
self
.
run
()
twoF_SUM
=
np
.
sum
(
self
.
data
[:,
-
1
])
...
...
This diff is collapsed.
Click to expand it.
pyfstat/helper_functions.py
+
32
−
0
View file @
975f1f5c
...
...
@@ -9,6 +9,7 @@ import logging
import
inspect
import
peakutils
from
functools
import
wraps
from
scipy.stats.distributions
import
ncx2
import
matplotlib.pyplot
as
plt
import
numpy
as
np
...
...
@@ -151,3 +152,34 @@ def get_comb_values(F0, frequencies, twoF, period, N=4):
comb_idxs
=
[
np
.
argmin
(
np
.
abs
(
frequencies
-
F0
-
F
))
for
F
in
comb_frequencies
]
return
comb_frequencies
,
twoF
[
comb_idxs
],
freq_err
*
np
.
ones
(
len
(
comb_idxs
))
def
compute_P_twoFstarcheck
(
twoFstarcheck
,
twoFcheck
,
M0
,
plot
=
False
):
"""
Returns the unnormalised pdf of twoFstarcheck given twoFcheck
"""
upper
=
4
+
twoFstarcheck
+
0.5
*
(
2
*
(
4
*
M0
+
2
*
twoFcheck
))
rho2starcheck
=
np
.
linspace
(
1e-1
,
upper
,
500
)
integrand
=
(
ncx2
.
pdf
(
twoFstarcheck
,
4
*
M0
,
rho2starcheck
)
*
ncx2
.
pdf
(
twoFcheck
,
4
,
rho2starcheck
))
if
plot
:
fig
,
ax
=
plt
.
subplots
()
ax
.
plot
(
rho2starcheck
,
integrand
)
fig
.
savefig
(
'
test
'
)
return
np
.
trapz
(
integrand
,
rho2starcheck
)
def
compute_pstar
(
twoFcheck_obs
,
twoFstarcheck_obs
,
m0
,
plot
=
False
):
M0
=
2
*
m0
+
1
upper
=
4
+
twoFcheck_obs
+
(
2
*
(
4
*
M0
+
2
*
twoFcheck_obs
))
twoFstarcheck_vals
=
np
.
linspace
(
1e-1
,
upper
,
500
)
P_twoFstarcheck
=
np
.
array
(
[
compute_P_twoFstarcheck
(
twoFstarcheck
,
twoFcheck_obs
,
M0
)
for
twoFstarcheck
in
twoFstarcheck_vals
])
C
=
np
.
trapz
(
P_twoFstarcheck
,
twoFstarcheck_vals
)
idx
=
np
.
argmin
(
np
.
abs
(
twoFstarcheck_vals
-
twoFstarcheck_obs
))
if
plot
:
fig
,
ax
=
plt
.
subplots
()
ax
.
plot
(
twoFstarcheck_vals
,
P_twoFstarcheck
)
ax
.
fill_between
(
twoFstarcheck_vals
[:
idx
+
1
],
0
,
P_twoFstarcheck
[:
idx
+
1
])
ax
.
axvline
(
twoFstarcheck_vals
[
idx
])
fig
.
savefig
(
'
test
'
)
pstar_l
=
np
.
trapz
(
P_twoFstarcheck
[:
idx
+
1
]
/
C
,
twoFstarcheck_vals
[:
idx
+
1
])
return
2
*
np
.
min
([
pstar_l
,
1
-
pstar_l
])
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment