Skip to content

Commit fe6fdac

Browse files
nhmcastrofrog
authored andcommitted
Adding some tests
1 parent f70b84b commit fe6fdac

3 files changed

Lines changed: 22 additions & 2 deletions

File tree

astropy/cosmology/cosmology.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,12 +165,12 @@ def dm(self, z):
165165
else:
166166
return dh / sqrtOk * sin(sqrtOk * dc / dh)
167167

168-
def Da(self, z):
168+
def da(self, z):
169169
""" Angular diameter distance in metres. Ratio of an object's
170170
physical transverse size to its angular size in radians."""
171171
return self.dm(z) / (1. + z)
172172

173-
def Da2(self, z1, z2):
173+
def da2(self, z1, z2):
174174
""" Angular diameter distance in metres between objects at 2
175175
redshifts. Useful for gravitational lensing."""
176176
# does not work for negative curvature

astropy/cosmology/tests/__init__.py

Whitespace-only changes.
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Licensed under a 3-clause BSD style license - see LICENSE.rst
2+
3+
from .. import cosmology
4+
5+
def test_cosmology():
6+
cosmo = cosmology.Cosmology(H0=70, Om=0.27 ,Ol=0.73)
7+
z = 1
8+
# Test values were taken from the following web cosmology
9+
# calculators on 27th Feb 2012:
10+
11+
# Wright: http://www.astro.ucla.edu/~wright/CosmoCalc.html
12+
# Kempner: http://www.kempner.net/cosmic.php
13+
# iCosmos: http://www.icosmos.co.uk/index.html
14+
15+
# The order of values below is Wright, Kempner, iCosmos'
16+
assert np.allclose(cosmo.dc(z), [3364.5, 3364.8, 3364.7988], rtol=1e-4)
17+
assert np.allclose(cosmo.da(z), [1682.3, 1682.4, 1682.3994], rtol=1e-4)
18+
assert np.allclose(cosmo.dl(z), [6729.2, 6729.6, 6729.5976], rtol=1e-4)
19+
assert np.allclose(cosmo.tl(z), [7.841, 7.84178, 7.843], rtol=1e-3)
20+

0 commit comments

Comments
 (0)