# Path: tests/convenience.py
# def plot_aa_style(cols=1):
#     """Use a plotting style specifically for Astronomy & Astrophyiscs."""
#     # Use a style file
#     dir = os.path.abspath(os.path.dirname(__file__))
#     style_file = os.path.join(dir, './aa.mplstyle')
#     plt.style.use(style_file)
# 
#     # Check whether interactive backend is present
#     if os.name == 'posix' and "DISPLAY" not in os.environ:
#         # On a cluster
#         plt.switch_backend('Agg')
#         # Use just the basic latex package allowing \text to be used
#         plt.rcParams['text.latex.preamble'] = r'\usepackage{amsmath}'
# 
#     if cols == 2:
#         plt.rcParams["figure.figsize"] = (5.75373, 3.556)
# 
# def rel_path(path):
#     """Return the relative path name for this directory."""
#     return os.path.join(os.path.abspath(os.path.dirname(__file__)), path)


import numpy as np
import matplotlib.pyplot as plt
from tests.convenience import plot_aa_style, rel_path
from alpha_complex import complex_rates
"""Compare rate calculations per alpha for the two askap settings."""


REMAKE = False
SIZE = 1e4
SURVEYS = ['parkes-htru', 'askap-fly', 'askap-incoh']
ALPHAS = np.around(np.linspace(-0.2, -2.5, 7), decimals=2)


def main():
    """Get detection rates for surveys."""
    complex = complex_rates(remake=REMAKE,
                            alphas=ALPHAS,
                            size=SIZE,
                            surveys=SURVEYS)

    # Plot population event rates
    plot_rates(complex)


def plot_rates(rates):
    """Plot detection rates for askap surveys."""

# Path: tests/convenience.py
# def plot_aa_style(cols=1):
#     """Use a plotting style specifically for Astronomy & Astrophyiscs."""
#     # Use a style file
#     dir = os.path.abspath(os.path.dirname(__file__))
#     style_file = os.path.join(dir, './aa.mplstyle')
#     plt.style.use(style_file)
# 
#     # Check whether interactive backend is present
#     if os.name == 'posix' and "DISPLAY" not in os.environ:
#         # On a cluster
#         plt.switch_backend('Agg')
#         # Use just the basic latex package allowing \text to be used
#         plt.rcParams['text.latex.preamble'] = r'\usepackage{amsmath}'
# 
#     if cols == 2:
#         plt.rcParams["figure.figsize"] = (5.75373, 3.556)
# 
# def rel_path(path):
#     """Return the relative path name for this directory."""
#     return os.path.join(os.path.abspath(os.path.dirname(__file__)), path)


# Path: tests/rates/alpha_askap.py
import numpy as np
import matplotlib.pyplot as plt
from tests.convenience import plot_aa_style, rel_path
from alpha_complex import complex_rates

"""Compare rate calculations per alpha for the two askap settings."""


REMAKE = False
SIZE = 1e4
SURVEYS = ['parkes-htru', 'askap-fly', 'askap-incoh']
ALPHAS = np.around(np.linspace(-0.2, -2.5, 7), decimals=2)


def main():
    """Get detection rates for surveys."""
    complex = complex_rates(remake=REMAKE,
                            alphas=ALPHAS,
                            size=SIZE,
                            surveys=SURVEYS)

    # Plot population event rates
    plot_rates(complex)


def plot_rates(rates):
    """Plot detection rates for askap surveys."""

    plot_aa_style()