Example #1
0
    def load_arar_analysis_backend(self, ln, arar_age):
        db = self.mainstore.db
        with db.session_ctx():
            ln = db.get_labnumber(ln)
            if ln:
                an = DBAnalysis()
                x = datetime.now()
                now = time.mktime(x.timetuple())
                an.timestamp = now
                try:
                    an.sync_irradiation(ln)
                except NoProductionError:
                    self.information_dialog(
                        'Irradiation={} Level={} has '
                        'no Correction/Production Ratio set defined'.format(
                            an.irradiation, an.irradiation_level))
                    return

                arar_age.trait_set(
                    j=an.j,
                    production_ratios=an.production_ratios,
                    interference_corrections=an.interference_corrections,
                    chron_segments=an.chron_segments,
                    irradiation_time=an.irradiation_time,
                    timestamp=now)

                arar_age.calculate_decay_factors()
            return True
Example #2
0
    def load_arar_analysis_backend(self, ln, arar_age):
        db = self.mainstore.db
        with db.session_ctx():
            ln = db.get_labnumber(ln)
            if ln:
                an = DBAnalysis()
                x = datetime.now()
                now = time.mktime(x.timetuple())
                an.timestamp = now
                try:
                    an.sync_irradiation(ln)
                except NoProductionError:
                    self.information_dialog('Irradiation={} Level={} has '
                                            'no Correction/Production Ratio set defined'.format(an.irradiation,
                                                                                                an.irradiation_level))
                    return

                arar_age.trait_set(j=an.j,
                                   production_ratios=an.production_ratios,
                                   interference_corrections=an.interference_corrections,
                                   chron_segments=an.chron_segments,
                                   irradiation_time=an.irradiation_time,
                                   timestamp=now)

                arar_age.calculate_decay_factors()
            return True
Example #3
0
    def _construct_analysis(self,
                            rec,
                            group,
                            prog,
                            calculate_age=True,
                            calculate_F=False,
                            unpack=False,
                            load_aux=False):
        atype = None
        if isinstance(rec, meas_AnalysisTable):
            rid = make_runid(rec.labnumber.identifier, rec.aliquot, rec.step)
            atype = rec.measurement.analysis_type.name
        elif hasattr(rec, 'record_id'):
            rid = rec.record_id
        else:
            rid = id(rec)

        graph_id = 0
        group_id = 0

        if hasattr(rec, 'group_id'):
            group_id = rec.group_id

        if hasattr(rec, 'graph_id'):
            graph_id = rec.graph_id

        if atype is None:
            atype = rec.analysis_type

        if prog:
            m = ''
            if calculate_age:
                show_age = atype in ('unknown', 'cocktail')
                m = 'calculating age' if show_age else ''
            elif calculate_F:
                m = 'calculating F'

            msg = 'loading {}. {}'.format(rid, m)
            prog.change_message(msg)

        if isinstance(rec, DBAnalysis):
            ai = rec
            if load_aux:
                ai.sync_aux(group)
            else:
                ai.sync(group, unpack=unpack, load_aux=load_aux)
        else:
            ai = DBAnalysis()  # if not self.use_vcs else VCSAnalysis
            # print ai
            ai.sync(group, unpack=unpack, load_aux=load_aux)
            # print ai, group

            # ai = klass(group_id=group_id,
            #        graph_id=graph_id)

        # ai.trait_set(group_id=group_id,
        #              graph_id=graph_id)

        # if not self.use_vcs:
        #
        # timethis(ai.sync, args=(group,),
        #          kwargs=dict(unpack=unpack, load_aux=load_aux))

        if atype in ('unknown', 'cocktail'):
            if calculate_age:
                # timethis(ai.sync, args=(meas_analysis, ),
                #          kwargs=dict(unpack=unpack, load_aux=load_aux))
                # timethis(ai.calculate_age, kwargs=dict(force=not self.use_vcs))
                ai.calculate_age()
                # timethis(ai.sync, args=(meas_analysis,),
                #          kwargs=dict(unpack=unpack, load_aux=load_aux))
                # timethis(ai.calculate_age)

                # synced = True
        if calculate_F:
            ai.calculate_f()

        # if not synced:
        #     ai.sync(group, unpack=unpack, load_aux=load_aux)

        return ai
    def _construct_analysis(self, rec, group, prog, calculate_age=True, calculate_F=False,
                            unpack=False, load_aux=False):
        atype = None
        if isinstance(rec, meas_AnalysisTable):
            rid = make_runid(rec.labnumber.identifier, rec.aliquot, rec.step)
            atype = rec.measurement.analysis_type.name
        elif hasattr(rec, 'record_id'):
            rid = rec.record_id
        else:
            rid = id(rec)

        graph_id = 0
        group_id = 0

        if hasattr(rec, 'group_id'):
            group_id = rec.group_id

        if hasattr(rec, 'graph_id'):
            graph_id = rec.graph_id

        if atype is None:
            atype = rec.analysis_type

        if prog:
            m=''
            if calculate_age:
                show_age = atype in ('unknown', 'cocktail')
                m = 'calculating age' if show_age else ''
            elif calculate_F:
                m = 'calculating F'

            msg = 'loading {}. {}'.format(rid, m)
            prog.change_message(msg)

        if isinstance(rec, DBAnalysis):
            ai = rec
            if load_aux:
                ai.sync_aux(group)
            else:
                ai.sync(group, unpack=unpack, load_aux=load_aux)
        else:
            ai = DBAnalysis()  # if not self.use_vcs else VCSAnalysis
            # print ai
            ai.sync(group, unpack=unpack, load_aux=load_aux)
            # print ai, group

            # ai = klass(group_id=group_id,
            #        graph_id=graph_id)

        ai.trait_set(group_id=group_id,
                     graph_id=graph_id)

        # if not self.use_vcs:
        #
        # timethis(ai.sync, args=(group,),
        #          kwargs=dict(unpack=unpack, load_aux=load_aux))

        if atype in ('unknown', 'cocktail'):
            if calculate_age:
                # timethis(ai.sync, args=(meas_analysis, ),
                #          kwargs=dict(unpack=unpack, load_aux=load_aux))
                # timethis(ai.calculate_age, kwargs=dict(force=not self.use_vcs))
                ai.calculate_age()  #force=not self.use_vcs)
                # timethis(ai.sync, args=(meas_analysis,),
                #          kwargs=dict(unpack=unpack, load_aux=load_aux))
                # timethis(ai.calculate_age)

                # synced = True
        if calculate_F:
            ai.calculate_F()

        # if not synced:
        #     ai.sync(group, unpack=unpack, load_aux=load_aux)

        return ai