Skip to content

Create GWTemplate plugin - #216

Open
OMarkwell wants to merge 2 commits into
sxs-collaboration:mainfrom
OMarkwell:main
Open

OMarkwell wants to merge 2 commits into
sxs-collaboration:mainfrom
OMarkwell:main

Conversation

@OMarkwell

@OMarkwell OMarkwell commented Oct 13, 2026 •

Copy link
Copy Markdown

GWTemplate is the DDPC waveform generator for LISA. It functions through plugins built into the waveform models, which can then be called by the waveform generator to get the waveforms. I have added such a plugin to sxs, to allow sxs waveforms to easily be used for LISA science. Additionally, I moved some of the FFT-related routines to the time-series class. This is just to avoid having to Fourier transform all the modes when computing the frequency-domain polarizations in a particular direction.


📚 Documentation preview 📚: https://sxs--216.org.readthedocs.build/en/216/

@codecov-commenter

codecov-commenter commented Oct 13, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 5.26316% with 36 lines in your changes missing coverage. Please review.
✅ Project coverage is 44.74%. Comparing base (c39aa9a) to head (6d1bfdf).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
sxs/time_series.py 5.26% 36 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #216      +/-   ##
==========================================
- Coverage   44.91%   44.74%   -0.18%     
==========================================
  Files          87       87              
  Lines        6773     6810      +37     
  Branches     1099     1103       +4     
==========================================
+ Hits         3042     3047       +5     
- Misses       3458     3490      +32     
  Partials      273      273              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@moble moble left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In addition to the individual comments:

  • Tests needed, at least to make sure the output is sensible
  • sxs/plugins/ needs an __init__.py.

I now realize there are several places that seem to assume astropy(?) input types. We need to make sure that those inputs really have the expected types. (I think we're supposed to use .to_value(unit) instead of just .value?) In particular, that assumption shouldn't make it into the sxs code; it should just be in the plugin code, since sxs doesn't know about astropy, etc.

Comment thread sxs/time_series.py
return type(self)(data, **self._metadata.copy()) No newline at end of file
return type(self)(data, **self._metadata.copy())

def preprocess(self, t1=0, t2=500, t3=None, t4=None, dt=None, **kwargs):

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few things:

First, we need to figure out a better way to do this to minimize code duplication. There are several ways this might work. One possibility would be to just move the function here, and guard the two changes with a test for the type of self — possibly making the WaveformModes version call this one with different arguments. The other would be to extract a lot of the code into a helper function somewhere else, and just make the two preprocess methods call that code with their own specializations.

Second, it's not clear to me that other people will want our preprocessing step at all; it's rather specific to how I want to do preprocessing, including the specific parameters for the transition window(s) and the line-subtraction step to remove memory discontinuities.

Third, note that the defaults include t1=0, t2=500. When this is applied to data that's gone through to_lvk, I think the t=0 point moves to the peak of the waveform, so this zeros out everything before the peak, and is still modifying the data far into the ringdown.

##Fourier transform
h = WaveformModes(time = t,
input_array = h_array,
modes_axis = 1,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should usually be 0. I think you don't need this argument at all.

Comment thread sxs/time_series.py
Comment on lines +1093 to +1094
return result
def fourier_transform(self, total_mass=None, luminosity_distance=None):

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs a space:

Suggested change
return result
def fourier_transform(self, total_mass=None, luminosity_distance=None):
return result
def fourier_transform(self, total_mass=None, luminosity_distance=None):

Comment thread sxs/time_series.py
h_tilde : TimeSeries
Unitful Fourier transform.
"""
from . import m_sun_in_meters, m_sun_in_seconds, parsec_in_meters

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be worth nitpicking about LISA's conventions compared to mine:

sxs/sxs/__init__.py

Lines 49 to 61 in b7d25d5

# The value of the solar mass parameter G*M_sun is known to higher accuracy than either of its
# factors. The value here is taken from the IAU Division I Working Group's publication on
# "Numerical Standards for Fundamental Astronomy"
# <https://iau-a3.gitlab.io/NSFA/NSFA_cbe.html#GMS2012>.
# In the TDB (Barycentric Dynamical Time) time scale — which seems to be the more relevant one and
# looks like the more standard one for LIGO — we have
solar_mass_parameter = 1.32712440041e20 # m^3/s^2
# Dividing by the speed of light squared, we get the mass of the sun in meters; dividing again, we
# get the mass of the sun in seconds. For consistency with the nominal value above, we retain more
# precision than is warranted by the measurement.
m_sun_in_meters = 1476.6250385063112526099633973363 # m
m_sun_in_seconds = 4.925490949162941425997992909269e-06 # s

Comment thread sxs/time_series.py
result = result.pad(pad_length, mode=pad_mode, **kwargs)
result = result.line_subtraction(treat_as_zero=treat_as_zero)
return result
def fourier_transform(self, total_mass=None, luminosity_distance=None):

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will mutate the data in place. Elsewhere, this is fine because where it's called from is right behind an evaluate call. But here, it could bite people.

Comment thread sxs/time_series.py
Comment on lines +1130 to +1131
h_unitful *= h_factor.value
h_unitful.t *= t_factor.value

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What are these .values for?

Comment thread sxs/time_series.py
if luminosity_distance is not None:
h_factor /= (luminosity_distance * 1e6 * parsec_in_meters)
h_unitful = self
if total_mass is not None and luminosity_distance is not None:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So no scaling will happen unless both total_mass and luminosity_distance are given?

from gwtemplate.mass_time import MassTime
from gwtemplate import constants
import astropy.units as u
from astropy.constants import G, c ,M_sun

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See my comment about m_sun_in_meters below.

Comment on lines +82 to +83
t_scaling = (self.params['total_mass'] / u.solMass * MTSUN_SI)
h_scaling = G * (self.params['total_mass']).to('kg') / (c**2 * self.params['distance'].to('m'))

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Increasing my concern about units...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants