# 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: cora/foreground/pointsource.py
# def faraday_rotate(polmap, rm_map, frequencies):
#     def __init__(self):
#     def source_count(self, flux):
#     def spectral_realisation(self, flux, frequencies):
#     def generate_population(self, area):
#     def getfield(self, catalogue=False):
#     def getsky(self):
#     def getpolsky(self):
#     def source_count(self, flux):
#     def spectral_realisation(self, flux, freq):
#     def source_count(self, flux):
#     def spectral_realisation(self, flux, freq):
#     def __init__(self):
#     def _generate_catalogue(self):
#     def getsky(self):
#     def getpolsky(self):
#     def getsky(self):
#     def getpolsky(self):
# class PointSourceModel(maps.Map3d):
# class PowerLawModel(PointSourceModel):
# class DiMatteo(PointSourceModel):
# class RealPointSources(maps.Map3d):
# class CombinedPointSources(maps.Map3d):
#     class _UnresolvedBackground(gaussianfg.PointSources):
#     class _RandomResolved(DiMatteo):
#     class _RealResolved(RealPointSources):
#     S_0 = 0.88
#         A = 3.55e-5
# 
# 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):


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


def test_galaxy():

    cr = galaxy.ConstrainedGalaxy()
    cr.nside = nside
    cr.frequencies = fa

    unpol = cr.getsky()
    assert unpol.shape == (32, 12 * nside ** 2)

    pol = cr.getpolsky()
    assert pol.shape == (32, 4, 12 * nside ** 2)

    # Check fluctuation amplitude for unpol
    ustd = unpol.std(axis=-1)
    assert (ustd > 10.0).all()
    assert (ustd < 50.0).all()

    # Check fluctuation amplitude for pol
    pstd = pol.std(axis=-1)
    assert (pstd[:, 0] > 10.0).all()
    assert (pstd[:, 0] < 50.0).all()
    assert (pol.std(axis=-1)[:, 1:3] > 0.1).all()
    assert (pol.std(axis=-1)[:, 1:3] < 3.0).all()
    assert (pol.std(axis=-1)[:, 3] == 0.0).all()


def test_pointsource():


# 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: cora/foreground/pointsource.py
# def faraday_rotate(polmap, rm_map, frequencies):
#     def __init__(self):
#     def source_count(self, flux):
#     def spectral_realisation(self, flux, frequencies):
#     def generate_population(self, area):
#     def getfield(self, catalogue=False):
#     def getsky(self):
#     def getpolsky(self):
#     def source_count(self, flux):
#     def spectral_realisation(self, flux, freq):
#     def source_count(self, flux):
#     def spectral_realisation(self, flux, freq):
#     def __init__(self):
#     def _generate_catalogue(self):
#     def getsky(self):
#     def getpolsky(self):
#     def getsky(self):
#     def getpolsky(self):
# class PointSourceModel(maps.Map3d):
# class PowerLawModel(PointSourceModel):
# class DiMatteo(PointSourceModel):
# class RealPointSources(maps.Map3d):
# class CombinedPointSources(maps.Map3d):
#     class _UnresolvedBackground(gaussianfg.PointSources):
#     class _RandomResolved(DiMatteo):
#     class _RealResolved(RealPointSources):
#     S_0 = 0.88
#         A = 3.55e-5
# 
# 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: tests/test_maps.py
import numpy as np
from cora.foreground import galaxy, pointsource
from cora.signal import corr21cm



def test_galaxy():

    cr = galaxy.ConstrainedGalaxy()
    cr.nside = nside
    cr.frequencies = fa

    unpol = cr.getsky()
    assert unpol.shape == (32, 12 * nside ** 2)

    pol = cr.getpolsky()
    assert pol.shape == (32, 4, 12 * nside ** 2)

    # Check fluctuation amplitude for unpol
    ustd = unpol.std(axis=-1)
    assert (ustd > 10.0).all()
    assert (ustd < 50.0).all()

    # Check fluctuation amplitude for pol
    pstd = pol.std(axis=-1)
    assert (pstd[:, 0] > 10.0).all()
    assert (pstd[:, 0] < 50.0).all()
    assert (pol.std(axis=-1)[:, 1:3] > 0.1).all()
    assert (pol.std(axis=-1)[:, 1:3] < 3.0).all()
    assert (pol.std(axis=-1)[:, 3] == 0.0).all()


def test_pointsource():


    cr = pointsource.CombinedPointSources()