Commit bf547960 authored by Marc Arene's avatar 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
......@@ -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)
......@@ -1451,7 +1451,7 @@ if __name__ == '__main__':
np.savetxt(sampler.plot_traj_dir + 'qpos.dat', sampler.dict_of_trajectories['qpos'])
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()
......
......@@ -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)
......
......@@ -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'
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment