# Path: cora/signal/corr21cm.py
# class Corr21cm(corr.RedshiftCorrelation, maps.Sky3d):
# class EoR21cm(Corr21cm):
#     def __init__(self, ps=None, redshift=0.0, sigma_v=0.0, **kwargs):
#     def T_b(self, z):
#     def mean(self, z):
#     def omega_HI(self, z):
#     def x_h(self, z):
#     def prefactor(self, z):
#     def growth_factor(self, z):
#     def growth_rate(self, z):
#     def bias_z(self, z):
#     def angular_powerspectrum(self, l, nu1, nu2, redshift=False):
#     def angular_powerspectrum_full(self, l, nu1, nu2, redshift=False):
#     def mean_nu(self, freq):
#     def getfield(self):
#     def get_kiyo_field(self, refinement=1):
#     def get_pwrspec(self, k_vec):
#     def get_kiyo_field_physical(
#         self, refinement=1, density_only=False, no_mean=False, no_evolution=False
#     ):
# def theory_power_spectrum(
#     redshift_filekey, bin_centers, unitless=True, fileout="theory.dat"
# ):
#     def T_b(self, z):
#     def omega_HI(self, z):
#     def x_h(self, z):
#     def bias_z(self, z):
# 
# Path: cora/foreground/galaxy.py
# class FullSkySynchrotron(gaussianfg.Synchrotron):
# class FullSkyPolarisedSynchrotron(gaussianfg.Synchrotron):
# class ConstrainedGalaxy(maps.Sky3d):
#     A = 6.6e-3
#     A = 1.65e-3
# def map_variance(input_map, nside):
# def chunk_var(a):
#     def __init__(self):
#     def _load_data(self):
#     def getsky(self, debug=False, celestial=True):
#         def tanh_lin(x):
#     def getpolsky(self, debug=False, celestial=True):
#         def angular(l):
#         def ptrans(phi, freq, dfreq):


import numpy as np
from cora.signal import corr21cm
from cora.foreground import galaxy

    Correct here is referenced to a specific version believed to have no errors.
    """

    cr = corr21cm.Corr21cm()

    aps1 = cr.angular_powerspectrum(np.arange(1000), 800.0, 800.0)
    assert len(aps1) == 1000
    assert np.allclose(
        aps1.sum(), 1.5963772205823096e-09, rtol=1e-7
    )  # Calculated for commit 02f4d1cd3f402d

    fa = np.linspace(400.0, 800.0, 64)
    aps2 = cr.angular_powerspectrum(
        np.arange(1000)[:, None, None], fa[None, :, None], fa[None, None, :]
    )
    assert aps2.shape == (1000, 64, 64)

    # Calculated for commit 02f4d1cd3f402d
    v1 = 8.986790805379046e-13  # l=400, fi=40, fj=40
    v2 = 1.1939298801340165e-18  # l=200, fi=10, fj=40
    assert np.allclose(aps2[400, 40, 40], v1, rtol=1e-7)
    assert np.allclose(aps2[200, 10, 40], v2, rtol=1e-7)


def test_corr_foreground():
    """Test that the foreground power spectrum is being calculated correctly.

    Correct here is referenced to a specific version believed to have no errors.
    """

# Path: cora/signal/corr21cm.py
# class Corr21cm(corr.RedshiftCorrelation, maps.Sky3d):
# class EoR21cm(Corr21cm):
#     def __init__(self, ps=None, redshift=0.0, sigma_v=0.0, **kwargs):
#     def T_b(self, z):
#     def mean(self, z):
#     def omega_HI(self, z):
#     def x_h(self, z):
#     def prefactor(self, z):
#     def growth_factor(self, z):
#     def growth_rate(self, z):
#     def bias_z(self, z):
#     def angular_powerspectrum(self, l, nu1, nu2, redshift=False):
#     def angular_powerspectrum_full(self, l, nu1, nu2, redshift=False):
#     def mean_nu(self, freq):
#     def getfield(self):
#     def get_kiyo_field(self, refinement=1):
#     def get_pwrspec(self, k_vec):
#     def get_kiyo_field_physical(
#         self, refinement=1, density_only=False, no_mean=False, no_evolution=False
#     ):
# def theory_power_spectrum(
#     redshift_filekey, bin_centers, unitless=True, fileout="theory.dat"
# ):
#     def T_b(self, z):
#     def omega_HI(self, z):
#     def x_h(self, z):
#     def bias_z(self, z):
# 
# Path: cora/foreground/galaxy.py
# class FullSkySynchrotron(gaussianfg.Synchrotron):
# class FullSkyPolarisedSynchrotron(gaussianfg.Synchrotron):
# class ConstrainedGalaxy(maps.Sky3d):
#     A = 6.6e-3
#     A = 1.65e-3
# def map_variance(input_map, nside):
# def chunk_var(a):
#     def __init__(self):
#     def _load_data(self):
#     def getsky(self, debug=False, celestial=True):
#         def tanh_lin(x):
#     def getpolsky(self, debug=False, celestial=True):
#         def angular(l):
#         def ptrans(phi, freq, dfreq):


# Path: tests/test_corr.py
import numpy as np
from cora.signal import corr21cm
from cora.foreground import galaxy


    Correct here is referenced to a specific version believed to have no errors.
    """

    cr = corr21cm.Corr21cm()

    aps1 = cr.angular_powerspectrum(np.arange(1000), 800.0, 800.0)
    assert len(aps1) == 1000
    assert np.allclose(
        aps1.sum(), 1.5963772205823096e-09, rtol=1e-7
    )  # Calculated for commit 02f4d1cd3f402d

    fa = np.linspace(400.0, 800.0, 64)
    aps2 = cr.angular_powerspectrum(
        np.arange(1000)[:, None, None], fa[None, :, None], fa[None, None, :]
    )
    assert aps2.shape == (1000, 64, 64)

    # Calculated for commit 02f4d1cd3f402d
    v1 = 8.986790805379046e-13  # l=400, fi=40, fj=40
    v2 = 1.1939298801340165e-18  # l=200, fi=10, fj=40
    assert np.allclose(aps2[400, 40, 40], v1, rtol=1e-7)
    assert np.allclose(aps2[200, 10, 40], v2, rtol=1e-7)


def test_corr_foreground():
    """Test that the foreground power spectrum is being calculated correctly.

    Correct here is referenced to a specific version believed to have no errors.
    """

    cr = galaxy.FullSkySynchrotron()