Skip to content

Commit

Permalink
Add angular-diameter distance to CLI also
Browse files Browse the repository at this point in the history
  • Loading branch information
lzkelley committed Apr 13, 2024
1 parent 6577aee commit eadfc1a
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 3 deletions.
2 changes: 1 addition & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ To-Do

Current
-------
- Added redshift to comoving and luminosity distance methods.
- Added redshift to comoving-, luminosity-, and angular-diameter- distance methods.
- Added differential volume calculation (dVc/dz)


Expand Down
21 changes: 19 additions & 2 deletions cosmopy/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,19 +71,34 @@ def calc_basic(cosmo, sets):
elif sets.dc is not None:
dcom = parse_input(sets.dc, U_CM)
redz = cosmo.dcom_to_z(dcom.cgs.value)
# Calculate luminosity-distance manually
# Calculate distances manually
dlum = dcom * (1.0 + redz)
dang = dcom / (1.0 + redz)
results['dc'] = dcom
results['dl'] = dlum
results['da'] = dang

# Luminosity Distance
elif sets.dl is not None:
dlum = parse_input(sets.dl, U_CM)
redz = cosmo.dlum_to_z(dlum.cgs.value)
# Calculate comoving-distance manually
# Calculate distances manually
dcom = dlum / (1.0 + redz)
dang = dlum / (1.0 + redz)**2
results['dc'] = dcom
results['dl'] = dlum
results['da'] = dang

# Angular-diameter Distance
elif sets.da is not None:
dang = parse_input(sets.da, U_CM)
redz = cosmo.dang_to_z(dang.cgs.value)
# Calculate distances manually
dcom = dang * (1.0 + redz)
dlum = dcom * (1.0 + redz)
results['dc'] = dcom
results['dl'] = dlum
results['da'] = dang

# No arguments set, raise error
else:
Expand Down Expand Up @@ -310,6 +325,8 @@ def parse_args(args):
help='target coming distance D_C')
parser.add_argument('-dl', '-ld', default=None,
help='target luminosity distance D_L')
parser.add_argument('-da', '-ad', default=None,
help='target angular-diameter distance D_a')
parser.add_argument('-tl', '-lt', default=None,
help='target look-back time T_L')
parser.add_argument('-ta', '-at', default=None,
Expand Down
3 changes: 3 additions & 0 deletions cosmopy/tests/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,9 @@ def compare(aa):
args = ['dc', '0.4231241Gpc']
compare(args)

args = ['da', '384.4342Mpc']
compare(args)

return

def test__calc_basic(self):
Expand Down

0 comments on commit eadfc1a

Please sign in to comment.