|
2 | 2 |
|
3 | 3 | from phoebe.parameters import * |
4 | 4 | from phoebe.parameters import constraint |
5 | | -from phoebe.features.dataset_features import * |
| 5 | +from phoebe.features.component_features import Spot |
| 6 | +from phoebe.features.dataset_features import RVOffset |
6 | 7 | from phoebe import u |
7 | 8 | from phoebe import conf |
8 | 9 |
|
|
12 | 13 |
|
13 | 14 | ### NOTE: if creating new parameters, add to the _forbidden_labels list in parameters.py |
14 | 15 |
|
15 | | -_allowed_components = {'spot': ['star', 'envelope'], |
16 | | - 'rv_offset': [None], |
17 | | - 'pulsation': ['star', 'envelope'], |
| 16 | +_allowed_components = {'pulsation': ['star', 'envelope'], |
18 | 17 | 'gp_sklearn': [None], |
19 | | - 'gp_celerite2': [None], |
20 | | - 'gaussian_process': [None]} |
| 18 | + 'gp_celerite2': [None]} |
21 | 19 |
|
22 | | -_allowed_datasets = {'spot': [None], |
23 | | - 'rv_offset': ['rv'], |
24 | | - 'pulsation': [None], |
| 20 | +_allowed_datasets = {'pulsation': [None], |
25 | 21 | 'gp_sklearn': ['lc', 'rv', 'lp'], |
26 | | - 'gp_celerite2': ['lc', 'rv', 'lp'], |
27 | | - 'gaussian_process': ['lc', 'rv', 'lp']} |
| 22 | + 'gp_celerite2': ['lc', 'rv', 'lp']} |
| 23 | + |
| 24 | +_feature_classes = {} |
28 | 25 |
|
29 | 26 | def _component_allowed_for_feature(feature_kind, component_kind): |
30 | 27 | return component_kind in getattr(feature_kind, 'allowed_component_kinds', _allowed_components.get(feature_kind, [])) |
31 | 28 |
|
32 | 29 | def _dataset_allowed_for_feature(feature_kind, dataset_kind): |
33 | 30 | return dataset_kind in getattr(feature_kind, 'allowed_dataset_kinds', _allowed_datasets.get(feature_kind, [])) |
34 | 31 |
|
35 | | -def _register(feature_cls, name): |
36 | | - globals()[name] = feature_cls.get_parameters |
| 32 | +def _register_feature(feature_cls, name): |
| 33 | + globals()[name] = feature_cls.create_feature_parameters |
37 | 34 | _allowed_components[name] = getattr(feature_cls, 'allowed_component_kinds', []) |
38 | 35 | _allowed_datasets[name] = getattr(feature_cls, 'allowed_dataset_kinds', []) |
| 36 | + _feature_classes[name] = feature_cls |
39 | 37 |
|
40 | | -def spot(feature, **kwargs): |
41 | | - """ |
42 | | - Create a <phoebe.parameters.ParameterSet> for a spot feature. |
43 | | -
|
44 | | - Generally, this will be used as an input to the kind argument in |
45 | | - <phoebe.frontend.bundle.Bundle.add_feature>. If attaching through |
46 | | - <phoebe.frontend.bundle.Bundle.add_feature>, all `**kwargs` will be |
47 | | - passed on to set the values as described in the arguments below. Alternatively, |
48 | | - see <phoebe.parameters.ParameterSet.set_value> to set/change the values |
49 | | - after creating the Parameters. |
50 | | -
|
51 | | - Allowed to attach to: |
52 | | - * components with kind: star |
53 | | - * datasets: not allowed |
54 | | -
|
55 | | - Arguments |
56 | | - ---------- |
57 | | - * `colat` (float/quantity, optional): colatitude of the center of the spot |
58 | | - wrt spin axis. |
59 | | - * `long` (float/quantity, optional): longitude of the center of the spot wrt |
60 | | - spin axis. |
61 | | - * `radius` (float/quantity, optional): angular radius of the spot. |
62 | | - * `relteff` (float/quantity, optional): temperature of the spot relative |
63 | | - to the intrinsic temperature. |
64 | | -
|
65 | | - Returns |
66 | | - -------- |
67 | | - * (<phoebe.parameters.ParameterSet>, list): ParameterSet of all newly created |
68 | | - <phoebe.parameters.Parameter> objects and a list of all necessary |
69 | | - constraints. |
70 | | - """ |
71 | 38 |
|
72 | | - params = [] |
73 | | - |
74 | | - params += [FloatParameter(qualifier="colat", value=kwargs.get('colat', 0.0), default_unit=u.deg, description='Colatitude of the center of the spot wrt spin axis')] |
75 | | - params += [FloatParameter(qualifier="long", value=kwargs.get('long', 0.0), default_unit=u.deg, description='Longitude of the center of the spot wrt spin axis')] |
76 | | - params += [FloatParameter(qualifier='radius', value=kwargs.get('radius', 1.0), default_unit=u.deg, description='Angular radius of the spot')] |
77 | | - # params += [FloatParameter(qualifier='area', value=kwargs.get('area', 1.0), default_unit=u.solRad, description='Surface area of the spot')] |
78 | | - |
79 | | - params += [FloatParameter(qualifier='relteff', value=kwargs.get('relteff', 1.0), limits=(0.,None), default_unit=u.dimensionless_unscaled, description='Temperature of the spot relative to the intrinsic temperature')] |
80 | | - # params += [FloatParameter(qualifier='teff', value=kwargs.get('teff', 10000), default_unit=u.K, description='Temperature of the spot')] |
81 | | - |
82 | | - constraints = [] |
83 | | - |
84 | | - return ParameterSet(params), constraints |
85 | | - |
86 | | -def rv_offset(feature, **kwargs): |
87 | | - """ |
88 | | - Create a <phoebe.parameters.ParameterSet> for an rvoffset feature. |
89 | | -
|
90 | | - Generally, this will be used as an input to the kind argument in |
91 | | - <phoebe.frontend.bundle.Bundle.add_feature>. If attaching through |
92 | | - <phoebe.frontend.bundle.Bundle.add_feature>, all `**kwargs` will be |
93 | | - passed on to set the values as described in the arguments below. Alternatively, |
94 | | - see <phoebe.parameters.ParameterSet.set_value> to set/change the values |
95 | | - after creating the Parameters. |
96 | | -
|
97 | | - Allowed to attach to: |
98 | | - * datasets: rv |
99 | | - """ |
100 | | - params = [] |
101 | | - |
102 | | - params += [FloatParameter(qualifier='rv_offset', copy_for={'kind': ['star'], 'component': '*'}, component='_default', value=kwargs.get('rv_offset', 0.0), default_unit=u.km/u.s, description='Per-component offset to add to synthetic RVs (i.e. for hot stars)')] |
103 | | - |
104 | | - return ParameterSet(params), [] |
| 39 | +_register_feature(Spot, 'spot') |
| 40 | +_register_feature(RVOffset, 'rv_offset') |
105 | 41 |
|
106 | 42 |
|
107 | 43 | def gp_sklearn(feature, **kwargs): |
@@ -270,13 +206,3 @@ def gp_celerite2(feature, **kwargs): |
270 | 206 | constraints = [] |
271 | 207 |
|
272 | 208 | return ParameterSet(params), constraints |
273 | | - |
274 | | -def gaussian_process(feature, **kwargs): |
275 | | - """ |
276 | | - Deprecated (will be removed in PHOEBE 2.5) |
277 | | -
|
278 | | - Support for celerite gaussian processes has been removed. This is now an |
279 | | - alias to <phoebe.parameters.feature.gp_celerite2>. |
280 | | - """ |
281 | | - logger.warning("gaussian_process is deprecated. Use gp_celerite2 instead.") |
282 | | - return gp_celerite2(feature, **kwargs) |
0 commit comments