Skip to content

rv_offset constraints and "in_solar_units" #1108

@dmrowan

Description

@dmrowan

When adding a constraint to enforce that the RV offset for a given spectrograph is the same for the primary and secondary stars, the constraint fails to get created because of some issue in converting velocity to "solar units".

phoebe verison 2.4.22
astropy version 7.1.0

Here is an example with some fake data:

import phoebe

b = phoebe.default_binary()
b.set_value('vgamma@system', -20)

rv1_a = [18.306, -40.717, -73.144, -75.965, -62.179, -39.121, -10.159, 21.551, 46.925, 40.882]
rv2_a = [-63.778, 3.677, 40.736, 43.96, 28.205, 1.853, -31.247, -67.487, -96.486, -89.58]
rv1_b = [-11.915, -61.288, -77.195, -70.403, -51.399, -25.074, 5.82, 36.279, 50.146, 18.456]
rv2_b = [-28.918, 27.507, 45.687, 37.924, 16.206, -13.879, -49.187, -83.997, -99.845, -63.628]

b.add_dataset('rv', 
              rvs={'primary': rv1_a, 'secondary': rv2_a},
              sigmas={'primary': [0.1]*len(rv1_a), 'secondary': [0.1]*len(rv2_a)},
              dataset='rvs_a')

b.add_dataset('rv', 
              rvs={'primary': rv1_b, 'secondary': rv2_b},
              sigmas={'primary': [0.1]*len(rv1_b), 'secondary': [0.1]*len(rv2_b)},
              dataset='rvs_b')

offset_guess = 0.2

b.set_value('rv_offset@primary@rvs_b', offset_guess)
b.set_value('rv_offset@secondary@rvs_b', offset_guess)

lhs = b.get_parameter('rv_offset@secondary@rvs_b')
rhs = b.get_parameter('rv_offset@primary@rvs_b')

b.add_constraint(lhs, rhs)

The error is

[ERROR] [bundle:run_constraint:7760]: Constraint 'rv_offset@secondary@rvs_b@rv@constraint' raised the following error while attempting to solve for 'rv_offset@secondary@rvs_b@rv@dataset'.  Consider flipping the constraint or changing the value of one of ['rv_offset@primary@rvs_b@rv@dataset', 'rv_offset@secondary@rvs_b@rv@dataset'] until the constraint succeeds.  Original error: cannot convert '0.2 km / s' with physical_type='speed/velocity' to solar units

See this discussion post for some more context: #1106

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions