Esempio n. 1
0
 def setUpClass(cls):
     src = os.path.join(get_data_dir(), 'opychrondata.db')
     db = isotope_db_factory(src, remove=False)
     with db.session_ctx():
         ans = db.get_analyses()
         cls.analyses = [MAnalysis(ai) for ai in ans]
     cls.new_identifier = '2000'
Esempio n. 2
0
def pychron_source_factory():
    src = os.path.join(get_data_dir(), 'opychrondata.db')
    dest = os.path.join(get_data_dir(), 'pychrondata.db')

    # duplicate the original database
    shutil.copyfile(src, dest)

    db = isotope_db_factory(dest, remove=False)
    return db
Esempio n. 3
0
def generate_opychrondb():
    src = os.path.join(get_data_dir(), 'opychrondata.db')
    db = isotope_db_factory(src)
    with db.session_ctx():
        db.add_labnumber('1000')
        db.add_labnumber('2000')
        db.flush()

        for i in range(3):
            db.add_analysis('1000', aliquot=i + 1)
Esempio n. 4
0
def db_factory():
    path = os.path.join(fget_data_dir(), DBNAME)
    db = isotope_db_factory(path)
    # from pychron.database.adapters.isotope_adapter import IsotopeAdapter
    from pychron.database.orms.isotope.util import Base
    #
    # db = IsotopeAdapter()
    # db.verbose_retrieve_query = True
    # db.trait_set(kind='sqlite', path=os.path.join(get_data_dir(), DBNAME))
    # db.connect()
    #
    if os.path.isfile(db.path):
        os.remove(db.path)

    metadata = Base.metadata
    db.create_all(metadata)
    metadata.create_all(db.session.bind)

    return db
Esempio n. 5
0
def source_factory():
    db = isotope_db_factory(os.path.join(get_data_dir(), SRC_NAME))
    p = os.path.join(get_data_dir(), 'irradiation_import.xls')

    # add a production ratio
    db.add_irradiation_production(name='Triga PR', K4039=10)

    loader = XLSIrradiationLoader(db=db)
    loader.open(p)
    loader.load_irradiation(p, dry_run=False)
    db.verbose = False
    dbirrads = db.get_irradiations(order_func='asc')
    irrads = [i.name for i in dbirrads]

    levels = {}
    for di in dbirrads:
        levels[di.name] = tuple([li.name for li in di.levels])

    return db, irrads, levels