How to use the uncertainties.umath.log function in uncertainties

To help you get started, we’ve selected a few uncertainties 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 xraypy / xraylarch / lib / fitting / uncertainties / test_umath.py View on Github external
else:
            raise Exception('ValueError exception expected')
        try:
            umath.log(0)
        except ValueError( err_ufloat):
            assert err_math.args == err_ufloat.args
        else:
            raise Exception('ValueError exception expected')
        try:
            umath.log(uncertainties.ufloat((0, 0)))
        except ValueError( err_ufloat):
            assert err_math.args == err_ufloat.args
        else:
            raise Exception('ValueError exception expected')
        try:
            umath.log(uncertainties.ufloat((0, 1)))
        except ValueError( err_ufloat):
            assert err_math.args == err_ufloat.args
        else:
            raise Exception('ValueError exception expected')

    else:  # Python 3+

        # !!! The tests should be made to work with Python 3 too!
        pass
github NMGRL / pychron / pychron / processing / error_contrib.py View on Github external
# fraction of ar40err from 40signal, 36signal
    fe40_40, fe40_36 = acalc_fractional_error(s40, constants.atm4036_v * ar36, ar40)

    R = ar40 / ar39
    # fraction of R error from ar40 and ar39
    fe40, fe39 = mcalc_fractional_error(ar40, ar39, R)

#    JR.std_dev equals total error
    JR = J * R
    k = constants.lambda_k
    k.set_std_dev(0)
    IlambdaK = 1 / k
    M = JR + 1
#    print constants.lambda_k.std_dev() / constants.lambda_k.nominal_value
#    print IlambdaK.std_dev() / IlambdaK.nominal_value
    a = umath.log(M)
    c = IlambdaK * a

#    print IlambdaK, a
#    print c.nominal_value * ((IlambdaK.std_dev() / IlambdaK.nominal_value) ** 2 + (a.std_dev() / a.nominal_value) ** 2) ** 0.5
#    print c
    feLambdaK, feJR = mcalc_fractional_error(IlambdaK, a, c)
#    print feLambdaK, feJR, feLambdaK + feJR
#    af = (IlambdaK.std_dev() / IlambdaK.nominal_value) ** 2 * (M.std_dev() / M.nominal_value) ** 2

#    errLambdaK = a.std_dev() * feLambdaK
#    errJR = a.std_dev() * feJR

#    #fraction of JR from J and R
    Je, Re = mcalc_fractional_error(J, R, JR)
#    print Je, Re
    # fractional error from ar40. e40=F40+F36
github KeplerGO / lightkurve / lightkurve / seismology / stellar_estimators.py View on Github external
The log10 of the surface gravity of the star.
    """
    numax = u.Quantity(numax, u.microhertz).value
    teff = u.Quantity(teff, u.Kelvin).value

    if all(b is not None for b in [numax_err, teff_err]):
        numax_err = u.Quantity(numax_err, u.microhertz).value
        teff_err = u.Quantity(teff_err, u.Kelvin).value
        unumax = ufloat(numax, numax_err)
        uteff = ufloat(teff, teff_err)
    else:
        unumax = ufloat(numax, 0)
        uteff = ufloat(teff, 0)

    ug = G_SOL.value * (unumax / NUMAX_SOL) * (uteff / TEFF_SOL)**0.5
    ulogg = umath.log(ug, 10)

    result = SeismologyQuantity(ulogg.n * u.dex,
                                error=ulogg.s * u.dex,
                                name="logg",
                                method="Uncorrected Scaling Relations")
    return result
github NMGRL / pychron / pychron / processing / age_converter.py View on Github external
m = 1

        torig = self._original_total_decay_constant
        t = self._lambda_t

        r, ex, ex_orig = self._calculate_r(age)

        sr = torig * exp(torig * age * 1e6) * error * 1e6 / ex_orig

        r_mc = ones(self._n) * r
        sr_mc = ones(self._n) * sr
        # return age, error

        vr = r_mc + sr_mc * randn(self._n, m)

        age = umath.log(((t / self._lambda_ec) * self._f * r) + 1) / (t * 1e6)

        # linear error propagation

        e = self._linear_error_propagation(age * 1e6, r, sr)
        e *= 1e-6

        # tm, tme = self._monte_carlo_error_propagation()
        # tm *= 1e-6
        # tme *= 1e-6
        tm, tme = 0, 0
        return age, e, tm, tme
github NMGRL / pychron / pychron / processing / argon_calculations.py View on Github external
f = ufloat(f)

    if not lambda_k:
        if arar_constants is None:
            arar_constants = ArArConstants()
        lambda_k = arar_constants.lambda_k

    if arar_constants is None:
        arar_constants = ArArConstants()

    if not include_decay_error:
        lambda_k = nominal_value(lambda_k)
    try:

        # lambda is defined in years, so age is in years
        age = lambda_k ** -1 * umath.log(1 + j * f)

        return arar_constants.scale_age(age, current='a')
    except (ValueError, TypeError):
        return ufloat(0, 0)
github NMGRL / pychron / standalone_age_calculator.py View on Github external
def age_equation(j, R, scalar=1, include_decay_error=False, constants=None):
    if isinstance(j, (tuple, str)):
        j = ufloat(j)
    if isinstance(R, (tuple, str)):
        R = ufloat(R)
    if constants is None:
        from pychron.processing.constants import Constants

        constants = Constants()
    #    print constants.lambda_k, 'dec'
    if include_decay_error:
        age = (1 / constants.lambda_k) * umath.log(1 + j * R) / float(scalar)
    else:
        age = (1 / constants.lambda_k.nominal_value) * umath.log(1 + j * R) / float(scalar)
    return age
github NMGRL / pychron / standalone_age_calculator.py View on Github external
def age_equation(j, R, scalar=1, include_decay_error=False, constants=None):
    if isinstance(j, (tuple, str)):
        j = ufloat(j)
    if isinstance(R, (tuple, str)):
        R = ufloat(R)
    if constants is None:
        from pychron.processing.constants import Constants

        constants = Constants()
    #    print constants.lambda_k, 'dec'
    if include_decay_error:
        age = (1 / constants.lambda_k) * umath.log(1 + j * R) / float(scalar)
    else:
        age = (1 / constants.lambda_k.nominal_value) * umath.log(1 + j * R) / float(scalar)
    return age