Exemplo n.º 1
0
        plt.clf()

        for c in all_comps:
            # only plot component if it exists
            # print('plotting {}'.format(c))
            if c.get_age() > time:
                # print('{} is greater than {}'.format(c.get_age(), time))
                c_copy = SphereComponent(c.get_pars())

                # modify age so that 'comp_now' is plotted at time `time`
                # time is how long ago, we want copy.age to be time since
                # birth, that is c.get_age - time
                c_copy.update_attribute({'age':c.get_age()-time})
                # print('pars updated to: {}'.format(c_copy.get_pars()))

                c_copy.plot(dim1=dim1, dim2=dim2, comp_now=True, comp_then=True,
                            comp_orbit=True)

                # There was a prior issue (
                # if c_copy.get_mean_now()[1] < -200:
                #     import pdb; pdb.set_trace()

        plt.xlim()
        plt.xlabel('{} [{}]'.format(labels[dim1], units[dim1]))
        plt.ylabel('{} [{}]'.format(labels[dim2], units[dim2]))

        lims[dim1] = update_1D_lims(lims[dim1], plt.xlim())
        lims[dim2] = update_1D_lims(lims[dim2], plt.ylim())

        plt.xlim(lims[dim1])
        plt.ylim(lims[dim2])
star_data = tabletool.build_data_dict_from_table(star_data_file)

# Set up base subplots, plotting everything that is the same across iterative
# plots. We will then store this via Pickle to save time
base_fig, base_ax = plt.subplots(nrows=2, ncols=2)
base_fig.set_size_inches(8, 8)
base_fig.set_tight_layout(True)

lims = 6 * [None]
for ax, (dim1, dim2) in zip(base_ax.flatten(), dims):
    true_comp.plot(ax=ax,
                   dim1=dim1,
                   dim2=dim2,
                   comp_now=False,
                   comp_then=True,
                   comp_orbit=True,
                   linestyle='-.',
                   color='grey',
                   alpha=0.15)
    for star_mn, star_cov in zip(star_data['means'], star_data['covs']):
        star_comp = SphereComponent(attributes={
            'mean': star_mn,
            'covmatrix': star_cov,
            'age': 0.
        })
        star_comp.plot(dim1=dim1,
                       dim2=dim2,
                       ax=ax,
                       color='blue',
                       comp_now=False,