code
string
signature
string
docstring
string
loss_without_docstring
float64
loss_with_docstring
float64
factor
float64
kwargs['check_visible'] = check_visible kwargs['check_default'] = check_default # print "***", kwargs ps = self.filter(twig=twig, **kwargs) if not len(ps): # TODO: custom exception? raise ValueError("0 results found") elif len(ps) != 1: ...
def get(self, twig=None, check_visible=True, check_default=True, **kwargs)
Get a single parameter from this ParameterSet. This works exactly the same as filter except there must be only a single result, and the Parameter itself is returned instead of a ParameterSet. Also see :meth:`get_parameter` (which is simply an alias of this method) :parameter str twig:...
4.657818
4.155999
1.120746
return self - self.filter(twig=twig, check_visible=check_visible, **kwargs)
def exclude(self, twig=None, check_visible=True, **kwargs)
Exclude the results from this filter from the current ParameterSet. See :meth:`filter` for options.
5.183196
5.197235
0.997299
ps = self.filter_or_get(qualifier=qualifier, **kwargs) if isinstance(ps, Parameter): return ps, False elif len(ps): # TODO: custom exception? raise ValueError("more than 1 result was found") else: self._attach_params(ParameterSet([...
def get_or_create(self, qualifier, new_parameter, **kwargs)
Get a :class:`Parameter` from the ParameterSet, if it does not exist, create and attach it. Note: running this on a ParameterSet that is NOT a :class:`phoebe.frontend.bundle.Bundle`, will NOT add the Parameter to the bundle, but only the temporary ParameterSet :paramete...
4.836788
4.20376
1.150586
# TODO: check to see if protected (required by a current constraint or # by a backend) self._params = [p for p in self._params if p != param]
def _remove_parameter(self, param)
Remove a Parameter from the ParameterSet :parameter param: the :class:`Parameter` object to be removed :type param: :class:`Parameter`
16.2873
18.035191
0.903084
param = self.get(twig=twig, **kwargs) self._remove_parameter(param)
def remove_parameter(self, twig=None, **kwargs)
Remove a :class:`Parameter` from the ParameterSet Note: removing Parameters from a ParameterSet will not remove them from any parent ParameterSets (including the :class:`phoebe.frontend.bundle.Bundle`) :parameter str twig: the twig to search for the parameter :parameter **kwarg...
5.499566
7.468978
0.736321
params = self.filter(twig=twig, check_visible=False, check_default=False, **kwargs) for param in params.to_list(): self._remove_parameter(param)
def remove_parameters_all(self, twig=None, **kwargs)
Remove all :class:`Parameter`s that match the search from the ParameterSet. Any Parameter that would be included in the resulting ParameterSet from a :func:`filter` call with the same arguments will be removed from this ParameterSet. Note: removing Parameters from a ParameterSe...
5.376429
7.068092
0.760662
# TODO: for time derivatives will need to use t instead of time (time # gets passed to twig filtering) if default is not None is not None: # then we need to do a filter first to see if parameter exists if not len(self.filter(twig=twig, **kwargs)): ...
def get_quantity(self, twig=None, unit=None, default=None, t=None, **kwargs)
TODO: add documentation
7.718192
7.470244
1.033191
# TODO: handle twig having parameter key (value@, default_unit@, adjust@, etc) # TODO: does this return anything (update the docstring)? return self.get_parameter(twig=twig, **kwargs).set_quantity(value=value, **kwargs)
def set_quantity(self, twig=None, value=None, **kwargs)
TODO: add documentation
17.217459
15.522491
1.109194
# TODO: for time derivatives will need to use t instead of time (time # gets passed to twig filtering) if default is not None: # then we need to do a filter first to see if parameter exists if not len(self.filter(twig=twig, **kwargs)): return def...
def get_value(self, twig=None, unit=None, default=None, t=None, **kwargs)
Get the value of a :class:`Parameter` in this ParameterSet :parameter str twig: the twig to search for the parameter :parameter unit: units for the returned result (if applicable). If None or not provided, the value will be returned in that Parameter's default_unit (if ...
6.837676
6.233988
1.096838
# TODO: handle twig having parameter key (value@, default_unit@, adjust@, etc) # TODO: does this return anything (update the docstring)? if twig is not None and value is None: # then try to support value as the first argument if no matches with twigs if not isins...
def set_value(self, twig=None, value=None, **kwargs)
Set the value of a :class:`Parameter` in this ParameterSet Note: setting the value of a Parameter in a ParameterSet WILL change that Parameter across any parent ParameterSets (including the :class:`phoebe.frontend.bundle.Bundle`) :parameter set twig: the twig to search for the paramete...
6.768817
6.440697
1.050945
if twig is not None and value is None: # then try to support value as the first argument if no matches with twigs if not isinstance(twig, str): value = twig twig = None elif not len(self.filter(twig=twig, check_default=check_default, ...
def set_value_all(self, twig=None, value=None, check_default=False, **kwargs)
Set the value of all returned :class:`Parameter`s in this ParameterSet. Any :class:`Parameter` that would be included in the resulting ParameterSet from a :func:`filter` call with the same arguments will have their value set. Note: setting the value of a Parameter in a ParameterSet WIL...
4.236095
4.202339
1.008033
return self.get_parameter(twig=twig, **kwargs).get_default_unit()
def get_default_unit(self, twig=None, **kwargs)
TODO: add documentation
5.28401
3.942966
1.340111
if twig is not None and unit is None: # then try to support value as the first argument if no matches with twigs if isinstance(unit, u.Unit) or not isinstance(twig, str): unit = twig twig = None elif not len(self.filter(twig=twig, che...
def set_default_unit(self, twig=None, unit=None, **kwargs)
TODO: add documentation
6.370314
6.200592
1.027372
if twig is not None and unit is None: # then try to support value as the first argument if no matches with twigs if isinstance(unit, u.Unit) or not isinstance(twig, str): unit = twig twig = None elif not len(self.filter(twig=twig, che...
def set_default_unit_all(self, twig=None, unit=None, **kwargs)
TODO: add documentation
6.187865
6.01194
1.029263
return self.get_parameter(twig=twig, **kwargs).get_description()
def get_description(self, twig=None, **kwargs)
TODO: add documentation
6.217199
4.581664
1.356974
if animate and not show and not save: logger.warning("setting show to True since animate=True and save not provided") show = True if animate: # prefer times over time times = kwargs.get('times', kwargs.get('time', None)) save_kwargs =...
def _show_or_save(self, save, show, animate, draw_sidebars=True, draw_title=True, tight_layout=False, subplot_grid=None, **kwargs)
Draw/animate and show and/or save a autofig plot
3.992759
3.923128
1.017749
kwargs.setdefault('show', True) kwargs.setdefault('save', False) kwargs.setdefault('animate', False) return self._show_or_save(**kwargs)
def show(self, **kwargs)
Draw and show the plot.
4.100742
3.590332
1.142162
filename = os.path.expanduser(filename) kwargs.setdefault('show', False) kwargs.setdefault('save', filename) kwargs.setdefault('animate', False) return self._show_or_save(**kwargs)
def savefig(self, filename, **kwargs)
Draw and save the plot. :parameter str filename: filename to save to. Be careful of extensions here... matplotlib accepts many different image formats while other backends will only export to html.
4.540197
5.766174
0.787385
s = self.to_json() cpy = parameter_from_json(s) # TODO: may need to subclass for Parameters that require bundle by using this line instead: # cpy = parameter_from_json(s, bundle=self._bundle) cpy.set_uniqueid(_uniqueid()) return cpy
def copy(self)
Deepcopy the parameter (with a new uniqueid). All other tags will remain the same... so some other tag should be changed before attaching back to a ParameterSet or Bundle. :return: the copied :class:`Parameter` object
12.585782
9.167743
1.372833
if hasattr(self, 'constrained_by') and len(self.constrained_by) > 0: return "* {:>30}: {}".format(self.uniquetwig_trunc, self.get_quantity() if hasattr(self, 'quantity') else self.get_value()) else: return "{:>32}: {}".format(self.uniquetwig_trunc, self.get_quantity() if...
def to_string_short(self)
see also :meth:`to_string` :return: a shorter abreviated string reprentation of the parameter
4.519995
4.698044
0.962101
filename = os.path.expanduser(filename) f = open(filename, 'w') json.dump(self.to_json(incl_uniqueid=incl_uniqueid), f, sort_keys=True, indent=0, separators=(',', ': ')) f.close() return filename
def save(self, filename, incl_uniqueid=False)
Save the Parameter to a JSON-formatted ASCII file :parameter str filename: relative or fullpath to the file :return: filename :rtype: str
2.437037
2.642322
0.922309
def _parse(k, v): if k=='value': if isinstance(self._value, nparray.ndarray): if self._value.unit is not None and hasattr(self, 'default_unit'): v = self._value.to(self.default_unit).to_dict() else:...
def to_json(self, incl_uniqueid=False)
:return: a JSON-ready dictionary holding all information for this parameter
3.813682
3.813151
1.000139
return OrderedDict([(k, getattr(self, k)) for k in _meta_fields_all if k not in ignore])
def get_meta(self, ignore=['uniqueid'])
See all the meta-tag properties for this Parameter :parameter list ignore: list of keys to exclude from the returned dictionary :return: an ordered dictionary of tag properties
5.415915
7.617987
0.710938
if ps is None: ps = self._bundle if ps is None: return self.twig return ps._uniquetwig(self.twig)
def uniquetwig(self, ps=None)
see also :meth:`twig` Determine the shortest (more-or-less) twig which will point to this single Parameter in a given parent :class:`ParameterSet` :parameter ps: :class:`ParameterSet` in which the returned uniquetwig will point to this Parameter. If not provided or Non...
6.078891
4.774642
1.273162
return "@".join([getattr(self, k) for k in _meta_fields_twig if getattr(self, k) is not None])
def twig(self)
The twig of a Parameter is a single string with the individual :meth:`meta` tags separated by '@' symbols. This twig gives a single string which can point back to this Parameter. see also :meth:`uniquetwig` :return: twig (full) of this Parameter
9.361527
11.462349
0.81672
def is_visible_single(visible_if): # visible_if syntax: [ignore,these]qualifier:value if visible_if.lower() == 'false': return False # otherwise we need to find the parameter we're referencing and check its value if visible_if[0]=='[': ...
def is_visible(self)
see also :meth:`visible_if` :return: whether this parameter is currently visible (and therefore shown in ParameterSets and visible to :meth:`ParameterSet.filter`) :rtype: bool
5.773333
5.725249
1.008399
if self._bundle is None: return None metawargs = {k:v for k,v in self.meta.items() if k not in ['qualifier', 'twig', 'uniquetwig']} return self._bundle.filter(**metawargs)
def get_parent_ps(self)
Return a :class:`ParameterSet` of all Parameters in the same :class:`phoebe.frontend.bundle.Bundle` which share the same meta-tags (except qualifier, twig, uniquetwig) :return: the parent :class:`ParameterSet`
12.858848
4.233209
3.037612
if self.qualifier in kwargs.keys(): # then we have an "override" value that was passed, and we should # just return that. # Example teff_param.get_value('teff', teff=6000) returns 6000 return kwargs.get(self.qualifier) return None
def get_value(self, *args, **kwargs)
This method should be overriden by any subclass of Parameter, and should be decorated with the @update_if_client decorator. Please see the individual classes documentation: * :meth:`FloatParameter.get_value` * :meth:`ArrayParameter.get_value` * :meth:`HierarchyParame...
8.382403
10.210029
0.820997
selection = [] for v in self.get_value(**kwargs): for choice in self.choices: if v==choice and choice not in selection: selection.append(choice) elif fnmatch(choice, v) and choice not in selection: selection.app...
def expand_value(self, **kwargs)
expand the selection to account for wildcards
3.739032
3.081684
1.213308
value = [v for v in self.get_value() if self.valid_selection(v)] self.set_value(value)
def remove_not_valid_selections(self)
update the value to remove any that are (no longer) valid
4.564979
3.30033
1.383188
return (self.limits[0] is None or value >= self.limits[0]) and (self.limits[1] is None or value <= self.limits[1])
def within_limits(self, value)
check whether a value falls within the set limits :parameter value: float or Quantity to test. If value is a float, it is assumed that it has the same units as default_units
2.617558
2.805488
0.933014
if isinstance(value, int) or isinstance(value, float): value = value * self.default_unit return (self.limits[0] is None or value >= self.limits[0]) and (self.limits[1] is None or value <= self.limits[1])
def within_limits(self, value)
check whether a value falls within the set limits :parameter value: float or Quantity to test. If value is a float, it is assumed that it has the same units as default_units
2.605259
2.405729
1.08294
if self._is_constraint is None: return None return self._bundle.get_parameter(context='constraint', uniqueid=self._is_constraint)
def is_constraint(self)
returns the expression of the constraint that constrains this parameter
12.801581
8.615189
1.485932
if self._is_constraint is None: return [] params = [] for var in self.is_constraint._vars: param = var.get_parameter() if param.uniqueid != self.uniqueid: params.append(param) return params
def constrained_by(self)
returns a list of parameters that constrain this parameter
5.727289
4.551027
1.258461
expressions = [] for uniqueid in self._in_constraints: expressions.append(self._bundle.get_parameter(context='constraint', uniqueid=uniqueid)) return expressions
def in_constraints(self)
returns a list of the expressions in which this parameter constrains another
10.17793
8.094599
1.257373
params = [] for constraint in self.in_constraints: for var in constraint._vars: param = var.get_parameter() if param.component == constraint.component and param.qualifier == constraint.qualifier: if param not in params and param.un...
def constrains(self)
returns a list of parameters that are constrained by this parameter
5.105208
4.434852
1.151157
params = [] constraints = self.in_constraints if self.is_constraint is not None: constraints.append(self.is_constraint) for constraint in constraints: for var in constraint._vars: param = var.get_parameter() if param not i...
def related_to(self)
returns a list of all parameters that are either constrained by or constrain this parameter
4.352293
3.278968
1.327336
opt = np.get_printoptions() np.set_printoptions(threshold=8, edgeitems=3, linewidth=opt['linewidth']-len(self.uniquetwig)-2) str_ = super(FloatArrayParameter, self).to_string_short() np.set_printoptions(**opt) return str_
def to_string_short(self)
see also :meth:`to_string` :return: a shorter abreviated string reprentation of the parameter
6.53434
6.377415
1.024606
# TODO: add support for units # TODO: add support for non-linear interpolation (probably would need to use scipy)? # TODO: add support for interpolating in phase_space if len(kwargs.keys()) > 1: raise KeyError("interp_value only takes a single qualifier-value pair")...
def interp_value(self, **kwargs)
Interpolate to find the value in THIS array given a value from ANOTHER array in the SAME parent :class:`ParameterSet` This currently only supports simple 1d linear interpolation (via numpy.interp) and does no checks to make sure you're interpolating with respect to an independent parame...
6.065485
4.612261
1.315078
if not isinstance(self._value, nparray.ndarray): raise ValueError("value is not a nparray object") for property, value in kwargs.items(): setattr(self._value, property, value)
def set_property(self, **kwargs)
set any property of the underlying nparray object
4.916221
3.223011
1.525351
repr_ = self.get_value() repr_str = '["{}"]'.format(repr_.replace(', ', '", "').replace('(', '", ["').replace(')', '"]')).replace(']"', '"]').replace('""', '"').replace(']"', ']') return json.loads(repr_str)
def _parse_repr(self)
turn something like "orbit:outer(orbit:inner(star:starA, star:starB), star:starC)" into ['orbit:outer', ['orbit:inner', ['star:starA', 'star:starB'], 'star:starC']]
7.183147
5.438761
1.320732
try: i = structure.index(item) except ValueError: for j,substructure in enumerate(structure): if isinstance(substructure, list): return self._recurse_find_trace(substructure, item, trace+[j]) else: return trace+[i]
def _recurse_find_trace(self, structure, item, trace=[])
given a nested structure from _parse_repr and find the trace route to get to item
2.336532
2.27704
1.026127
for i in trace: structure = structure[i] return structure
def _get_by_trace(self, structure, trace)
retrieve an item from the nested structure from _parse_repr given a trace (probably modified from _recurse_find_trace)
8.723035
5.319206
1.639913
l = re.findall(r"[\w']+", self.get_value()) # now search for indices of star and take the next entry from this flat list return [l[i+1] for i,s in enumerate(l) if s=='star']
def get_stars(self)
get 'component' of all stars in order primary -> secondary
11.570756
9.691164
1.193949
#~ l = re.findall(r"[\w']+", self.get_value()) # now search for indices of orbit and take the next entry from this flat list #~ return [l[i+1] for i,s in enumerate(l) if s=='orbit'] orbits = [] for star in self.get_stars(): parent = self.get_parent_of(star) ...
def get_orbits(self)
get 'component' of all orbits in order primary -> secondary
6.367996
5.590562
1.139062
sibling = self.get_sibling_of(component) if sibling in self.get_stars(): return sibling stars = [child for child in self.get_stars_of_children_of(sibling)] # TODO: do we need to make sure there aren't duplicates? # return list(set(stars)) return ...
def get_stars_of_sibling_of(self, component)
same as get_sibling_of except if the sibling is an orbit, this will recursively follow the tree to return a list of all stars under that orbit
4.528728
4.009229
1.129576
structure, trace, item = self._get_structure_and_trace(component) item_kind, item_label = item.split(':') if isinstance(kind, str): kind = [kind] if item_kind not in ['orbit']: # return None return [] else: items = self....
def get_children_of(self, component, kind=None)
get to component labels of the children of a given component
4.793083
4.629704
1.035289
stars = self.get_stars() orbits = self.get_orbits() stars_children = [] for child in self.get_children_of(component): if child in stars: stars_children.append(child) elif child in orbits: stars_children += self.get_stars_...
def get_stars_of_children_of(self, component)
same as get_children_of except if any of the children are orbits, this will recursively follow the tree to return a list of all children (grandchildren, etc) stars under that orbit
4.052608
3.551973
1.140946
children = self.get_children_of(component, kind=kind) if children is None: return None else: return children[ind]
def get_child_of(self, component, ind, kind=None)
get a child (by index) of a given component
2.676798
2.466941
1.085068
parent = self.get_parent_of(component) if parent is None: # then this is a single component, not in a binary return 'primary' children_of_parent = self.get_children_of(parent) ind = children_of_parent.index(component) if ind > 1: re...
def get_primary_or_secondary(self, component, return_ind=False)
return whether a given component is the 'primary' or 'secondary' component in its parent orbit
4.110916
3.764654
1.091977
l = re.findall(r"[\w']+", self.get_value()) # now search for indices of star and take the next entry from this flat list meshables = [l[i+1] for i,s in enumerate(l) if s in ['star', 'envelope']] # now we want to remove any star which has a sibling envelope has_sibling_...
def get_meshables(self)
return a list of components that are meshable (generally stars, but handles the envelope for an contact_binary)
6.481849
5.486671
1.181381
if component not in self._is_contact_binary.keys(): self._update_cache() return self._is_contact_binary.get(component)
def is_contact_binary(self, component)
especially useful for constraints tells whether any component (star, envelope) is part of a contact_binary by checking its siblings for an envelope
4.540682
4.590373
0.989175
if component not in self._is_binary.keys(): self._update_cache() return self._is_binary.get(component)
def is_binary(self, component)
especially useful for constraints tells whether any component (star, envelope) is part of a binary by checking its parent
5.333884
5.339405
0.998966
# cache _var_params if self._var_params is None: self._var_params = ParameterSet([var.get_parameter() for var in self._vars]) return self._var_params
def vars(self)
return all the variables in a PS
5.133895
5.271564
0.973885
kwargs['twig'] = twig kwargs['check_default'] = False kwargs['check_visible'] = False ps = self.vars.filter(**kwargs) if len(ps)==1: return ps.get(check_visible=False, check_default=False) elif len(ps) > 1: # TODO: is this safe? Some cons...
def get_parameter(self, twig=None, **kwargs)
get a parameter from those that are variables
7.800228
7.21034
1.081811
_orig_expression = self.get_value() # try to get the parameter from the bundle kwargs['twig'] = twig newly_constrained_var = self._get_var(**kwargs) newly_constrained_param = self.get_parameter(**kwargs) check_kwargs = {k:v for k,v in newly_constrained_param.m...
def flip_for(self, twig=None, expression=None, **kwargs)
flip the constraint to solve for for any of the parameters in the expression expression (optional if sympy available, required if not)
6.36844
6.285535
1.01319
if self._value == 'loaded': status = 'loaded' elif not _is_server and self._bundle is not None and self._server_status is not None: if not _can_requests: raise ImportError("requests module required for external jobs") if self._value in ['com...
def get_status(self)
[NOT IMPLEMENTED]
7.114625
6.972108
1.020441
form_kwargs = self.get_form_kwargs() # @@@ remove fields that would cause the form to be bound # when instantiated bound_fields = ["data", "files"] for field in bound_fields: form_kwargs.pop(field, None) return self.get_form_class()(**form_kwargs)
def get_unbound_form(self)
Overrides behavior of FormView.get_form_kwargs when method is POST or PUT
4.779594
4.492742
1.063848
data = { "html": render_to_string( "pinax/teams/_invite_form.html", { "invite_form": self.get_unbound_form(), "team": self.team }, request=self.request ) } me...
def get_form_success_data(self, form)
Allows customization of the JSON data returned when a valid form submission occurs.
2.887729
2.812576
1.026721
# TODO: this is ugly and makes everything ugly # can we handle this with a clean decorator or just requiring that only floats be passed?? if hasattr(obj, 'value'): return obj.value elif isinstance(obj, np.ndarray): return np.array([o.value for o in obj]) elif hasattr(obj, '__ite...
def _value(obj)
make sure to get a float
5.573536
5.076232
1.097967
return np.sqrt(4./np.sqrt(3) * float(area) / float(ntriangles))
def _estimate_delta(ntriangles, area)
estimate the value for delta to send to marching based on the number of requested triangles and the expected surface area of mesh
6.616459
7.204944
0.918322
hier = b.hierarchy if not len(hier.get_value()): raise NotImplementedError("Meshing requires a hierarchy to exist") # now pull general compute options if compute is not None: if isinstance(compute, str): compute_ps = b.get_compute(comp...
def from_bundle(cls, b, compute=None, datasets=[], **kwargs)
Build a system from the :class:`phoebe.frontend.bundle.Bundle` and its hierarchy. :parameter b: the :class:`phoebe.frontend.bundle.Bundle` :parameter str compute: name of the computeoptions in the bundle :parameter list datasets: list of names of datasets :parameter **kwargs: te...
4.204144
4.141336
1.015166
if component in self._bodies.keys(): return self._bodies[component] else: # then hopefully we're a child star of an contact_binary envelope parent_component = self._parent_envelope_of[component] return self._bodies[parent_component].get_half(compo...
def get_body(self, component)
TODO: add documentation
12.746766
11.465027
1.111796
self.xs = np.array(_value(xs)) self.ys = np.array(_value(ys)) self.zs = np.array(_value(zs)) for starref,body in self.items(): body.update_position(time, xs, ys, zs, vxs, vys, vzs, ethetas, elongans, eincls, ...
def update_positions(self, time, xs, ys, zs, vxs, vys, vzs, ethetas, elongans, eincls, ds=None, Fs=None, ignore_effects=False)
TODO: add documentation all arrays should be for the current time, but iterable over all bodies
2.756618
2.577188
1.069623
if self.irrad_method is not 'none' and not ignore_effects: # TODO: only for kinds that require intensities (i.e. not orbit or # dynamical RVs, etc) self.handle_reflection() for kind, dataset in zip(kinds, datasets): for starref, body in self.it...
def populate_observables(self, time, kinds, datasets, ignore_effects=False)
TODO: add documentation ignore_effects: whether to ignore reflection and features (useful for computing luminosities)
11.048758
10.713653
1.031278
eclipse_method = kwargs.get('eclipse_method', self.eclipse_method) horizon_method = kwargs.get('horizon_method', self.horizon_method) # Let's first check to see if eclipses are even possible at these # positions. If they are not, then we only have to do horizon # ...
def handle_eclipses(self, expose_horizon=False, **kwargs)
Detect the triangles at the horizon and the eclipsed triangles, handling any necessary subdivision. :parameter str eclipse_method: name of the algorithm to use to detect the horizon or eclipses (defaults to the value set by computeoptions) :parameter str subdiv_alg: name of the algo...
4.692637
4.817507
0.97408
logger.debug("{}.instantaneous_maxr".format(self.component)) if 'maxr' not in self.inst_vals.keys(): logger.debug("{}.instantaneous_maxr COMPUTING".format(self.component)) self.inst_vals['maxr'] = max(self.mesh.rs.centers*self._scale) return self.inst_vals['ma...
def instantaneous_maxr(self)
Recall the maximum r (triangle furthest from the center of the star) of this star at the given time :return: maximum r :rtype: float
4.957175
5.216095
0.950361
if hasattr(index, '__iter__'): return sum([self.masses[i] for i in index]) else: return self.masses[index]
def _get_mass_by_index(self, index)
where index can either by an integer or a list of integers (returns some of masses)
2.632565
2.045639
1.286916
if hasattr(index, '__iter__'): # then we want the center-of-mass coordinates # TODO: clean this up return np.average([_value(coords_array[i]) for i in index], weights=[self._get_mass_by_index(i) for i in index]) else: ...
def _get_coords_by_index(self, coords_array, index)
where index can either by an integer or a list of integers (returns some of masses) coords_array should be a single array (xs, ys, or zs)
4.684193
4.431062
1.057127
# TODO: allow this to take etheta and retreive a mesh at that true anomaly theta = 0.0 protomesh = self._standard_meshes[theta] #.copy() # if theta in self._standard_meshes.keys() else self.mesh.copy() if scaled: # TODO: be careful about self._scale... we may want s...
def get_standard_mesh(self, scaled=True)
TODO: add documentation
10.152263
9.593312
1.058265
self.true_anom = true_anom self.elongan = elongan self.eincl = eincl self.time = time self.populated_at_time = [] self.reset() return
def reset_time(self, time, true_anom, elongan, eincl)
TODO: add documentation
3.278537
3.190156
1.027704
if kind in ['mesh', 'orb']: return if time==self.time and dataset in self.populated_at_time and 'pblum' not in kind: # then we've already computed the needed columns # TODO: handle the case of intensities already computed by # /different/ datas...
def populate_observable(self, time, kind, dataset, **kwargs)
TODO: add documentation
12.577874
12.402858
1.014111
return mesh.spin_in_roche(self.polar_direction_uvw, self.true_anom, self.elongan, self.eincl).astype(float)
def polar_direction_xyz(self)
get current polar direction in Roche (xyz) coordinates
42.512295
27.106421
1.568348
# TODO: make this a function of d instead of etheta? logger.debug("determining target volume at t={}, theta={}".format(self.time, etheta)) # TODO: eventually this could allow us to "break" volume conservation # and have volume be a function of d, with some scaling factor provid...
def get_target_volume(self, etheta=0.0, scaled=False)
TODO: add documentation get the volume that the Star should have at a given euler theta
10.028481
9.809793
1.022293
# TODO: is this rpole scaling true for all distortion_methods?? rpole = self.instantaneous_rpole*self.sma return self.polar_direction_uvw*rpole+self.mesh._pos
def north_pole_uvw(self)
location of the north pole in the global/system frame
43.883785
43.141232
1.017212
logger.debug("{}.instantaneous_tpole".format(self.component)) if 'tpole' not in self.inst_vals.keys(): logger.debug("{}.instantaneous_tpole COMPUTING".format(self.component)) if self.mesh is None: raise ValueError("mesh must be computed before determini...
def instantaneous_tpole(self)
compute the instantaenous temperature at the pole to achieve the mean effective temperature (teff) provided by the user
9.21963
8.615151
1.070165
logger.debug("{}._fill_loggs".format(self.component)) if mesh is None: mesh = self.mesh loggs = np.log10(mesh.normgrads.for_computations * g_rel_to_abs(self.masses[self.ind_self], self.sma)) if not ignore_effects: for feature in self.features: ...
def _fill_loggs(self, mesh=None, ignore_effects=False)
TODO: add documentation Calculate local surface gravity GMSunNom = 1.3271244e20 m**3 s**-2 RSunNom = 6.597e8 m
5.716223
5.703029
1.002314
logger.debug("{}._fill_gravs".format(self.component)) if mesh is None: mesh = self.mesh # TODO: rename 'gravs' to 'gdcs' (gravity darkening corrections) gravs = ((mesh.normgrads.for_computations * g_rel_to_abs(self.masses[self.ind_self], self.sma))/self.instantane...
def _fill_gravs(self, mesh=None, **kwargs)
TODO: add documentation requires _fill_loggs to have been called
11.394106
10.753775
1.059545
r logger.debug("{}._fill_teffs".format(self.component)) if mesh is None: mesh = self.mesh # Now we can compute the local temperatures. # see PHOEBE Legacy scientific reference eq 5.23 teffs = self.instantaneous_tpole*mesh.gravs.for_computations**0.25 ...
def _fill_teffs(self, mesh=None, ignore_effects=False, **kwargs)
r""" requires _fill_loggs and _fill_gravs to have been called Calculate local temperature of a Star.
7.048918
6.739264
1.045948
logger.debug("{}._fill_abuns".format(self.component)) if mesh is None: mesh = self.mesh # TODO: support from frontend mesh.update_columns(abuns=abun) if not self.needs_recompute_instantaneous: logger.debug("{}._fill_abuns: copying abuns to sta...
def _fill_abuns(self, mesh=None, abun=0.0)
TODO: add documentation
6.775132
6.335988
1.06931
logger.debug("{}._fill_albedos".format(self.component)) if mesh is None: mesh = self.mesh mesh.update_columns(irrad_frac_refl=irrad_frac_refl) if not self.needs_recompute_instantaneous: logger.debug("{}._fill_albedos: copying albedos to standard mesh"....
def _fill_albedos(self, mesh=None, irrad_frac_refl=0.0)
TODO: add documentation
4.061365
3.85045
1.054777
logger.debug("{}.compute_pblum_scale(dataset={}, pblum={})".format(self.component, dataset, pblum)) abs_luminosity = self.compute_luminosity(dataset, **kwargs) # We now want to remember the scale for all intensities such that the # luminosity in relative units gives the provid...
def compute_pblum_scale(self, dataset, pblum, **kwargs)
intensities should already be computed for this dataset at the time for which pblum is being provided TODO: add documentation
4.752468
4.518362
1.051812
logger.debug("{}._populate_lp(dataset={})".format(self.component, dataset)) profile_rest = kwargs.get('profile_rest', self.lp_profile_rest.get(dataset)) rv_cols = self._populate_rv(dataset, **kwargs) cols = rv_cols # rvs = (rv_cols['rvs']*u.solRad/u.d).to(u.m/u.s).val...
def _populate_lp(self, dataset, **kwargs)
Populate columns necessary for an LP dataset This should not be called directly, but rather via :meth:`Body.populate_observable` or :meth:`System.populate_observables`
6.531996
6.140492
1.063758
logger.debug("{}._populate_rv(dataset={})".format(self.component, dataset)) # We need to fill all the flux-related columns so that we can weigh each # triangle's rv by its flux in the requested passband. lc_cols = self._populate_lc(dataset, **kwargs) # rv per element i...
def _populate_rv(self, dataset, **kwargs)
Populate columns necessary for an RV dataset This should not be called directly, but rather via :meth:`Body.populate_observable` or :meth:`System.populate_observables`
12.719056
12.312061
1.033057
# TODO: may be able to get away with removing the features check and just doing for pulsations, etc? # TODO: what about dpdt, deccdt, dincldt, etc? return len(self.features) > 0 or self.is_misaligned or self.ecc != 0 or self.dynamics_method != 'keplerian'
def needs_remesh(self)
whether the star needs to be re-meshed (for any reason)
23.223019
19.590075
1.185448
# need the sma to scale between Roche and real units sma = kwargs.get('sma', self.sma) # Rsol (same units as coordinates) mesh_args = self.instantaneous_mesh_args if mesh_method == 'marching': # TODO: do this during mesh initialization only and then keep delta fi...
def _build_mesh(self, mesh_method, **kwargs)
this function takes mesh_method and kwargs that came from the generic Body.intialize_mesh and returns the grid... intialize mesh then takes care of filling columns and rescaling to the correct units, etc
6.354696
6.37358
0.997037
# if we don't provide instantaneous masses or smas, then assume they are # not time dependent - in which case they were already stored in the init sma = kwargs.get('sma', self.sma) # Rsol (same units as coordinates) mesh_args = self.instantaneous_mesh_args if mesh_me...
def _build_mesh(self, mesh_method, **kwargs)
this function takes mesh_method and kwargs that came from the generic Body.intialize_mesh and returns the grid... intialize mesh then takes care of filling columns and rescaling to the correct units, etc
6.588287
6.651826
0.990448
for half in self._halves: half.populate_observable(time, kind, dataset, **kwargs)
def populate_observable(self, time, kind, dataset, **kwargs)
TODO: add documentation
5.261744
4.905539
1.072613
feature_ps = b.get_feature(feature) colat = feature_ps.get_value('colat', unit=u.rad) longitude = feature_ps.get_value('long', unit=u.rad) if len(b.hierarchy.get_stars())>=2: star_ps = b.get_component(feature_ps.component) orbit_ps = b.get_component(b....
def from_bundle(cls, b, feature)
Initialize a Spot feature from the bundle.
3.378227
3.350457
1.008288
t = time - self._t0 longitude = self._longitude + self._dlongdt * t # define the basis vectors in the spin (primed) coordinates in terms of # the Roche coordinates. # ez' = s # ex' = (ex - s(s.ex)) /|i - s(s.ex)| # ey' = s x ex' ex = np.array([1...
def pointing_vector(self, s, time)
s is the spin vector in roche coordinates time is the current time
7.303915
6.700658
1.090029
if t is None: # then assume at t0 t = self._t0 pointing_vector = self.pointing_vector(s,t) logger.debug("spot.process_teffs at t={} with pointing_vector={} and radius={}".format(t, pointing_vector, self._radius)) cos_alpha_coords = np.dot(coords, pointi...
def process_teffs(self, teffs, coords, s=np.array([0., 0., 1.]), t=None)
Change the local effective temperatures for any values within the "cone" defined by the spot. Any teff within the spot will have its current value multiplied by the "relteff" factor :parameter array teffs: array of teffs for computations :parameter array coords: array of coords for com...
4.384933
3.790871
1.156708
feature_ps = b.get_feature(feature) freq = feature_ps.get_value('freq', unit=u.d**-1) radamp = feature_ps.get_value('radamp', unit=u.dimensionless_unscaled) l = feature_ps.get_value('l', unit=u.dimensionless_unscaled) m = feature_ps.get_value('m', unit=u.dimensionless_u...
def from_bundle(cls, b, feature)
Initialize a Pulsation feature from the bundle.
4.855508
4.754161
1.021317
pot = globals()[pot_name] dpdx = globals()['d%sdx'%(pot_name)] dpdy = globals()['d%sdy'%(pot_name)] dpdz = globals()['d%sdz'%(pot_name)] dpdr = globals()['d%sdr'%(pot_name)] n_iter = 0 rmag, rmag0 = np.sqrt((r*r).sum()), 0 lam, nu = r[0]/rmag, r[2]/rmag dc = np.array((lam, np...
def project_onto_potential(r, pot_name, *args)
TODO: add documentation
4.040298
3.995276
1.011269
if not conf.devel: raise NotImplementedError("'from_server' not officially supported for this release. Enable developer mode to test.") # TODO: run test message on server, if localhost and fails, attempt to # launch? url = "{}/{}/json".format(server, bundleid) ...
def from_server(cls, bundleid, server='http://localhost:5555', as_client=True)
Load a new bundle from a server. [NOT IMPLEMENTED] Load a bundle from a phoebe server. This is a constructor so should be called as: >>> b = Bundle.from_server('asdf', as_client=False) :parameter str bundleid: the identifier given to the bundle by the server ...
6.786339
7.37197
0.92056
logger.warning("importing from legacy is experimental until official 1.0 release") filename = os.path.expanduser(filename) return io.load_legacy(filename, add_compute_legacy, add_compute_phoebe)
def from_legacy(cls, filename, add_compute_legacy=True, add_compute_phoebe=True)
Load a bundle from a PHOEBE 1.0 Legacy file. This is a constructor so should be called as: >>> b = Bundle.from_legacy('myfile.phoebe') :parameter str filename: relative or full path to the file :return: instantiated :class:`Bundle` object
5.410957
6.668587
0.81141
if not force_build and not conf.devel: b = cls.open(os.path.join(_bundle_cache_dir, 'default_star.bundle')) if starA != 'starA': b.rename_component('starA', starA) return b b = cls() # IMPORTANT NOTE: if changing any of the defaults...
def default_star(cls, starA='starA', force_build=False)
For convenience, this function is available at the top-level as <phoebe.default_star> as well as <phoebe.frontend.bundle.Bundle.default_star>. sun This is a constructor, so should be called as: >>> b = Bundle.default_binary() Arguments ----------- * `starA` (s...
10.651378
10.872824
0.979633
if not force_build and not conf.devel: if contact_binary: b = cls.open(os.path.join(_bundle_cache_dir, 'default_contact_binary.bundle')) else: b = cls.open(os.path.join(_bundle_cache_dir, 'default_binary.bundle')) secondary = 'seconda...
def default_binary(cls, starA='primary', starB='secondary', orbit='binary', contact_binary=False, force_build=False)
For convenience, this function is available at the top-level as <phoebe.default_binary> as well as <phoebe.frontend.bundle.Bundle.default_binary>. primary - secondary This is a constructor, so should be called as: >>> b = Bundle.default_binary() Arguments ----...
3.661016
3.44029
1.064159
if not conf.devel: raise NotImplementedError("'default_triple' not officially supported for this release. Enable developer mode to test.") b = cls() b.add_star(component=starA) b.add_star(component=starB) b.add_star(component=starC) b.add_orbit(comp...
def default_triple(cls, inner_as_primary=True, inner_as_overcontact=False, starA='starA', starB='starB', starC='starC', inner='inner', outer='outer', contact_envelope='contact_envelope')
Load a bundle with a default triple system. Set inner_as_primary based on what hierarchical configuration you want. inner_as_primary = True: starA - starB -- starC inner_as_primary = False: starC -- starA - starB This is a constructor, so should be called as: ...
4.256108
4.491623
0.947566
if clear_history: # TODO: let's not actually clear history, # but rather skip the context when saving self.remove_history() # TODO: add option for clear_models, clear_feedback # NOTE: PS.save will handle os.path.expanduser return super(Bundle...
def save(self, filename, clear_history=True, incl_uniqueid=False, compact=False)
Save the bundle to a JSON-formatted ASCII file. :parameter str filename: relative or full path to the file :parameter bool clear_history: whether to clear history log items before saving (default: True) :parameter bool incl_uniqueid: whether to including uniqueids in the ...
11.436285
12.772573
0.895378
logger.warning("exporting to legacy is experimental until official 1.0 release") filename = os.path.expanduser(filename) return io.pass_to_legacy(self, filename)
def export_legacy(self, filename)
TODO: add docs
9.28906
8.509773
1.091575