# Path: cora/core/maps.py
# class Map2d(object):
# class Map3d(Map2d):
# class Sky3d(Map3d):
#     def like_map(cls, mapobj, *args, **kwargs):
#     def _width_array(self):
#     def _num_array(self):
#     def x_pixels(self):
#     def y_pixels(self):
#     def nside(self):
#     def nside(self, value):
#     def like_map(cls, mapobj, *args, **kwargs):
#     def _width_array(self):
#     def _num_array(self):
#     def nu_num(self):
#     def nu_num(self, num):
#     def frequencies(self):
#     def frequencies(self, freq):
#     def like_kiyo_map(cls, mapobj, *args, **kwargs):
#     def angular_powerspectrum(self, l, nu1, nu2):
#     def mean_nu(self, freq):
#     def getfield(self):
#     def getsky(self):
#     def getpolsky(self):
#     def getalms(self, lmax):
# 
# Path: cora/util/units.py
# G = 6.6742e-11
# 
# Path: cora/foreground/poisson.py
# def homogeneous_process(t, rate):
# def test_hpp():
# def inhomogeneous_process(t, rate):
#     def _inhomogeneous_process_wk(t, rate):
# def test_ipp():
#     def rate(t):
# def inhomogeneous_process_approx(t, rate):
# 
# Path: cora/foreground/gaussianfg.py
# class ForegroundMap(maps.Sky3d):
# class ForegroundSCK(ForegroundMap):
# class Synchrotron(ForegroundSCK):
# class ExtraGalacticFreeFree(ForegroundSCK):
# class GalacticFreeFree(ForegroundSCK):
# class PointSources(ForegroundSCK):
#     def angular_ps(self, l):
#     def frequency_covariance(self, nu1, nu2):
#     def angular_powerspectrum(self, l, nu1, nu2):
#     def generate_weight(self, regen=False):
#     def getfield(self):
#     def angular_ps(self, larray):
#     def frequency_covariance(self, nu1, nu2):
#     def frequency_variance(self, nu):
#     def frequency_correlation(self, nu1, nu2):
#     def frequency_correlation_dlog(self, dlognu):
#     def angular_correlation(self, tarray):
#             def cf(theta):
#     A = 7.00e-4
#     A = 1.40e-8
#     A = 8.80e-8
#     A = 5.70e-5


from os.path import join, dirname
from scipy.optimize import newton
from cora.core import maps
from cora.util import units
from cora.foreground import poisson as ps
from cora.foreground import gaussianfg
import numpy as np
import numpy.random as rnd
import healpy
        -------
        sources : ndarray
            The fluxes of the sources in the population.
        """

        flux_max = self.flux_max

        # If we don't have a maximum flux set, set one by calculating
        # the flux at which there is only a very small probability of
        # there being a brighter source.
        #
        # For a power law with dN/dS \propto S^(1-\beta), this is the
        # flux at which the probability of a source P(>S_max) < 0.05/
        # \beta
        if flux_max == None:
            ratelog = lambda s: (s * area * self.source_count(s) - 5e-2)
            flux_max = newton(ratelog, self.flux_min)
            print("Using maximum flux: %e Jy" % flux_max)

        # Generate realisation by creating a rate and treating like an
        # inhomogenous Poisson process.
        # rate = lambda s: area*self.source_count(self.flux_min+s)
        # fluxes = self.flux_min + ps.inhomogeneous_process_approx(flux_max-self.flux_min, rate)
        rate = (
            lambda s: self.flux_min
            * np.exp(s)
            * area
            * self.source_count(self.flux_min * np.exp(s))
        )
        fluxes = self.flux_min * np.exp(

# Path: cora/core/maps.py
# class Map2d(object):
# class Map3d(Map2d):
# class Sky3d(Map3d):
#     def like_map(cls, mapobj, *args, **kwargs):
#     def _width_array(self):
#     def _num_array(self):
#     def x_pixels(self):
#     def y_pixels(self):
#     def nside(self):
#     def nside(self, value):
#     def like_map(cls, mapobj, *args, **kwargs):
#     def _width_array(self):
#     def _num_array(self):
#     def nu_num(self):
#     def nu_num(self, num):
#     def frequencies(self):
#     def frequencies(self, freq):
#     def like_kiyo_map(cls, mapobj, *args, **kwargs):
#     def angular_powerspectrum(self, l, nu1, nu2):
#     def mean_nu(self, freq):
#     def getfield(self):
#     def getsky(self):
#     def getpolsky(self):
#     def getalms(self, lmax):
# 
# Path: cora/util/units.py
# G = 6.6742e-11
# 
# Path: cora/foreground/poisson.py
# def homogeneous_process(t, rate):
# def test_hpp():
# def inhomogeneous_process(t, rate):
#     def _inhomogeneous_process_wk(t, rate):
# def test_ipp():
#     def rate(t):
# def inhomogeneous_process_approx(t, rate):
# 
# Path: cora/foreground/gaussianfg.py
# class ForegroundMap(maps.Sky3d):
# class ForegroundSCK(ForegroundMap):
# class Synchrotron(ForegroundSCK):
# class ExtraGalacticFreeFree(ForegroundSCK):
# class GalacticFreeFree(ForegroundSCK):
# class PointSources(ForegroundSCK):
#     def angular_ps(self, l):
#     def frequency_covariance(self, nu1, nu2):
#     def angular_powerspectrum(self, l, nu1, nu2):
#     def generate_weight(self, regen=False):
#     def getfield(self):
#     def angular_ps(self, larray):
#     def frequency_covariance(self, nu1, nu2):
#     def frequency_variance(self, nu):
#     def frequency_correlation(self, nu1, nu2):
#     def frequency_correlation_dlog(self, dlognu):
#     def angular_correlation(self, tarray):
#             def cf(theta):
#     A = 7.00e-4
#     A = 1.40e-8
#     A = 8.80e-8
#     A = 5.70e-5


# Path: cora/foreground/pointsource.py
from os.path import join, dirname
from scipy.optimize import newton
from cora.core import maps
from cora.util import units
from cora.foreground import poisson as ps
from cora.foreground import gaussianfg
import numpy as np
import numpy.random as rnd
import healpy

        -------
        sources : ndarray
            The fluxes of the sources in the population.
        """

        flux_max = self.flux_max

        # If we don't have a maximum flux set, set one by calculating
        # the flux at which there is only a very small probability of
        # there being a brighter source.
        #
        # For a power law with dN/dS \propto S^(1-\beta), this is the
        # flux at which the probability of a source P(>S_max) < 0.05/
        # \beta
        if flux_max == None:
            ratelog = lambda s: (s * area * self.source_count(s) - 5e-2)
            flux_max = newton(ratelog, self.flux_min)
            print("Using maximum flux: %e Jy" % flux_max)

        # Generate realisation by creating a rate and treating like an
        # inhomogenous Poisson process.
        # rate = lambda s: area*self.source_count(self.flux_min+s)
        # fluxes = self.flux_min + ps.inhomogeneous_process_approx(flux_max-self.flux_min, rate)
        rate = (
            lambda s: self.flux_min
            * np.exp(s)
            * area
            * self.source_count(self.flux_min * np.exp(s))
        )
        fluxes = self.flux_min * np.exp(

            ps.inhomogeneous_process_approx(np.log(flux_max / self.flux_min), rate)