Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
PORTER Edward
GWHMC
Commits
98726a3b
Commit
98726a3b
authored
Apr 05, 2021
by
Marc Arene
Browse files
fix for --plot_traj: - saving `q_pos_traj_0` and not `q_pos_0` - saving under `qpos_traj.dat`
parent
f93f1a4f
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
14 additions
and
10 deletions
+14
-10
Codes/main.py
Codes/main.py
+5
-5
Library/BNS_HMC_Tools.py
Library/BNS_HMC_Tools.py
+4
-3
Tests/plot_trajectory.py
Tests/plot_trajectory.py
+5
-2
No files found.
Codes/main.py
View file @
98726a3b
...
...
@@ -554,7 +554,7 @@ if __name__ == '__main__':
sampler
.
dict_of_trajectories
=
dict
(
H_p_logL_logP
=
[],
pmom_trajs
=
[],
qpos
=
[],
qpos
_traj
=
[],
dlogL
=
[],
dlogTrajPi_traj
=
[],
lengths
=
[]
...
...
@@ -650,10 +650,10 @@ if __name__ == '__main__':
if
RUN_CONST
.
plot_traj
:
np
.
savetxt
(
sampler
.
plot_traj_dir
+
'H_p_logL_logP.dat'
,
sampler
.
dict_of_trajectories
[
'H_p_logL_logP'
])
np
.
savetxt
(
sampler
.
plot_traj_dir
+
'pmom_trajs.dat'
,
sampler
.
dict_of_trajectories
[
'pmom_trajs'
])
np
.
savetxt
(
sampler
.
plot_traj_dir
+
'qpos.dat'
,
sampler
.
dict_of_trajectories
[
'qpos'
])
np
.
savetxt
(
sampler
.
plot_traj_dir
+
'qpos
_traj
.dat'
,
sampler
.
dict_of_trajectories
[
'qpos
_traj
'
])
np
.
savetxt
(
sampler
.
plot_traj_dir
+
'dlogL.dat'
,
sampler
.
dict_of_trajectories
[
'dlogL'
])
np
.
savetxt
(
sampler
.
plot_traj_dir
+
'dlogTrajPi_traj.dat'
,
sampler
.
dict_of_trajectories
[
'dlogTrajPi_traj'
])
np
.
savetxt
(
sampler
.
plot_traj_dir
+
'lengths.dat'
,
sampler
.
dict_of_trajectories
[
'lengths'
])
np
.
savetxt
(
sampler
.
plot_traj_dir
+
'lengths.dat'
,
sampler
.
dict_of_trajectories
[
'lengths'
]
,
fmt
=
'%.0f'
)
# Make a walker and corner plots of the chain in phase1
sampler
.
plot_corner
(
sis
=
False
,
reweighted
=
False
,
priors
=
True
,
save
=
True
,
outdir
=
outdir
+
'plots/phase1/'
,
in_comp_mass
=
False
)
...
...
@@ -1448,10 +1448,10 @@ if __name__ == '__main__':
if
RUN_CONST
.
plot_traj
:
np
.
savetxt
(
sampler
.
plot_traj_dir
+
'H_p_logL_logP.dat'
,
sampler
.
dict_of_trajectories
[
'H_p_logL_logP'
])
np
.
savetxt
(
sampler
.
plot_traj_dir
+
'pmom_trajs.dat'
,
sampler
.
dict_of_trajectories
[
'pmom_trajs'
])
np
.
savetxt
(
sampler
.
plot_traj_dir
+
'qpos.dat'
,
sampler
.
dict_of_trajectories
[
'qpos'
])
np
.
savetxt
(
sampler
.
plot_traj_dir
+
'qpos
_traj
.dat'
,
sampler
.
dict_of_trajectories
[
'qpos
_traj
'
])
np
.
savetxt
(
sampler
.
plot_traj_dir
+
'dlogL.dat'
,
sampler
.
dict_of_trajectories
[
'dlogL'
])
np
.
savetxt
(
sampler
.
plot_traj_dir
+
'dlogTrajPi_traj.dat'
,
sampler
.
dict_of_trajectories
[
'dlogTrajPi_traj'
])
np
.
savetxt
(
sampler
.
plot_traj_dir
+
'lengths.dat'
,
sampler
.
dict_of_trajectories
[
'lengths'
])
np
.
savetxt
(
sampler
.
plot_traj_dir
+
'lengths.dat'
,
sampler
.
dict_of_trajectories
[
'lengths'
]
,
fmt
=
'%.0f'
)
sampler
.
plot_all_corners
()
sampler
.
plot_autocorrelations_of_parameters
()
...
...
Library/BNS_HMC_Tools.py
View file @
98726a3b
...
...
@@ -48,7 +48,8 @@ def NumericalGradientLeapfrog_ThreeDetectors(q_pos_0, logL_0, dlogL_0, randGen,
H_p_logL_logP_0
=
[
H_0
,
0.5
*
(
p_mom_0
**
2
).
sum
(),
logL_0
,
logTrajPi_0
]
sampler
.
dict_of_trajectories
[
'H_p_logL_logP'
].
append
(
H_p_logL_logP_0
)
sampler
.
dict_of_trajectories
[
'pmom_trajs'
].
append
(
p_mom_0
.
tolist
())
sampler
.
dict_of_trajectories
[
'qpos'
].
append
(
q_pos_0
.
tolist
())
q_pos_traj_0
=
sampler
.
q_pos_to_q_pos_traj
(
q_pos_0
)
sampler
.
dict_of_trajectories
[
'qpos_traj'
].
append
(
q_pos_traj_0
.
tolist
())
sampler
.
dict_of_trajectories
[
'dlogL'
].
append
(
dlogL_0
)
dlogTrajPi_0
=
sampler
.
traj_prior_gradients
.
calculate_dlogPi_np
(
qpos_dict_0
)
sampler
.
dict_of_trajectories
[
'dlogTrajPi_traj'
].
append
(
dlogTrajPi_0
.
tolist
())
...
...
@@ -90,13 +91,13 @@ def NumericalGradientLeapfrog_ThreeDetectors(q_pos_0, logL_0, dlogL_0, randGen,
H_p_logL_logP_0
=
[
0
,
0
,
0
,
0
]
sampler
.
dict_of_trajectories
[
'H_p_logL_logP'
].
append
(
0
)
sampler
.
dict_of_trajectories
[
'pmom_trajs'
].
append
([
0
]
*
sampler
.
n_dim
)
sampler
.
dict_of_trajectories
[
'qpos'
].
append
([
0
]
*
sampler
.
n_dim
)
sampler
.
dict_of_trajectories
[
'qpos
_traj
'
].
append
([
0
]
*
sampler
.
n_dim
)
sampler
.
dict_of_trajectories
[
'dlogL'
].
append
(
0
)
sampler
.
dict_of_trajectories
[
'dlogTrajPi_traj'
].
append
([
0
]
*
sampler
.
n_dim
)
for
i
in
range
(
len
(
pt_fit_traj
)):
sampler
.
dict_of_trajectories
[
'H_p_logL_logP'
].
append
(
H_p_logL_logP_traj
[
i
])
sampler
.
dict_of_trajectories
[
'pmom_trajs'
].
append
(
pmom_traj
[
i
])
sampler
.
dict_of_trajectories
[
'qpos'
].
append
(
pt_fit_traj
[
i
])
sampler
.
dict_of_trajectories
[
'qpos
_traj
'
].
append
(
pt_fit_traj
[
i
])
sampler
.
dict_of_trajectories
[
'dlogL'
].
append
(
dlogL_fit_traj
[
i
])
sampler
.
dict_of_trajectories
[
'dlogTrajPi_traj'
].
append
(
dlogTrajPi_traj
[
i
])
sampler
.
dict_of_trajectories
[
'lengths'
].
append
(
lengthT
)
...
...
Tests/plot_trajectory.py
View file @
98726a3b
...
...
@@ -79,8 +79,11 @@ search_trajectory_inv_functions = get_trajectory_inverse_functions(search_trajec
# dict_trajectory_parameters_keys = get_dict_trajectory_parameters_keys(search_parameter_keys, sampler_dict['trajectory_parameters_keys'])
dict_parameters_offsets
=
sampler_dict
[
'parameters_offsets'
]
pt_fit_traj_file
=
outdir_plot_traj
+
'qpos.dat'
# For a long time I used to save the positions of the trajectories under `qpos.dat` and then renamed for `qpos_traj.dat` because I am actually saving the "trajectory" parameters values.
if
os
.
path
.
isfile
(
outdir_plot_traj
+
'qpos.dat'
):
pt_fit_traj_file
=
outdir_plot_traj
+
'qpos.dat'
else
:
pt_fit_traj_file
=
outdir_plot_traj
+
'qpos_traj.dat'
dlogL_file
=
outdir_plot_traj
+
'dlogL.dat'
H_p_logL_logP_file
=
outdir_plot_traj
+
'H_p_logL_logP.dat'
pmom_trajs_file
=
outdir_plot_traj
+
'pmom_trajs.dat'
...
...
Write
Preview
Markdown
is supported
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