Exemple #1
0
    def _plot_inverse_isochron(self, po, plot, pid):
        analyses = self.sorted_analyses
        plot.padding_left = 75

        refiso = analyses[0]

        self._ref_constants = refiso.arar_constants
        self._ref_j = refiso.j
        self._ref_age_scalar = refiso.arar_constants.age_scalar
        self._ref_age_units = refiso.arar_constants.age_units

        try:
            age, reg, data = calculate_isochron(analyses)
        except TypeError:
            return

        xs, ys, xerrs, yerrs = data
        self._cached_data = data
        self._cached_reg = reg
        self._age = age

        graph = self.graph
        graph.set_x_title('39Ar/40Ar')
        graph.set_y_title('36Ar/40Ar')

        graph.set_grid_traits(visible=False)
        graph.set_grid_traits(visible=False, grid='y')

        scatter, _p = graph.new_series(xs, ys,
                                       xerror=ArrayDataSource(data=xerrs),
                                       yerror=ArrayDataSource(data=yerrs),
                                       type='scatter',
                                       marker='circle',
                                       bind_id=self.group_id,
                                       #selection_marker_size=5,
                                       #selection_color='green',
                                       marker_size=2)
        #self._scatter = scatter
        graph.set_series_label('data{}'.format(self.group_id))

        eo = ErrorEllipseOverlay(component=scatter)
        scatter.overlays.append(eo)

        mi, ma = graph.get_x_limits()

        ma = max(ma, max(xs))
        mi = min(mi, min(xs))
        rxs = linspace(mi, ma)
        rys = reg.predict(rxs)

        graph.set_x_limits(min_=mi, max_=ma, pad='0.1')

        graph.new_series(rxs, rys, color=scatter.color)
        graph.set_series_label('fit{}'.format(self.group_id))

        if po.show_labels:
            self._add_point_labels(scatter)
        self._add_scatter_inspector(scatter)

        self._add_info(plot, reg, text_color=scatter.color)
Exemple #2
0
    def _calculate_isochron_age(self):
        args = calculate_isochron(list(self.clean_analyses()))
        if args:
            age = args[0]
            reg = args[1]
            v, e = age.nominal_value, age.std_dev
            e = self._modify_error(v, e, self.isochron_age_error_kind,
                                   mswd=reg.mswd)

            return ufloat(v, e)
Exemple #3
0
    def _make(self, ep):
        opt = ep.doc(0)
        db = self.db
        with db.session_ctx():
            ids = opt['identifiers']
            progress = self.open_progress(n=len(ids), close_at_end=False)

            editor = InverseIsochronEditor(processor=self)
            editor.plotter_options_manager.set_plotter_options('Default')
            p, _ = unique_path(
                os.path.join(paths.dissertation, 'data', 'minnabluff'),
                'compare_iso_spec')
            wfile = open(p, 'w')
            for i in ids:

                hist = db.get_interpreted_age_histories((i, ))[-1]

                li = db.get_labnumber(i)
                ans = self._get_analyses(li)
                if ans:
                    progress.change_message(
                        'Calculating isochron for {}'.format(i))

                    unks = self.make_analyses(ans,
                                              use_progress=False,
                                              use_cache=False)
                    age, reg, _ = calculate_isochron(unks)
                    # print self._calculate_intercept(reg)
                    iaage = hist.interpreted_age.age
                    iaerr = hist.interpreted_age.age_err

                    ii, ee = self._calculate_intercept(reg)
                    ee2 = 2 * ee * (reg.mswd**0.5 if reg.mswd > 1 else 1)
                    comp = 'EQ'
                    if ii - ee2 > 295.5:
                        comp = 'GT'
                    elif ii + ee2 < 295.5:
                        comp = 'LT'
                    t0 = 'Identifier:        {}'.format(li.identifier)
                    t00 = 'Sample:            {}'.format(li.sample.name)
                    t1 = 'InterpretedAge:    {}+/-{}'.format(iaage, iaerr)
                    t2 = 'IsochronAge:       {}'.format(age)
                    t3 = 'Dev:               {} ({:0.2f}%)'.format(
                        age - iaage, (age - iaage) / iaage * 100)
                    t4 = 'TrappedComponent:  {:0.2f}+/-{:0.3f}'.format(ii, ee)
                    t5 = 'TrappedComparison: {}'.format(comp)
                    t = '\n'.join((t0, t00, t1, t2, t3, t4, t5))
                    # print t
                    wfile.write(t + '\n---\n')
                    # editor.set_items(unks)
                    # editor.rebuild()
                    # print 'exception', editor.get_trapped_component()
            wfile.close()
            progress.close()
Exemple #4
0
    def _calculate_isochron_age(self):
        args = calculate_isochron(list(self.clean_analyses()))
        if args:
            age = args[0]
            reg = args[1]
            v, e = age.nominal_value, age.std_dev
            e = self._modify_error(v,
                                   e,
                                   self.isochron_age_error_kind,
                                   mswd=reg.mswd)

            return ufloat(v, e)
Exemple #5
0
    def _make(self, ep):
        opt = ep.doc(0)
        db = self.db
        with db.session_ctx():
            ids = opt['identifiers']
            progress = self.open_progress(n=len(ids), close_at_end=False)

            editor = InverseIsochronEditor(processor=self)
            editor.plotter_options_manager.set_plotter_options('Default')
            p, _ = unique_path(os.path.join(paths.dissertation, 'data', 'minnabluff'),
                               'compare_iso_spec')
            fp = open(p, 'w')
            for i in ids:

                hist = db.get_interpreted_age_histories((i,))[-1]

                li = db.get_labnumber(i)
                ans = self._get_analyses(li)
                if ans:
                    progress.change_message('Calculating isochron for {}'.format(i))

                    unks = self.make_analyses(ans,
                                              use_progress=False,
                                              use_cache=False)
                    age, reg, _ = calculate_isochron(unks)
                    # print self._calculate_intercept(reg)
                    iaage = hist.interpreted_age.age
                    iaerr = hist.interpreted_age.age_err

                    ii, ee = self._calculate_intercept(reg)
                    ee2 = 2 * ee * (reg.mswd ** 0.5 if reg.mswd > 1 else 1)
                    comp = 'EQ'
                    if ii - ee2 > 295.5:
                        comp = 'GT'
                    elif ii + ee2 < 295.5:
                        comp = 'LT'
                    t0 = 'Identifier:        {}'.format(li.identifier)
                    t00 = 'Sample:            {}'.format(li.sample.name)
                    t1 = 'InterpretedAge:    {}+/-{}'.format(iaage, iaerr)
                    t2 = 'IsochronAge:       {}'.format(age)
                    t3 = 'Dev:               {} ({:0.2f}%)'.format(age - iaage, (age - iaage) / iaage * 100)
                    t4 = 'TrappedComponent:  {:0.2f}+/-{:0.3f}'.format(ii, ee)
                    t5 = 'TrappedComparison: {}'.format(comp)
                    t = '\n'.join((t0, t00, t1, t2, t3, t4, t5))
                    # print t
                    fp.write(t + '\n---\n')
                    # editor.set_items(unks)
                    # editor.rebuild()
                    # print editor.get_trapped_component()
            fp.close()
            progress.close()
    def get_isochron_data(self, exclude_non_plateau=False):
        ans = [a for a in self.analyses if isinstance(a, ArArAge)]

        if exclude_non_plateau and hasattr(self, 'get_is_plateau_step'):

            def test(ai):
                a = ai.is_omitted()
                b = not self.get_is_plateau_step(ai)
                return a or b
        else:

            def test(ai):
                return ai.is_omitted()

        exclude = [i for i, x in enumerate(ans) if test(x)]
        if ans:
            return calculate_isochron(ans,
                                      self.isochron_age_error_kind,
                                      exclude=exclude)
Exemple #7
0
 def get_isochron_data(self):
     return calculate_isochron(list(self.clean_analyses()))
Exemple #8
0
    def _plot_inverse_isochron(self, po, plot, pid):
        analyses = self.sorted_analyses
        plot.padding_left = 75

        refiso = analyses[0]

        self._ref_constants = refiso.arar_constants
        self._ref_j = refiso.j
        self._ref_age_scalar = refiso.arar_constants.age_scalar
        self._ref_age_units = refiso.arar_constants.age_units

        try:
            age, reg, data = calculate_isochron(analyses)
        except TypeError:
            return

        xs, ys, xerrs, yerrs = data
        self._cached_data = data
        self._cached_reg = reg
        self._age = age

        graph = self.graph
        graph.set_x_title('39Ar/40Ar')
        graph.set_y_title('36Ar/40Ar')

        graph.set_grid_traits(visible=False)
        graph.set_grid_traits(visible=False, grid='y')

        scatter, _p = graph.new_series(
            xs,
            ys,
            xerror=ArrayDataSource(data=xerrs),
            yerror=ArrayDataSource(data=yerrs),
            type='scatter',
            marker='circle',
            bind_id=self.group_id,
            #selection_marker_size=5,
            #selection_color='green',
            marker_size=2)
        #self._scatter = scatter
        graph.set_series_label('data{}'.format(self.group_id))

        eo = ErrorEllipseOverlay(component=scatter)
        scatter.overlays.append(eo)

        mi, ma = graph.get_x_limits()

        ma = max(ma, max(xs))
        mi = min(mi, min(xs))
        rxs = linspace(mi, ma)
        rys = reg.predict(rxs)

        graph.set_x_limits(min_=mi, max_=ma, pad='0.1')

        graph.new_series(rxs, rys, color=scatter.color)
        graph.set_series_label('fit{}'.format(self.group_id))

        if po.show_labels:
            self._add_point_labels(scatter)
        self._add_scatter_inspector(scatter)

        self._add_info(plot, reg, text_color=scatter.color)
Exemple #9
0
 def get_isochron_data(self):
     return calculate_isochron(list(self.clean_analyses()))
Exemple #10
0
 def get_isochron_data(self):
     ans = [a for a in self.analyses if isinstance(a, ArArAge)]
     exclude = [i for i, x in enumerate(ans) if x.is_omitted()]
     if ans:
         return calculate_isochron(ans, self.isochron_age_error_kind, exclude=exclude)
Exemple #11
0
 def _calculate_isochron_age(self):
     args = calculate_isochron(self.analyses)
     if args:
         return args[0]
Exemple #12
0
 def get_isochron_data(self):
     return calculate_isochron(list(self.clean_analyses()), self.isochron_age_error_kind)
Exemple #13
0
 def _calculate_isochron_age(self):
     args = calculate_isochron(self.analyses)
     if args:
         return args[0]
 def get_isochron_data(self):
     return calculate_isochron(list(self.clean_analyses()),
                               self.isochron_age_error_kind)