Skip to content

Commit 45bf037

Browse files
committed
cleanup units, split off stellar_type unit
1 parent f2270fe commit 45bf037

2 files changed

Lines changed: 41 additions & 49 deletions

File tree

src/amuse/units/stellar_types.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
from amuse.units.si import core
2+
3+
stellar_type = core.enumeration_unit(
4+
'stellar_type',
5+
'stellar_type',
6+
None,
7+
[
8+
"deeply or fully convective low mass MS star", # 0
9+
"Main Sequence star", # 1
10+
"Hertzsprung Gap", # 2
11+
"First Giant Branch", # 3
12+
"Core Helium Burning", # 4
13+
"First Asymptotic Giant Branch", # 5
14+
"Second Asymptotic Giant Branch", # 6
15+
"Main Sequence Naked Helium star", # 7
16+
"Hertzsprung Gap Naked Helium star", # 8
17+
"Giant Branch Naked Helium star", # 9
18+
"Helium White Dwarf", # 10
19+
"Carbon/Oxygen White Dwarf", # 11
20+
"Oxygen/Neon White Dwarf", # 12
21+
"Neutron Star", # 13
22+
"Black Hole", # 14
23+
"Massless Supernova", # 15
24+
"Unknown stellar type", # 16
25+
"Pre-main-sequence Star", # 17
26+
"Planet", # 18
27+
"Brown Dwarf", # 19
28+
]
29+
)

src/amuse/units/units.py

Lines changed: 12 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -3,27 +3,20 @@
33
"""
44

55
import numpy
6-
from amuse.units.si import (
7-
named,
8-
s,
9-
m,
10-
kg,
11-
none,
12-
core,
13-
)
14-
from amuse.units.derivedsi import (
15-
km,
16-
V,
17-
W,
18-
J,
19-
Pa,
20-
rad,
21-
)
22-
from amuse.units.si import *
23-
from amuse.units.derivedsi import *
24-
from amuse.units import constants
6+
from . import constants
257
from . import quantities
268

9+
# The two imports below are to explicitly expose everything directly used in
10+
# this module.
11+
from .si import (named, s, m, kg, none, core, no_unit,)
12+
from .derivedsi import (km, V, W, J, Pa, rad,)
13+
14+
# importing * from si and derivedsi since we do want all of the units in these
15+
# modules, and we don't want to repeat everything here.
16+
from .si import *
17+
from .derivedsi import *
18+
from .stellar_types import stellar_type
19+
2720
# misc every day
2821
minute = named("minute", "min", 60.0 * s)
2922
hour = named("hour", "hr", 60.0 * minute)
@@ -57,7 +50,6 @@
5750
Mpc = named("mega parsec", "Mpc", 10**6 * parsec)
5851
Gpc = named("giga parsec", "Gpc", 10**9 * parsec)
5952
lightyear = named("light year", "ly", 9460730472580.8 * km)
60-
# lightyear = named('light year', 'ly', c*julianyr)
6153
LSun = named("solar luminosity", "LSun", 3.839e26 * W)
6254
MSun = named("solar mass", "MSun", 1.98892e30 * kg)
6355
RSun = named("solar radius", "RSun", 6.955e8 * m)
@@ -99,39 +91,10 @@
9991

10092
string = core.string_unit("string", "string")
10193

102-
stellar_type = core.enumeration_unit(
103-
"stellar_type",
104-
"stellar_type",
105-
None,
106-
[
107-
"deeply or fully convective low mass MS star", # 0
108-
"Main Sequence star", # 1
109-
"Hertzsprung Gap", # 2
110-
"First Giant Branch", # 3
111-
"Core Helium Burning", # 4
112-
"First Asymptotic Giant Branch", # 5
113-
"Second Asymptotic Giant Branch", # 6
114-
"Main Sequence Naked Helium star", # 7
115-
"Hertzsprung Gap Naked Helium star", # 8
116-
"Giant Branch Naked Helium star", # 9
117-
"Helium White Dwarf", # 10
118-
"Carbon/Oxygen White Dwarf", # 11
119-
"Oxygen/Neon White Dwarf", # 12
120-
"Neutron Star", # 13
121-
"Black Hole", # 14
122-
"Massless Supernova", # 15
123-
"Unknown stellar type", # 16
124-
"Pre-main-sequence Star", # 17
125-
"Planet", # 18
126-
"Brown Dwarf", # 19
127-
],
128-
)
129-
13094
# special unit for keys of particles
13195
object_key = core.key_unit("object_key", "key")
13296

13397
# angles
134-
# rad=named('radian','rad',m/m) (defined in derivedsi.py)
13598
pi = numpy.pi | rad
13699
rev = named("revolutions", "rev", (2 * numpy.pi) * rad)
137100
deg = named("degree", "deg", (numpy.pi / 180) * rad)

0 commit comments

Comments
 (0)