-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmodels_registry.py
43 lines (36 loc) · 1.88 KB
/
models_registry.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# this should (perhaps?) be replaced by introspection from
# the astropy.modeling.Model registry. For now, we directly
# store hard-coded instances.
# import astropy.modeling.functional_models as models
import astropy.modeling.models as models
registry = {
'Box1D' : models.Box1D(1.0, 1.0, 1.0),
'Gaussian1D': models.Gaussian1D(1.0, 1.0, 1.0),
'GaussianAbsorption1D': models.GaussianAbsorption1D(1.0, 1.0, 1.0),
'Lorentz1D': models.Lorentz1D(1.0, 1.0, 1.0),
'MexicanHat1D': models.MexicanHat1D(1.0, 1.0, 1.0),
'Trapezoid1D': models.Trapezoid1D(1.0, 1.0, 1.0, 1.0),
'ExponentialCutoffPowerLaw1D':models.ExponentialCutoffPowerLaw1D(1.0, 1.0, 1.0, 1.0),
'BrokenPowerLaw1D': models.BrokenPowerLaw1D(1.0, 1.0, 1.0, 1.0),
'LogParabola1D' : models.LogParabola1D(1.0, 1.0, 1.0, 1.0),
'PowerLaw1D' : models.PowerLaw1D(1.0, 1.0, 1.0),
'Linear1D': models.Linear1D(1.0, 0.0),
'Const1D': models.Const1D(0.0),
'Redshift': models.Redshift(0.0),
'Scale': models.Scale(1.0),
'Shift': models.Shift(0.0),
'Sine1D' : models.Sine1D(1.0, 1.0),
'Chebyshev1D': models.Chebyshev1D(1),
'Legendre1D' : models.Legendre1D(1),
'Polynomial1D' : models.Polynomial1D(1),
}
def get_component_name(function):
# there must be a better way of getting the class' name......
class_string = str(function.__class__)
return class_string.split('\'>')[0].split(".")[-1]
def get_component_path(function):
class_string = str(function.__class__)
module_path = class_string.split('\'')[1]
index = module_path.rfind('.')
module_path = module_path[:index]
return module_path