Ejemplo n.º 1
0
def test_gaussian():
    p = gaussian()
    A = 1.0
    mu = 3.0
    sigma = 2.0
    x = np.linspace(-10.,10.,100)
    p.set_param_values(A=A, mu=mu, sigma=sigma)
    assert_allclose(p(x), A*np.exp(-0.5*((x-mu)/sigma)**2)/(np.sqrt(2.*np.pi)*sigma))
Ejemplo n.º 2
0
def test_gaussian():
    p = gaussian()
    A = 1.0
    mu = 3.0
    sigma = 2.0
    x = np.linspace(-10., 10., 100)
    p.set_param_values(A=A, mu=mu, sigma=sigma)
    assert_allclose(
        p(x),
        A * np.exp(-0.5 * ((x - mu) / sigma)**2) /
        (np.sqrt(2. * np.pi) * sigma))
Ejemplo n.º 3
0
def maxwellian_velocity(v="v", A="A", sigma="sigma"):
    return gaussian(x=v, A=A, sigma=sigma, mu=0)
Ejemplo n.º 4
0
from formulas.base import Formula1D, variable, Formula2D
from formulas.radial_profiles import NFW_density_profile
from formulas.general import gaussian
import yt.units as u
from numpy.testing import assert_allclose
import pytest

f_x = Formula1D("a*x**2+b","x",["a","b"])
a = 50.*u.km/u.s**2
b = 30.*u.km
f_x.set_param_values(a=a, b=b)

g_x = gaussian(x="x", A="A_x", mu="mu_x", sigma="sigma_x")
g_y = gaussian(x="y", A="A_y", mu="mu_y", sigma="sigma_y")
g_z = gaussian(x="z", A="A_z", mu="mu_z", sigma="sigma_z")
A_x = A_y = A_z = 1.0
mu_x = mu_y = mu_z = 30*u.s
sigma_x = sigma_y = sigma_z = 40*u.s
g_x.set_param_values(A_x=A_x, mu_x=mu_x, sigma_x=sigma_x)
g_y.set_param_values(A_y=A_y, mu_y=mu_y, sigma_y=sigma_y)
g_z.set_param_values(A_z=A_z, mu_z=mu_z, sigma_z=sigma_z)

g_xy = g_x*g_y
g_xyz = g_xy*g_z

x = 60.*u.s
y = 25.*u.s
z = -10.*u.s

def test_unitless():
    assert_allclose(f_x(x).v, f_x.unitless()(x.v))
Ejemplo n.º 5
0
from formulas.base import Formula1D, variable, Formula2D
from formulas.radial_profiles import NFW_density_profile
from formulas.general import gaussian
import yt.units as u
from numpy.testing import assert_allclose
import pytest

f_x = Formula1D("a*x**2+b", "x", ["a", "b"])
a = 50. * u.km / u.s**2
b = 30. * u.km
f_x.set_param_values(a=a, b=b)

g_x = gaussian(x="x", A="A_x", mu="mu_x", sigma="sigma_x")
g_y = gaussian(x="y", A="A_y", mu="mu_y", sigma="sigma_y")
g_z = gaussian(x="z", A="A_z", mu="mu_z", sigma="sigma_z")
A_x = A_y = A_z = 1.0
mu_x = mu_y = mu_z = 30 * u.s
sigma_x = sigma_y = sigma_z = 40 * u.s
g_x.set_param_values(A_x=A_x, mu_x=mu_x, sigma_x=sigma_x)
g_y.set_param_values(A_y=A_y, mu_y=mu_y, sigma_y=sigma_y)
g_z.set_param_values(A_z=A_z, mu_z=mu_z, sigma_z=sigma_z)

g_xy = g_x * g_y
g_xyz = g_xy * g_z

x = 60. * u.s
y = 25. * u.s
z = -10. * u.s


def test_unitless():