def ecosw(b, orbit, solve_for=None, **kwargs):
    """
    Create a constraint for ecosw in an orbit.

    If 'ecosw' does not exist in the orbit, it will be created

    :parameter b: the :class:`phoebe.frontend.bundle.Bundle`
    :parameter str orbit: the label of the orbit in which this
        constraint should be built
    :parameter str solve_for:  if 'ecosw' should not be the derived/constrained
        parameter, provide which other parameter should be derived
        (ie 'ecc' or 'per0')
    :returns: lhs (Parameter), rhs (ConstraintParameter), args (list of arguments
        that were passed to this function)
    """
    orbit_ps = _get_system_ps(b, orbit)

    metawargs = orbit_ps.meta
    metawargs.pop('qualifier')

    ecosw_def = FloatParameter(qualifier='ecosw', value=0.0, default_unit=u.dimensionless_unscaled, limits=(-1.0,1.0), description='Eccentricity times cos of argument of periastron')
    ecosw, created = b.get_or_create('ecosw', ecosw_def, **metawargs)

    ecc = b.get_parameter(qualifier='ecc', **metawargs)
    per0 = b.get_parameter(qualifier='per0', **metawargs)

    if solve_for in [None, ecosw]:
        lhs = ecosw
        rhs = ecc * cos(per0)

    elif solve_for == ecc:
        lhs = ecc
        rhs = ecosw / cos(per0)
    elif solve_for == per0:
        lhs = per0
        #rhs = arccos(ecosw/ecc)
        rhs = ecosw2per0(ecc, ecosw)
    else:
        raise NotImplementedError

    return lhs, rhs, {'orbit': orbit}
Create a constraint for ecosw in an orbit.

    If 'ecosw' does not exist in the orbit, it will be created

    :parameter b: the :class:`phoebe.frontend.bundle.Bundle`
    :parameter str orbit: the label of the orbit in which this
        constraint should be built
    :parameter str solve_for:  if 'ecosw' should not be the derived/constrained
        parameter, provide which other parameter should be derived
        (ie 'ecc' or 'per0')
    :returns: lhs (Parameter), rhs (ConstraintParameter), args (list of arguments
        that were passed to this function)