LEGWORK modules and API reference

LEGWORK is composed of 7 different modules, each with a different focus. The diagram below illustrates how each module is connected to the others as well as listing the general purpose of each module. In particular, note that the source module provides a simple interface to the functions in all other modules!

Package structure graph

The rest of this page contains the API reference for each individual function in every module, feel free to use the table of contents on the left to easily navigate to the function you need.

legwork.evol Module

Functions using equations from Peters and Mathews (1964) to calculate inspiral times and evolve binary parameters.


de_dt(e, times, beta, c_0)

Compute eccentricity time derivative


Wrapper that integrates legwork.evol.de_dt() with odeint

evol_circ([t_evol, n_step, timesteps, beta, ...])

Evolve an array of circular binaries for t_evol time

evol_ecc(ecc_i[, t_evol, n_step, timesteps, ...])

Evolve an array of eccentric binaries for t_evol time

get_t_merge_circ([beta, m_1, m_2, a_i, f_orb_i])

Computes the merger time for circular binaries

get_t_merge_ecc(ecc_i[, a_i, f_orb_i, beta, ...])

Computes the merger time for binaries


A fit to the Peters 1964 merger time equation (5.14) by Ilya Mandel.

evolve_f_orb_circ(f_orb_i, m_c, t_evol[, ...])

Evolve orbital frequency for t_evol time.

check_mass_freq_input([beta, m_1, m_2, a_i, ...])

Check that mass and frequency input is valid

create_timesteps_array(a_i, beta[, ecc_i, ...])

Create an array of timesteps

determine_stationarity(f_orb_i, t_evol, ecc_i)

Determine whether a binary is stationary


Feeling a bit spun around by all this binary evolution? Check out our tutorial on using functions in the evol module here!

legwork.psd Module

Functions to compute various power spectral densities for sensitivity curves


load_response_function(f[, fstar])

Load in LISA response function from file

approximate_response_function(f, fstar)

Approximate LISA response function

power_spectral_density(f[, instrument, ...])

Calculates the effective power spectral density for all instruments.

lisa_psd(f[, t_obs, L, approximate_R, ...])

Calculates the effective LISA power spectral density sensitivity curve

tianqin_psd(f[, L, t_obs, approximate_R, ...])

Calculates the effective TianQin power spectral density sensitivity curve

legwork.snr Module

Functions to calculate signal-to-noise ratio in four different cases


snr_circ_stationary(m_c, f_orb, dist, t_obs)

Computes SNR for circular and stationary sources

snr_ecc_stationary(m_c, f_orb, ecc, dist, ...)

Computes SNR for eccentric and stationary sources

snr_circ_evolving(m_1, m_2, f_orb_i, dist, ...)

Computes SNR for circular and stationary sources

snr_ecc_evolving(m_1, m_2, f_orb_i, dist, ...)

Computes SNR for eccentric and evolving sources.

legwork.source Module

A collection of classes for analysing gravitational wave sources


Source(m_1, m_2, ecc, dist[, n_proc, f_orb, ...])

Class for generic GW sources

Stationary(m_1, m_2, ecc, dist[, n_proc, ...])

Subclass for sources that are stationary

Evolving(m_1, m_2, ecc, dist[, n_proc, ...])

Subclass for sources that are evolving


Generate a Source class with the LISA verification binaries preloaded.

Class Inheritance Diagram

Inheritance diagram of legwork.source.Source, legwork.source.Stationary, legwork.source.Evolving, legwork.source.VerificationBinaries


Unable to find the source of your issues? Never fear! Check out our tutorial on using the Source class here!

legwork.strain Module

Computes several types of gravitational wave strains


amplitude_modulation(position, polarisation, ...)

Computes the modulation of the strain due to the orbit averaged response of the detector to the position, polarisation, and inclination of the source

h_0_n(m_c, f_orb, ecc, n, dist[, position, ...])

Computes strain amplitude

h_c_n(m_c, f_orb, ecc, n, dist[, position, ...])

Computes characteristic strain amplitude


Feeling a little strained trying to parse these docs? Check out our tutorial on using functions in the strain module here!

legwork.utils Module

A collection of miscellaneous utility functions


chirp_mass(m_1, m_2)

Computes chirp mass of binaries

peters_g(n, e)

Compute g(n, e) from Peters and Mathews (1963) Eq.20


f(e) from Peters and Mathews (1963) Eq.17

get_a_from_f_orb(f_orb, m_1, m_2)

Converts orbital frequency to semi-major axis

get_f_orb_from_a(a, m_1, m_2)

Converts semi-major axis to orbital frequency

get_a_from_ecc(ecc, c_0)

Convert eccentricity to semi-major axis

beta(m_1, m_2)

Compute beta defined in Peters and Mathews (1964) Eq.5.9

c_0(a_i, ecc_i)

Computes the c_0 factor in Peters and Mathews (1964) Eq.5.11

fn_dot(m_c, f_orb, e, n)

Rate of change of nth frequency of a binary


Convert arguments to numpy arrays

D_plus_squared(theta, phi)

Required for the detector responses <F_+^2>, <F_x^2>, <F_+F_x>

D_cross_squared(theta, phi)

Required for the detector responses <F_+^2>, <F_x^2>, <F_+F_x>

D_plus_D_cross(theta, phi)

Required for the detector responses <F_+^2>, <F_x^2>, <F_+F_x>

F_plus_squared(theta, phi, psi)

Compute the auto-correlated detector response for the plus polarization

F_cross_squared(theta, phi, psi)

Compute the auto-correlated detector response for the cross polarization

legwork.visualisation Module


plot_1D_dist(x[, weights, disttype, fig, ...])

plot a 1D distribution of x.

plot_2D_dist(x, y[, weights, disttype, ...])

Plot a 2D distribution of x and y

plot_sensitivity_curve([frequency_range, ...])

Plot the LISA sensitivity curve

plot_sources_on_sc_circ_stat(f_orb, h_0_2, snr)

Overlay circular/stationary sources on the LISA sensitivity curve.

plot_sources_on_sc_ecc_stat(f_dom, snr[, ...])

Overlay eccentric/stationary sources on the LISA sensitivity curve.


Not quite sure how things are working vis-à-vis visualisation? Check out our tutorial on using functions in the visualisation module here!