How to use the uncertainties.std_dev 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 NMGRL / pychron / pychron / pipeline / editors / diff_editor.py View on Github external
rvalue=nominal_value(ri)))
                vs.append(
                    Value(name=func(u'Total {}'.format(PLUSMINUS_ONE_SIGMA)), lvalue=std_dev(i), rvalue=std_dev(ri)))

            vs.append(Value(name=func('N'), lvalue=iso.n, rvalue=riso.n))
            vs.append(Value(name=func('fN'), lvalue=iso.fn, rvalue=riso.fn))

            vs.append(StrValue(name=func('Fit'), lvalue=iso.fit.lower(), rvalue=riso.fit.lower()))
            vs.append(StrValue(name=func('Filter'), lvalue=filter_str(iso), rvalue=filter_str(riso)))
            vs.append(Value(name=func('Filter Iter'), lvalue=iso.filter_outliers_dict.get('iterations', 0),
                            rvalue=riso.filter_outliers_dict.get('iterations', 0)))
            vs.append(Value(name=func('Filter SD'), lvalue=iso.filter_outliers_dict.get('std_devs', 0),
                            rvalue=riso.filter_outliers_dict.get('std_devs', 0)))
            vs.append(Value(name=func('IC'), lvalue=nominal_value(iso.ic_factor),
                            rvalue=nominal_value(riso.ic_factor)))
            vs.append(Value(name=func(u'IC {}'.format(PLUSMINUS_ONE_SIGMA)), lvalue=std_dev(iso.ic_factor),
                            rvalue=std_dev(riso.ic_factor)))
        for a in isotopes:
            func = pfunc(a)
            baseline = left.isotopes[a].baseline
            rbaseline = right.isotopes[a].baseline

            vs.append(Value(name=func('Bs'), lvalue=baseline.value, rvalue=rbaseline.value))
            vs.append(Value(name=func(u'Bs {}'.format(PLUSMINUS_ONE_SIGMA)), lvalue=baseline.error,
                            rvalue=rbaseline.error))
            vs.append(Value(name=func('Bs N'), lvalue=baseline.n, rvalue=rbaseline.n))
            vs.append(Value(name=func('Bs fN'), lvalue=baseline.fn, rvalue=rbaseline.fn))

            fv = StrValue(name=func('Bs Filter'), lvalue=filter_str(iso), rvalue=filter_str(iso))
            vs.append(fv)
            if not (fv.lvalue == 'no' and fv.rvalue == 'no'):
                vs.append(Value(name=func('Bs Filter Iter'), lvalue=baseline.filter_outliers_dict.get('iterations'),
github NMGRL / pychron / pychron / processing / analyses / view / adapters.py View on Github external
def _get_error_text(self, *args, **kw):
        v = self.item.get_intensity()
        return self._format(self.item, std_dev(v), 'error')
github NMGRL / pychron / pychron / pipeline / plot / plotter / spectrum.py View on Github external
def _build_integrated_age_label(self, tga, n):
        txt = 'NaN'
        if not isnan(nominal_value(tga)):
            age, error = nominal_value(tga.nominal_value), std_dev(tga)

            error *= self.options.nsigma
            txt = self._build_label_text(age, error, n, sig_figs=self.options.integrated_sig_figs)

        return u'Integrated Age= {}'.format(txt)
github NMGRL / pychron / pychron / geochron / geochron_service.py View on Github external
def _add_parameters(self, sample_elem, analysis_group):
        param_elem = etree.SubElement(sample_elem, 'Parameters')

        ref = analysis_group.analyses[0]

        param_elem.attrib['standardName'] = ref.standard_name
        param_elem.attrib['standardAge'] = str(nominal_value(ref.standard_age))
        param_elem.attrib['standardAgeSigma'] = str(std_dev(ref.standard_age))
        param_elem.attrib['standardMaterial'] = ref.standard_material

        param_elem.attrib['decayConstant40ArTotal'] = str(nominal_value(ref.arar_constants.lambda_k))
        param_elem.attrib['decayConstant40ArTotalSigma'] = str(std_dev(ref.arar_constants.lambda_k))
        param_elem.attrib['jValue'] = str(nominal_value(ref.j))
        param_elem.attrib['jValueSigma'] = str(std_dev(ref.j))

        # for attr, iattr, required in PARAMETER_ATTRS:
        #     if
        #
        #
        #     val = self._get_value(analysis_group, attr, iattr, required)
        #     if val is not None:
        #         param_elem.attrib[attr] = val

        self._add_experiment(param_elem, analysis_group)
github NMGRL / pychron / pychron / processing / analyses / view / adapters.py View on Github external
def _error(self, v):
        return floatfmt(std_dev(v), n=self.sig_figs)
github NMGRL / pychron / pychron / pipeline / editors / flux_visualization_editor.py View on Github external
# plot mean value
                    # l1 = g.add_horizontal_rule(yy, color='black', line_style='solid', plotid=idx)
                    # l2 = g.add_horizontal_rule(yy + ye, plotid=idx)
                    # l3 = g.add_horizontal_rule(yy - ye, plotid=idx)
                    # rs = (l1, l2, l3)
                    # d = {idx: rs}
                    # if hasattr(g, 'rules'):
                    #     g.rules.update(d)
                    # else:
                    #     g.rules = d

                    # plot individual analyses
                    fs = [a.model_j(monage, lk) * scale for a in ais]
                    fs = sorted(fs)
                    iys = array([nominal_value(fi) for fi in fs])
                    ies = array([std_dev(fi) for fi in fs])

                    if self.plotter_options.use_weighted_fit:
                        fit = 'weighted mean'
                    else:
                        fit = 'average'

                    ek = self.plotter_options.error_kind
                    if ek == MSEM:
                        ek = 'msem'

                    fit = '{}_{}'.format(fit, ek)

                    p_, s, l_ = g.new_series(linspace(0, n - 1, n), iys, yerror=ies, type='scatter',
                                             fit=fit,
                                             add_point_inspector=False,
                                             add_inspector=False,
github NMGRL / pychron / pychron / pipeline / tables / xlsx_table_writer.py View on Github external
# write total k2o
            v = floatfmt(nominal_value(group.total_k2o), k2o_col.nsigfigs)
            sh.write_rich_string(self._current_row, k2o_idx, 'K', self._subscript, '2', 'O wt. %={}'.format(v), fmt)

            self._current_row += 1

        t = group.arar_constants.atm4036
        trapped_value, trapped_error = nominal_value(t), std_dev(t)
        if self._options.include_isochron_age:
            sh.write_string(self._current_row, start_col, u'Isochron Age {}'.format(pmsigma),
                            fmt)

            iage = group.scaled_age(group.isochron_age, self._options.age_units)
            sh.write_number(self._current_row, idx, nominal_value(iage), nfmt)
            sh.write_number(self._current_row, idx + 1, std_dev(iage) * nsigma, nfmt)

            mt = group.isochron_mswd()
            try:
                trapped = group.isochron_4036
                trapped_value, trapped_error = nominal_value(trapped), std_dev(trapped)
            except ZeroDivisionError:
                trapped_value, trapped_error = 'NaN', 'NaN'

            sh.write_string(self._current_row, idx + 3, format_mswd(mt), fmt)

            self._current_row += 1

        if self._options.include_trapped_ratio:
            nsigma = self._options.asummary_trapped_ratio_nsigma

            sh.write_rich_string(self._current_row, start_col,
github NMGRL / pychron / pychron / processing / arar_constants.py View on Github external
def atm3836_e(self):
        return std_dev(self.atm3836)
github NMGRL / pychron / pychron / processing / tasks / recall / edit_analysis_view.py View on Github external
isos = self.editor.model.isotopes
        ns = []
        bks = []
        bs = []
        ics = []
        dets = []
        for k in self.editor.model.isotope_keys:
            iso = isos[k]
            iso.use_static = True
            ns.append(iso)
            bks.append(iso.blank)
            bs.append(iso.baseline)

            det = iso.detector
            if not det in dets:
                v, e = nominal_value(iso.ic_factor), std_dev(iso.ic_factor)
                ics.append(ICFactor(value=v, error=e,
                                    ovalue=v, oerror=e,
                                    name=det))
            dets.append(det)

        self.isotopes = ns
        self.blanks = bks
        self.baselines = bs
        self.ic_factors = ics
github NMGRL / pychron / pychron / geochron / geochron_service.py View on Github external
measurement_elem.attrib[attr] = val

        measurement_elem.attrib['interceptUnit'] = 'fA'
        measurement_elem.attrib['blankUnit'] = 'fA'
        for k in ('36', '37', '38', '39', '40'):
            iso = analysis.get_isotope('Ar{}'.format(k))
            v = iso.get_baseline_corrected_value()
            tag = 'intercept{}Ar'.format(k)
            measurement_elem.attrib[tag] = str(nominal_value(v))
            measurement_elem.attrib['{}Sigma'.format(tag)] = str(std_dev(v))
            measurement_elem.attrib['{}RegressionType'.format(tag)] = iso.fit

            v = iso.blank.uvalue
            tag = 'blank{}Ar'.format(k)
            measurement_elem.attrib[tag] = str(nominal_value(v))
            measurement_elem.attrib['{}Sigma'.format(tag)] = str(std_dev(v))