diff --git a/bilby/gw/likelihood.py b/bilby/gw/likelihood.py index 2f3d7ab76e068bd9660840eec13f708af0326bbd..4bdccca9edfd1d3edd2258d0442a3a281fff1f19 100644 --- a/bilby/gw/likelihood.py +++ b/bilby/gw/likelihood.py @@ -925,9 +925,9 @@ class ROQGravitationalWaveTransient(GravitationalWaveTransient): """ - # Maximum delay time to geocentre plus 10% - earth_light_crossing_time = 1.1 * radius_of_earth / speed_of_light time_space = self._get_time_resolution() + # Maximum delay time to geocentre + 5 steps + earth_light_crossing_time = radius_of_earth / speed_of_light + 5 * time_space delta_times = np.arange( self.priors['geocent_time'].minimum - earth_light_crossing_time, self.priors['geocent_time'].maximum + earth_light_crossing_time, @@ -963,18 +963,29 @@ class ROQGravitationalWaveTransient(GravitationalWaveTransient): ifo.name, len(overlap_frequencies), min(overlap_frequencies), max(overlap_frequencies))) + logger.debug("Preallocate array") + tc_shifted_data = np.zeros(( + len(self.weights['time_samples']), len(overlap_frequencies)), + dtype=complex) + + logger.debug("Calculate shifted data") data = ifo.frequency_domain_strain[ifo.frequency_mask][ifo_idxs] - tc_shifted_data = data * np.exp( - 2j * np.pi * overlap_frequencies * time_samples[:, np.newaxis]) + prefactor = ( + data / + ifo.power_spectral_density_array[ifo.frequency_mask][ifo_idxs] + ) + for j in range(len(self.weights['time_samples'])): + tc_shifted_data[j] = prefactor * np.exp( + 2j * np.pi * overlap_frequencies * time_samples[j]) # to not kill all computers this minimises the memory usage of the # required inner products max_block_gigabytes = 4 max_elements = int((max_block_gigabytes * 2 ** 30) / 8) + logger.debug("Apply dot product") self.weights[ifo.name + '_linear'] = blockwise_dot_product( - tc_shifted_data / - ifo.power_spectral_density_array[ifo.frequency_mask][ifo_idxs], + tc_shifted_data, linear_matrix[roq_idxs], max_elements) * 4 / ifo.strain_data.duration diff --git a/bilby/gw/source.py b/bilby/gw/source.py index b5a3c556d8fc6719310336418d931e5c2708de2c..66ace0968729bdb78937943cb093447421d2c7f8 100644 --- a/bilby/gw/source.py +++ b/bilby/gw/source.py @@ -382,7 +382,7 @@ def _base_roq_waveform( frequency_nodes_quadratic = waveform_arguments['frequency_nodes_quadratic'] reference_frequency = waveform_arguments['reference_frequency'] approximant = lalsim_GetApproximantFromString( - waveform_arguments['approximant']) + waveform_arguments['waveform_approximant']) luminosity_distance = luminosity_distance * 1e6 * utils.parsec mass_1 = mass_1 * utils.solar_mass diff --git a/examples/injection_examples/roq_example.py b/examples/injection_examples/roq_example.py index cf6a28250da33ff4c973e26c91bcf7dbed82d0e0..947d85a523802655ebd508253ca6670b9de0b767 100644 --- a/examples/injection_examples/roq_example.py +++ b/examples/injection_examples/roq_example.py @@ -73,7 +73,7 @@ search_waveform_generator = bilby.gw.waveform_generator.WaveformGenerator( waveform_arguments=dict( frequency_nodes_linear=freq_nodes_linear, frequency_nodes_quadratic=freq_nodes_quadratic, - reference_frequency=20. * scale_factor, approximant='IMRPhenomPv2'), + reference_frequency=20. * scale_factor, waveform_approximant='IMRPhenomPv2'), parameter_conversion=bilby.gw.conversion.convert_to_lal_binary_black_hole_parameters) # Here we add constraints on chirp mass and mass ratio to the prior, these are