How to use the exoplanet.units.with_unit function in exoplanet

To help you get started, we’ve selected a few exoplanet examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github adrn / thejoker / thejoker / prior.py View on Github external
pars['s'] = pars.get('s', s)
    else:
        if not hasattr(s, 'unit') or not s.unit.is_equivalent(u.km/u.s):
            raise u.UnitsError("Invalid unit for s: must be equivalent to km/s")

    # dictionary of parameters to return
    out_pars = dict()

    with model:
        # Set up the default priors for parameters with defaults

        # Note: we have to do it this way (as opposed to with .get(..., default)
        # because this can only get executed if the param is not already
        # defined, otherwise variables are defined twice in the model
        if 'e' not in pars:
            out_pars['e'] = xu.with_unit(Kipping13Global('e'),
                                         u.one)

        # If either omega or M0 is specified by user, default to U(0,2π)
        if 'omega' not in pars:
            out_pars['omega'] = xu.with_unit(Angle('omega'), u.rad)

        if 'M0' not in pars:
            out_pars['M0'] = xu.with_unit(Angle('M0'), u.rad)

        if 's' not in pars:
            out_pars['s'] = xu.with_unit(pm.Deterministic('s',
                                                          tt.constant(s.value)),
                                         s.unit)

        if 'P' not in pars:
            if P_min is None or P_max is None:
github dfm / exoplanet / exoplanet / orbits / keplerian.py View on Github external
# Parameters
        if m_planet_units is not None:
            warnings.warn(
                "The `m_planet_units` argument has been deprecated. "
                "Use `with_unit` instead.",
                DeprecationWarning,
            )
            m_planet = with_unit(m_planet, m_planet_units)
        if rho_star_units is not None:
            warnings.warn(
                "The `rho_star_units` argument has been deprecated. "
                "Use `with_unit` instead.",
                DeprecationWarning,
            )
            rho_star = with_unit(rho_star, rho_star_units)
        inputs = _get_consistent_inputs(
            a, period, rho_star, r_star, m_star, m_planet
        )
        self.a, self.period, self.rho_star, self.r_star, self.m_star, self.m_planet = (
            inputs
        )
        self.m_total = self.m_star + self.m_planet

        self.n = 2 * np.pi / self.period
        self.a_star = self.a * self.m_planet / self.m_total
        self.a_planet = -self.a * self.m_star / self.m_total

        self.K0 = self.n * self.a / self.m_total

        # Set up the contact points calculation
        if contact_points_kwargs is None: