Planet orbits#

Planet orbits: the projected position of a planet on an elliptical orbit at a given time, and orbit plots.

The orbit is an ellipse with the star at a focus, r(theta) = a(1-e^2)/(1+e cos(theta)), with theta the true anomaly (theta = 0 at periapsis). It is rotated by the position angle pa in its plane and then inclined about the x axis, so the sky position is x = r cos(theta+pa), y = r sin(theta+pa) cos(inc). Lengths are in the unit of a (arcsec in the package).

toycoronagraph.planet.t_period_convert(t)[source]#

Convert a time value to its fractional part in the interval (0, 1].

Whole numbers of periods (including 0, up to np.isclose) map to 1.0 (the initial position), not to 0; negative times count back from the initial position (e.g. -0.3 -> 0.7).

Parameters:

t (float) – The input time, in units of the orbital period.

Returns:

The fractional part of the input time, in (0, 1]; 1.0 (after printing a message) if t is not an int/float.

Return type:

float

toycoronagraph.planet.planet_position(a, e, pa, inc, t, mode, res)[source]#

Calculate the position of a planet in an elliptical orbit at a given time.

Kepler’s second law: the swept area grows as the integral of r^2 dtheta, so the true anomaly at time t is where the cumulative sum of r^2 over res samples of theta in [0, 2 pi] reaches the fraction t of its total (linear interpolation between the two nearest samples). t = 1 (or any whole number of periods) is the periapsis.

Parameters:
  • a (float) – Semi-major axis of the orbit (arcsec).

  • e (float) – Eccentricity of the orbit, 0 <= e < 1.

  • pa (float) – Position angle of the orbit (degrees): rotation of the periapsis from +x in the orbital plane.

  • inc (float) – Inclination of the orbit (degrees), about the x axis (0 = face-on).

  • t (float) – Time in units of the orbital period (see t_period_convert).

  • mode (str) – Coordinate mode (“polar” or “cartesian”) for the output.

  • res (int) – Number of points used for orbit calculations.

Returns:

Planet’s projected position: (r in arcsec, angle in radian from +x towards +y) for “polar”, (x, y) in arcsec for “cartesian”; None (after printing a message) for any other mode.

Return type:

tuple or None

toycoronagraph.planet.orbit_position(a, e, pa, inc, res)[source]#

Calculate the Cartesian positions of points along an elliptical orbit.

Parameters:
  • a (float) – Semi-major axis of the orbit (arcsec).

  • e (float) – Eccentricity of the orbit, 0 <= e < 1.

  • pa (float) – Position angle of the orbit (degrees), see planet_position.

  • inc (float) – Inclination of the orbit (degrees), see planet_position.

  • res (int) – Number of points used for orbit calculations.

Returns:

orbit_x, orbit_y: (res,) float64 arrays of the projected x and y positions (arcsec), at true anomalies evenly spaced over [0, 2 pi] (first and last points coincide).

Return type:

tuple

toycoronagraph.planet.orbit_plot(a, e, pa, inc, planet_pos, plot_dpi, res, flip, mode, name='')[source]#

Plot the orbit of a planet around a star, save it to “oribit<name>.png” and show it.

Parameters:
  • a (float) – Semi-major axis of the orbit (arcsec).

  • e (float) – Eccentricity of the orbit, 0 <= e < 1.

  • pa (float) – Position angle of the orbit (degrees), see planet_position.

  • inc (float) – Inclination of the orbit (degrees), see planet_position.

  • planet_pos (tuple) – Planet’s position in the specified mode: (r arcsec, angle radian) for “polar”, (x, y) arcsec for “cartesian”.

  • plot_dpi (int) – Dots per inch (DPI) for the plot.

  • res (int) – Number of points used for orbit calculations.

  • flip (bool) – True: +y upwards (as Target’s images); False: the y axis turned over.

  • mode (str) – Coordinate mode of planet_pos (“polar” or “cartesian”); any other value prints a message and plots planet_pos as cartesian.

  • name (str) – Suffix of the saved plot file name.

Returns:

None. Saves “oribit”+name+”.png” in the current directory.