Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import orbitize.priors as priors
threshold = 1e-1
initialization_inputs = {
priors.GaussianPrior : [1000., 1.],
priors.LogUniformPrior : [1., 2.],
priors.UniformPrior : [0., 1.],
priors.SinPrior : [],
priors.LinearPrior : [-2., 2.]
}
expected_means_mins_maxes = {
priors.GaussianPrior : (1000.,0.,np.inf),
priors.LogUniformPrior : (1/np.log(2),1., 2.),
priors.UniformPrior : (0.5, 0., 1.),
priors.SinPrior : (np.pi/2., 0., np.pi),
priors.LinearPrior : (1./3.,0.,1.0)
}
lnprob_inputs = {
priors.GaussianPrior : np.array([-3.0, np.inf, 1000., 999.]),
priors.LogUniformPrior : np.array([-1., 0., 1., 1.5, 2., 2.5]),
priors.UniformPrior : np.array([0., 0.5, 1., -1., 2.]),
priors.SinPrior : np.array([0., np.pi/2., np.pi, 10., -1.]),
priors.LinearPrior : np.array([0., 0.5, 1., 2., -1.])
}
expected_probs = {
priors.GaussianPrior : np.array([0., 0., nm(1000.,1.).pdf(1000.), nm(1000.,1.).pdf(999.)]),
priors.LogUniformPrior : np.array([0., 0., 1., 2./3., 0.5, 0.])/np.log(2),
priors.UniformPrior : np.array([1., 1., 1., 0., 0.]),
data_table['quant1'] *= 1000
data_table['quant1_err'] *= 1000
data_table['quant2'] *= 1000
data_table['quant2_err'] *= 1000
data_table['epoch'] -= 50000
# Initialize System object which stores data & sets priors
bP_system = system.System(
num_secondary_bodies, data_table, system_mass,
plx, mass_err=mass_err, plx_err=plx_err
)
# We could overwrite any priors we want to here.
# Using defaults for now.
bP_system.sys_priors[3] = priors.UniformPrior(np.pi/10, np.pi/2)
# Initialize Sampler object, which stores information about
# the likelihood function & the algorithm used to generate
# orbits, and has System object as an attribute.
bP_sampler = sampler.PTMCMC(likelihood_func_name,bP_system,n_temps,n_walkers,n_threads)
# Run the sampler to compute some orbits, yeah!
# Results stored in bP_sampler.chain and bP_sampler.lnlikes
bP_sampler.run_sampler(total_orbits, burn_steps=burn_steps, thin=10)
import h5py
import ctypes
fin = h5py.File("/indirect/big_scr6/jwang/demo.hdf5", "w")
chain = fin.create_dataset("chain", bP_sampler.chain.shape, dtype=ctypes.c_float)
chain[...] = bP_sampler.chain
fin.close()
for body in np.arange(num_secondary_bodies):
# Add semimajor axis prior
self.sys_priors.append(priors.LogUniformPrior(0.001, 1e7))
self.labels.append('sma{}'.format(body+1))
# Add eccentricity prior
self.sys_priors.append(priors.UniformPrior(0., 1.))
self.labels.append('ecc{}'.format(body+1))
# Add inclination angle prior
self.sys_priors.append(priors.SinPrior())
self.labels.append('inc{}'.format(body+1))
# Add argument of periastron prior
self.sys_priors.append(priors.UniformPrior(0., 2.*np.pi))
self.labels.append('aop{}'.format(body+1))
# Add position angle of nodes prior
self.sys_priors.append(priors.UniformPrior(0., angle_upperlim))
self.labels.append('pan{}'.format(body+1))
# Add epoch of periastron prior.
self.sys_priors.append(priors.UniformPrior(0., 1.))
self.labels.append('tau{}'.format(body+1))
#
# Set priors on total mass and parallax
#
self.labels.append('plx')
if plx_err > 0:
self.sys_priors.append(priors.GaussianPrior(plx, plx_err))
self.labels.append('ecc{}'.format(body+1))
# Add inclination angle prior
self.sys_priors.append(priors.SinPrior())
self.labels.append('inc{}'.format(body+1))
# Add argument of periastron prior
self.sys_priors.append(priors.UniformPrior(0., 2.*np.pi))
self.labels.append('aop{}'.format(body+1))
# Add position angle of nodes prior
self.sys_priors.append(priors.UniformPrior(0., angle_upperlim))
self.labels.append('pan{}'.format(body+1))
# Add epoch of periastron prior.
self.sys_priors.append(priors.UniformPrior(0., 1.))
self.labels.append('tau{}'.format(body+1))
#
# Set priors on total mass and parallax
#
self.labels.append('plx')
if plx_err > 0:
self.sys_priors.append(priors.GaussianPrior(plx, plx_err))
else:
self.sys_priors.append(plx)
# checking for rv data to include appropriate rv priors:
if len(self.rv[0]) > 0 and self.fit_secondary_mass:
self.sys_priors.append(priors.UniformPrior(-5, 5)) # gamma prior in km/s
self.labels.append('gamma')
self.sys_priors.append(priors.UniformPrior(0., 1.))
self.labels.append('tau{}'.format(body+1))
#
# Set priors on total mass and parallax
#
self.labels.append('plx')
if plx_err > 0:
self.sys_priors.append(priors.GaussianPrior(plx, plx_err))
else:
self.sys_priors.append(plx)
# checking for rv data to include appropriate rv priors:
if len(self.rv[0]) > 0 and self.fit_secondary_mass:
self.sys_priors.append(priors.UniformPrior(-5, 5)) # gamma prior in km/s
self.labels.append('gamma')
self.sys_priors.append(priors.LogUniformPrior(1e-4, 0.05)) # jitter prior in km/s
self.labels.append('sigma')
if self.fit_secondary_mass:
for body in np.arange(num_secondary_bodies)+1:
self.sys_priors.append(priors.LogUniformPrior(1e-6, 2)) # in Solar masses for now
self.labels.append('m{}'.format(body))
self.labels.append('m0')
else:
self.labels.append('mtot')
# still need to append m0/mtot, even though labels are appended above
if mass_err > 0:
self.sys_priors.append(priors.GaussianPrior(stellar_mass, mass_err))
self.labels.append('sma{}'.format(body+1))
# Add eccentricity prior
self.sys_priors.append(priors.UniformPrior(0., 1.))
self.labels.append('ecc{}'.format(body+1))
# Add inclination angle prior
self.sys_priors.append(priors.SinPrior())
self.labels.append('inc{}'.format(body+1))
# Add argument of periastron prior
self.sys_priors.append(priors.UniformPrior(0., 2.*np.pi))
self.labels.append('aop{}'.format(body+1))
# Add position angle of nodes prior
self.sys_priors.append(priors.UniformPrior(0., angle_upperlim))
self.labels.append('pan{}'.format(body+1))
# Add epoch of periastron prior.
self.sys_priors.append(priors.UniformPrior(0., 1.))
self.labels.append('tau{}'.format(body+1))
#
# Set priors on total mass and parallax
#
self.labels.append('plx')
if plx_err > 0:
self.sys_priors.append(priors.GaussianPrior(plx, plx_err))
else:
self.sys_priors.append(plx)
# checking for rv data to include appropriate rv priors: