Skip to content

Commit

Permalink
some cleanup and docstrings
Browse files Browse the repository at this point in the history
  • Loading branch information
rieder committed Apr 24, 2024
1 parent 9a6f097 commit 8cfafce
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 deletions.
5 changes: 4 additions & 1 deletion src/amuse/units/optparse.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@

"""
Overloaded option parser with unit support.
Now deprecated, standard argparse can be used instead.
"""

import optparse
import textwrap
Expand Down
20 changes: 15 additions & 5 deletions src/amuse/units/units.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,8 @@

# astronomical units
angstrom = named("angstrom", "angstrom", 1e-10 * m)
AU = named("astronomical unit", "au", 149597870691.0 * m)
au = named("astronomical unit", "au", 149597870691.0 * m)
AUd = named("au per day", "aud", 149597870691.0 * m / day)
aud = named("au per day", "aud", 149597870691.0 * m / day)
parsec = named("parsec", "parsec", au / numpy.tan(numpy.pi / (180 * 60 * 60)))
kpc = named("kilo parsec", "kpc", 10**3 * parsec)
Mpc = named("mega parsec", "Mpc", 10**6 * parsec)
Expand All @@ -61,17 +60,28 @@
# lightyear = named('light year', 'ly', c*julianyr)
LSun = named("solar luminosity", "LSun", 3.839e26 * W)
MSun = named("solar mass", "MSun", 1.98892e30 * kg)
MJupiter = named("jupiter mass", "MJupiter", 1.8987e27 * kg)
MEarth = named("earth mass", "MEarth", 5.9722e24 * kg)
RSun = named("solar radius", "RSun", 6.955e8 * m)
MJupiter = named("jupiter mass", "MJupiter", 1.8987e27 * kg)
RJupiter = named("jupiter radius", "RJupiter", 71492.0 * km)
MEarth = named("earth mass", "MEarth", 5.9722e24 * kg)
REarth = named("earth radius", "REarth", 6371.0088 * km) # IUGG mean radius
kyr = named("kilo year", "kyr", 1000 * yr)
myr = named("million year", "Myr", 1000000 * yr)
Myr = myr
gyr = named("giga (billion) year", "Gyr", 1000000000 * yr)

# alternatives, for compatibility
AU = au
AUd = aud
Myr = myr
Gyr = gyr
pc = parsec
Lsun = LSun
Msun = MSun
Rsun = RSun
Mjupiter = MJupiter
Rjupiter = RJupiter
Mearth = MEarth
Rearth = REarth

# cgs units
g = named("gram", "g", 1e-3 * kg)
Expand Down

0 comments on commit 8cfafce

Please sign in to comment.