Commit 2a20555a authored by Marc Arene's avatar Marc Arene
Browse files

Introducing `maximum_frequency_of_analysis`

parent 09a919ce
......@@ -173,6 +173,7 @@ if __name__=='__main__':
print("\nInjection parameters dictionary:")
pu.print_dict(injection_parameters)
minimum_frequency = injection_parameters['meta']['minimum_frequency']
maximum_frequency_of_analysis = injection_parameters['meta']['maximum_frequency_of_analysis']
duration = injection_parameters['meta']['duration']
sampling_frequency = injection_parameters['meta']['sampling_frequency']
f_high = injection_parameters['meta']['f_high']
......@@ -189,6 +190,7 @@ if __name__=='__main__':
# The minimun frequency for each interferometer needs to be set if we want the strain derived from the psd to start being non zero at that frequency and not at the default one which is 20Hz
for ifo in interferometers:
ifo.minimum_frequency = minimum_frequency
ifo.maximum_frequency = maximum_frequency_of_analysis
# The following line is called automatically when setting the PSDs, which we donnot do here hence the line.
# Stangely however, in bilby, the `Interferometer` class does not have `duration` and `sampling_frequency` arguments when the `InterferometerStrainData` and the `InterferometerList` classes do. Hence one needs to set those arguments for the list of `InterferometerStrainData` so that the `InterferometerList` inherits from them. The values will be inherited from the first one in the list...
# Why do `interferometers.duration` and `interferometers.sampling_frequency` need to be set ? => Because I use them when creating my waveform_generator in bilby_wavefor
......@@ -209,15 +211,18 @@ if __name__=='__main__':
start_time=start_time)
# WAVEFORM GENERATION
template_ifos = bilby_wv.WaveForm_ThreeDetectors(injection_parameters, minimum_frequency, interferometers)
injection_parameters['meta']['maximum_frequency_of_generated_waveform'] = injection_parameters['meta']['maximum_frequency_injected_waveform']
template_ifos_injected = bilby_wv.WaveForm_ThreeDetectors(injection_parameters, minimum_frequency, interferometers)
# INJECT TEMPLATE INTO NOISE STRAIN DATA
# Add the template signal to each detector's strain data
for i in range(len(interferometers)):
interferometers[i].strain_data.frequency_domain_strain += template_ifos[i]
interferometers[i].strain_data.frequency_domain_strain += template_ifos_injected[i]
interferometers[i].fd_strain = interferometers[i].strain_data.frequency_domain_strain
# COMPUTE AND PRINT SNR
injection_parameters['meta']['maximum_frequency_of_generated_waveform'] = injection_parameters['meta']['maximum_frequency_of_analysis']
template_ifos = bilby_wv.WaveForm_ThreeDetectors(injection_parameters, minimum_frequency, interferometers)
logL, Snr, opt_snr_Best = logL_snr.main(template_ifos, interferometers, True)
......
......@@ -17,7 +17,7 @@ import Codes.logL_snr as logL_snr
def main(injection_parameters, start_time, minimum_frequency, interferometers, do_prints=False):
import IPython; IPython.embed()
dlogL, logL = bilby_wv.dlogL_ThreeDetectors(injection_parameters, start_time, minimum_frequency, interferometers)
prefix = '\ndlogL with bilby '
......@@ -71,7 +71,7 @@ if __name__=='__main__':
pu.print_dict(injection_parameters)
minimum_frequency = injection_parameters['meta']['minimum_frequency']
maximum_frequency = 2048
# maximum_frequency = injection_parameters['meta']['maximum_frequency']
# maximum_frequency_of_analysis = injection_parameters['meta']['maximum_frequency_of_analysis']
duration = injection_parameters['meta']['duration']
sampling_frequency = injection_parameters['meta']['sampling_frequency']
f_high = injection_parameters['meta']['f_high']
......@@ -86,7 +86,7 @@ if __name__=='__main__':
for ifo in interferometers:
# ifo.__class__ = bilby_detector.Interferometer
ifo.minimum_frequency = minimum_frequency
ifo.maximum_frequency = maximum_frequency
ifo.maximum_frequency = maximum_frequency_of_analysis
# The following line is called automatically when setting the PSDs, which we donnot do here hence the line.
# Stangely however, in bilby, the `Interferometer` class does not have `duration` and `sampling_frequency` arguments when the `InterferometerStrainData` and the `InterferometerList` classes do. Hence one needs to set those arguments for the list of `InterferometerStrainData` so that the `InterferometerList` inherits from them. The values will be inherited from the first one in the list...
# Why do `interferometers.duration` and `interferometers.sampling_frequency` need to be set ? => Because I use them when creating my waveform_generator in bilby_wavefor
......
......@@ -49,7 +49,7 @@ if __name__=='__main__':
injection_parameters = set_inj.ini_file_to_dict()
pu.print_dict(injection_parameters)
minimum_frequency = injection_parameters['meta']['minimum_frequency']
maximum_frequency = injection_parameters['meta']['maximum_frequency']
maximum_frequency_of_analysis = injection_parameters['meta']['maximum_frequency_of_analysis']
duration = injection_parameters['meta']['duration']
sampling_frequency = injection_parameters['meta']['sampling_frequency']
f_high = injection_parameters['meta']['f_high']
......@@ -63,7 +63,7 @@ if __name__=='__main__':
interferometers = bilby.gw.detector.InterferometerList(ifos_chosen)
for ifo in interferometers:
ifo.minimum_frequency = minimum_frequency
# ifo.maximum_frequency = maximum_frequency
ifo.maximum_frequency = maximum_frequency_of_analysis
# The following line is called automatically when setting the PSDs, which we donnot do here hence the line.
# Stangely however, in bilby, the `Interferometer` class does not have `duration` and `sampling_frequency` arguments when the `InterferometerStrainData` and the `InterferometerList` classes do. Hence one needs to set those arguments for the list of `InterferometerStrainData` so that the `InterferometerList` inherits from them. The values will be inherited from the first one in the list...
# Why do `interferometers.duration` and `interferometers.sampling_frequency` need to be set ? => Because I use them when creating my waveform_generator in bilby_wavefor
......@@ -83,13 +83,17 @@ if __name__=='__main__':
start_time=start_time)
# WAVEFORM GENERATION
template_ifos = bilby_wv.WaveForm_ThreeDetectors(injection_parameters, minimum_frequency, interferometers)
injection_parameters['meta']['maximum_frequency_of_generated_waveform'] = injection_parameters['meta']['maximum_frequency_injected_waveform']
template_ifos_injected = bilby_wv.WaveForm_ThreeDetectors(injection_parameters, minimum_frequency, interferometers)
# INJECT TEMPLATE INTO NOISE STRAIN DATA
# Add the template signal to each detector's strain data
for i in range(len(interferometers)):
interferometers[i].strain_data.frequency_domain_strain += template_ifos[i]
interferometers[i].strain_data.frequency_domain_strain += template_ifos_injected[i]
interferometers[i].fd_strain = interferometers[i].strain_data.frequency_domain_strain
# COMPUTE AND PRINT SNR
# Generate a template up to frequency of analysis
injection_parameters['meta']['maximum_frequency_of_generated_waveform'] = injection_parameters['meta']['maximum_frequency_of_analysis']
template_ifos = bilby_wv.WaveForm_ThreeDetectors(injection_parameters, minimum_frequency, interferometers)
logLBest, mf_snr_best, opt_snr_Best = main(template_ifos, interferometers, True)
......@@ -146,9 +146,10 @@ def ini_file_to_dict(file_path='../examples/GW170817.ini'):
rescaled_params = roqu.rescale_params(params_best_basis, scale_factor)
minimum_frequency = rescaled_params['flow']
maximum_frequency = rescaled_params['fhigh']
# maximum_frequency = min(2048, rescaled_params['fhigh'])
# maximum_frequency = min(4 * 4096, f_high_run)
# maximum_frequency_injected_waveform = rescaled_params['fhigh']
maximum_frequency_injected_waveform = min(2048, rescaled_params['fhigh'])
maximum_frequency_of_analysis = min(2048, rescaled_params['fhigh'])
# maximum_frequency_of_analysis = rescaled_params['fhigh']
sampling_frequency = 2 * max(2048, rescaled_params['fhigh'])
duration = rescaled_params['seglen']
reference_frequency = 20 * scale_factor
......@@ -176,21 +177,24 @@ def ini_file_to_dict(file_path='../examples/GW170817.ini'):
M_min_sec = (m1_min + m2_min) * LAL_MTSUN_SI
f_high = f_CUT / M_sec
f_high_run = f_CUT / M_min_sec
maximum_frequency = min(2048, f_high_run)
# maximum_frequency = min(4 * 4096, f_high_run)
sampling_frequency = 2 * maximum_frequency
maximum_frequency_of_analysis = min(2048, f_high_run)
# maximum_frequency_of_analysis = min(4 * 4096, f_high_run)
maximum_frequency_injected_waveform = maximum_frequency_of_analysis
sampling_frequency = 2 * maximum_frequency_of_analysis
duration = 64
reference_frequency = 20
# import IPython; IPython.embed();
# maximum_frequency = min(4096 * 4, f_high_run)
# maximum_frequency = max(4096, f_high)
# maximum_frequency_of_analysis = min(4096 * 4, f_high_run)
# maximum_frequency_of_analysis = max(4096, f_high)
# sampling_frequency = 4096
# sampling_frequency = 4397
start_time = injection_parameters['geocent_time'] - tc_3p5PN
# breakpoint()
meta_params = dict(
minimum_frequency = minimum_frequency,
maximum_frequency = maximum_frequency,
maximum_frequency_injected_waveform = maximum_frequency_injected_waveform,
maximum_frequency_of_analysis = maximum_frequency_of_analysis,
maximum_frequency_of_generated_waveform = None,
sampling_frequency = sampling_frequency,
duration = duration,
tc_3p5PN = tc_3p5PN,
......@@ -205,7 +209,7 @@ def ini_file_to_dict(file_path='../examples/GW170817.ini'):
conf.minimum_frequency = minimum_frequency
conf.approximant = approximant
conf.maximum_frequency = maximum_frequency
conf.maximum_frequency_of_analysis = maximum_frequency_of_analysis
conf.reference_frequency = reference_frequency
# These two lines have been added to be able to plot the injected value on phi_c on the corner plots. Otherwise the `phi_c` and `tc_3p5PN` keys are not used in the code.
......
......@@ -11,12 +11,13 @@ import Library.bilby_detector as bilby_det
import Library.config as conf
def get_source_frame_polarizations(parameters, minimum_frequency, interferometers):
# breakpoint()
# Fixed arguments passed into the source model. The analysis starts at 40 Hz.
if 'meta' in parameters.keys():
waveform_arguments = dict(waveform_approximant=parameters['meta']['approximant'], reference_frequency=parameters['meta']['reference_frequency'], minimum_frequency=minimum_frequency, maximum_frequency=parameters['meta']['maximum_frequency'])
waveform_arguments = dict(waveform_approximant=parameters['meta']['approximant'], reference_frequency=parameters['meta']['reference_frequency'], minimum_frequency=minimum_frequency, maximum_frequency=0)
# waveform_arguments = dict(waveform_approximant=parameters['meta']['approximant'], reference_frequency=parameters['meta']['reference_frequency'], minimum_frequency=minimum_frequency, maximum_frequency=parameters['meta']['maximum_frequency_of_generated_waveform'])
else:
waveform_arguments = dict(waveform_approximant=conf.approximant, reference_frequency=conf.reference_frequency, minimum_frequency=conf.minimum_frequency, maximum_frequency=conf.maximum_frequency)
waveform_arguments = dict(waveform_approximant=conf.approximant, reference_frequency=conf.reference_frequency, minimum_frequency=conf.minimum_frequency, maximum_frequency=conf.maximum_frequency_of_analysis)
# Create the waveform_generator using a LAL Binary Neutron Star source function
waveform_generator = bilby.gw.WaveformGenerator(
......@@ -26,7 +27,7 @@ def get_source_frame_polarizations(parameters, minimum_frequency, interferometer
parameter_conversion=bilby.gw.conversion.convert_to_lal_binary_neutron_star_parameters,
waveform_arguments=waveform_arguments
)
pu.print_dict({"waveform_arguments": waveform_arguments})
# pu.print_dict({"waveform_arguments": waveform_arguments})
# [Marc]: h+ and hx in source frame
source_frame_polarizations = waveform_generator.frequency_domain_strain(parameters)
......@@ -764,6 +765,7 @@ if __name__=='__main__':
injection_parameters = set_inj.ini_file_to_dict()
pu.print_dict(injection_parameters)
minimum_frequency = injection_parameters['meta']['minimum_frequency']
maximum_frequency_of_analysis = injection_parameters['meta']['maximum_frequency_of_analysis']
duration = injection_parameters['meta']['duration']
sampling_frequency = injection_parameters['meta']['sampling_frequency']
f_high = injection_parameters['meta']['f_high']
......@@ -777,6 +779,7 @@ if __name__=='__main__':
interferometers = bilby.gw.detector.InterferometerList(ifos_chosen)
for ifo in interferometers:
ifo.minimum_frequency = minimum_frequency
ifo.maximum_frequency = maximum_frequency_of_analysis
# The following line is called automatically when setting the PSDs, which we donnot do here hence the line.
# Stangely however, in bilby, the `Interferometer` class does not have `duration` and `sampling_frequency` arguments when the `InterferometerStrainData` and the `InterferometerList` classes do. Hence one needs to set those arguments for the list of `InterferometerStrainData` so that the `InterferometerList` inherits from them. The values will be inherited from the first one in the list...
# Why do `interferometers.duration` and `interferometers.sampling_frequency` need to be set ? => Because I use them when creating my waveform_generator in bilby_wavefor
......@@ -833,7 +836,7 @@ if __name__=='__main__':
# plt.plot(time[idx_start:idx_stop], h_wave_td[ifo_index][idx_start:idx_stop], linewidth=1, color=ifo_colors[ifo_index], label=interferometers[ifo_index].name)
plt.axvline(x=time_until_fISCO, linewidth=1, color='blue', label='time to reach fISCO')
plt.axvline(x=injection_parameters['meta']['tc_3p5PN'], color='black', linewidth=1, label='tc')
text = 'f_low = {:.2f}Hz\nf_ISCO = {:.2f}Hz\nmax_freq = {:.2f}Hz\nsamp_freq= {:.2f}Hz\ntc_3p5PN = {:.4f}s'.format(minimum_frequency, fISCO, injection_parameters['meta']['maximum_frequency'], sampling_frequency, injection_parameters['meta']['tc_3p5PN'])
text = 'f_low = {:.2f}Hz\nf_ISCO = {:.2f}Hz\nmax_freq = {:.2f}Hz\nsamp_freq= {:.2f}Hz\ntc_3p5PN = {:.4f}s'.format(minimum_frequency, fISCO, injection_parameters['meta']['maximum_frequency_of_analysis'], sampling_frequency, injection_parameters['meta']['tc_3p5PN'])
plt.text(duration-7, h_wave_td[0].max()*2/3, text, fontsize=10)
# import IPython; IPython.embed()
plt.xlabel("Time (sec)")
......
......@@ -37,7 +37,8 @@ param_indices = [0,1,2,3,4,5,6,7,8]
dlogL = 'dlogL1'
minimum_frequency = 30
approximant = 'TaylorF2'
maximum_frequency = 0
maximum_frequency_injected_waveform = 0
maximum_frequency_of_analysis = 0
reference_frequency = 0
debug = False
......
......@@ -1045,4 +1045,20 @@ logL on gpu = 4ms
- Timing comparision IMRPhenomPv2 with and without ROQ
- for a freq array of 524289 elements -going from flow=34Hz until fhigh=6963.2Hz- dlogL took 2.63s without ROQ versus 33ms with ROQ => speed up factor of 80 ! (Values of logL and dlogL of both methods being very close (logL=674 case))
- Understanding the different logL values and weights calculated by ROQ:
- bottom line: lalsim seems to generate different waveforms depending on the maximum frequency it's inputed with: values of h_plus are different between 34Hz and 2048Hz if maximum_freq is 2048Hz or 6963Hz.
- The weights built from the ROQ basis depend on the fd_strain injected
- The sampling frequency for the ROQ basis to be built needs to be 2*roq_params['fhigh'] but the maximum_freq of the interferometers can be less, like 2048Hz
- TaylorF2:
- Using:
```
f_ISCO = Compute_LAL_fISCO(m1 * LAL_MSUN_SI, m2 * LAL_MSUN_SI)
f_ISCO_run = Compute_LAL_fISCO(m1_min * LAL_MSUN_SI, m2_min * LAL_MSUN_SI)
```
instead of my `Compute_fISCO()` actually changes a bit the SNR and logL value
- => Try running phase1 with this configuration and see how the fitting works
AVANT LE DEPART EN DROME: AVOIR UN RUN PHASE 1AVEC IMRPHENOMPV2 ROQ sur GW170817 !
......@@ -68,8 +68,7 @@ if __name__=='__main__':
injection_parameters = set_inj.ini_file_to_dict(opts.inj_file)
pu.print_dict(injection_parameters)
minimum_frequency = injection_parameters['meta']['minimum_frequency']
maximum_frequency = 2048
# maximum_frequency = injection_parameters['meta']['maximum_frequency']
maximum_frequency_of_analysis = injection_parameters['meta']['maximum_frequency_of_analysis']
duration = injection_parameters['meta']['duration']
sampling_frequency = injection_parameters['meta']['sampling_frequency']
f_high = injection_parameters['meta']['f_high']
......@@ -85,7 +84,7 @@ if __name__=='__main__':
for ifo in interferometers:
# ifo.__class__ = bilby_detector.Interferometer
ifo.minimum_frequency = minimum_frequency
# ifo.maximum_frequency = maximum_frequency
ifo.maximum_frequency = maximum_frequency_of_analysis
# The following line is called automatically when setting the PSDs, which we donnot do here hence the line.
# Stangely however, in bilby, the `Interferometer` class does not have `duration` and `sampling_frequency` arguments when the `InterferometerStrainData` and the `InterferometerList` classes do. Hence one needs to set those arguments for the list of `InterferometerStrainData` so that the `InterferometerList` inherits from them. The values will be inherited from the first one in the list...
# Why do `interferometers.duration` and `interferometers.sampling_frequency` need to be set ? => Because I use them when creating my waveform_generator in bilby_wavefor
......@@ -104,6 +103,7 @@ if __name__=='__main__':
start_time=start_time)
# WAVEFORM GENERATION
injection_parameters['meta']['maximum_frequency_of_generated_waveform'] = injection_parameters['meta']['maximum_frequency_injected_waveform']
template_ifos = bilby_wv.WaveForm_ThreeDetectors(injection_parameters, minimum_frequency, interferometers)
# INJECT TEMPLATE INTO NOISE STRAIN DATA
......@@ -136,7 +136,7 @@ if __name__=='__main__':
# Load the parameters describing the valid parameters for the basis.
params = injection_parameters['roq']['rescaled_params'].copy()
weights_file_path = outdir + '{:.0f}Hz_{:.0f}Hz_{:.0f}s_weights.json'.format(params['flow'], min(params['fhigh'], maximum_frequency), params['seglen'])
weights_file_path = outdir + '{:.0f}Hz_{:.0f}Hz_{:.0f}Hz_{:.0f}s_weights.json'.format(params['flow'], injection_parameters['meta']['maximum_frequency_of_analysis'], injection_parameters['meta']['maximum_frequency_injected_waveform'], params['seglen'])
# injection_parameters = dict(
# mass_1=36.0, mass_2=29.0, a_1=0.4, a_2=0.3, tilt_1=0.0, tilt_2=0.0,
......
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