How to use the exoplanet.units 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
"nonlinear parameters on the model.")

    if v_names and 'v0' not in pars:
        sigma_v = validate_sigma_v(sigma_v, poly_trend, v_names)

    with model:
        if 'K' not in pars:
            if sigma_K0 is None or P0 is None:
                raise ValueError("If using the default prior form on K, you "
                                 "must pass in a variance scale (sigma_K0) "
                                 "and a reference period (P0)")

            # Default prior on semi-amplitude: scales with period and
            # eccentricity such that it is flat with companion mass
            v_unit = sigma_K0.unit
            out_pars['K'] = xu.with_unit(FixedCompanionMass('K', P=P, e=e,
                                                            sigma_K0=sigma_K0,
                                                            P0=P0),
                                         v_unit)
        else:
            v_unit = getattr(pars['K'], xu.UNIT_ATTR_NAME, u.one)

        for i, name in enumerate(v_names):
            if name not in pars:
                # Default priors are independent gaussians
                # FIXME: make mean, mu_v, customizable
                out_pars[name] = xu.with_unit(
                    pm.Normal(name, 0.,
                              sigma_v[name].value),
                    sigma_v[name].unit)

    for k in pars.keys():
github adrn / thejoker / thejoker / prior.py View on Github external
# 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:
                raise ValueError("If you are using the default period prior, "
                                 "you must pass in both P_min and P_max to set "
                                 "the period prior domain.")
            out_pars['P'] = xu.with_unit(UniformLog('P',
                                                    P_min.value,
                                                    P_max.to_value(P_min.unit)),
                                         P_min.unit)

    for k in pars.keys():
        out_pars[k] = pars[k]