### Install pyseobnr from source Source: https://github.com/aei-acr/pyseobnr/blob/main/docs/source/installation.rst Standard procedure for cloning the repository and installing the package in a clean environment. ```console (.venv) $ git clone https://git.ligo.org/waveforms/software/pyseobnr.git (.venv) $ cd pyseobnr (.venv) $ pip install -U pip wheel setuptools numpy (.venv) $ pip install . ``` -------------------------------- ### Install pyseobnr from Source Source: https://github.com/aei-acr/pyseobnr/blob/main/README.rst Commands to install the package directly from a local source directory. ```bash pip install -U pip wheel setuptools pip install . ``` -------------------------------- ### Install documentation dependencies Source: https://github.com/aei-acr/pyseobnr/blob/main/docs/source/installation.rst Commands to install pandoc and documentation-specific Python packages. ```console (.conda_venv) $ conda install --yes --channel conda-forge pandoc ``` ```console (.venv) $ apt-get update && apt-get install -y pandoc ``` ```console (.venv) $ brew install pandoc ``` ```console (.venv) $ pip install ".[docs]" ``` ```console (.venv) $ cd docs (.venv) $ make html ``` -------------------------------- ### Install and configure pre-commit Source: https://github.com/aei-acr/pyseobnr/blob/main/docs/source/how_to_contribute.rst Commands to install the pre-commit package and initialize it within the project repository. ```console # install the pre-commit package pip install pre-commit cd pyseobnr pre-commit install ``` -------------------------------- ### Generate documentation locally Source: https://github.com/aei-acr/pyseobnr/blob/main/docs/source/how_to_contribute.rst Use this command to build the project documentation and automatically install necessary dependencies. ```console tox -e docs ``` -------------------------------- ### Create Conda Environment and Install Dependencies Source: https://github.com/aei-acr/pyseobnr/blob/main/README.rst Commands to initialize a new conda environment and install the required lalsuite dependency. ```bash conda create -n pyseobnr python=3.9 conda activate pyseobnr conda install -c conda-forge lalsuite ``` -------------------------------- ### Install pyseobnr via pip Source: https://github.com/aei-acr/pyseobnr/blob/main/README.rst Standard installation command for the released version of the package. ```bash pip install pyseobnr ``` -------------------------------- ### Install optional dependencies Source: https://github.com/aei-acr/pyseobnr/blob/main/docs/source/installation.rst Commands to install extra packages for running sanity checks or external waveform tools. ```console (.venv) $ pip install ".[checks]" ``` ```console (.venv) $ pip install git+https://bitbucket.org/sergei_ossokine/waveform_tools ``` -------------------------------- ### Install Optional Sanity Check Dependencies Source: https://github.com/aei-acr/pyseobnr/blob/main/README.rst Commands to install extra dependencies required for running sanity checks and the external waveform_tools library. ```bash pip install .[checks] ``` ```bash pip install git+https://bitbucket.org/sergei_ossokine/waveform_tools ``` -------------------------------- ### Force GSL library installation Source: https://github.com/aei-acr/pyseobnr/blob/main/docs/source/installation.rst Commands to force the installation of pygsl-lite linked to a specific system GSL path. ```console (.venv) $ GSL_HOME=/path/to/your/GSL/HOME pip install --force-reinstall pygsl-lite ``` ```console (.venv) $ GSL_HOME=$(brew --prefix gsl) pip install --force-reinstall pygsl-lite ``` ```console (.venv) $ pip install \ --use-pep517 \ --config-setting="--global-option=build_ext" \ --config-setting="--build-option=-I$(brew --prefix gsl)/include/" \ --config-setting="--build-option=-L$(brew --prefix gsl)/lib/" \ --force-reinstall \ --no-binary pygsl_lite \ --no-cache-dir \ pygsl_lite ``` -------------------------------- ### Manage Secular Backwards Integration Source: https://github.com/aei-acr/pyseobnr/blob/main/docs/source/notebooks/example_SEOBNRv5EHM.md Control the automatic secular backwards integration triggered when starting separation is less than 10M. ```python settings = dict( # Setting this to False will avoid the warning message # warning_secular_bwd_int=False, ) t, modes = generate_modes_opt( q, chi_1, chi_2, omega_start, eccentricity=0.5, rel_anomaly=0.0, approximant="SEOBNRv5EHM", settings=settings, ) ``` ```python plt.figure() plt.plot(t, np.abs(modes["2,2"])) plt.xlabel("Time (M)") plt.ylabel(r"$|h_{2}|$") plt.axvline(x=0, ls="--", color="k") plt.grid(True) ``` ```python try: settings = dict( secular_bwd_int=False, ) t, modes = generate_modes_opt( q, chi_1, chi_2, omega_start, eccentricity=0.5, rel_anomaly=0.0, approximant="SEOBNRv5EHM", settings=settings, ) except Exception as e: print(e) ``` ```python settings = dict( secular_bwd_int=True, r_start_min=7.0, ) t, modes = generate_modes_opt( q, chi_1, chi_2, omega_start, eccentricity=0.5, rel_anomaly=0.0, approximant="SEOBNRv5EHM", settings=settings, ) ``` -------------------------------- ### Initialize Environment and Imports Source: https://github.com/aei-acr/pyseobnr/blob/main/docs/source/notebooks/pseob_example.md Imports necessary libraries and suppresses LAL warnings. ```python import warnings from copy import deepcopy import numpy as np from matplotlib import pyplot as plt # silence warnings coming from LAL warnings.filterwarnings("ignore", "Wswiglal-redir-stdio") ``` -------------------------------- ### Importing pyseobnr and dependencies Source: https://github.com/aei-acr/pyseobnr/blob/main/docs/source/notebooks/getting_started.md Initializes the environment by silencing LAL warnings and importing necessary libraries for waveform generation and plotting. ```python import warnings # silence warnings coming from LAL warnings.filterwarnings("ignore", "Wswiglal-redir-stdio") import numpy as np from matplotlib import pyplot as plt # import the library from pyseobnr.generate_waveform import GenerateWaveform ``` -------------------------------- ### Defining physical parameters Source: https://github.com/aei-acr/pyseobnr/blob/main/docs/source/notebooks/example_precession.md Sets up mass ratio, component masses, spin vectors, and initial orbital frequency. ```python q = 2.0 m1 = q / (1.0 + q) m2 = 1 - m1 chi_1 = np.array([0.5, 0.0, 0.5]) chi_2 = np.array([0.5, 0.0, 0.5]) omega0 = 0.01 ``` -------------------------------- ### Configuring frequency-domain parameters Source: https://github.com/aei-acr/pyseobnr/blob/main/docs/source/notebooks/example_SEOBNRv5EHM.md Setting up the dictionary for frequency-domain waveform generation. ```python deltaF = 1.0 / 9 # Create dict for gwsignal generator gwsignal_dict = { "mass1": m1 * u.solMass, "mass2": m2 * u.solMass, "spin1x": s1x * u.dimensionless_unscaled, "spin1y": s1y * u.dimensionless_unscaled, "spin1z": s1z * u.dimensionless_unscaled, "spin2x": s2x * u.dimensionless_unscaled, "spin2y": s2y * u.dimensionless_unscaled, "spin2z": s2z * u.dimensionless_unscaled, #'deltaF' : delta_frequency * u.Hz, #'deltaT': deltaT*u.s, "deltaF": deltaF * u.Hz, "f22_start": f_min * u.Hz, "f_max": f_max * u.Hz, "f22_ref": f_ref * u.Hz, "phi_ref": phase * u.rad, "distance": luminosity_distance * u.Mpc, "inclination": iota * u.rad, "eccentricity": eccentricity * u.dimensionless_unscaled, "longAscNodes": longitude_ascending_nodes * u.rad, "meanPerAno": meanPerAno * u.rad, # 'ModeArray': mode_array, "condition": 1, "lmax": 4, "lmax_nyquist": 4, # Some additional specific SEOBNRv5EHM parameters "secular_bwd_int": True, "warning_bwd_int": False, "warning_secular_bwd_int": False, "t_backwards": 0, } waveform_approximant = "SEOBNRv5EHM" try: wf_gen = gwsignal_get_waveform_generator(waveform_approximant) except ValueError as e: if str(e) != "Approximant not implemented in GWSignal!": raise wf_gen = None print("SEOBNRv5EHM not supported by this version of lal") ``` -------------------------------- ### Configuring SEOBNRv5EHM parameters Source: https://github.com/aei-acr/pyseobnr/blob/main/docs/source/notebooks/example_SEOBNRv5EHM.md Setting up the dictionary of physical and extrinsic parameters for the waveform generator. ```python # start with the usual parameter definitions # Masses m1 = 30.0 m2 = 30.0 # spings s1x = 0.0 s1y = 0.0 s1z = 0.5 s2x = 0.0 s2y = 0.0 s2z = -0.2 # Extrinsic parameters deltaT = 1.0 / 4096.0 / 2.0 f_min = 10.0 f_ref = 10.0 luminosity_distance = 1000.0 iota = np.pi / 3.0 phase = 0.0 # Eccentric parameters eccentricity = 0.2 longitude_ascending_nodes = 0.0 meanPerAno = 0.5 # Conditioning condition = 1 deltaF = 1.0 / 8.0 # /20. # Create dict for gwsignal generator gwsignal_dict = { "mass1": m1 * u.solMass, "mass2": m2 * u.solMass, "spin1x": s1x * u.dimensionless_unscaled, "spin1y": s1y * u.dimensionless_unscaled, "spin1z": s1z * u.dimensionless_unscaled, "spin2x": s2x * u.dimensionless_unscaled, "spin2y": s2y * u.dimensionless_unscaled, "spin2z": s2z * u.dimensionless_unscaled, #'deltaF' : delta_frequency * u.Hz, "deltaT": deltaT * u.s, #'deltaF': deltaF*u.Hz, "f22_start": f_min * u.Hz, "f_max": f_max * u.Hz, "f22_ref": f_ref * u.Hz, "phi_ref": phase * u.rad, "distance": luminosity_distance * u.Mpc, "inclination": iota * u.rad, "eccentricity": eccentricity * u.dimensionless_unscaled, "longAscNodes": longitude_ascending_nodes * u.rad, "meanPerAno": meanPerAno * u.rad, # 'ModeArray': mode_array, "condition": 0, "lmax": 4, "lmax_nyquist": 4, # Some additional specific SEOBNRv5EHM parameters "secular_bwd_int": True, "warning_secular_bwd_int": False, "t_backwards": 0, "warning_bwd_int": False, } waveform_approximant = "SEOBNRv5EHM" try: wf_gen = gwsignal_get_waveform_generator(waveform_approximant) except ValueError as e: if str(e) != "Approximant not implemented in GWSignal!": raise wf_gen = None print("SEOBNRv5EHM not supported by this version of lal") ``` -------------------------------- ### Run development and test environments Source: https://github.com/aei-acr/pyseobnr/blob/main/docs/source/installation.rst Using tox to manage test environments and build documentation. ```console (.venv) $ pip install tox (.venv) $ tox -l # lists the environments (.venv) $ CI_TEST_DYNAMIC_REGRESSIONS=1 \ tox -e py311 # runs additional tests (.venv) $ tox -e py311 # runs the tests for python 3.11 (.venv) $ tox -e docs # builds the documentation ``` -------------------------------- ### Apply Alternative Phase and Time Conventions Source: https://github.com/aei-acr/pyseobnr/blob/main/docs/source/notebooks/getting_started.md Demonstrates generating waveforms using IMRPhenomT conventions for reference phase and time origin. ```python # Start with the usual parameter definitions # Masses in solar masses m1 = 50.0 m2 = 10.0 s1x, s1y, s1z = 0.0, 0.0, 0.5 s2x, s2y, s2z = 0.0, 0.0, 0.8 deltaT = 1.0 / 2048.0 f_min = 20.0 f_max = 1024.0 distance = 1000.0 # Mpc inclination = np.pi / 3.0 phiRef = 0.0 approximant = "SEOBNRv5HM" params_dict = { "mass1": m1, "mass2": m2, "spin1x": s1x, "spin1y": s1y, "spin1z": s1z, "spin2x": s2x, "spin2y": s2y, "spin2z": s2z, "deltaT": deltaT, "f22_start": f_min, "phi_ref": phiRef, "distance": distance, "inclination": inclination, "f_max": f_max, "approximant": approximant, } # We call the generator with the parameters wfm_gen = GenerateWaveform(params_dict) # We update with the new convention wfm_gen_2 = GenerateWaveform( params_dict | { "convention_coprecessing_phase22_set_to_0_at_reference_frequency": True, "convention_t0_set_to_0_at_coprecessing_amplitude22_peak": True, } ) # Generate mode dictionary times_0, hlms_0 = wfm_gen.generate_td_modes() times_1, hlms_1 = wfm_gen_2.generate_td_modes() plt.figure() plt.plot(times_0, hlms_0[(2, 2)].real, label="default pyseobnr convention") plt.plot(times_1, hlms_1[(2, 2)].real, label="IMRPhenomT convention", ls="dashed") plt.xlabel("Time (seconds)") plt.ylabel(r"$\Re[h_{22}]$") plt.legend() plt.xlim([-0.05, 0.01]) plt.grid(True) plt.tight_layout() ``` -------------------------------- ### Defining waveform parameters Source: https://github.com/aei-acr/pyseobnr/blob/main/docs/source/notebooks/getting_started.md Sets up the physical parameters for the binary system and the waveform generation configuration in a dictionary. ```python # Start with the usual parameter definitions # Masses in solar masses m1 = 50.0 m2 = 30.0 s1x, s1y, s1z = 0.0, 0.0, 0.5 s2x, s2y, s2z = 0.0, 0.0, 0.8 deltaT = 1.0 / 2048.0 f_min = 20.0 f_max = 1024.0 distance = 1000.0 # Mpc inclination = np.pi / 3.0 phiRef = 0.0 approximant = "SEOBNRv5HM" params_dict = { "mass1": m1, "mass2": m2, "spin1x": s1x, "spin1y": s1y, "spin1z": s1z, "spin2x": s2x, "spin2y": s2y, "spin2z": s2z, "deltaT": deltaT, "f22_start": f_min, "phi_ref": phiRef, "distance": distance, "inclination": inclination, "f_max": f_max, "approximant": approximant, } ``` -------------------------------- ### Import dependencies Source: https://github.com/aei-acr/pyseobnr/blob/main/docs/source/notebooks/pycbc_example.md Load necessary libraries for waveform generation and plotting. ```python import lal import matplotlib.pyplot as pp import numpy as np import pycbc import pycbc.waveform from pycbc.types import TimeSeries ``` -------------------------------- ### Define SEOBNRv5EHM parameters Source: https://github.com/aei-acr/pyseobnr/blob/main/docs/source/notebooks/example_SEOBNRv5EHM.md Set up the dictionary of physical parameters required to initialize the GenerateWaveform class. ```python # start with the usual parameter definitions m1 = 50.0 m2 = 30.0 s1x = 0.0 s1y = 0.0 s1z = 0.0 s2x = 0.0 s2y = 0.0 s2z = 0.0 eccentricity = 0.3 rel_anomaly = np.pi deltaT = 1.0 / 1024.0 f_min = 20.0 f_max = 512.0 distance = 1000.0 inclination = np.pi / 3.0 approximant = "SEOBNRv5EHM" params_dict = { "mass1": m1, "mass2": m2, "spin1x": s1x, "spin1y": s1y, "spin1z": s1z, "spin2x": s2x, "spin2y": s2y, "spin2z": s2z, "deltaT": deltaT, "f22_start": f_min, "distance": distance, "inclination": inclination, "f_max": f_max, "mode_array": [ (2, 2), (2, 1), (3, 2), (3, 3), (4, 3), (4, 4), ], # Specify which modes are to be returned "approximant": approximant, "eccentricity": eccentricity, "rel_anomaly": rel_anomaly, "EccIC": 1, # EccIC = 0 for instantaneous initial orbital frequency, and EccIC = 1 for orbit-averaged initial orbital frequency } ``` -------------------------------- ### Run linting with tox Source: https://github.com/aei-acr/pyseobnr/blob/main/docs/source/how_to_contribute.rst Execute the linting task defined in the tox configuration. ```console tox -e linting ``` -------------------------------- ### Importing gwsignal modules Source: https://github.com/aei-acr/pyseobnr/blob/main/docs/source/notebooks/example_SEOBNRv5EHM.md Initial imports required to access waveform generation tools. ```python import astropy.units as u from lalsimulation.gwsignal import ( GenerateFDWaveform, GenerateTDModes, GenerateTDWaveform, ) from lalsimulation.gwsignal.models import gwsignal_get_waveform_generator ``` -------------------------------- ### Initialize GenerateWaveform Source: https://github.com/aei-acr/pyseobnr/blob/main/docs/source/notebooks/example_SEOBNRv5EHM.md Instantiate the waveform generator with the defined parameter dictionary. ```python wfm_gen = GenerateWaveform(params_dict) # We call the generator with the parameters ``` -------------------------------- ### Importing dependencies Source: https://github.com/aei-acr/pyseobnr/blob/main/docs/source/notebooks/example_SEOBNRv5EHM.md Initial imports for plotting and numerical operations. ```python import matplotlib.pyplot as plt import numpy as np ``` -------------------------------- ### Import Waveform Generator Source: https://github.com/aei-acr/pyseobnr/blob/main/docs/source/notebooks/pseob_example.md Loads the GenerateWaveform class from the pyseobnr library. ```python # Import the library from pyseobnr.generate_waveform import GenerateWaveform ``` -------------------------------- ### Configuring the pyseobnr interface Source: https://github.com/aei-acr/pyseobnr/blob/main/docs/source/notebooks/example_SEOBNRv5EHM.md Imports for the waveform generator and suppression of LAL warnings. ```python import warnings warnings.filterwarnings("ignore", "Wswiglal-redir-stdio") # silence LAL warnings from pyseobnr.generate_waveform import GenerateWaveform, generate_modes_opt ``` -------------------------------- ### Run tests with tox Source: https://github.com/aei-acr/pyseobnr/blob/main/docs/source/how_to_contribute.rst Execute the test suite for the Python 3.11 environment using tox. ```console tox -e py311 ``` -------------------------------- ### Instantiate Waveform Generators Source: https://github.com/aei-acr/pyseobnr/blob/main/docs/source/notebooks/pseob_example.md Creates generator instances for both GR and non-GR configurations. ```python # We call the generator with the parameters wfm_gen = GenerateWaveform(params_GR) wfm_gen_dtau = GenerateWaveform(params_dtau) ``` -------------------------------- ### Import pyseobnr generator Source: https://github.com/aei-acr/pyseobnr/blob/main/docs/source/notebooks/pycbc_example.md Import the native pyseobnr waveform generator. ```python from pyseobnr.generate_waveform import GenerateWaveform ``` -------------------------------- ### Configuring warnings and importing model generator Source: https://github.com/aei-acr/pyseobnr/blob/main/docs/source/notebooks/example_precession.md Silences LAL warnings and imports the waveform generation function. ```python warnings.filterwarnings("ignore", "Wswiglal-redir-stdio") # silence LAL warnings from pyseobnr.generate_waveform import generate_modes_opt ``` -------------------------------- ### Importing necessary libraries Source: https://github.com/aei-acr/pyseobnr/blob/main/docs/source/notebooks/example_precession.md Standard imports for numerical operations and plotting. ```python import warnings import matplotlib.pyplot as plt import numpy as np ``` -------------------------------- ### Defining input parameters Source: https://github.com/aei-acr/pyseobnr/blob/main/docs/source/notebooks/example_SEOBNRv5EHM.md Setting physical parameters for the waveform generation in geometric units. ```python # Input parameters q = 5.3 chi_1 = 0.9 chi_2 = 0.3 omega_start = 0.0137 # This is the orbital frequency in geometric units with M=1 eccentricity = 0.4 rel_anomaly = 2.3 ``` -------------------------------- ### Configure waveform parameters Source: https://github.com/aei-acr/pyseobnr/blob/main/docs/source/notebooks/pycbc_example.md Define physical parameters and pyCBC-specific settings for the waveform. ```python m1 = 50.0 m2 = 30.0 distance = 1.0 inclination = np.pi / 3.0 phiRef = 0.0 s1x, s1y, s1z = 0.0, 0.0, 0.5 s2x, s2y, s2z = 0.0, 0.0, 0.1 dt = 1 / 2048.0 f_max = 1024.0 f_min = 0.0157 / ((m1 + m2) * np.pi * lal.MTSUN_SI) params_dict = { "mass1": m1, "mass2": m2, "spin1x": s1x, "spin1y": s1y, "spin1z": s1z, "spin2x": s2x, "spin2y": s2y, "spin2z": s2z, "delta_t": dt, # pyCBC parameter # pyCBC parameter: # if f_ref not specified, pyCBC will set it to "0" # and it will be as if it was not set and defaults to pyseobnr default "f_ref": 20, "f_lower": f_min, # pyCBC parameter "coa_phase": phiRef, # pyCBC parameter "distance": distance, "inclination": inclination, # pyCBC parameter: same as f_ref. Only used in get_fd_waveform # "f_final": f_max, "postadiabatic": False, # pyseobnr specific parameter } ``` -------------------------------- ### Plotting PN spin evolution Source: https://github.com/aei-acr/pyseobnr/blob/main/docs/source/notebooks/example_precession.md Visualizes the evolution of the first component spin. ```python plt.figure(figsize=(8, 6)) plt.plot(t_PN, chi1_PN, "-") plt.xlabel("Time (M)") plt.grid(True) ``` -------------------------------- ### Defining parameters for anti-symmetric mode test Source: https://github.com/aei-acr/pyseobnr/blob/main/docs/source/notebooks/example_precession.md Sets up specific spin parameters for testing anti-symmetric modes. ```python q = 2.0 m1 = q / (1.0 + q) m2 = 1 - m1 chi_1 = np.array([0.9, 0.0, 0.1]) chi_2 = np.array([-0.5, 0.0, 0.1]) omega0 = 0.01 ``` -------------------------------- ### Configure Parameter Dictionaries Source: https://github.com/aei-acr/pyseobnr/blob/main/docs/source/notebooks/pseob_example.md Constructs the GR parameter dictionary and creates a modified version including the non-GR deviation dictionary. ```python # Combine parameters in a dictionary params_GR = { "mass1": m1, "mass2": m2, "spin1x": s1x, "spin1y": s1y, "spin1z": s1z, "spin2x": s2x, "spin2y": s2y, "spin2z": s2z, "distance": distance, "inclination": inclination, "phi_ref": phiRef, "f22_start": f_min, "f_ref": f_min, "f_max": f_max, "deltaT": deltaT, "deltaF": deltaF, "approximant": approximant, "ModeArray": ModeArray, } # Add parametrized deviations to the parameter dictionary. # See the documentation of GenerateWaveform for all possible # options of non-GR deviation parameters. params_dtau = deepcopy(params_GR) params_dtau["dtau_dict"] = deviation_dict ``` -------------------------------- ### Generate waveform with pyseobnr Source: https://github.com/aei-acr/pyseobnr/blob/main/docs/source/notebooks/pycbc_example.md Generate the waveform using the native pyseobnr interface with adjusted parameters. ```python params_dict_pyseobnr = { "mass1": m1, "mass2": m2, "spin1x": s1x, "spin1y": s1y, "spin1z": s1z, "spin2x": s2x, "spin2y": s2y, "spin2z": s2z, "deltaT": dt, # different from pyCBC "f_ref": 20, "f22_start": f_min, # different from pyCBC "phi_ref": phiRef, # different from pyCBC "distance": distance, "inclination": inclination, "f_max": f_max, "postadiabatic": False, } hp_py, hc_py = GenerateWaveform(params_dict_pyseobnr).generate_td_polarizations() ``` -------------------------------- ### Access Model Dynamics Source: https://github.com/aei-acr/pyseobnr/blob/main/docs/source/expert_mode.rst Retrieve system dynamics from the model object, noting that values are internally rescaled and assume a total mass of 1. ```python t, r, phi, pr, pphi, H, Omega, _ = model.dynamics.T ``` -------------------------------- ### Generating models with and without anti-symmetric modes Source: https://github.com/aei-acr/pyseobnr/blob/main/docs/source/notebooks/example_precession.md Compares standard generation with generation using enabled anti-symmetric modes. ```python _, _, model = generate_modes_opt( q, chi_1, chi_2, omega0, debug=True, approximant="SEOBNRv5PHM", settings={"return_coprec": True}, ) _, _, model_antisym = generate_modes_opt( q, chi_1, chi_2, omega0, debug=True, approximant="SEOBNRv5PHM", settings=dict( return_coprec=True, enable_antisymmetric_modes=True, antisymmetric_modes=[(2, 2), (3, 3), (4, 4)], ), ) ``` -------------------------------- ### Generate and plot waveforms with gwsignal Source: https://github.com/aei-acr/pyseobnr/blob/main/docs/source/notebooks/example_SEOBNRv5EHM.md Generates a frequency-domain waveform using the provided gwsignal dictionary and generator, then plots the plus and cross polarizations. ```python if wf_gen is not None: hpc = GenerateFDWaveform(gwsignal_dict, wf_gen) freqs = np.arange(len(hpc.hp)) * gwsignal_dict["deltaF"] plt.plot(freqs, np.abs(hpc.hp), label=r"$h_p$") plt.plot(freqs, np.abs(hpc.hc), label=r"$h_x$") plt.xlabel("Frequency (Hz)") plt.ylabel(r"$h_{p,x}$") plt.legend() plt.xscale("log") plt.yscale("log") plt.grid(True) plt.show() else: print("Plot skipped") ``` -------------------------------- ### Generating waveform modes Source: https://github.com/aei-acr/pyseobnr/blob/main/docs/source/notebooks/example_SEOBNRv5EHM.md Executing the waveform generation for the SEOBNRv5EHM model. ```python t, modes = generate_modes_opt( q, chi_1, chi_2, omega_start, eccentricity=eccentricity, rel_anomaly=rel_anomaly, approximant="SEOBNRv5EHM", ) ``` -------------------------------- ### Generating time-domain modes Source: https://github.com/aei-acr/pyseobnr/blob/main/docs/source/notebooks/getting_started.md Instantiates the waveform generator with the parameter dictionary and computes the time-domain modes. ```python # We call the generator with the parameters wfm_gen = GenerateWaveform(params_dict) # Generate mode dictionary times, hlm = wfm_gen.generate_td_modes() ``` -------------------------------- ### Generate and plot time-domain polarizations Source: https://github.com/aei-acr/pyseobnr/blob/main/docs/source/notebooks/example_SEOBNRv5EHM.md Compute time-domain polarizations as LAL REAL8TimeSeries and plot them. ```python # Generate time-domain polarizations - As LAL REAL8TimeSeries hp, hc = wfm_gen.generate_td_polarizations() times = hp.deltaT * np.arange(hp.data.length) + hp.epoch plt.figure() plt.plot(times, hp.data.data, label=r"$h_+$") plt.plot(times, hc.data.data, label=r"$h_{\times}$") plt.xlabel("Time (seconds)") plt.legend() plt.grid(True) plt.show() ``` -------------------------------- ### Inspecting the model object Source: https://github.com/aei-acr/pyseobnr/blob/main/docs/source/notebooks/example_precession.md Displays the model object. ```python model ``` -------------------------------- ### Plotting all modes on a log scale Source: https://github.com/aei-acr/pyseobnr/blob/main/docs/source/notebooks/example_SEOBNRv5EHM.md Visualization of all generated modes on a logarithmic scale. ```python for mode in modes.keys(): plt.semilogy(t, np.abs(modes[mode]), label=mode) plt.xlabel("Time (M)") plt.ylabel(r"$\|h_{\ell m}|$") plt.xlim(-500, 150) plt.ylim(1e-5, 1) plt.legend(loc=3) plt.grid(True) ``` -------------------------------- ### Comparing inertial modes with anti-symmetric contribution Source: https://github.com/aei-acr/pyseobnr/blob/main/docs/source/notebooks/example_precession.md Visualizes the difference in the (2,2) mode when anti-symmetric modes are enabled. ```python plt.figure(figsize=(8, 6)) plt.plot(model.t, model.waveform_modes["2,2"].real, label="Inertial") plt.plot(model.t, model_antisym.waveform_modes["2,2"].real, label="Inertial - antisym") plt.plot( model.t, (model.waveform_modes["2,2"].real - model_antisym.waveform_modes["2,2"].real) / 2, label="Inertial - only antisym", ) plt.xlabel("Time (M)") plt.ylabel(r"$\Re[h_{21}]$") plt.grid(True, which="both") plt.legend(loc=2) plt.xlim(-200, 50) ``` -------------------------------- ### Filter Output Modes Source: https://github.com/aei-acr/pyseobnr/blob/main/docs/source/notebooks/example_SEOBNRv5EHM.md Configure the settings dictionary to return specific waveform modes by providing a list of tuples to the return_modes key. ```python settings = dict( # "EccIC" determines the prescription for the starting frequency. # EccIC=0 means that omega_start corresponds to the *instantaneous* angular frequency, and # EccIC=1 means that omega_start corresponds to the *orbit-averaged* angular frequency [default option] EccIC=1, # Specify which modes are to be returned, return_modes=[(2, 2), (2, 1)], ) # See the pyseobnr/generate_waveform.py file for a description of more settings t_new, modes_new = generate_modes_opt( q, chi_1, chi_2, omega_start, eccentricity=eccentricity, rel_anomaly=rel_anomaly, approximant="SEOBNRv5EHM", settings=settings, ) ``` ```python modes_new.keys() ``` ```python plt.figure() plt.plot(t_new, np.abs(modes_new["2,1"])) plt.xlabel("Time (M)") plt.ylabel(r"$|h_{21}|$") plt.axvline(x=0, ls="--", color="k") plt.xlim(-1000, 100) plt.grid(True) ``` -------------------------------- ### Generate time-domain modes and frequency-domain polarizations Source: https://github.com/aei-acr/pyseobnr/blob/main/docs/source/basic_usage.rst Uses the GenerateWaveform class to compute waveform modes and frequency-domain polarizations based on a parameter dictionary. ```python import numpy as np from pyseobnr.generate_waveform import GenerateWaveform # Start with the usual parameter definitions # Masses in solar masses m1 = 50.0 m2 = 30.0 s1x, s1y, s1z = 0.0, 0.0, 0.5 s2x, s2y, s2z = 0.0, 0.0, 0.8 deltaT = 1.0 / 2048.0 f_min = 20.0 f_max = 1024.0 distance = 1000.0 # Mpc inclination = np.pi / 3.0 phiRef = 0.0 approximant = "SEOBNRv5HM" params_dict = { "mass1": m1, "mass2": m2, "spin1x": s1x, "spin1y": s1y, "spin1z": s1z, "spin2x": s2x, "spin2y": s2y, "spin2z": s2z, "deltaT": deltaT, "f22_start": f_min, "phi_ref": phiRef, "distance": distance, "inclination": inclination, "f_max": f_max, "approximant": approximant, } # We call the generator with the parameters wfm_gen = GenerateWaveform(params_dict) # Generate mode dictionary times, hlm = wfm_gen.generate_td_modes() ``` ```python # Generate Fourier-domain polarizations - As LAL COMPLEX16FrequencySeries hpf, hcf = wfm_gen.generate_fd_polarizations() freqs = hpf.deltaF*np.arange(hpf.data.length) ``` -------------------------------- ### Generate and plot Fourier-domain polarizations Source: https://github.com/aei-acr/pyseobnr/blob/main/docs/source/notebooks/example_SEOBNRv5EHM.md Compute Fourier-domain polarizations as LAL COMPLEX16FrequencySeries and plot them. ```python # Generate Fourier-domain polarizations - As LAL COMPLEX16FrequencySeries hpf, hcf = wfm_gen.generate_fd_polarizations() freqs = hpf.deltaF * np.arange(hpf.data.length) plt.figure() plt.plot(freqs, np.abs(hpf.data.data), label=r"$\tilde{h}_+$") plt.plot(freqs, np.abs(hcf.data.data), label=r"$\tilde{h}_{\times}$") plt.xlabel("f (Hz)") plt.legend() plt.xscale("log") plt.yscale("log") plt.grid(True) plt.show() ``` -------------------------------- ### Extracting PN dynamics Source: https://github.com/aei-acr/pyseobnr/blob/main/docs/source/notebooks/example_precession.md Retrieves PN precession dynamics and orbital frequency, normalizing spins by mass squared. ```python t_PN = model.pn_dynamics[:, 0] LNhat_PN = model.pn_dynamics[:, 1:4] chi1_PN = model.pn_dynamics[:, 4:7] / m1**2 # Mind the normalization! chi2_PN = model.pn_dynamics[:, 7:10] / m2**2 # Mind the normalization! omega_PN = model.pn_dynamics[:, 10] ``` -------------------------------- ### Define Waveform Parameters and Deviations Source: https://github.com/aei-acr/pyseobnr/blob/main/docs/source/notebooks/pseob_example.md Sets physical parameters for the binary system and defines fractional deviations for specific modes. ```python # Start with the usual parameter definitions # Masses in solar masses m1 = 50.0 m2 = 30.0 s1x, s1y, s1z = 0.0, 0.0, 0.5 s2x, s2y, s2z = 0.0, 0.0, 0.8 deltaT = 1.0 / 4096.0 deltaF = 1.0 / 16 f_min = 20.0 f_max = 2048.0 distance = 1000.0 # Mpc inclination = np.pi / 3.0 phiRef = 0.0 approximant = "SEOBNRv5PHM" ModeArray = [(2, 2), (3, 3)] dev = 0.3 # Fractional deviations for each mode deviation_dict = { "2,2": dev, "2,1": 0.0, "3,3": dev, "3,2": 0.0, "4,4": 0.0, "4,3": 0.0, "5,5": 0.0, } ``` -------------------------------- ### Check approximant availability Source: https://github.com/aei-acr/pyseobnr/blob/main/docs/source/notebooks/pycbc_example.md Verify if specific approximants are available in pyCBC. ```python "SEOBNRv5HM" in pycbc.waveform.td_approximants() ``` ```python "SEOBNRv5HM" in pycbc.waveform.fd_approximants() ``` ```python "SEOBNRv5PHM" in pycbc.waveform.td_approximants() ``` ```python "SEOBNRv5PHM" in pycbc.waveform.fd_approximants() ``` -------------------------------- ### Invoke Expert Mode Source: https://github.com/aei-acr/pyseobnr/blob/main/docs/source/expert_mode.rst Enable expert mode by setting debug=True in the generate_modes_opt function to return the model object. ```python >>> from pyseobnr.generate_waveform import generate_modes_opt >>> q = 5.3 >>> chi_1 = 0.9 >>> chi_2 = 0.3 >>> omega0 = 0.0137 # This is the orbital frequency in geometric units with M=1 >>> _, _, model = generate_modes_opt(q, chi_1, chi_2, omega0, debug=True) >>> model ``` -------------------------------- ### Inspecting generated modes Source: https://github.com/aei-acr/pyseobnr/blob/main/docs/source/notebooks/example_SEOBNRv5EHM.md Retrieving the keys of the generated modes dictionary. ```python modes.keys() ``` -------------------------------- ### Generate Fourier-Domain Polarizations Source: https://github.com/aei-acr/pyseobnr/blob/main/docs/source/notebooks/pseob_example.md Computes the Fourier-domain polarizations and frequency array. ```python # Generate Fourier-domain polarizations hp, hc = wfm_gen.generate_fd_polarizations() hp_dtau, hc_dtau = wfm_gen_dtau.generate_fd_polarizations() freqs = hp.deltaF * np.arange(hp.data.length) ``` -------------------------------- ### Generate Waveform Modes in Expert Mode Source: https://github.com/aei-acr/pyseobnr/blob/main/docs/source/notebooks/getting_started.md Uses generate_modes_opt to compute waveform modes with specific mass ratio, spins, and orbital frequency. ```python from pyseobnr.generate_waveform import generate_modes_opt q = 5.3 chi_1 = 0.9 chi_2 = 0.3 omega0 = 0.0137 # This is the orbital frequency in geometric units with M=1 _, _, model = generate_modes_opt(q, chi_1, chi_2, omega0, debug=True) model ``` -------------------------------- ### Plot time-domain waveform Source: https://github.com/aei-acr/pyseobnr/blob/main/docs/source/notebooks/pycbc_example.md Visualize the generated time-domain waveform. ```python pp.plot(hp.sample_times, hp) pp.xlabel("Time (s)"); ``` -------------------------------- ### Plot pyseobnr waveform Source: https://github.com/aei-acr/pyseobnr/blob/main/docs/source/notebooks/pycbc_example.md Visualize the waveform generated via the pyseobnr interface. ```python t = hp_py.deltaT * np.arange(hp_py.data.length) + hp_py.epoch pp.plot(t, hp_py.data.data[:]) pp.xlabel("Time (s)"); ``` -------------------------------- ### Generating and plotting time-domain waveforms Source: https://github.com/aei-acr/pyseobnr/blob/main/docs/source/notebooks/example_SEOBNRv5EHM.md Generating the time-domain waveform and plotting the plus and cross polarizations. ```python if wf_gen is not None: hpc = GenerateTDWaveform(gwsignal_dict, wf_gen) time = np.arange(len(hpc.hp)) * gwsignal_dict["deltaT"] plt.plot(time, hpc.hp, label=r"$h_p$") plt.plot(time, hpc.hc, label=r"$h_x$") plt.xlabel("Time (seconds)") plt.ylabel(r"$h_{x,p}$") plt.show() else: print("Plot skipped") ``` -------------------------------- ### Generate time-domain waveform Source: https://github.com/aei-acr/pyseobnr/blob/main/docs/source/notebooks/pycbc_example.md Generate the waveform using the pyCBC interface. ```python # Let's plot what our new waveform looks like hp, hc = pycbc.waveform.get_td_waveform(approximant="SEOBNRv5HM", **params_dict) ``` -------------------------------- ### Plot frequency-domain waveform Source: https://github.com/aei-acr/pyseobnr/blob/main/docs/source/notebooks/pycbc_example.md Convert to frequency domain and plot the real part. ```python hf = hp.to_frequencyseries() pp.plot(hf.sample_frequencies, hf.real()) pp.xlabel("Frequency (Hz)") pp.xscale("log") pp.xlim(20, 100); ``` -------------------------------- ### Generate and plot time-domain modes Source: https://github.com/aei-acr/pyseobnr/blob/main/docs/source/notebooks/example_SEOBNRv5EHM.md Compute time-domain modes and visualize specific components using matplotlib. ```python # Generate mode dictionary times, hlm = wfm_gen.generate_td_modes() plt.figure() plt.plot(times, hlm[(2, 2)].real) plt.xlabel("Time (seconds)") plt.ylabel(r"$\Re[h_{22}]$") plt.grid(True) plt.show() plt.figure() plt.plot(times, hlm[(3, 3)].imag) plt.xlabel("Time (seconds)") plt.ylabel(r"$\Im[h_{33}]$") plt.grid(True) plt.show() ``` -------------------------------- ### Generating and plotting time-domain modes Source: https://github.com/aei-acr/pyseobnr/blob/main/docs/source/notebooks/example_SEOBNRv5EHM.md Generating TD modes and plotting the real part of specific (l, m) modes. ```python if wf_gen is not None: # Generate TD modes hlm = GenerateTDModes(gwsignal_dict, wf_gen) l, m = 2, -1 plt.plot(time, np.real(hlm[(l, m)]), label=f"({l,m})") plt.plot(time, np.real(hlm[(l, -m)]), ls="--", label=f"({l,-m})") plt.xlabel("Time (seconds)") plt.ylabel(r"$\Re[h_{22}]$") plt.legend() plt.show() else: print("Plot skipped") ``` -------------------------------- ### Generate SEOBNRv5EHM Waveform Modes Source: https://github.com/aei-acr/pyseobnr/blob/main/docs/source/notebooks/example_SEOBNRv5EHM.md Generates waveform modes using the SEOBNRv5EHM approximant with debug mode enabled to return the model object. ```python t, modes, model = generate_modes_opt( q, chi_1, chi_2, omega_start, eccentricity=eccentricity, rel_anomaly=rel_anomaly, approximant="SEOBNRv5EHM", debug=True, ) ``` -------------------------------- ### Comparing inertial and co-precessing modes Source: https://github.com/aei-acr/pyseobnr/blob/main/docs/source/notebooks/example_precession.md Plots the (2,1) mode in both inertial and co-precessing frames. ```python plt.figure(figsize=(8, 6)) plt.plot(model.t, model.waveform_modes["2,1"].real, label="Inertial") plt.plot(model.t, model.coprecessing_modes["2,1"].real, ls="-", label="Coprecessing") plt.xlabel("Time (M)") plt.ylabel(r"$\Re[h_{21}]$") plt.grid(True, which="both") plt.legend(loc=2) ``` -------------------------------- ### Extracting dynamical quantities Source: https://github.com/aei-acr/pyseobnr/blob/main/docs/source/notebooks/example_precession.md Accesses time and radial distance from the model dynamics. ```python t_dyn = model.dynamics[:, 0] r_dyn = model.dynamics[:, 1] ``` -------------------------------- ### Plot Fourier-Domain Waveforms Source: https://github.com/aei-acr/pyseobnr/blob/main/docs/source/notebooks/pseob_example.md Visualizes the absolute value of the plus polarization in the frequency domain. ```python plt.plot(freqs, np.abs(hp.data.data), label="GR") plt.plot( freqs, np.abs(hp_dtau.data.data), label=r"$\delta \tau_{22} = \delta \tau_{33} = " + f"{dev}$$", ) plt.xlabel("$f [Hz]$") plt.ylabel(r"$\tilde{h}_+$") plt.xscale("log") plt.yscale("log") plt.xlim(1.0) plt.grid() plt.legend(); ``` -------------------------------- ### Generate Time-Domain Modes Source: https://github.com/aei-acr/pyseobnr/blob/main/docs/source/notebooks/pseob_example.md Computes the time-domain modes for both GR and non-GR scenarios. ```python # Generate time-domain modes dictionary times, hlm = wfm_gen.generate_td_modes() times_dtau, hlm_dtau = wfm_gen_dtau.generate_td_modes() ``` -------------------------------- ### Perform Backwards Evolution Source: https://github.com/aei-acr/pyseobnr/blob/main/docs/source/notebooks/example_SEOBNRv5EHM.md Evolve the system backwards in time by specifying t_backwards in the settings dictionary. ```python t, modes = generate_modes_opt( q, chi_1, chi_2, omega_start, eccentricity=eccentricity, rel_anomaly=rel_anomaly, approximant="SEOBNRv5EHM", ) settings = dict( t_backwards=1000, # Geometric units # warning_bwd_int=False, # Setting this to False will avoid the warning message ) t_back, modes_back = generate_modes_opt( q, chi_1, chi_2, omega_start, eccentricity=eccentricity, rel_anomaly=rel_anomaly, approximant="SEOBNRv5EHM", settings=settings, ) ``` ```python plt.figure() plt.plot(t, np.abs(modes["2,2"]), label="Original system") plt.plot(t_back, np.abs(modes_back["2,2"]), "--", label="Backwards integration") plt.xlabel("Time (M)") plt.ylabel(r"$|h_{2}|$") plt.axvline(x=0, ls="--", color="k") plt.legend() plt.grid(True) ``` -------------------------------- ### Plotting radial dynamics Source: https://github.com/aei-acr/pyseobnr/blob/main/docs/source/notebooks/example_precession.md Visualizes the evolution of the radial distance over time. ```python plt.figure(figsize=(8, 6)) plt.plot(t_dyn, r_dyn) plt.xlabel("Time (M)") plt.ylabel(r"$r$ (M)") plt.grid(True) ``` -------------------------------- ### Generate modes using the internal EOB interface Source: https://github.com/aei-acr/pyseobnr/blob/main/docs/source/basic_usage.rst Computes waveforms in geometric units using the internal EOB generator, which outputs modes for m>0 in aligned-spin cases. ```python >>> from pyseobnr.generate_waveform import generate_modes_opt >>> q = 5.3 >>> chi_1 = 0.9 >>> chi_2 = 0.3 >>> omega0 = 0.0137 # This is the orbital frequency in geometric units with M=1 >>> t,modes = generate_modes_opt(q,chi_1,chi_2,omega0) >>> modes.keys() dict_keys(['2,2', '2,1', '3,3', '3,2', '4,4', '4,3', '5,5']) ``` -------------------------------- ### Access generator parameters Source: https://github.com/aei-acr/pyseobnr/blob/main/docs/source/notebooks/example_SEOBNRv5EHM.md Retrieve the parameters currently set in the generator instance. ```python wfm_gen.parameters # Access the parameters ```