Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
gwsample-generation [2022/05/19 09:42]
theoastro created
gwsample-generation [2022/05/19 09:53] (current)
theoastro
Line 1: Line 1:
 ==== GW sample generation ==== ==== GW sample generation ====
 +In order to generate EOS samples, we need a posterior probability file computed for a certain EOS set. Here, we use the ''15nsat_cse_uniform_R14'' EOS folder (get tar.gz) and its respective probability file, which can be found [[https://zenodo.org/record/6106130#.YoYSi3VByV5|here]]. 
  
   import numpy as np   import numpy as np
   import pandas as pd   import pandas as pd
   import bilby   import bilby
- +  # load posterior file 
-# load posterior file +  eos_post = np.loadtxt('./posterior_probability_files/Astro/15nsat_cse_uniform_R14/posterior_probability.txt')
-  eos_post = np.loadtxt('/home/nina/15_nmma_tutorial/06_GWEM-  +
- resampling/posterior_probability_files/Astro/15nsat_cse_uniform_R14/posterior_probability.txt') +
   npts = 150000    npts = 150000 
   Neos = 5000   Neos = 5000
Line 15: Line 13:
   params_low =  [1.001398, 1.001398, 1]   params_low =  [1.001398, 1.001398, 1]
   params_high = [2.2,      2.2,     75]   params_high = [2.2,      2.2,     75]
- 
   # 1) create dummy EOS samples with eos_post from nature paper   # 1) create dummy EOS samples with eos_post from nature paper
   EOS_raw = np.arange(0, Neos)  # the gwem_resampling will add one to this   EOS_raw = np.arange(0, Neos)  # the gwem_resampling will add one to this
   EOS_samples = np.random.choice(EOS_raw, p=eos_post, size=npts, replace=True)   EOS_samples = np.random.choice(EOS_raw, p=eos_post, size=npts, replace=True)
- 
   # 2) generate samples for masses and distance   # 2) generate samples for masses and distance
   mass_1 = np.random.uniform(params_low[0], params_high[0], size=npts)   mass_1 = np.random.uniform(params_low[0], params_high[0], size=npts)
Line 27: Line 23:
   chirp_mass = bilby.gw.conversion.component_masses_to_chirp_mass(mass_1, mass_2)   chirp_mass = bilby.gw.conversion.component_masses_to_chirp_mass(mass_1, mass_2)
   lum_distance = np.random.uniform(params_low[2], params_high[2], size=npts)   lum_distance = np.random.uniform(params_low[2], params_high[2], size=npts)
- 
   # 3) create pandas dataframe   # 3) create pandas dataframe
   dataset = pd.DataFrame({'mass_1': mass_1, 'mass_2': mass_2, 'chirp_mass': chirp_mass, 'mass_ratio': mass_ratio, 'luminosity_distance': lum_distance, 'EOS': EOS_samples})   dataset = pd.DataFrame({'mass_1': mass_1, 'mass_2': mass_2, 'chirp_mass': chirp_mass, 'mass_ratio': mass_ratio, 'luminosity_distance': lum_distance, 'EOS': EOS_samples})
- 
   # 4) save GWsamples.dat file   # 4) save GWsamples.dat file
-  dataset.to_csv('GWsamples_newimport numpy as np +  dataset.to_csv('GWsamples_new.dat', index=False, sep='  ')
-import pandas as pd +
-import bilby +
- +
-# load posterior file +
-eos_post = np.loadtxt('/home/nina/15_nmma_tutorial/06_GWEM-resampling/posterior_probability_files/Astro/15nsat_cse_uniform_R14/posterior_probability.txt'+
- +
-npts = 150000 +
-Neos = 5000 +
-nparams = 3 +
-############# [mass1,    mass2,   DL] +
-params_low =  [1.001398, 1.001398, 1] +
-params_high = [2.2,      2.2,     75] +
- +
-# 1) create dummy EOS samples with eos_post from nature paper +
-EOS_raw = np.arange(0, Neos)  # the gwem_resampling will add one to this +
-EOS_samples = np.random.choice(EOS_raw, p=eos_post, size=npts, replace=True) +
- +
-# 2) generate samples for masses and distance +
-mass_1 = np.random.uniform(params_low[0], params_high[0], size=npts) +
-mass_2 = np.random.uniform(params_low[1], params_high[1], size=npts) +
- +
-mass_1, mass_2 = np.maximum(mass_1, mass_2), np.minimum(mass_1, mass_2) +
-mass_ratio = mass_2 / mass_1  # mass ratio q < 1 convention is used +
-chirp_mass = bilby.gw.conversion.component_masses_to_chirp_mass(mass_1, mass_2) +
- +
-lum_distance = np.random.uniform(params_low[2], params_high[2], size=npts) +
- +
-# 3) create pandas dataframe +
-dataset = pd.DataFrame({'mass_1': mass_1, 'mass_2': mass_2, 'chirp_mass': chirp_mass, 'mass_ratio': mass_ratio, 'luminosity_distance': lum_distance, 'EOS': EOS_samples}) +
- +
-# 4) save GWsamples.dat file +
-dataset.to_csv('GWsamples.dat', index=False, sep=' ').dat', index=False, sep=' ')+
Last modified: le 2022/05/19 09:42