Ejemplo n.º 1
0
    def run_fit(self, plot_it=False, burnin_steps=1000, sampling_steps=1000):
        self.best_like_fit, chain, self.lnprob =\
            gf.fit_group(
                self.tb_file, fixed_age=self.fixed_age, burnin_steps=1000,
                sampling_steps=1000
            )
        self.nwalkers, self.nsteps, self.npars = chain.shape
        flat_chain = np.reshape(chain, (-1, self.npars))
        self.nsamples = self.nwalkers*self.nsteps
        logging.info("Fixed fit completed for {}".format(self.fixed_age))

        cov_mats = self.calc_covs(flat_chain)
        self.calc_pos_radii(cov_mats)
        self.calc_mean_fit(cov_mats, flat_chain)
Ejemplo n.º 2
0
    def run_fit(self, plot_it=False, burnin_steps=1000, sampling_steps=1000):
        self.best_like_fit, chain, self.lnprob =\
            gf.fit_group(
                self.tb_file, fixed_age=self.fixed_age, burnin_steps=1000,
                sampling_steps=1000
            )
        self.nwalkers, self.nsteps, self.npars = chain.shape
        flat_chain = np.reshape(chain, (-1, self.npars))
        self.nsamples = self.nwalkers * self.nsteps
        logging.info("Fixed fit completed for {}".format(self.fixed_age))

        cov_mats = self.calc_covs(flat_chain)
        self.calc_pos_radii(cov_mats)
        self.calc_mean_fit(cov_mats, flat_chain)
Ejemplo n.º 3
0
    def run_fit(self, plot_it=False, burnin_steps=1000, sampling_steps=1000):
        self.best_like_fit, self.chain, lnprob =\
            gf.fit_group(
                self.tb_file, plot_it=plot_it, burnin_steps=burnin_steps,
                sampling_steps=sampling_steps
            )

        self.nwalkers, self.nsteps, self.npars = self.chain.shape
        flat_chain = np.reshape(self.chain, (-1, self.npars))
        self.nsamples = self.nwalkers*self.nsteps

        cov_mats = self.calc_covs(flat_chain)
        self.calc_pos_radii(cov_mats)
        #self.calc_phase_radius(cov_mats)
        self.calc_mean_fit(cov_mats, flat_chain)
Ejemplo n.º 4
0
    def run_fit(self, plot_it=False, burnin_steps=1000, sampling_steps=1000):
        self.best_like_fit, self.chain, lnprob =\
            gf.fit_group(
                self.tb_file, plot_it=plot_it, burnin_steps=burnin_steps,
                sampling_steps=sampling_steps
            )

        self.nwalkers, self.nsteps, self.npars = self.chain.shape
        flat_chain = np.reshape(self.chain, (-1, self.npars))
        self.nsamples = self.nwalkers * self.nsteps

        cov_mats = self.calc_covs(flat_chain)
        self.calc_pos_radii(cov_mats)
        #self.calc_phase_radius(cov_mats)
        self.calc_mean_fit(cov_mats, flat_chain)
Ejemplo n.º 5
0
def maximise(infile,
             ngroups,
             z=None,
             init_conditions=None,
             burnin_steps=500,
             sampling_steps=1000):
    """Given membership probabilities, maximise the parameters of each group model

    Parameters
    ----------
    infile : str
        Name of the traceback file being fitted to

    ngroups : int
        Number of groups to be fitted to the traceback orbits

    z : [nstars, ngroups] array
        An array designating each star's probability of being a member to each
        group. It is populated by floats in the range (0.0, 1.0) such that
        each row sums to 1.0, each column sums to the expected size of each
        group, and the entire array sums to the number of stars.

    init_conditions : [ngroups, npars] array
        The initial conditions for the groups, encoded in the 'internal' manner
        (that is, 1/dX, 1/dY etc. and no star count)

    burnin_steps : int
        number of steps during burnin phase

    sampling_steps : int
        number of steps during sampling phase

    Returns
    -------
    best_fits : [ngroups, npars] array
        The best fitting parameters for each group
    chains : [ngroups, nwalkers, nsteps, npars] array
        The final chain for each group's fit
    lnprobs : [ngroups, nwalkers, nsteps] array
        The sampler.probability array for each group's fit

    TODO: Have some means to enforce fixed ages
    """
    NPARS = 14
    best_fits = np.zeros((ngroups, NPARS))
    chains = None
    lnprobs = None

    for i in range(ngroups):
        best_fit, chain, lnprob = gf.fit_group(infile,
                                               z=ix_snd(z, i),
                                               init_pars=ix_fst(
                                                   init_conditions, i),
                                               burnin_steps=burnin_steps,
                                               sampling_steps=sampling_steps,
                                               plot_it=True)
        best_fits[i] = best_fit
        if chains is None:
            dims = np.append(ngroups, chain.shape)
            chains = np.zeros(dims)
        if lnprobs is None:
            dims = np.append(ngroups, lnprob.shape)
            lnprobs = np.zeros(dims)

        chains[i] = chain
        lnprobs[i] = lnprob
    return best_fits, chains, lnprobs
Ejemplo n.º 6
0
def maximise(infile, ngroups, z=None, init_conditions=None, burnin_steps=500,
             sampling_steps=1000):
    """Given membership probabilities, maximise the parameters of each group model

    Parameters
    ----------
    infile : str
        Name of the traceback file being fitted to

    ngroups : int
        Number of groups to be fitted to the traceback orbits

    z : [nstars, ngroups] array
        An array designating each star's probability of being a member to each
        group. It is populated by floats in the range (0.0, 1.0) such that
        each row sums to 1.0, each column sums to the expected size of each
        group, and the entire array sums to the number of stars.

    init_conditions : [ngroups, npars] array
        The initial conditions for the groups, encoded in the 'internal' manner
        (that is, 1/dX, 1/dY etc. and no star count)

    burnin_steps : int
        number of steps during burnin phase

    sampling_steps : int
        number of steps during sampling phase

    Returns
    -------
    best_fits : [ngroups, npars] array
        The best fitting parameters for each group
    chains : [ngroups, nwalkers, nsteps, npars] array
        The final chain for each group's fit
    lnprobs : [ngroups, nwalkers, nsteps] array
        The sampler.probability array for each group's fit

    TODO: Have some means to enforce fixed ages
    """
    NPARS = 14
    best_fits = np.zeros((ngroups, NPARS))
    chains = None
    lnprobs = None

    for i in range(ngroups):
        best_fit, chain, lnprob = gf.fit_group(
            infile, z=ix_snd(z, i), init_pars=ix_fst(init_conditions, i),
            burnin_steps=burnin_steps, sampling_steps=sampling_steps,
            plot_it=True
        )
        best_fits[i] = best_fit
        if chains is None:
            dims = np.append(ngroups, chain.shape)
            chains = np.zeros(dims)
        if lnprobs is None:
            dims = np.append(ngroups, lnprob.shape)
            lnprobs = np.zeros(dims)

        chains[i] = chain
        lnprobs[i] = lnprob
    return best_fits, chains, lnprobs