Commit e31c1512 authored by Marc Arene's avatar Marc Arene
Browse files

Now using `set_inj.ini_file_to_dict()`

parent ed175a31
......@@ -175,7 +175,7 @@ if __name__=='__main__':
# SET THE INJECTION PARAMETERS
injection_parameters = set_inj.injection_parameters
injection_parameters = set_inj.ini_file_to_dict()
print("\nInjection parameters dictionary:")
pu.print_dict(injection_parameters)
minimum_frequency = injection_parameters['meta']['minimum_frequency']
......
{
"mass_1":1.47,
"mass_2":1.27,
"chi_1":0.0,
"chi_2":0.0,
"luminosity_distance":40,
"iota":2.81,
"theta_jn":2.81,
"psi":2.21,
"phase":5.497787143782138,
"geocent_time":1187008882.43,
"ra":3.44616,
"dec":-0.408084,
"lambda_1":0.0,
"lambda_2":0.0,
"tilt_1":0,
"tilt_2":0,
"meta": {
"minimum_frequency":40
}
}
......@@ -53,66 +53,47 @@ def Compute_fmax(Rmin, m1, m2):
fmax = vmax**3 / (PI * GEOM * Mt) # fmax signal
return fmax
# with open('../Codes/GW170817.json') as inj_file:
# injection_parameters = json.load(inj_file)
# inj_file.close
config = ConfigParser()
config.read('../Codes/GW170817.ini')
injection_parameters = pu.config_parser_to_dict(config)['parameters']
# injection_parameters = dict(
# mass_1=1.47,
# mass_2=1.27,
# chi_1=0.0,
# chi_2=0.0,
# luminosity_distance=40,
# # iota=146*np.pi/180,
# iota=2.81,
# theta_jn=2.81,
# psi=2.21,
# phase=5.497787143782138,
# geocent_time=1187008882.43,
# ra=3.44616, # value from fixed skyposition run
# dec=-0.408084, # value from fixed skyposition run
# lambda_1=0.,
# lambda_2=0.,
# tilt_1=0,
# tilt_2=0
# )
injection_parameters = conv.generate_mass_parameters(injection_parameters)
injection_parameters['reduced_mass'] = (injection_parameters['mass_1'] * injection_parameters['mass_2']) / (injection_parameters['mass_1'] + injection_parameters['mass_2'])
# Set the duration and sampling frequency of the data segment that we're going
# to inject the signal into. For the
# TaylorF2 waveform, we cut the signal close to the isco frequency
minimum_frequency=30.0
m1 = injection_parameters['mass_1']
m2 = injection_parameters['mass_2']
tc_3p5PN = ComputeChirpTime3p5PN(minimum_frequency, m1, m2)
# We integrate the signal up to the frequency of the "Innermost stable circular orbit (ISCO)"
R_isco = 6. # Orbital separation at ISCO, in geometric units. 6M for PN ISCO; 2.8M for EOB
m1_min = 1
m2_min = 1
f_high = Compute_fmax(R_isco, m1, m2)
f_high_run = Compute_fmax(R_isco, m1_min, m2_min)
# import IPython; IPython.embed();
duration = tc_3p5PN + 2
# sampling_frequency = 4096
# sampling_frequency = 4397
sampling_frequency = 2 * f_high_run
start_time = injection_parameters['geocent_time'] - tc_3p5PN
meta_params = dict(
minimum_frequency = minimum_frequency,
tc_3p5PN = tc_3p5PN,
f_high = f_high,
f_high_run = f_high_run,
duration = duration,
sampling_frequency = sampling_frequency,
start_time = start_time
)
injection_parameters['meta'] = meta_params
def ini_file_to_dict(file_path='../examples/GW170817.ini'):
config = ConfigParser()
config.read(file_path)
injection_parameters = pu.config_parser_to_dict(config)['parameters']
injection_parameters = conv.generate_mass_parameters(injection_parameters)
injection_parameters['reduced_mass'] = (injection_parameters['mass_1'] * injection_parameters['mass_2']) / (injection_parameters['mass_1'] + injection_parameters['mass_2'])
# Set the duration and sampling frequency of the data segment that we're going
# to inject the signal into. For the
# TaylorF2 waveform, we cut the signal close to the isco frequency
minimum_frequency=30.0
m1 = injection_parameters['mass_1']
m2 = injection_parameters['mass_2']
tc_3p5PN = ComputeChirpTime3p5PN(minimum_frequency, m1, m2)
# We integrate the signal up to the frequency of the "Innermost stable circular orbit (ISCO)"
R_isco = 6. # Orbital separation at ISCO, in geometric units. 6M for PN ISCO; 2.8M for EOB
m1_min = 1
m2_min = 1
f_high = Compute_fmax(R_isco, m1, m2)
f_high_run = Compute_fmax(R_isco, m1_min, m2_min)
# import IPython; IPython.embed();
duration = tc_3p5PN + 2
# sampling_frequency = 4096
# sampling_frequency = 4397
sampling_frequency = 2 * f_high_run
start_time = injection_parameters['geocent_time'] - tc_3p5PN
meta_params = dict(
minimum_frequency = minimum_frequency,
tc_3p5PN = tc_3p5PN,
f_high = f_high,
f_high_run = f_high_run,
duration = duration,
sampling_frequency = sampling_frequency,
start_time = start_time
)
injection_parameters['meta'] = meta_params
return injection_parameters
......@@ -167,7 +167,7 @@ def q_pos_to_dictionary_original(q_pos, start_time):
def q_pos_to_dictionary(q_pos, start_time, dictionary=None):
if dictionary is None:
dictionary = set_inj.injection_parameters
dictionary = set_inj.ini_file_to_dict()
if 0 in conf.param_indices:
dictionary['iota'] = q_pos[0]
dictionary['theta_jn'] = q_pos[0]
......@@ -289,8 +289,8 @@ def sigpar_to_freq_and_indices_2(sigpar,n_freq):
duration, sampling_frequency, start_time = sigpar_to_ifo_parameters(sigpar)
import Library.set_injection_parameters as set_inj
duration = set_inj.injection_parameters['meta']['duration']
sampling_frequency = set_inj.injection_parameters['meta']['sampling_frequency']
duration = set_inj.ini_file_to_dict()['meta']['duration']
sampling_frequency = set_inj.ini_file_to_dict()['meta']['sampling_frequency']
freqs = bc_utils.create_frequency_series(sampling_frequency, duration)
......
......@@ -114,7 +114,7 @@ def main_old():
return injection_parameters
def main():
return set_inj.injection_parameters
return set_inj.ini_file_to_dict()
if __name__=='__main__':
......
......@@ -13,7 +13,7 @@ import bilby
# ## Initialise the input data
injection_parameters = set_inj.injection_parameters
injection_parameters = set_inj.ini_file_to_dict()
minimum_frequency=30.0
m1 = injection_parameters['mass_1']
m2 = injection_parameters['mass_2']
......
......@@ -29,7 +29,7 @@ H1 = interferometers[0]
L1 = interferometers[1]
injection_parameters = set_inj.injection_parameters
injection_parameters = set_inj.ini_file_to_dict()
parameters = injection_parameters.copy()
......
......@@ -13,7 +13,7 @@ import bilby
# ## Initialise the input data
injection_parameters = set_inj.injection_parameters
injection_parameters = set_inj.ini_file_to_dict()
minimum_frequency=30.0
m1 = injection_parameters['mass_1']
m2 = injection_parameters['mass_2']
......
......@@ -21,15 +21,15 @@ LAL_PI = 3.141592653589793238462643383279502884
LAL_PC_SI = 3.085677581491367278913937957796471611e16 # not used here
LAL_GAMMA = 0.577215664901532860606512090082402431
eta = set_inj.injection_parameters['symmetric_mass_ratio']
mass_1= set_inj.injection_parameters['mass_1']
mass_2 = set_inj.injection_parameters['mass_2']
eta = set_inj.ini_file_to_dict()['symmetric_mass_ratio']
mass_1= set_inj.ini_file_to_dict()['mass_1']
mass_2 = set_inj.ini_file_to_dict()['mass_2']
mass_1 = mass_1 * bilby.core.utils.solar_mass
mass_2 = mass_2 * bilby.core.utils.solar_mass
m1 = mass_1 / LAL_MSUN_SI
m2 = mass_2 / LAL_MSUN_SI
luminosity_distance = set_inj.injection_parameters['luminosity_distance']
luminosity_distance = set_inj.ini_file_to_dict()['luminosity_distance']
luminosity_distance = luminosity_distance * 1e6 * bilby.core.utils.parsec
r = luminosity_distance
......
......@@ -11,7 +11,7 @@ import Library.bilby_utils as bilby_utils
import Library.config as conf
import Library.set_injection_parameters as set_inj
injection_parameters = set_inj.injection_parameters
injection_parameters = set_inj.ini_file_to_dict()
parameters = injection_parameters.copy()
......
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