示例#1
0
    def _get_positions(self, name, level):
        dm = self._dm
        sheet = dm.get_sheet(('Positions', 2))
        nameidx = dm.get_column_idx(NAME, sheet)
        levelidx = dm.get_column_idx(LEVEL, sheet)
        positionidx = dm.get_column_idx(POSITION, sheet)
        sampleidx = dm.get_column_idx(SAMPLE, sheet)
        materialidx = dm.get_column_idx(MATERIAL, sheet)
        projectidx = dm.get_column_idx(PROJECT, sheet)
        piidx = dm.get_column_idx(PI, sheet)
        noteidx = dm.get_column_idx(NOTE, sheet)
        weightidx = dm.get_column_idx(WEIGHT, sheet)

        ps = []
        for row in dm.iterrows(sheet, start=1):
            if row[nameidx].value == name and row[levelidx].value == level:
                pos = Position()

                pos.position = row[positionidx].value

                sample = Sample()
                sample.name = row[sampleidx].value
                sample.material = row[materialidx].value

                project = Project()
                project.name = row[projectidx].value
                project.principal_investigator = row[piidx].value
                sample.project = project
                pos.sample = sample

                pos.note = row[noteidx].value or ''
                pos.weight = row[weightidx].value or 0

                ps.append(pos)
        return ps
示例#2
0
    def _get_positions(self, name, level):
        dm = self._dm
        sheet = dm.get_sheet(('Positions', 2))
        nameidx = dm.get_column_idx(NAME, sheet)
        levelidx = dm.get_column_idx(LEVEL, sheet)
        positionidx = dm.get_column_idx(POSITION, sheet)
        sampleidx = dm.get_column_idx(SAMPLE, sheet)
        materialidx = dm.get_column_idx(MATERIAL, sheet)
        projectidx = dm.get_column_idx(PROJECT, sheet)
        piidx = dm.get_column_idx(PI, sheet)
        noteidx = dm.get_column_idx(NOTE, sheet)
        weightidx = dm.get_column_idx(WEIGHT, sheet)

        ps = []
        for row in dm.iterrows(sheet, start=1):
            if row[nameidx].value == name and row[levelidx].value == level:
                pos = Position()

                pos.position = row[positionidx].value

                sample = Sample()
                sample.name = row[sampleidx].value
                sample.material = row[materialidx].value

                project = Project()
                project.name = row[projectidx].value
                project.principal_investigator = row[piidx].value
                sample.project = project
                pos.sample = sample

                pos.note = row[noteidx].value or ''
                pos.weight = row[weightidx].value or 0

                ps.append(pos)
        return ps
示例#3
0
    def get_import_spec(self, name):
        from pychron.entry.import_spec import ImportSpec, Irradiation, Level, \
            Sample, Project, Position, Production
        spec = ImportSpec()

        i = Irradiation()
        i.name = name

        spec.irradiation = i

        chrons = self.get_chronology_by_irradname(name)
        i.doses = [(1.0, ci.StartTime, ci.EndTime) for ci in chrons]

        levels = self.get_irradiation_levels(name)
        nlevels = []
        for dbl in levels:
            level = Level()
            level.name = dbl.Level

            prod = Production()
            dbprod = dbl.production
            prod.name = dbprod.Label.replace(' ', '_')

            for attr in INTERFERENCE_KEYS:
                try:
                    setattr(prod, attr, (getattr(
                        dbprod, attr), getattr(dbprod, '{}Er'.format(attr))))
                except AttributeError:
                    pass

            prod.Ca_K = (dbprod.CaOverKMultiplier, dbprod.CaOverKMultiplierEr)
            prod.Cl_K = (dbprod.ClOverKMultiplier, dbprod.ClOverKMultiplierEr)
            prod.Cl3638 = (dbprod.P36Cl38Cl, dbprod.P36Cl38ClEr)

            level.production = prod
            level.holder = dbl.SampleHolder

            pos = []
            for ip in self.get_irradiation_positions(name, level.name):
                dbsam = ip.sample
                s = Sample()
                s.name = dbsam.Sample
                s.material = ip.Material

                pp = Project()
                pp.name = ip.sample.project.Project
                pp.principal_investigator = ip.sample.project.PrincipalInvestigator
                s.project = pp

                p = Position()
                p.sample = s
                p.position = ip.HoleNumber
                p.identifier = ip.IrradPosition
                p.j = ip.J
                p.j_err = ip.JEr
                p.note = ip.Note
                p.weight = ip.Weight

                pos.append(p)
            level.positions = pos
            nlevels.append(level)

            i.levels = nlevels
        return spec
示例#4
0
    def get_import_spec(self, name):
        from pychron.entry.import_spec import ImportSpec, Irradiation, Level, \
            Sample, Project, Position, Production
        spec = ImportSpec()

        i = Irradiation()
        i.name = name

        spec.irradiation = i

        with self.session_ctx():
            chrons = self.get_chronology_by_irradname(name)
            i.doses = [(1.0, ci.StartTime, ci.EndTime) for ci in chrons]

            levels = self.get_irradiation_levels(name)
            nlevels = []
            for dbl in levels:
                level = Level()
                level.name = dbl.Level

                prod = Production()
                dbprod = dbl.production
                prod.name = dbprod.Label.replace(' ', '_')

                for attr in INTERFERENCE_KEYS:
                    try:
                        setattr(prod, attr, (getattr(dbprod, attr),
                                             getattr(dbprod, '{}Er'.format(attr))))
                    except AttributeError:
                        pass

                prod.Ca_K = (dbprod.CaOverKMultiplier, dbprod.CaOverKMultiplierEr)
                prod.Cl_K = (dbprod.ClOverKMultiplier, dbprod.ClOverKMultiplierEr)
                prod.Cl3638 = (dbprod.P36Cl38Cl, dbprod.P36Cl38ClEr)

                level.production = prod
                level.holder = dbl.SampleHolder

                pos = []
                for ip in self.get_irradiation_positions(name, level.name):
                    dbsam = ip.sample
                    s = Sample()
                    s.name = dbsam.Sample
                    s.material = ip.Material

                    pp = Project()
                    pp.name = ip.sample.project.Project
                    pp.principal_investigator = ip.sample.project.PrincipalInvestigator
                    s.project = pp

                    p = Position()
                    p.sample = s
                    p.position = ip.HoleNumber
                    p.identifier = ip.IrradPosition
                    p.j = ip.J
                    p.j_err = ip.JEr
                    p.note = ip.Note
                    p.weight = ip.Weight

                    pos.append(p)
                level.positions = pos
                nlevels.append(level)

            i.levels = nlevels
        return spec