diff --git a/gw_eccentricity/eccDefinition.py b/gw_eccentricity/eccDefinition.py index 16d80d2d..2813c038 100644 --- a/gw_eccentricity/eccDefinition.py +++ b/gw_eccentricity/eccDefinition.py @@ -584,6 +584,22 @@ def process_data_dict(self, amp22_merger = newDataDict["amplm"][(2, 2)][merger_idx] phase22 = newDataDict["phaselm"][(2, 2)] phase22_merger = phase22[merger_idx] + # check if phase22 is increasing. phase22 at merger should be greater + # than the phase22 at the start of the waveform + if phase22_merger < phase22[0]: + raise Exception( + f"phase22 = {phase22_merger} at the merger is < " + f"phase22 = {phase22[0]} at the start. The " + "phaselm should be related to hlm as " + "hlm = amplm * exp(- i phaselm) ensuring that " + "the phaselm is monotonically increasing for m > 0 modes." + "This might be fixed by changing the overall sign of " + "phase in the input `dataDict`") + # check that omega22 is positive by checking its value at the merger + omega22_merger = newDataDict["omegalm"][(2, 2)][merger_idx] + if omega22_merger < 0: + raise Exception(f"omega22 at merger is {omega22_merger} < 0. " + "omega22 must be positive.") # Minimum width for peak finding function min_width_for_extrema = self.get_width_for_peak_finder_from_phase22( newDataDict["t"], diff --git a/test/test_dataDict.py b/test/test_dataDict.py index 132cd277..94a28334 100644 --- a/test/test_dataDict.py +++ b/test/test_dataDict.py @@ -130,9 +130,10 @@ def test_dataDict(): # To avoid exception for residual method since the data does # not contain zeroecc data continue + second_data_dict = copy.deepcopy(dataDict2) # use data_w_hlm as dataDict1 compare_eccentricity_measurement(dataDict1=dataDict1_w_hlm, - dataDict2=dataDict2, + dataDict2=second_data_dict, method=method) # Now we repeat the same as above but adding hlm_zeroecc to both the data # dict. @@ -162,13 +163,15 @@ def test_dataDict(): {"omegalm_zeroecc": omegalm_zeroecc}) # Loop over the different methods for method in available_methods: + second_data_dict = copy.deepcopy(dataDict2_w_hlm_zeroecc) compare_eccentricity_measurement( dataDict1=dataDict1_w_hlm_zeroecc, - dataDict2=dataDict2_w_hlm_zeroecc, + dataDict2=second_data_dict, method=method) + second_data_dict = copy.deepcopy(dataDict2_w_hlm_zeroecc_and_omegalm_zeroecc) compare_eccentricity_measurement( dataDict1=dataDict1_w_hlm_zeroecc, - dataDict2=dataDict2_w_hlm_zeroecc_and_omegalm_zeroecc, + dataDict2=second_data_dict, method=method) # This time instead of adding hlm_zeroecc, we add amplm_zeroecc and # phaselm_zeroecc to dataDict2, dataDict1 is the same as above. @@ -193,11 +196,13 @@ def test_dataDict(): {"omegalm_zeroecc": omegalm_zeroecc}) # Loop over the different methods for method in available_methods: + second_data_dict = copy.deepcopy(dataDict2_w_amplm_and_phaselm_zeroecc) compare_eccentricity_measurement( dataDict1=dataDict1_w_hlm_zeroecc, - dataDict2=dataDict2_w_amplm_and_phaselm_zeroecc, + dataDict2=second_data_dict, method=method) + second_data_dict = copy.deepcopy(dataDict2_w_amplm_and_phaselm_and_omegalm_zeroecc) compare_eccentricity_measurement( dataDict1=dataDict1_w_hlm_zeroecc, - dataDict2=dataDict2_w_amplm_and_phaselm_and_omegalm_zeroecc, + dataDict2=second_data_dict, method=method)