From ead5c36507e4626e8bcd2a3017182a0367d15d78 Mon Sep 17 00:00:00 2001
From: Colm Talbot <colm.talbot@ligo.org>
Date: Tue, 13 Apr 2021 23:23:21 +0000
Subject: [PATCH] Remove deprecated functions/classes

---
 bilby/core/prior/dict.py      |   8 --
 bilby/core/utils.py           |  33 -------
 bilby/gw/detector/networks.py | 157 ----------------------------------
 bilby/gw/source.py            |  13 ---
 test/core/prior/dict_test.py  |   5 --
 test/gw/likelihood_test.py    |   4 +-
 test/gw/source_test.py        |   4 +-
 7 files changed, 4 insertions(+), 220 deletions(-)

diff --git a/bilby/core/prior/dict.py b/bilby/core/prior/dict.py
index 7c82b4f4f..c38c047d7 100644
--- a/bilby/core/prior/dict.py
+++ b/bilby/core/prior/dict.py
@@ -530,14 +530,6 @@ class PriorDict(dict):
         return self.__class__(dictionary=dict(self))
 
 
-class PriorSet(PriorDict):
-
-    def __init__(self, dictionary=None, filename=None):
-        """ DEPRECATED: USE PriorDict INSTEAD"""
-        logger.warning("The name 'PriorSet' is deprecated use 'PriorDict' instead")
-        super(PriorSet, self).__init__(dictionary, filename)
-
-
 class PriorDictException(Exception):
     """ General base class for all prior dict exceptions """
 
diff --git a/bilby/core/utils.py b/bilby/core/utils.py
index ccb7fc11e..fd0c558ed 100644
--- a/bilby/core/utils.py
+++ b/bilby/core/utils.py
@@ -9,10 +9,8 @@ import types
 import shutil
 import subprocess
 import sys
-import warnings
 from distutils.spawn import find_executable
 from importlib import import_module
-from math import fmod
 from numbers import Number
 
 import numpy as np
@@ -321,37 +319,6 @@ def theta_phi_to_ra_dec(theta, phi, gmst):
     return ra, dec
 
 
-def gps_time_to_gmst(gps_time):
-    """
-    Convert gps time to Greenwich mean sidereal time in radians
-
-    This method assumes a constant rotation rate of earth since 00:00:00, 1 Jan. 2000
-    A correction has been applied to give the exact correct value for 00:00:00, 1 Jan. 2018
-    Error accumulates at a rate of ~0.0001 radians/decade.
-
-    Parameters
-    ==========
-    gps_time: float
-        gps time
-
-    Returns
-    =======
-    float: Greenwich mean sidereal time in radians
-
-    """
-    warnings.warn(
-        "Function gps_time_to_gmst deprecated, use "
-        "lal.GreenwichMeanSiderealTime(time) instead",
-        DeprecationWarning)
-    omega_earth = 2 * np.pi * (1 / 365.2425 + 1) / 86400.
-    gps_2000 = 630720013.
-    gmst_2000 = (6 + 39. / 60 + 51.251406103947375 / 3600) * np.pi / 12
-    correction_2018 = -0.00017782487379358614
-    sidereal_time = omega_earth * (gps_time - gps_2000) + gmst_2000 + correction_2018
-    gmst = fmod(sidereal_time, 2 * np.pi)
-    return gmst
-
-
 def create_white_noise(sampling_frequency, duration):
     """ Create white_noise which is then coloured by a given PSD
 
diff --git a/bilby/gw/detector/networks.py b/bilby/gw/detector/networks.py
index 8abd64c3f..d354f2bf4 100644
--- a/bilby/gw/detector/networks.py
+++ b/bilby/gw/detector/networks.py
@@ -1,16 +1,13 @@
 import os
 import sys
-import warnings
 
 import numpy as np
 import math
 
 from ...core import utils
 from ...core.utils import logger
-from .. import utils as gwutils
 from .interferometer import Interferometer
 from .psd import PowerSpectralDensity
-from .strain_data import InterferometerStrainData
 
 
 class InterferometerList(list):
@@ -324,73 +321,6 @@ class TriangularInterferometer(InterferometerList):
             longitude += np.arctan(length * np.cos(xarm_azimuth * np.pi / 180) * 1e3 / utils.radius_of_earth)
 
 
-def get_event_data(
-        event, interferometer_names=None, duration=4, roll_off=0.2,
-        psd_offset=-1024, psd_duration=100, cache=True, outdir='outdir',
-        label=None, plot=True, filter_freq=None, **kwargs):
-    """
-    Get open data for a specified event.
-
-    Parameters
-    ==========
-    event: str
-        Event descriptor, this can deal with some prefixes, e.g., '150914',
-        'GW150914', 'LVT151012'
-    interferometer_names: list, optional
-        List of interferometer identifiers, e.g., 'H1'.
-        If None will look for data in 'H1', 'V1', 'L1'
-    duration: float
-        Time duration to search for.
-    roll_off: float
-        The roll-off (in seconds) used in the Tukey window.
-    psd_offset, psd_duration: float
-        The power spectral density (psd) is estimated using data from
-        `center_time+psd_offset` to `center_time+psd_offset + psd_duration`.
-    cache: bool
-        Whether or not to store the acquired data.
-    outdir: str
-        Directory where the psd files are saved
-    label: str
-        If given, an identifying label used in generating file names.
-    plot: bool
-        If true, create an ASD + strain plot
-    filter_freq: float
-        Low pass filter frequency
-    **kwargs:
-        All keyword arguments are passed to
-        `gwpy.timeseries.TimeSeries.fetch_open_data()`.
-
-    Returns
-    ======
-    list: A list of bilby.gw.detector.Interferometer objects
-    """
-
-    warnings.warn(
-        "get_event_data is deprecated, use set_strain_data_from_gwpy instead",
-        DeprecationWarning
-    )
-
-    event_time = gwutils.get_event_time(event)
-
-    interferometers = []
-
-    if interferometer_names is None:
-        interferometer_names = ['H1', 'L1', 'V1']
-
-    for name in interferometer_names:
-        try:
-            interferometers.append(get_interferometer_with_open_data(
-                name, trigger_time=event_time, duration=duration, roll_off=roll_off,
-                psd_offset=psd_offset, psd_duration=psd_duration, cache=cache,
-                outdir=outdir, label=label, plot=plot, filter_freq=filter_freq,
-                **kwargs))
-        except ValueError as e:
-            logger.debug("Error raised {}".format(e))
-            logger.warning('No data found for {}.'.format(name))
-
-    return InterferometerList(interferometers)
-
-
 def get_empty_interferometer(name):
     """
     Get an interferometer with standard parameters for known detectors.
@@ -452,90 +382,3 @@ def load_interferometer(filename):
     else:
         raise IOError("{} could not be loaded. Invalid parameter 'shape'.".format(filename))
     return ifo
-
-
-def get_interferometer_with_open_data(
-        name, trigger_time, duration=4, start_time=None, roll_off=0.2,
-        psd_offset=-1024, psd_duration=100, cache=True, outdir='outdir',
-        label=None, plot=True, filter_freq=None, **kwargs):
-    """
-    Helper function to obtain an Interferometer instance with appropriate
-    PSD and data, given an center_time.
-
-    Parameters
-    ==========
-
-    name: str
-        Detector name, e.g., 'H1'.
-    trigger_time: float
-        Trigger GPS time.
-    duration: float, optional
-        The total time (in seconds) to analyse. Defaults to 4s.
-    start_time: float, optional
-        Beginning of the segment, if None, the trigger is placed 2s before the end
-        of the segment.
-    roll_off: float
-        The roll-off (in seconds) used in the Tukey window.
-    psd_offset, psd_duration: float
-        The power spectral density (psd) is estimated using data from
-        `center_time+psd_offset` to `center_time+psd_offset + psd_duration`.
-    cache: bool, optional
-        Whether or not to store the acquired data
-    outdir: str
-        Directory where the psd files are saved
-    label: str
-        If given, an identifying label used in generating file names.
-    plot: bool
-        If true, create an ASD + strain plot
-    filter_freq: float
-        Low pass filter frequency
-    **kwargs:
-        All keyword arguments are passed to
-        `gwpy.timeseries.TimeSeries.fetch_open_data()`.
-
-    Returns
-    =======
-    bilby.gw.detector.Interferometer: An Interferometer instance with a PSD and frequency-domain strain data.
-
-    """
-
-    warnings.warn(
-        "get_interferometer_with_open_data is deprecated, use set_strain_data_from_gwpy instead",
-        DeprecationWarning
-    )
-
-    logger.warning(
-        "Parameter estimation for real interferometer data in bilby is in "
-        "alpha testing at the moment: the routines for windowing and filtering"
-        " have not been reviewed.")
-
-    utils.check_directory_exists_and_if_not_mkdir(outdir)
-
-    if start_time is None:
-        start_time = trigger_time + 2 - duration
-
-    strain = InterferometerStrainData(roll_off=roll_off)
-    strain.set_from_open_data(
-        name=name, start_time=start_time, duration=duration,
-        outdir=outdir, cache=cache, **kwargs)
-    strain.low_pass_filter(filter_freq)
-
-    strain_psd = InterferometerStrainData(roll_off=roll_off)
-    strain_psd.set_from_open_data(
-        name=name, start_time=start_time + duration + psd_offset,
-        duration=psd_duration, outdir=outdir, cache=cache, **kwargs)
-    # Low pass filter
-    strain_psd.low_pass_filter(filter_freq)
-    # Create and save PSDs
-    psd_frequencies, psd_array = strain_psd.create_power_spectral_density(
-        name=name, outdir=outdir, fft_length=strain.duration)
-
-    interferometer = get_empty_interferometer(name)
-    interferometer.power_spectral_density = PowerSpectralDensity(
-        psd_array=psd_array, frequency_array=psd_frequencies)
-    interferometer.strain_data = strain
-
-    if plot:
-        interferometer.plot_data(outdir=outdir, label=label)
-
-    return interferometer
diff --git a/bilby/gw/source.py b/bilby/gw/source.py
index b874b8a03..776e0fbce 100644
--- a/bilby/gw/source.py
+++ b/bilby/gw/source.py
@@ -413,19 +413,6 @@ def _base_lal_cbc_fd_waveform(
     return dict(plus=h_plus, cross=h_cross)
 
 
-def roq(
-        frequency_array, mass_1, mass_2, luminosity_distance, a_1, tilt_1,
-        phi_12, a_2, tilt_2, phi_jl, theta_jn, phase, **waveform_arguments):
-    logger.warning(
-        'bilby.gw.source.roq has been deprecated and will be removed. Use '
-        'bilby.gw.source.binary_black_hole_roq instead.')
-    return binary_black_hole_roq(
-        frequency_array=frequency_array, mass_1=mass_1, mass_2=mass_2,
-        luminosity_distance=luminosity_distance, a_1=a_1, tilt_1=tilt_1,
-        phi_12=phi_12, a_2=a_2, tilt_2=tilt_2, phi_jl=phi_jl,
-        theta_jn=theta_jn, phase=phase, **waveform_arguments)
-
-
 def binary_black_hole_roq(
         frequency_array, mass_1, mass_2, luminosity_distance, a_1, tilt_1,
         phi_12, a_2, tilt_2, phi_jl, theta_jn, phase, **waveform_arguments):
diff --git a/test/core/prior/dict_test.py b/test/core/prior/dict_test.py
index a004feab1..546bcd465 100644
--- a/test/core/prior/dict_test.py
+++ b/test/core/prior/dict_test.py
@@ -41,11 +41,6 @@ class TestPriorDict(unittest.TestCase):
         priors = bilby.core.prior.PriorDict(self.priors)
         self.assertEqual(priors, priors.copy())
 
-    def test_prior_set(self):
-        priors_dict = bilby.core.prior.PriorDict(self.priors)
-        priors_set = bilby.core.prior.PriorSet(self.priors)
-        self.assertEqual(priors_dict, priors_set)
-
     def test_prior_set_is_dict(self):
         self.assertIsInstance(self.prior_set_from_dict, dict)
 
diff --git a/test/gw/likelihood_test.py b/test/gw/likelihood_test.py
index 8f8bbcfc1..adea14483 100644
--- a/test/gw/likelihood_test.py
+++ b/test/gw/likelihood_test.py
@@ -830,7 +830,7 @@ class TestROQLikelihood(unittest.TestCase):
         roq_wfg = bilby.gw.waveform_generator.WaveformGenerator(
             duration=self.duration,
             sampling_frequency=self.sampling_frequency,
-            frequency_domain_source_model=bilby.gw.source.roq,
+            frequency_domain_source_model=bilby.gw.source.binary_black_hole_roq,
             waveform_arguments=dict(
                 frequency_nodes_linear=fnodes_linear,
                 frequency_nodes_quadratic=fnodes_quadratic,
@@ -1080,7 +1080,7 @@ class TestRescaledROQLikelihood(unittest.TestCase):
         self.roq_wfg = bilby.gw.waveform_generator.WaveformGenerator(
             duration=self.duration,
             sampling_frequency=self.sampling_frequency,
-            frequency_domain_source_model=bilby.gw.source.roq,
+            frequency_domain_source_model=bilby.gw.source.binary_black_hole_roq,
             waveform_arguments=dict(
                 frequency_nodes_linear=fnodes_linear,
                 frequency_nodes_quadratic=fnodes_quadratic,
diff --git a/test/gw/source_test.py b/test/gw/source_test.py
index ec4a2929a..24c7346d6 100644
--- a/test/gw/source_test.py
+++ b/test/gw/source_test.py
@@ -236,7 +236,7 @@ class TestROQBBH(unittest.TestCase):
     def test_roq_runs_valid_parameters(self):
         self.parameters.update(self.waveform_kwargs)
         self.assertIsInstance(
-            bilby.gw.source.roq(self.frequency_array, **self.parameters), dict
+            bilby.gw.source.binary_black_hole_roq(self.frequency_array, **self.parameters), dict
         )
 
     def test_roq_fails_without_frequency_nodes(self):
@@ -244,7 +244,7 @@ class TestROQBBH(unittest.TestCase):
         del self.parameters["frequency_nodes_linear"]
         del self.parameters["frequency_nodes_quadratic"]
         with self.assertRaises(KeyError):
-            bilby.gw.source.roq(self.frequency_array, **self.parameters)
+            bilby.gw.source.binary_black_hole_roq(self.frequency_array, **self.parameters)
 
 
 if __name__ == "__main__":
-- 
GitLab