Exemplo n.º 1
0
def rebuild_if_needed(lc_dir, db_dir, n_vps=20, n_lcs=1000):
    """
    Helper that checks if needed time series files & vantage point databases already exists
    recreates them if they don't.
    """
    if (simsearch.need_to_rebuild(lc_dir, db_dir)):
        simsearch.rebuild_lcs_dbs(lc_dir, db_dir, n_vps=n_vps, n_lcs=n_lcs)
Exemplo n.º 2
0
def test_makelcs():
    lc_temp_dir = TEMP_DIR + LIGHT_CURVES_DIR
    db_temp_dir = TEMP_DIR + DB_DIR

    # Before we've generated anything, confirm that our rebuild detector method properly detects that we need to rebuild
    assert (simsearch.need_to_rebuild(lc_temp_dir, db_temp_dir) == True)

    makelcs.make_lcs_wfm(5, lc_temp_dir)
    assert (simsearch.need_to_rebuild(lc_temp_dir, db_temp_dir) == True)

    clear_dir(TEMP_DIR, recreate=False)
    # Generate 100 light curves in temp dir
    makelcs.make_lcs_wfm(100, lc_temp_dir)
    assert (simsearch.need_to_rebuild(lc_temp_dir, db_temp_dir) == True)

    # load that back in from disk
    lc_dict = genvpdbs.load_ts_fsm(lc_temp_dir)
    assert (len(lc_dict) == 100)
Exemplo n.º 3
0
def test_genvpdbs():
    lc_temp_dir = TEMP_DIR + LIGHT_CURVES_DIR
    db_temp_dir = TEMP_DIR + DB_DIR

    # Create 10 vantage point database files
    genvpdbs.create_vpdbs(10, lc_temp_dir, db_temp_dir)

    # With vantage points created, we should have fully created dataset
    assert (simsearch.need_to_rebuild(lc_temp_dir, db_temp_dir) == False)

    # Load vantage points back in from disk
    vp_dict = simsearch.load_vp_lcs(db_temp_dir, lc_temp_dir)
    assert (len(vp_dict) == 10)

    clear_dir(TEMP_DIR, recreate=False)
Exemplo n.º 4
0
def cmd_line_util():
    """
    Main program loop. Determines which flags were submitted, confirms that lc files and db files
    exist (Recreates them if they don't) before kicking off similarity search.
    """

    # Default conditions
    rebuild = need_to_rebuild(LIGHT_CURVES_DIR, DB_DIR)
    need_help = False
    input_fpath = False
    plot = False
    demo = False

    while True:
        if len(sys.argv) <= 1:
            print("No arguments provided")
            print(USAGE)
            break

        # First, identify which flags were included
        for arg in sys.argv[1:]:
            if arg.lower() in ['-h','--help', 'help']: need_help = True

            elif '.txt' in arg.lower() or '.dat_folded' in arg.lower():
                input_fpath = arg

            elif arg.lower() in ['-r', '--rebuild']: rebuild = True
            elif arg.lower() in ['-d', '--demo']: demo = True
            elif arg.lower() in ['-p', '--plot']: plot = True

        # Execute selected options
        if need_help:
            print(HELP_MESSAGE)
            break
        elif rebuild:
            rebuild_lcs_dbs(LIGHT_CURVES_DIR, DB_DIR)

        if demo:
            run_demo(DB_DIR, LIGHT_CURVES_DIR, plot)
            break

        elif(input_fpath is not False):
            sim_search(input_fpath, DB_DIR, LIGHT_CURVES_DIR, plot)
            break
        else:
            print("Error: no compatible time series or light curve file provided")
            print(USAGE)
            break
Exemplo n.º 5
0
def test_simsearch():
    lc_temp_dir = TEMP_DIR + LIGHT_CURVES_DIR
    db_temp_dir = TEMP_DIR + DB_DIR

    simsearch.rebuild_lcs_dbs(lc_temp_dir, db_temp_dir, 10, 100)

    # Repeat checks from above on re-generated data
    lc_dict = genvpdbs.load_ts_fsm(lc_temp_dir)
    assert (len(lc_dict) == 100)
    vp_dict = simsearch.load_vp_lcs(db_temp_dir, lc_temp_dir)
    assert (len(vp_dict) == 10)
    assert (simsearch.need_to_rebuild(lc_temp_dir, db_temp_dir) == False)

    demo_ts_fn = random.choice(
        os.listdir('cs207project/tsrbtreedb/' + SAMPLE_DIR))
    demo_fp = 'cs207project/tsrbtreedb/' + SAMPLE_DIR + demo_ts_fn
    simsearchutil.sim_search(demo_fp, db_temp_dir, lc_temp_dir, False)