Пример #1
0
 def open_database(back, db_dir=None):
     # File -> Open Database
     try:
         # Use the same args in a new (opened) database
         args = back.hs.args
         if db_dir is None:
             msg = 'Select (or create) a database directory.'
             db_dir = guitools.select_directory(msg)
         print('[*back] user selects database: ' + db_dir)
         # Try and load db
         args.dbdir = db_dir
         hs = HotSpotterAPI.HotSpotter(args=args, db_dir=db_dir)
         hs.load(load_all=False)
         # Write to cache and connect if successful
         io.global_cache_write('db_dir', db_dir)
         back.connect_api(hs)
         #back.layout_figures()
     except Exception as ex:
         import traceback
         print(traceback.format_exc())
         back.user_info('Aborting open database')
         print('aborting open database')
         print(ex)
         if back.hs.args.strict:
             raise
     print('')
Пример #2
0
def main(defaultdb='NAUTS', usedbcache=False, default_load_all=True):
    import matplotlib
    matplotlib.use('Qt4Agg')
    imports()
    from hscom import argparse2
    from hscom import helpers
    from hotspotter import HotSpotterAPI as api
    args = argparse2.parse_arguments(defaultdb=defaultdb)
    # Parse arguments
    args = argparse2.fix_args_with_cache(args)
    if usedbcache:
        load_all, cids = preload_args_process(args)
    else:
        args = argparse2.fix_args_shortnames(args)
        load_all = helpers.get_flag('--load-all', default_load_all)

    # Preload process args
    if args.delete_global:
        from hscom import fileio as io
        io.delete_global_cache()

    # --- Build HotSpotter API ---
    hs = api.HotSpotter(args)
    setcfg = args.setcfg
    if setcfg is not None:
        import experiment_harness
        print('[main] setting cfg to %r' % setcfg)
        varried_list = experiment_harness.get_varried_params_list([setcfg])
        cfg_dict = varried_list[0]
        #print(cfg_dict)
        hs.prefs.query_cfg.update_cfg(**cfg_dict)
        hs.prefs.save()
        #hs.prefs.printme()
        # load default preferences
        hs.default_preferences()

    # Load all data if needed now, otherwise be lazy
    try:
        hs.load(load_all=load_all)
        from hscom import fileio as io
        #imported from wrong module
        #from hotspotter import fileio as io
        db_dir = hs.dirs.db_dir
        io.global_cache_write('db_dir', db_dir)
    except ValueError as ex:
        print('[main] ValueError = %r' % (ex, ))
        if hs.args.strict:
            raise
    return hs
Пример #3
0
def main(defaultdb='cache', preload=False, app=None):
    from hscom import fileio as io
    from hscom import params
    from hotspotter import HotSpotterAPI as api
    from hsgui import guitools
    from hsgui import guiback
    if app is True:
        app, is_root = guitools.init_qtapp()
    args = parse_arguments(defaultdb, defaultdb == 'cache')
    # --- Build HotSpotter API ---
    if app is None:
        hs = api.HotSpotter(args)
    else:
        back = guiback.make_main_window(app)
        hs = back.open_database(args.dbdir)
    setcfg = args.setcfg
    if setcfg is not None:
        # FIXME move experiment harness to hsdev
        import experiment_harness
        print('[tapi.main] setting cfg to %r' % setcfg)
        varied_list = experiment_harness.get_varied_params_list([setcfg])
        cfg_dict = varied_list[0]
        hs.prefs.query_cfg.update_cfg(**cfg_dict)
        hs.prefs.save()
        hs.prefs.printme()
    # Load all data if needed now, otherwise be lazy
    try:
        load_all = preload
        hs.load(load_all=load_all)
        db_dir = hs.dirs.db_dir
        io.global_cache_write('db_dir', db_dir)
    except ValueError as ex:
        print('[tapi.main] ValueError = %r' % (ex, ))
        if params.args.strict:
            raise
    if app is not None:
        return hs, back
    else:
        from hsgui import guitools
        app, is_root = guitools.init_qtapp()
        hs.app = app
    return hs
Пример #4
0
def open_database(db_dir=None):
    # File -> Open Database
    try:
        # Use the same args in a new (opened) database
        args = params.args

        # Try and load db
        if args is not None:
            args.dbdir = db_dir
        hs = HotSpotterAPI.HotSpotter(args=args, db_dir=db_dir)
        hs.load(load_all=False)
        
    except Exception as ex:
        import traceback
        import sys
        print(traceback.format_exc())
        print('aborting open database')
        print(ex)
        if '--strict' in sys.argv:
            raise
        raise
    print('')
    return hs
Пример #5
0
def open_database(db_dir=None):
    # File -> Open Database
    try:
        # Use the same args in a new (opened) database
        args = params.args
        # Try and load db
        if args is not None:
            args.dbdir = db_dir
        hs = HotSpotterAPI.HotSpotter(args=args, db_dir=db_dir)
        hs.load(load_all=False)
        # Write to cache and connect if successful
        io.global_cache_write('db_dir', db_dir)
        #back.layout_figures()
    except Exception as ex:
        import traceback
        import sys
        print(traceback.format_exc())
        print('aborting open database')
        print(ex)
        if '--strict' in sys.argv:
            raise
        raise
    print('')
    return hs
Пример #6
0
from hscom import helpers
from hscom import helpers as util
from hsviz import viz
import multiprocessing
import numpy as np  # NOQA

if __name__ == '__main__':
    multiprocessing.freeze_support()
    # Debugging vars
    chip_cfg = None
    #l')=103.7900s
    cx_list = None
    kwargs = {}
    # --- LOAD TABLES --- #
    args = argparse2.parse_arguments(defaultdb='NAUTS')
    hs = api.HotSpotter(args)
    hs.load_tables()
    hs.update_samples()
    # --- LOAD CHIPS --- #
    force_compute = helpers.get_flag('--force', default=False)
    cc2.load_chips(hs, force_compute=force_compute)
    cx = helpers.get_arg('--cx', type_=int)
    if not cx is None:
        #tau = np.pi * 2
        #hs.change_theta(cx, tau / 8)
        viz.show_chip(hs, cx, draw_kpts=False, fnum=1)
        viz.show_image(hs, hs.cx2_gx(cx), fnum=2)
    else:
        print('usage: feature_compute.py --cx [cx]')
    exec(viz.df2.present())