mirror of
https://github.com/Richard-Sti/csiborgtools_public.git
synced 2025-07-06 22:41:11 +00:00
* Update nb * Update script * Update script * Rename * Update script * Update script * Remove warning * Ignore minors when extracting MAH * Fix paths bug * Move notebooks * Move files * Rename and delete things * Rename file * Move file * Rename things * Remove old print statement * Add basic MAH plot * Add random MAH path * Output snapshot numbers * Add MAH random extraction * Fix redshift bug * Edit script * Add extracting random MAH * Little updates * Add CB2 redshift * Add some caching * Add diagnostic plots * Add caching * Minor updates * Update nb * Update notebook * Update script * Add Sorce randoms * Add CB2 varysmall * Update nb * Update nb * Update nb * Use catalogue HMF * Move definition of radec2galactic * Update nb * Update import * Update import * Add galatic coords to catalogues * Update nb
24 KiB
24 KiB
In [7]:
import numpy as np
import matplotlib.pyplot as plt
import Pk_library as PKL
import os
import analysis
import h5py as h5
In [36]:
ini_name = 'ini_file.ini'
dirname = 'outdir/example0'
which_field = 'BORG_final_density'; MAS = 'CIC'
# which_field = 's_field'; MAS = 'None'
dens, L = analysis.get_mock_field(ini_name, dirname, which_field)
print(np.std(dens), np.mean(dens))
Pk = PKL.Pk(dens.astype(np.float32), L, axis=0, MAS=MAS, threads=1, verbose=True)
k = Pk.k3D
Pk_true = Pk.Pk[:,0]
plt.loglog(k, Pk_true)
plt.figure()
plt.pcolor(dens[dens.shape[0]//2])
plt.gca().set_aspect('equal')
In [39]:
mcmc_steps = np.arange(20)
ini_name = 'ini_file.ini'
dirname = 'outdir/example0'
dens_mean, dens_std = analysis.compute_ensemble_mean_field(ini_name, dirname, mcmc_steps)
plt.figure()
plt.pcolor(dens_mean[dens_mean.shape[0]//2])
plt.gca().set_aspect('equal')
In [35]:
mcmc_steps = np.arange(20)
ini_name = 'ini_file.ini'
dirname = 'outdir/example0'
k, Pk_true, all_pk, all_r = analysis.get_spectra(ini_name, dirname, mcmc_steps)
# for i in range(len(all_pk)):
for i in range(0, 20, 2):
plt.loglog(k, all_pk[i], label=f'Step {i}')
plt.loglog(k, Pk_true, ls='--', color='k', label='True')
plt.legend()
plt.figure()
for i in range(0, 20, 2):
plt.semilogx(k, all_r[i], label=f'Step {i}')
plt.axhline(1, ls='--', color='k', label='True')
plt.legend()
Out[35]:
In [11]:
dirname = 'outdir/example1'
all_fname = ['mock_data.h5', 'mcmc_0.h5', 'mcmc_20.h5', 'mcmc_79.h5']
for fname in all_fname:
with h5.File(os.path.join(dirname, fname), 'r') as f:
sfield = f['scalars/BORG_final_density'][:]
print(fname, sfield.std())
In [ ]: