diff --git a/gw_eccentricity/eccDefinition.py b/gw_eccentricity/eccDefinition.py index de8884d..fa8a25a 100644 --- a/gw_eccentricity/eccDefinition.py +++ b/gw_eccentricity/eccDefinition.py @@ -8,7 +8,6 @@ import numpy as np import matplotlib.pyplot as plt -import warnings from .load_data import get_coprecessing_data_dict from .utils import peak_time_via_quadratic_fit, check_kwargs_and_set_defaults from .utils import amplitude_using_all_modes @@ -25,8 +24,7 @@ class eccDefinition: """Base class to define eccentricity for given waveform data dictionary.""" def __init__(self, dataDict, num_orbits_to_exclude_before_merger=2, - precessing=False, - frame="inertial", + precessing=False, frame="inertial", debug_level=0, extra_kwargs=None): """Init eccDefinition class. @@ -196,6 +194,14 @@ def __init__(self, dataDict, num_orbits_to_exclude_before_merger=2, Default value is "inertial". + debug_level: int + Debug settings for warnings/errors: + -1: All warnings are suppressed. NOTE: Use at your own risk! + 0: Only important warnings are issued. + 1: All warnings are issued. Use when investigating. + 2: All warnings become exceptions. + Default: 0. + extra_kwargs: dict A dictionary of any extra kwargs to be passed. Allowed kwargs are: @@ -227,14 +233,6 @@ def __init__(self, dataDict, num_orbits_to_exclude_before_merger=2, eccDefinition.get_width_for_peak_finder_from_phase_gw for more details. - debug_level: int - Debug settings for warnings/errors: - -1: All warnings are suppressed. NOTE: Use at your own risk! - 0: Only important warnings are issued. - 1: All warnings are issued. Use when investigating. - 2: All warnings become exceptions. - Default: 0. - debug_plots: bool If True, diagnostic plots are generated. This can be computationally expensive and should only be used when @@ -308,6 +306,7 @@ def __init__(self, dataDict, num_orbits_to_exclude_before_merger=2, """ self.precessing = precessing self.frame = frame + self.debug_level = debug_level # check if frame makes sense. available_frames = ["inertial", "coprecessing"] if self.frame not in available_frames: @@ -352,7 +351,6 @@ def __init__(self, dataDict, num_orbits_to_exclude_before_merger=2, "utils.get_default_spline_kwargs()") self.available_averaging_methods \ = self.get_available_omega_gw_averaging_methods() - self.debug_level = self.extra_kwargs["debug_level"] self.debug_plots = self.extra_kwargs["debug_plots"] self.return_zero_if_small_ecc_failure = self.extra_kwargs["return_zero_if_small_ecc_failure"] # check if there are unrecognized keys in the dataDict @@ -623,11 +621,12 @@ def process_data_dict(self, # frame, rotate the modes and obtain the corresponding modes in the # coprecessing frame if self.precessing is True and self.frame == "inertial": - warnings.warn( + debug_message( f"The system is precessing but the modes are provided in " f"the {self.frame} frame. Transforming the modes from" f" the {self.frame} frame to the coprecessing frame and " - "updating `self.frame` to `coprecessing`.") + "updating `self.frame` to `coprecessing`.", + debug_level=self.debug_level, important=False) dataDict = self.transform_inertial_to_coprecessing(dataDict) # transform the zeroecc modes as well if provided in dataDict if "hlm_zeroecc" in dataDict or "amplm_zeroecc" in dataDict: @@ -755,20 +754,22 @@ def transform_inertial_to_coprecessing(self, data_dict, tag=""): hlm_dict = self.get_hlm_from_amplm_phaselm(amplm_dict, phaselm_dict) data_dict.update(hlm_dict) data_dict = get_coprecessing_data_dict(data_dict, tag=tag) - warnings.warn( + debug_message( f"Removing the input inertial frame {'amplm' + tag}, " f"{'phaselm' + tag} from `dataDict`. The corresponding " "coprecessing frame quantities are computed " f"later from the coprecessing {'hlm' + tag} in " - f"`get_amp_phase_omega_data`.") + f"`get_amp_phase_omega_data`.", debug_level=self.debug_level, + important=False) data_dict.pop("amplm" + tag, None) data_dict.pop("phaselm" + tag, None) if "omegalm" + tag in data_dict: - warnings.warn( + debug_message( f"Removing the input inertial frame {'omegalm' + tag} " f"from `dataDict`. The coprecessing {'omegalm' + tag} is " f"computed later from the coprecessing {'hlm' + tag} in " - f"`get_amp_phase_omega_data`.") + f"`get_amp_phase_omega_data`.", debug_level=self.debug_level, + important=False) data_dict.pop("omegalm" + tag, None) return data_dict @@ -987,7 +988,6 @@ def get_default_extra_kwargs(self): "spline_kwargs": {}, "extrema_finding_kwargs": {}, # Gets overridden in methods like # eccDefinitionUsingAmplitude - "debug_level": 0, "debug_plots": False, "omega_gw_averaging_method": "orbit_averaged_omega_gw", "treat_mid_points_between_pericenters_as_apocenters": False, diff --git a/gw_eccentricity/gw_eccentricity.py b/gw_eccentricity/gw_eccentricity.py index caaab31..fa5452b 100644 --- a/gw_eccentricity/gw_eccentricity.py +++ b/gw_eccentricity/gw_eccentricity.py @@ -65,6 +65,7 @@ def measure_eccentricity(tref_in=None, num_orbits_to_exclude_before_merger=2, precessing=False, frame="inertial", + debug_level=0, extra_kwargs=None): """Measure eccentricity and mean anomaly from a gravitational waveform. @@ -337,6 +338,14 @@ def measure_eccentricity(tref_in=None, Default value is "inertial". + debug_level: int + Debug settings for warnings/errors: + -1: All warnings are suppressed. NOTE: Use at your own risk! + 0: Only important warnings are issued. + 1: All warnings are issued. Use when investigating. + 2: All warnings become exceptions. + Default: 0. + extra_kwargs: A dict of any extra kwargs to be passed. Allowed kwargs are: spline_kwargs: Dictionary of arguments to be passed to the spline interpolation @@ -365,14 +374,6 @@ def measure_eccentricity(tref_in=None, eccDefinition.get_width_for_peak_finder_from_phase_gw for more details. - debug_level: int - Debug settings for warnings/errors: - -1: All warnings are suppressed. NOTE: Use at your own risk! - 0: Only important warnings are issued. - 1: All warnings are issued. Use when investigating. - 2: All warnings become exceptions. - Default: 0. - debug_plots: bool If True, diagnostic plots are generated. This can be computationally expensive and should only be used when @@ -500,7 +501,7 @@ def measure_eccentricity(tref_in=None, if method in available_methods: gwecc_object = available_methods[method]( dataDict, num_orbits_to_exclude_before_merger, - precessing, frame, extra_kwargs) + precessing, frame, debug_level, extra_kwargs) return_dict = gwecc_object.measure_ecc( tref_in=tref_in, fref_in=fref_in) return_dict.update({"gwecc_object": gwecc_object})