Skip to content

Projection

gwmock_signal.projection

Projection of GW polarizations onto detector networks.

ProjectionEffects dataclass

The physical effects projection includes. All are on by default; each can be turned off alone.

Compact binaries, bursts and continuous waves are projected by the same code, so a given set of effects means the same thing for each. :meth:long_wavelength turns them all off: a point detector at its vertex, a geocentre at rest and a J2000 direction, the convention of Bilby's and PyCBC's default projection.

Attributes:

Name Type Description
earth_rotation bool

The antenna pattern and the geocentre-to-detector delay follow the Earth's rotation sample by sample. Off, both are held at the midpoint of the span, which suits only a signal of seconds.

finite_arm_length bool

Each arm responds to the strain averaged along the light's round trip to its end mirror and back rather than to the strain at the vertex; see :mod:~gwmock_signal.projection.finite_arm. Needs every detector's arm length.

source_precession bool

The source direction is rotated from J2000 into the mean equator and equinox of date before the Earth's orientation is applied, as LALPulsar's barycentring does. Off, a J2000 direction is used with sidereal time of date, as LAL, Bilby and PyCBC do for transients; the two differ by up to 1.8e-4 s of geocentre-to-detector delay and about 0.4 degrees of right ascension in 2030.

roemer_delay bool

The travel time between the geocentre and the solar-system barycentre, from the Earth's orbit; see :mod:~gwmock_signal.projection.solar_system.

einstein_delay bool

The relativistic time dilation of the Earth's clock, TDB minus TT.

shapiro_delay bool

The Sun's gravitational delay.

For a transient the three solar-system delays enter only through how they change across the signal: their value and rate at the signal's reference time (a compact binary's coalescence, a burst's peak) are absorbed, so that time keeps its meaning at the geocentre and the detector-frame masses theirs. For a continuous wave, whose parameters are defined at the barycentre, they enter in full.

Source code in src/gwmock_signal/projection/effects.py
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
@dataclass(frozen=True)
class ProjectionEffects:
    """The physical effects projection includes. All are on by default; each can be turned off alone.

    Compact binaries, bursts and continuous waves are projected by the same code, so a given set of
    effects means the same thing for each. :meth:`long_wavelength` turns them all off: a point detector at
    its vertex, a geocentre at rest and a J2000 direction, the convention of Bilby's and PyCBC's default
    projection.

    Attributes:
        earth_rotation: The antenna pattern and the geocentre-to-detector delay follow the Earth's
            rotation sample by sample. Off, both are held at the midpoint of the span, which suits only a
            signal of seconds.
        finite_arm_length: Each arm responds to the strain averaged along the light's round trip to its
            end mirror and back rather than to the strain at the vertex; see
            :mod:`~gwmock_signal.projection.finite_arm`. Needs every detector's arm length.
        source_precession: The source direction is rotated from J2000 into the mean equator and equinox of
            date before the Earth's orientation is applied, as LALPulsar's barycentring does. Off, a J2000
            direction is used with sidereal time of date, as LAL, Bilby and PyCBC do for transients; the
            two differ by up to 1.8e-4 s of geocentre-to-detector delay and about 0.4 degrees of right
            ascension in 2030.
        roemer_delay: The travel time between the geocentre and the solar-system barycentre, from the
            Earth's orbit; see :mod:`~gwmock_signal.projection.solar_system`.
        einstein_delay: The relativistic time dilation of the Earth's clock, TDB minus TT.
        shapiro_delay: The Sun's gravitational delay.

    For a transient the three solar-system delays enter only through how they change across the signal:
    their value and rate at the signal's reference time (a compact binary's coalescence, a burst's peak)
    are absorbed, so that time keeps its meaning at the geocentre and the detector-frame masses theirs.
    For a continuous wave, whose parameters are defined at the barycentre, they enter in full.
    """

    earth_rotation: bool = True
    finite_arm_length: bool = True
    source_precession: bool = True
    roemer_delay: bool = True
    einstein_delay: bool = True
    shapiro_delay: bool = True

    @classmethod
    def long_wavelength(cls, *, earth_rotation: bool = False) -> ProjectionEffects:
        """Return every effect off: a point detector at its vertex, a geocentre at rest, J2000 directions.

        Args:
            earth_rotation: Keep the Earth's rotation on, for a signal long enough to need it.
        """
        return replace(
            cls(**dict.fromkeys((field.name for field in fields(cls)), False)), earth_rotation=earth_rotation
        )

    @property
    def solar_system(self) -> bool:
        """Whether any of the three solar-system delays is included."""
        return self.roemer_delay or self.einstein_delay or self.shapiro_delay

solar_system property

Whether any of the three solar-system delays is included.

long_wavelength(*, earth_rotation=False) classmethod

Return every effect off: a point detector at its vertex, a geocentre at rest, J2000 directions.

Parameters:

Name Type Description Default
earth_rotation bool

Keep the Earth's rotation on, for a signal long enough to need it.

False
Source code in src/gwmock_signal/projection/effects.py
60
61
62
63
64
65
66
67
68
69
@classmethod
def long_wavelength(cls, *, earth_rotation: bool = False) -> ProjectionEffects:
    """Return every effect off: a point detector at its vertex, a geocentre at rest, J2000 directions.

    Args:
        earth_rotation: Keep the Earth's rotation on, for a signal long enough to need it.
    """
    return replace(
        cls(**dict.fromkeys((field.name for field in fields(cls)), False)), earth_rotation=earth_rotation
    )

SolarSystemEphemeris dataclass

The Earth and Sun tables the solar-system delay is computed from.

Attributes:

Name Type Description
earth str

Path or standard name of the Earth table.

sun str

Path or standard name of the Sun table.

Source code in src/gwmock_signal/projection/solar_system.py
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
@dataclass(frozen=True)
class SolarSystemEphemeris:
    """The Earth and Sun tables the solar-system delay is computed from.

    Attributes:
        earth: Path or standard name of the Earth table.
        sun: Path or standard name of the Sun table.
    """

    earth: str = DEFAULT_EARTH_EPHEMERIS
    sun: str = DEFAULT_SUN_EPHEMERIS

    def tables(self) -> tuple[EphemerisTable, EphemerisTable]:
        """Return the two tables, reading (and if need be downloading) each once per process."""
        return read_table(str(self.earth)), read_table(str(self.sun))

tables()

Return the two tables, reading (and if need be downloading) each once per process.

Source code in src/gwmock_signal/projection/solar_system.py
353
354
355
def tables(self) -> tuple[EphemerisTable, EphemerisTable]:
    """Return the two tables, reading (and if need be downloading) each once per process."""
    return read_table(str(self.earth)), read_table(str(self.sun))

project_polarizations_to_network(polarizations, detector_names, *, right_ascension, declination, polarization_angle, effects=None, reference_time=None, ephemeris=None, backend='numpy', sinc_taps=DEFAULT_SINC_TAPS, kaiser_beta=DEFAULT_KAISER_BETA, tapered=False, earth_rotation=None, precess_source_direction=None, finite_arm_length=None, output_grid=None)

Project tensor plus/cross strains onto detectors using detector geometry.

Built-in and custom detector codes are resolved through the LAL cached detector registry. For earth_rotation=False, the constant geocenter->detector delay is applied via an exact frequency-domain phase shift (h(t-tau) <-> H(f)*exp(-2*pi*i*f*tau)), which is lossless at all frequencies. For earth_rotation=True, the polarizations are resampled at the time-dependent delayed times with the Kaiser-windowed sinc kernel in :mod:gwmock_signal.projection.resampling, gathered from a zero-padded copy so kernel taps reaching past either end read zero rather than repeating the endpoint.

Each detector series is longer than the input, and starts earlier. Delaying the signal by the geocentre-to-detector light-travel time -- up to Earth's radius over the speed of light, about 21 ms -- moves part of it past the end, or before the start, of the polarization buffer. The polarizations are therefore zero-padded by :func:~gwmock_signal.projection.resampling.edge_padding samples at each end before they are projected, and every returned series covers that padded span: it starts that many samples before the input and has twice that many more samples, on the input's own sample lattice -- or, with output_grid, the same span on that lattice, starting up to one sample earlier. The padding is sized for the largest delay any ground-based detector can have, plus the resampling kernel's half-width, so it is the same for every detector, sky position and backend: all returned series share one start time and length. Inside the input's span the samples are what a same-length projection gives, up to rounding; outside it they hold the delayed signal that a same-length projection would have dropped (earth_rotation=True) or wrapped round to the other end of the buffer (earth_rotation=False). A caller that needs the input's span exactly can crop to it, at the cost of that content.

Parameters:

Name Type Description Default
polarizations Mapping[str, TimeSeries | TimeSeries]

Mapping containing plus and cross time series, each a :class:~gwmock_signal.timeseries.TimeSeries or a GWpy TimeSeries, on a common grid. Sample times are the lattice t0 + k * dt of the series' start time and spacing, not a GWpy times array, which at GPS magnitudes and a rate that is not a power of two drifts from it (by 0.22 samples within one second at 3000 Hz).

required
detector_names Sequence[DetectorSpec]

Sequence of IFO codes (e.g. H1, L1, V1) or :class:~gwmock_signal.detector.CustomDetector instances, or a mix of both.

required
right_ascension float

Source right ascension in radians.

required
declination float

Source declination in radians.

required
polarization_angle float

Polarization angle psi in radians (tensor modes).

required
effects ProjectionEffects | None

Which physical effects to include; see :class:~gwmock_signal.projection.effects.ProjectionEffects. All are on by default: Earth rotation, the finite-arm response, source precession and the Roemer, Einstein and Shapiro delays. ProjectionEffects.long_wavelength() turns them all off.

None
reference_time float | None

GPS time at which a transient's solar-system delay is absorbed: its value and rate there are taken out, so that time keeps its meaning at the geocentre. The coalescence time of a compact binary, the peak time of a burst. None, the default, takes the time of the polarizations' peak power, which for a compact binary is the merger, milliseconds from coalescence; absorbing there rather than at coalescence changes the delay by about 1e-12 s.

None
ephemeris SolarSystemEphemeris | None

The Earth and Sun tables for the solar-system delays; the LALPulsar DE405 tables by default, downloaded and cached on first use.

None
backend str

Which implementation evaluates the earth_rotation=True branch. "numpy" (the default) runs on the host. "jax" delegates to :func:~gwmock_signal.projection.jax_projection.project_polarizations_td_rotating, which runs on whatever JAX backend is configured and is several times faster even on a CPU because the whole per-sample kernel fuses into one compiled loop. The two agree to 1e-10 of peak, pinned by test_rotating_projection_matches_numpy_path; the difference is floating-point reassociation, not a different model. Selected rather than automatic: an implicit switch on whether JAX imports would make the numerical output depend on what happens to be installed.

'numpy'
sinc_taps int

Taps in the band-limited resampling kernel used by the earth_rotation=True branch. More taps cost arithmetic and buy accuracy.

DEFAULT_SINC_TAPS
kaiser_beta float

Kaiser window shape parameter for that kernel.

DEFAULT_KAISER_BETA
tapered bool

Whether the polarizations are a whole signal that falls smoothly to zero at both ends, such as a generated compact-binary waveform. If so, the earth_rotation=True branch oversamples them exactly before the kernel reads them, and is accurate up to their Nyquist frequency rather than to 0.8 of it. Leave it False for a piece cut from a longer signal: the exact interpolation is global, and the cut ends would ring across the whole piece. The earth_rotation=False branch is unaffected.

False
earth_rotation bool | None

Deprecated; effects=ProjectionEffects(earth_rotation=...). Overrides that field when given.

None
precess_source_direction bool | None

Deprecated; effects=ProjectionEffects(source_precession=...). Overrides that field when given. Which value suits which analysis is described on source_precession.

None
finite_arm_length bool | None

Deprecated; effects=ProjectionEffects(finite_arm_length=...). Overrides that field when given.

None
output_grid SamplingGrid | None

A lattice to put the returned series on, at the inputs' sample rate, such as the segment the strain will be added to. Each series then starts at the lattice sample preceding the padded input's start, up to one sample earlier, and its samples are the detector strain at those lattice times: the sub-sample offset joins the delay in the one resampling the projection makes. Adding the result to a series on the same lattice is then an integer-offset add. Placing a series that is off the lattice needs a second resampling instead, of strain that need not be band-limited at its ends, and resampling a finished buffer cannot reproduce what the band-limited interpolant of the polarizations puts past them. None, the default, keeps the inputs' own lattice.

None

Returns:

Type Description
dict[str, TimeSeries]

Mapping from each detector name to the projected strain as a

dict[str, TimeSeries]

class:~gwmock_signal.timeseries.TimeSeries, at the inputs' sample rate and on their

dict[str, TimeSeries]

sample lattice, or on output_grid when given, padded by

dict[str, TimeSeries]

edge_padding(sample_rate, sinc_taps, kaiser_beta) samples at each end as described above.

Raises:

Type Description
TypeError

If polarizations is not a mapping of time series as required.

ValueError

If keys are missing, time grids disagree, a detector name is not recognized, backend is unknown, backend="jax" is combined with earth_rotation=False, or the resampling kernel (sinc_taps, kaiser_beta) is invalid -- checked on both branches, since it sizes the padding on both, or the finite-arm response is asked of a detector with no arm length, or a solar-system delay of a span the ephemeris does not cover (2000 to 2040 for the default tables), or output_grid has another sample rate.

Source code in src/gwmock_signal/projection/network.py
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
def project_polarizations_to_network(  # noqa: PLR0913
    polarizations: Mapping[str, TimeSeries | gwpy.timeseries.TimeSeries],
    detector_names: Sequence[DetectorSpec],
    *,
    right_ascension: float,
    declination: float,
    polarization_angle: float,
    effects: ProjectionEffects | None = None,
    reference_time: float | None = None,
    ephemeris: SolarSystemEphemeris | None = None,
    backend: str = "numpy",
    sinc_taps: int = DEFAULT_SINC_TAPS,
    kaiser_beta: float = DEFAULT_KAISER_BETA,
    tapered: bool = False,
    earth_rotation: bool | None = None,
    precess_source_direction: bool | None = None,
    finite_arm_length: bool | None = None,
    output_grid: SamplingGrid | None = None,
) -> dict[str, TimeSeries]:
    """Project tensor plus/cross strains onto detectors using detector geometry.

    Built-in and custom detector codes are resolved through the LAL cached
    detector registry. For ``earth_rotation=False``, the constant
    geocenter->detector delay is applied via an exact frequency-domain phase
    shift (``h(t-tau) <-> H(f)*exp(-2*pi*i*f*tau)``), which is lossless at all
    frequencies. For ``earth_rotation=True``, the polarizations are resampled at the
    time-dependent delayed times with the Kaiser-windowed sinc kernel in
    :mod:`gwmock_signal.projection.resampling`, gathered from a zero-padded copy so kernel
    taps reaching past either end read zero rather than repeating the endpoint.

    **Each detector series is longer than the input, and starts earlier.** Delaying the signal
    by the geocentre-to-detector light-travel time -- up to Earth's radius over the speed of
    light, about 21 ms -- moves part of it past the end, or before the start, of the
    polarization buffer. The polarizations are therefore zero-padded by
    :func:`~gwmock_signal.projection.resampling.edge_padding` samples at each end before they
    are projected, and every returned series covers that padded span: it starts that many
    samples before the input and has twice that many more samples, on the input's own sample
    lattice -- or, with ``output_grid``, the same span on that lattice, starting up to one sample
    earlier. The padding is sized for the largest delay any ground-based detector can have, plus
    the resampling kernel's half-width, so it is the same for every detector, sky position and
    backend: all returned series share one start time and length. Inside the input's span the
    samples are what a same-length projection gives, up to rounding; outside it they hold the
    delayed signal that a same-length projection would have dropped (``earth_rotation=True``) or
    wrapped round to the other end of the buffer (``earth_rotation=False``). A caller that needs
    the input's span exactly can crop to it, at the cost of that content.

    Args:
        polarizations: Mapping containing ``plus`` and ``cross`` time series, each a
            :class:`~gwmock_signal.timeseries.TimeSeries` or a GWpy ``TimeSeries``, on a common
            grid. Sample times are the lattice ``t0 + k * dt`` of the series' start time and
            spacing, not a GWpy ``times`` array, which at GPS magnitudes and a rate that is not a
            power of two drifts from it (by 0.22 samples within one second at 3000 Hz).
        detector_names: Sequence of IFO codes (e.g. ``H1``, ``L1``, ``V1``) or
            :class:`~gwmock_signal.detector.CustomDetector` instances, or a mix
            of both.
        right_ascension: Source right ascension in radians.
        declination: Source declination in radians.
        polarization_angle: Polarization angle psi in radians (tensor modes).
        effects: Which physical effects to include; see
            :class:`~gwmock_signal.projection.effects.ProjectionEffects`. All are on by default:
            Earth rotation, the finite-arm response, source precession and the Roemer, Einstein and
            Shapiro delays. ``ProjectionEffects.long_wavelength()`` turns them all off.
        reference_time: GPS time at which a transient's solar-system delay is absorbed: its value and
            rate there are taken out, so that time keeps its meaning at the geocentre. The coalescence
            time of a compact binary, the peak time of a burst. ``None``, the default, takes the time of
            the polarizations' peak power, which for a compact binary is the merger, milliseconds from
            coalescence; absorbing there rather than at coalescence changes the delay by about 1e-12 s.
        ephemeris: The Earth and Sun tables for the solar-system delays; the LALPulsar DE405 tables by
            default, downloaded and cached on first use.
        backend: Which implementation evaluates the ``earth_rotation=True`` branch.
            ``"numpy"`` (the default) runs on the host. ``"jax"`` delegates to
            :func:`~gwmock_signal.projection.jax_projection.project_polarizations_td_rotating`,
            which runs on whatever JAX backend is configured and is several times faster even
            on a CPU because the whole per-sample kernel fuses into one compiled loop. The two
            agree to 1e-10 of peak, pinned by ``test_rotating_projection_matches_numpy_path``;
            the difference is floating-point reassociation, not a different model. Selected
            rather than automatic: an implicit switch on whether JAX imports would make the
            numerical output depend on what happens to be installed.
        sinc_taps: Taps in the band-limited resampling kernel used by the
            ``earth_rotation=True`` branch. More taps cost arithmetic and buy accuracy.
        kaiser_beta: Kaiser window shape parameter for that kernel.
        tapered: Whether the polarizations are a whole signal that falls smoothly to zero at both
            ends, such as a generated compact-binary waveform. If so, the ``earth_rotation=True``
            branch oversamples them exactly before the kernel reads them, and is accurate up to
            their Nyquist frequency rather than to 0.8 of it. Leave it ``False`` for a piece cut
            from a longer signal: the exact interpolation is global, and the cut ends would ring
            across the whole piece. The ``earth_rotation=False`` branch is unaffected.
        earth_rotation: Deprecated; ``effects=ProjectionEffects(earth_rotation=...)``. Overrides that
            field when given.
        precess_source_direction: Deprecated; ``effects=ProjectionEffects(source_precession=...)``.
            Overrides that field when given. Which value suits which analysis is described on
            ``source_precession``.
        finite_arm_length: Deprecated; ``effects=ProjectionEffects(finite_arm_length=...)``. Overrides
            that field when given.
        output_grid: A lattice to put the returned series on, at the inputs' sample rate, such as
            the segment the strain will be added to. Each series then starts at the lattice sample
            preceding the padded input's start, up to one sample earlier, and its samples are the
            detector strain at those lattice times: the sub-sample offset joins the delay in the one
            resampling the projection makes. Adding the result to a series on the same lattice is
            then an integer-offset add. Placing a series that is off the lattice needs a second
            resampling instead, of strain that need not be band-limited at its ends, and
            resampling a finished buffer cannot reproduce what the band-limited interpolant of the
            polarizations puts past them. ``None``, the default, keeps the inputs' own lattice.

    Returns:
            Mapping from each detector name to the projected strain as a
            :class:`~gwmock_signal.timeseries.TimeSeries`, at the inputs' sample rate and on their
            sample lattice, or on ``output_grid`` when given, padded by
            ``edge_padding(sample_rate, sinc_taps, kaiser_beta)`` samples at each end as described above.

    Raises:
        TypeError: If ``polarizations`` is not a mapping of time series as required.
        ValueError: If keys are missing, time grids disagree, a detector name is not
            recognized, ``backend`` is unknown, ``backend="jax"`` is combined with
            ``earth_rotation=False``, or the resampling kernel (``sinc_taps``, ``kaiser_beta``)
            is invalid -- checked on both branches, since it sizes the padding on both, or the
            finite-arm response is asked of a detector with no arm length, or a solar-system delay of
            a span the ephemeris does not cover (2000 to 2040 for the default tables), or ``output_grid``
            has another sample rate.
    """
    return _project(
        polarizations,
        detector_names,
        right_ascension=right_ascension,
        declination=declination,
        polarization_angle=polarization_angle,
        effects=_resolve_effects(
            effects,
            earth_rotation=earth_rotation,
            precess_source_direction=precess_source_direction,
            finite_arm_length=finite_arm_length,
        ),
        backend=backend,
        sinc_taps=sinc_taps,
        kaiser_beta=kaiser_beta,
        tapered=tapered,
        ephemeris=ephemeris,
        reference_time=reference_time,
        output_grid=output_grid,
    )

validate_projection_backend(value, *, parameter='backend')

Return value if it names a projection implementation, else raise.

Shared so the name is checked identically wherever it is accepted -- this function, and the simulators that take it at construction time and only reach the projection later. Checking it in each place separately is how one of them ends up accepting a name the projection does not.

Parameters:

Name Type Description Default
value str

The candidate backend name.

required
parameter str

What to call it in the error message, since callers spell the argument differently (backend here, projection_backend on a simulator).

'backend'

Returns:

Type Description
str

value unchanged.

Raises:

Type Description
ValueError

If value is not one of :data:PROJECTION_BACKENDS.

Source code in src/gwmock_signal/projection/network.py
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
def validate_projection_backend(value: str, *, parameter: str = "backend") -> str:
    """Return *value* if it names a projection implementation, else raise.

    Shared so the name is checked identically wherever it is accepted -- this function, and the
    simulators that take it at construction time and only reach the projection later. Checking it
    in each place separately is how one of them ends up accepting a name the projection does not.

    Args:
        value: The candidate backend name.
        parameter: What to call it in the error message, since callers spell the argument
            differently (``backend`` here, ``projection_backend`` on a simulator).

    Returns:
        *value* unchanged.

    Raises:
        ValueError: If *value* is not one of :data:`PROJECTION_BACKENDS`.
    """
    if value not in PROJECTION_BACKENDS:
        raise ValueError(f"{parameter} must be 'numpy' or 'jax', got {value!r}.")
    return value

gwmock_signal.projection.solar_system

The delay between the geocentre and the solar-system barycentre, for every source.

A wave reaches the geocentre at a different time than it reaches the solar-system barycentre (SSB), by an amount that changes as the Earth moves. Written as the SSB time of a wavefront that passes the geocentre at t, t_SSB = t + D(t), the delay D has three parts, each switchable through :class:~gwmock_signal.projection.effects.ProjectionEffects:

  • Roemer: n . r(t) / c, the geocentre's position r relative to the SSB along the direction n to the source (J2000). Up to 500 s, changing by up to 1e-4 s per second.
  • Einstein: TDB minus TT, the relativistic time dilation of a clock on Earth, 1.7 ms over a year.
  • Shapiro: the Sun's gravitational delay, -2 G M / c^3 ln(1 + cos) in effect, entering D with a minus sign; up to ~1e-4 s for a source near the Sun.

This is LALPulsar's XLALBarycenterEarth and XLALBarycenter in their TIMECORRECTION_ORIGINAL time system, without the site term, which projection adds from the detector geometry, and agrees with lalpulsar.Barycenter at the geocentre to 1e-13 s: the Earth's position from the JPL DE405 tables LALPulsar ships (second-order Taylor expansion about the nearest entry, 7200 s apart, which misses the Earth's jerk by up to 5e-8 s between entries, as LALPulsar does), the Einstein delay from the 40 largest terms of TEMPO's series, and the Shapiro delay including a ray that passes through the Sun. The arithmetic follows the JAX port of those functions in ripplegw (ripplegw.waveforms.cw.earth and barycenter, MIT licence), which the continuous-wave simulator used before this module existed.

The tables are read from earth00-40-DE405.dat.gz and sun00-40-DE405.dat.gz by default, which cover GPS 630720013 to 1893024018 (2000 to 2040). A file not found locally is downloaded once from the LALSuite repository and cached; on a machine without network access, place the files in the cache (:func:cache_directory) or pass their paths.

DelayModel dataclass

The delay over a span of geocentre times, ready to evaluate at every sample on the host or device.

The Roemer and Shapiro parts are evaluated exactly as LALPulsar evaluates them, by Taylor expansion about the nearest table entry, from the few entries the span needs; the Einstein part, a smooth series whose fastest term has a 30-day period, from cubic-Hermite interpolation of its value and rate on a grid :data:EINSTEIN_GRID_SECONDS apart. Interpolating the Roemer part instead would smooth over the steps LALPulsar's expansion takes between entries, up to 5e-8 s, and disagree with it by that.

Times are passed relative to :attr:epoch, so a device in any precision never handles the GPS epoch.

Attributes:

Name Type Description
epoch float

GPS time the times passed to :meth:evaluate are measured from.

source ndarray

Unit vector towards the source, J2000.

components tuple[bool, bool, bool]

(roemer, einstein, shapiro), which parts are included.

earth tuple[float, float, ndarray, ndarray, ndarray]

Earth-table entries covering the span: (offset of the first entry from the epoch, spacing, position, velocity, acceleration).

sun tuple[float, float, ndarray, ndarray, ndarray]

The same for the Sun.

einstein_grid tuple[float, float, ndarray, ndarray]

(offset of the first node from the epoch, spacing, value, rate).

Source code in src/gwmock_signal/projection/solar_system.py
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
@dataclass(frozen=True)
class DelayModel:
    """The delay over a span of geocentre times, ready to evaluate at every sample on the host or device.

    The Roemer and Shapiro parts are evaluated exactly as LALPulsar evaluates them, by Taylor expansion
    about the nearest table entry, from the few entries the span needs; the Einstein part, a smooth
    series whose fastest term has a 30-day period, from cubic-Hermite interpolation of its value and rate
    on a grid :data:`EINSTEIN_GRID_SECONDS` apart. Interpolating the Roemer part instead would smooth over
    the steps LALPulsar's expansion takes between entries, up to 5e-8 s, and disagree with it by that.

    Times are passed relative to :attr:`epoch`, so a device in any precision never handles the GPS epoch.

    Attributes:
        epoch: GPS time the times passed to :meth:`evaluate` are measured from.
        source: Unit vector towards the source, J2000.
        components: ``(roemer, einstein, shapiro)``, which parts are included.
        earth: Earth-table entries covering the span: ``(offset of the first entry from the epoch,
            spacing, position, velocity, acceleration)``.
        sun: The same for the Sun.
        einstein_grid: ``(offset of the first node from the epoch, spacing, value, rate)``.
    """

    epoch: float
    source: np.ndarray
    components: tuple[bool, bool, bool]
    earth: tuple[float, float, np.ndarray, np.ndarray, np.ndarray]
    sun: tuple[float, float, np.ndarray, np.ndarray, np.ndarray]
    einstein_grid: tuple[float, float, np.ndarray, np.ndarray]

    @classmethod
    def build(  # noqa: PLR0913
        cls,
        start: float,
        end: float,
        right_ascension: float,
        declination: float,
        ephemeris: SolarSystemEphemeris,
        *,
        roemer: bool = True,
        einstein: bool = True,
        shapiro: bool = True,
    ) -> DelayModel:
        """Return the model for geocentre GPS times in ``[start, end]``, measured from ``start``.

        Raises:
            ValueError: If the span reaches outside the tables.
        """
        earth_table, sun_table = ephemeris.tables()
        pieces = []
        for table in (earth_table, sun_table):
            table.state(np.array([start, end]))  # refuses a span outside the table
            # A row count fixed by the span's length alone, so a compiled device kernel serves every
            # span of that length: the entries nearest each time in the span, and one to spare.
            count = math.ceil((end - start) / table.spacing) + 2
            first = int(np.floor((start - table.gps0) / table.spacing + 0.5))
            first = max(0, min(first, len(table.position) - count))
            rows = slice(first, first + count)
            pieces.append(
                (
                    table.gps0 + first * table.spacing - start,
                    table.spacing,
                    table.position[rows],
                    table.velocity[rows],
                    table.acceleration[rows],
                )
            )
        nodes = start + EINSTEIN_GRID_SECONDS * np.arange(-1, math.ceil((end - start) / EINSTEIN_GRID_SECONDS) + 2)
        value, rate = _einstein(nodes)
        return cls(
            epoch=float(start),
            source=source_direction(right_ascension, declination),
            components=(roemer, einstein, shapiro),
            earth=pieces[0],
            sun=pieces[1],
            einstein_grid=(-EINSTEIN_GRID_SECONDS, EINSTEIN_GRID_SECONDS, value, rate),
        )

    def arrays(self) -> tuple[Any, ...]:
        """Return the model as a flat tuple of arrays, for :func:`evaluate_arrays` on a device."""
        earth_first, earth_spacing, *earth = self.earth
        sun_first, sun_spacing, *sun = self.sun
        grid_first, grid_spacing, value, rate = self.einstein_grid
        offsets = np.array([earth_first, earth_spacing, sun_first, sun_spacing, grid_first, grid_spacing])
        return (offsets, self.source, *earth, *sun, value, rate)

    def evaluate(self, since_epoch: Any, *, xp: Any = np) -> Any:
        """Return the delay ``D`` at geocentre times ``since_epoch`` seconds after :attr:`epoch`."""
        return evaluate_arrays(self.arrays(), self.components, since_epoch, xp=xp)

arrays()

Return the model as a flat tuple of arrays, for :func:evaluate_arrays on a device.

Source code in src/gwmock_signal/projection/solar_system.py
523
524
525
526
527
528
529
def arrays(self) -> tuple[Any, ...]:
    """Return the model as a flat tuple of arrays, for :func:`evaluate_arrays` on a device."""
    earth_first, earth_spacing, *earth = self.earth
    sun_first, sun_spacing, *sun = self.sun
    grid_first, grid_spacing, value, rate = self.einstein_grid
    offsets = np.array([earth_first, earth_spacing, sun_first, sun_spacing, grid_first, grid_spacing])
    return (offsets, self.source, *earth, *sun, value, rate)

build(start, end, right_ascension, declination, ephemeris, *, roemer=True, einstein=True, shapiro=True) classmethod

Return the model for geocentre GPS times in [start, end], measured from start.

Raises:

Type Description
ValueError

If the span reaches outside the tables.

Source code in src/gwmock_signal/projection/solar_system.py
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
@classmethod
def build(  # noqa: PLR0913
    cls,
    start: float,
    end: float,
    right_ascension: float,
    declination: float,
    ephemeris: SolarSystemEphemeris,
    *,
    roemer: bool = True,
    einstein: bool = True,
    shapiro: bool = True,
) -> DelayModel:
    """Return the model for geocentre GPS times in ``[start, end]``, measured from ``start``.

    Raises:
        ValueError: If the span reaches outside the tables.
    """
    earth_table, sun_table = ephemeris.tables()
    pieces = []
    for table in (earth_table, sun_table):
        table.state(np.array([start, end]))  # refuses a span outside the table
        # A row count fixed by the span's length alone, so a compiled device kernel serves every
        # span of that length: the entries nearest each time in the span, and one to spare.
        count = math.ceil((end - start) / table.spacing) + 2
        first = int(np.floor((start - table.gps0) / table.spacing + 0.5))
        first = max(0, min(first, len(table.position) - count))
        rows = slice(first, first + count)
        pieces.append(
            (
                table.gps0 + first * table.spacing - start,
                table.spacing,
                table.position[rows],
                table.velocity[rows],
                table.acceleration[rows],
            )
        )
    nodes = start + EINSTEIN_GRID_SECONDS * np.arange(-1, math.ceil((end - start) / EINSTEIN_GRID_SECONDS) + 2)
    value, rate = _einstein(nodes)
    return cls(
        epoch=float(start),
        source=source_direction(right_ascension, declination),
        components=(roemer, einstein, shapiro),
        earth=pieces[0],
        sun=pieces[1],
        einstein_grid=(-EINSTEIN_GRID_SECONDS, EINSTEIN_GRID_SECONDS, value, rate),
    )

evaluate(since_epoch, *, xp=np)

Return the delay D at geocentre times since_epoch seconds after :attr:epoch.

Source code in src/gwmock_signal/projection/solar_system.py
531
532
533
def evaluate(self, since_epoch: Any, *, xp: Any = np) -> Any:
    """Return the delay ``D`` at geocentre times ``since_epoch`` seconds after :attr:`epoch`."""
    return evaluate_arrays(self.arrays(), self.components, since_epoch, xp=xp)

EphemerisTable dataclass

One body's tabulated position, velocity and acceleration relative to the SSB.

Attributes:

Name Type Description
gps0 float

GPS time of the first entry, seconds.

spacing float

Seconds between entries.

position ndarray

Light-seconds, shape (n, 3).

velocity ndarray

In units of c, shape (n, 3).

acceleration ndarray

Per second, shape (n, 3).

source str

Where the table was read from.

Source code in src/gwmock_signal/projection/solar_system.py
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
@dataclass(frozen=True)
class EphemerisTable:
    """One body's tabulated position, velocity and acceleration relative to the SSB.

    Attributes:
        gps0: GPS time of the first entry, seconds.
        spacing: Seconds between entries.
        position: Light-seconds, shape ``(n, 3)``.
        velocity: In units of ``c``, shape ``(n, 3)``.
        acceleration: Per second, shape ``(n, 3)``.
        source: Where the table was read from.
    """

    gps0: float
    spacing: float
    position: np.ndarray = field(repr=False)
    velocity: np.ndarray = field(repr=False)
    acceleration: np.ndarray = field(repr=False)
    source: str = ""

    @property
    def gps_end(self) -> float:
        """GPS time of the last entry."""
        return self.gps0 + (len(self.position) - 1) * self.spacing

    def state(self, gps: np.ndarray) -> tuple[np.ndarray, np.ndarray]:
        """Return position and velocity at ``gps``, Taylor-expanded about the nearest entry as LALPulsar does.

        Raises:
            ValueError: If a time lies outside the table, where LALPulsar refuses too.
        """
        gps = np.asarray(gps, dtype=float)
        offset = gps - self.gps0
        entry = np.floor(offset / self.spacing + 0.5).astype(np.int64)
        if np.any(entry < 0) or np.any(entry >= len(self.position)):
            raise ValueError(
                f"GPS times {float(np.min(gps)):.1f} to {float(np.max(gps)):.1f} reach outside the ephemeris "
                f"{self.source or 'table'}, which covers {self.gps0:.1f} to {self.gps_end:.1f}. Turn the solar-system "
                f"delays off in ProjectionEffects, or pass SolarSystemEphemeris(...) over tables that cover this epoch."
            )
        since = (offset - self.spacing * entry)[..., None]
        position = self.position[entry] + self.velocity[entry] * since + 0.5 * self.acceleration[entry] * since**2
        velocity = self.velocity[entry] + self.acceleration[entry] * since
        return position, velocity

gps_end property

GPS time of the last entry.

state(gps)

Return position and velocity at gps, Taylor-expanded about the nearest entry as LALPulsar does.

Raises:

Type Description
ValueError

If a time lies outside the table, where LALPulsar refuses too.

Source code in src/gwmock_signal/projection/solar_system.py
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
def state(self, gps: np.ndarray) -> tuple[np.ndarray, np.ndarray]:
    """Return position and velocity at ``gps``, Taylor-expanded about the nearest entry as LALPulsar does.

    Raises:
        ValueError: If a time lies outside the table, where LALPulsar refuses too.
    """
    gps = np.asarray(gps, dtype=float)
    offset = gps - self.gps0
    entry = np.floor(offset / self.spacing + 0.5).astype(np.int64)
    if np.any(entry < 0) or np.any(entry >= len(self.position)):
        raise ValueError(
            f"GPS times {float(np.min(gps)):.1f} to {float(np.max(gps)):.1f} reach outside the ephemeris "
            f"{self.source or 'table'}, which covers {self.gps0:.1f} to {self.gps_end:.1f}. Turn the solar-system "
            f"delays off in ProjectionEffects, or pass SolarSystemEphemeris(...) over tables that cover this epoch."
        )
    since = (offset - self.spacing * entry)[..., None]
    position = self.position[entry] + self.velocity[entry] * since + 0.5 * self.acceleration[entry] * since**2
    velocity = self.velocity[entry] + self.acceleration[entry] * since
    return position, velocity

SolarSystemEphemeris dataclass

The Earth and Sun tables the solar-system delay is computed from.

Attributes:

Name Type Description
earth str

Path or standard name of the Earth table.

sun str

Path or standard name of the Sun table.

Source code in src/gwmock_signal/projection/solar_system.py
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
@dataclass(frozen=True)
class SolarSystemEphemeris:
    """The Earth and Sun tables the solar-system delay is computed from.

    Attributes:
        earth: Path or standard name of the Earth table.
        sun: Path or standard name of the Sun table.
    """

    earth: str = DEFAULT_EARTH_EPHEMERIS
    sun: str = DEFAULT_SUN_EPHEMERIS

    def tables(self) -> tuple[EphemerisTable, EphemerisTable]:
        """Return the two tables, reading (and if need be downloading) each once per process."""
        return read_table(str(self.earth)), read_table(str(self.sun))

tables()

Return the two tables, reading (and if need be downloading) each once per process.

Source code in src/gwmock_signal/projection/solar_system.py
353
354
355
def tables(self) -> tuple[EphemerisTable, EphemerisTable]:
    """Return the two tables, reading (and if need be downloading) each once per process."""
    return read_table(str(self.earth)), read_table(str(self.sun))

cache_directory()

Return where downloaded tables are kept.

$GWMOCK_SIGNAL_CACHE_DIR/ephemeris if that variable is set; otherwise $XDG_CACHE_HOME/gwmock-signal/ephemeris (~/.cache when unset), or ~/Library/Caches/gwmock-signal/ephemeris on macOS.

Source code in src/gwmock_signal/projection/solar_system.py
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
def cache_directory() -> Path:
    """Return where downloaded tables are kept.

    ``$GWMOCK_SIGNAL_CACHE_DIR/ephemeris`` if that variable is set; otherwise
    ``$XDG_CACHE_HOME/gwmock-signal/ephemeris`` (``~/.cache`` when unset), or
    ``~/Library/Caches/gwmock-signal/ephemeris`` on macOS.
    """
    override = os.environ.get("GWMOCK_SIGNAL_CACHE_DIR")
    if override:
        return Path(override) / "ephemeris"
    if sys.platform == "darwin":
        base = Path.home() / "Library" / "Caches"
    else:
        base = Path(os.environ.get("XDG_CACHE_HOME") or Path.home() / ".cache")
    return base / "gwmock-signal" / "ephemeris"

delay(gps, right_ascension, declination, ephemeris, *, roemer=True, einstein=True, shapiro=True)

Return the delay D with t_SSB = t + D at geocentre times gps, and its rate.

Parameters:

Name Type Description Default
gps ndarray

GPS times at the geocentre.

required
right_ascension float

J2000 right ascension of the source, radians.

required
declination float

J2000 declination, radians.

required
ephemeris SolarSystemEphemeris

The Earth and Sun tables.

required
roemer bool

Include the Roemer delay.

True
einstein bool

Include the Einstein delay.

True
shapiro bool

Include the Shapiro delay, which enters with a minus sign.

True

Returns:

Type Description
tuple[ndarray, ndarray]

(D, dD/dt), each of the shape of gps.

Source code in src/gwmock_signal/projection/solar_system.py
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
def delay(  # noqa: PLR0913 -- the times, the sky, the tables and the three switches
    gps: np.ndarray,
    right_ascension: float,
    declination: float,
    ephemeris: SolarSystemEphemeris,
    *,
    roemer: bool = True,
    einstein: bool = True,
    shapiro: bool = True,
) -> tuple[np.ndarray, np.ndarray]:
    """Return the delay ``D`` with ``t_SSB = t + D`` at geocentre times ``gps``, and its rate.

    Args:
        gps: GPS times at the geocentre.
        right_ascension: J2000 right ascension of the source, radians.
        declination: J2000 declination, radians.
        ephemeris: The Earth and Sun tables.
        roemer: Include the Roemer delay.
        einstein: Include the Einstein delay.
        shapiro: Include the Shapiro delay, which enters with a minus sign.

    Returns:
        ``(D, dD/dt)``, each of the shape of ``gps``.
    """
    gps = np.asarray(gps, dtype=float)
    value = np.zeros(gps.shape)
    rate = np.zeros(gps.shape)
    if not (roemer or einstein or shapiro):
        return value, rate
    earth_table, sun_table = ephemeris.tables()
    source = source_direction(right_ascension, declination)
    earth_position, earth_velocity = earth_table.state(gps)
    if roemer:
        value = value + earth_position @ source
        rate = rate + earth_velocity @ source
    if einstein:
        einstein_value, einstein_rate = _einstein(gps)
        value, rate = value + einstein_value, rate + einstein_rate
    if shapiro:
        sun_position, sun_velocity = sun_table.state(gps)
        shapiro_value, shapiro_rate = _shapiro(earth_position - sun_position, earth_velocity - sun_velocity, source)
        value, rate = value - shapiro_value, rate - shapiro_rate
    return value, rate

evaluate_arrays(arrays, components, since_epoch, *, xp)

Return the delay of :meth:DelayModel.arrays at since_epoch, in the namespace xp.

components is (roemer, einstein, shapiro); on a device it is static, the arrays traced.

Source code in src/gwmock_signal/projection/solar_system.py
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
def evaluate_arrays(arrays: tuple[Any, ...], components: tuple[bool, bool, bool], since_epoch: Any, *, xp: Any) -> Any:
    """Return the delay of :meth:`DelayModel.arrays` at ``since_epoch``, in the namespace ``xp``.

    ``components`` is ``(roemer, einstein, shapiro)``; on a device it is static, the arrays traced.
    """
    offsets, source, *rest = arrays
    earth = (offsets[0], offsets[1], *rest[0:3])
    sun = (offsets[2], offsets[3], *rest[3:6])
    grid = (offsets[4], offsets[5], *rest[6:8])
    roemer, einstein, shapiro = components
    source = xp.asarray(source)
    total = xp.zeros_like(since_epoch)
    if roemer or shapiro:
        earth_position = _table_position(earth, since_epoch, xp)
    if roemer:
        total = total + _dot3(earth_position, source)
    if einstein:
        total = total + _hermite(grid, since_epoch, xp)
    if shapiro:
        sun_to_earth = earth_position - _table_position(sun, since_epoch, xp)
        distance = xp.sqrt(_dot3(sun_to_earth, sun_to_earth))
        along = _dot3(sun_to_earth, source)
        impact = xp.sqrt(xp.maximum(distance * distance - along * along, 0.0))
        usual = 9.852e-6 * xp.log(_AU_OVER_C / (distance + along))
        inside = 9.852e-6 * xp.log(
            _AU_OVER_C / (along + xp.sqrt(_SUN_RADIUS_LIGHT_SECONDS**2 + along * along))
        ) + 19.704e-6 * (1.0 - impact / _SUN_RADIUS_LIGHT_SECONDS)
        total = total - xp.where((impact < _SUN_RADIUS_LIGHT_SECONDS) & (along < 0.0), inside, usual)
    return total

read_table(name_or_path) cached

Read a LALPulsar ephemeris table, once per process.

The file holds a header gps0 spacing count, then count rows of gps x y z vx vy vz ax ay az.

Raises:

Type Description
FileNotFoundError

See :func:resolve_table.

ValueError

If a table looked up by a recorded name is not the recorded one (see :func:resolve_table), the header disagrees with the rows, or the rows are not evenly spaced.

Source code in src/gwmock_signal/projection/solar_system.py
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
@cache
def read_table(name_or_path: str) -> EphemerisTable:
    """Read a LALPulsar ephemeris table, once per process.

    The file holds a header ``gps0 spacing count``, then ``count`` rows of ``gps x y z vx vy vz ax ay az``.

    Raises:
        FileNotFoundError: See :func:`resolve_table`.
        ValueError: If a table looked up by a recorded name is not the recorded one (see
            :func:`resolve_table`), the header disagrees with the rows, or the rows are not evenly spaced.
    """
    path = resolve_table(name_or_path)
    with path.open("rb") as raw:
        compressed = raw.read(2) == b"\x1f\x8b"
    with gzip.open(path, "rt") if compressed else path.open() as text:
        values = [
            token for line in text if line.strip() and not line.lstrip().startswith("#") for token in line.split()
        ]
    if len(values) < _HEADER_LENGTH:
        raise ValueError(f"Ephemeris {path} has no header.")
    spacing, count = float(values[1]), int(float(values[2]))
    body = np.asarray(values[3:], dtype=float)
    if count <= 0 or body.size != 10 * count:
        raise ValueError(f"Ephemeris {path} declares {count} rows but holds {body.size} values.")
    rows = body.reshape(count, 10)
    if count > 1 and not np.allclose(np.diff(rows[:, 0]), spacing, rtol=0.0, atol=1e-6):
        raise ValueError(f"Ephemeris {path} is not evenly spaced at its declared {spacing} s.")
    position, velocity, acceleration = (np.ascontiguousarray(rows[:, k : k + 3]) for k in (1, 4, 7))
    for array in (position, velocity, acceleration):
        array.setflags(write=False)
    return EphemerisTable(float(rows[0, 0]), spacing, position, velocity, acceleration, str(path))

resolve_table(name_or_path)

Return a local path for a table, downloading a standard one into the cache if it is not there.

A bare standard name, such as earth00-40-DE405.dat.gz, is looked up in the working directory, then in :func:cache_directory, and downloaded there from :data:LALSUITE_EPHEMERIS_URL if absent; nothing else is downloaded. Wherever it is found, a table looked up by a name with a recorded SHA-256 (:data:RECORDED_SHA256, the two default tables compressed or not) must have that content. A path with a directory, such as tables/earth00-40-DE405.dat.gz or "./earth00-40-DE405.dat.gz" given as a string, is the caller's own table and is used as it is. (:class:~pathlib.Path drops a leading ./, so give that form as a string.)

Raises:

Type Description
FileNotFoundError

If the file does not exist and is not a standard name, the cache cannot be written, or the download failed.

ValueError

If a table looked up by a recorded name does not have the recorded content.

Source code in src/gwmock_signal/projection/solar_system.py
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
def resolve_table(name_or_path: str | os.PathLike[str]) -> Path:
    """Return a local path for a table, downloading a standard one into the cache if it is not there.

    A bare standard name, such as ``earth00-40-DE405.dat.gz``, is looked up in the working directory, then
    in :func:`cache_directory`, and downloaded there from :data:`LALSUITE_EPHEMERIS_URL` if absent; nothing
    else is downloaded. Wherever it is found, a table looked up by a name with a recorded SHA-256
    (:data:`RECORDED_SHA256`, the two default tables compressed or not) must have that content. A path
    with a directory, such as ``tables/earth00-40-DE405.dat.gz`` or ``"./earth00-40-DE405.dat.gz"`` given
    as a string, is the caller's own table and is used as it is. (:class:`~pathlib.Path` drops a leading
    ``./``, so give that form as a string.)

    Raises:
        FileNotFoundError: If the file does not exist and is not a standard name, the cache cannot be
            written, or the download failed.
        ValueError: If a table looked up by a recorded name does not have the recorded content.
    """
    raw = os.fspath(name_or_path)
    path = Path(raw)
    by_name = os.path.basename(raw) == raw and _STANDARD_NAME.match(raw) is not None
    for candidate in (path, Path(f"{path}.gz")):
        if candidate.exists():
            if by_name:
                _require_recorded_content(candidate, candidate.name)
            return candidate
    if not by_name:
        if os.path.basename(raw) != raw:
            raise FileNotFoundError(f"Ephemeris {raw!r} does not exist.")
        raise FileNotFoundError(
            f"Ephemeris {raw!r} does not exist, and is not a standard LALPulsar name such as "
            f"{DEFAULT_EARTH_EPHEMERIS!r} that can be downloaded."
        )
    cached = cache_directory() / path.name
    if cached.exists():
        _require_recorded_content(cached, path.name)
        return cached
    try:
        cached.parent.mkdir(parents=True, exist_ok=True)
        handle, partial = tempfile.mkstemp(dir=cached.parent, prefix=f".{path.name}.", suffix=".part")
    except OSError as exc:
        raise FileNotFoundError(
            f"Ephemeris {path.name!r} is not in {cached.parent}, which cannot be written to: {exc}. Set "
            f"$GWMOCK_SIGNAL_CACHE_DIR to a writable directory, copy the table there, or pass its path."
        ) from exc
    try:
        with (
            os.fdopen(handle, "wb") as target,
            urllib.request.urlopen(f"{LALSUITE_EPHEMERIS_URL}/{path.name}", timeout=60) as response,  # noqa: S310
        ):
            shutil.copyfileobj(response, target)
        _require_recorded_content(Path(partial), path.name, downloaded=True)
        os.replace(partial, cached)
    except ValueError:
        Path(partial).unlink(missing_ok=True)
        raise
    except (urllib.error.URLError, OSError, TimeoutError) as exc:
        Path(partial).unlink(missing_ok=True)
        raise FileNotFoundError(
            f"Ephemeris {path.name!r} is not in {cached.parent} and could not be downloaded from "
            f"{LALSUITE_EPHEMERIS_URL}: {exc}. On a machine without network access, copy it into that "
            f"directory or pass its path."
        ) from exc
    return cached

source_direction(right_ascension, declination)

Return the unit vector towards a source at J2000 right ascension and declination.

Source code in src/gwmock_signal/projection/solar_system.py
390
391
392
393
394
395
396
397
398
def source_direction(right_ascension: float, declination: float) -> np.ndarray:
    """Return the unit vector towards a source at J2000 right ascension and declination."""
    return np.array(
        [
            math.cos(declination) * math.cos(right_ascension),
            math.cos(declination) * math.sin(right_ascension),
            math.sin(declination),
        ]
    )

For usage examples, see the User guide — Detector projection examples.