Util module

Function helpers.

poliastro.util.circular_velocity(k, a)

Compute circular velocity for a given body (k) and semimajor axis (a).

poliastro.util.rotate(vector, angle, axis='z')

Rotates a vector around axis a right-handed positive angle.

This is just a convenience function around astropy.coordinates.matrix_utilities.rotation_matrix().

Parameters
  • vector (Quantity) – Dimension 3 vector.

  • angle (Quantity) – Angle of rotation.

  • axis (str, optional) – Either ‘x’, ‘y’ or ‘z’.

Note

This performs a so-called active or alibi transformation: rotates the vector while the coordinate system remains unchanged. To do the opposite operation (passive or alias transformation) call the function as rotate(vec, ax, -angle, unit) or use the convenience function transform(), see 1.

References

1

http://en.wikipedia.org/wiki/Rotation_matrix#Ambiguities

poliastro.util.transform(vector, angle, axis='z')

Rotates a coordinate system around axis a positive right-handed angle.

Note

This is a convenience function, equivalent to rotate(vec, -angle, axis, unit). Refer to the documentation of rotate() for further information.

poliastro.util.norm(vec)

Norm of a Quantity vector that respects units.

Parameters

vec (Quantity) – Vector with units.

poliastro.util.time_range(start, *, periods=50, spacing=None, end=None, format=None, scale=None)

Generates range of astronomical times.

New in version 0.8.0.

Parameters
  • periods (int, optional) – Number of periods, default to 50.

  • spacing (Time or Quantity, optional) – Spacing between periods, optional.

  • end (Time or equivalent, optional) – End date.

Returns

Array of time values.

Return type

Time

poliastro.util.hyp_nu_limit(ecc, r_max_ratio=inf)

Limit true anomaly for hyperbolic orbits.

Parameters
  • ecc (Quantity) – Eccentricity, should be larger than 1.

  • r_max_ratio (float, optional) – Value of \(r_{\text{max}} / p\) for this angle, default to infinity.

poliastro.util.get_eccentricity_critical_argp(attractor, a, inc)

Calculates the eccentricity for frozen orbits when the argument of perigee is critical

Parameters
  • attractor (Body) – Main attractor.

  • a (Quantity) – Orbit’s semimajor axis

  • inc (Quantity, optional) – Inclination, default to critical value.

poliastro.util.get_inclination_critical_argp(attractor, a, ecc)

Calculates the inclination for frozen orbits when the argument of perigee is critical and the eccentricity is given

Parameters
  • attractor (Body) – Main attractor.

  • a (Quantity) – Orbit’s semimajor axis

  • ecc (Quantity, optional) – Eccentricity

poliastro.util.get_eccentricity_critical_inc(ecc=None)

Calculates the eccentricity when a frozen orbit has critical inclination

If ecc is None we set an arbitrary value which is the Moon ecc because it seems reasonable

Parameters

ecc (: ~astropy.units.Quantity, optional) – Eccentricity, or None if it was not defined

poliastro.util.find_closest_value(value, values)

Calculates the closest value in the given values :param value: :type value: ~astropy.units.Quantity :param values: :type values: ~astropy.units.Quantity