def __init__(self, num_secondary_bodies, data_table, system_mass, plx, mass_err=0, plx_err=0, restrict_angle_ranges=None, results=None): self.num_secondary_bodies = num_secondary_bodies self.sys_priors = [] self.labels = [] self.results = [] # # Group the data in some useful ways # self.data_table = data_table # List of arrays of indices corresponding to each body self.body_indices = [] # List of arrays of indices corresponding to epochs in RA/Dec for each body self.radec = [] # List of arrays of indices corresponding to epochs in SEP/PA for each body self.seppa = [] radec_indices = np.where(self.data_table['quant_type'] == 'radec') seppa_indices = np.where(self.data_table['quant_type'] == 'seppa') for body_num in np.arange(self.num_secondary_bodies + 1): self.body_indices.append( np.where(self.data_table['object'] == body_num)) self.radec.append( np.intersect1d(self.body_indices[body_num], radec_indices)) self.seppa.append( np.intersect1d(self.body_indices[body_num], seppa_indices)) if (len(radec_indices) + len(seppa_indices) == len( self.data_table)) and (restrict_angle_ranges is None): restrict_angle_ranges = True if restrict_angle_ranges: angle_upperlim = np.pi else: angle_upperlim = 2. * np.pi # # Set priors for each orbital element # for body in np.arange(num_secondary_bodies): # Add semimajor axis prior self.sys_priors.append(priors.JeffreysPrior(0.1, 100.)) 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., angle_upperlim)) 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('epp{}'.format(body + 1)) # # Set priors on total mass and parallax # self.labels.append('plx') self.labels.append('mtot') if plx_err > 0: self.sys_priors.append(priors.GaussianPrior(plx, plx_err)) else: self.sys_priors.append(plx) if mass_err > 0: self.sys_priors.append(priors.GaussianPrior(system_mass, mass_err)) else: self.sys_priors.append(system_mass) #add labels dictionary for parameter indexing self.param_idx = dict(zip(self.labels, np.arange(len(self.labels))))
system_mass, plx, mass_err=mass_err, plx_err=plx_err, sysrv=sysrv, sysrv_err=sysrv_err, mcmc_kwargs={ 'num_temps': num_temps, 'num_walkers': num_walkers, 'num_threads': num_threads }, system_kwargs={"restrict_angle_ranges": restrict_angle_ranges}, ) if len(planet) == 1: my_driver.system.sys_priors[0] = priors.JeffreysPrior(1, 1e2) my_driver.sampler = sampler.MCMC(my_driver.system, num_temps=num_temps, num_walkers=num_walkers, num_threads=num_threads, like='chi2_lnlike', custom_lnlike=None) if 1 and len(planet) == 1: _filename = os.path.join( astrometry_DATADIR, "figures", "HR_8799_" + planet, 'chain_' + rv_str + '_' + planet + '_it{0}_{1}_{2}_{3}_{4}_{5}_coplanar.fits'.format( itnum - 1, num_temps, num_walkers, 100000, thin, uservs)) print(_filename)