Exemplo n.º 1
0
def test_get_best_from_chain():
    # Triplicate sphere pars (are copies)
    # Represents a chain with 2 walkers and 3 steps
    intern_sphere_pars = SphereComponent.internalise(SPHERE_PARS)
    dummy_chain = np.array(
        [[intern_sphere_pars, intern_sphere_pars, intern_sphere_pars],
         [intern_sphere_pars, intern_sphere_pars, intern_sphere_pars]])
    dummy_lnprob = np.zeros(dummy_chain.shape[:2])

    # Incorporate identifying marker at desired index
    true_best_ix = (1, 1)
    dummy_chain[true_best_ix][0] = 10.
    dummy_lnprob[true_best_ix] = 1.

    best_comp = SphereComponent.get_best_from_chain(dummy_chain, dummy_lnprob)
    assert np.allclose(dummy_chain[true_best_ix], best_comp.get_emcee_pars())
Exemplo n.º 2
0
if PLOT_FED_STARS:
    print("Plotting fed stars)")

    # Setting up file names
    synth_fit = 'fed_stars'
    rdir = '../../results/archive/fed_fits/20/gaia/'
    origins_file = rdir + 'origins.npy'
    origin_comp_file = rdir + 'origin_ellip_comp.npy'
    chain_file = rdir + 'final_chain.npy'
    lnprob_file = rdir + 'final_lnprob.npy'
    star_pars_file = rdir + 'xyzuvw_now.fits'
    init_xyzuvw_file = rdir + '../xyzuvw_init_offset.npy'
    perf_xyzuvw_now = rdir + '../perf_xyzuvw.npy'

    # loading in data
    best_comp = SphereComponent.get_best_from_chain(chain_file, lnprob_file)
    origin_comp = EllipComponent.load_raw_components(origin_comp_file)[0]
    init_xyzuvw = np.load(init_xyzuvw_file)
    star_pars = dt.loadXYZUVW(star_pars_file)
    perf_mean_now = np.load(perf_xyzuvw_now)

    original_origin = dt.loadGroups(origins_file)[0]

    # assigning useful shorthands
    mns = star_pars['xyzuvw']
    covs = star_pars['xyzuvw_cov']

    fed_xranges, fed_yranges = calcRanges(
        {'xyzuvw': np.vstack((star_pars['xyzuvw'], init_xyzuvw))},
        sep_axes=True,
    )