Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
will be added to the Body. Else, a WD mesh will be added.
@type mesh: str (one of C{wd} or C{marching})
"""
#-- initialise all the variables and lists needed for the rvdep parameters
rv_dep = []
prim_rv = 0
sec_rv = 0
rv_pb = []
ld_coeffs1 = []
ld_coeffs2 = []
rv_file = []
#-- initialise the orbital and component parameter sets.
orbit = parameters.ParameterSet(frame='phoebe',context='orbit',add_constraints=True)
comp1 = parameters.ParameterSet(frame='phoebe',context='component',label='star1',
add_constraints=True)
comp2 = parameters.ParameterSet(frame='phoebe',context='component',label='star2',
add_constraints=True)
mesh1wd = parameters.ParameterSet(frame='phoebe',context='mesh:wd',add_constraints=True)
mesh2wd = parameters.ParameterSet(frame='phoebe',context='mesh:wd',add_constraints=True)
#-- Open the parameter file and read each line
ff = open(inputfile,'r')
lines = ff.readlines()
for l in lines:
#-- ignore initial comment
if l[0]=='#': continue
#-- try splitting the parameter name and value
try:
key, val = l.split('=')
totalmass = keplerorbit.third_law(sma=sma,period=period)
M1 = totalmass / (1.0 + q)
M2 = q * M1
# Derive radii at periastron passage
R1 = roche.potential2radius(pot1,q,1-ecc,f1,component=1,sma=sma)
R2 = roche.potential2radius(pot2,q,1-ecc,f2,component=2,sma=sma)
# Derive rotation period
rotperiod1 = period/f1
rotperiod2 = period/f2
# Build the stars with the basic parameters
star1 = parameters.ParameterSet(context='star', mass=(M1,'Msol'),
radius=(R1,'au'), rotperiod=(rotperiod1,'d'))
star2 = parameters.ParameterSet(context='star', mass=(M2,'Msol'),
radius=(R2,'au'), rotperiod=(rotperiod2,'d'))
# And copy some values straight from the components
for key in ['teff']:
star1[key] = comp1.get_value_with_unit(key)
star2[key] = comp2.get_value_with_unit(key)
for key in ['atm','label','ld_func','ld_coeffs','gravb','irradiator','alb']:
star1[key] = comp1[key]
star2[key] = comp2[key]
star1['label'] = comp1['label']
star2['label'] = comp2['label']
return star1, star2
def misaligned_binary(create_body=True):
"""
Default Phoebe2 misaligned binary system (primary is misaligned)
"""
component1 = parameters.ParameterSet('component', label='primary')
component2 = parameters.ParameterSet('component', label='secondary')
orbit = parameters.ParameterSet('orbit', c1label='primary', c2label='secondary', label='new_system')
tools.make_misaligned(orbit, theta=0.0, phi0=90.0, precperiod=np.inf)
comp1 = universe.MisalignedBinaryRocheStar(component=component1, orbit=orbit)
comp2 = universe.BinaryRocheStar(component=component2, orbit=orbit)
position = parameters.ParameterSet('position', distance=(10.,'pc'))
reddening = parameters.ParameterSet('reddening:interstellar')
return universe.BodyBag([comp1, comp2], label='new_system', reddening=reddening,
position=position)
starC['rotperiod'] = np.inf
starB['ld_func'] = 'linear'
starB['atm'] = 'blackbody'
starB['ld_coeffs'] = [0.5]
#-- inner binary
orbitBC = parameters.ParameterSet(frame='phoebe',context='orbit',add_constraints=True)
orbitBC['period'] = 1.76713,'d'
orbitBC['sma'] = 0.021986,'au'
orbitBC['ecc'] = 0.02334
orbitBC['per0'] = 89.52,'deg'
orbitBC['incl'] = 96.907-92.100,'deg'
orbitBC['long_an'] = 8.012,'deg'
#-- outer binary
orbitA_BC = parameters.ParameterSet(frame='phoebe',context='orbit',add_constraints=True)
orbitA_BC['period'] = 33.9214,'d'
orbitA_BC['sma'] = 0.2495,'au'
orbitA_BC['ecc'] = 0.3043
orbitA_BC['per0'] = 52.88,'deg'
orbitA_BC['incl'] = 92.100,'deg'
orbitA_BC['label'] = 'KOI126'
mean_anomaly = 19.87/180.*np.pi
orbitA_BC['t0'] = T0-keplerorbit.mean_anomaly_to_time(mean_anomaly,starA.request_value('mass','kg')+\
starB.request_value('mass','kg')+starC.request_value('mass','kg'),\
orbitA_BC.request_value('sma','m'))/(3600*24.)
mean_anomaly = 355.66/180.*np.pi
orbitBC['t0'] = T0-keplerorbit.mean_anomaly_to_time(mean_anomaly,starB.request_value('mass','kg')+\
starC.request_value('mass','kg'),\
orbitBC.request_value('sma','m'))/(3600*24.)
def add_compute(self,ps=None,**kwargs):
"""
Add a new compute ParameterSet
@param ps: compute ParameterSet
@type ps: None or ParameterSet
@param label: label of the compute options (will override label in ps)
@type label: str
"""
if ps is None:
ps = parameters.ParameterSet(context='compute')
for k,v in kwargs.items():
ps.set_value(k,v)
self._add_to_section('compute',ps)
self._attach_set_value_signals(ps)
def pulsating_star(create_body=True):
"""
Pulsating single star
"""
star = from_library('Sun', create_body=True)
star.set_params(parameters.ParameterSet('puls', ampl=0.1, amplteff=0.05, label='puls01'))
return star
def add_fitting(self,fitting=None,**kwargs):
"""
Add a new fitting ParameterSet
@param fitting: fitting ParameterSet
@type fitting: None, or ParameterSet
@param copy: whether to return deepcopy
@type copy: bool
"""
context = kwargs.pop('context', 'fitting:emcee')
if fitting is None:
fitting = parameters.ParameterSet(context=context)
# here override from defaults in fitting.cfg
for k,v in kwargs.items():
fitting.set_value(k,v)
self.sections['fitting'].append(fitting)
@type accept_feedback: bool
@param server: name of server to run on, or False to force locally (will override usersettings)
@type server: string
"""
if add_feedback is None:
add_feedback = self.settings['add_feedback_on_fitting']
if server is not None:
server = self.get_server(server)
mpi = server.mpi_ps
else:
mpi = None
# get fitting params
if fittinglabel is None:
fittingoptions = parameters.ParameterSet(context='fitting')
else:
fittingoptions = self.get_fitting(fittinglabel).copy()
# get compute params
if computelabel is None:
computeoptions = parameters.ParameterSet(context='compute')
else:
computeoptions = self.get_compute(label).copy()
# now temporarily override with any values passed through kwargs
for k,v in kwargs.items():
if k in options.keys():
options.set_value(k,v)
# now temporarily override with any values passed through kwargs
for k,v in kwargs.items():
- :ref:`fitting:grid `
- :ref:`feedback `, :ref:`iterate `
@param system: the system to fit
@type system: Body
@param params: computation parameters
@type params: ParameterSet
@param mpi: mpi parameters
@type mpi: ParameterSet
@param fitparams: fit algorithm parameters
@type fitparams: ParameterSet
@return: the grid sampling history (ParameterSet of context 'fitting:grid'
@rtype: ParameterSet
"""
if fitparams is None:
fitparams = parameters.ParameterSet(frame='phoebe',context='fitting:grid')
sampling = fitparams['sampling']
# We need unique names for the parameters that need to be fitted, we need
# initial values and identifiers to distinguish parameters with the same
# name (we'll also use the identifier in the parameter name to make sure
# they are unique). While we are iterating over all the parameterSets,
# we'll also have a look at what context they are in. From this, we decide
# which fitting algorithm to use.
ids = []
names = []
ranges = []
# Walk through all the parameterSets available. This needs to be via this
# this utility function because we need to iteratively walk down through all
# BodyBags too.