Exemplo n.º 1
0
def load_isotopedb_defaults(db):
    with db.session_ctx() as sess:
        for name, mass in MOLECULAR_WEIGHTS.iteritems():
            db.add_molecular_weight(name, mass)

        for at in ['blank_air',
                   'blank_cocktail',
                   'blank_unknown',
                   'background', 'air', 'cocktail', 'unknown']:
        #                           blank', 'air', 'cocktail', 'background', 'unknown']:
            db.add_analysis_type(at)

        for mi in ['obama', 'jan', 'nmgrl map']:
            db.add_mass_spectrometer(mi)

        project = db.add_project('references')
        #print project
        for i, di in enumerate(['blank_air',
                                'blank_cocktail',
                                'blank_unknown',
                                'background', 'air', 'cocktail']):
            samp = db.add_sample(di, project=project)
            #print samp.id, samp, project.id
            #            samp.project = project
            #samp.project_id=project.id
            #print samp.project_id
            db.add_labnumber(i + 1, sample=samp)
        sess.commit()

        for hi, kind, make in [('Fusions CO2', '10.6um co2', 'photon machines'),
                               ('Fusions Diode', '810nm diode', 'photon machines'),
                               ('Fusions UV', '193nm eximer', 'photon machines')
        ]:
            db.add_extraction_device(name=hi,
                                     kind=kind,
                                     make=make,
            )

        mdir = os.path.join(paths.setup_dir, 'irradiation_tray_maps')
        mdir=paths.irradiation_tray_maps_dir
        # if not os.path.isdir(mdir):
        #     if information(None, 'No irradiation_tray_maps directory. add to .../setupfiles'):
        #         try:
        #             os.mkdir(mdir)
        #         except OSError,e:
        #             warning(None, 'Failed making {}: error={}'.format(mdir, e))
        #
        # else:
        for p, name in iterdir(mdir, exclude=('.zip',)):
            load_irradiation_map(db, p, name)

        mdir = paths.map_dir
        for p, name in iterdir(mdir):
            _load_tray_map(db, p, name)

        for t in ('ok', 'invalid'):
            db.add_tag(t, user='******')
Exemplo n.º 2
0
    def map_dac_to_isotope(self, dac=None, det=None, current=True):
        if dac is None:
            dac = self._dac
        if det is None:
            det = self.detector

        if det:
            dac = self.spectrometer.uncorrect_dac(det, dac, current=current)

        m = self.map_dac_to_mass(dac, det.name)
        molweights = self.spectrometer.molecular_weights
        return next((k for k, v in molweights.iteritems() if abs(v - m) < 0.001), None)
Exemplo n.º 3
0
def load_isotopedb_defaults(db):
    with db.session_ctx() as sess:
        for name, mass in MOLECULAR_WEIGHTS.iteritems():
            db.add_molecular_weight(name, mass)

        populate_isotopes(db)

        for at in ['blank_air',
                   'blank_cocktail',
                   'blank_unknown',
                   'background', 'air', 'cocktail', 'unknown']:
            #                           blank', 'air', 'cocktail', 'background', 'unknown']:
            db.add_analysis_type(at)

        # for mi in ['obama', 'jan', 'nmgrl map']:
        #     db.add_mass_spectrometer(mi)

        project = db.add_project('REFERENCES')
        # print project
        for i, di in enumerate(['blank_air',
                                'blank_cocktail',
                                'blank_unknown',
                                'background', 'air', 'cocktail']):
            samp = db.add_sample(di, project=project)
            # print samp.id, samp, project.id
            #            samp.project = project
            # samp.project_id=project.id
            # print samp.project_id
            # db.add_labnumber(i + 1, sample=samp)
        sess.commit()

        # for hi, kind, make in [('Fusions CO2', '10.6um co2', 'photon machines'),
        #                        ('Fusions Diode', '810nm diode', 'photon machines'),
        #                        ('Fusions UV', '193nm eximer', 'photon machines')]:
        #     db.add_extraction_device(name=hi,
        #                              kind=kind,
        #                              make=make)

        mdir = paths.irradiation_tray_maps_dir
        for p, name in iterdir(mdir, exclude=('.zip',)):
            og = False
            load_irradiation_map(db, p, name, overwrite_geometry=og)

        mdir = paths.map_dir
        for p, name in iterdir(mdir):
            try:
                _load_tray_map(db, p, name)
            except BaseException:
                print 'failed loading tray map "{}", "{}"'.format(p, name)

        for t in ('ok', 'invalid'):
            db.add_tag(t, user='******')
Exemplo n.º 4
0
    def map_dac_to_isotope(self, dac=None, det=None, current=True):
        """
        convert a dac voltage to isotope name for a given detector


        :param dac: float, voltage
        :param det: str, detector name
        :param current: bool, get current hv
        :return: str, e.g Ar40
        """
        if dac is None:
            dac = self._dac
        if det is None:
            det = self.detector

        if det:
            dac = self.spectrometer.uncorrect_dac(det, dac, current=current)

        m = self.map_dac_to_mass(dac, det.name)
        if m is not None:
            molweights = self.spectrometer.molecular_weights
            return next((k for k, v in molweights.iteritems() if abs(v - m) < 0.001), None)
Exemplo n.º 5
0
    def map_dac_to_isotope(self, dac=None, det=None, current=True):
        """
        convert a dac voltage to isotope name for a given detector


        :param dac: float, voltage
        :param det: str, detector name
        :param current: bool, get current hv
        :return: str, e.g Ar40
        """
        if dac is None:
            dac = self._dac
        if det is None:
            det = self.detector

        if det:
            dac = self.spectrometer.uncorrect_dac(det, dac, current=current)

        m = self.map_dac_to_mass(dac, det.name)
        if m is not None:
            molweights = self.spectrometer.molecular_weights
            return next((k for k, v in molweights.iteritems() if abs(v - m) < 0.001), None)